Initial draft of a loader that is designed to be a portable Z80 loading tool
that can load Fuzix images out of a Fuzix file system.
+
+Commands
+
+*xxx anything beginning * is handed to the platform specific code
+ so may be relevant or not.
+
+[A-P]: capital required - select drive to load from
+ (will also allow A0-P3 once we do partitions)
+
+any other string is taken as a filename to search for in / of the current
+volume and boot as a kernel image.
.ascii 'Fuzix Intermediate Loader v0.01.\n'
.asciz '(C)2019 Alan Cox\n\n'
- .area _DATA
-
-loadname:
- .ds 31
-ibuf:
- .ds 64
-dbuf:
- .ds 512
-partbase_l:
- .dw 0
-partbase_h:
- .dw 0
-
- .area _CODE
-
partitions:
; No partitions found (hack for now)
ld hl,#0
bread:
ld a,d
or e
- jr nz, bread_disk
+ jp nz, bread_disk
ld d,h
ld e,l
ld bc,#511
djnz cmploop
ret ; Z
+ .area _DATA
+
+loadname:
+ .ds 31
+ibuf:
+ .ds 64
+dbuf:
+ .ds 512
+partbase_l:
+ .dw 0
+partbase_h:
+ .dw 0
;
; Currently this and the glue driver code is well under 2 disk blocks.
; Adding partitions should still fit 2 blocks nicely.
+;
+; Our SCM command 'BOOT' loads the MBR of the media and then runs it
+; if appropriate. We are loaded at 0xF000 and hold all of CODE
+;
+;
+; Section ordering
;
.area _CODE
+ .area _STACK
+ .area _CODE2
+ .area _DATA
;
+; _CODE and _STACK goes in the boot sector.
+; _CODE2 and _DATA are split across them or beyond (as data is
+; uninitialized
+;
+ .area _CODE
+
+;
+; So we can check set up
+;
+ .globl start
+ .globl stack
+;
; Magic for the loader
;
.byte 'Z'
.byte 80
;
-; Loader core
+; We have 446 bytes of space in the boot sector before the
+; partitions that is loaded (and the partition table), but we
+; need to load the second sector holding the core of FILO
;
- .include '../filo/filo.s'
+
+start:
+ ld sp, #stack
+ ld bc, #0xF200 ; Straight after us
+ ld hl, #0x0001 ; Sector 1
+ ld de, #0x0000
+ call bread_raw
+ jp boot_begin ; Run FILO
+
;
; ****************************************************************************
;
xor a
ret
;
+; Private helper
+;
+bread_raw:
+ push hl
+ ld h,b
+ ld l,c
+ jr nocarry_lba
+;
; Timeout might be a good idea
;
ide_ready:
ld c,#0x0a
ld de,#0x10
jr mcall
+
+ .area _STACK
+
+ .ds 16
+stack:
+
+ .area _CODE2
+
+;
+; Loader core loaded from sector 1
+;
+ .include '../filo/filo.s'