Skip to content

Commit

Permalink
searle: convert to new toolchain
Browse files Browse the repository at this point in the history
Builds but not yet tested
  • Loading branch information
EtchedPixels committed Oct 31, 2023
1 parent 4ca33fb commit 8178aec
Show file tree
Hide file tree
Showing 22 changed files with 1,860 additions and 736 deletions.
59 changes: 37 additions & 22 deletions Kernel/platform/platform-searle/Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,72 @@
ASRCS = crt0.s tricks.s commonmem.s searle.s usermem.s
CSRCS = devices.c main.c devtty.c ide.c
ASRCS = crt0.S tricks.S commonmem.S searle.S usermem.S ide.S
CSRCS = devices.c main.c devtty.c
DISCARD_CSRCS = discard.c
DISCARD_DSRCS = ../../dev/tinyide_discard.c
DSRCS = ../../dev/tinyide.c ../../dev/tinydisk.c ../../dev/tinydisk_discard.c
DASRCS =
NSRCS =

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

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

CROSS_CCOPTS += -I../../dev/ -I../../dev/net/

JUNK = *.rel *.lst *.asm *.sym *.rst *.map *.ihx *.bin
JUNK = *.o

all: $(OBJS)

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

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

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

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

$(DISCARD_COBJS): %.rel: %.c
$(DISCARD_COBJS): %.o: %.c
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -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 $<

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

image: loader.bin

loader.bin: loader.s
sdasz80 -o loader.s
sdldz80 -i loader.rel
makebin -s 65536 loader.ihx loader.tmp
$(CROSS_LD) -b -C 0x0100 -S 0xF000 -f CLDBbXSs -o fuzix.bin \
crt0.o commonmem.o searle.o ../../start.o \
../../version.o ../../cpu-z80u/lowlevel-z80u-thunked.o \
../../usermem.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/simple.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 -o loader.o
ldz80 -b -C 0 loader.o -o loader.tmp
dd if=loader.tmp bs=256 skip=208 of=loader.bin


Expand Down
8 changes: 8 additions & 0 deletions Kernel/platform/platform-searle/commonmem.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;
; Standard common. Nothing special here except to remember that writes
; to common space won't write through all banks
;
.common

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

65 changes: 60 additions & 5 deletions Kernel/platform/platform-searle/commonmem.s
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
# 0 "commonmem.S"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "commonmem.S"
;
; Standard common. Nothing special here except to remember that writes
; to common space won't write through all banks
; Standard common. Nothing special here except to remember that writes
; to common space won't write through all banks
;
.module commonmem
.common

# 1 "../../cpu-z80u/std-commonmem.s" 1
# 0 "../../cpu-z80u/std-commonmem.S"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "../../cpu-z80u/std-commonmem.S"
;
;
; 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
istack_top:
istack_switched_sp: .word 0
# 8 "commonmem.S" 2
2 changes: 1 addition & 1 deletion Kernel/platform/platform-searle/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ extern uint16_t swap_dev;

#define CONFIG_TD_NUM 2
#define CONFIG_TD_IDE
#define CONFIG_TINYIDE_SDCCPIO
#define CONFIG_TINYIDE_8BIT
#define CONFIG_TINYIDE_INDIRECT
#define IDE_IS_8BIT(x) 1

/* Device parameters */
Expand Down
38 changes: 38 additions & 0 deletions Kernel/platform/platform-searle/crt0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; 2015-02-20 Sergey Kiselev
; 2013-12-18 William R Sowerbutts

#include "kernelu.def"

; startup code (0x100)
.code
init:
di
; switch to stack in high memory
ld sp, kstack_top

; move the common memory where it belongs
ld hl, __bss
ld de, __common
ld bc, __common_size
ldir
; and the discard
ld de, __discard
ld bc, __discard_size
ldir

ld hl, __bss
ld de, __bss + 1
ld bc, __bss_size - 1
ld (hl), 0
ldir

; Hardware setup
call init_hardware

; Call the C main routine
call _fuzix_main

; fuzix_main() shouldn't return, but if it does...
di
stop: halt
jr stop
91 changes: 38 additions & 53 deletions Kernel/platform/platform-searle/crt0.s
Original file line number Diff line number Diff line change
@@ -1,80 +1,65 @@
# 0 "crt0.S"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "crt0.S"
; 2015-02-20 Sergey Kiselev
; 2013-12-18 William R Sowerbutts

.module crt0
# 1 "kernelu.def" 1
; FUZIX mnemonics for memory addresses etc

; Ordering of segments for the linker.
; WRS: Note we list all our segments here, even though
; we don't use them all, because their ordering is set
; when they are first seen.
.area _CODE
.area _HOME ; compiler stores __mullong etc in here if you use them
.area _CODE2
.area _CONST
.area _INITIALIZED
.area _DATA
.area _BSEG
.area _BSS
.area _HEAP
; note that areas below here may be overwritten by the heap at runtime, so
; put initialisation stuff in here
.area _BUFFERS ; _BUFFERS grows to consume all before it (up to KERNTOP)
.area _INITIALIZER ; binman copies this to the right place for us
.area _GSINIT ; unused
.area _GSFINAL ; unused
.area _DISCARD
.area _DISCARDL
.area _DISCARDH
.area _COMMONMEM
U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000
Z80_TYPE .equ 0 ; CMOS

; exported symbols
.globl init
Z80_MMU_HOOKS .equ 0

; imported symbols
.globl _fuzix_main
.globl init_hardware
.globl s__INITIALIZER
.globl s__COMMONMEM
.globl l__COMMONMEM
.globl s__DISCARD
.globl l__DISCARD
.globl s__DATA
.globl l__DATA
.globl kstack_top
CONFIG_SWAP .equ 1

.include "kernel.def"
PROGBASE .equ 0x0000
PROGLOAD .equ 0x0100

NBUFS .equ 4

;
; Select where to put the high code - in our case we need this
; in common
;

; startup code (0x100)
.area _CODE

HIGHPAGE .equ 0 ; We only have 1 page byte and the low page
; isn't used
# 5 "crt0.S" 2

; startup code (0x100)
.code
init:
di
; switch to stack in high memory
ld sp, #kstack_top
ld sp, kstack_top

; move the common memory where it belongs
ld hl, #s__DATA
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
; move the common memory where it belongs
ld hl, __bss
ld de, __common
ld bc, __common_size
ldir
; and the discard
ld de, #s__DISCARD
ld bc, #l__DISCARD
ld de, __discard
ld bc, __discard_size
ldir

ld hl, #s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
ld hl, __bss
ld de, __bss + 1
ld bc, __bss_size - 1
ld (hl), 0
ldir

; Hardware setup
call init_hardware

; Call the C main routine
call _fuzix_main

; fuzix_main() shouldn't return, but if it does...
di
stop: halt
stop: halt
jr stop
Loading

0 comments on commit 8178aec

Please sign in to comment.