6 #include <minix/acpi.h>
10 #include <minix/log.h>
11 #include <minix/sysutil.h>
13 static struct log log
=
14 { .name
= "libacpi", .log_level
= LEVEL_TRACE
, .log_func
= default_log
};
16 static endpoint_t acpi_ep
= NONE
;
22 res
= ds_retrieve_label_endpt("acpi", &acpi_ep
);
26 /*===========================================================================*
28 *===========================================================================*/
30 acpi_get_irq(unsigned bus
, unsigned dev
, unsigned pin
)
35 if (acpi_ep
== NONE
) {
38 panic("libacpi: ds_retrieve_label_endpt failed for 'acpi': %d", err
);
41 log_info(&log
, "resolved acpi to endpoint: %d\n", acpi_ep
);
45 ((struct acpi_get_irq_req
*)&m
)->hdr
.request
= ACPI_REQ_GET_IRQ
;
46 ((struct acpi_get_irq_req
*)&m
)->bus
= bus
;
47 ((struct acpi_get_irq_req
*)&m
)->dev
= dev
;
48 ((struct acpi_get_irq_req
*)&m
)->pin
= pin
;
50 if ((err
= ipc_sendrec(acpi_ep
, &m
)) != OK
)
51 panic("libacpi: error %d while receiving from ACPI\n", err
);
53 return ((struct acpi_get_irq_resp
*)&m
)->irq
;
57 * tells acpi which two busses are connected by this bridge. The primary bus
58 * (pbnr) must be already known to acpi and it must map dev as the connection to
59 * the secondary (sbnr) bus
62 acpi_map_bridge(unsigned int pbnr
, unsigned int dev
, unsigned int sbnr
)
67 if (acpi_ep
== NONE
) {
70 panic("libacpi: ds_retrieve_label_endpt failed for 'acpi': %d", err
);
74 ((struct acpi_map_bridge_req
*)&m
)->hdr
.request
= ACPI_REQ_MAP_BRIDGE
;
75 ((struct acpi_map_bridge_req
*)&m
)->primary_bus
= pbnr
;
76 ((struct acpi_map_bridge_req
*)&m
)->secondary_bus
= sbnr
;
77 ((struct acpi_map_bridge_req
*)&m
)->device
= dev
;
79 if ((err
= ipc_sendrec(acpi_ep
, &m
)) != OK
)
80 panic("libacpi: error %d while receiving from ACPI\n", err
);
82 if (((struct acpi_map_bridge_resp
*)&m
)->err
!= OK
)
83 printf("libacpi: acpi failed to map pci (%d) to pci (%d) bridge\n",