Also checksum the bootsector in the Atari version of haiku_loader.

Remove duplicate of the checksum tool.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2010-10-10 18:28:07 +00:00
parent 06abf33747
commit aed95f3c6c
3 changed files with 22 additions and 35 deletions

View File

@ -67,6 +67,27 @@ KernelMergeObject boot_platform_atari_m68k.o :
boot_arch_m68k_040.o
;
# the bootsector in haiku_loader must be checksummed
rule ChecksumAtariLoader {
local haikuLoader = $(1) ;
local checksummer = <build>fixup_tos_boot_checksum ;
Depends $(haikuLoader) : $(checksummer) ;
TARGET_CHECKSUM on $(haikuLoader) = $(checksummer) ;
}
actions ChecksumAtariLoader bind TARGET_CHECKSUM {
$(TARGET_CHECKSUM) $(1)
}
ChecksumAtariLoader haiku_loader ;
# AUTO folder PRG target
# based on KernelLd

View File

@ -1,35 +0,0 @@
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
uint8_t sector[512];
int main(int argc, char **argv)
{
int fd, i;
uint16_t sum;
uint8_t *p = sector;
fd = open(argv[1], O_RDWR);
if (fd < 0) {
return 1;
}
if (read(fd, sector, 512-2) < 512-2) {
perror("read");
return 1;
}
for (sum = 0, i = 0; i < (512-2)/2; i++) {
uint16_t v;
v = *p++ << 8;
v += *p++;
sum += v;
}
sum = 0x1234 - sum /*+ 1*/;
//sum = 0xaa55;
// big endian
*p++ = (uint8_t)(sum >> 8);
*p++ = (uint8_t)sum;
//lseek(fd, 0LL, SEEK_SET);
write(fd, &sector[512-2], 2);
close(fd);
return 0;
}

View File

@ -31,5 +31,6 @@ int main(int argc, char **argv)
*p++ = (uint8_t)sum;
//lseek(fd, 0LL, SEEK_SET);
write(fd, &sector[512-2], 2);
close(fd);
return 0;
}