Load root directory from sd card
This commit is contained in:
@@ -7,6 +7,8 @@ NAME=bios
|
||||
BIN=$(NAME).bin
|
||||
HEX=$(NAME).hex
|
||||
|
||||
FPGA_IMG=../../hw/efinix_fpga/init_hex.mem
|
||||
|
||||
LISTS=lists
|
||||
TESTS=tests
|
||||
|
||||
@@ -19,6 +21,7 @@ all: $(HEX)
|
||||
|
||||
$(HEX): $(BIN)
|
||||
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
|
||||
diff $(HEX) $(FPGA_IMG)
|
||||
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
|
||||
@@ -13,7 +13,7 @@ _sd_readblock = $6
|
||||
|
||||
buf = $8200
|
||||
addrh = $0000
|
||||
addrl = $0001
|
||||
addrl = $0000
|
||||
|
||||
|
||||
.segment "BOOTSECTOR"
|
||||
@@ -34,11 +34,47 @@ _main:
|
||||
ldx #>str
|
||||
jsr _cputs
|
||||
|
||||
lda #<_fat_count
|
||||
ldx #>_fat_count
|
||||
jsr pushax
|
||||
lda $8010
|
||||
ldx #$0
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
jsr _cprintf
|
||||
|
||||
; this is offset from bpb?
|
||||
|
||||
lda #<_fat_sectors
|
||||
ldx #>_fat_sectors
|
||||
jsr pushax
|
||||
lda $8026
|
||||
sta sreg
|
||||
ldx $8027
|
||||
stx sreg + 1
|
||||
lda $8024
|
||||
ldx $8025
|
||||
jsr pusheax
|
||||
ldy #$06
|
||||
jsr _cprintf
|
||||
|
||||
lda #<_reserved_sect
|
||||
ldx #>_reserved_sect
|
||||
jsr pushax
|
||||
lda $800E
|
||||
pha
|
||||
ldx $800F
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
jsr _cprintf
|
||||
|
||||
lda #<addrh
|
||||
sta sreg
|
||||
lda #>addrh
|
||||
sta sreg + 1
|
||||
lda #<addrl
|
||||
pla
|
||||
clc
|
||||
adc #<addrl
|
||||
ldx #>addrl
|
||||
jsr pusheax
|
||||
lda #<buf
|
||||
@@ -52,22 +88,48 @@ _main:
|
||||
ldx #>buf
|
||||
jsr _SD_printBuf
|
||||
|
||||
lda #<_reserved_sect
|
||||
ldx #>_reserved_sect
|
||||
jsr pushax
|
||||
lda $800E
|
||||
ldx $800F
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
lda #<rd_word
|
||||
ldx #>rd_word
|
||||
jsr pushax
|
||||
|
||||
lda buf
|
||||
ldx #$00
|
||||
jsr pushax
|
||||
ldy #$4
|
||||
jsr _cprintf
|
||||
|
||||
; we need to read from data segment 0, that will be the first directory entry
|
||||
; that has sector offset $00ef_e000
|
||||
|
||||
lda #$00
|
||||
sta sreg
|
||||
lda #$00
|
||||
sta sreg+1
|
||||
lda #$f0
|
||||
ldx #$77
|
||||
jsr pusheax
|
||||
lda #<buf
|
||||
ldx #>buf
|
||||
jsr pushax
|
||||
lda #<ptr1
|
||||
ldx #>ptr1
|
||||
jsr _SD_readSingleBlock
|
||||
|
||||
lda #<buf
|
||||
ldx #>buf
|
||||
jsr _SD_printBuf
|
||||
|
||||
|
||||
@end: bra @end
|
||||
|
||||
_reserved_sect:
|
||||
.asciiz "Reserved Sectors: %x\r\n"
|
||||
.asciiz "Reserved Sectors: %x\r\n"
|
||||
_fat_sectors:
|
||||
.asciiz "Sectors per fat: %lx\r\n"
|
||||
_fat_count:
|
||||
.asciiz "Fat Count: %x\r\n"
|
||||
str: .asciiz "Hello from the bootloader!\r\n"
|
||||
|
||||
rd_word: .asciiz "Read: %x\r\n"
|
||||
_end:
|
||||
|
||||
.res (440+_start-_end)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
hello, world!
|
||||
@@ -7,6 +7,8 @@ NAME=kernel
|
||||
|
||||
O65 = $(NAME).o65
|
||||
|
||||
FSDIR=../fsdir
|
||||
|
||||
LISTS=lists
|
||||
|
||||
SRCS=$(wildcard *.s) $(wildcard *.c)
|
||||
@@ -16,6 +18,7 @@ OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
|
||||
|
||||
# Make sure the kernel linked to correct address, no relocation!
|
||||
all: $(O65)
|
||||
cp $(O65) $(FSDIR)
|
||||
|
||||
$(O65): $(OBJS)
|
||||
$(LD) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
|
||||
|
||||
@@ -28,7 +28,6 @@ FILES
|
||||
FORMATS
|
||||
{
|
||||
o65: os = super, version = 0, type = small,
|
||||
import = LUNIXKERNEL,
|
||||
export = _init;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
DEVICE=/dev/mmcblk0
|
||||
TMPMOUNT=/tmp/sd
|
||||
FSDIR=fsdir
|
||||
FSDIR=../fsdir
|
||||
|
||||
V=
|
||||
V=-v
|
||||
|
||||
echo "$(tput bold setaf 11)Mounting Device$(tput sgr 0)"
|
||||
mkdir $V -p $TMPMOUNT
|
||||
@@ -16,4 +16,4 @@ echo
|
||||
echo "$(tput bold setaf 11)Unmounting Device$(tput sgr 0)"
|
||||
sudo umount $V $DEVICE
|
||||
rmdir $V $TMPMOUNT
|
||||
echo
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user