Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Nov 11, 2024
1 parent 79ff6e9 commit d57533a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/kernel/include/memory/firstfit_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FirstFitAllocator : public AllocatorBase {
klog::Err("addr not aligned. 0x%lX\n", addr);
throw;
}
printf("%s: 0x%p(0x%X pages) init.\n", name_, addr_, length_);
printf("%s: 0x%p(0x%lX pages) init.\n", name_, (void *)addr_, length_);
}

/// @name 构造/析构函数
Expand Down
34 changes: 34 additions & 0 deletions src/kernel/virtual_memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,25 @@
VirtualMemoryManager::VirtualMemoryManager(uint32_t, uint8_t*) {
// 分配一页用于保存页目录
pt_t pgd_kernel = (pt_t)AllocKernelPage();
auto old_pgd_kernel = GetPageDirectory();
// 0x7C02023
// 0x530001
// memcpy(pgd_kernel, old_pgd_kernel, 1024);
memset(pgd_kernel, 0, PhysicalMemoryManager::kPageSize);
for (auto i = 0; i < 1024; i++) {
if (!pgd_kernel[i]) {
continue;
}
klog::Debug("first pgd_kernel[%d]: 0x%X\n", i, pgd_kernel[i]);
uint64_t* pte = ((uint64_t*)pgd_kernel[i]);

for (auto j = 0; j < 1024; j++) {
if (!pte[j]) {
continue;
}
klog::Debug("first pte[%d]: 0x%X\n", j, pte[j]);
}
}
// 映射内核空间
for (uint64_t addr = kBasicInfo.GetInstance().kernel_addr;
addr < kBasicInfo.GetInstance().kernel_addr + kKernelSpaceSize;
Expand All @@ -36,6 +54,22 @@ VirtualMemoryManager::VirtualMemoryManager(uint32_t, uint8_t*) {
cpu::vmm::VMM_PAGE_READABLE | cpu::vmm::VMM_PAGE_WRITABLE |
cpu::vmm::VMM_PAGE_EXECUTABLE);
}

for (auto i = 0; i < 1024; i++) {
if (!pgd_kernel[i]) {
continue;
}
klog::Debug("last pgd_kernel[%d]: 0x%X\n", i, pgd_kernel[i]);
uint64_t* pte = ((uint64_t*)pgd_kernel[i]);

for (auto j = 0; j < 1024; j++) {
if (!pte[j]) {
continue;
}
klog::Debug("last pte[%d]: 0x%X\n", j, pte[j]);
}
}

// 设置页目录
klog::Debug("SetPageDirectory: 0x%X\n", pgd_kernel);
SetPageDirectory(pgd_kernel);
Expand Down

0 comments on commit d57533a

Please sign in to comment.