Unit testing framework and devicetree framework refactoring (#50)
[lunaix-os.git] / lunaix-os / arch / x86 / hart.c
1 #include <lunaix/hart_state.h>
2 #include <lunaix/mm/vmm.h>
3 #include <klibc/string.h>
4
5 #include <asm/mempart.h>
6
7 bool
8 install_hart_transition(ptr_t vm_mnt, struct hart_transition* ht)
9 {
10     pte_t pte;
11     if (!vmm_lookupat(vm_mnt, ht->inject, &pte)) {
12         return false;
13     }
14
15     mount_page(PG_MOUNT_4, pte_paddr(pte));
16
17     ptr_t mount_inject = PG_MOUNT_4 + va_offset(ht->inject);
18     memcpy((void*)mount_inject, &ht->transfer, sizeof(ht->transfer));
19     
20     unmount_page(PG_MOUNT_4);
21     return true;
22 }