From: Alan Cox Date: Sat, 5 Nov 2016 23:45:40 +0000 (+0000) Subject: coco2cart: small fixes X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b14ff4dac38cf9560a8756227e9037e067bd95ac;p=FUZIX.git coco2cart: small fixes This gets us to the point we fail to mount a rootfs. I need to double check the IDE mapping logic and work out why that fails. --- diff --git a/Kernel/platform-coco2cart/Makefile b/Kernel/platform-coco2cart/Makefile index 45403835..dbcf0d6c 100644 --- a/Kernel/platform-coco2cart/Makefile +++ b/Kernel/platform-coco2cart/Makefile @@ -63,5 +63,6 @@ image: ../syscall_exec16.o devtty.o libc.o ../vt.o video.o ../syscall_fs3.o \ ../font8x8.o ../tools/decb-image <../fuzix.bin fuzix.img - - + dd if=fuzix.img of=fuzix.rom bs=1024 skip=48 count=16 + dd if=fuzix.img of=fuzix.ide bs=256 skip=26 count=102 + dd if=fuzix.img of=fuzix.ide bs=256 skip=1 count=1 conv=notrunc diff --git a/Kernel/platform-coco2cart/README b/Kernel/platform-coco2cart/README index faffd06b..ab456951 100644 --- a/Kernel/platform-coco2cart/README +++ b/Kernel/platform-coco2cart/README @@ -42,9 +42,11 @@ Needs the IDE patches TODO ==== -Test it Make the boot loader robust (timeout handling) -Add magic numbers to check we loaded the right thing! +Add hash of code not just simple magic - so we know bits match +Why doesn't coco keyboard auto-mapping work ? +Why don't we find the root fs (IDE mapping bug ?) + Support for a real time clock and clock locking Review irq disabling. We shouldn't need much of this at all as we don't have floppy hell to contend with, but the switchin/switchout logic needs to be @@ -60,6 +62,21 @@ MPI switching We have about 2K left to try and jam those bits in which might just about be enough to add support for very minimal MBR parsing and offsets. That would -be a big improvement and make the current loading of the kernel image from -blocks 1-51 of the disk sensible. If not we need to move it. +be a big improvement. + + +To Test +======= + +Build the image and you'll get a fuzix.ide and fuzix.rom + +In the xroar directory where you have a hard disc image do + +dd if=/tmp/fuzix.ide of=hd0.img bs=512 seek=3 conv=notrunc +/opt/xroaride/bin/xroar -default-machine dragon64 -cart ide -cart-rom fuzix.rom + +(use dragon64 until I fix the coco keymapping stuff) + +exec 49152 +enjoy diff --git a/Kernel/platform-coco2cart/bootstrap.s b/Kernel/platform-coco2cart/bootstrap.s index aaa76a87..d43b67ed 100644 --- a/Kernel/platform-coco2cart/bootstrap.s +++ b/Kernel/platform-coco2cart/bootstrap.s @@ -93,15 +93,28 @@ ud_wipe: std ,x++ cmpx #$1C00 bne ud_wipe -endstr: rts + lda ,x+ + cmpa $15 + bne wrong + lda ,x+ + cmpa $C0 + bne wrong + rts load_error: ldu #fail + bsr copy_str +l1: bra l1 + copy_str: lda ,u+ beq endstr sta ,y+ bra copy_str +endstr: rts fail: .ascii "Fail" .db 0 +wrong: + .ascii "Wrong image" + .db 0 diff --git a/Kernel/platform-coco2cart/coco2.s b/Kernel/platform-coco2cart/coco2.s index 19b3632e..3cc0e703 100644 --- a/Kernel/platform-coco2cart/coco2.s +++ b/Kernel/platform-coco2cart/coco2.s @@ -84,6 +84,7 @@ init_hardware: lda 0xFF03 ora #1 sta 0xFF03 + jsr _vid256x192 jsr _vtinit rts @@ -122,9 +123,11 @@ ___hard_irqrestore: ; B holds the data ; No memory management for now ; _program_vectors: + rts + map_kernel: pshs a - clr $ffdf ; ROM in + clr $ffde ; ROM in lda #1 map_kr: sta romin @@ -133,7 +136,7 @@ map_kr: map_process: map_process_always: map_process_a: - clr $ffde ; ROM out + clr $ffdf ; ROM out clr romin rts @@ -142,7 +145,7 @@ map_restore: lda romsave sta romin bne map_kr - clr $ffde + clr $ffdf puls a,pc map_save: diff --git a/Kernel/platform-coco2cart/crt0.s b/Kernel/platform-coco2cart/crt0.s index 83b4e369..e3a00c29 100644 --- a/Kernel/platform-coco2cart/crt0.s +++ b/Kernel/platform-coco2cart/crt0.s @@ -51,3 +51,6 @@ identified: orcc #0x10 stop: bra stop + .area .magic + .db $15,$C0,$DE,$4C,$0C,$02 + diff --git a/Kernel/platform-coco2cart/discard.c b/Kernel/platform-coco2cart/discard.c index 17917697..de6fbfcd 100644 --- a/Kernel/platform-coco2cart/discard.c +++ b/Kernel/platform-coco2cart/discard.c @@ -9,6 +9,7 @@ static const char *sysname[] = {"Dragon", "COCO", "COCO3", "Unknown"}; +#if 0 struct cart_rom_id { uint16_t hash; uint8_t id; @@ -35,15 +36,21 @@ static struct cart_rom_id *cart_lookup(uint16_t hash) } while(cart++->hash); return NULL; } +#endif void map_init(void) { uint8_t i; +#if 0 uint8_t bslot = 0; uint16_t hash; struct cart_rom_id *rom; +#endif kprintf("%s system.\n", sysname[system_id]); +#if 0 + /* We would have to do the mpi management in asm and we really + don't have enough memory to care about this ! */ if (mpi_present()) { kputs("MPI cartridge detected.\n"); cartslots = 4; @@ -66,6 +73,7 @@ void map_init(void) i == bslot ? '*':' '); } mpi_set_slot(bootslot); +#endif /* We put swap on the start of slice 0, but with the first 64K free so we can keep the OS image linearly there */ for (i = 0; i < MAX_SWAPS; i++) diff --git a/Kernel/platform-coco2cart/main.c b/Kernel/platform-coco2cart/main.c index 293b2179..0c2114c7 100644 --- a/Kernel/platform-coco2cart/main.c +++ b/Kernel/platform-coco2cart/main.c @@ -9,9 +9,11 @@ uint8_t membanks; uint8_t system_id; +#if 0 uint8_t cartslots = 1; uint8_t carttype[4]; uint8_t bootslot = 0; +#endif uint16_t swap_dev; void platform_idle(void) @@ -30,7 +32,7 @@ void do_beep(void) void platform_discard(void) { } - +#if 0 /* Find a cartridge or it's slot */ int cart_find(int id) { @@ -41,6 +43,7 @@ int cart_find(int id) } return -1; } +#endif unsigned char vt_mangle_6847(unsigned char c) { diff --git a/Kernel/platform-coco2cart/mini_ide_discard.c b/Kernel/platform-coco2cart/mini_ide_discard.c index 49eff530..6bab6f96 100644 --- a/Kernel/platform-coco2cart/mini_ide_discard.c +++ b/Kernel/platform-coco2cart/mini_ide_discard.c @@ -51,6 +51,8 @@ static void ide_identify(int dev, uint8_t *buf) giveup = set_timer_ms(2000); + kprintf("%x : ", dev); + if (ide_wait_nbusy() == -1) return; *devh = dev << 4; /* Select */ @@ -71,12 +73,14 @@ static void ide_identify(int dev, uint8_t *buf) return; if (ide_wait_drdy() == -1) return; - kprintf("%x : ", dev); /* Check the LBA bit is set, and print the name */ dptr = buf + 54; /* Name info */ if (*dptr) - for (i = 0; i < 40; i++) - kputchar(*dptr++); + for (i = 0; i < 20; i++) { + kputchar(dptr[1]); + kputchar(*dptr); + dptr += 2; + } if (!(buf[99] & 0x02)) { /* No LBA ? */ kputs(" - non-LBA\n"); return; diff --git a/Kernel/platform-coco2cart/video.s b/Kernel/platform-coco2cart/video.s index ab65cb30..5ab0caca 100644 --- a/Kernel/platform-coco2cart/video.s +++ b/Kernel/platform-coco2cart/video.s @@ -59,8 +59,8 @@ _plot_char: lda 4,s bsr vidaddr ; preserves X (holding the char) tfr x,d - anda $7F ; no high font bits - suba $20 ; skip control symbols + andb #$7F ; no high font bits + subb #$20 ; skip control symbols rolb ; multiply by 8 rola rolb