From: Alan Cox Date: Fri, 17 Aug 2018 22:23:46 +0000 (+0100) Subject: sam: Get to the point we enter the kernel X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=36438e23f567f9470d6d1c8479da99469a806f57;p=FUZIX.git sam: Get to the point we enter the kernel Fix for binman to allow for our page below code Assorted logic fixes to the boot and setup code Make crt0 map the high kernel bank Video is still broken and we die early in setup but we made it into C --- diff --git a/Kernel/platform-sam/Makefile b/Kernel/platform-sam/Makefile index e09d60f3..d077d334 100644 --- a/Kernel/platform-sam/Makefile +++ b/Kernel/platform-sam/Makefile @@ -45,10 +45,12 @@ image: boot setup dd if=/dev/zero of=fuzix.raw bs=512 count=1600 # Boot block at track 4 sector 1 dd if=boot.bin of=fuzix.raw bs=512 seek=40 count=1 conv=notrunc - # Kernel from track 4 sector 2 - dd if=../fuzix.bin of=fuzix.raw bs=512 seek=41 conv=notrunc + # Kernel from track 4 sector 2 highest 32K first + dd if=../fuzix.bin of=fuzix.raw bs=512 seek=41 skip=64 count=64 conv=notrunc + # Low 32K next + dd if=../fuzix.bin of=fuzix.raw bs=512 seek=105 count=64 conv=notrunc # Font and setup from 64K further on - dd if=setup.bin of=fuzix.raw bs=512 seek=169 conv=notrunc + dd if=setup.bin of=fuzix.raw bs=512 seek=169 skip=64 conv=notrunc # Now shuffle it into a .mgt file ../tools/raw2mgt fuzix.raw fuzix.mgt diff --git a/Kernel/platform-sam/boot.s b/Kernel/platform-sam/boot.s index 02a3e31a..fefb1dc5 100644 --- a/Kernel/platform-sam/boot.s +++ b/Kernel/platform-sam/boot.s @@ -43,7 +43,7 @@ boot: jp go go: ld sp,#go - ld de,#0x0401 ; track 4 sector 2 (we are sector 1) + ld de,#0x0402 ; track 4 sector 2 (we are sector 1) ld a,e ; Start in bank 2 ld hl,#0x8000 ; Which we map high out (HIMEM),a @@ -59,7 +59,7 @@ next_sec: ex af,af' still_good: ld a,e ; update the sector register - ld (SECTOR),a + out (SECTOR),a dread: ld a,#CMD_READ ; Ask for data from the FDC out (CMD),a ld b,#20 ; Wait for FDC diff --git a/Kernel/platform-sam/crt0.s b/Kernel/platform-sam/crt0.s index d0ef9148..e7f0cf53 100644 --- a/Kernel/platform-sam/crt0.s +++ b/Kernel/platform-sam/crt0.s @@ -44,8 +44,13 @@ ; ; Once the loader completes it jumps here +; Our low bank is set, our high bank is still setup ; start: + ; Map the kernel high bank + ld a,#4 + out (251),a +l1: jp l1 ld sp, #kstack_top ; move the common memory where it belongs ld hl, #s__DATA diff --git a/Kernel/platform-sam/sam.s b/Kernel/platform-sam/sam.s index a841e4bd..b437f21e 100644 --- a/Kernel/platform-sam/sam.s +++ b/Kernel/platform-sam/sam.s @@ -281,9 +281,8 @@ rst38: jp interrupt_high ; Interrupt handling stub nop nop nop - ; 40 - .ds 0x26 -nmi_handler: ; FIXME: check ends up at 0066 + .ds 0x27 +nmi_handler: ; Should be at 0x66 retn .area _PAGEH diff --git a/Kernel/platform-sam/setup.lnk b/Kernel/platform-sam/setup.lnk index ceacb937..c7322d08 100644 --- a/Kernel/platform-sam/setup.lnk +++ b/Kernel/platform-sam/setup.lnk @@ -1,5 +1,6 @@ -m -i setup.ihx +-b _BOOTSTRAP=0x8000 setup.rel ../font8x8_exp2.rel -e diff --git a/Kernel/platform-sam/setup.s b/Kernel/platform-sam/setup.s index 5825b3a8..bdce0c5a 100644 --- a/Kernel/platform-sam/setup.s +++ b/Kernel/platform-sam/setup.s @@ -12,18 +12,26 @@ .globl _fontdata_8x8_exp2 .area _BOOTSTRAP + .area _FONT + + .area _BOOTSTRAP MODE3 .equ 0x40 ; I think ? +LOMEM .equ 250 +VIDEO .equ 252 +BORDER .equ 254 bootstrap: ; Blue border for debugging ld a,#1 - out (254),a + out (BORDER),a ; ; The kernel low 32K is currently sitting in 4/5 not 0/1 so ; move it. The upper 32K is already in 2/3 ; ld de,#0x2420 + ld sp,#here +here: call copy16k ld de,#0x2521 call copy16k @@ -33,7 +41,7 @@ bootstrap: ; ; Map bank 4/5 low ld a,#0x24 - out (250),a + out (LOMEM),a ; Put the font data where it belongs ld hl,#_fontdata_8x8_exp2 ld de,#0xE000-0x8000 @@ -44,26 +52,26 @@ bootstrap: ; ; Put the video in the right place and set the mode ld a,#4 + MODE3 - out (252),a + out (VIDEO),a ; Map the kernel low ld a,#0x20 ; ROM off bank 0/1 - out (250),a + out (LOMEM),a ; Black border to hint where we got to xor a - out (254),a + out (BORDER),a jp 0x100 ; ; Move 16K via a bounce buffer ; copy16k: ld a,d ; soure bank - out (250),a + out (LOMEM),a ld a,e ld hl,#0x0000 ld de,#0xC000 ; buffer via bank 7 ld bc,#0x4000 ldir - out (250),a ; dest bank + out (LOMEM),a ; dest bank ld hl,#0xC000 ld de,#0x0000 ld bc,#0x4000 diff --git a/Kernel/tools/binman.c b/Kernel/tools/binman.c index ab54fd53..d8af1563 100644 --- a/Kernel/tools/binman.c +++ b/Kernel/tools/binman.c @@ -10,7 +10,7 @@ static unsigned int s__CODE, s__CODE2, s__INITIALIZER, s__DATA, s__INITIALIZED, s__INITIALIZER, s__COMMONMEM, s__VIDEO, l__INITIALIZED, l__GSFINAL, l__GSINIT, l__COMMONMEM, s__FONT, l__FONT, s__DISCARD, l__DISCARD, l__CODE, l__CODE2, l__VIDEO, l__DATA, s__CONST, l__CONST, - s__HEAP, l__HEAP; + s__HEAP, l__HEAP, s__PAGE0 = 0xFFFF; static void ProcessMap(FILE * fp) @@ -73,6 +73,8 @@ static void ProcessMap(FILE * fp) sscanf(p1, "%x", &s__HEAP); if (strcmp(p2, "l__HEAP") == 0) sscanf(p1, "%x", &l__HEAP); + if (strcmp(p2, "s__PAGE0") == 0) + sscanf(p1, "%x", &s__PAGE0); } } @@ -152,6 +154,9 @@ int main(int argc, char *argv[]) /* Our standard layout begins with the code */ start = s__CODE; + /* But for some cases we have a 0 page we need to keep */ + if (s__PAGE0 != 0xFFFF) + start = 0; /* TODO: Support a proper discardable high discard in other mappings */