More IRQ handlers.
This commit is contained in:
parent
15703025b0
commit
3552dd37a8
2
Makefile
2
Makefile
|
@ -31,7 +31,7 @@ BIN = $(CP) -O binary
|
|||
|
||||
CFLAGS += -mabi=ilp32 -march=rv32imc -g $(INCLUDES)
|
||||
ASFLAGS += -mabi=ilp32 -march=rv32imc -g
|
||||
LDFLAGS += -nostartfiles -specs=nosys.specs -lc -lm -lnosys
|
||||
LDFLAGS += -nostartfiles -specs=nosys.specs -specs=nano.specs -lc -lm -lnosys
|
||||
|
||||
|
||||
LDFLAGS += -T$(LDSCRIPT) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map -Wl,--print-memory-usage
|
||||
|
|
|
@ -2,14 +2,34 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "soc_peripherals.h"
|
||||
#include "xilinx_timer.h"
|
||||
|
||||
void Generic_ExceptionCallback(void) {
|
||||
printf("Generic exception handler!!\r\n");
|
||||
for(;;) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((interrupt)) void Generic_TimerCallback(void) {
|
||||
TIMER0->TCSR0 |= (1 << 0x08); // Clear interrupt;
|
||||
SysTick++;
|
||||
}
|
||||
|
||||
__attribute__((interrupt)) void Generic_TrapCallback(void) {
|
||||
printf("Trap!!\r\n");
|
||||
uint32_t mepc, mcause, mstatus;
|
||||
__csrr("mepc", mepc);
|
||||
__csrr("mcause", mcause);
|
||||
__csrr("mstatus", mstatus);
|
||||
printf("mepc: 0x%08x, mcause: 0x%08x, mstatus: 0x%08x\r\n", mepc, mcause, mstatus);
|
||||
for(;;) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((interrupt)) void NMI_Handler(void) {
|
||||
printf("NMI occurred!!\r\n");
|
||||
for(;;) {
|
||||
//
|
||||
}
|
||||
}
|
|
@ -31,7 +31,8 @@ int main(int argc, char *argv[]) {
|
|||
previous_tick = GetTick();
|
||||
xilinx_gpio_toggle(&soc_gpio, 1);
|
||||
printf("SysTick: %lu\r\n", GetTick());
|
||||
printf("MCycle: %016llx\r\n", __read_mcycle());
|
||||
uint64_t cycle = __read_mcycle();
|
||||
printf("MCycle: %08lx%08lx\r\n", (uint32_t)(cycle >> 32), cycle & 0xFFFFFFFFU);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
44
startup.s
44
startup.s
|
@ -85,18 +85,44 @@ Default_IRQHandler:
|
|||
Timer_IRQHandler:
|
||||
jal x0, Generic_TimerCallback
|
||||
|
||||
Trap_Handler:
|
||||
jal x0, Generic_TrapCallback
|
||||
|
||||
/* ISR vector table */
|
||||
.section .isr_vectors, "ax"
|
||||
.option norvc;
|
||||
|
||||
.org 0x00
|
||||
.rept 7
|
||||
jal x0, Default_IRQHandler
|
||||
.endr
|
||||
jal x0, Timer_IRQHandler
|
||||
.rept 23
|
||||
jal x0, Default_IRQHandler
|
||||
.endr
|
||||
|
||||
.org 0x80
|
||||
jal x0, Trap_Handler /* Trap IRQ (IRQ 0) */
|
||||
jal x0, Default_IRQHandler /* IRQ 1 */
|
||||
jal x0, Default_IRQHandler /* IRQ 2 */
|
||||
jal x0, Default_IRQHandler /* IRQ 3 */
|
||||
jal x0, Default_IRQHandler /* IRQ 4 */
|
||||
jal x0, Default_IRQHandler /* IRQ 5 */
|
||||
jal x0, Default_IRQHandler /* IRQ 6 */
|
||||
jal x0, Timer_IRQHandler /* Timer IRQ (IRQ 7) */
|
||||
jal x0, Default_IRQHandler /* IRQ 8 */
|
||||
jal x0, Default_IRQHandler /* IRQ 9 */
|
||||
jal x0, Default_IRQHandler /* IRQ 10 */
|
||||
jal x0, Default_IRQHandler /* External IRQ (IRQ 11) */
|
||||
jal x0, Default_IRQHandler /* IRQ 12 */
|
||||
jal x0, Default_IRQHandler /* IRQ 13 */
|
||||
jal x0, Default_IRQHandler /* IRQ 14 */
|
||||
jal x0, Default_IRQHandler /* IRQ 15 */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 0 (IRQ 16) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 1 (IRQ 17) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 2 (IRQ 18) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 3 (IRQ 19) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 4 (IRQ 20) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 5 (IRQ 21) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 6 (IRQ 22) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 7 (IRQ 23) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 8 (IRQ 24) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 9 (IRQ 25) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 10 (IRQ 26) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 11 (IRQ 27) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 12 (IRQ 28) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 13 (IRQ 29) */
|
||||
jal x0, Default_IRQHandler /* Fast IRQ 14 (IRQ 30) */
|
||||
jal x0, NMI_Handler /* Non-Maskable IRQ (IRQ 31) */
|
||||
jal x0, Reset_Handler
|
||||
|
|
Loading…
Reference in New Issue