101 lines
1.8 KiB
C++
101 lines
1.8 KiB
C++
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <malloc.h>
|
|
|
|
#include "drv_omap35x_gpt.hh"
|
|
#include "omap35x.hh"
|
|
#include "omap35x_intc.hh"
|
|
#include "omap35x_prcm.hh"
|
|
#include "phys_mm.hh"
|
|
#include "mm.hh"
|
|
#include "cortexa8.hh"
|
|
#include "uart.hh"
|
|
|
|
static volatile uint32_t tickctr = 0;
|
|
static OMAP35x_prcm* _prcm = nullptr;
|
|
void tickfunc() noexcept {
|
|
++tickctr;
|
|
|
|
_prcm->clear_wake_per(3);
|
|
}
|
|
|
|
void setConsole(ICharacterDevice* newConsole);
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// Initialize memory
|
|
cortexa8::enable_dcache();
|
|
cortexa8::enable_icache();
|
|
cortexa8::init_mmu();
|
|
|
|
// Enable early console
|
|
EarlyUART earlyUART{};
|
|
setConsole(&earlyUART);
|
|
|
|
// Install handlers
|
|
cortexa8::init_handlers();
|
|
|
|
// Initialize physical memory managment
|
|
phys_mm::init();
|
|
|
|
// Initialize kernel dynamic memory management
|
|
mm::init();
|
|
// From here on, malloc/free and new/delete may be used
|
|
|
|
phys_mm::print_state();
|
|
|
|
// Configure PRCM
|
|
OMAP35x_prcm prcm {0x48004000, 0x48306000};
|
|
_prcm = &prcm;
|
|
|
|
//while(1) {__asm__ __volatile__ ("wfi"); }
|
|
|
|
// Configure interrrupt & exception handling
|
|
OMAP35x_intc intc {0x48200000};
|
|
|
|
prcm.enable_peripherals();
|
|
|
|
UART consoleUART {0x49020000, 74, prcm};
|
|
setConsole(&consoleUART);
|
|
|
|
// Enable interrupts
|
|
cortexa8_ena_int();
|
|
|
|
OMAP35x_Info chipInfo{0x48002000, 0x4830a000};
|
|
|
|
chipInfo.print_chip_id();
|
|
|
|
printf("5\n");
|
|
|
|
OMAP35x_GPT gpt2{0x49032000, 38};
|
|
|
|
gpt2.ticktimer(&tickfunc);
|
|
|
|
printf("6\n");
|
|
|
|
while(1) {
|
|
char buf[256];
|
|
if(fgets(buf, 256, stdin))
|
|
printf("%s", buf);
|
|
else
|
|
printf("Error\n");
|
|
if(strcmp(buf, "exit\n") == 0)
|
|
break;
|
|
}
|
|
|
|
malloc_stats();
|
|
phys_mm::print_state();
|
|
|
|
while(1) {
|
|
__asm__ __volatile__ ("wfi");
|
|
if(tickctr%100 == 0) {
|
|
printf(".");
|
|
fflush(stdout);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|