mem: add phys_memcpy
This commit is contained in:
parent
877f6aa7c9
commit
da5aaf68e9
2 changed files with 8 additions and 6 deletions
|
|
@ -116,6 +116,7 @@ paddr_t virtual_to_physical(uintptr_t vaddr, paddr_t page_base);
|
|||
void mem_early_init(char *mem, size_t len);
|
||||
uint64_t phys_read(paddr_t paddr);
|
||||
void phys_write(paddr_t paddr, uint64_t data);
|
||||
void *phys_memcpy(void *dest, paddr_t src, size_t num);
|
||||
|
||||
#endif /* __ASM__ */
|
||||
#endif /* _MEM_H_ */
|
||||
|
|
|
|||
13
mem/page.c
13
mem/page.c
|
|
@ -249,14 +249,9 @@ paddr_t proc_clone_mmap(struct proc *in, struct proc *out)
|
|||
{
|
||||
/* allocate a new page table */
|
||||
out->cr3 = (uintptr_t)buddy_alloc(0x1000);
|
||||
if (!out->cr3) {
|
||||
kprintf(LOG_ERROR "proc_clone_mmap: failed to allocate new page table\n");
|
||||
return 0;
|
||||
}
|
||||
memcpy((void *)out->cr3, (void *)(in->cr3 | hhdm_start), 0x1000);
|
||||
|
||||
out->cr3 &= ~hhdm_start;
|
||||
|
||||
/* copy the kernel mappings */
|
||||
/* copy all mappings */
|
||||
spinlock_acquire(&in->lock);
|
||||
spinlock_acquire(&out->lock);
|
||||
|
|
@ -290,6 +285,12 @@ inline void phys_write(paddr_t paddr, uint64_t data)
|
|||
*(uint64_t *)(paddr | hhdm_start) = data;
|
||||
}
|
||||
|
||||
inline void *phys_memcpy(void *dest, paddr_t src, size_t num)
|
||||
{
|
||||
memcpy(dest, (void *)(src | hhdm_start), num);
|
||||
return dest;
|
||||
}
|
||||
|
||||
paddr_t virtual_to_physical(uintptr_t vaddr, paddr_t page_base)
|
||||
{
|
||||
size_t pn = (vaddr >> 12) & 0x1FF;
|
||||
|
|
|
|||
Loading…
Reference in a new issue