12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #include "fw.h"
- #include "io.h"
- #include "abcio.h"
- #include "sys.h"
- #include "console.h"
- volatile uint32_t timer_irq_count;
- IRQHANDLER(sysclock)
- {
- uint32_t count = timer_irq_count;
- count++;
- timer_irq_count = count;
- set_led(count >> 3); /* 4 Hz */
- }
- /* Configure ABC memory map */
- static void init_abc_memmap(void)
- {
- volatile uint32_t *pg = &ABCMEMMAP_PAGE(0);
- for (unsigned int addr = 0; addr < 0x10000; addr += 512) {
- if (addr >= 0x5800 && addr < 0x6000) {
- *pg++ = ABCMEMMAP_RD | addr;
- } else if (addr >= 0x8000 && addr < 0xc000) {
- *pg++ = ABCMEMMAP_RD | ABCMEMMAP_WR | addr;
- } else {
- *pg++ = addr; /* Disabled */
- }
- }
- }
- static no_return killed(const char *how, size_t pc)
- {
- con_printf("ERROR: %s at 0x%08x\n", how, pc);
- con_flush();
- udelay(5000000);
- reset();
- }
- IRQHANDLER(BUSERR)
- {
- killed("misaligned", pc);
- }
- IRQHANDLER(EBREAK)
- {
- killed("invalid instruction", pc);
- }
- static uint32_t timer_irq_start;
- static void init(void)
- {
- static const char hello[] =
- "\n*** Hello, World! ***\n"
- "Firmware compiled on: " __DATE__ " " __TIME__ "\n\n";
- /* Start ROM copy engine */
- unmask_irqs((1U << ROMCOPY_IRQ)|(1U << EBREAK_IRQ)|(1U << BUSERR_IRQ));
- set_led(0);
- con_set_baudrate(115200);
- con_puts(hello);
- abc_init();
- init_abc_memmap();
- timer_irq_count = 0;
- timer_irq_start = rdtime();
- unmask_irq(SYSCLOCK_IRQ);
- read_rtc();
- abcdisk_init();
- }
- bool dont_gc; /* Keep things from linker gc */
- void main(void)
- {
- init();
- if (dont_gc)
- run_test_image();
- while (1) {
- wait_for_irq();
- abcdisk_io_poll();
- }
- }
|