diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2007-02-17 23:59:04 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2007-02-17 23:59:04 +0000 |
commit | 5cb17b9e44e0f5b04df3d136964b9cd4e2296206 (patch) | |
tree | 024f172edea7c154305462c5da2ee6c98e88966d /sys/dev/acpi/acpi.c | |
parent | 41ba8ea6e88f4010ce8cae1b994e736d8392ee5b (diff) |
Add SMALL_KERNEL throught acpi to make it fit on boot media.
ok deraadt
Diffstat (limited to 'sys/dev/acpi/acpi.c')
-rw-r--r-- | sys/dev/acpi/acpi.c | 227 |
1 files changed, 123 insertions, 104 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 907a0028ae1..9a2e836a8c3 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.78 2007/02/13 04:39:43 marco Exp $ */ +/* $OpenBSD: acpi.c,v 1.79 2007/02/17 23:59:03 marco Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -242,10 +242,12 @@ acpi_gasio(struct acpi_softc *sc, int iodir, int iospace, uint64_t address, case GAS_EMBEDDED: if (sc->sc_ec == NULL) break; +#ifndef SMALL_KERNEL if (iodir == ACPI_IOREAD) acpiec_read(sc->sc_ec, (u_int8_t)address, len, buffer); else acpiec_write(sc->sc_ec, (u_int8_t)address, len, buffer); +#endif break; } return (0); @@ -516,6 +518,7 @@ acpi_inidev(struct aml_node *node, void *arg) aml_freevalue(&res); } +#ifndef SMALL_KERNEL void acpi_foundtmp(struct aml_node *node, void *arg) { @@ -658,6 +661,7 @@ acpi_founddock(struct aml_node *node, void *arg) config_found(self, &aaa, acpi_print); } +#endif /* SMALL_KERNEL */ void acpi_init_pic(struct acpi_softc *sc) @@ -724,11 +728,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux) struct acpi_rsdp *rsdp; struct acpi_q *entry; struct acpi_dsdt *p_dsdt; +#ifndef SMALL_KERNEL struct device *dev; struct acpi_ac *ac; struct acpi_bat *bat; paddr_t facspa; - +#endif sc->sc_iot = aaa->aaa_iot; sc->sc_memt = aaa->aaa_memt; @@ -825,8 +830,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) aml_postparse(); /* Walk AML Tree */ - //aml_walkroot(); + /* aml_walkroot(); */ +#ifndef SMALL_KERNEL /* Find available sleeping states */ acpi_init_states(sc); @@ -855,6 +861,8 @@ acpi_attach(struct device *parent, struct device *self, void *aux) /* some devices require periodic polling */ timeout_set(&sc->sc_dev_timeout, acpi_poll, sc); +#endif + /* * Take over ACPI control. Note that once we do this, we * effectively tell the system that we have ownership of @@ -889,6 +897,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) } printf("\n"); +#ifndef SMALL_KERNEL /* * ACPI is enabled now -- attach timer */ @@ -905,6 +914,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) #endif config_found(self, &aaa, acpi_print); } +#endif /* SMALL_KERNEL */ /* * Attach table-defined devices @@ -931,6 +941,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) /* attach pci interrupt routing tables */ aml_find_node(aml_root.child, "_PRT", acpi_foundprt, sc); +#ifndef SMALL_KERNEL /* XXX EC needs to be attached first on some systems */ aml_find_node(aml_root.child, "_HID", acpi_foundec, sc); @@ -971,6 +982,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_thread->running = 1; kthread_create_deferred(acpi_create_thread, sc); +#endif /* SMALL_KERNEL */ } int @@ -1129,6 +1141,7 @@ acpi_load_dsdt(paddr_t pa, struct acpi_q **dsdt) } } +#ifndef SMALL_KERNEL int acpi_interrupt(void *arg) { @@ -1450,6 +1463,107 @@ acpi_powerdown(void) acpi_enter_sleep_state(acpi_softc, ACPI_STATE_S5); } +void +acpi_isr_thread(void *arg) +{ + struct acpi_thread *thread = arg; + struct acpi_softc *sc = thread->sc; + u_int32_t gpe; + + /* + * If we have an interrupt handler, we can get notification + * when certain status bits changes in the ACPI registers, + * so let us enable some events we can forward to userland + */ + if (sc->sc_interrupt) { + int16_t flag; + + dnprintf(1,"slpbtn:%c pwrbtn:%c\n", + sc->sc_fadt->flags & FADT_SLP_BUTTON ? 'n' : 'y', + sc->sc_fadt->flags & FADT_PWR_BUTTON ? 'n' : 'y'); + dnprintf(10, "Enabling acpi interrupts...\n"); + sc->sc_wakeup = 1; + + /* Enable Sleep/Power buttons if they exist */ + flag = acpi_read_pmreg(sc, ACPIREG_PM1_EN, 0); + if (!(sc->sc_fadt->flags & FADT_PWR_BUTTON)) { + flag |= ACPI_PM1_PWRBTN_EN; + } + if (!(sc->sc_fadt->flags & FADT_SLP_BUTTON)) { + flag |= ACPI_PM1_SLPBTN_EN; + } + acpi_write_pmreg(sc, ACPIREG_PM1_EN, 0, flag); + + /* Enable handled GPEs here */ + for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { + if (sc->gpe_table[gpe].handler) + acpi_enable_onegpe(sc, gpe, 1); + } + } + + while (thread->running) { + dnprintf(10, "sleep... %d\n", sc->sc_wakeup); + while (sc->sc_wakeup) + tsleep(sc, PWAIT, "acpi_idle", 0); + sc->sc_wakeup = 1; + dnprintf(10, "wakeup..\n"); + + for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { + struct gpe_block *pgpe = &sc->gpe_table[gpe]; + + if (pgpe->active) { + pgpe->active = 0; + dnprintf(50, "softgpe: %.2x\n", gpe); + if (pgpe->handler) + pgpe->handler(sc, gpe, pgpe->arg); + } + } + if (sc->sc_powerbtn) { + sc->sc_powerbtn = 0; + + aml_notify_dev(ACPI_DEV_PBD, 0x80); + + acpi_evindex++; + dnprintf(1,"power button pressed\n"); + KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_PWRBTN, + acpi_evindex)); + } + if (sc->sc_sleepbtn) { + sc->sc_sleepbtn = 0; + + aml_notify_dev(ACPI_DEV_SBD, 0x80); + + acpi_evindex++; + dnprintf(1,"sleep button pressed\n"); + KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_SLPBTN, + acpi_evindex)); + } + + /* handle polling here to keep code non-concurrent*/ + if (sc->sc_poll) { + sc->sc_poll = 0; + acpi_poll_notify(); + } + } + free(thread, M_DEVBUF); + + kthread_exit(0); +} + +void +acpi_create_thread(void *arg) +{ + struct acpi_softc *sc = arg; + + if (kthread_create(acpi_isr_thread, sc->sc_thread, NULL, DEVNAME(sc)) + != 0) { + printf("%s: unable to create isr thread, GPEs disabled\n", + DEVNAME(sc)); + return; + } +} +#endif /* SMALL_KERNEL */ + int acpiopen(dev_t dev, int flag, int mode, struct proc *p) { @@ -1478,11 +1592,13 @@ acpiclose(dev_t dev, int flag, int mode, struct proc *p) int acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { + int error = 0; +#ifndef SMALL_KERNEL struct acpi_softc *sc; struct acpi_ac *ac; struct acpi_bat *bat; struct apm_power_info *pi = (struct apm_power_info *)data; - int error = 0, bats; + int bats; unsigned int remaining, rem, minutes, rate; if (!acpi_cd.cd_ndevs || minor(dev) != 0 || @@ -1561,6 +1677,9 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } ACPI_UNLOCK(sc); +#else + error = ENXIO; +#endif /* SMALL_KERNEL */ return (error); } @@ -1609,103 +1728,3 @@ acpikqfilter(dev_t dev, struct knote *kn) return (0); } - -void -acpi_isr_thread(void *arg) -{ - struct acpi_thread *thread = arg; - struct acpi_softc *sc = thread->sc; - u_int32_t gpe; - - /* - * If we have an interrupt handler, we can get notification - * when certain status bits changes in the ACPI registers, - * so let us enable some events we can forward to userland - */ - if (sc->sc_interrupt) { - int16_t flag; - - dnprintf(1,"slpbtn:%c pwrbtn:%c\n", - sc->sc_fadt->flags & FADT_SLP_BUTTON ? 'n' : 'y', - sc->sc_fadt->flags & FADT_PWR_BUTTON ? 'n' : 'y'); - dnprintf(10, "Enabling acpi interrupts...\n"); - sc->sc_wakeup = 1; - - /* Enable Sleep/Power buttons if they exist */ - flag = acpi_read_pmreg(sc, ACPIREG_PM1_EN, 0); - if (!(sc->sc_fadt->flags & FADT_PWR_BUTTON)) { - flag |= ACPI_PM1_PWRBTN_EN; - } - if (!(sc->sc_fadt->flags & FADT_SLP_BUTTON)) { - flag |= ACPI_PM1_SLPBTN_EN; - } - acpi_write_pmreg(sc, ACPIREG_PM1_EN, 0, flag); - - /* Enable handled GPEs here */ - for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { - if (sc->gpe_table[gpe].handler) - acpi_enable_onegpe(sc, gpe, 1); - } - } - - while (thread->running) { - dnprintf(10, "sleep... %d\n", sc->sc_wakeup); - while (sc->sc_wakeup) - tsleep(sc, PWAIT, "acpi_idle", 0); - sc->sc_wakeup = 1; - dnprintf(10, "wakeup..\n"); - - for (gpe = 0; gpe < sc->sc_lastgpe; gpe++) { - struct gpe_block *pgpe = &sc->gpe_table[gpe]; - - if (pgpe->active) { - pgpe->active = 0; - dnprintf(50, "softgpe: %.2x\n", gpe); - if (pgpe->handler) - pgpe->handler(sc, gpe, pgpe->arg); - } - } - if (sc->sc_powerbtn) { - sc->sc_powerbtn = 0; - - aml_notify_dev(ACPI_DEV_PBD, 0x80); - - acpi_evindex++; - dnprintf(1,"power button pressed\n"); - KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_PWRBTN, - acpi_evindex)); - } - if (sc->sc_sleepbtn) { - sc->sc_sleepbtn = 0; - - aml_notify_dev(ACPI_DEV_SBD, 0x80); - - acpi_evindex++; - dnprintf(1,"sleep button pressed\n"); - KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_SLPBTN, - acpi_evindex)); - } - - /* handle polling here to keep code non-concurrent*/ - if (sc->sc_poll) { - sc->sc_poll = 0; - acpi_poll_notify(); - } - } - free(thread, M_DEVBUF); - - kthread_exit(0); -} - -void -acpi_create_thread(void *arg) -{ - struct acpi_softc *sc = arg; - - if (kthread_create(acpi_isr_thread, sc->sc_thread, NULL, DEVNAME(sc)) - != 0) { - printf("%s: unable to create isr thread, GPEs disabled\n", - DEVNAME(sc)); - return; - } -} |