New sw folders

This commit is contained in:
Byron Lathi
2024-10-14 23:48:16 -07:00
parent bc9b04853c
commit 21efb8ace8
11 changed files with 198 additions and 3 deletions

19
sw/Makefile Normal file
View File

@@ -0,0 +1,19 @@
SD_IMAGE = sd_image.bin
BOOTLOADER = bootloader/bootloader.bin
all: $(SD_IMAGE) $(BOOTLOADER)
$(BOOTLOADER):
$(MAKE) -C bootloader bootloader.bin
$(SD_IMAGE):
dd if=/dev/zero of=$@ bs=1M count=256
/sbin/mkfs.vfat $@
udisksctl loop-setup --file $@
udisksctl mount -b /dev/loop1
udisksctl unmount -b /dev/loop1
udisksctl loop-delete -b /dev/loop1
clean:
rm -rf $(SD_IMAGE)
rm -rf $(BOOTLOADER)

38
sw/bootloader/Makefile Normal file
View File

@@ -0,0 +1,38 @@
CC=../toolchain/cc65/bin/cl65
LD=../toolchain/cc65/bin/cl65
CFLAGS=-T -t none -I. --cpu "65C02"
LDFLAGS=-C link.ld -m $(NAME).map
NAME=bootloader
BIN=$(NAME).bin
HEX=$(NAME).hex
LISTS=lists
SRCS=$(wildcard *.s) $(wildcard *.c)
SRCS+=$(wildcard **/*.s) $(wildcard **/*.c)
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
all: $(HEX)
$(HEX): $(BIN)
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
%.o: %.c $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
%.o: %.s $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
$(LISTS):
mkdir -p $(addprefix $(LISTS)/,$(sort $(dir $(SRCS))))
.PHONY: clean
clean:
rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map

View File

@@ -0,0 +1,25 @@
.export _init, _nmi_int, _irq_int
.segment "VECTORS"
.addr _nmi_int ; NMI vector
.addr _init ; Reset vector
.addr _irq_int ; IRQ/BRK vector
SDRAM= $200
.code
_nmi_int:
_irq_int:
_init:
lda #$00
@start:
sta SDRAM
cmp SDRAM
bne @end
ina
bra @start
@end: bra @end

30
sw/bootloader/link.ld Normal file
View File

@@ -0,0 +1,30 @@
MEMORY
{
RAM: start = $0000, size = $200;
ROM: start = $F000, size = $1000, file = %O;
}
SEGMENTS {
ZEROPAGE: load = RAM, type = zp, define = yes;
DATA: load = ROM, type = rw, define = yes;
CODE: load = ROM, type = ro;
RODATA: load = ROM, type = ro;
VECTORS: load = ROM, type = ro, start = $FFFA;
}
FEATURES {
CONDES: segment = STARTUP,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = STARTUP,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
# Define the stack size for the application
__STACKSIZE__: value = $0200, type = weak;
__STACKSTART__: type = weak, value = $0800; # 2k stack
}

39
sw/kernel/Makefile Normal file
View File

@@ -0,0 +1,39 @@
CC=../toolchain/cc65/bin/cl65
LD=../toolchain/cc65/bin/cl65
CFLAGS=-T -t none -I. --cpu "65C02"
LDFLAGS=-C link.ld -m $(NAME).map
NAME=bootloader
BIN=$(NAME).bin
HEX=$(NAME).hex
LISTS=lists
SRCS=$(wildcard *.s) $(wildcard *.c)
SRCS+=$(wildcard **/*.s) $(wildcard **/*.c)
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
# Make sure the kernel linked to correct address, no relocation!
all: $(HEX)
$(HEX): $(BIN)
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
%.o: %.c $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
%.o: %.s $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
$(LISTS):
mkdir -p $(addprefix $(LISTS)/,$(sort $(dir $(SRCS))))
.PHONY: clean
clean:
rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map

9
sw/kernel/kernel.s Normal file
View File

@@ -0,0 +1,9 @@
.segment "ENTRY"
.addr main
.code
main:
bra main

30
sw/kernel/link.ld Normal file
View File

@@ -0,0 +1,30 @@
MEMORY
{
RAM: start = $0000, size = $200;
KERNEL: start = $8000, size = $7000, file = %O;
}
SEGMENTS {
ZEROPAGE: load = RAM, type = zp, define = yes;
ENTRY: load = KERNEL, type = ro, start = $8000;
DATA: load = KERNEL, type = rw, define = yes;
CODE: load = KERNEL, type = ro;
RODATA: load = KERNEL, type = ro;
}
FEATURES {
CONDES: segment = STARTUP,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = STARTUP,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
# Define the stack size for the application
__STACKSIZE__: value = $0200, type = weak;
__STACKSTART__: type = weak, value = $0800; # 2k stack
}