1 #include <minix/driver.h>
4 #include <minix/acpi.h>
9 struct machine machine
;
11 /* don't know where ACPI tables are, we may need to access any memory */
12 static int init_mem_priv(void)
14 struct minix_mem_range mr
;
17 mr
.mr_limit
= 0xffffffff;
19 return sys_privctl(SELF
, SYS_PRIV_ADD_MEM
, &mr
);
22 static void set_machine_mode(void)
25 ACPI_OBJECT_LIST args
;
28 arg1
.Type
= ACPI_TYPE_INTEGER
;
29 arg1
.Integer
.Value
= machine
.apic_enabled
? 1 : 0;
33 as
= AcpiEvaluateObject(ACPI_ROOT_OBJECT
, "_PIC", &args
, NULL
);
35 * We can silently ignore failure as it may not be implemented, ACPI should
36 * provide us with correct information anyway
39 printf("ACPI: machine set to %s mode\n",
40 machine
.apic_enabled
? "APIC" : "PIC");
43 static ACPI_STATUS
init_acpica(void)
47 status
= AcpiInitializeSubsystem();
48 if (ACPI_FAILURE(status
))
51 status
= AcpiInitializeTables(NULL
, 16, FALSE
);
52 if (ACPI_FAILURE(status
))
55 status
= AcpiLoadTables();
56 if (ACPI_FAILURE(status
))
59 status
= AcpiEnableSubsystem(0);
60 if (ACPI_FAILURE(status
))
63 status
= AcpiInitializeObjects(0);
64 if (ACPI_FAILURE(status
))
77 /* test conditions for acpi */
78 if (sys_getmachine(&machine
)) {
79 printf("ACPI: no machine\n");
82 if (machine
.acpi_rsdp
== 0) {
83 printf("ACPI: no RSDP\n");
86 if (init_mem_priv()) {
87 printf("ACPI: no mem access\n");
91 if ((acpi_err
= init_acpica()) == AE_OK
) {
93 printf("ACPI: ACPI enabled\n");
97 printf("ACPI: ACPI failed with err %d\n", acpi_err
);
101 static int sef_cb_init_fresh(int type
, sef_init_info_t
*info
)
108 static void sef_local_startup()
110 /* Register init callbacks. */
111 sef_setcb_init_fresh(sef_cb_init_fresh
);
112 sef_setcb_init_lu(sef_cb_init_fresh
);
113 sef_setcb_init_restart(sef_cb_init_fresh
);
115 /* Register live update callbacks. */
116 sef_setcb_lu_prepare(sef_cb_lu_prepare_always_ready
);
117 sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid_standard
);
119 /* Let SEF perform startup. */
132 err
= driver_receive(ANY
, &m
, &ipc_status
);
134 printf("ACPI: driver_receive failed: %d\n", err
);
138 switch (((struct acpi_request_hdr
*)&m
)->request
) {
139 case ACPI_REQ_GET_IRQ
:
142 case ACPI_REQ_MAP_BRIDGE
:
146 printf("ACPI: ignoring unsupported request %d "
148 ((struct acpi_request_hdr
*)&m
)->request
,
149 ((struct acpi_request_hdr
*)&m
)->m_source
);
152 err
= send(m
.m_source
, &m
);
154 printf("ACPI: send failed: %d\n", err
);