Moving ACPI Embedded Controller to ACPI bus manager.
* Removed irq_routing struct from ACPI.h to where it is used. Might be able to use acrestype.h instead of duplication. * Disable old embedded controller and remove it from image. * Move embedded controller code to busmanager module. * Remove (some) code duplication Should work as before, but is now initialized right after the bus manager. Can probably remove further code duplication. I hope I've done it correctly, feedback is most welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36420 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c966de0646
commit
5d9cc10f80
@ -119,6 +119,8 @@ SYSTEM_ADD_ONS_ACCELERANTS = $(X86_ONLY)radeon.accelerant
|
||||
$(X86_ONLY)ati.accelerant
|
||||
#$(X86_ONLY)via.accelerant
|
||||
#$(X86_ONLY)vmware.accelerant
|
||||
#$(X86_ONLY)radeonhd.accelerant
|
||||
|
||||
;
|
||||
SYSTEM_ADD_ONS_TRANSLATORS = BMPTranslator EXRTranslator GIFTranslator
|
||||
HVIFTranslator ICOTranslator JPEGTranslator JPEG2000Translator
|
||||
@ -241,7 +243,6 @@ if $(TARGET_ARCH) = x86 {
|
||||
AddNewDriversToHaikuImage disk scsi : scsi_cd scsi_disk ;
|
||||
AddNewDriversToHaikuImage power : $(X86_ONLY)enhanced_speedstep ;
|
||||
AddNewDriversToHaikuImage power : $(X86_ONLY)acpi_battery ;
|
||||
AddNewDriversToHaikuImage power : $(X86_ONLY)acpi_embedded_controller ;
|
||||
|
||||
# legacy drivers
|
||||
AddDriversToHaikuImage : console dprintf null
|
||||
|
@ -131,39 +131,9 @@ enum {
|
||||
*/
|
||||
typedef uint32 acpi_status;
|
||||
|
||||
#define AE_CODE_PROGRAMMER 0x1000
|
||||
|
||||
#define AE_OK 0x0000
|
||||
#define AE_ERROR 0x0001
|
||||
#define AE_NOT_ACQUIRED 0x0014
|
||||
#define AE_NO_HARDWARE_RESPONSE 0x0016
|
||||
#define AE_BAD_PARAMETER (0x0001 | AE_CODE_PROGRAMMER)
|
||||
#define AE_BAD_ADDRESS (0x0009 | AE_CODE_PROGRAMMER)
|
||||
|
||||
#else
|
||||
#error "Our ACPI.h uses different naming than actypes.h.\n" \\
|
||||
"If you need actypes.h this probably needs updating."
|
||||
|
||||
#endif // __ACTYPES_H__
|
||||
|
||||
|
||||
#ifndef __ACRESTYP_H__
|
||||
|
||||
|
||||
typedef struct acpi_prt
|
||||
{
|
||||
uint32 length;
|
||||
uint32 pin;
|
||||
int address; /* here for 64-bit alignment */
|
||||
uint32 sourceIndex;
|
||||
char source[4]; /* pad to 64 bits so sizeof() works in
|
||||
all cases */
|
||||
} acpi_pci_routing_table;
|
||||
|
||||
|
||||
#endif // __ACRESTYP_H__
|
||||
|
||||
|
||||
typedef uint32 (*acpi_event_handler)(void *Context);
|
||||
|
||||
typedef acpi_status (*acpi_adr_space_handler)(uint32 function,
|
||||
|
@ -131,7 +131,7 @@ local tables_src =
|
||||
tbfadt.c
|
||||
tbfind.c
|
||||
tbinstal.c
|
||||
#tbutils.c
|
||||
tbutils.c
|
||||
tbxface.c
|
||||
tbxfroot.c
|
||||
;
|
||||
@ -170,16 +170,6 @@ StaticLibrary libacpi_ca.a :
|
||||
$(utilities_src)
|
||||
;
|
||||
|
||||
|
||||
# this is a workaround for an optimization bug in our GCC4 with -O1 and -O2, this should be dropped when we upgrade
|
||||
#oldOPTIM = $(OPTIM) ;
|
||||
#OPTIM = -O3 ;
|
||||
StaticLibrary libacpi_ca.a :
|
||||
tbutils.c
|
||||
;
|
||||
|
||||
#OPTIM = $(oldOPTIM) ;
|
||||
|
||||
SEARCH on [ FGristFiles $(events_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi events ] ;
|
||||
SEARCH on [ FGristFiles $(hardware_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi hardware ] ;
|
||||
SEARCH on [ FGristFiles $(namespace_src) ] = [ FDirName $(HAIKU_TOP) src add-ons kernel bus_managers acpi namespace ] ;
|
||||
@ -196,6 +186,8 @@ KernelAddon acpi :
|
||||
acpi_module.c
|
||||
acpi_device.c
|
||||
acpi_ns_dump.cpp
|
||||
acpi_embedded_controller.cpp
|
||||
SmallResourceData.cpp
|
||||
:
|
||||
libacpi_ca.a
|
||||
;
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ACPI.h>
|
||||
#include <condition_variable.h>
|
||||
#include <Errors.h>
|
||||
#include <KernelExport.h>
|
||||
@ -51,13 +50,10 @@
|
||||
// name of pnp generator of path ids
|
||||
#define ACPI_EC_PATHID_GENERATOR "embedded_controller/path_id"
|
||||
|
||||
device_manager_info *gDeviceManager = NULL;
|
||||
pci_module_info *gPCIManager = NULL;
|
||||
|
||||
// cpu frequency in Hz
|
||||
int64 gHz;
|
||||
|
||||
|
||||
|
||||
|
||||
uint8
|
||||
bus_space_read_1(int address)
|
||||
{
|
||||
@ -80,7 +76,7 @@ acpi_GetInteger(acpi_device_module_info* acpi, acpi_device& acpiCookie,
|
||||
acpi_object_type object;
|
||||
buf.pointer = &object;
|
||||
buf.length = sizeof(acpi_object_type);
|
||||
|
||||
|
||||
/*
|
||||
* Assume that what we've been pointed at is an Integer object, or
|
||||
* a method that will return an Integer.
|
||||
@ -211,7 +207,7 @@ acpi_get_type(device_node* dev)
|
||||
const char *bus;
|
||||
if (gDeviceManager->get_attr_string(dev, B_DEVICE_BUS, &bus, false))
|
||||
return -1;
|
||||
|
||||
|
||||
if (strcmp(bus, "acpi"))
|
||||
return -1;
|
||||
|
||||
@ -230,14 +226,16 @@ embedded_controller_support(device_node* dev)
|
||||
static const char* ec_ids[] = { "PNP0C09", NULL };
|
||||
|
||||
/* Check that this is a device. */
|
||||
TRACE("before acpi_get_type...");
|
||||
if (acpi_get_type(dev) != ACPI_TYPE_DEVICE)
|
||||
return 0.0;
|
||||
|
||||
|
||||
const char* name;
|
||||
|
||||
if (gDeviceManager->get_attr_string(dev, ACPI_DEVICE_HID_ITEM, &name, false)
|
||||
!= B_OK || strcmp(name, ec_ids[0]))
|
||||
return 0.0;
|
||||
|
||||
TRACE("after\n");
|
||||
TRACE("supported device found %s\n", name);
|
||||
return 0.6;
|
||||
}
|
||||
@ -293,21 +291,6 @@ embedded_controller_init_driver(device_node* dev, void** _driverCookie)
|
||||
!= B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
// DPC module
|
||||
if (gDPC == NULL && get_module(B_DPC_MODULE_NAME, (module_info**) &gDPC)
|
||||
!= B_OK) {
|
||||
dprintf("failed to get dpc module for os execution\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (gDPCHandle == NULL) {
|
||||
if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task", B_NORMAL_PRIORITY)
|
||||
!= B_OK) {
|
||||
dprintf("failed to create os execution queue\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
acpi_data buf;
|
||||
buf.pointer = NULL;
|
||||
buf.length = ACPI_ALLOCATE_BUFFER;
|
||||
@ -431,9 +414,6 @@ embedded_controller_uninit_driver(void* driverCookie)
|
||||
mutex_destroy(&sc->ec_lock);
|
||||
free(sc);
|
||||
put_module(B_ACPI_MODULE_NAME);
|
||||
put_module(B_DPC_MODULE_NAME);
|
||||
gDPC = NULL;
|
||||
gDPCHandle = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -470,13 +450,6 @@ embedded_controller_uninit_device(void* _cookie)
|
||||
}
|
||||
|
||||
|
||||
module_dependency module_dependencies[] = {
|
||||
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **) &gDeviceManager },
|
||||
{ B_PCI_MODULE_NAME, (module_info **) &gPCIManager},
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
driver_module_info embedded_controller_driver_module = {
|
||||
{
|
||||
ACPI_EC_DRIVER_NAME,
|
||||
@ -518,13 +491,6 @@ struct device_module_info embedded_controller_device_module = {
|
||||
};
|
||||
|
||||
|
||||
module_info* modules[] = {
|
||||
(module_info*) &embedded_controller_driver_module,
|
||||
(module_info*) &embedded_controller_device_module,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
EcGpeQueryHandler(void* context)
|
||||
{
|
||||
@ -606,9 +572,9 @@ EcGpeHandler(void* context)
|
||||
EC_STATUS EcStatus = EC_GET_CSR(sc);
|
||||
if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pending) {
|
||||
TRACE("gpe queueing query handler\n");
|
||||
status_t status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler,
|
||||
ACPI_STATUS s = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler,
|
||||
context);
|
||||
if (status == B_OK)
|
||||
if (s == AE_OK)
|
||||
sc->ec_sci_pending = TRUE;
|
||||
else
|
||||
dprintf("EcGpeHandler: queuing GPE query handler failed\n");
|
||||
@ -720,7 +686,7 @@ EcWaitEvent(struct acpi_ec_cookie* sc, EC_EVENT event, int32 gen_count)
|
||||
{
|
||||
acpi_status status = AE_NO_HARDWARE_RESPONSE;
|
||||
int32 count, i;
|
||||
|
||||
|
||||
// int need_poll = cold || rebooting || ec_polled_mode || sc->ec_suspending;
|
||||
int need_poll = ec_polled_mode || sc->ec_suspending;
|
||||
|
||||
@ -770,7 +736,7 @@ EcWaitEvent(struct acpi_ec_cookie* sc, EC_EVENT event, int32 gen_count)
|
||||
}
|
||||
|
||||
count = ec_timeout;
|
||||
|
||||
|
||||
/*
|
||||
* Wait for the GPE to signal the status changed, checking the
|
||||
* status register each time we get one. It's possible to get a
|
||||
@ -876,7 +842,7 @@ EcRead(struct acpi_ec_cookie* sc, uint8 address, uint8* readData)
|
||||
return status;
|
||||
|
||||
u_int gen_count = sc->ec_gencount;
|
||||
|
||||
|
||||
EC_SET_DATA(sc, address);
|
||||
status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL, gen_count);
|
||||
if (status != AE_OK) {
|
||||
@ -884,7 +850,7 @@ EcRead(struct acpi_ec_cookie* sc, uint8 address, uint8* readData)
|
||||
return status;
|
||||
}
|
||||
*readData = EC_GET_DATA(sc);
|
||||
|
||||
|
||||
if (sc->ec_burstactive) {
|
||||
sc->ec_burstactive = FALSE;
|
||||
status = EcCommand(sc, EC_COMMAND_BURST_DISABLE);
|
@ -33,11 +33,18 @@
|
||||
|
||||
#include <ACPI.h>
|
||||
#include <condition_variable.h>
|
||||
#include <dpc.h>
|
||||
|
||||
#include <Drivers.h>
|
||||
#include <KernelExport.h>
|
||||
#include <lock.h>
|
||||
|
||||
extern "C" {
|
||||
#include "acpi.h"
|
||||
#include "accommon.h"
|
||||
#include "acnamesp.h"
|
||||
#include "acpi_priv.h"
|
||||
}
|
||||
|
||||
// #define TRACE_EMBEDDED_CONTROLLER
|
||||
#ifdef TRACE_EMBEDDED_CONTROLLER
|
||||
# define TRACE(x...) dprintf("EC: " x)
|
||||
@ -46,72 +53,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
dpc_module_info *gDPC = NULL;
|
||||
void *gDPCHandle = NULL;
|
||||
|
||||
|
||||
#define ACPI_GPE_EDGE_TRIGGERED (uint8) 0x00
|
||||
#define ACPI_GPE_TYPE_RUNTIME (uint8) 0x04 /* Default */
|
||||
|
||||
#define ACPI_NOT_ISR 0x1
|
||||
#define ACPI_ISR 0x0
|
||||
|
||||
enum {
|
||||
OSL_GLOBAL_LOCK_HANDLER,
|
||||
OSL_NOTIFY_HANDLER,
|
||||
OSL_GPE_HANDLER,
|
||||
OSL_DEBUGGER_THREAD,
|
||||
OSL_EC_POLL_HANDLER,
|
||||
OSL_EC_BURST_HANDLER
|
||||
};
|
||||
|
||||
typedef void (*ACPI_OSD_EXEC_CALLBACK)(void* Context);
|
||||
|
||||
|
||||
// ToDo: Maybe also put this acpi function into the acpi module?
|
||||
status_t
|
||||
AcpiOsExecute(uint32 Type, ACPI_OSD_EXEC_CALLBACK Function,
|
||||
void *Context)
|
||||
{
|
||||
switch (Type) {
|
||||
case OSL_GLOBAL_LOCK_HANDLER:
|
||||
case OSL_NOTIFY_HANDLER:
|
||||
case OSL_GPE_HANDLER:
|
||||
case OSL_DEBUGGER_THREAD:
|
||||
case OSL_EC_POLL_HANDLER:
|
||||
case OSL_EC_BURST_HANDLER:
|
||||
break;
|
||||
}
|
||||
|
||||
if (gDPC->queue_dpc(gDPCHandle, Function, Context) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
/* copied from utmisc.c don't want to put this simple function into the acpi
|
||||
module */
|
||||
void
|
||||
AcpiUtStrupr(char *SrcString)
|
||||
{
|
||||
char *String;
|
||||
|
||||
if (!SrcString)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Walk entire string, uppercasing the letters */
|
||||
|
||||
for (String = SrcString; *String; String++)
|
||||
{
|
||||
*String = (char) toupper(*String);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#define ACPI_REGION_DEACTIVATE 1
|
||||
|
||||
#define ACPI_READ 0
|
@ -226,5 +226,7 @@ _EXPORT module_info *modules[] = {
|
||||
(module_info *)&sACPIRootModule,
|
||||
(module_info *)&acpi_ns_dump_module,
|
||||
(module_info *)&gACPIDeviceModule,
|
||||
(module_info*) &embedded_controller_driver_module,
|
||||
(module_info*) &embedded_controller_device_module,
|
||||
NULL
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ __BEGIN_DECLS
|
||||
#include <device_manager.h>
|
||||
#include <KernelExport.h>
|
||||
#include <ACPI.h>
|
||||
#include <PCI.h>
|
||||
|
||||
// name of ACPI root module
|
||||
#define ACPI_ROOT_MODULE_NAME "bus_managers/acpi/root/driver_v1"
|
||||
@ -24,6 +25,7 @@ __BEGIN_DECLS
|
||||
|
||||
|
||||
extern device_manager_info *gDeviceManager;
|
||||
extern pci_module_info *gPCIManager;
|
||||
|
||||
// information about one ACPI device
|
||||
typedef struct acpi_device_cookie {
|
||||
@ -124,6 +126,9 @@ extern struct acpi_module_info gACPIModule;
|
||||
|
||||
extern struct device_module_info acpi_ns_dump_module;
|
||||
|
||||
extern struct driver_module_info embedded_controller_driver_module;
|
||||
extern struct device_module_info embedded_controller_device_module;
|
||||
|
||||
extern acpi_device_module_info gACPIDeviceModule;
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ SubDir HAIKU_TOP src add-ons kernel drivers power ;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_battery ;
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_button ;
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_embedded_controller ;
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_lid ;
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_thermal ;
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers power enhanced_speedstep ;
|
||||
|
@ -39,6 +39,18 @@ struct irq_descriptor
|
||||
};
|
||||
|
||||
|
||||
/* Similar to bus_managers/acpi/include/acrestyp.h definition */
|
||||
typedef struct acpi_prt
|
||||
{
|
||||
uint32 length;
|
||||
uint32 pin;
|
||||
int address; /* here for 64-bit alignment */
|
||||
uint32 sourceIndex;
|
||||
char source[4]; /* pad to 64 bits so sizeof() works in
|
||||
all cases */
|
||||
} acpi_pci_routing_table;
|
||||
|
||||
|
||||
void print_irq_descriptor(irq_descriptor* descriptor);
|
||||
void print_irq_routing_table(IRQRoutingTable* table);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user