mbv: now with functioning timer interrupts!

And a few other nice things.
The bootloader now has an embedded wozmon!
If you know its offset, you can jump to it from the app.
This commit is contained in:
2025-06-10 23:46:43 -07:00
parent fa6ae7b667
commit 3db383d461
17 changed files with 485 additions and 93 deletions

View File

@@ -1,6 +1,6 @@
MEMORY
{
RAM (rwx) : ORIGIN = 0x00000800, LENGTH = 14336
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x10000000
}
_vector_table = 0x0;
@@ -37,6 +37,6 @@ SECTIONS
_heap_begin = .;
_initial_stack_pointer = 16384;
_heap_end = _initial_stack_pointer - 1024;
_initial_stack_pointer = 0x90000000;
_heap_end = 0x8f000000; /* leave 1M for the stack */
}

View File

@@ -1,43 +0,0 @@
MEMORY
{
/* RAM (rwx) : ORIGIN = 0x00000800, LENGTH = 14336 */
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x10000000
}
_vector_table = 0x0;
SECTIONS
{
.text :
{
_text_begin = .;
KEEP(*(.start))
*(.text*)
_text_end = .;
*(.rodata*)
} > RAM
.bss (NOLOAD) :
{
_bss_begin = .;
*(.bss*)
*(COMMON)
_bss_end = .;
} > RAM
.data :
{
*(.data*)
__exidx_start = .;
*(.exidx*)
__exidx_end = .;
} > RAM
_heap_begin = .;
_initial_stack_pointer = 16384;
_heap_end = _initial_stack_pointer - 1024;
}

View File

@@ -1,10 +1,12 @@
#include <cstdint>
#include "pol0.h"
struct Gpio {
volatile uint32_t data;
};
#define gpio0 ((Gpio*)0x40000000)
#define gpio0 ((Gpio*)GPIO0_BASE)
void sleep(int ms) {
for (int m = 0; m < ms; m++) {

47
mbv/apps/timer/timer.cc Normal file
View File

@@ -0,0 +1,47 @@
#include <cstdint>
#include "intc.h"
#include "interrupts.h"
#include "pol0.h"
#include "timer.h"
namespace {
struct Gpio {
volatile uint32_t data;
};
Gpio* leds = reinterpret_cast<Gpio*>(GPIO0_BASE);
Timer* timer;
}
void Timer0Isr() {
static int counter = 0;
leds->data = counter++;
timer->Pet();
timer->ClearInterrupt();
}
void SetupTimer() {
timer = Timer::Instance(TIMER0_BASE);
timer->SetupAsWdt(100'000'000);
timer->EnableT1();
SetIsr(TIMER0_IRQN, Timer0Isr);
SetIrqEnabled(TIMER0_IRQN, true);
EnableInterrupts();
}
int main() {
leds->data = 0xa0;
SetupTimer();
SetExternalInterruptHandler(InterruptHandler);
EnableExternalInterrupts();
leds->data = 0xa1;
BiosWozmon();
}

View File

@@ -125,7 +125,6 @@ int main() {
gpio0->data = 1;
uint32_t cur_addr = 0;
uint32_t cur_data = 0;
bool writing = false;
char inbuf[64] = {};
char* inptr = inbuf;