diff options
author | dzwdz | 2022-07-17 14:39:45 +0200 |
---|---|---|
committer | dzwdz | 2022-07-17 14:39:45 +0200 |
commit | 51cbabd0f40b041fa00203266afa046d14e88b22 (patch) | |
tree | 75022bc959b32e72876dfe3449faecac6feb5caa /src/kernel/arch/amd64/32/paging.c | |
parent | 4c10db944ca18c8001848c7e4e8ef51876bbe094 (diff) |
amd64: remove dead code, combine shared code
Diffstat (limited to 'src/kernel/arch/amd64/32/paging.c')
-rw-r--r-- | src/kernel/arch/amd64/32/paging.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/kernel/arch/amd64/32/paging.c b/src/kernel/arch/amd64/32/paging.c index ef65ccf..f33168d 100644 --- a/src/kernel/arch/amd64/32/paging.c +++ b/src/kernel/arch/amd64/32/paging.c @@ -1,65 +1,34 @@ -#include <stddef.h> -#include <stdint.h> - -struct page_generic { - uint64_t present : 1; - uint64_t writeable : 1; - uint64_t user : 1; - uint64_t writethru : 1; - - uint64_t uncached : 1; - uint64_t accessed : 1; - uint64_t dirty : 1; - uint64_t large : 1; // also PAT - - uint64_t global : 1; // TODO enable CR4.PGE - uint64_t _unused2 : 2; - uint64_t _unused3 : 1; // HLAT - - uint64_t address : 40; - - uint64_t _unused4 : 7; - uint64_t pke : 4; - uint64_t noexec : 1; -} __attribute__((packed)); +#include <kernel/arch/amd64/32/util.h> +#include <kernel/arch/amd64/paging.h> __attribute__((aligned(4096))) -struct page_generic pml4_identity[512]; +pe_generic_t pml4_identity[512]; __attribute__((aligned(4096))) -struct page_generic pdpte_low[512]; // 0-512gb +static pe_generic_t pdpte_low[512]; // 0-512gb __attribute__((aligned(4096))) -struct page_generic pde_low[512]; // 0-1gb - - -static void *memset32(void *s, int c, size_t n) { - uint8_t *s2 = s; - for (size_t i = 0; i < n; i++) - s2[i] = c; - return s; -} - +static pe_generic_t pde_low[512]; // 0-1gb void pml4_identity_init(void) { memset32(pml4_identity, 0, sizeof pml4_identity); memset32(pdpte_low, 0, sizeof pdpte_low); memset32(pde_low, 0, sizeof pde_low); - pml4_identity[0] = (struct page_generic) { + pml4_identity[0] = (pe_generic_t) { .present = 1, .writeable = 1, .address = ((uintptr_t)pdpte_low) >> 12, }; - pdpte_low[0] = (struct page_generic) { + pdpte_low[0] = (pe_generic_t) { .present = 1, .writeable = 1, .address = ((uintptr_t)pde_low) >> 12, }; for (int i = 0; i < 512; i++) { - pde_low[i] = (struct page_generic) { + pde_low[i] = (pe_generic_t) { .present = 1, .writeable = 1, .large = 1, |