os/libc/memory.c

27 lines
467 B
C
Raw Normal View History

2019-03-17 12:22:00 -05:00
#include <stdint.h>
void* alloc_memory(uint32_t num_pages) {
void* address;
asm volatile(" \
mov $3, %%eax; \
int $80; \
":"=b"(address):"b"(num_pages));
return address;
}
void alloc_memory_virt(uint32_t num_pages,void* addr) {
asm volatile(" \
2019-03-17 18:04:06 -05:00
mov $4, %%eax; \
2019-03-17 12:22:00 -05:00
int $80; \
"::"b"(num_pages),"c"(addr));
}
2019-05-05 13:14:14 -05:00
void* new_address_space() {
void* cr3;
asm volatile(" \
mov $8, %%eax; \
int $80; \
":"=b"(cr3));
return cr3;
}