int LAL_ERR_RTRN( LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id ) { if ( stat->statusCode ) { FAILMSG( stat, func, file, line, id ); } return stat->statusCode; }
int LAL_ERR_ABRT( LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id ) { if ( stat->statusCode ) { FAILMSG( stat, func, file, line, id ); abort(); } return 0; }
ULONG DetectMPS( OUT PBOOLEAN IsConfiguredMp ) /*++ Routine Description: This function is called from HalInitializeProcessors to determine if this is an appropriate system to run the MPS hal on. The recommended detection mechanism is: if ( MPS information does not exist ) then System is not MPS compliant. Return false. In MP table: if ( number IO APICs < 1 ) then Not a MPS System - return false if ( # CPUs = 1 ) then Found a Single Processor MPS System else Found a MP MPS System A side effect of this routine is the mapping of the IO UNits and Local unit virtual addresses. Return TRUE Arguments: IsConfiguredMp - TRUE if this machine is a MP instance of the MPS spec, else FALSE. Return Value: 0 - if not a MPS 1 - if MPS */ { UCHAR ApicVersion, i; PUCHAR LocalApic; PPCMPIOAPIC IoEntryPtr; // // Initialize MpInfo table // RtlZeroMemory (&HalpMpInfoTable, sizeof HalpMpInfoTable); // // Set the return Values to the default // *IsConfiguredMp = FALSE; // // See if there is a MP Table // #if 1 if ((PcMpTablePtr = GetPcMpTable()) == NULL) { FAILMSG (rgzNoMpsTable); return(FALSE); } #else //******** //******** HACK! To make down level 1.0 machine work //******** if ((PcMpTablePtr = MPS10_GetPcMpTable()) == NULL) { FAILMSG (rgzNoMpsTable); return(FALSE); } #endif #ifdef SETUP // During setup, if we detected a default MPS configuration, we have // no more checking to do. if (PcMpTablePtr == (struct PcMpTable *) DEFAULT_MPS_INDICATOR) { *IsConfiguredMp = TRUE; return(TRUE); } #endif // SETUP #if DEBUGGING HalpDisplayConfigTable(); #endif // We have a MPS table. Initialize a HAL specific MP information // structure that gets information from the MPS table. HalpInitMpInfo(PcMpTablePtr); // Verify the information in the MPS table as best as we can. if (HalpMpInfoTable.IOApicCount == 0) { // // Someone Has a MP Table and no IO Units -- Weird // We have to assume the BIOS knew what it was doing // when it built the table. so .. // FAILMSG (rgzNoApic); return (FALSE); } // // It's a MPS System. It could be a UP System though. // #ifdef SETUP // // If this is a MPS (MPS) compliant system, but has only 1 processor, // for now we want to install a standard UP kernel and HAL. // if (HalpMpInfoTable.ProcessorCount <= 1) { return FALSE; } #endif if (HalpMpInfoTable.ProcessorCount > 1) { *IsConfiguredMp = TRUE; } HalpMpInfoTable.LocalApicBase = (ULONG) PcMpTablePtr->LocalApicAddress; LocalApic = (PUCHAR) HalpMapPhysicalMemoryWriteThrough( (PVOID) HalpMpInfoTable.LocalApicBase,1); #ifndef SETUP HalpRemapVirtualAddress ( (PVOID) LOCALAPIC, (PVOID) HalpMpInfoTable.LocalApicBase, TRUE ); #endif ApicVersion = (UCHAR) *(LocalApic + LU_VERS_REGISTER); if (ApicVersion > 0x1f) { // // Only known Apics are 82489dx with version 0.x and // Embedded Apics with version 1.x (where x is don't care) // // Return of 0xFF? Can't have an MPS system without a Local Unit. // #ifdef DEBUGGING sprintf(Cbuf, "HALMPS: apic version %x, read from %x\n", ApicVersion, LocalApic + LU_VERS_REGISTER); HalDisplayString(Cbuf); #endif FAILMSG (rgzBadApicVersion); return (FALSE); } #ifdef SETUP // // MP MPS table, and the local APIC ID looked OK. // return TRUE; #endif //SETUP #ifdef DEBUGGING if ((ApicVersion & 0xf0) == 0) { if (HalpMpInfoTable.ApicVersion != APIC_82489DX) HalDisplayString("HAL:Invalid Local Apic version in MP table\n"); else { sprintf(Cbuf, "HAL: DetectMPS: Found 82489DX Local APIC (Ver 0x%x) at 0x%lx\n", ApicVersion, LocalApic); HalDisplayString(Cbuf); } } else { sprintf(Cbuf, "HAL: DetectMPS: Found Embedded Local APIC (Ver 0x%x) at 0x%lx\n", ApicVersion, LocalApic); HalDisplayString(Cbuf); } #endif // DEBUGGING IoEntryPtr = HalpMpInfoTable.IoApicEntryPtr; for(i=0; i < HalpMpInfoTable.IOApicCount; i++, IoEntryPtr++) { if (IoEntryPtr->IoApicFlag & IO_APIC_ENABLED) { // // Verify the existance of the IO Units // HalpMpInfoTable.IoApicPhys[i] = (ULONG) IoEntryPtr->IoApicAddress; HalpMpInfoTable.IoApicBase[i] = (PULONG) HalpMapPhysicalMemoryWriteThrough( (PVOID)(IoEntryPtr->IoApicAddress), 1); // // Verify the existance of the IO Unit // if (!(HalpVerifyIOUnit((PUCHAR)HalpMpInfoTable.IoApicBase[i]))) { FAILMSG (rgzApicNotVerified); return (FALSE); } } } DBGMSG("HAL: DetectMPS: MPS system found - Returning TRUE\n"); return(TRUE); }