#include <lunaix/types.h>
#include <sys-generic/bootmem.h>
-
-#define boot_text __attribute__((section(".boot.text")))
-#define boot_data __attribute__((section(".boot.data")))
-#define boot_bss __attribute__((section(".boot.bss")))
+#include <asm/boot_stage.h>
ptr_t
kremap();
+#include <lunaix/sections.h>
+#include <asm-generic/init_pagetable.h>
+#include <asm/boot_stage.h>
+
+#include "init.h"
+
+static pte_t kpt[LEVEL_SIZE][32];
+
+ptr_t
+kremap()
+{
+ struct pt_alloc alloc;
+ struct ptw_state ptw;
+ pte_t pte;
+ unsigned long nr;
+
+ init_pt_alloc(&alloc, to_kphysical(&kpt), sizeof(kpt));
+ init_ptw_state(&ptw, &alloc, kpt_alloc_table(&alloc));
+
+ pte = mkpte(boot_start, KERNEL_DATA);
+ pte = pte_mkexec(pte);
+ nr = leaf_count(boot_end - boot_start);
+ kpt_set_ptes(&ptw, boot_start, pte, LFT_SIZE, nr);
+
+ kpt_mktable_at(&ptw, VMAP, L0T_SIZE);
+ kpt_mktable_at(&ptw, PMAP, L2T_SIZE);
+ kpt_mktable_at(&ptw, KMAP, LFT_SIZE);
+
+ kpt_migrate_highmem(&ptw);
+
+ pte = mkpte(__ptr(ptw.root), KERNEL_PGTAB);
+ kpt_set_ptes(&ptw, VMS_SELF, pte, L0T_SIZE, 1);
+
+ return __ptr(ptw.root);
+}
\ No newline at end of file
+++ /dev/null
-#include "init.h"
-#include <lunaix/sections.h>
-#include <lunaix/spike.h>
-
-#define BOOTMEM_SIZE (4 * 4096)
-
-static reclaimable char bootmem_pool[BOOTMEM_SIZE];
-static unsigned int pos;
-
-void*
-bootmem_alloc(unsigned int size)
-{
- ptr_t res;
-
- res = __ptr(bootmem_pool) + pos;
-
- size = ROUNDUP(size, 4);
- pos += size;
-
- if (pos >= BOOTMEM_SIZE) {
- spin();
- }
-
- return (void*)res;
-}
-
-void
-bootmem_free(void* ptr)
-{
- // not need to support, as they are all one-shot
- return;
-}
\ No newline at end of file