Kernel/aarch64: Move query_firmware_version into RPi::Mailbox

This is for the upcoming commit that merges the x86_64 and aarch64
init.cpp files.
This commit is contained in:
Timon Kruiper 2023-04-01 01:57:48 +02:00 committed by Andrew Kaster
parent 2613ac4cb4
commit 14d20618f1
Notes: sideshowbarker 2024-07-17 03:45:48 +09:00
3 changed files with 30 additions and 30 deletions

View file

@ -104,4 +104,30 @@ bool Mailbox::send_queue(void* queue, u32 queue_size) const
return true;
}
class QueryFirmwareVersionMboxMessage : RPi::Mailbox::Message {
public:
u32 version;
QueryFirmwareVersionMboxMessage()
: RPi::Mailbox::Message(0x0000'0001, 4)
{
version = 0;
}
};
u32 Mailbox::query_firmware_version()
{
struct __attribute__((aligned(16))) {
MessageHeader header;
QueryFirmwareVersionMboxMessage query_firmware_version;
MessageTail tail;
} message_queue;
if (!the().send_queue(&message_queue, sizeof(message_queue))) {
return 0xffff'ffff;
}
return message_queue.query_firmware_version.version;
}
}

View file

@ -49,6 +49,8 @@ public:
// Sends message queue to VideoCore
bool send_queue(void* queue, u32 queue_size) const;
u32 query_firmware_version();
};
}

View file

@ -47,8 +47,6 @@ READONLY_AFTER_INIT bool g_in_early_boot;
namespace Kernel {
static u32 query_firmware_version();
extern "C" [[noreturn]] void halt();
extern "C" [[noreturn]] void init();
@ -68,8 +66,8 @@ void init_stage2(void*)
{
Process::register_new(Process::current());
auto firmware_version = query_firmware_version();
dmesgln("Firmware version: {}", firmware_version);
auto firmware_version = RPi::Mailbox::the().query_firmware_version();
dmesgln("RPi: Firmware version: {}", firmware_version);
VirtualFileSystem::initialize();
@ -179,30 +177,4 @@ extern "C" [[noreturn]] void init()
VERIFY_NOT_REACHED();
}
class QueryFirmwareVersionMboxMessage : RPi::Mailbox::Message {
public:
u32 version;
QueryFirmwareVersionMboxMessage()
: RPi::Mailbox::Message(0x0000'0001, 4)
{
version = 0;
}
};
static u32 query_firmware_version()
{
struct __attribute__((aligned(16))) {
RPi::Mailbox::MessageHeader header;
QueryFirmwareVersionMboxMessage query_firmware_version;
RPi::Mailbox::MessageTail tail;
} message_queue;
if (!RPi::Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
return 0xffff'ffff;
}
return message_queue.query_firmware_version.version;
}
}