Example #1
0
void dump_acpi(struct backend *be)
{
    const struct acpi_rsdp *rsdp;
    uint32_t rsdp_len;

    rsdp = find_rsdp();

    printf("Dumping ACPI... ");

    if (!rsdp)
	return;			/* No ACPI information found */

    cpio_mkdir(be, "acpi");

    rsdp_len = rsdp->rev > 0 ? rsdp->len : 20;

    dump_table(be, "RSDP", rsdp, rsdp_len);

    dump_rsdt(be, rsdp);
    dump_xsdt(be, rsdp);

    rb_destroy(rb_types);
    rb_destroy(rb_addrs);

    printf("done.\n");
}
Example #2
0
void init_acpi()
{
    kprintf("Initializing ACPI\n");

    // Find RSDP
    find_rsdp();
    if (!acpi_supported) {
        kprintf("\tACPI not supported!\n");
        return;
    }

    // Get and map RSDT or XSDT
    if (acpi_v2_enabled) {
        acpi_xsdt = (struct acpi_xsdt *)(ulong)(acpi_rsdp->xsdt_address);
        kernel_direct_map_array((ulong)acpi_xsdt, sizeof(struct acpi_xsdt), 0);
    } else {
        acpi_rsdt = (struct acpi_rsdt *)(acpi_rsdp->rsdt_address);
        kernel_direct_map_array((ulong)acpi_rsdt, sizeof(struct acpi_rsdt), 0);
    }

    // Find out all tables
    kprintf("\tScanning All ACPI Tables\n");

    int count = 0;
    if (acpi_v2_enabled) {
        count = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header)) / sizeof(u64);
        kernel_direct_map_array((ulong)acpi_xsdt, acpi_xsdt->header.length, 0);
    } else {
        count = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header)) / sizeof(u32);
        kernel_direct_map_array((ulong)acpi_rsdt, acpi_rsdt->header.length, 0);
    }

    int i;
    for (i = 0; i < count; i++) {
        struct acpi_sdt_header *hdr;

        if (acpi_v2_enabled) {
            hdr = (struct acpi_sdt_header *)(ulong)acpi_xsdt->entry[i];
        } else {
            hdr = (struct acpi_sdt_header *)(ulong)acpi_rsdt->entry[i];
        }

        // Map the table
        kernel_direct_map_array((ulong)hdr, sizeof(struct acpi_sdt_header), 0);

        // MADT
        if (!memcmp(hdr->signature, ACPI_MADT_SIGNATURE, 4)) {
            kprintf("\tFound MADT at %p\n", hdr);
            init_madt((struct acpi_madt *)hdr);
        }

        // FADT
        //else if (!memcmp(hdr->signature, ACPI_FADT_SIGNATURE, 4)) {
        //    kprintf("\tFound FADT at %p\n", hdr);
        //    init_fadt((struct acpi_fadt *)hdr);
        //}
    }
}
Example #3
0
static void
acpi_init_global (void)
{
	u64 rsdp;
	struct rsdp *p;
	struct facp *q;
	struct acpi_ent_dmar *r;
	struct domain *create_dom() ;

	rsdp_found = false;
	pm1a_cnt_found = false;

	rsdp = find_rsdp ();
	if (rsdp == FIND_RSDP_NOT_FOUND) {
		printf ("ACPI RSDP not found.\n");
		return;
	}
	p = acpi_mapmem (rsdp, sizeof *p);
	memcpy (&rsdp_copy, p, sizeof *p);
	rsdp_found = true;

	r=find_entry(DMAR_SIGNATURE);
	if (!r) {
		printf ("ACPI DMAR not found.\n");
		iommu_detected=0;
	} else {
		int i ;
		printf ("ACPI DMAR found.\n");
		iommu_detected=1;
		
		parse_dmar_bios_report(r) ;
		num_dom=0 ;
		for (i=0 ; i<MAX_IO_DOM ; i++)
			dom_io[i]=create_dom(i) ;
	}

	q = find_facp ();
	if (!q) {
		printf ("ACPI FACP not found.\n");
		return;
	}
#ifdef ACPI_DSDT
	acpi_dsdt_parse (q->dsdt);
#endif
	get_pm1a_cnt_ioaddr (q);
	get_facs_addr (q);
	if (0)
		debug_dump (q, q->header.length);
	if (0)
		printf ("PM1a control port is 0x%X\n", pm1a_cnt_ioaddr);
	pm1a_cnt_found = true;
	clear_mcfg ();
}