Exemple #1
0
static int acpi_find_bmc(unsigned long *physaddr, int *port)
{
	acpi_status       status;
	struct SPMITable  *spmi;

	status = acpi_get_firmware_table("SPMI", 1,
					 ACPI_LOGICAL_ADDRESSING,
					 (struct acpi_table_header **) &spmi);
	if (status != AE_OK)
		goto not_found;
	if (spmi->InterfaceType[0] != 1)
		/* Not IPMI. */
		goto not_found;

	if (spmi->InterfaceType[1] != 1)
                /* Not KCS. */
		goto not_found;

	if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
		*physaddr = spmi->addr.address;
		printk(KERN_DEBUG "ipmi_kcs_intf: Found ACPI-specified state machine"
		       " at memory address 0x%lx\n",
		       (unsigned long) spmi->addr.address);
	} else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
		*port = spmi->addr.address;
		printk(KERN_DEBUG "ipmi_kcs_intf: Found ACPI-specified state machine"
		       " at I/O address 0x%x\n",
		       (int) spmi->addr.address);
	} else
		goto not_found; /* Not an address type we recognise. */

	return 0;
 not_found:
	return -ENODEV;
}
acpi_status
acpi_tb_find_table(char *signature,
		   char *oem_id,
		   char *oem_table_id, struct acpi_table_header ** table_ptr)
{
	acpi_status status;
	struct acpi_table_header *table;

	ACPI_FUNCTION_TRACE("tb_find_table");

	/* Validate string lengths */

	if ((ACPI_STRLEN(signature) > ACPI_NAME_SIZE) ||
	    (ACPI_STRLEN(oem_id) > sizeof(table->oem_id)) ||
	    (ACPI_STRLEN(oem_table_id) > sizeof(table->oem_table_id))) {
		return_ACPI_STATUS(AE_AML_STRING_LIMIT);
	}

	if (!ACPI_STRNCMP(signature, DSDT_SIG, ACPI_NAME_SIZE)) {
		/*
		 * The DSDT pointer is contained in the FADT, not the RSDT.
		 * This code should suffice, because the only code that would perform
		 * a "find" on the DSDT is the data_table_region() AML opcode -- in
		 * which case, the DSDT is guaranteed to be already loaded.
		 * If this becomes insufficient, the FADT will have to be found first.
		 */
		if (!acpi_gbl_DSDT) {
			return_ACPI_STATUS(AE_NO_ACPI_TABLES);
		}
		table = acpi_gbl_DSDT;
	} else {
		/* Find the table */

		status = acpi_get_firmware_table(signature, 1,
						 ACPI_LOGICAL_ADDRESSING,
						 &table);
		if (ACPI_FAILURE(status)) {
			return_ACPI_STATUS(status);
		}
	}

	/* Check oem_id and oem_table_id */

	if ((oem_id[0] && ACPI_STRNCMP(oem_id, table->oem_id,
				       sizeof(table->oem_id))) ||
	    (oem_table_id[0] && ACPI_STRNCMP(oem_table_id, table->oem_table_id,
					     sizeof(table->oem_table_id)))) {
		return_ACPI_STATUS(AE_AML_NAME_NOT_FOUND);
	}

	ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n",
			  table->signature));

	*table_ptr = table;
	return_ACPI_STATUS(AE_OK);
}
__init u32 hrt_get_acpi_pm_ptr(void)
{
	struct fadt_descriptor_rev2 *fadt = &acpi_fadt;
	struct fadt_descriptor_rev2 local_fadt;

	if (!fadt || !fadt->header.signature[0]) {
		fadt = &local_fadt;
		fadt->header.signature[0] = '\0';
		acpi_get_firmware_table("FACP", 1, ACPI_PHYSICAL_POINTER,
					(struct acpi_table_header **) & fadt);
	}
	if (!fadt || !fadt->header.signature[0]) {
		printk("ACPI: Could not find the ACPI pm timer.");
	}

	if (fadt->header.revision == 2) {
		return (u32) fadt->xpm_tmr_blk.address;
	} else {
		return (u32) fadt->V1_pm_tmr_blk;
	}
}
acpi_status
acpi_tb_find_table (
	char                            *signature,
	char                            *oem_id,
	char                            *oem_table_id,
	struct acpi_table_header        **table_ptr)
{
	acpi_status                     status;
	struct acpi_table_header        *table;


	ACPI_FUNCTION_TRACE ("tb_find_table");


	/* Validate string lengths */

	if ((ACPI_STRLEN (signature)  > ACPI_NAME_SIZE) ||
		(ACPI_STRLEN (oem_id)     > sizeof (table->oem_id)) ||
		(ACPI_STRLEN (oem_table_id) > sizeof (table->oem_table_id))) {
		return_ACPI_STATUS (AE_AML_STRING_LIMIT);
	}

	/* Find the table */

	status = acpi_get_firmware_table (signature, 1,
			   ACPI_LOGICAL_ADDRESSING, &table);
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	/* Check oem_id and oem_table_id */

	if ((oem_id[0]     && ACPI_STRCMP (oem_id, table->oem_id)) ||
		(oem_table_id[0] && ACPI_STRCMP (oem_table_id, table->oem_table_id))) {
		return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
	}

	*table_ptr = table;
	return_ACPI_STATUS (AE_OK);
}