mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Move find_acpi_table to new hardware.cpp
This commit is contained in:
@@ -58,6 +58,7 @@ modules:
|
|||||||
- src/boot/main.cpp
|
- src/boot/main.cpp
|
||||||
- src/boot/console.cpp
|
- src/boot/console.cpp
|
||||||
- src/boot/error.cpp
|
- src/boot/error.cpp
|
||||||
|
- src/boot/hardware.cpp
|
||||||
- src/boot/memory.cpp
|
- src/boot/memory.cpp
|
||||||
- src/boot/utility.cpp
|
- src/boot/utility.cpp
|
||||||
|
|
||||||
|
|||||||
41
src/boot/hardware.cpp
Normal file
41
src/boot/hardware.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "hardware.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
namespace boot {
|
||||||
|
namespace hw {
|
||||||
|
|
||||||
|
void *
|
||||||
|
find_acpi_table(uefi::system_table *st)
|
||||||
|
{
|
||||||
|
status_line status(L"Searching for ACPI table");
|
||||||
|
|
||||||
|
// Find ACPI tables. Ignore ACPI 1.0 if a 2.0 table is found.
|
||||||
|
uintptr_t acpi1_table = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < st->number_of_table_entries; ++i) {
|
||||||
|
uefi::configuration_table *table = &st->configuration_table[i];
|
||||||
|
|
||||||
|
// If we find an ACPI 2.0 table, return it immediately
|
||||||
|
if (table->vendor_guid == uefi::vendor_guids::acpi2)
|
||||||
|
return table->vendor_table;
|
||||||
|
|
||||||
|
if (table->vendor_guid == uefi::vendor_guids::acpi1) {
|
||||||
|
// Mark a v1 table with the LSB high
|
||||||
|
acpi1_table = reinterpret_cast<uintptr_t>(table->vendor_table);
|
||||||
|
acpi1_table |= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!acpi1_table) {
|
||||||
|
error::raise(uefi::status::not_found, L"Could not find ACPI table");
|
||||||
|
} else if (acpi1_table & 1) {
|
||||||
|
status_line::warn(L"Only found ACPI 1.0 table");
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<void*>(acpi1_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace hw
|
||||||
|
} // namespace boot
|
||||||
15
src/boot/hardware.h
Normal file
15
src/boot/hardware.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <uefi/tables.h>
|
||||||
|
|
||||||
|
namespace boot {
|
||||||
|
namespace hw {
|
||||||
|
|
||||||
|
/// Find the ACPI table in the system configuration tables
|
||||||
|
/// and return a pointer to it. If only an ACPI 1.0 table is
|
||||||
|
/// available, the returned pointer will have its least
|
||||||
|
/// significant bit set to 1.
|
||||||
|
void * find_acpi_table(uefi::system_table *st);
|
||||||
|
|
||||||
|
} // namespace hw
|
||||||
|
} // namespace boot
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "hardware.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
#include "kernel_args.h"
|
#include "kernel_args.h"
|
||||||
@@ -83,37 +84,6 @@ detect_debug_mode(EFI_RUNTIME_SERVICES *run, kernel_args *header) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void *
|
|
||||||
find_acpi_table(uefi::system_table *st)
|
|
||||||
{
|
|
||||||
status_line status(L"Searching for ACPI table");
|
|
||||||
|
|
||||||
// Find ACPI tables. Ignore ACPI 1.0 if a 2.0 table is found.
|
|
||||||
uintptr_t acpi1_table = 0;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < st->number_of_table_entries; ++i) {
|
|
||||||
uefi::configuration_table *table = &st->configuration_table[i];
|
|
||||||
|
|
||||||
// If we find an ACPI 2.0 table, return it immediately
|
|
||||||
if (table->vendor_guid == uefi::vendor_guids::acpi2)
|
|
||||||
return table->vendor_table;
|
|
||||||
|
|
||||||
if (table->vendor_guid == uefi::vendor_guids::acpi1) {
|
|
||||||
// Mark a v1 table with the LSB high
|
|
||||||
acpi1_table = reinterpret_cast<uintptr_t>(table->vendor_table);
|
|
||||||
acpi1_table |= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!acpi1_table) {
|
|
||||||
error::raise(uefi::status::not_found, L"Could not find ACPI table");
|
|
||||||
} else if (acpi1_table & 1) {
|
|
||||||
status_line::warn(L"Only found ACPI 1.0 table");
|
|
||||||
}
|
|
||||||
|
|
||||||
return reinterpret_cast<void*>(acpi1_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
uefi::status
|
uefi::status
|
||||||
bootloader_main_uefi(uefi::system_table *st, console &con)
|
bootloader_main_uefi(uefi::system_table *st, console &con)
|
||||||
{
|
{
|
||||||
@@ -124,7 +94,7 @@ bootloader_main_uefi(uefi::system_table *st, console &con)
|
|||||||
|
|
||||||
memory::init_pointer_fixup(bs, rs);
|
memory::init_pointer_fixup(bs, rs);
|
||||||
|
|
||||||
void *acpi_table = find_acpi_table(st);
|
void *acpi_table = hw::find_acpi_table(st);
|
||||||
|
|
||||||
kernel::args::header *args = nullptr;
|
kernel::args::header *args = nullptr;
|
||||||
kernel::args::module *modules = nullptr;
|
kernel::args::module *modules = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user