time_t GetCMOSTime() { struct tm tm; // Assume that we already aren't in a CMOS update tm.tm_sec = ReadCMOS(CMOS_RTC_SECONDS); tm.tm_min = ReadCMOS(CMOS_RTC_MINUTES); tm.tm_hour = ReadCMOS(CMOS_RTC_HOURS); tm.tm_mday = ReadCMOS(CMOS_RTC_DAY_MONTH); tm.tm_wday = ReadCMOS(CMOS_RTC_DAY_WEEK); tm.tm_mon = ReadCMOS(CMOS_RTC_MONTH); tm.tm_year = ReadCMOS(CMOS_RTC_YEAR); int century = ReadCMOS(CMOS_CENTURY); int RegisterB = ReadCMOS(CMOS_STATUS_B); // Fix BCD crap if (!(RegisterB & 0x04)) { tm.tm_sec = BCD2BIN(tm.tm_sec); tm.tm_min = BCD2BIN(tm.tm_min); tm.tm_hour = BCD2BIN(tm.tm_hour); tm.tm_mday = BCD2BIN(tm.tm_mday); tm.tm_wday = BCD2BIN(tm.tm_wday); tm.tm_mon = BCD2BIN(tm.tm_mon); tm.tm_year = BCD2BIN(tm.tm_year); century = BCD2BIN(century); } // Convert from 12 hour to 24 hour if necessary if (!(RegisterB & 0x02) && (tm.tm_hour & 0x80)) tm.tm_hour = ((tm.tm_hour & 0x7F) + 12) % 24; // Fix the year tm.tm_year += century * 100; return mktime(&tm); }
PUCHAR NCRDeterminePlatform( OUT PBOOLEAN IsConfiguredMp ) /*++ Routine Description: Determine on which NCR platform we are running. For now just display a message. Later we may not continue the boot if we're on an unrecognized platform. Arguments: none. Return Value: Pointer to character string identifying which NCR platform. NULL means it is unrecognized, and we shouldn't continue. --*/ { BOOLEAN Matchfound; MSBUPlatformMapEntry *MSBUPlatformMapPtr; PVOID BIOSPagePtr; PUCHAR StringPtr; PUCHAR CopyrightPtr; PUCHAR SearchPtr; UCHAR CpuFlags; // first check for a WPD platform by searching the 0xE000 BIOS segment // for a ROM string that identifies this system as a 3360 // get virtual address to the BIOS region (assuming region is both // page aligned and multiple pages in size) BIOSPagePtr = HalpMapPhysicalMemory((PVOID) WPDStringIDRangeStart, (WPDStringIDRangeSize >> 12)); if (BIOSPagePtr != NULL) { SearchPtr = BIOSPagePtr; // begin search at start of region Matchfound = FALSE; // search until string is found or we are beyond the region while (!Matchfound && (SearchPtr <= (PUCHAR)((ULONG)BIOSPagePtr + WPDStringIDRangeSize - WPDStringIDLength))) { // see if SearchPtr points to the desired string StringPtr = (PUCHAR)((ULONG)SearchPtr++); CopyrightPtr = WPDStringID; // continue compare as long as characters compare // and not at end of string while ((Matchfound = (*CopyrightPtr++ == *StringPtr++)) && (CopyrightPtr < WPDStringID + WPDStringIDLength)); } // see if string was found (i.e., if this is a 3360) if (Matchfound) { // store system identifier ("3360") for later HAL use NCRPlatform = NCR3360; // read CPU good flags from CMOS and determine if MP ReadCMOS(0x88A, 1, &CpuFlags); // *IsConfiguredMp = (CpuFlags & (CpuFlags-1)) ? TRUE : FALSE; // This is an MP hal *IsConfiguredMp = TRUE; return(WPDPlatformName); } } // now check for an MSBU platform /* * Map in the BIOS text so we can look for our copyright string. */ BIOSPagePtr = (PVOID)((ULONG)MSBUCopyrightPhysicalPtr & ~(PAGE_SIZE - 1)); BIOSPagePtr = HalpMapPhysicalMemory(BIOSPagePtr, 2); if (BIOSPagePtr == NULL) return(NULL); StringPtr = (PUCHAR)((ULONG)BIOSPagePtr + ((ULONG)MSBUCopyrightPhysicalPtr & (PAGE_SIZE - 1))) + (MSBUCopyrightStringLen - 1); CopyrightPtr = MSBUCopyrightString + (MSBUCopyrightStringLen - 1); do { Matchfound = ((*CopyrightPtr == '?') || (*CopyrightPtr == *StringPtr)); --CopyrightPtr; --StringPtr; } while (Matchfound && (CopyrightPtr >= MSBUCopyrightString)); // // /* // * Clear the mapping to BIOS. We mapped in two pages. // */ // BIOSPagePtr = MiGetPteAddress(BIOSPagePtr); // *(PULONG)BIOSPagePtr = 0; // *(((PULONG)BIOSPagePtr)+1) = 0; // /* // * Flush the TLB. // */ // _asm { // mov eax, cr3 // mov cr3, eax // } // if (Matchfound) { /* * must be an MSBU machine..determine which. */ ReadCMOS(0xB16, 4, (PUCHAR)&NCRPlatform); for (MSBUPlatformMapPtr = MSBUPlatformMap; (MSBUPlatformMapPtr->ClassFromFirmware != 0); ++MSBUPlatformMapPtr) { if (MSBUPlatformMapPtr->ClassFromFirmware == NCRPlatform) { *IsConfiguredMp = TRUE; return(MSBUPlatformMapPtr->PlatformName); } } /* * prerelease version of firmware had this machine class * at the wrong offset into CMOS. until all those versions * of firmware are extinguished from the face of the earth * we should recognize them with this: */ ReadCMOS(0xAB3, 4, (PUCHAR)&NCRPlatform); for (MSBUPlatformMapPtr = MSBUPlatformMap; (MSBUPlatformMapPtr->ClassFromFirmware != 0); ++MSBUPlatformMapPtr) { if (MSBUPlatformMapPtr->ClassFromFirmware == NCRPlatform) { *IsConfiguredMp = TRUE; return(MSBUPlatformMapPtr->PlatformName); } } } return(NULL); }