#define MIN_ADDRESS 0xFF810000
#define FW_SIZE 0x400000
#define START_SECTOR 2048
typedef int (*f_w)(int, int, int, int); // drive(?), start sector, number of sectors, address
int main() {
int i;
unsigned long sa;
f_w wr;
for (i=0x1900;i<0xF0000;i+=4)
if ((*(unsigned int*)(i+0x34)==0) &&
(*(unsigned int*)(i+0x38)==0) &&
(*(unsigned int*)(i+0x3C)==3) &&
(*(unsigned int*)(i+0x4C)>MIN_ADDRESS) &&
(*(unsigned int*)(i+0x50)>MIN_ADDRESS) ) {
wr=(f_w)*(unsigned int*)(i+0x50);
#if defined (DRYOS)
// #warning DRYOS
// jeff666: fill some memory with zeroes; "simulate" large diskboot
// WARNING: the starting address is a guess
for (i = 0x1c00; i<0x30000; i+=4) *(int*)i=0;
#elif defined (VXWORKS)
// #warning VXWORKS
#else
#error OS type must be defined
#endif
sa=(unsigned long)wr>0xFFC00000 ? 0xFFC00000 : 0xFF810000;
wr(0, START_SECTOR, FW_SIZE/512, sa);
}
while(1);
return 0;
}
I understand that it writes a raw stream of data, no FAT and stuff, and that the big empty file is supposed to catch the data (assuming that sectors are consecutive).
But I do not understand how it does so.
For example, I am totally confused by: typedef int (*f_w)(int, int, int, int); // drive(?), start sector, number of sectors, address. How exactly does it work?