diff --git a/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c b/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c new file mode 100644 index 0000000000..8e410e6e22 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c @@ -0,0 +1,28 @@ +#include +#include +#include + + +uint8 sector[512]; + +int main(int argc, char **argv) +{ + int fd, i; + uint16 sum; + uint16 *p = (uint16 *)sector; + fd = open(argv[1], O_RDWR); + if (fd < 0) { + return 1; + } + if (read(fd, sector, 512-2) < 512) { + perror("read"); + return 1; + } + for (sum = 0, i = 0; i < (512-2)/2; i++) { + sum += B_LENDIAN_TO_HOST_INT16(p[i]); + } + p[(512-2)/2] = B_HOST_TO_BENDIAN_INT16(0x1234 - sum); + //lseek(fd, 0LL, SEEK_SET); + write(fd, §or[512-2], 2); + return 0; +} diff --git a/src/system/boot/platform/atari_m68k/shell.S b/src/system/boot/platform/atari_m68k/shell.S index d75ad10c42..2ae1fea74b 100644 --- a/src/system/boot/platform/atari_m68k/shell.S +++ b/src/system/boot/platform/atari_m68k/shell.S @@ -69,7 +69,12 @@ floppy_start: // load at base + this code. move.l #ATARI_ZBEOS_BASE+512,%a2 bsr load_sectors - + tst.l %d0 + beq floppy_done + lea failure_string,%a0 + jsr puts + bra spin +flopy_done: jmp #ATARI_ZBEOS_BASE+512 /** Loads %d2 sectors from floppy disk, starting at head XXX %dh, sector %cx. @@ -91,12 +96,16 @@ load_sectors: floppy_end: // .org FAILURE_STRING +failure_string: .string " Loading failed! Press key to reboot.\r\n" + // .org DOT_STRING .string "." -// .org 0x01fe - .word 0xaa55 +//shell_end: +// .skip 0x01fe - tmp_floppy_end +//// .org 0x01fe +// .word 0xaa55 // this bumps the "start" label to offset 0x0200 as // expected by the BFS boot loader, and also marks // this block as valid boot block for the BIOS @@ -112,8 +121,8 @@ prg_start: // all done lea unimpl,%a0 jsr puts -prg_spin: - bra prg_spin +spin: + bra spin super_done: @@ -168,3 +177,13 @@ str: .string "Haiku!" unimpl: .string "Unimplemented." + +shell_end: + .skip 0x01fe - tmp_floppy_end +// .org 0x01fe + .word 0xaa55-1 // will be replaced by the one calculated by the build. + // we make sure we PCs don't try to execute it. + // this bumps the "start" label to offset 0x0200 as + // expected by the BFS boot loader, and also marks + // this block as valid boot block for the BIOS + // XXX: actually TOS wants a real checksum here so sum is 0x1234!