Skip to content

Commit

Permalink
Merge branch 'boot' into new_intr
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Jul 8, 2024
2 parents 8e070a8 + 08a067f commit 2e2eaad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kernel/arch/riscv64/arch_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C" void *end[];
BasicInfo::BasicInfo(uint32_t argc, uint8_t *argv) {
(void)argc;
(void)argv;

auto [memory_base, memory_size] = kKernelFdt.GetInstance().GetMemory();
physical_memory_addr = memory_base;
physical_memory_size = memory_size;
Expand All @@ -46,6 +47,8 @@ BasicInfo::BasicInfo(uint32_t argc, uint8_t *argv) {
reinterpret_cast<uint64_t>(__executable_start);
elf_addr = 0;
elf_size = 0;

fdt_addr = reinterpret_cast<uint64_t>(argv);
}

uint32_t ArchInit(uint32_t argc, uint8_t *argv) {
Expand Down
5 changes: 5 additions & 0 deletions src/kernel/arch/x86_64/arch_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ extern "C" void *__executable_start[];
extern "C" void *end[];
BasicInfo::BasicInfo(uint32_t argc, uint8_t *argv) {
(void)argc;

auto basic_info = *reinterpret_cast<BasicInfo *>(argv);
physical_memory_addr = basic_info.physical_memory_addr;
physical_memory_size = basic_info.physical_memory_size;

kernel_addr = reinterpret_cast<uint64_t>(__executable_start);
kernel_size = reinterpret_cast<uint64_t>(end) -
reinterpret_cast<uint64_t>(__executable_start);

elf_addr = basic_info.elf_addr;
elf_size = basic_info.elf_size;

fdt_addr = 0;
}

uint32_t ArchInit(uint32_t argc, uint8_t *argv) {
Expand Down
4 changes: 4 additions & 0 deletions src/kernel/include/basic_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct BasicInfo {
/// elf 大小
size_t elf_size;

/// fdt 地址
uint64_t fdt_addr;

/**
* 构造函数,在 arch_main.cpp 中定义
* @param argc 同 _start
Expand All @@ -65,6 +68,7 @@ struct BasicInfo {
basic_info.kernel_size);
printf("elf_addr: 0x%X, size 0x%X\n", basic_info.elf_addr,
basic_info.elf_size);
printf("fdt_addr: 0x%X\n", basic_info.fdt_addr);
return os;
}
};
Expand Down

0 comments on commit 2e2eaad

Please sign in to comment.