Skip to content

Commit

Permalink
smc: Implement read/write of SMC error code storage
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveMHz authored and mborgerson committed Feb 15, 2023
1 parent d0d3e7b commit d8fa50e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hw/xbox/smbus_xbox_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
#define SMC_REG_BOARDTEMP 0x0a
#define SMC_REG_TRAYEJECT 0x0c
#define SMC_REG_INTACK 0x0d
#define SMC_REG_ERROR_WRITE 0x0e
#define SMC_REG_ERROR_READ 0x0f
#define SMC_REG_INTSTATUS 0x11
#define SMC_REG_INTSTATUS_POWER 0x01
#define SMC_REG_INTSTATUS_TRAYCLOSED 0x02
Expand All @@ -102,6 +104,7 @@ typedef struct SMBusSMCDevice {
uint8_t avpack_reg;
uint8_t intstatus_reg;
uint8_t scratch_reg;
uint8_t error_reg;
} SMBusSMCDevice;

static void smc_quick_cmd(SMBusDevice *dev, uint8_t read)
Expand Down Expand Up @@ -137,6 +140,10 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len)
}
break;

case SMC_REG_ERROR_WRITE:
smc->error_reg = buf[0];
break;

case SMC_REG_SCRATCH:
smc->scratch_reg = buf[0];
break;
Expand Down Expand Up @@ -177,6 +184,9 @@ static uint8_t smc_receive_byte(SMBusDevice *dev)
case SMC_REG_AVPACK:
return smc->avpack_reg;

case SMC_REG_ERROR_READ:
return smc->error_reg;

case SMC_REG_INTSTATUS: {
uint8_t r = smc->intstatus_reg;
smc->intstatus_reg = 0; // FIXME: Confirm clear on read
Expand Down Expand Up @@ -252,6 +262,7 @@ static void smbus_smc_realize(DeviceState *dev, Error **errp)
smc->intstatus_reg = 0;
smc->scratch_reg = 0;
smc->cmd = 0;
smc->error_reg = 0;

if (object_property_get_bool(qdev_get_machine(), "short-animation", NULL)) {
smc->scratch_reg = SMC_REG_SCRATCH_SHORT_ANIMATION;
Expand Down

0 comments on commit d8fa50e

Please sign in to comment.