Author: tkreuzer Date: Sat Nov 8 19:05:22 2014 New Revision: 65326
URL: http://svn.reactos.org/svn/reactos?rev=65326&view=rev Log: [FREELDR] Check for CPU compatibility early and bugcheck if the CPU is too old. Based on patch by winocm. CORE-6427
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c trunk/reactos/boot/freeldr/freeldr/freeldr.c trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] Sat Nov 8 19:05:22 2014 @@ -59,6 +59,12 @@ };
/* FUNCTIONS ******************************************************************/ + +VOID +FrLdrCheckCpuCompatiblity(VOID) +{ + /* Nothing for now */ +}
VOID ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Sat Nov 8 19:05:22 2014 @@ -1788,7 +1788,51 @@ /* * No futher processing here. * Optionally implement HLT instruction handling. - */ -} + */ +} + +VOID +FrLdrCheckCpuCompatiblity(VOID) +{ + INT CpuInformation[4] = {-1}; + ULONG NumberOfIds; + + /* Check if the processor first supports ID 1 */ + __cpuid(CpuInformation, 0); + + NumberOfIds = CpuInformation[0]; + + if (NumberOfIds == 0) + { + FrLdrBugCheckWithMessage(MISSING_HARDWARE_REQUIREMENTS, + __FILE__, + __LINE__, + "ReactOS requires the CPUID instruction to return " + "more than one supported ID.\n\n"); + } + + /* NumberOfIds will be greater than 1 if the processor is new enough. */ + if (NumberOfIds == 1) + { + INT ProcessorFamily; + + /* Get information. */ + __cpuid(CpuInformation, 1); + + ProcessorFamily = (CpuInformation[0] >> 8) & 0xF; + + /* If it's Family 4 or lower, bugcheck. */ + if(ProcessorFamily < 5) + { + FrLdrBugCheckWithMessage(MISSING_HARDWARE_REQUIREMENTS, + __FILE__, + __LINE__, + "Processor is too old (family %u < 5)\n" + "ReactOS requires a Pentium-level processor or newer.", + ProcessorFamily); + } + } +} +
/* EOF */
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freeld... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr.c [iso-8859-1] Sat Nov 8 19:05:22 2014 @@ -37,6 +37,9 @@
TRACE("BootMain() called.\n");
+ /* Check if the CPU is new enough */ + FrLdrCheckCpuCompatiblity(); + if (!UiInitialize(FALSE)) { UiMessageBoxCritical("Unable to initialize UI.\n"); @@ -50,10 +53,10 @@ }
#ifdef _M_IX86 - HalpInitializePciStubs(); - HalpInitBusHandler(); + HalpInitializePciStubs(); + HalpInitBusHandler(); #endif - RunLoader(); + RunLoader();
quit: /* If we reach this point, something went wrong before, therefore reboot */
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] Sat Nov 8 19:05:22 2014 @@ -121,5 +121,6 @@ VOID BootMain(LPSTR CmdLine); VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem); VOID RunLoader(VOID); +VOID FrLdrCheckCpuCompatiblity(VOID);
#endif /* __FREELDR_H */