unittester: Implement status register and 0x00 "No-op" command
This commit is contained in:
@@ -95,8 +95,6 @@ This is how most commands will work.
|
|||||||
|
|
||||||
### 0x00: No-op
|
### 0x00: No-op
|
||||||
|
|
||||||
**TODO: IMPLEMENT ME!**
|
|
||||||
|
|
||||||
This does nothing, takes no input, and gives no output.
|
This does nothing, takes no input, and gives no output.
|
||||||
|
|
||||||
This is an easy way to reset the status to 0x04 (no command in flight, not waiting for reads or writes, and no errors).
|
This is an easy way to reset the status to 0x04 (no command in flight, not waiting for reads or writes, and no errors).
|
||||||
|
@@ -39,6 +39,20 @@ enum fsm2_value {
|
|||||||
UT_FSM2_WAIT_IOBASE_1,
|
UT_FSM2_WAIT_IOBASE_1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Status bit mask */
|
||||||
|
#define UT_STATUS_AWAITING_READ (1<<0)
|
||||||
|
#define UT_STATUS_AWAITING_WRITE (1<<1)
|
||||||
|
#define UT_STATUS_IDLE (1<<2)
|
||||||
|
#define UT_STATUS_UNSUPPORTED_CMD (1<<3)
|
||||||
|
|
||||||
|
/* Command list */
|
||||||
|
enum unittester_cmd {
|
||||||
|
UT_CMD_NOOP = 0x00,
|
||||||
|
UT_CMD_CAPTURE_SCREEN_SNAPSHOT = 0x01,
|
||||||
|
UT_CMD_READ_SCREEN_SNAPSHOT_RECTANGLE = 0x02,
|
||||||
|
UT_CMD_VERIFY_SCREEN_SNAPSHOT_RECTANGLE = 0x03,
|
||||||
|
};
|
||||||
|
|
||||||
struct unittester_state {
|
struct unittester_state {
|
||||||
/* I/O port settings */
|
/* I/O port settings */
|
||||||
uint16_t trigger_port;
|
uint16_t trigger_port;
|
||||||
@@ -50,6 +64,10 @@ struct unittester_state {
|
|||||||
/* FSM2: IOBASE port selection, once trigger is activated */
|
/* FSM2: IOBASE port selection, once trigger is activated */
|
||||||
enum fsm2_value fsm2;
|
enum fsm2_value fsm2;
|
||||||
uint16_t fsm2_new_iobase;
|
uint16_t fsm2_new_iobase;
|
||||||
|
|
||||||
|
/* Runtime state */
|
||||||
|
uint8_t status;
|
||||||
|
enum unittester_cmd cmd_id;
|
||||||
};
|
};
|
||||||
static struct unittester_state unittester;
|
static struct unittester_state unittester;
|
||||||
static const struct unittester_state unittester_defaults = {
|
static const struct unittester_state unittester_defaults = {
|
||||||
@@ -57,6 +75,7 @@ static const struct unittester_state unittester_defaults = {
|
|||||||
.iobase_port = 0xFFFF,
|
.iobase_port = 0xFFFF,
|
||||||
.fsm1 = UT_FSM1_WAIT_8,
|
.fsm1 = UT_FSM1_WAIT_8,
|
||||||
.fsm2 = UT_FSM2_IDLE,
|
.fsm2 = UT_FSM2_IDLE,
|
||||||
|
.status = UT_STATUS_IDLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FIXME TEMPORARY --GM */
|
/* FIXME TEMPORARY --GM */
|
||||||
@@ -85,8 +104,22 @@ unittester_write(uint16_t port, uint8_t val, UNUSED(void *priv))
|
|||||||
{
|
{
|
||||||
if (port == unittester.iobase_port+0x00) {
|
if (port == unittester.iobase_port+0x00) {
|
||||||
/* Command port */
|
/* Command port */
|
||||||
/* TODO! --GM */
|
|
||||||
unittester_log("[UT] W %02X Command\n", val);
|
unittester_log("[UT] W %02X Command\n", val);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
/* 0x00: No-op */
|
||||||
|
case UT_CMD_NOOP:
|
||||||
|
unittester.cmd_id = UT_CMD_NOOP;
|
||||||
|
unittester.status = UT_STATUS_IDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Unsupported command - terminate here */
|
||||||
|
default:
|
||||||
|
unittester.cmd_id = UT_CMD_NOOP;
|
||||||
|
unittester.status = UT_STATUS_IDLE | UT_STATUS_UNSUPPORTED_CMD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (port == unittester.iobase_port+0x01) {
|
} else if (port == unittester.iobase_port+0x01) {
|
||||||
/* Data port */
|
/* Data port */
|
||||||
/* TODO! --GM */
|
/* TODO! --GM */
|
||||||
@@ -101,14 +134,13 @@ unittester_read(uint16_t port, UNUSED(void *priv))
|
|||||||
{
|
{
|
||||||
if (port == unittester.iobase_port+0x00) {
|
if (port == unittester.iobase_port+0x00) {
|
||||||
/* Status port */
|
/* Status port */
|
||||||
/* TODO! --GM */
|
unittester_log("[UT] R -- Status = %02X\n", unittester.status);
|
||||||
unittester_log("[UT] R -- Status\n");
|
return unittester.status;
|
||||||
return 0x04;
|
|
||||||
} else if (port == unittester.iobase_port+0x01) {
|
} else if (port == unittester.iobase_port+0x01) {
|
||||||
/* Data port */
|
/* Data port */
|
||||||
/* TODO! --GM */
|
|
||||||
unittester_log("[UT] R -- Data\n");
|
unittester_log("[UT] R -- Data\n");
|
||||||
return 0xFE;
|
/* TODO! --GM */
|
||||||
|
return 0xFF;
|
||||||
} else {
|
} else {
|
||||||
/* Not handled here - possibly open bus! */
|
/* Not handled here - possibly open bus! */
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
|
Reference in New Issue
Block a user