Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-NXP93-ELE-events-fetch #363

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm64/src/imx9/hardware/imx9_ele.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#define AHAB_RESP_TAG 0xe1
#define ELE_RELEASE_RDC_REQ 0xc4
#define ELE_READ_FUSE_REQ 0x97
#define ELE_GET_EVENTS 0xa2
#define ELE_DERIVE_KEY_REQ 0xa9
#define ELE_FWD_LIFECYCLE_UP 0x95
#define ELE_OK 0xd6

#define ELE_MU_TCR (IMX9_S3MUA_BASE+ 0x120)
Expand All @@ -50,6 +52,8 @@
#define ELE_MU_TR(i) (IMX9_S3MUA_BASE + 0x200 + (i) * 4)
#define ELE_MU_RR(i) (IMX9_S3MUA_BASE + 0x280 + (i) * 4)

#define FSB_LC_REG 0x4751041cUL

struct ele_header_t
{
union
Expand Down
58 changes: 58 additions & 0 deletions arch/arm64/src/imx9/imx9_ele.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,61 @@ int imx9_ele_get_key(uint8_t *key, size_t key_size,
return -EIO;
}

int imx9_ele_get_events(uint32_t *buffer, size_t buffer_size)
{
size_t events_num;
size_t i;

msg.header.version = AHAB_VERSION;
msg.header.tag = AHAB_CMD_TAG;
msg.header.size = 1;
msg.header.command = ELE_GET_EVENTS;

imx9_ele_sendmsg(&msg);
imx9_ele_receivemsg(&msg);

if ((msg.data[0] & 0xff) == ELE_OK)
{
events_num = msg.data[1] & 0xffff;
if (buffer)
{
for (i = 0; (i < buffer_size) && (i < events_num); i++)
{
buffer[i] = msg.data[i + 2];
}

return (int)i;
}
else
{
return (int)events_num;
}
}

return -EIO;
}

int imx9_ele_close_device(void)
{
msg.header.version = AHAB_VERSION;
msg.header.tag = AHAB_CMD_TAG;
msg.header.size = 2;
msg.header.command = ELE_FWD_LIFECYCLE_UP;
msg.data[0] = 0x08;

imx9_ele_sendmsg(&msg);
imx9_ele_receivemsg(&msg);

if ((msg.data[0] & 0xff) == ELE_OK)
{
return 0;
}

return -EIO;
}

uint32_t imx9_ele_get_lifecycle(void)
{
return (getreg32(FSB_LC_REG) & 0x3ff);
}

50 changes: 50 additions & 0 deletions arch/arm64/src/imx9/imx9_ele.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,54 @@ uint32_t imx9_ele_read_common_fuse(uint32_t fuse_id);
int imx9_ele_get_key(uint8_t *key, size_t key_size,
uint8_t *ctx, size_t ctx_size);

/****************************************************************************
* Name: imx9_ele_get_events
*
* Description:
* Trusted Resource Domain Controller AHAB interface. This function
* communicates with the Advanced High Assurance Boot (AHAB) image that
* should reside in the particular address. This returns ELE events.
*
* Input Parameters:
* buffer - Event buffer
* buffer_size - Event buffer size
*
* Returned Value:
* Zero (OK) is returned if no envents success. A negated errno value
* is returned on failure. Positive value is number of events read.
*
****************************************************************************/

int imx9_ele_get_events(uint32_t *buffer, size_t buffer_size);

/****************************************************************************
* Name: imx9_ele_close_device
*
* Description:
* Trusted Resource Domain Controller AHAB interface. This function
* communicates with the Advanced High Assurance Boot (AHAB) image that
* should reside in the particular address. This sets device to
* OEM close state. This operation is irreversible.
*
* Returned Value:
* Zero (OK) is returned if no envents success. A negated errno value
* is returned on failure.
*
****************************************************************************/

int imx9_ele_close_device(void);

/****************************************************************************
* Name: imx9_ele_get_lifecycle
*
* Description:
* This returns devices lifecycle value
*
* Returned Value:
* Lifecycle value
*
****************************************************************************/

uint32_t imx9_ele_get_lifecycle(void);

#endif /* __ARCH_ARM64_SRC_IMX9_IMX9_ELE_H */
Loading