soc/intel/common/cse: Add argument for CSE fixed client addr

There are multiple HECI clients in the CSE. heci_send_receive() is
sending HECI messages to only the MKHI client. Add an argument to
heci_send_receive() function to provide flexibility to the caller to
select the client for which the message is intended.
With the above change heci_send() and heci_receive() functions are
no longer required to be exposed.

In the follow-up patches there will be messages sent to one other
client.

BUG=None
BRANCH=None
TEST=Build and boot brya. HECI message send and receive to MKHI client
is working. Also, MEI BUS message to disable bus is working.

Signed-off-by: Rizwan Qureshi <rizwan.qureshi@intel.com>
Change-Id: Icde6d0155b62472b6a7caadc5fc8ea2e2ba6eb0c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57295
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Rizwan Qureshi
2021-08-30 16:43:57 +05:30
committed by Felix Held
parent 92db5d734c
commit 957857de6a
5 changed files with 38 additions and 49 deletions

View File

@@ -44,7 +44,6 @@ static enum fuse_flash_state {
static int read_cse_file(const char *path, void *buff, size_t *size, static int read_cse_file(const char *path, void *buff, size_t *size,
size_t offset, uint32_t flags) size_t offset, uint32_t flags)
{ {
int res;
size_t reply_size; size_t reply_size;
struct mca_command { struct mca_command {
@@ -77,18 +76,10 @@ static int read_cse_file(const char *path, void *buff, size_t *size,
msg.data_size = *size; msg.data_size = *size;
msg.offset = offset; msg.offset = offset;
res = heci_send(&msg, sizeof(msg), BIOS_HOST_ADDR, HECI_MKHI_ADDR);
if (!res) {
printk(BIOS_ERR, "failed to send HECI message\n");
return 0;
}
reply_size = sizeof(rmsg); reply_size = sizeof(rmsg);
res = heci_receive(&rmsg, &reply_size);
if (!res) { if (!heci_send_receive(&msg, sizeof(msg), &rmsg, &reply_size, HECI_MKHI_ADDR)) {
printk(BIOS_ERR, "failed to receive HECI reply\n"); printk(BIOS_ERR, "HECI: Failed to read file\n");
return 0; return 0;
} }

View File

@@ -384,7 +384,12 @@ send_one_message(uint32_t hdr, const void *buff)
return pend_len; return pend_len;
} }
int /*
* Send message msg of size len to host from host_addr to cse_addr.
* Returns 1 on success and 0 otherwise.
* In case of error heci_reset() may be required.
*/
static int
heci_send(const void *msg, size_t len, uint8_t host_addr, uint8_t client_addr) heci_send(const void *msg, size_t len, uint8_t host_addr, uint8_t client_addr)
{ {
uint8_t retry; uint8_t retry;
@@ -487,7 +492,15 @@ recv_one_message(uint32_t *hdr, void *buff, size_t maxlen)
return recv_len; return recv_len;
} }
int heci_receive(void *buff, size_t *maxlen) /*
* Receive message into buff not exceeding maxlen. Message is considered
* successfully received if a 'complete' indication is read from ME side
* and there was enough space in the buffer to fit that message. maxlen
* is updated with size of message that was received. Returns 0 on failure
* and 1 on success.
* In case of error heci_reset() may be required.
*/
static int heci_receive(void *buff, size_t *maxlen)
{ {
uint8_t retry; uint8_t retry;
size_t left, received; size_t left, received;
@@ -533,9 +546,10 @@ int heci_receive(void *buff, size_t *maxlen)
return 0; return 0;
} }
int heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg, size_t *rcv_sz) int heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg, size_t *rcv_sz,
uint8_t cse_addr)
{ {
if (!heci_send(snd_msg, snd_sz, BIOS_HOST_ADDR, HECI_MKHI_ADDR)) { if (!heci_send(snd_msg, snd_sz, BIOS_HOST_ADDR, cse_addr)) {
printk(BIOS_ERR, "HECI: send Failed\n"); printk(BIOS_ERR, "HECI: send Failed\n");
return 0; return 0;
} }
@@ -663,7 +677,8 @@ static int cse_request_reset(enum rst_req_type rst_type)
if (rst_type == CSE_RESET_ONLY) if (rst_type == CSE_RESET_ONLY)
status = heci_send(&msg, sizeof(msg), BIOS_HOST_ADDR, HECI_MKHI_ADDR); status = heci_send(&msg, sizeof(msg), BIOS_HOST_ADDR, HECI_MKHI_ADDR);
else else
status = heci_send_receive(&msg, sizeof(msg), &reply, &reply_size); status = heci_send_receive(&msg, sizeof(msg), &reply, &reply_size,
HECI_MKHI_ADDR);
printk(BIOS_DEBUG, "HECI: Global Reset %s!\n", status ? "success" : "failure"); printk(BIOS_DEBUG, "HECI: Global Reset %s!\n", status ? "success" : "failure");
return status; return status;
@@ -733,7 +748,7 @@ int cse_hmrfpo_enable(void)
} }
if (!heci_send_receive(&msg, sizeof(struct hmrfpo_enable_msg), if (!heci_send_receive(&msg, sizeof(struct hmrfpo_enable_msg),
&resp, &resp_size)) &resp, &resp_size, HECI_MKHI_ADDR))
return 0; return 0;
if (resp.hdr.result) { if (resp.hdr.result) {
@@ -782,7 +797,7 @@ int cse_hmrfpo_get_status(void)
} }
if (!heci_send_receive(&msg, sizeof(struct hmrfpo_get_status_msg), if (!heci_send_receive(&msg, sizeof(struct hmrfpo_get_status_msg),
&resp, &resp_size)) { &resp, &resp_size, HECI_MKHI_ADDR)) {
printk(BIOS_ERR, "HECI: HMRFPO send/receive fail\n"); printk(BIOS_ERR, "HECI: HMRFPO send/receive fail\n");
return -1; return -1;
} }
@@ -847,7 +862,8 @@ void print_me_fw_version(void *unused)
heci_reset(); heci_reset();
if (!heci_send_receive(&fw_ver_msg, sizeof(fw_ver_msg), &resp, &resp_size)) if (!heci_send_receive(&fw_ver_msg, sizeof(fw_ver_msg), &resp, &resp_size,
HECI_MKHI_ADDR))
goto fail; goto fail;
if (resp.hdr.result) if (resp.hdr.result)

View File

@@ -33,16 +33,10 @@ static bool cse_disable_mei_bus(void)
uint8_t reserved[2]; uint8_t reserved[2];
} __packed reply = {}; } __packed reply = {};
/* This is sent to the MEI client endpoint, not the MKHI endpoint */
int ret = heci_send(&msg, sizeof(msg), BIOS_HOST_ADDR, HECI_MEI_ADDR);
if (!ret) {
printk(BIOS_ERR, "HECI: Failed to send MEI bus disable command!\n");
return false;
}
size_t reply_sz = sizeof(reply); size_t reply_sz = sizeof(reply);
if (!heci_receive(&reply, &reply_sz)) {
printk(BIOS_ERR, "HECI: Failed to receive a reply from CSE\n"); if (!heci_send_receive(&msg, sizeof(msg), &reply, &reply_sz, HECI_MEI_ADDR)) {
printk(BIOS_ERR, "HECI: Failed to Disable MEI bus\n");
return false; return false;
} }
@@ -112,7 +106,7 @@ static enum cse_eop_result cse_send_eop(void)
printk(BIOS_INFO, "HECI: Sending End-of-Post\n"); printk(BIOS_INFO, "HECI: Sending End-of-Post\n");
if (!heci_send_receive(&msg, sizeof(msg), &resp, &resp_size)) { if (!heci_send_receive(&msg, sizeof(msg), &resp, &resp_size, HECI_MKHI_ADDR)) {
printk(BIOS_ERR, "HECI: EOP send/receive fail\n"); printk(BIOS_ERR, "HECI: EOP send/receive fail\n");
return CSE_EOP_RESULT_ERROR; return CSE_EOP_RESULT_ERROR;
} }

View File

@@ -202,7 +202,8 @@ static bool cse_get_bp_info(struct get_bp_info_rsp *bp_info_rsp)
size_t resp_size = sizeof(struct get_bp_info_rsp); size_t resp_size = sizeof(struct get_bp_info_rsp);
if (!heci_send_receive(&info_req, sizeof(info_req), bp_info_rsp, &resp_size)) { if (!heci_send_receive(&info_req, sizeof(info_req), bp_info_rsp, &resp_size,
HECI_MKHI_ADDR)) {
printk(BIOS_ERR, "cse_lite: Could not get partition info\n"); printk(BIOS_ERR, "cse_lite: Could not get partition info\n");
return false; return false;
} }
@@ -254,7 +255,8 @@ static bool cse_set_next_boot_partition(enum boot_partition_id bp)
struct mkhi_hdr switch_resp; struct mkhi_hdr switch_resp;
size_t sw_resp_sz = sizeof(struct mkhi_hdr); size_t sw_resp_sz = sizeof(struct mkhi_hdr);
if (!heci_send_receive(&switch_req, sizeof(switch_req), &switch_resp, &sw_resp_sz)) if (!heci_send_receive(&switch_req, sizeof(switch_req), &switch_resp, &sw_resp_sz,
HECI_MKHI_ADDR))
return false; return false;
if (switch_resp.result) { if (switch_resp.result) {
@@ -291,7 +293,7 @@ static bool cse_data_clear_request(const struct cse_bp_info *cse_bp_info)
size_t data_clr_rsp_sz = sizeof(data_clr_rsp); size_t data_clr_rsp_sz = sizeof(data_clr_rsp);
if (!heci_send_receive(&data_clr_rq, sizeof(data_clr_rq), &data_clr_rsp, if (!heci_send_receive(&data_clr_rq, sizeof(data_clr_rq), &data_clr_rsp,
&data_clr_rsp_sz)) { &data_clr_rsp_sz, HECI_MKHI_ADDR)) {
return false; return false;
} }

View File

@@ -130,29 +130,15 @@ enum csme_failure_reason {
/* set up device for use in early boot enviroument with temp bar */ /* set up device for use in early boot enviroument with temp bar */
void heci_init(uintptr_t bar); void heci_init(uintptr_t bar);
/*
* Receive message into buff not exceeding maxlen. Message is considered
* successfully received if a 'complete' indication is read from ME side
* and there was enough space in the buffer to fit that message. maxlen
* is updated with size of message that was received. Returns 0 on failure
* and 1 on success.
* In case of error heci_reset() may be requiered.
*/
int heci_receive(void *buff, size_t *maxlen);
/*
* Send message msg of size len to host from host_addr to cse_addr.
* Returns 1 on success and 0 otherwise.
* In case of error heci_reset() may be requiered.
*/
int
heci_send(const void *msg, size_t len, uint8_t host_addr, uint8_t cse_addr);
/* /*
* Send message from BIOS_HOST_ADDR to cse_addr.
* Sends snd_msg of size snd_sz, and reads message into buffer pointed by * Sends snd_msg of size snd_sz, and reads message into buffer pointed by
* rcv_msg of size rcv_sz * rcv_msg of size rcv_sz
* Returns 0 on failure and 1 on success. * Returns 0 on failure and 1 on success.
*/ */
int heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg, size_t *rcv_sz); int heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg, size_t *rcv_sz,
uint8_t cse_addr);
/* /*
* Attempt device reset. This is useful and perhaps only thing left to do when * Attempt device reset. This is useful and perhaps only thing left to do when