* Moved checksum to where it should be.

* Added tool to calculate the checksum (TOS wants a real one to 1234, not aa55).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23483 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-13 10:53:35 +00:00
parent df0e96bcef
commit 551d3012d8
2 changed files with 52 additions and 5 deletions

View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <OS.h>
#include <ByteOrder.h>
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, &sector[512-2], 2);
return 0;
}

View File

@ -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!