Fix: mbox output

This commit is contained in:
2025-03-11 17:52:11 +08:00
parent 73c9fc1423
commit bfcb951628
5 changed files with 70 additions and 21 deletions

View File

@@ -42,11 +42,9 @@ volatile unsigned int __attribute__((aligned(16))) mbox[36];
#define MAILBOX_BASE MMIO_BASE + 0xb880
#define REQUEST_CODE 0x00000000
#define REQUEST_SUCCEED 0x80000000
#define REQUEST_FAILED 0x80000001
#define TAG_REQUEST_CODE 0x00000000
#define END_TAG 0x00000000
#define TAG_MBOX_REQUEST 0x00000000
/**
* Make a mailbox call. Returns 0 on failure, non-zero on success
@@ -73,17 +71,55 @@ int mbox_call(unsigned char ch)
unsigned int get_board_revision(void)
{
mbox[0] = 36 * 4;
mbox[1] = REQUEST_CODE;
mbox[1] = MBOX_REQUEST;
// tags
mbox[2] = MBOX_TAG_BOARD_REVISION;
mbox[3] = 4;
mbox[4] = TAG_REQUEST_CODE;
mbox[4] = TAG_MBOX_REQUEST;
mbox[5] = 0; // value buffer
mbox[6] = END_TAG;
mbox[6] = MBOX_TAG_LAST;
mbox_call(MBOX_CH_PROP);
return mbox[5];
}
unsigned int get_memory_base_addr(void)
{
mbox[0] = 36 * 4;
mbox[1] = MBOX_REQUEST;
// tags
mbox[2] = MBOX_TAG_ARM_MEMORY;
mbox[3] = 8;
mbox[4] = 8;
mbox[5] = 0;
mbox[6] = 0;
mbox[7] = MBOX_TAG_LAST;
mbox_call(MBOX_CH_PROP);
return mbox[5];
}
unsigned int get_memory_size(void)
{
mbox[0] = 36 * 4;
mbox[1] = MBOX_REQUEST;
// tags
mbox[2] = MBOX_TAG_ARM_MEMORY;
mbox[3] = 8;
mbox[4] = 8;
mbox[5] = 0;
mbox[6] = 0;
mbox[7] = MBOX_TAG_LAST;
mbox_call(MBOX_CH_PROP);
return mbox[6];
}