From d6fb45e3b29df30e30ac400cfb8b030719207213 Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Thu, 29 Jan 2015 14:47:54 +1030 Subject: hw/ipmi: Disable flash access when requested BMC based systems contain a PNOR to provide flash storage. The host normally has exclusive access to the PNOR, however the BMC may use IPMI to request access to perform functions such as update the firmware. Indicate to users of the flash that the device is busy by taking the lock, and setting a per-flash busy flag, which causes flash operations to return OPAL_BUSY. Minor changes from Jeremy Kerr Signed-off-by: Joel Stanley Signed-off-by: Jeremy Kerr --- hw/ipmi/ipmi-sel.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'hw/ipmi/ipmi-sel.c') diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 173b7be..c86c2c9 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -41,6 +41,9 @@ #define SOFT_OFF 0x00 #define SOFT_REBOOT 0x01 +#define RELEASE_PNOR 0x00 +#define REQUEST_PNOR 0x01 + struct oem_sel { /* SEL header */ uint8_t id[2]; @@ -180,6 +183,33 @@ int ipmi_elog_commit(struct errorlog *elog_buf) return 0; } +#define ACCESS_DENIED 0x00 +#define ACCESS_GRANTED 0x01 + +static void sel_pnor(uint8_t access) +{ + struct ipmi_msg *msg; + uint8_t granted = ACCESS_GRANTED; + + switch (access) { + case REQUEST_PNOR: + prlog(PR_NOTICE, "IPMI: PNOR access requested\n"); + granted = flash_reserve(); + + /* Ack the request */ + msg = ipmi_mkmsg_simple(IPMI_PNOR_ACCESS_STATUS, &granted, 1); + ipmi_queue_msg(msg); + break; + case RELEASE_PNOR: + prlog(PR_NOTICE, "IPMI: PNOR access released\n"); + flash_release(); + break; + default: + prlog(PR_ERR, "IPMI: invalid PNOR access requested: %02x\n", + access); + } +} + static void sel_power(uint8_t power) { switch (power) { @@ -271,9 +301,11 @@ void ipmi_parse_sel(struct ipmi_msg *msg) sel_occ_reset(sel.data[0]); break; case CMD_AMI_PNOR_ACCESS: + sel_pnor(sel.data[0]); break; default: - printf("IPMI: unknown OEM SEL command %02x received\n", - sel.cmd); + prlog(PR_WARNING, + "IPMI: unknown OEM SEL command %02x received\n", + sel.cmd); } } -- cgit v1.1