xref: /haiku/src/add-ons/kernel/bus_managers/acpi/arch/x86/arch_init.cpp (revision 97f11716bfaa0f385eb0e28a52bf56a5023b9e99)
1 /*
2  * Copyright 2022 Adrien Destugues <pulkomandy@pulkomandy.tk>
3  *
4  * Distributed under terms of the MIT license.
5  */
6 
7 
8 #include <ACPI.h>
9 #include <apic.h>
10 
11 extern "C" {
12 #include "acpi.h"
13 #include "accommon.h"
14 #include "acdisasm.h"
15 #include "acnamesp.h"
16 }
17 
18 #include "arch_init.h"
19 
20 
21 #define PIC_MODE 0
22 #define APIC_MODE 1
23 
24 
25 ACPI_PHYSICAL_ADDRESS
arch_init_find_root_pointer()26 arch_init_find_root_pointer()
27 {
28 	ACPI_PHYSICAL_ADDRESS address;
29 	ACPI_STATUS status = AcpiFindRootPointer(&address);
30 	if (status == AE_OK)
31 		return address;
32 
33 	return 0;
34 }
35 
36 
37 void
arch_init_interrupt_controller()38 arch_init_interrupt_controller()
39 {
40 	ACPI_OBJECT arg;
41 	ACPI_OBJECT_LIST parameter;
42 
43 	arg.Integer.Type = ACPI_TYPE_INTEGER;
44 	arg.Integer.Value = apic_available() ? APIC_MODE : PIC_MODE;
45 
46 	parameter.Count = 1;
47 	parameter.Pointer = &arg;
48 
49 	AcpiEvaluateObject(NULL, (ACPI_STRING)"\\_PIC", &parameter, NULL);
50 }
51