Files
mango/sandbox/vm/main.c

30 lines
647 B
C

#include <stdio.h>
#include <sys/mman.h>
#include "vm.h"
/* amount of memory to allocate for system RAM in megabytes */
#define SIMULATED_MEMORY_MB 16
#define MEMPTR(offset) ((void *)((uintptr_t)system_memory) + (offset))
int main(int argc, const char **argv)
{
printf("Hello, world!\n");
void *system_memory = mmap(
NULL,
SIMULATED_MEMORY_MB * 0x100000,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
if (system_memory == MAP_FAILED) {
perror("mmap");
fprintf(stderr, "cannot allocated simulated system RAM buffer\n");
return -1;
}
munmap(system_memory, SIMULATED_MEMORY_MB * 0x100000);
return 0;
}