ACPI_STATUS AcpiUtValidateFadt ( void) { /* * Verify Fixed ACPI Description Table fields, * but don't abort on any problems, just display error */ if (AcpiGbl_FADT->Pm1EvtLen < 4) { AcpiUtFadtRegisterError ("PM1_EVT_LEN", (UINT32) AcpiGbl_FADT->Pm1EvtLen, ACPI_FADT_OFFSET (Pm1EvtLen)); } if (!AcpiGbl_FADT->Pm1CntLen) { AcpiUtFadtRegisterError ("PM1_CNT_LEN", 0, ACPI_FADT_OFFSET (Pm1CntLen)); } if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address)) { AcpiUtFadtRegisterError ("X_PM1a_EVT_BLK", 0, ACPI_FADT_OFFSET (XPm1aEvtBlk.Address)); } if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aCntBlk.Address)) { AcpiUtFadtRegisterError ("X_PM1a_CNT_BLK", 0, ACPI_FADT_OFFSET (XPm1aCntBlk.Address)); } if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPmTmrBlk.Address)) { AcpiUtFadtRegisterError ("X_PM_TMR_BLK", 0, ACPI_FADT_OFFSET (XPmTmrBlk.Address)); } if ((ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address) && !AcpiGbl_FADT->Pm2CntLen)) { AcpiUtFadtRegisterError ("PM2_CNT_LEN", (UINT32) AcpiGbl_FADT->Pm2CntLen, ACPI_FADT_OFFSET (Pm2CntLen)); } if (AcpiGbl_FADT->PmTmLen < 4) { AcpiUtFadtRegisterError ("PM_TM_LEN", (UINT32) AcpiGbl_FADT->PmTmLen, ACPI_FADT_OFFSET (PmTmLen)); } /* Length of GPE blocks must be a multiple of 2 */ if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) && (AcpiGbl_FADT->Gpe0BlkLen & 1)) { AcpiUtFadtRegisterError ("(x)GPE0_BLK_LEN", (UINT32) AcpiGbl_FADT->Gpe0BlkLen, ACPI_FADT_OFFSET (Gpe0BlkLen)); } if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) && (AcpiGbl_FADT->Gpe1BlkLen & 1)) { AcpiUtFadtRegisterError ("(x)GPE1_BLK_LEN", (UINT32) AcpiGbl_FADT->Gpe1BlkLen, ACPI_FADT_OFFSET (Gpe1BlkLen)); } return (AE_OK); }
acpi_status acpi_hw_initialize ( void) { acpi_status status = AE_OK; u32 index; FUNCTION_TRACE ("Hw_initialize"); /* We must have the ACPI tables by the time we get here */ if (!acpi_gbl_FADT) { acpi_gbl_restore_acpi_chipset = FALSE; ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT!\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* Identify current ACPI/legacy mode */ switch (acpi_gbl_system_flags & SYS_MODES_MASK) { case (SYS_MODE_ACPI): acpi_gbl_original_mode = SYS_MODE_ACPI; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports ACPI mode only.\n")); break; case (SYS_MODE_LEGACY): acpi_gbl_original_mode = SYS_MODE_LEGACY; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n")); break; case (SYS_MODE_ACPI | SYS_MODE_LEGACY): if (acpi_hw_get_mode () == SYS_MODE_ACPI) { acpi_gbl_original_mode = SYS_MODE_ACPI; } else { acpi_gbl_original_mode = SYS_MODE_LEGACY; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports both ACPI and LEGACY modes.\n")); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System is currently in %s mode.\n", (acpi_gbl_original_mode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY")); break; } if (acpi_gbl_system_flags & SYS_MODE_ACPI) { /* Target system supports ACPI mode */ /* * The purpose of this code is to save the initial state * of the ACPI event enable registers. An exit function will be * registered which will restore this state when the application * exits. The exit function will also clear all of the ACPI event * status bits prior to restoring the original mode. * * The location of the PM1a_evt_blk enable registers is defined as the * base of PM1a_evt_blk + DIV_2(PM1a_evt_blk_length). Since the spec further * fully defines the PM1a_evt_blk to be a total of 4 bytes, the offset * for the enable registers is always 2 from the base. It is hard * coded here. If this changes in the spec, this code will need to * be modified. The PM1b_evt_blk behaves as expected. */ acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read ( ACPI_MTX_LOCK, PM1_EN); /* * The GPEs behave similarly, except that the length of the register * block is not fixed, so the buffer must be allocated with malloc */ if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) && acpi_gbl_FADT->gpe0blk_len) { /* GPE0 specified in FADT */ acpi_gbl_gpe0enable_register_save = ACPI_MEM_ALLOCATE ( DIV_2 (acpi_gbl_FADT->gpe0blk_len)); if (!acpi_gbl_gpe0enable_register_save) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Save state of GPE0 enable bits */ for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) { acpi_gbl_gpe0enable_register_save[index] = (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index); } } else { acpi_gbl_gpe0enable_register_save = NULL; } if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) && acpi_gbl_FADT->gpe1_blk_len) { /* GPE1 defined */ acpi_gbl_gpe1_enable_register_save = ACPI_MEM_ALLOCATE ( DIV_2 (acpi_gbl_FADT->gpe1_blk_len)); if (!acpi_gbl_gpe1_enable_register_save) { return_ACPI_STATUS (AE_NO_MEMORY); } /* save state of GPE1 enable bits */ for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) { acpi_gbl_gpe1_enable_register_save[index] = (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index); } } else { acpi_gbl_gpe1_enable_register_save = NULL; } } return_ACPI_STATUS (status); }