From 7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 25 Oct 2021 19:40:53 +0300 Subject: Some minor changes to virtual memory handling + Should start to think about how virtual memory should be handled efficiently, I'm sort of flailing around and not actually doing anything beneficial. The mapping system I've so far implemented _works_, but it's not good and I'm not happy with it. I might come back and fix/improve it, but I think I'll go ahead and do other things for a while, might give me a better overhead view of what the virtual memory system should do. + TODO: should probably document the memory layout I'm going with at the moment. --- include/apos/init.h | 13 ++++++----- include/apos/sizes.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/apos/vmem.h | 8 +++++++ 3 files changed, 77 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/apos/init.h b/include/apos/init.h index 05e24ba..2dd8a27 100644 --- a/include/apos/init.h +++ b/include/apos/init.h @@ -2,6 +2,7 @@ #define APOS_INIT_H #include +#include struct init_data_t { pm_t init_base; @@ -10,6 +11,9 @@ struct init_data_t { pm_t initrd_base; pm_t initrd_top; + pm_t pmap_base; + pm_t pmap_top; + pm_t fdt_base; pm_t fdt_top; @@ -17,12 +21,11 @@ struct init_data_t { pm_t stack_top; struct vm_branch_t *kernel_vm_base; + vm_t tmp_pte; - /* - TODO: is this necessary? - pm_t pmap_base; - pm_t pmap_top; - */ + size_t max_order; + size_t bits[10]; + size_t page_shift; }; #endif /* APOS_INIT_H */ diff --git a/include/apos/sizes.h b/include/apos/sizes.h index 58a68bc..392e122 100644 --- a/include/apos/sizes.h +++ b/include/apos/sizes.h @@ -1,6 +1,8 @@ #ifndef APOS_SIZES_H #define APOS_SIZES_H +#if defined(__ASSEMBLER__) + #define SZ_1 0x000000000001 #define SZ_2 0x000000000002 #define SZ_4 0x000000000004 @@ -56,4 +58,63 @@ #define SZ_256T 0x400000000000 #define SZ_512T 0x800000000000 +#else + +#define SZ_1 0x000000000001UL +#define SZ_2 0x000000000002UL +#define SZ_4 0x000000000004UL +#define SZ_8 0x000000000008UL +#define SZ_16 0x000000000010UL +#define SZ_32 0x000000000020UL +#define SZ_64 0x000000000040UL +#define SZ_128 0x000000000080UL +#define SZ_256 0x000000000100UL +#define SZ_512 0x000000000200UL + +#define SZ_1K 0x000000000400UL +#define SZ_2K 0x000000000800UL +#define SZ_4K 0x000000001000UL +#define SZ_8K 0x000000002000UL +#define SZ_16K 0x000000004000UL +#define SZ_32K 0x000000008000UL +#define SZ_64K 0x000000010000UL +#define SZ_128K 0x000000020000UL +#define SZ_256K 0x000000040000UL +#define SZ_512K 0x000000080000UL + +#define SZ_1M 0x000000100000UL +#define SZ_2M 0x000000200000UL +#define SZ_4M 0x000000400000UL +#define SZ_8M 0x000000800000UL +#define SZ_16M 0x000001000000UL +#define SZ_32M 0x000002000000UL +#define SZ_64M 0x000004000000UL +#define SZ_128M 0x000008000000UL +#define SZ_256M 0x000010000000UL +#define SZ_512M 0x000020000000UL + +#define SZ_1G 0x000040000000UL +#define SZ_2G 0x000080000000UL +#define SZ_4G 0x000100000000UL +#define SZ_8G 0x000200000000UL +#define SZ_16G 0x000400000000UL +#define SZ_32G 0x000800000000UL +#define SZ_64G 0x000400000000UL +#define SZ_128G 0x000800000000UL +#define SZ_256G 0x001000000000UL +#define SZ_512G 0x002000000000UL + +#define SZ_1T 0x004000000000UL +#define SZ_2T 0x008000000000UL +#define SZ_4T 0x010000000000UL +#define SZ_8T 0x020000000000UL +#define SZ_16T 0x040000000000UL +#define SZ_32T 0x080000000000UL +#define SZ_64T 0x100000000000UL +#define SZ_128T 0x200000000000UL +#define SZ_256T 0x400000000000UL +#define SZ_512T 0x800000000000UL + +#endif + #endif /* APOS_SIZES_H */ diff --git a/include/apos/vmem.h b/include/apos/vmem.h index d2dcedc..e72f783 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -28,4 +28,12 @@ vm_t map_vregion(struct vm_branch_t *branch, pm_t base, vm_t start, size_t size, uint8_t flags); void unmap_vregion(struct vm_branch_t *branch, vm_t start); +void init_vmem(struct vm_branch_t *branch, vm_t tmp_pte); + +#if defined(KERNEL) +void arch_init_vmem(struct vm_branch_t *branch, vm_t tmp_pte); +#else +struct vm_branch_t *arch_get_tmp_pte(struct vm_branch_t *branch); +#endif + #endif /* APOS_VMEM_H */ -- cgit v1.3