diff options
author | Jordan Hargrave <jordan@cvs.openbsd.org> | 2005-12-16 00:08:54 +0000 |
---|---|---|
committer | Jordan Hargrave <jordan@cvs.openbsd.org> | 2005-12-16 00:08:54 +0000 |
commit | f624844013dce61b546f77b9db84844d8b2bd951 (patch) | |
tree | f5c0ef3f3c4921c4ede597100a839ee64ec7e62f /sys/dev/acpi | |
parent | b05373089eea560beafa272e77be00a19d2c419f (diff) |
Moved DSDT AML parsing into parent ACPI driver
ok marco@
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpi.c | 149 | ||||
-rw-r--r-- | sys/dev/acpi/acpireg.h | 16 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 89 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.h | 3 | ||||
-rw-r--r-- | sys/dev/acpi/files.acpi | 7 |
5 files changed, 149 insertions, 115 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index bf7e07ccd05..ce8daa0114b 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.6 2005/12/14 04:16:25 marco Exp $ */ +/* $OpenBSD: acpi.c,v 1.7 2005/12/16 00:08:53 jordan Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -69,44 +69,119 @@ int acpi_evindex; struct acpi_softc *acpi_softc; #if 0 -void -acpi_read_pm1_status(struct acpi_softc *sc, uint32_t *status_a, uint32_t *status_b) -{ - *status_a = bus_space_read_2(sc->sc_iot, sc->sc_ioh_pm1a_evt, ACPI_PM1_STATUS); - *status_b = 0; -} -void -acpi_write_pm1_status(struct acpi_softc *sc, uint32_t status_a, uint32_t status_b) -{ - bus_space_write_2(sc->sc_iot, sc->sc_ioh_pm1a_evt, ACPI_PM1_STATUS, status_a); -} -void -acpi_read_pm1_enable(struct acpi_softc *sc, uint32_t *enable_a, uint32_t *enable_b) -{ - *status_a = bus_space_read_2(sc->sc_iot, sc->sc_ioh_pm1a_evt, ACPI_PM1_STATUS); - *status_b = 0; -} -void -acpi_write_pm1_enable(struct acpi_softc *sc, uint32_t enable_a, uint32_t enable_b) +int +acpi_mapregister(struct acpi_softc *sc, int reg, bus_space_handle_t *ioh) { - bus_space_write_2(sc->sc_iot, sc->sc_ioh_pm1a_evt, ACPI_PM1_STATUS, status_a); -} + bus_addr_t addr; + bus_size_t size; + + size = 0; + switch (reg) { + case ACPIREG_SMICMD: + size = 1; + addr = sc->sc_fadt->smi_cmd; + break; -void -acpi_read_gpe_status(struct acpi_softc *sc, uint32_t *status_0, uint32_t *status_1) -{ -} -void -acpi_write_gpe_status(struct acpi_softc *sc, uint32_t status_0, uint32_t status_1) -{ + case ACPIREG_PM1A_STS: + case ACPIREG_PM1A_EN: + size = sc->sc_fadt->pm1_evt_len >> 1; + addr = sc->sc_fadt->pm1a_evt_blk; + if (reg == ACPIREG_PM1A_EN) + addr += size; + break; + case ACPIREG_PM1A_CNT: + size = sc->sc_fadt->pm1_cnt_len; + addr = sc->sc_fadt->pm1a_cnt_blk; + break; + + case ACPIREG_PM1B_STS: + case ACPIREG_PM1B_EN: + size = sc->sc_fadt->pm1_evt_len >> 1; + addr = sc->sc_fadt->pm1b_evt_blk; + if (reg == ACPIREG_PM1B_EN) + addr += size; + break; + case ACPIREG_PM1B_CNT: + size = sc->sc_fadt->pm1_cnt_len; + addr = sc->sc_fadt->pm1b_cnt_blk; + break; + + case ACPIREG_PM2_CNT: + size = sc->sc_fadt->pm2_cnt_len; + addr = sc->sc_fadt->pm2_cnt_blk; + break; + + case ACPIREG_PM_TMR: + size = sc->sc_fadt->pm_tmr_len; + addr = sc->sc_fadt->pm_tmr_blk; + break; + + case ACPIREG_GPE0_STS: + case ACPIREG_GPE0_EN: + size = sc->sc_fadt->gpe0_len >> 1; + addr = sc->sc_fadt->gpe0_blk; + if (reg == ACPIREG_GPE0_EN) + addr += size; + break; + + case ACPIREG_GPE1_STS: + case ACPIREG_GPE1_EN: + size = sc->sc_fadt->gpe1_len >> 1; + addr = sc->sc_fadt->gpe1_blk; + if (reg == ACPIREG_GPE1_EN) + addr += size; + break; + } + if (size) { + bus_space_map(sc->sc_iot, addr, size, 0, ioh); + + return (size); } -void -acpi_read_gpe_enable(struct acpi_softc *sc, uint32_t *enable_0, uint32_t *enable_1) + +uint32_t +acpi_read_pm_reg(struct acpi_softc *sc, int reg) { + bus_space_handle_t ioh; + int size; + uint32_t rval; + + rval = 0; + size = acpi_mapregister(sc, reg, &ioh); + switch (size) { + case 1: + rval = bus_space_read_1(sc->sc_ioh, ioh, 0); + break; + case 2: + rval = bus_space_read_2(sc->sc_ioh, ioh, 0); + break; + case 4: + rval = bus_space_read_4(sc->sc_ioh, ioh, 0); + break; + } + if (size) + bus_space_unmap(sc->sc_iot, ioh, size); + + return rval; } void -acpi_write_gpe_enable(struct acpi_softc *sc, uint32_t enable_0, uint32_t enable_1) +acpi_write_pm_reg(struct acpi_softc *sc, int reg, uint32_t regval) { + bus_space_handle_t ioh; + int size, offset; + + size = acpi_mapregister(sc, &ioh); + switch (size) { + case 1: + bus_space_write_1(sc->sc_iot, ioh, 0, regval); + break; + case 2: + bus_space_write_2(sc->sc_iot, ioh, 0, regval); + break; + case 4: + bus_space_write_4(sc->sc_iot, ioh, 0, regval); + break; + } + acpi_unmapregister(sc, reg, ioh); } #endif @@ -177,6 +252,7 @@ acpiattach(struct device *parent, struct device *self, void *aux) struct acpi_mem_map handle; struct acpi_rsdp *rsdp; struct acpi_q *entry; + struct acpi_dsdt *p_dsdt; paddr_t facspa; sc->sc_iot = aaa->aaa_iot; @@ -238,6 +314,9 @@ acpiattach(struct device *parent, struct device *self, void *aux) printf("!DSDT "); SIMPLEQ_INSERT_HEAD(&sc->sc_tables, entry, q_next); + p_dsdt = entry->q_table; + acpi_parse_aml(sc, p_dsdt->aml, p_dsdt->hdr_length - sizeof(p_dsdt->hdr)); + /* * Set up a pointer to the firmware control structure */ @@ -506,11 +585,6 @@ acpi_interrupt(void *arg) struct acpi_softc *sc = (struct acpi_softc *)arg; u_int16_t flags; -#if 0 - acpi_read_pm1_status(sc, &sts_a, &sts_b); - if ((sts_a & ACPI_PM1_PWRBTN_STS) && (sts_b & ACPI_PM1_PWRBTN_STS) { - acpi_write_pm1_status(sc, -#else flags = bus_space_read_2(sc->sc_iot, sc->sc_ioh_pm1a_evt, ACPI_PM1_STATUS); if (flags & (ACPI_PM1_PWRBTN_STS | ACPI_PM1_SLPBTN_STS)) { @@ -538,7 +612,6 @@ acpi_interrupt(void *arg) #endif return (1); } -#endif return (0); } diff --git a/sys/dev/acpi/acpireg.h b/sys/dev/acpi/acpireg.h index 0dc0f5f324a..8c85d417f63 100644 --- a/sys/dev/acpi/acpireg.h +++ b/sys/dev/acpi/acpireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpireg.h,v 1.4 2005/12/14 04:16:25 marco Exp $ */ +/* $OpenBSD: acpireg.h,v 1.5 2005/12/16 00:08:53 jordan Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Marco Peereboom <marco@opebsd.org> @@ -457,4 +457,18 @@ struct acpi_facs { #define ACPI_DEV_IOA "ACPI000A" /* IO APIC Device */ #define ACPI_DEV_IOSA "ACPI000B" /* IO SAPIC Device */ +#define ACPIREG_PM1A_STS 0x00 +#define ACPIREG_PM1A_EN 0x01 +#define ACPIREG_PM1A_CNT 0x02 +#define ACPIREG_PM1B_STS 0x03 +#define ACPIREG_PM1B_EN 0x04 +#define ACPIREG_PM1B_CNT 0x05 +#define ACPIREG_PM2_CNT 0x06 +#define ACPIREG_PM_TMR 0x07 +#define ACPIREG_GPE0_STS 0x08 +#define ACPIREG_GPE0_EN 0x09 +#define ACPIREG_GPE1_STS 0x0A +#define ACPIREG_GPE1_EN 0x0B +#define ACPIREG_SMICMD 0x0C + #endif /* !_DEV_ACPI_ACPIREG_H_ */ diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 254e79a02f5..a7341a7deed 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.10 2005/12/14 03:46:38 marco Exp $ */ +/* $OpenBSD: dsdt.c,v 1.11 2005/12/16 00:08:53 jordan Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -27,59 +27,8 @@ #include <dev/acpi/amltypes.h> #include <dev/acpi/dsdt.h> -struct dsdt_softc { - struct device sc_dev; - - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; -}; - -int dsdtmatch(struct device *, void *, void *); -void dsdtattach(struct device *, struct device *, void *); -int dsdt_parse_aml(struct dsdt_softc *, u_int8_t *, u_int32_t); - -struct cfattach dsdt_ca = { - sizeof(struct dsdt_softc), dsdtmatch, dsdtattach -}; - -struct cfdriver dsdt_cd = { - NULL, "dsdt", DV_DULL -}; - extern int acpi_debug; -int -dsdtmatch(struct device *parent, void *match, void *aux) -{ - struct acpi_attach_args *aaa = aux; - struct acpi_table_header *hdr; - - /* if we do not have a table, it is not us */ - if (aaa->aaa_table == NULL) - return (0); - - /* if it is an DSDT table, we can attach */ - hdr = (struct acpi_table_header *)aaa->aaa_table; - if (memcmp(hdr->signature, DSDT_SIG, sizeof(DSDT_SIG) - 1) == 0) - return (1); - - /* Attach SSDT tables */ - if (memcmp(hdr->signature, SSDT_SIG, sizeof(SSDT_SIG) - 1) == 0) - return (1); - - return (0); -} - -void -dsdtattach(struct device *parent, struct device *self, void *aux) -{ - struct acpi_attach_args *aa = aux; - struct dsdt_softc *sc = (struct dsdt_softc *) self; - struct acpi_dsdt *dsdt = (struct acpi_dsdt *)aa->aaa_table; - - dsdt_parse_aml(sc, dsdt->aml, dsdt->hdr_length - sizeof(dsdt->hdr)); -} - struct aml_optable { u_int16_t opcode; @@ -98,8 +47,8 @@ int aml_isnamedop(u_int16_t); u_int8_t *aml_decodelength(u_int8_t *, int *); u_int8_t *aml_decodename(u_int8_t *, const char **, const char *); u_int8_t *aml_getopcode(u_int8_t *, u_int16_t *); -u_int8_t *aml_parseargs(struct dsdt_softc *, struct aml_node *, u_int8_t *, const char *); -u_int8_t *aml_parse_object(struct dsdt_softc *, struct aml_node *, u_int8_t *); +u_int8_t *aml_parseargs(struct acpi_softc *, struct aml_node *, u_int8_t *, const char *); +u_int8_t *aml_parse_object(struct acpi_softc *, struct aml_node *, u_int8_t *); u_int64_t aml_bcd2dec(u_int64_t); u_int64_t aml_dec2bcd(u_int64_t); @@ -122,11 +71,11 @@ void aml_setopregion(struct aml_value *, int, int, u_int64_t); void aml_setpackage(struct aml_value *, struct aml_node *); void aml_setprocessor(struct aml_value *, u_int8_t, u_int32_t, u_int8_t); -void aml_setnodevalue(struct dsdt_softc *, struct aml_node *, const struct aml_value *); -void aml_setnodeinteger(struct dsdt_softc *, struct aml_node *, int64_t); +void aml_setnodevalue(struct acpi_softc *, struct aml_node *, const struct aml_value *); +void aml_setnodeinteger(struct acpi_softc *, struct aml_node *, int64_t); -int aml_match(struct dsdt_softc *, int, const struct aml_value *, const struct aml_value *); -int aml_cmpobj(struct dsdt_softc *, const struct aml_value *, const struct aml_value *); +int aml_match(struct acpi_softc *, int, const struct aml_value *, const struct aml_value *); +int aml_cmpobj(struct acpi_softc *, const struct aml_value *, const struct aml_value *); void aml_setinteger(struct aml_value *val, int size, int64_t value) @@ -609,7 +558,7 @@ struct aml_optable aml_table[] = { { 0xFFFF } }; -int aml_evalnode(struct dsdt_softc *, struct aml_node *, struct aml_value *, +int aml_evalnode(struct acpi_softc *, struct aml_node *, struct aml_value *, struct aml_value *); void aml_copyvalue(struct aml_value *, const struct aml_value *); @@ -651,7 +600,7 @@ childOf(struct aml_node *parent, int child) struct aml_value aml_debug; void -aml_setnodevalue(struct dsdt_softc *sc, struct aml_node *node, const struct aml_value *val) +aml_setnodevalue(struct acpi_softc *sc, struct aml_node *node, const struct aml_value *val) { switch (node->opcode) { case AMLOP_DEBUG: @@ -676,7 +625,7 @@ aml_setnodevalue(struct dsdt_softc *sc, struct aml_node *node, const struct aml_ } void -aml_setnodeinteger(struct dsdt_softc *sc, struct aml_node *node, int64_t value) +aml_setnodeinteger(struct acpi_softc *sc, struct aml_node *node, int64_t value) { struct aml_value ival; @@ -686,7 +635,7 @@ aml_setnodeinteger(struct dsdt_softc *sc, struct aml_node *node, int64_t value) #if 0 int -aml_callmethod(struct dsdt_softc *sc, struct aml_node *parent, const char *method, +aml_callmethod(struct acpi_softc *sc, struct aml_node *parent, const char *method, int nargs, struct aml_value *args, struct aml_value *result) { struct aml_node *pnode; @@ -708,17 +657,17 @@ aml_callmethod(struct dsdt_softc *sc, struct aml_node *parent, const char *metho } int -aml_readfield(struct dsdt_softc *sc, const struct aml_value *field, struct aml_value *dest) +aml_readfield(struct acpi_softc *sc, const struct aml_value *field, struct aml_value *dest) { } int -aml_writefield(struct dsdt_softc *sc, const struct aml_value *field, const struct aml_value *src) +aml_writefield(struct acpi_softc *sc, const struct aml_value *field, const struct aml_value *src) { } #endif -int aml_cmpobj(struct dsdt_softc *sc, const struct aml_value *lhs, +int aml_cmpobj(struct acpi_softc *sc, const struct aml_value *lhs, const struct aml_value *rhs) { /* ASSERT: lhs and rhs are of same type */ @@ -736,7 +685,7 @@ int aml_cmpobj(struct dsdt_softc *sc, const struct aml_value *lhs, } int -aml_match(struct dsdt_softc *sc, int mtype, const struct aml_value *lhs, +aml_match(struct acpi_softc *sc, int mtype, const struct aml_value *lhs, const struct aml_value *rhs) { int rc; @@ -765,7 +714,7 @@ aml_match(struct dsdt_softc *sc, int mtype, const struct aml_value *lhs, } int -aml_evalnode(struct dsdt_softc *sc, struct aml_node *node, struct aml_value *result, +aml_evalnode(struct acpi_softc *sc, struct aml_node *node, struct aml_value *result, struct aml_value *env) { struct aml_value lhs, rhs, tmp, pkg, op1, op2; @@ -1129,7 +1078,7 @@ aml_evalnode(struct dsdt_softc *sc, struct aml_node *node, struct aml_value *res } u_int8_t * -aml_parseargs(struct dsdt_softc *sc, struct aml_node *node, u_int8_t *pos, +aml_parseargs(struct acpi_softc *sc, struct aml_node *node, u_int8_t *pos, const char *arg) { int len; @@ -1256,7 +1205,7 @@ aml_addchildnode(struct aml_node *parent, struct aml_node *child) } u_int8_t * -aml_parse_object(struct dsdt_softc *sc, struct aml_node *parent, u_int8_t *pos) +aml_parse_object(struct acpi_softc *sc, struct aml_node *parent, u_int8_t *pos) { struct aml_optable *optab = aml_table; u_int8_t *nxtpos; @@ -1380,7 +1329,7 @@ aml_eisaid(u_int32_t pid) } int -dsdt_parse_aml(struct dsdt_softc *sc, u_int8_t *start, u_int32_t length) +acpi_parse_aml(struct acpi_softc *sc, u_int8_t *start, u_int32_t length) { u_int8_t *pos, *nxtpos; diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h index bed392a3c91..28f521835c8 100644 --- a/sys/dev/acpi/dsdt.h +++ b/sys/dev/acpi/dsdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.h,v 1.1 2005/12/13 07:22:18 marco Exp $ */ +/* $OpenBSD: dsdt.h,v 1.2 2005/12/16 00:08:53 jordan Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -21,5 +21,6 @@ const char *aml_eisaid(u_int32_t); int aml_find_node(struct aml_node *, const char *, void (*)(struct aml_node *, void *), void *); +int acpi_parse_aml(struct acpi_softc *, u_int8_t *, u_int32_t); #endif /* __DEV_ACPI_DSDT_H__ */ diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 21b8b85e926..d112ce0f6fe 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.5 2005/12/14 04:16:25 marco Exp $ +# $OpenBSD: files.acpi,v 1.6 2005/12/16 00:08:53 jordan Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -8,6 +8,7 @@ device acpi attach acpi at mainbus file dev/acpi/acpi.c acpi needs-flag file dev/acpi/acpiutil.c acpi +file dev/acpi/dsdt.c acpi # ACPI timer device acpitimer @@ -29,7 +30,3 @@ device hpet attach hpet at acpi file dev/acpi/hpet.c hpet -# DSDT (AML Parser) -device dsdt -attach dsdt at acpi -file dev/acpi/dsdt.c dsdt |