//**************************[system_bootloader_error]************************** 26.10.2015 void system_bootloader_error() { // enable read while write section cli(); boot_rww_enable_safe(); sei(); eeprom_busy_wait(); boot_spm_busy_wait(); // send error string bootloader_data_out('e'); bootloader_data_out('r'); bootloader_data_out('r'); bootloader_data_out('o'); bootloader_data_out('r'); bootloader_data_out(13 ); // notify user if (! bootloader_error()) { system_bootloader_reset(); } uint8_t t = 100; // dump every data until there is no more data for 0.1 second while (t--) { if (bootloader_data_stat()) { bootloader_data_in(); t = 100; } delay_ms(1); } }
void bootloader_interrupt_ap_init(void) { t_ia32_idt idt; memcpy(&idt, &init->machine.idt, sizeof (t_ia32_idt)); /* * 1) */ if (idt_activate(&idt) != STATUS_OK) { bootloader_cons_msg('!', "interrupt: error activating idt.\n"); bootloader_error(); } asm volatile("sti"); }
BOOL flash_roms(void) { BYTE flags = 2; if(!flash_module(0x08EB,21, LOAD_DIR"bootfpga.bin", "the bootloader", 3)) { printf("Verifying failed; I will now program it...\n"); if(!flash_module(0x08EB,21, LOAD_DIR"bootfpga.bin", "the bootloader", 3)) { if(!flash_module(0x08EB,21, LOAD_DIR"bootfpga.bin", "the bootloader", 3)) { bootloader_error(); return FALSE; } } } if(!flash_module(0x0808, 4, LOAD_DIR"ar5pal.bin", "Action Replay 5.0 PAL", 2)) { flags = 7; // virgin flash. Retry ar5 if(!flash_module(0x0808, 4, LOAD_DIR"ar5pal.bin", "Action Replay 5.0 PAL", flags)) return FALSE; } if(!flash_module(0x080C, 4, LOAD_DIR"ar6pal.bin", "Action Replay 6.0 PAL", flags)) return FALSE; if(!flash_module(0x0810, 8, LOAD_DIR"final3.bin", "Final Cartridge III", flags)) return FALSE; if(!flash_module(0x0818, 4, LOAD_DIR"sounds.bin", "Drive Sounds", 3)) return FALSE; if(!flash_module(0x081C, 2, LOAD_DIR"sidcrt.bin", "SID Player", 3)) return FALSE; if(!flash_module(0x081E, 2, LOAD_DIR"1541.bin", "CBM 1541 ROM", 3)) return FALSE; if(!flash_module(0x0820, 8, LOAD_DIR"rr38pal.bin", "Retro Replay 3.8 PAL", flags)) return FALSE; if(!flash_module(0x0828, 8, LOAD_DIR"ss5pal.bin", "Super Snapshot V5 PAL", flags)) return FALSE; if(!flash_module(0x0830, 4, LOAD_DIR"ar5ntsc.bin", "Action Replay 5.0 NTSC", flags)) return FALSE; // if(!flash_module(0x0834, 4, LOAD_DIR"ar6ntsc.bin", "Action Replay 6.0 NTSC", flags)) // return FALSE; if(!flash_module(0x0834, 2, LOAD_DIR"1541C.bin", "1541C ROM", flags)) return FALSE; if(!flash_module(0x0836, 2, LOAD_DIR"1541-ii.bin", "1541-II ROM", flags)) return FALSE; if(!flash_module(0x0838, 8, LOAD_DIR"rr38ntsc.bin", "Retro Replay 3.8 NTSC", flags)) return FALSE; if(!flash_module(0x0840, 8, LOAD_DIR"ss5ntsc.bin", "Super Snapshot V5 NTSC", flags)) return FALSE; // if(!flash_module(0x0848, 8, LOAD_DIR"tar_pal.bin", "TAsm / CodeNet PAL", flags)) { flags = 3; // retry if(!flash_module(0x0848, 8, LOAD_DIR"tar_pal.bin", "TAsm / CodeNet PAL", flags)) { return FALSE; } } if(!flash_module(0x0850, 8, LOAD_DIR"tar_ntsc.bin", "TAsm / CodeNet NTSC", flags)) return FALSE; if(!flash_module(0x0858, 2, LOAD_DIR"epyx.bin", "Epyx Fastloader", 3)) return FALSE; if(!flash_module(0x08A0,40, LOAD_DIR"appl.bin", "the application", 3)) return FALSE; return TRUE; }
void bootloader_paging_init(void) { t_uint32 limit; t_uint32 addr; t_uint16 i; t_ia32_page pg; /* * 1) */ if (pd_build(bootloader_init_alloc(PD_MAX_ENTRIES * sizeof(t_ia32_pde), NULL), &pd, 1) != ERROR_NONE) { printf("cannot build a page-directory\n"); bootloader_error(); } /* * 2) */ init->machdep.pd = pd; /* * 3) */ if (pt_build(bootloader_init_alloc(PT_MAX_ENTRIES * sizeof(t_ia32_pte), NULL), &pt0, 1) != ERROR_NONE) { printf("cannot build a page-table\n"); bootloader_error(); } pt0.present = 1; pt0.rw = PT_WRITABLE; pt0.user = PT_PRIVILEGED; pt0.cached = PT_CACHED; pt0.writeback = PT_WRITEBACK; pd_add_table(&pd, 0, pt0); pg.present = 1; pg.rw = PG_WRITABLE; pg.user = PG_PRIVILEGED; pg.cached = PG_CACHED; pg.writeback = PG_WRITEBACK; for (i = 0, addr = PAGESZ; i < PT_MAX_ENTRIES - 1; i++, addr += PAGESZ) { pg.addr = addr; pt_add_page(&pt0, PTE_ENTRY(addr), pg); } /* * 4) */ limit = bootloader_init_alloc(0, NULL); for (addr = init->kcode; addr < limit; addr += PAGESZ) { if (pd_get_table(&pd, PDE_ENTRY(addr), &pt) != ERROR_NONE) { if (pt_build(bootloader_init_alloc(PT_MAX_ENTRIES * sizeof(t_ia32_pte), NULL), &pt, 1) != ERROR_NONE) { printf("cannot build a page-table\n"); bootloader_error(); } pt.present = 1; pt.rw = PT_WRITABLE; pt.user = PT_PRIVILEGED; pt.cached = PT_CACHED; pt.writeback = PT_WRITEBACK; pd_add_table(&pd, PDE_ENTRY(addr), pt); limit += PAGESZ; } pg.addr = addr; pt_add_page(&pt, PTE_ENTRY(addr), pg); } /* * 5) */ pd_activate(pd, PD_CACHED, PD_WRITEBACK); /* * 6) */ paging_enable(); }
void bootloader_interrupt_init(void) { t_ia32_idt idt; t_ia32_gate gate; int i; /* * 1) */ if (idt_build(256, bootloader_init_alloc(256 * sizeof(t_ia32_idte), NULL), 1, &idt) != STATUS_OK) { bootloader_cons_msg('!', "interrupt: error creating idt.\n"); bootloader_error(); } /* * 2) */ if (idt_activate(&idt) != STATUS_OK) { bootloader_cons_msg('!', "interrupt: error activating idt.\n"); bootloader_error(); } /* * 3) */ for (i = 0; i < 256; i++) { gate.offset = (t_uint32)bootloader_interrupt_dummy; gate.segsel = IA32_PMODE_BOOTLOADER_CS << 3; gate.privilege = 0; gate.type = ia32_type_gate_interrupt; if (idt_add_gate(NULL, i, gate) != STATUS_OK) { bootloader_cons_msg('!', "interrupt: error adding gate.\n"); bootloader_error(); } } /* * 4) */ if (pic_init() != STATUS_OK) { bootloader_cons_msg('!', "interrupt: error activating PIC.\n"); bootloader_error(); } asm volatile("sti"); memcpy(&init->machine.idt, &idt, sizeof (t_ia32_idt)); }