bool copy_bootrom(void) {
const int size = 8*1024;
int i;
unsigned char buf[size];
int fd, w;
int old = disable_irq_save();
cpucache_invalidate();
DEVID &= ~(1<<31);
SCU_REMAP = 0;
for (i = 0; i < size; i++) {
buf[i] = (*(volatile unsigned char*)(i));
}
SCU_REMAP = 0xDEADBEEF;
DEVID |= (1<<31);
restore_irq(old);
fd = creat("/bootrom.bin", 0666);
if (fd < 0) {
return false;
}
else {
w = write(fd, buf, size);
if (w < 0)
return false;
close(fd);
}
return true;
}