static inline __attribute__((unused)) int do_normal_boot(void) { unsigned char byte; if (cmos_error() || !cmos_chksum_valid()) { /* Invalid CMOS checksum detected! * Force fallback boot... */ byte = cmos_read(RTC_BOOT_BYTE); byte &= boot_set_fallback(byte) & 0x0f; byte |= 0xf << 4; cmos_write(byte, RTC_BOOT_BYTE); } /* The RTC_BOOT_BYTE is now o.k. see where to go. */ byte = cmos_read(RTC_BOOT_BYTE); /* Are we attempting to boot normally? */ if (boot_use_normal(byte)) { /* Are we already at the max count? */ if (boot_count(byte) < CONFIG_MAX_REBOOT_CNT) byte = increment_boot_count(byte); else byte = boot_set_fallback(byte); } /* Save the boot byte */ cmos_write(byte, RTC_BOOT_BYTE); /* Return selected code path for this boot attempt */ return boot_use_normal(byte); }
static inline void check_cmos( void ) { char *cmos_default = NULL; int i; #if DUMP_CMOS_RAM u8 c = 0; #endif if (cmos_error() || !cmos_chksum_valid()) { cmos_default = cbfs_find_file("cmos.default", 0xaa); if (cmos_default) { #if DUMP_CMOS_RAM __DEBUG__("Write cmos default ...\n"); #endif outb(0x0a,0x72); i = inb(0x73); i &= ~(1 << 4); outb(i,0x73); for (i = 14; i < 128; i++) { #if DUMP_CMOS_RAM if( c%16 == 0 ) __DEBUG__("%02x:", i); __DEBUG__(" %02x", (u8)cmos_default[i]); if( c%16 == 15 ) __DEBUG__("\n"); c++; #endif outb(i,0x72); outb(cmos_default[i],0x73); } #if DUMP_CMOS_RAM __DEBUG__("\n"); #endif if( !cmos_chksum_valid() ) __DEBUG__("CMOS CHECKSUM ERROR\n"); /* Now reboot to run with default cmos. */ outb(0x06, 0xcf9); for (;;) asm("hlt"); /* Wait for reset! */ } } // update altcentury outb(0x32, 0x72); i = inb(0x73); if ( i != 0x20 ) { outb(0x20,0x73); set_chksum(LB_CKS_RANGE_START, LB_CKS_RANGE_END, LB_CKS_LOC); } }