6 #define BOOTLDR_SIZE 0x400
7 #define DIAG_TOTAL_SIZE 0x4000
9 char *rombuf, *zerobuf, *devicebuf;
11 int main(int argc, char *argv[]) {
12 FILE *rom = fopen("bootrom", "rb");
14 printf("Could not open file bootrom for reading.\n");
17 FILE *out = fopen("../piscsi.rom", "wb+");
19 printf("Could not open file piscsi.rom for writing.\n");
23 FILE *device = fopen("pi-scsi.device", "rb");
25 printf("Could not open file pi-scsi.device for reading.\n");
31 fseek(device, 0, SEEK_END);
32 fseek(rom, 0, SEEK_END);
33 uint32_t rom_size = ftell(rom);
34 uint32_t device_size = ftell(device);
35 fseek(rom, 0, SEEK_SET);
36 fseek(device, 0, SEEK_SET);
38 uint32_t pad_size = BOOTLDR_SIZE - rom_size;
40 rombuf = malloc(rom_size);
41 devicebuf = malloc(device_size);
42 zerobuf = malloc(pad_size);
43 memset(zerobuf, 0x00, pad_size);
45 fread(rombuf, rom_size, 1, rom);
46 fread(devicebuf, device_size, 1, device);
48 fwrite(rombuf, rom_size, 1, out);
49 fwrite(zerobuf, pad_size, 1, out);
50 fwrite(devicebuf, device_size, 1, out);
53 zerobuf = malloc(DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size));
54 memset(zerobuf, 0x00, DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size));
55 fwrite(zerobuf, DIAG_TOTAL_SIZE - (rom_size + pad_size + device_size), 1, out);
57 printf("piscsi.rom successfully created.\n");