Skip to content

Commit

Permalink
sbc2g: get building with new tools
Browse files Browse the repository at this point in the history
Not yet tested
  • Loading branch information
EtchedPixels committed Nov 1, 2023
1 parent 94c3263 commit 0bb0570
Show file tree
Hide file tree
Showing 20 changed files with 1,615 additions and 513 deletions.
58 changes: 37 additions & 21 deletions Kernel/platform/platform-sbc2g/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,74 @@ CSRCS += devices.c main.c

DISCSRCS = discard.c

ASRCS = sbc2g.s crt0.s
ASRCS += tricks.s commonmem.s
ASRCS = sbc2g.S crt0.S
ASRCS += tricks.S commonmem.S ide.S

DISCARD_DSRCS = ../../dev/tinydisk_discard.c ../../dev/tinyide_discard.c
DSRCS = ../../dev/tinydisk.c ../../dev/tinyide.c
NSRCS =

DASRCS =

COBJS = $(CSRCS:.c=.rel)
AOBJS = $(ASRCS:.s=.rel)
NOBJS = $(patsubst ../../dev/net/%.c,%.rel, $(NSRCS))
DISCOBJS = $(DISCSRCS:.c=.rel)
DISCARD_DOBJS = $(patsubst ../../dev/%.c,%.rel, $(DISCARD_DSRCS))
DOBJS = $(patsubst ../../dev/%.c,%.rel, $(DSRCS))
DAOBJS = $(patsubst ../../dev/%.s,%.rel, $(DASRCS))
COBJS = $(CSRCS:.c=.o)
AOBJS = $(ASRCS:.S=.o)
NOBJS = $(patsubst ../../dev/net/%.c,%.o, $(NSRCS))
DISCOBJS = $(DISCSRCS:.c=.o)
DISCARD_DOBJS = $(patsubst ../../dev/%.c,%.o, $(DISCARD_DSRCS))
DOBJS = $(patsubst ../../dev/%.c,%.o, $(DSRCS))
DAOBJS = $(patsubst ../../dev/%.S,%.o, $(DASRCS))

OBJS = $(COBJS) $(AOBJS) $(NOBJS) $(DISCOBJS) $(DOBJS) $(DISCARD_DOBJS) $(DAOBJS)

JUNK = *.lst *.asm *.sym *.rst *.lst *.ihx *.tmp *.rel
JUNK = *.tmp *.o

all: $(OBJS)

$(COBJS): %.rel: %.c
$(COBJS): %.o: %.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<

$(DISCOBJS): %.rel: %.c
$(DISCOBJS): %.o: %.c
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $<

$(DOBJS): %.rel: ../../dev/%.c
$(DOBJS): %.o: ../../dev/%.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<

$(DISCARD_DOBJS): %.rel: ../../dev/%.c
$(DISCARD_DOBJS): %.o: ../../dev/%.c
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $<

$(NOBJS): %.rel: ../../dev/net/%.c
$(NOBJS): %.o: ../../dev/net/%.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<

$(AOBJS): %.rel: %.s
$(AOBJS): %.o: %.S
$(CROSS_AS) $(ASOPTS) $<

$(DAOBJS): %.rel: ../../dev/%.s
$(DAOBJS): %.o: ../../dev/%.S
$(CROSS_AS) $(ASOPTS) $@ $<

clean:
rm -f $(JUNK) core *~ loader.bin

image: loader.bin

loader.bin: loader.s
sdasz80 -o loader.s
sdldz80 -i loader.rel
$(CROSS_LD) -b -C 0x0100 -S 0xF600 -f CLDBbXSs -o fuzix.bin \
crt0.o commonmem.o sbc2g.o ../../start.o \
../../version.o ../../cpu-z80u/lowlevel-z80u.o \
../../usermem.o tricks.o main.o discard.o \
../../timer.o ../../kdata.o devices.o ../../devio.o \
../../filesys.o ../../blk512.o ../../process.o \
../../inode.o ../../syscall_exec.o ../../syscall_exec16.o \
../../syscall_fs.o ../../syscall_fs2.o ../../syscall_fs3.o \
../../syscall_proc.o ../../syscall_other.o ../../syscall_net.o \
../../network.o ../../tty.o ../../mm.o ../../mm/memalloc_none.o \
../../swap.o ../../mm/bankfixed.o ../../devsys.o \
devtty.o ../../dev/tinydisk.o ../../dev/tinydisk_discard.o \
../../dev/tinyide.o ../../dev/tinyide_discard.o ide.o \
/opt/ccz80/lib/libz80.a -m fuzix.tmpmap
perl -lpe '$$_=hex' fuzix.tmpmap | paste -d" " - fuzix.tmpmap | sort -n | cut -d" " -f 2- >../../fuzix.map
../../tools/pack85 <../../fuzix.map fuzix.bin ../../fuzix.bin

loader.bin: loader.S
asz80 loader.S
ldz80 -b loader.o -o loader.tmp
makebin -s 65536 loader.ihx loader.tmp
dd if=loader.tmp bs=256 skip=192 of=loader.bin

Expand Down
9 changes: 9 additions & 0 deletions Kernel/platform/platform-sbc2g/commonmem.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;
; The common memory area traditionally starts with the udata and the
; interrupt stacks. As this is standard in almost all cases you can
; just include the standard implementation.
;
.common

#include "../../cpu-z80u/std-commonmem.S"

61 changes: 55 additions & 6 deletions Kernel/platform/platform-sbc2g/commonmem.s
Original file line number Diff line number Diff line change
@@ -1,11 +1,60 @@
# 0 "commonmem.S"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "commonmem.S"
;
; The common memory area traditionally starts with the udata and the
; interrupt stacks. As this is standard in almost all cases you can
; just include the standard implementation.
; The common memory area traditionally starts with the udata and the
; interrupt stacks. As this is standard in almost all cases you can
; just include the standard implementation.
;
.module commonmem
.common

# 1 "../../cpu-z80u/std-commonmem.S" 1
;
;
; Standard Z80 common memory area blocks.
;
; Must remain a multiple of 256 bytes
;
; exported symbols
.export _ub
.export _udata
.export kstack_top
.export istack_top
.export istack_switched_sp

.area _COMMONMEM

.include "../../cpu-z80/std-commonmem.s"
_ub: ; first 512 bytes: starts with struct u_block, with the kernel stack working down from above
_udata:
kstack_base:
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
istack_top:
istack_switched_sp: .word 0
# 9 "commonmem.S" 2
2 changes: 1 addition & 1 deletion Kernel/platform/platform-sbc2g/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern uint16_t swap_dev;
#define CONFIG_TD
#define CONFIG_TD_NUM 2
#define CONFIG_TD_IDE
#define CONFIG_TINYIDE_SDCCPIO
#define CONFIG_TINYIDE_INDIRECT
#define CONFIG_TINYIDE_8BIT
#define IDE_IS_8BIT(x) 1

Expand Down
40 changes: 40 additions & 0 deletions Kernel/platform/platform-sbc2g/crt0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
; startup code
.code

; Load at 0x0100
; We are executed from ROMWBW so we live in bank 14/15
; with the HBIOS proxy at FE00
start:
di
ld sp, kstack_top
; move the common memory where it belongs
ld hl, __bss
ld de, __common
ld bc, __common_size
ldir
ld de, __commondata
ld bc, __commondata_size
ldir
; then the discard
; Discard can just be linked in but is next to the buffers
ld de, __discard
ld bc, __discard_size
ldir
; then zero the data area
ld hl, __bss
ld de, __bss + 1
ld bc, __bss_size - 1
ld (hl), 0
ldir
; Zero buffers area
ld hl, __buffers
ld de, __buffers + 1
ld bc, __buffers_size - 1
ld (hl), 0
ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop
116 changes: 42 additions & 74 deletions Kernel/platform/platform-sbc2g/crt0.s
Original file line number Diff line number Diff line change
@@ -1,76 +1,44 @@
; Ordering of segments for the linker.
.area _CODE
.area _CODE2
.area _HOME
.area _CONST
.area _INITIALIZED
.area _DATA
.area _BSEG
.area _BSS
.area _HEAP
.area _GSINIT
.area _GSFINAL
.area _BUFFERS
.area _INITIALIZER
.area _DISCARD
.area _COMMONMEM
.area _COMMONDATA
# 0 "crt0.S"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "crt0.S"
; startup code
.code

; imported symbols
.globl _fuzix_main
.globl init_early
.globl init_hardware
.globl s__DATA
.globl l__DATA
.globl s__DISCARD
.globl l__DISCARD
.globl s__BUFFERS
.globl l__BUFFERS
.globl s__COMMONMEM
.globl l__COMMONMEM
.globl s__COMMONDATA
.globl l__COMMONDATA
.globl s__INITIALIZER
.globl kstack_top
.globl map_kernel

; startup code
.area _CODE

; Load at 0x0100
; We are executed from ROMWBW so we live in bank 14/15
; with the HBIOS proxy at FE00
; Load at 0x0100
; We are executed from ROMWBW so we live in bank 14/15
; with the HBIOS proxy at FE00
start:
di
ld sp, #kstack_top
; move the common memory where it belongs
ld hl, #s__DATA
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
ld de, #s__COMMONDATA
ld bc, #l__COMMONDATA
ldir
; then the discard
; Discard can just be linked in but is next to the buffers
ld de, #s__DISCARD
ld bc, #l__DISCARD
ldir
; then zero the data area
ld hl, #s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
ldir
; Zero buffers area
ld hl, #s__BUFFERS
ld de, #s__BUFFERS + 1
ld bc, #l__BUFFERS - 1
ld (hl), #0
ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop
di
ld sp, kstack_top
; move the common memory where it belongs
ld hl, __bss
ld de, __common
ld bc, __common_size
ldir
ld de, __commondata
ld bc, __commondata_size
ldir
; then the discard
; Discard can just be linked in but is next to the buffers
ld de, __discard
ld bc, __discard_size
ldir
; then zero the data area
ld hl, __bss
ld de, __bss + 1
ld bc, __bss_size - 1
ld (hl), 0
ldir
; Zero buffers area
ld hl, __buffers
ld de, __buffers + 1
ld bc, __buffers_size - 1
ld (hl), 0
ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop
Loading

0 comments on commit 0bb0570

Please sign in to comment.