提交 ba75772f 编写于 作者: M Mario Six

gdsys: cmd_ioloop: Introduce commenting enum

Replace the boolean parameter of io_check_status that controls whether
the status is printed or not with a documenting enum.
Signed-off-by: NMario Six <mario.six@gdsys.cc>
上级 db1d03a2
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
#include <gdsys_fpga.h> #include <gdsys_fpga.h>
enum status_print_type {
STATUS_LOUD = 0,
STATUS_SILENT = 1,
};
enum { enum {
STATE_TX_PACKET_BUILDING = BIT(0), STATE_TX_PACKET_BUILDING = BIT(0),
STATE_TX_TRANSMITTING = BIT(1), STATE_TX_TRANSMITTING = BIT(1),
...@@ -52,7 +57,7 @@ unsigned long long rx_ctr; ...@@ -52,7 +57,7 @@ unsigned long long rx_ctr;
unsigned long long tx_ctr; unsigned long long tx_ctr;
unsigned long long err_ctr; unsigned long long err_ctr;
static void io_check_status(uint fpga, u16 status, bool silent) static void io_check_status(uint fpga, u16 status, enum status_print_type type)
{ {
u16 mask = STATE_RX_DIST_ERR | STATE_RX_LENGTH_ERR | u16 mask = STATE_RX_DIST_ERR | STATE_RX_LENGTH_ERR |
STATE_RX_FRAME_CTR_ERR | STATE_RX_FCS_ERR | STATE_RX_FRAME_CTR_ERR | STATE_RX_FCS_ERR |
...@@ -66,7 +71,7 @@ static void io_check_status(uint fpga, u16 status, bool silent) ...@@ -66,7 +71,7 @@ static void io_check_status(uint fpga, u16 status, bool silent)
err_ctr++; err_ctr++;
FPGA_SET_REG(fpga, ep.rx_tx_status, status); FPGA_SET_REG(fpga, ep.rx_tx_status, status);
if (silent) if (type == STATUS_SILENT)
return; return;
if (status & STATE_RX_PACKET_DROPPED) if (status & STATE_RX_PACKET_DROPPED)
...@@ -193,7 +198,7 @@ int do_ioreflect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ...@@ -193,7 +198,7 @@ int do_ioreflect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
FPGA_GET_REG(fpga, top_interrupt, &top_int); FPGA_GET_REG(fpga, top_interrupt, &top_int);
FPGA_GET_REG(fpga, ep.rx_tx_status, &rx_tx_status); FPGA_GET_REG(fpga, ep.rx_tx_status, &rx_tx_status);
io_check_status(fpga, rx_tx_status, true); io_check_status(fpga, rx_tx_status, STATUS_SILENT);
if ((top_int & IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS) && if ((top_int & IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS) &&
(top_int & IRQ_CPU_TRANSMITBUFFER_FREE_STATUS)) (top_int & IRQ_CPU_TRANSMITBUFFER_FREE_STATUS))
io_reflect(fpga); io_reflect(fpga);
...@@ -260,7 +265,7 @@ int do_ioloop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ...@@ -260,7 +265,7 @@ int do_ioloop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
FPGA_GET_REG(fpga, top_interrupt, &top_int); FPGA_GET_REG(fpga, top_interrupt, &top_int);
FPGA_GET_REG(fpga, ep.rx_tx_status, &rx_tx_status); FPGA_GET_REG(fpga, ep.rx_tx_status, &rx_tx_status);
io_check_status(fpga, rx_tx_status, false); io_check_status(fpga, rx_tx_status, STATUS_LOUD);
if (top_int & IRQ_CPU_TRANSMITBUFFER_FREE_STATUS) if (top_int & IRQ_CPU_TRANSMITBUFFER_FREE_STATUS)
io_send(fpga, size); io_send(fpga, size);
if (top_int & IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS) if (top_int & IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册