Update software to match efinix hw
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"conio.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ LISTS=lists
|
||||
TESTS=tests
|
||||
|
||||
SRCS=$(wildcard *.s) $(wildcard *.c)
|
||||
SRCS+=$(filter-out $(wildcard tests/*), $(wildcard **/*.s)) $(filter-out $(wildcard tests/*), $(wildcard **/*.c))
|
||||
SRCS+=$(filter-out $(wildcard tests/*), $(wildcard **/*.s)) $(filter-out $(wildcard tests/*) $(wildcard filesystem/*), $(wildcard **/*.c))
|
||||
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
|
||||
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
|
||||
|
||||
@@ -33,7 +33,7 @@ $(TEST_BIN): $(OBJS) $(TEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(TEST_OBJS) -o $@
|
||||
|
||||
$(HEX): $(BIN)
|
||||
objcopy --input-target=binary --output-target=ihex $(BIN) $(HEX)
|
||||
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
|
||||
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t hex_set_8(uint8_t val, uint8_t idx);
|
||||
uint8_t hex_set_16(uint16_t val);
|
||||
uint8_t hex_set_24(uint32_t val);
|
||||
|
||||
void hex_enable(uint8_t mask);
|
||||
|
||||
uint8_t sw_read();
|
||||
|
||||
void led_set(uint8_t val);
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
.importzp sp, sreg
|
||||
|
||||
.export _hex_set_8
|
||||
.export _hex_set_16
|
||||
.export _hex_set_24
|
||||
.export _hex_enable
|
||||
.export _sw_read
|
||||
.export _led_set
|
||||
|
||||
@@ -13,49 +9,6 @@
|
||||
|
||||
.code
|
||||
|
||||
; @in A: idx Stack[0]: val
|
||||
; @out A: 0 for success, 1 for failure.
|
||||
; Sets one of the 3 pairs of hex digits.
|
||||
_hex_set_8:
|
||||
phx
|
||||
cmp #$3 ; If idx >= 3 then fail
|
||||
bcc @1
|
||||
plx
|
||||
lda #$1
|
||||
rts
|
||||
@1: tax ; Move idx into x
|
||||
jsr popa ; put val into a
|
||||
sta SEVEN_SEG,x ; write to val
|
||||
lda #$0
|
||||
plx
|
||||
rts
|
||||
|
||||
; @in A/X: val
|
||||
; @out A: 0 for success, 1 for failure
|
||||
; Sets the low 2 pairs of hex digits
|
||||
_hex_set_16:
|
||||
sta SEVEN_SEG
|
||||
stx SEVEN_SEG+1
|
||||
lda #$0
|
||||
rts
|
||||
|
||||
; @in A/X/sreg: val
|
||||
; @out A: 0 for success, 1 for failure
|
||||
; Sets the 3 pairs of hex digits for a 24 bit value
|
||||
_hex_set_24:
|
||||
sta SEVEN_SEG
|
||||
stx SEVEN_SEG+1
|
||||
lda sreg
|
||||
sta SEVEN_SEG+2
|
||||
lda #$0
|
||||
rts
|
||||
|
||||
; @in A: mask
|
||||
; Set the mask for seven seg enables
|
||||
_hex_enable:
|
||||
sta SEVEN_SEG+3
|
||||
rts
|
||||
|
||||
; @out A: The Value of the switches
|
||||
; Reads the current values of the switches.
|
||||
_sw_read:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.export _cputc
|
||||
.export gotoxy
|
||||
.export _clrscr
|
||||
.export _cgetc
|
||||
;.export _cgetc
|
||||
|
||||
.autoimport on
|
||||
|
||||
@@ -53,8 +53,8 @@ _clrscr:
|
||||
pla
|
||||
rts
|
||||
|
||||
_cgetc:
|
||||
@2: lda _lastchar
|
||||
beq @2
|
||||
stz _lastchar
|
||||
rts
|
||||
;_cgetc:
|
||||
;@2: lda _lastchar
|
||||
; beq @2
|
||||
; stz _lastchar
|
||||
; rts
|
||||
@@ -9,7 +9,6 @@
|
||||
.import _handle_irq
|
||||
|
||||
.export _irq_int, _nmi_int
|
||||
.export _irq_get_status, _irq_set_status
|
||||
|
||||
.include "io.inc65"
|
||||
|
||||
@@ -47,12 +46,3 @@ irq: PLA ; Restore accumulator contents
|
||||
|
||||
break: JMP break ; If BRK is detected, something very bad
|
||||
; has happened, so stop running
|
||||
|
||||
_irq_get_status:
|
||||
lda IRQ_STATUS
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
_irq_set_status:
|
||||
sta IRQ_STATUS
|
||||
rts
|
||||
@@ -1,18 +1,12 @@
|
||||
SEVEN_SEG = $7ff0
|
||||
|
||||
UART = $7ff4
|
||||
UART = $efe6
|
||||
UART_TXB = UART
|
||||
UART_RXB = UART
|
||||
UART_STATUS = UART + 1
|
||||
|
||||
LED = $7ff6
|
||||
LED = $efff
|
||||
SW = LED
|
||||
|
||||
MM_CTRL = $7ff7
|
||||
MM_DATA = $7fe0
|
||||
SD_ARG = $efd8
|
||||
SD_CMD = $efdc
|
||||
SD_DATA = $efdd
|
||||
|
||||
SD_ARG = $7ff8
|
||||
SD_CMD = $7ffc
|
||||
SD_DATA = $7ffd
|
||||
|
||||
IRQ_STATUS = $7fff
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef _MAPPER_H
|
||||
#define _MAPPER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void mapper_enable(uint8_t en);
|
||||
|
||||
uint8_t mapper_read(uint8_t addr);
|
||||
void mapper_write(uint8_t data, uint8_t addr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
.include "io.inc65"
|
||||
|
||||
.importzp sp, sreg
|
||||
|
||||
.export _mapper_enable
|
||||
.export _mapper_read, _mapper_write
|
||||
|
||||
.autoimport on
|
||||
|
||||
.code
|
||||
|
||||
|
||||
; void mapper_enable(uint8_t en)
|
||||
_mapper_enable:
|
||||
sta MM_CTRL
|
||||
rts
|
||||
|
||||
_mapper_read:
|
||||
phx
|
||||
tax
|
||||
lda MM_DATA,x
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
_mapper_write:
|
||||
phx
|
||||
tax
|
||||
jsr popa
|
||||
sta MM_DATA,x
|
||||
plx
|
||||
rts
|
||||
|
||||
@@ -5,21 +5,35 @@
|
||||
|
||||
void sd_init() {
|
||||
uint32_t resp;
|
||||
uint8_t attempts, i;
|
||||
|
||||
cputs("In sd_init\n");
|
||||
|
||||
sd_card_command(0, 0);
|
||||
|
||||
cprintf("Sent Reset\n");
|
||||
|
||||
sd_card_command(0x000001aa, 8);
|
||||
sd_card_resp(&resp);
|
||||
cprintf("CMD8: %lx\n", resp);
|
||||
|
||||
sd_card_command(0, 55);
|
||||
sd_card_command(0x40180000, 41);
|
||||
sd_card_resp(&resp);
|
||||
cprintf("CMD41: %lx\n", resp);
|
||||
attempts = 0;
|
||||
do {
|
||||
if (attempts > 100) {
|
||||
cprintf("SD Timed out");
|
||||
return;
|
||||
}
|
||||
sd_card_command(0, 55);
|
||||
sd_card_resp(&resp);
|
||||
sd_card_command(0x40180000, 41);
|
||||
sd_card_resp(&resp);
|
||||
cprintf("CMD41: %lx\n", resp);
|
||||
|
||||
sd_card_command(0, 55);
|
||||
sd_card_command(0x40180000, 41);
|
||||
sd_card_resp(&resp);
|
||||
cprintf("CMD41: %lx\n", resp);
|
||||
//10ms loop?
|
||||
for (i = 0; i < 255; i++);
|
||||
|
||||
attempts++;
|
||||
} while (resp != 0);
|
||||
|
||||
sd_card_command(0, 2);
|
||||
sd_card_resp(&resp);
|
||||
|
||||
@@ -19,8 +19,8 @@ _uart_txb:
|
||||
_uart_txb_block:
|
||||
pha
|
||||
sta UART_TXB ; Write value
|
||||
@1: lda UART_STATUS ; Wait for status[0] to be 0
|
||||
bit #$01
|
||||
@1: lda UART_STATUS ; Wait for status[1] to be 0
|
||||
bit #$02
|
||||
bne @1
|
||||
pla
|
||||
rts
|
||||
|
||||
@@ -5,20 +5,7 @@
|
||||
#include "devices/interrupt.h"
|
||||
#include "devices/uart.h"
|
||||
|
||||
char lastchar;
|
||||
|
||||
|
||||
void handle_irq() {
|
||||
uint8_t status;
|
||||
|
||||
status = irq_get_status();
|
||||
|
||||
if (status & BUTTON) {
|
||||
cputs("Button Interrupt!\n");
|
||||
irq_set_status(status & ~BUTTON);
|
||||
}
|
||||
if (status & UART) {
|
||||
lastchar = uart_rxb();
|
||||
irq_set_status(status & ~UART);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ MEMORY
|
||||
{
|
||||
ZP: start = $0, size = $100, type = rw, define = yes;
|
||||
SDRAM: start = $200, size = $7cf0, type = rw, define = yes;
|
||||
ROM: start = $8000, size = $8000, file = %O;
|
||||
ROM: start = $F000, size = $1000, file = %O;
|
||||
}
|
||||
|
||||
SEGMENTS {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "devices/board_io.h"
|
||||
#include "devices/uart.h"
|
||||
#include "devices/mapper.h"
|
||||
#include "devices/sd_card.h"
|
||||
#include "filesystem/fat.h"
|
||||
|
||||
@@ -14,34 +13,21 @@
|
||||
uint8_t buf[512];
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
uint16_t rca;
|
||||
char* filename;
|
||||
uint32_t cluster;
|
||||
uint8_t* kernel_load;
|
||||
|
||||
clrscr();
|
||||
cprintf("boot\n");
|
||||
|
||||
for (i = 0; i < 16; i++){
|
||||
//cprintf("Mapping %1xxxx to %2xxxx\n", i, i);
|
||||
mapper_write(i, i);
|
||||
}
|
||||
|
||||
cprintf("Enabling Mapper\n");
|
||||
mapper_enable(1);
|
||||
|
||||
mapper_write(0x10, 0xd);
|
||||
mapper_write(0x11, 0xe);
|
||||
mapper_write(0x12, 0xf);
|
||||
cputs("Starting sd_init\n");
|
||||
cprintf("And testing cprintf\n");
|
||||
|
||||
sd_init();
|
||||
|
||||
cprintf("finish sd_init\n");
|
||||
|
||||
rca = sd_get_rca();
|
||||
cprintf("rca: %x\n", rca);
|
||||
|
||||
sd_select_card(rca);
|
||||
|
||||
/*
|
||||
fat_init();
|
||||
|
||||
filename = (char*)malloc(FAT_MAX_FILE_NAME);
|
||||
@@ -54,8 +40,12 @@ int main() {
|
||||
cluster = fat_get_chain_value(cluster);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
cprintf("Done!\n");
|
||||
|
||||
for(;;);
|
||||
|
||||
cprintf("Reset vector: %x\n", *((uint16_t*)0xfffc));
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user