2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
16 typedef uint8_t UBYTE
;
17 typedef uint32_t ULONG
;
23 UBYTE BootBlockCode
[0];
24 } __attribute__((packed
));
26 const UBYTE m68k_boot
[] = {
27 0x43, 0xfa, 0x00, 0x18, 0x4e, 0xae, 0xff, 0xa0,
28 0x4a, 0x80, 0x67, 0x0a, 0x20, 0x40, 0x20, 0x68,
29 0x00, 0x16, 0x70, 0x00, 0x4e, 0x75, 0x70, 0xff,
30 0x60, 0xfa, 0x64, 0x6f, 0x73, 0x2e, 0x6c, 0x69,
31 0x62, 0x72, 0x61, 0x72, 0x79, 0x00 };
33 #define BOOTBLOCKSIZE 1024
35 /* Adapted from rom/boot/strap.c */
36 static void BootBlockChecksum(UBYTE
*bootblock
, size_t size
)
41 memset(bootblock
+4, 0, 4);
43 for (i
= 0; i
< size
; i
+= 4) {
44 ULONG v
= (bootblock
[i
] << 24) | (bootblock
[i
+ 1] << 16) |
45 (bootblock
[i
+ 2] << 8) | bootblock
[i
+ 3];
52 bootblock
[4+0] = (crc
>> 24) & 0xff;
53 bootblock
[4+1] = (crc
>> 16) & 0xff;
54 bootblock
[4+2] = (crc
>> 8) & 0xff;
55 bootblock
[4+3] = (crc
>> 0) & 0xff;
59 int main(int argc
, char **argv
)
62 const char *image
= argv
[1];
63 UBYTE buff
[BOOTBLOCKSIZE
];
64 struct BootBlock
*bootblock
= (void *)&buff
[0];
67 fd
= open(image
, O_RDWR
);
73 err
= read(fd
, buff
, sizeof(buff
));
79 lseek(fd
, 0, SEEK_SET
);
81 if (memcmp(bootblock
->DiskType
, "DOS", 3) != 0) {
82 fprintf(stderr
, "%s: Not a DOS (OFS or FFS) disk\n", image
);
87 memset(bootblock
->BootBlockCode
, 0, sizeof(buff
)-sizeof(struct BootBlock
));
89 memcpy(bootblock
->BootBlockCode
, m68k_boot
, sizeof(m68k_boot
));
91 BootBlockChecksum(buff
, sizeof(buff
));
93 err
= write(fd
, buff
, 1024);