[app][uefi] Add configuration table
This commit is contained in:
31
lib/uefi/configuration_table.cpp
Normal file
31
lib/uefi/configuration_table.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "configuration_table.h"
|
||||
#include "boot_service_provider.h"
|
||||
#include "system_table.h"
|
||||
#include <string.h>
|
||||
|
||||
void setup_configuration_table(EfiSystemTable *table) {
|
||||
auto &rng = table->configuration_table[0];
|
||||
rng.vendor_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
|
||||
rng.vendor_table = alloc_page(PAGE_SIZE);
|
||||
auto rng_seed = reinterpret_cast<linux_efi_random_seed *>(rng.vendor_table);
|
||||
rng_seed->size = 512;
|
||||
memset(&rng_seed->bits, 0, rng_seed->size);
|
||||
table->number_of_table_entries = 1;
|
||||
}
|
||||
37
lib/uefi/configuration_table.h
Normal file
37
lib/uefi/configuration_table.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CONFIGURATION_TABLE_
|
||||
#define __CONFIGURATION_TABLE_
|
||||
|
||||
#include "system_table.h"
|
||||
#include "types.h"
|
||||
|
||||
struct linux_efi_random_seed {
|
||||
uint32_t size;
|
||||
uint8_t bits[];
|
||||
};
|
||||
|
||||
static constexpr auto LINUX_EFI_RANDOM_SEED_TABLE_GUID =
|
||||
EfiGuid{0x1ce1e5bc,
|
||||
0x7ceb,
|
||||
0x42f2,
|
||||
{0x81, 0xe5, 0x8a, 0xad, 0xf1, 0x80, 0xf5, 0x7b}};
|
||||
|
||||
void setup_configuration_table(EfiSystemTable *table);
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DEFER_HEADER_
|
||||
#define __DEFER_HEADER_
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "protocols/simple_text_output_protocol.h"
|
||||
#include "runtime_service.h"
|
||||
|
||||
typedef struct {
|
||||
struct EfiConfigurationTable {
|
||||
EfiGuid vendor_guid;
|
||||
const void* vendor_table;
|
||||
} EfiConfigurationTable;
|
||||
void *vendor_table;
|
||||
};
|
||||
|
||||
typedef struct EfiSystemTable {
|
||||
struct EfiSystemTable {
|
||||
EfiTableHeader header;
|
||||
char16_t* firmware_vendor;
|
||||
uint32_t firmware_revision;
|
||||
@@ -43,7 +43,7 @@ typedef struct EfiSystemTable {
|
||||
EfiRuntimeService *runtime_service;
|
||||
EfiBootService* boot_services;
|
||||
size_t number_of_table_entries;
|
||||
const EfiConfigurationTable* configuration_table;
|
||||
} EfiSystemTable;
|
||||
EfiConfigurationTable *configuration_table;
|
||||
};
|
||||
|
||||
#endif // __SYSTEM_TABLE_H__
|
||||
|
||||
@@ -12,5 +12,6 @@ MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/boot_service_provider.cpp \
|
||||
$(LOCAL_DIR)/runtime_service_provider.cpp \
|
||||
$(LOCAL_DIR)/switch_stack.S \
|
||||
$(LOCAL_DIR)/configuration_table.cpp \
|
||||
|
||||
include make/module.mk
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "arch/mmu.h"
|
||||
#include "boot_service.h"
|
||||
#include "boot_service_provider.h"
|
||||
@@ -11,11 +28,13 @@
|
||||
#include <lk/debug.h>
|
||||
#include <lk/err.h>
|
||||
#include <lk/trace.h>
|
||||
#include <math.h>
|
||||
#include <platform.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "configuration_table.h"
|
||||
#include "protocols/simple_text_output_protocol.h"
|
||||
#include "runtime_service.h"
|
||||
#include "runtime_service_provider.h"
|
||||
@@ -53,7 +72,7 @@ static constexpr size_t BIT10 = 1 << 10;
|
||||
@return Immediate address encoded in the instruction
|
||||
|
||||
**/
|
||||
uint16_t ThumbMovtImmediateAddress(uint16_t *Instruction) {
|
||||
uint16_t ThumbMovtImmediateAddress(const uint16_t *Instruction) {
|
||||
uint32_t Movt;
|
||||
uint16_t Address;
|
||||
|
||||
@@ -262,7 +281,7 @@ int load_sections_and_execute(bdev_t *dev,
|
||||
image_base + optional_header->AddressOfEntryPoint);
|
||||
printf("Entry function located at %p\n", entry);
|
||||
|
||||
EfiSystemTable table{};
|
||||
EfiSystemTable &table = *static_cast<EfiSystemTable *>(alloc_page(PAGE_SIZE));
|
||||
EfiBootService boot_service{};
|
||||
EfiRuntimeService runtime_service{};
|
||||
fill(&runtime_service, 0);
|
||||
@@ -274,8 +293,12 @@ int load_sections_and_execute(bdev_t *dev,
|
||||
table.header.signature = EFI_SYSTEM_TABLE_SIGNATURE;
|
||||
EfiSimpleTextOutputProtocol console_out = get_text_output_protocol();
|
||||
table.con_out = &console_out;
|
||||
constexpr size_t kStackSize = 1024ul * 1024;
|
||||
auto stack = reinterpret_cast<char *>(alloc_page(kStackSize, PAGE_SIZE));
|
||||
table.configuration_table =
|
||||
reinterpret_cast<EfiConfigurationTable *>(alloc_page(PAGE_SIZE));
|
||||
setup_configuration_table(&table);
|
||||
|
||||
constexpr size_t kStackSize = 8 * 1024ul * 1024;
|
||||
auto stack = reinterpret_cast<char *>(alloc_page(kStackSize, 23));
|
||||
memset(stack, 0, kStackSize);
|
||||
return call_with_stack(stack + kStackSize, entry, image_base, &table);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user