Ejemplo n.º 1
0
Archivo: acpi.c Proyecto: Hooman3/minix
void acpi_init(void)
{
	int s, i;
	read_func = acpi_phys_copy;

	if (!get_acpi_rsdp()) {
		printf("WARNING : Cannot configure ACPI\n");
		return;
	}
	
	s = acpi_read_sdt_at(acpi_rsdp.rsdt_addr, (struct acpi_sdt_header *) &rsdt,
			sizeof(struct acpi_rsdt), ACPI_SDT_SIGNATURE(RSDT));

	sdt_count = (s - sizeof(struct acpi_sdt_header)) / sizeof(u32_t);

	for (i = 0; i < sdt_count; i++) {
		struct acpi_sdt_header hdr;
		int j;
		if (read_func(rsdt.data[i], &hdr, sizeof(struct acpi_sdt_header))) {
			printf("ERROR acpi cannot read header at 0x%x\n",
								rsdt.data[i]);
			return;
		}

		for (j = 0 ; j < ACPI_SDT_SIGNATURE_LEN; j++)
			sdt_trans[i].signature[j] = hdr.signature[j];
		sdt_trans[i].signature[ACPI_SDT_SIGNATURE_LEN] = '\0';
		sdt_trans[i].length = hdr.length;
	}

	acpi_init_poweroff();
}
Ejemplo n.º 2
0
/** Initialize ACPI
 */
void
x64_acpi_init(void){
	int                 s, i;
	acpi_sdt_header      hdr;
        acpi_rsdt           rsdt;
#if defined(DEBUG_ACPI_LAPIC) || defined(DEBUG_ACPI_IOAPIC)
	unsigned int         idx;
#endif  /*  DEBUG_ACPI_LAPIC || DEBUG_ACPI_IOAPIC */
#if defined(DEBUG_ACPI_LAPIC)
	acpi_madt_lapic   *lapic;
#endif  /*  DEBUG_ACPI_LAPIC  */
#if defined(DEBUG_ACPI_IOAPIC)
	acpi_madt_ioapic *ioapic;
#endif  /*  DEBUG_ACPI_IOAPIC  */

	memset(&g_acpi_info, 0, sizeof(acpi_info));

	if ( get_acpi_rsdp() != 1 ) {

		kprintf("WARNING : Cannot configure ACPI\n");
		return;
	} 

	s = read_sdt_at(g_acpi_info.rsdp.rsdt_addr, (acpi_sdt_header *)&rsdt,
			sizeof(acpi_rsdt), ACPI_SDT_SIGNATURE(RSDT));
	g_acpi_info.sdt_count = (s - sizeof(acpi_sdt_header)) / sizeof(uint32_t);
	
	for (i = 0; g_acpi_info.sdt_count > i ; ++i) {

		acpi_copy_phys(rsdt.data[i], &hdr, sizeof(acpi_sdt_header));

		if ( memcmp(hdr.signature, "APIC", ACPI_SDT_SIGNATURE_LEN) == 0 ) 
			g_acpi_info.sdt_trans[i].type = ACPI_SDT_TRANS_TYPE_APIC;
		else if ( memcmp(hdr.signature, "FACP", ACPI_SDT_SIGNATURE_LEN) == 0 ) 
			g_acpi_info.sdt_trans[i].type = ACPI_SDT_TRANS_TYPE_FACP;
		else if ( memcmp(hdr.signature, "HPET", ACPI_SDT_SIGNATURE_LEN) == 0 ) 
			g_acpi_info.sdt_trans[i].type = ACPI_SDT_TRANS_TYPE_HPET;
		else
			g_acpi_info.sdt_trans[i].type = ACPI_SDT_TRANS_TYPE_NONE;

		g_acpi_info.sdt_trans[i].paddr = rsdt.data[i];
		g_acpi_info.sdt_trans[i].kaddr = (void *)PHY_TO_KERN_STRAIGHT(rsdt.data[i]);
		g_acpi_info.sdt_trans[i].length = hdr.length;
	}

#if defined(DEBUG_ACPI_LAPIC)
	for(idx = 0; ;) {

		lapic = acpi_get_lapic(&idx);
		if ( lapic == NULL )
			break;
		
		kprintf("ACPI APIC[%d] cpuid=%d apicid=%d flags=0x%x\n", 
			idx - 1, lapic->acpi_cpu_id, lapic->apic_id, lapic->flags);
	}
#endif  /*  DEBUG_ACPI_LAPIC  */

#if defined(DEBUG_ACPI_IOAPIC)
	for(idx = 0; ; ) {

		ioapic = acpi_get_ioapic(&idx);
		if ( ioapic == NULL )
			break;
		
		kprintf("ACPI IOAPIC[%d] id=%d address=0x%x global int base=0x%x\n", 
			idx - 1, ioapic->id, ioapic->address, ioapic->global_int_base);
	}
#endif  /*  DEBUG_ACPI_IOAPIC  */
}