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 | |
parent | 41ba8ea6e88f4010ce8cae1b994e736d8392ee5b (diff) |
Add SMALL_KERNEL throught acpi to make it fit on boot media.
ok deraadt
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/amd64/conf/RAMDISK_CD | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISKB | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISKC | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK_CD | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 4 | ||||
-rw-r--r-- | sys/dev/acpi/acpi.c | 227 | ||||
-rw-r--r-- | sys/dev/acpi/acpiec.c | 4 |
10 files changed, 142 insertions, 121 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 7c464b5a3a3..542807f4887 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.54 2007/02/01 20:42:17 art Exp $ */ +/* $OpenBSD: machdep.c,v 1.55 2007/02/17 23:59:03 marco Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -908,7 +908,7 @@ haltsys: #endif if (howto & RB_HALT) { -#if NACPI > 0 +#if NACPI > 0 && !defined(SMALL_KERNEL) extern int acpi_s5, acpi_enabled; if (acpi_enabled) { diff --git a/sys/arch/amd64/conf/RAMDISK b/sys/arch/amd64/conf/RAMDISK index 3f75a52eeff..b21e82cc082 100644 --- a/sys/arch/amd64/conf/RAMDISK +++ b/sys/arch/amd64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.36 2006/12/20 03:33:12 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.37 2007/02/17 23:59:03 marco Exp $ machine amd64 # architecture, used by config; REQUIRED @@ -40,7 +40,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/amd64/conf/RAMDISK_CD b/sys/arch/amd64/conf/RAMDISK_CD index 73e791c637a..a6fc2ea495e 100644 --- a/sys/arch/amd64/conf/RAMDISK_CD +++ b/sys/arch/amd64/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.68 2007/02/04 23:30:19 jsg Exp $ +# $OpenBSD: RAMDISK_CD,v 1.69 2007/02/17 23:59:03 marco Exp $ machine amd64 # architecture, used by config; REQUIRED @@ -41,7 +41,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK index 36ca21f19fa..78715660e1b 100644 --- a/sys/arch/i386/conf/RAMDISK +++ b/sys/arch/i386/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.147 2007/02/17 03:16:26 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.148 2007/02/17 23:59:03 marco Exp $ machine i386 # architecture, used by config; REQUIRED @@ -46,7 +46,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/i386/conf/RAMDISKB b/sys/arch/i386/conf/RAMDISKB index 34cf7f3f3df..3efc9e35c9a 100644 --- a/sys/arch/i386/conf/RAMDISKB +++ b/sys/arch/i386/conf/RAMDISKB @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISKB,v 1.94 2006/12/20 03:31:33 deraadt Exp $ +# $OpenBSD: RAMDISKB,v 1.95 2007/02/17 23:59:03 marco Exp $ machine i386 # architecture, used by config; REQUIRED @@ -46,7 +46,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/i386/conf/RAMDISKC b/sys/arch/i386/conf/RAMDISKC index c1027ffd5d9..a244389bfc7 100644 --- a/sys/arch/i386/conf/RAMDISKC +++ b/sys/arch/i386/conf/RAMDISKC @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISKC,v 1.71 2006/12/20 03:32:20 deraadt Exp $ +# $OpenBSD: RAMDISKC,v 1.72 2007/02/17 23:59:03 marco Exp $ machine i386 # architecture, used by config; REQUIRED @@ -46,7 +46,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/i386/conf/RAMDISK_CD b/sys/arch/i386/conf/RAMDISK_CD index 79b6beedac9..a9cd3b50b86 100644 --- a/sys/arch/i386/conf/RAMDISK_CD +++ b/sys/arch/i386/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.134 2007/02/04 23:30:19 jsg Exp $ +# $OpenBSD: RAMDISK_CD,v 1.135 2007/02/17 23:59:03 marco Exp $ machine i386 # architecture, used by config; REQUIRED @@ -48,7 +48,7 @@ acpi0 at mainbus? disable #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? -acpiec* at acpi? disable +#acpiec* at acpi? acpiprt* at acpi? #acpitz* at acpi? diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 838e9e45ce0..60f984e5f38 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.376 2007/02/17 17:38:37 tom Exp $ */ +/* $OpenBSD: machdep.c,v 1.377 2007/02/17 23:59:03 marco Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2456,7 +2456,7 @@ haltsys: doshutdownhooks(); if (howto & RB_HALT) { -#if NACPI > 0 +#if NACPI > 0 && !defined(SMALL_KERNEL) extern int acpi_s5, acpi_enabled; if (acpi_enabled) { 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; - } -} diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index e69129d084c..24acd86d84e 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.15 2006/12/23 17:24:40 canacar Exp $ */ +/* $OpenBSD: acpiec.c,v 1.16 2007/02/17 23:59:03 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * @@ -297,8 +297,10 @@ acpiec_attach(struct device *parent, struct device *self, void *aux) dnprintf(10, "%s: GPE: %d\n", DEVNAME(sc), sc->sc_gpe); +#ifndef SMALL_KERNEL acpi_set_gpehandler(sc->sc_acpi, sc->sc_gpe, acpiec_gpehandler, sc, "acpiec"); +#endif printf(": %s\n", sc->sc_devnode->parent->name); } |