mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
Kernel: Add query for VideoCore and ARM physical memory ranges
This commit is contained in:
parent
c2e24a2fa1
commit
9359e49383
2 changed files with 66 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
|
||||
#include <Kernel/Library/Panic.h>
|
||||
|
||||
namespace Kernel::RPi {
|
||||
|
||||
|
@ -171,4 +172,60 @@ StringView Mailbox::query_kernel_command_line(Bytes buffer)
|
|||
return StringView { (char const*)&message[5], response_length };
|
||||
}
|
||||
|
||||
class QueryARMMemoryMailboxMessage : RPi::Mailbox::Message {
|
||||
public:
|
||||
u32 base;
|
||||
u32 size;
|
||||
|
||||
QueryARMMemoryMailboxMessage()
|
||||
: RPi::Mailbox::Message(0x0001'0005, 8)
|
||||
{
|
||||
base = 0;
|
||||
size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
Mailbox::MemoryRange Mailbox::query_lower_arm_memory_range()
|
||||
{
|
||||
struct __attribute__((aligned(16))) {
|
||||
MessageHeader header;
|
||||
QueryARMMemoryMailboxMessage query_arm_memory;
|
||||
MessageTail tail;
|
||||
} message_queue;
|
||||
|
||||
if (!the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
PANIC("Failed to determine the available RAM range");
|
||||
}
|
||||
|
||||
return { message_queue.query_arm_memory.base, message_queue.query_arm_memory.size };
|
||||
}
|
||||
|
||||
class QueryVCMemoryMailboxMessage : RPi::Mailbox::Message {
|
||||
public:
|
||||
u32 base;
|
||||
u32 size;
|
||||
|
||||
QueryVCMemoryMailboxMessage()
|
||||
: RPi::Mailbox::Message(0x0001'0006, 8)
|
||||
{
|
||||
base = 0;
|
||||
size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
Mailbox::MemoryRange Mailbox::query_videocore_memory_range()
|
||||
{
|
||||
struct __attribute__((aligned(16))) {
|
||||
MessageHeader header;
|
||||
QueryVCMemoryMailboxMessage query_vc_memory;
|
||||
MessageTail tail;
|
||||
} message_queue;
|
||||
|
||||
if (!the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
PANIC("Failed to determine the VideoCore memory range");
|
||||
}
|
||||
|
||||
return { message_queue.query_vc_memory.base, message_queue.query_vc_memory.size };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,15 @@ public:
|
|||
|
||||
// Returns the kernel command line as a StringView into the given buffer.
|
||||
StringView query_kernel_command_line(Bytes buffer);
|
||||
|
||||
struct MemoryRange {
|
||||
u32 base;
|
||||
u32 size;
|
||||
};
|
||||
// Returns the RAM available to the CPU in the first 1GB of the physical address space.
|
||||
// FIXME: Remove in favor of parsing the device tree.
|
||||
MemoryRange query_lower_arm_memory_range();
|
||||
MemoryRange query_videocore_memory_range();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue