33 lines
700 B
C
33 lines
700 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <inttypes.h>
|
|
|
|
#include "emulator/hart.h"
|
|
#include "emulator/elf.h"
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc < 2)
|
|
{
|
|
printf("Usage: %s <input elf>\n", argv[0]);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
uint32_t mem_size = 16 * 1024 * 1024;
|
|
char* mem = (char*)malloc(mem_size);
|
|
uint32_t start_address = 0;
|
|
|
|
if (!load_elf(argv[1], mem, mem_size, &start_address))
|
|
{
|
|
printf("Error loading ELF into memory\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
struct Hart hart = {0};
|
|
hart_init(&hart, 0, mem, mem_size);
|
|
|
|
execute_from(&hart, start_address);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|