UINT32 GetSystemMemorySizeBelow4gb ( VOID ) { UINT8 Cmos0x34; UINT8 Cmos0x35; // // CMOS 0x34/0x35 specifies the system memory above 16 MB. // * CMOS(0x35) is the high byte // * CMOS(0x34) is the low byte // * The size is specified in 64kb chunks // * Since this is memory above 16MB, the 16MB must be added // into the calculation to get the total memory size. // Cmos0x34 = (UINT8) CmosRead8 (0x34); Cmos0x35 = (UINT8) CmosRead8 (0x35); return (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB); }
VOID BootModeInitialization ( VOID ) { EFI_STATUS Status; if (CmosRead8 (0xF) == 0xFE) { mBootMode = BOOT_ON_S3_RESUME; } Status = PeiServicesSetBootMode (mBootMode); ASSERT_EFI_ERROR (Status); Status = PeiServicesInstallPpi (mPpiBootMode); ASSERT_EFI_ERROR (Status); }
VOID DebugDumpCmos ( VOID ) { UINTN Loop; DEBUG ((EFI_D_INFO, "CMOS:\n")); for (Loop = 0; Loop < 0x80; Loop++) { if ((Loop % 0x10) == 0) { DEBUG ((EFI_D_INFO, "%02x:", Loop)); } DEBUG ((EFI_D_INFO, " %02x", CmosRead8 (Loop))); if ((Loop % 0x10) == 0xf) { DEBUG ((EFI_D_INFO, "\n")); } } }
STATIC UINT64 GetSystemMemorySizeAbove4gb ( ) { UINT32 Size; UINTN CmosIndex; // // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. // * CMOS(0x5d) is the most significant size byte // * CMOS(0x5c) is the middle size byte // * CMOS(0x5b) is the least significant size byte // * The size is specified in 64kb chunks // Size = 0; for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) { Size = (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex); } return LShiftU64 (Size, 16); }