2020-07-22 19:46:57 -05:00
|
|
|
#include "cpu/paging.h"
|
|
|
|
#include "cpu/arch_consts.h"
|
2019-05-05 13:03:14 -05:00
|
|
|
|
2019-05-06 08:35:59 -05:00
|
|
|
void address_spaces_copy_data(void* cr3, void* data,uint32_t size,void* virt_addr) {
|
2020-07-22 19:26:55 -05:00
|
|
|
void* old_cr3=get_cr3();
|
2019-05-05 13:03:14 -05:00
|
|
|
void* phys_addr=virt_to_phys(data);
|
2020-07-22 21:28:00 -05:00
|
|
|
load_address_space(cr3);
|
2020-07-22 19:26:55 -05:00
|
|
|
map_pages(virt_addr,phys_addr,(size/PAGE_SZ)+1,1,1);
|
2020-07-22 21:28:00 -05:00
|
|
|
load_address_space(old_cr3);
|
2019-05-05 13:03:14 -05:00
|
|
|
}
|
2019-05-23 20:42:00 -05:00
|
|
|
|
|
|
|
void* address_spaces_put_data(void* cr3, void* data,uint32_t size) {
|
2020-07-22 19:26:55 -05:00
|
|
|
void* old_cr3=get_cr3();
|
2019-05-23 20:42:00 -05:00
|
|
|
void* phys_addr=virt_to_phys(data);
|
2020-07-22 21:28:00 -05:00
|
|
|
load_address_space(cr3);
|
2020-07-22 19:26:55 -05:00
|
|
|
void* virt_addr=find_free_pages((size/PAGE_SZ)+1);
|
|
|
|
map_pages(virt_addr,phys_addr,(size/PAGE_SZ)+1,1,1);
|
2020-07-22 21:28:00 -05:00
|
|
|
load_address_space(old_cr3);
|
2019-05-23 20:42:00 -05:00
|
|
|
return virt_addr;
|
|
|
|
}
|