Add init code for mapper
init_mapper now remaps so that it can change irq vectors
This commit is contained in:
2
hw/efinix_fpga/.gitignore
vendored
2
hw/efinix_fpga/.gitignore
vendored
@@ -7,4 +7,4 @@ outflow
|
|||||||
*.gtkw
|
*.gtkw
|
||||||
*.vvp
|
*.vvp
|
||||||
|
|
||||||
.mem
|
*.mem
|
||||||
10
sw/kernel/devices/mapper.h
Normal file
10
sw/kernel/devices/mapper.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _MAPPER_H
|
||||||
|
#define _MAPPER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void init_mapper();
|
||||||
|
|
||||||
|
void map(uint16_t p_page, uint8_t v_page);
|
||||||
|
|
||||||
|
#endif
|
||||||
38
sw/kernel/devices/mapper.s
Normal file
38
sw/kernel/devices/mapper.s
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
.MACPACK generic
|
||||||
|
|
||||||
|
.autoimport
|
||||||
|
|
||||||
|
.export _init_mapper
|
||||||
|
.export _map
|
||||||
|
|
||||||
|
MAPPER_BASE = $200
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
; void init_paging();
|
||||||
|
; This should be identity mapped at reset, but we can do it again anyway
|
||||||
|
.proc _init_mapper
|
||||||
|
ldx #$00
|
||||||
|
L1:
|
||||||
|
txa
|
||||||
|
lsr
|
||||||
|
sta MAPPER_BASE,x
|
||||||
|
lda #$00
|
||||||
|
sta MAPPER_BASE+1,x
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
cpx #$20
|
||||||
|
blt L1
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
; void map(uint16_t p_page, uint8_t v_page);
|
||||||
|
.proc _map
|
||||||
|
asl
|
||||||
|
tax ; x = v_page * 2
|
||||||
|
jsr popa ; low byte of p_page
|
||||||
|
sta MAPPER_BASE,x ; write low byte to mm_low
|
||||||
|
jsr popa ; high byte of p_page
|
||||||
|
sta MAPPER_BASE+1,x ; write high byte to mm_high
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
#define BUTTON (1 << 0)
|
#define BUTTON (1 << 0)
|
||||||
#define UART (1 << 1)
|
#define UART (1 << 1)
|
||||||
|
|
||||||
|
void init_interrupts();
|
||||||
|
|
||||||
void register_irq(void* addr, uint8_t irqn);
|
void register_irq(void* addr, uint8_t irqn);
|
||||||
|
|
||||||
uint8_t irq_get_status();
|
uint8_t irq_get_status();
|
||||||
|
|||||||
@@ -3,15 +3,38 @@
|
|||||||
.autoimport
|
.autoimport
|
||||||
|
|
||||||
.import _enable_irq
|
.import _enable_irq
|
||||||
|
.import _map
|
||||||
|
|
||||||
.export irq_int, nmi_int
|
.export irq_int, nmi_int
|
||||||
.export _register_irq
|
.export _register_irq
|
||||||
|
.export _init_interrupts
|
||||||
|
|
||||||
IRQ_CMD_ADDR = $effc
|
IRQ_CMD_ADDR = $effc
|
||||||
IRQ_DAT_ADDR = $effd
|
IRQ_DAT_ADDR = $effd
|
||||||
|
|
||||||
IRQ_CMD_READIRQ = $00
|
IRQ_CMD_READIRQ = $00
|
||||||
|
|
||||||
|
; void init_interrupts();
|
||||||
|
; remap the upper page into ram,
|
||||||
|
; then load the new vector addresses.
|
||||||
|
.proc _init_interrupts
|
||||||
|
; map(001f, f);
|
||||||
|
lda #$1f
|
||||||
|
jsr pushax
|
||||||
|
lda #$f
|
||||||
|
jsr _map
|
||||||
|
|
||||||
|
lda #<irq_int
|
||||||
|
sta $fffe
|
||||||
|
lda #>irq_int
|
||||||
|
sta $ffff
|
||||||
|
|
||||||
|
lda #<nmi_int
|
||||||
|
sta $fffa
|
||||||
|
lda #>nmi_int
|
||||||
|
sta $fffb
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
.proc nmi_int
|
.proc nmi_int
|
||||||
rti
|
rti
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include "devices/interrupt_controller.h"
|
#include "devices/interrupt_controller.h"
|
||||||
#include "interrupts/interrupt.h"
|
#include "interrupts/interrupt.h"
|
||||||
|
#include "devices/mapper.h"
|
||||||
#include "devices/rtc.h"
|
#include "devices/rtc.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -13,11 +14,11 @@ int main() {
|
|||||||
|
|
||||||
cputs("Kernel\n");
|
cputs("Kernel\n");
|
||||||
|
|
||||||
// cputs("Init Paging\n")
|
cputs("Init Mapper\n");
|
||||||
// init_paging()
|
init_mapper();
|
||||||
|
|
||||||
// cputs("Initialize Interrupts\n");
|
cputs("Initialize Interrupts\n");
|
||||||
// init_interrupts();
|
init_interrupts();
|
||||||
|
|
||||||
cputs("Initialize Interrupt Controller\n");
|
cputs("Initialize Interrupt Controller\n");
|
||||||
init_interrupt_controller();
|
init_interrupt_controller();
|
||||||
|
|||||||
Reference in New Issue
Block a user