diff -ru /sys/dev/acpica/Osd/OsdInterrupt.c acpica/Osd/OsdInterrupt.c --- /sys/dev/acpica/Osd/OsdInterrupt.c Mon May 21 00:51:45 2001 +++ acpica/Osd/OsdInterrupt.c Sun May 13 01:45:11 2001 @@ -40,7 +40,7 @@ #include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("INTERRUPT") /* diff -ru /sys/dev/acpica/Osd/OsdSchedule.c acpica/Osd/OsdSchedule.c --- /sys/dev/acpica/Osd/OsdSchedule.c Mon May 21 00:51:45 2001 +++ acpica/Osd/OsdSchedule.c Mon May 14 06:57:25 2001 @@ -38,7 +38,7 @@ #include #include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("SCHEDULE") /* @@ -115,6 +115,7 @@ free(at, M_ACPITASK); Function(Context); + return_VOID; } @@ -126,13 +127,13 @@ AcpiOsSleep (UINT32 Seconds, UINT32 Milliseconds) { int timo; - + static int dummy; FUNCTION_TRACE(__FUNCTION__); - - timo = (Seconds * hz) + Milliseconds / (1000 * hz); + timo = (Seconds * hz) + Milliseconds *hz / 1000 ; if (timo == 0) timo = 1; - tsleep(NULL, PZERO, "acpislp", timo); + tsleep(&dummy, 0, "acpislp", timo); + return_VOID; } @@ -148,3 +149,5 @@ } return_VOID; } + + diff -ru /sys/dev/acpica/Osd/OsdSynch.c acpica/Osd/OsdSynch.c --- /sys/dev/acpica/Osd/OsdSynch.c Mon May 21 00:51:45 2001 +++ acpica/Osd/OsdSynch.c Mon May 14 19:34:47 2001 @@ -37,14 +37,14 @@ #include #include #include +#include -#define _COMPONENT OS_DEPENDENT +#define _COMPONENT ACPI_OS_SERVICES MODULE_NAME("SYNCH") static MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore"); /* disable semaphores - AML in the field doesn't use them correctly */ -#define ACPI_NO_SEMAPHORES /* * Simple counting semaphore implemented using a mutex. (Subsequently used @@ -54,7 +54,9 @@ struct mtx as_mtx; UINT32 as_units; UINT32 as_maxunits; +#if 0 char *as_name; +#endif }; ACPI_STATUS @@ -76,9 +78,10 @@ mtx_init(&as->as_mtx, "ACPI semaphore", MTX_DEF); as->as_units = InitialUnits; as->as_maxunits = MaxUnits; +#if 0 as->as_name = malloc(strlen(name) + 1, M_ACPISEM, M_NOWAIT); strcpy(as->as_name, name); - +#endif DEBUG_PRINT(TRACE_MUTEX, ("created semaphore %p max %d, initial %d\n", as, InitialUnits, MaxUnits)); @@ -98,13 +101,15 @@ FUNCTION_TRACE(__FUNCTION__); -#ifdef ACPI_TRACK_SEMAPHORE +#if 0 printf("destroyed semaphore '%s' @ %p\n", as->as_name, as); #else DEBUG_PRINT(TRACE_MUTEX, ("destroyed semaphore %p\n", as)); #endif mtx_destroy(&as->as_mtx); +#if 0 free(as->as_name, M_ACPISEM); +#endif free(Handle, M_ACPISEM); return_ACPI_STATUS(AE_OK); #else @@ -135,7 +140,7 @@ tmo = 0; } else { /* compute timeout using microseconds per tick */ - tmo = (Timeout * 1000) / (1000000 / hz) + tmo = (Timeout * 1000) / (1000000 / hz); if (tmo <= 0) tmo = 1; } @@ -155,7 +160,7 @@ } DEBUG_PRINT(TRACE_MUTEX, ("semaphore blocked, calling msleep(%p, %p, %d, \"acpisem\", %d)\n", as, as->as_mtx, 0, tmo)); - for (;;) ; + /*for (;;) ;*/ rv = msleep(as, &as->as_mtx, 0, "acpisem", tmo); DEBUG_PRINT(TRACE_MUTEX, ("msleep returned %d\n", rv)); @@ -195,4 +200,9 @@ #else return(AE_OK); #endif +} + +UINT32 AcpiOsGetThreadId() +{ + return curproc->p_pid; } diff -ru /sys/dev/acpica/acpi.c acpica/acpi.c --- /sys/dev/acpica/acpi.c Mon May 21 01:19:02 2001 +++ acpica/acpi.c Tue May 29 01:51:56 2001 @@ -26,13 +26,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.16 2001/05/01 08:11:55 markm Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.15 2001/04/02 23:36:36 jhb Exp $ */ #include "opt_acpi.h" #include #include -#include #include #include #include @@ -43,10 +42,11 @@ #include #include -#include +#include +#include +#include #include - #include "acpi.h" #include @@ -57,7 +57,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("ACPI") /* @@ -67,7 +67,9 @@ static d_open_t acpiopen; static d_close_t acpiclose; static d_ioctl_t acpiioctl; - +static int acpikqfilter(dev_t ,struct knote *); +static int filt_acpi(struct knote *, long ); +static void filt_acpidetach(struct knote *); #define CDEV_MAJOR 152 static struct cdevsw acpi_cdevsw = { acpiopen, @@ -82,7 +84,8 @@ CDEV_MAJOR, nodump, nopsize, - 0 + D_KQFILTER, + acpikqfilter, }; static const char* sleep_state_names[] = { @@ -120,7 +123,7 @@ static void acpi_system_eventhandler_sleep(void *arg, int state); static void acpi_system_eventhandler_wakeup(void *arg, int state); static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); - +static int acpi_off_state = ACPI_STATE_S5; static device_method_t acpi_methods[] = { /* Device interface */ DEVMETHOD(device_identify, acpi_identify), @@ -242,6 +245,35 @@ return_VALUE(0); } +/*This should be MD*/ +static int acpi_alloc_wakeup_handler(struct acpi_softc *sc) +{ + if( bus_dma_tag_create(/*parent*/ NULL,/*alignment*/2, 0, + /*lowaddr*/0x9ffff, + /*highaddr*/BUS_SPACE_MAXADDR,NULL,NULL, + 4096,1,4096,0,&sc->acpi_waketag) != 0){ + device_printf(sc->acpi_dev,"unable to create wake tag\n"); + return ENOMEM; + } + if(bus_dmamem_alloc(sc->acpi_waketag,(void **)&sc->acpi_wakeaddr, + BUS_DMA_NOWAIT,&sc->acpi_wakemap)){ + device_printf(sc->acpi_dev,"unable to alloc wake mem\n"); + return ENOMEM; + } + return 0; +} +void +acpi_s2inst(void *arg,bus_dma_segment_t *segs, int nsegs, int error) +{ + static char wakecode[]={ 0xb0, 0x41, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xb0, 0x42, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xb0, 0x43, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xb0, 0x44, 0x00, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xf4 }; + struct acpi_softc *sc = arg; + if(nsegs == 0){ + return; + } + printf("%x\n",segs[0].ds_addr); + AcpiSetFirmwareWakingVector(segs[0].ds_addr); + bcopy(wakecode,sc->acpi_wakeaddr,sizeof(wakecode)); +} static int acpi_attach(device_t dev) { @@ -252,7 +284,6 @@ #endif FUNCTION_TRACE(__FUNCTION__); - sc = device_get_softc(dev); bzero(sc, sizeof(*sc)); sc->acpi_dev = dev; @@ -261,26 +292,28 @@ if (debugpoint && !strcmp(debugpoint, "spaces")) acpi_EnterDebugger(); #endif + + device_printf(dev,"wakealloc %d\n",acpi_alloc_wakeup_handler(sc)); /* * Install the default address space handlers. */ if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemMemory handler: %s\n", acpi_strerror(error)); return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise SystemIO handler: %s\n", acpi_strerror(error)); return_VALUE(ENXIO); } if ((error = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ADDRESS_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL)) != AE_OK) { device_printf(dev, "could not initialise PciConfig handler: %s\n", acpi_strerror(error)); @@ -304,7 +337,8 @@ device_printf(dev, "could not enable ACPI: %s\n", acpi_strerror(error)); return_VALUE(ENXIO); } - + bus_dmamap_load(sc->acpi_waketag,sc->acpi_wakemap,sc->acpi_wakeaddr,4096, + acpi_s2inst, sc,0); /* * Setup our sysctl tree. * @@ -323,7 +357,8 @@ SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "lid_switch_state", CTLTYPE_STRING | CTLFLAG_RW, &sc->acpi_lid_switch_sx, 0, acpi_sleep_state_sysctl, "A", ""); - + mtx_init(&sc->acpi_mtx,"ACPI softc mtx",MTX_DEF); + sc->acpi_filter = -1; /* * Dispatch the default sleep state to devices. * TBD: should be configured from userland policy manager. @@ -356,7 +391,7 @@ */ EVENTHANDLER_REGISTER(acpi_sleep_event, acpi_system_eventhandler_sleep, sc, ACPI_EVENT_PRI_LAST); EVENTHANDLER_REGISTER(acpi_wakeup_event, acpi_system_eventhandler_wakeup, sc, ACPI_EVENT_PRI_LAST); - + /* * Flag our initial states. */ @@ -368,7 +403,7 @@ */ sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi"); sc->acpi_dev_t->si_drv1 = sc; - + #ifdef ENABLE_DEBUGGER if (debugpoint && !strcmp(debugpoint, "running")) acpi_EnterDebugger(); @@ -673,7 +708,7 @@ if (howto & RB_POWEROFF) { printf("Power system off using ACPI...\n"); - if ((status = AcpiEnterSleepState(ACPI_STATE_S5)) != AE_OK) { + if ((status = AcpiEnterSleepState(acpi_off_state)) != AE_OK) { printf("ACPI power-off failed - %s\n", acpi_strerror(status)); } else { DELAY(1000000); @@ -898,7 +933,8 @@ sc->acpi_sstate = ACPI_STATE_S0; acpi_enable_fixed_events(sc); break; - + case ACPI_STATE_S3: + acpi_off_state = ACPI_STATE_S3; case ACPI_STATE_S5: /* * Shut down cleanly and power off. This will call us back through the @@ -1034,9 +1070,10 @@ struct acpi_softc *sc = (struct acpi_softc *)context; FUNCTION_TRACE(__FUNCTION__); - + acpi_knote(ACPI_KNOTE_POWERBUTTON); +#if 0 EVENTHANDLER_INVOKE(acpi_sleep_event, sc->acpi_power_button_sx); - +#endif return_VALUE(INTERRUPT_HANDLED); } @@ -1046,9 +1083,10 @@ struct acpi_softc *sc = (struct acpi_softc *)context; FUNCTION_TRACE(__FUNCTION__); - + acpi_knote(ACPI_KNOTE_SLEEPBUTTON); +#if 0 EVENTHANDLER_INVOKE(acpi_wakeup_event, sc->acpi_power_button_sx); - +#endif return_VALUE(INTERRUPT_HANDLED); } @@ -1305,7 +1343,58 @@ out: return(error); } +static struct filterops acpi_filtops = +{ 1, NULL, filt_acpidetach, filt_acpi }; +static int acpikqfilter(dev_t dev, struct knote * kn) +{ + struct acpi_softc *sc = dev->si_drv1; + struct klist *kl = &sc->acpi_klist; + + printf("KQFILT:%d\n",kn->kn_filter); + switch(kn->kn_filter){ + case EVFILT_READ: + kn->kn_fop = & acpi_filtops; + break; + default: + return 1; + } + kn->kn_hook = (caddr_t) sc; + mtx_lock(&sc->acpi_mtx); + SLIST_INSERT_HEAD(kl, kn, kn_selnext); + mtx_unlock(&sc->acpi_mtx); + return 0; +} +static void filt_acpidetach(struct knote *kn) +{ + struct acpi_softc *sc = (struct acpi_softc *)kn->kn_hook; + mtx_lock(&sc->acpi_mtx); + SLIST_REMOVE(&sc->acpi_klist, kn, knote, kn_selnext); + if(SLIST_EMPTY(&sc->acpi_klist)){ + sc->acpi_filter = -1; + } + mtx_unlock(&sc->acpi_mtx); +} +static int filt_acpi(struct knote *kn, long hint) +{ + /*This assumes with acpi_mtx acquired*/ + struct acpi_softc *sc = (struct acpi_softc *)kn->kn_hook; + if((sc->acpi_filter != -1)&&(kn->kn_sfflags&(1<acpi_filter))){ + kn->kn_fflags |= (1<acpi_filter); + return 1; + } + return 0; +} +void acpi_knote(int filter){ + struct acpi_softc *sc = devclass_get_softc(acpi_devclass,0); + if((filter <0) || (filter > 32)){ + Debugger("HOE\n"); + } + mtx_lock(&sc->acpi_mtx); + sc->acpi_filter = filter; + KNOTE(&sc->acpi_klist, 0); + mtx_unlock(&sc->acpi_mtx); +} static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS) { diff -ru /sys/dev/acpica/acpi_acad.c acpica/acpi_acad.c --- /sys/dev/acpica/acpi_acad.c Mon May 21 00:51:46 2001 +++ acpica/acpi_acad.c Tue May 29 00:34:07 2001 @@ -37,6 +37,7 @@ #include #include #include +#include #include "acpi.h" #include @@ -66,7 +67,6 @@ if (acpi_EvaluateInteger(h, "_PSR", &sc->status) != AE_OK) return; - device_printf(dev,"%s\n",(sc->status) ? "On Line" : "Off Line"); } static void @@ -82,6 +82,7 @@ /*Temporally. It is better to notify policy manager*/ AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_get_status,context); + acpi_knote(ACPI_KNOTE_ACAD); break; default: break; @@ -119,9 +120,8 @@ acpi_acad_notify_handler, dev); acpi_acad_get_status((void *)dev); - error = acpi_register_ioctl(ACPIIO_ACAD_GET_STATUS, acpi_acad_ioctl, - device_get_softc(dev)); + dev); if (error) return (error); @@ -148,18 +148,29 @@ static int acpi_acad_ioctl(u_long cmd, caddr_t addr, void *arg) { + device_t dev = arg; struct acpi_acad_softc *sc; - - sc = (struct acpi_acad_softc *)arg; + + sc = device_get_softc(dev); if (sc == NULL) { return(ENXIO); } switch (cmd) { case ACPIIO_ACAD_GET_STATUS: + acpi_acad_get_status(dev); *(int *)addr = sc->status; break; } return(0); } + + + + + + + + + diff -ru /sys/dev/acpica/acpi_button.c acpica/acpi_button.c --- /sys/dev/acpica/acpi_button.c Mon May 21 00:51:46 2001 +++ acpica/acpi_button.c Sun May 13 01:41:26 2001 @@ -40,7 +40,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_POWER_CONTROL MODULE_NAME("BUTTON") struct acpi_button_softc { diff -ru /sys/dev/acpica/acpi_cmbat.c acpica/acpi_cmbat.c --- /sys/dev/acpica/acpi_cmbat.c Mon May 21 00:51:46 2001 +++ acpica/acpi_cmbat.c Tue May 29 00:28:42 2001 @@ -38,6 +38,7 @@ #include #include #include +#include #include "acpi.h" @@ -57,6 +58,7 @@ struct acpi_bst bst; ACPI_BUFFER bif_buffer; ACPI_BUFFER bst_buffer; + int bif_gen; }; /* XXX: devclass_get_maxunit() don't give us the current allocated units... */ @@ -209,21 +211,16 @@ static void acpi_cmbat_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) { + device_t dev = context; + struct acpi_cmbat_softc *sc = device_get_softc(dev); + switch (notify) { -#if 0 - /* XXX - * AML method execution is somewhat heavy even using swi. - * better to disable them until we fix the problem. - */ - case ACPI_BATTERY_BST_CHANGE: - AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpi_cmbat_get_bst, context); - break; case ACPI_BATTERY_BIF_CHANGE: - AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpi_cmbat_get_bif, context); + sc->bif_gen++; + /*FALLTHROUGH*/ + case ACPI_BATTERY_BST_CHANGE: + acpi_knote(ACPI_KNOTE_BAT_START+device_get_unit(dev)); break; -#endif default: break; } diff -ru /sys/dev/acpica/acpi_ec.c acpica/acpi_ec.c --- /sys/dev/acpica/acpi_ec.c Mon May 21 00:51:46 2001 +++ acpica/acpi_ec.c Mon May 21 23:42:01 2001 @@ -152,7 +152,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT EMBEDDED_CONTROLLER +#define _COMPONENT ACPI_EMBEDDED_CONTROLLER MODULE_NAME("EC") struct acpi_ec_softc { @@ -173,6 +173,7 @@ int ec_locked; int ec_pendquery; int ec_csrvalue; + int ec_burst; }; #define EC_LOCK_TIMEOUT 1000 /* 1ms */ @@ -285,7 +286,7 @@ { struct acpi_ec_softc *sc; ACPI_STATUS Status; - + int res; FUNCTION_TRACE(__FUNCTION__); /* @@ -295,7 +296,7 @@ bzero(sc, sizeof(*sc)); sc->ec_dev = dev; sc->ec_handle = acpi_get_handle(dev); - + /* * Evaluate resources */ @@ -332,7 +333,8 @@ DEBUG_PRINT(TRACE_RESOURCES, ("attaching GPE\n")); if ((Status = acpi_EvaluateInteger(sc->ec_handle, "_GPE", &sc->ec_gpebit)) != AE_OK) { device_printf(dev, "can't evaluate _GPE - %s\n", acpi_strerror(Status)); - return_VALUE(ENXIO); + res = ENXIO; + goto error; } /* @@ -346,21 +348,29 @@ if ((Status = AcpiInstallGpeHandler(sc->ec_gpebit, ACPI_EVENT_LEVEL_TRIGGERED | ACPI_EVENT_EDGE_TRIGGERED, EcGpeHandler, sc)) != AE_OK) { device_printf(dev, "can't install GPE handler - %s\n", acpi_strerror(Status)); - return_VALUE(ENXIO); + res = ENXIO; + goto error; } /* * Install address space handler */ DEBUG_PRINT(TRACE_RESOURCES, ("attaching address space handler\n")); - if ((Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ADDRESS_SPACE_EC, + if ((Status = AcpiInstallAddressSpaceHandler(sc->ec_handle, ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, sc)) != AE_OK) { device_printf(dev, "can't install address space handler - %s\n", acpi_strerror(Status)); - return_VALUE(ENXIO); + res = ENXIO; + goto error; } DEBUG_PRINT(TRACE_RESOURCES, ("attach complete\n")); return_VALUE(0); +error: + if(sc->ec_csr_res) + bus_release_resource(dev,SYS_RES_IOPORT,sc->ec_csr_rid, sc->ec_csr_res); + if(sc->ec_data_res) + bus_release_resource(dev,SYS_RES_IOPORT,sc->ec_data_rid, sc->ec_data_res); + return_VALUE(res); } static void @@ -393,7 +403,6 @@ * Find out why the EC is signalling us */ Status = EcQuery(sc, &Data); - /* * If we failed to get anything from the EC, give up */ @@ -475,21 +484,19 @@ int i; FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Address); - if ((Address > 0xFF) || (width % 8 != 0) || (Value == NULL) || (Context == NULL)) return_ACPI_STATUS(AE_BAD_PARAMETER); switch (Function) { - case ADDRESS_SPACE_READ: + case ACPI_READ_ADR_SPACE: EcRequest.Command = EC_COMMAND_READ; EcRequest.Address = Address; - EcRequest.Data = 0; + (*Value) = 0; break; - case ADDRESS_SPACE_WRITE: + case ACPI_WRITE_ADR_SPACE: EcRequest.Command = EC_COMMAND_WRITE; EcRequest.Address = Address; - EcRequest.Data = (UINT8)(*Value); break; default: @@ -500,9 +507,13 @@ /* * Perform the transaction. */ - (*Value) = 0; +#if 0 + if(width > 32){ + EcBurstEnable(sc); + } +#endif for (i = 0; i < width; i += 8) { - if (Function == ADDRESS_SPACE_READ) + if (Function == ACPI_READ_ADR_SPACE) EcRequest.Data = 0; else EcRequest.Data = (UINT8)((*Value) >> i); @@ -512,7 +523,11 @@ if (++EcRequest.Address == 0) return_ACPI_STATUS(AE_BAD_PARAMETER); } - +#if 0 + if(sc->ec_burst){ + EcBurstDisable(sc); + } +#endif return_ACPI_STATUS(Status); } static ACPI_STATUS @@ -525,6 +540,7 @@ if (!EcIsLocked(sc)) device_printf(sc->ec_dev, "EcWaitEventIntr called without EC lock!\n"); EcStatus = EC_GET_CSR(sc); + /*Too long?*/ for(i=0;i<10;i++){ if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && @@ -569,9 +585,9 @@ * Wait For Event: * --------------- * Poll the EC status register to detect completion of the last - * command. Wait up to 10ms (in 100us chunks) for this to occur. + * command. Wait up to 10ms (in 10us chunks) for this to occur. */ - for (i = 0; i < 100; i++) { + for (i = 0; i < 1000; i++) { EcStatus = EC_GET_CSR(sc); if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && @@ -582,11 +598,41 @@ !(EcStatus & EC_FLAG_INPUT_BUFFER)) return(AE_OK); - AcpiOsSleepUsec(100); + AcpiOsSleepUsec(10); } return(AE_ERROR); } +static ACPI_STATUS EcBurstEnable(struct acpi_ec_softc *sc) +{ + ACPI_STATUS Status; + u_int8_t data; + if((Status = EcLock(sc)) != AE_OK) + return(Status); + EC_SET_CSR(sc, EC_COMMAND_BURST_ENABLE); + Status = EcWaitEventIntr(sc,EC_EVENT_OUTPUT_BUFFER_FULL); + if(Status != AE_OK) + return Status; + data = EC_GET_DATA(sc); + if(data != 0x90) + return AE_ERROR; + sc->ec_burst = 1; + return AE_OK; +} +static ACPI_STATUS EcBurstDisable(struct acpi_ec_softc *sc) +{ + ACPI_STATUS Status; + u_int8_t data; + if((Status = EcLock(sc)) != AE_OK) + return(Status); + EC_SET_CSR(sc, EC_COMMAND_BURST_DISABLE); + Status = EcWaitEventIntr(sc,EC_EVENT_OUTPUT_BUFFER_FULL); + if(Status != AE_OK) + return Status; + sc->ec_burst = 0; + EcUnlock(sc); + return AE_OK; +} static ACPI_STATUS EcQuery(struct acpi_ec_softc *sc, UINT8 *Data) @@ -619,7 +665,6 @@ */ if ((Status = EcLock(sc)) != AE_OK) return(Status); - /* * Perform the transaction. */ @@ -638,6 +683,11 @@ } /* + * Unlock the EC + */ + + EcUnlock(sc); + /* * Clear & Re-Enable the EC GPE: * ----------------------------- * 'Consume' any EC GPE events that we generated while performing @@ -646,6 +696,7 @@ * (EC-SCI) will still be high and thus should trigger the GPE * immediately after we re-enabling it. */ + if (sc->ec_pendquery){ if(AcpiOsQueueForExecution(OSD_PRIORITY_HIGH, EcGpeQueryHandler, sc) != AE_OK) @@ -658,10 +709,6 @@ if (AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE) != AE_OK) device_printf(sc->ec_dev, "EcRequest: Unable to re-enable the EC GPE.\n"); - /* - * Unlock the EC - */ - EcUnlock(sc); return(Status); } diff -ru /sys/dev/acpica/acpi_isa.c acpica/acpi_isa.c --- /sys/dev/acpica/acpi_isa.c Mon May 21 00:51:46 2001 +++ acpica/acpi_isa.c Sun May 13 01:41:52 2001 @@ -46,7 +46,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("ISA") #define PNP_HEXTONUM(c) ((c) >= 'a' \ diff -ru /sys/dev/acpica/acpi_lid.c acpica/acpi_lid.c --- /sys/dev/acpica/acpi_lid.c Mon May 21 00:51:46 2001 +++ acpica/acpi_lid.c Tue May 29 00:05:12 2001 @@ -44,7 +44,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_POWER_CONTROL MODULE_NAME("LID") struct acpi_lid_softc { @@ -128,7 +128,7 @@ if (acpi_sc == NULL) { return_VOID; } - + acpi_knote(ACPI_KNOTE_LID); if (sc->lid_status == 0) { EVENTHANDLER_INVOKE(acpi_sleep_event, acpi_sc->acpi_lid_switch_sx); } else { diff -ru /sys/dev/acpica/acpi_pcib.c acpica/acpi_pcib.c --- /sys/dev/acpica/acpi_pcib.c Mon May 21 00:51:46 2001 +++ acpica/acpi_pcib.c Sun May 13 01:42:22 2001 @@ -42,7 +42,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("PCIB") struct acpi_pcib_softc { diff -ru /sys/dev/acpica/acpi_resource.c acpica/acpi_resource.c --- /sys/dev/acpica/acpi_resource.c Mon May 21 00:51:46 2001 +++ acpica/acpi_resource.c Wed May 23 14:56:44 2001 @@ -41,7 +41,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT BUS_MANAGER +#define _COMPONENT ACPI_BUS_MANAGER MODULE_NAME("RESOURCE") /* @@ -54,7 +54,7 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resource_set *set) { ACPI_BUFFER buf; - RESOURCE *res; + ACPI_RESOURCE *res; char *curr, *last; ACPI_STATUS status; int i; @@ -79,24 +79,24 @@ curr = buf.Pointer; last = (char *)buf.Pointer + buf.Length; while (curr < last) { - res = (RESOURCE *)curr; + res = (ACPI_RESOURCE *)curr; curr += res->Length; /* * Handle the individual resource types */ switch(res->Id) { - case EndTag: + case ACPI_RSTYPE_END_TAG: DEBUG_PRINT(TRACE_RESOURCES, ("EndTag\n")); curr = last; break; - case FixedIo: + case ACPI_RSTYPE_FIXED_IO: DEBUG_PRINT(TRACE_RESOURCES, ("FixedIo 0x%x/%d\n", res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength)); set->set_ioport(dev, context, res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength); break; - case Io: + case ACPI_RSTYPE_IO: if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) { DEBUG_PRINT(TRACE_RESOURCES, ("Io 0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength)); set->set_ioport(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength); @@ -108,14 +108,14 @@ } break; - case FixedMemory32: + case ACPI_RSTYPE_FIXED_MEM32: DEBUG_PRINT(TRACE_RESOURCES, ("FixedMemory32 0x%x/%d\n", res->Data.FixedMemory32.RangeBaseAddress, res->Data.FixedMemory32.RangeLength)); set->set_memory(dev, context, res->Data.FixedMemory32.RangeBaseAddress, res->Data.FixedMemory32.RangeLength); break; - case Memory32: + case ACPI_RSTYPE_MEM32: if (res->Data.Memory32.MinBaseAddress == res->Data.Memory32.MaxBaseAddress) { DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress, res->Data.Memory32.RangeLength)); @@ -128,7 +128,7 @@ } break; - case Memory24: + case ACPI_RSTYPE_MEM24: if (res->Data.Memory24.MinBaseAddress == res->Data.Memory24.MaxBaseAddress) { DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress, res->Data.Memory24.RangeLength)); @@ -141,43 +141,43 @@ } break; - case Irq: + case ACPI_RSTYPE_IRQ: for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) { DEBUG_PRINT(TRACE_RESOURCES, ("Irq %d\n", res->Data.Irq.Interrupts[i])); set->set_irq(dev, context, res->Data.Irq.Interrupts[i]); } break; - case Dma: + case ACPI_RSTYPE_DMA: for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) { DEBUG_PRINT(TRACE_RESOURCES, ("Drq %d\n", res->Data.Dma.Channels[i])); set->set_drq(dev, context, res->Data.Dma.Channels[i]); } break; - case StartDependentFunctions: + case ACPI_RSTYPE_START_DPF: DEBUG_PRINT(TRACE_RESOURCES, ("start dependant functions")); - set->set_start_dependant(dev, context, res->Data.StartDependentFunctions.CompatibilityPriority); + set->set_start_dependant(dev, context, res->Data.StartDpf.CompatibilityPriority); break; - case EndDependentFunctions: + case ACPI_RSTYPE_END_DPF: DEBUG_PRINT(TRACE_RESOURCES, ("end dependant functions")); set->set_end_dependant(dev, context); break; - case Address32: + case ACPI_RSTYPE_ADDRESS32: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address32 resource\n")); break; - case Address16: + case ACPI_RSTYPE_ADDRESS16: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address16 resource\n")); break; - case ExtendedIrq: + case ACPI_RSTYPE_EXT_IRQ: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented ExtendedIrq resource\n")); break; - case VendorSpecific: + case ACPI_RSTYPE_VENDOR: DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented VendorSpecific resource\n")); break; default: --- /sys/dev/acpica/acpi_thermal.c Mon May 21 00:51:46 2001 +++ acpica/acpi_thermal.c Tue May 29 01:26:16 2001 @@ -31,15 +31,15 @@ #include #include #include - +#include #include "acpi.h" #include - +#include /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT THERMAL_CONTROL +#define _COMPONENT ACPI_THERMAL_ZONE MODULE_NAME("THERMAL") #define TZ_ZEROC 2732 @@ -133,13 +133,14 @@ static void acpi_tz_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) { + device_t dev = context; FUNCTION_TRACE(__FUNCTION__); - switch(notify){ case ACPI_TZ_STATUS_CHANGE: case ACPI_TZ_TRIPPOINT_CHANGE: - /*Check trip point*/ + /*Check trip point*/ AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_tz_check_tripping_point, context); + acpi_knote(ACPI_KNOTE_THRM_START+device_get_unit(dev)); break; } return_VOID; diff -ru /sys/dev/acpica/acpi_timer.c acpica/acpi_timer.c --- /sys/dev/acpica/acpi_timer.c Mon May 21 00:51:46 2001 +++ acpica/acpi_timer.c Sun May 13 01:44:20 2001 @@ -39,7 +39,7 @@ /* * Hooks for the ACPI CA debugging infrastructure */ -#define _COMPONENT SYSTEM_CONTROL +#define _COMPONENT ACPI_SYSTEM MODULE_NAME("TIMER") #define ACPITIMER_MAGIC 0x524d4954 /* "TIMR" */ diff -ru /sys/dev/acpica/acpiio.h acpica/acpiio.h --- /sys/dev/acpica/acpiio.h Mon May 21 00:51:46 2001 +++ acpica/acpiio.h Tue May 29 00:53:42 2001 @@ -70,6 +70,15 @@ #define ACPIIO_ACAD_GET_STATUS _IOR('A', 1, int) +/*Kqueue releated stuff (1< #include +#include extern devclass_t acpi_devclass; @@ -53,6 +54,13 @@ int acpi_power_button_sx; int acpi_sleep_button_sx; int acpi_lid_switch_sx; + bus_dma_tag_t acpi_waketag; + bus_dmamap_t acpi_wakemap; + char *acpi_wakeaddr; +/*kevent related things*/ + struct klist acpi_klist; + struct mtx acpi_mtx; + int acpi_filter; }; struct acpi_device { @@ -222,4 +230,4 @@ extern char *acpi_name(ACPI_HANDLE handle); extern int acpi_avoid(ACPI_HANDLE handle); extern int acpi_disabled(char *subsys); - +extern void acpi_knote(int filter);