02114ea7d8
- Cleanup exception trigger code - Cleanup division to divide by 0 - Cleanup SRET code - Cleanup CSR code - Added interrupts - Added TIMER interrupt
52 lines
1.0 KiB
C
52 lines
1.0 KiB
C
#include "vriscv.h"
|
|
#include "memory/memory.h"
|
|
#include "bootloader/bootloader.h"
|
|
#include "cpu/rv32cpu.h"
|
|
#include "cpu/interrupt.h"
|
|
#include "gdbstub/gdbstub.h"
|
|
#include "devices/uart/uart.h"
|
|
|
|
char* CURRENT_NAME;
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
CURRENT_NAME = argc ? argv[0] : NAME;
|
|
parse_options(argc, argv);
|
|
|
|
// Initialize the memory
|
|
mem_init();
|
|
|
|
// Initialize UART (memory-mapped)
|
|
uart_init();
|
|
|
|
// Bootload the file passed as argument
|
|
uint32_t entry_point = bootload(file_path);
|
|
|
|
// Initialize the CPU
|
|
cpu_init();
|
|
cpu0->pc = entry_point;
|
|
|
|
if(gdbstub)
|
|
{
|
|
gdbstub_start();
|
|
gdbstub_wait_for_connection();
|
|
}
|
|
|
|
// Initialize timer for timer interrupt
|
|
interrupt_timer_setup();
|
|
|
|
// CPU simulation : create cpu0 thread
|
|
if(!gdbstub) cpu0->sim_ticks_left = -1; // Simulate forever
|
|
pthread_t cpu0_thread;
|
|
pthread_create(&cpu0_thread, 0, (void*) cpu_loop, cpu0);
|
|
|
|
// Wait forever, until simulation end (which should be an ecall shutdown)
|
|
pthread_join(cpu0_thread, 0);
|
|
if(gdbstub)
|
|
{
|
|
gdbstub_stop();
|
|
}
|
|
|
|
return 0;
|
|
}
|