/* ddb interface */ void db_acpi_showval(db_expr_t addr, int haddr, db_expr_t count, char *modif) { struct aml_node *node; if (db_parse_name()) return; node = aml_searchname(&aml_root, scope); if (node) db_aml_showvalue(node->value); else db_printf("Not a valid value\n"); }
void acpiec_get_events(struct acpiec_softc *sc) { int idx; char name[16]; memset(sc->sc_events, 0, sizeof(sc->sc_events)); for (idx = 0; idx < ACPIEC_MAX_EVENTS; idx++) { snprintf(name, sizeof(name), "_Q%02X", idx); sc->sc_events[idx].event = aml_searchname(sc->sc_devnode, name); if (sc->sc_events[idx].event != NULL) dnprintf(10, "%s: Found event %s\n", DEVNAME(sc), name); } }
int acpi_foundvout(struct aml_node *node, void *arg) { struct acpivideo_softc *sc = (struct acpivideo_softc *)arg; struct device *self = (struct device *)arg; struct acpi_attach_args aaa; node = node->parent; DPRINTF(("Inside acpi_foundvout()\n")); if (node->parent != sc->sc_devnode) return (0); if (aml_searchname(node, "_BCM") && aml_searchname(node, "_BQC")) { memset(&aaa, 0, sizeof(aaa)); aaa.aaa_iot = sc->sc_acpi->sc_iot; aaa.aaa_memt = sc->sc_acpi->sc_memt; aaa.aaa_node = node; aaa.aaa_name = "acpivout"; config_found(self, &aaa, acpivideo_print); } return (0); }
int acpiec_reg(struct acpiec_softc *sc) { struct aml_value arg[2]; struct aml_node *node; memset(&arg, 0, sizeof(arg)); arg[0].type = AML_OBJTYPE_INTEGER; arg[0].v_integer = REG_TYPE_EC; arg[1].type = AML_OBJTYPE_INTEGER; arg[1].v_integer = 1; node = aml_searchname(sc->sc_devnode, "_REG"); if (node && aml_evalnode(sc->sc_acpi, node, 2, arg, NULL)) { dnprintf(10, "%s: eval method _REG failed\n", DEVNAME(sc)); printf("acpiec _REG failed, broken BIOS\n"); } return (0); }
void db_acpi_disasm(db_expr_t addr, int haddr, db_expr_t count, char *modif) { struct aml_node *node; if (db_parse_name()) return; node = aml_searchname(&aml_root, scope); if (node && node->value && node->value->type == AML_OBJTYPE_METHOD) { struct aml_scope ns; memset(&ns, 0, sizeof(ns)); ns.pos = node->value->v_method.start; ns.end = node->value->v_method.end; ns.node = node; while (ns.pos < ns.end) aml_disasm(&ns, 0, db_disprint, 0); } else db_printf("Not a valid method\n"); }
int acpidock_foundejd(struct aml_node *node, void *arg) { struct acpidock_softc *sc = (struct acpidock_softc *)arg; struct aml_value res; struct aml_node *dock; extern struct aml_node aml_root; dnprintf(15, "%s: %s", DEVNAME(sc), node->name); if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == -1) printf(": error\n"); else { dock = aml_searchname(&aml_root, res.v_string); if (dock == sc->sc_devnode) /* Add all children devices of Device containing _EJD */ aml_walknodes(node->parent, AML_WALK_POST, acpidock_walkchildren, sc); aml_freevalue(&res); } return (0); }
int acpiec_getcrs(struct acpiec_softc *sc, struct acpi_attach_args *aa) { struct aml_value res; bus_size_t ec_sc, ec_data; int dtype, ctype; char *buf; int size, ret; int64_t gpe; struct acpi_ecdt *ecdt = aa->aaa_table; extern struct aml_node aml_root; /* Check if this is ECDT initialization */ if (ecdt) { /* Get GPE, Data and Control segments */ sc->sc_gpe = ecdt->gpe_bit; ctype = ecdt->ec_control.address_space_id; ec_sc = ecdt->ec_control.address; dtype = ecdt->ec_data.address_space_id; ec_data = ecdt->ec_data.address; /* Get devnode from header */ sc->sc_devnode = aml_searchname(&aml_root, ecdt->ec_id); goto ecdtdone; } if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_GPE", 0, NULL, &gpe)) { dnprintf(10, "%s: no _GPE\n", DEVNAME(sc)); return (1); } sc->sc_gpe = gpe; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_CRS", 0, NULL, &res)) { dnprintf(10, "%s: no _CRS\n", DEVNAME(sc)); return (1); } /* Parse CRS to get control and data registers */ if (res.type != AML_OBJTYPE_BUFFER) { dnprintf(10, "%s: unknown _CRS type %d\n", DEVNAME(sc), res.type); aml_freevalue(&res); return (1); } size = res.length; buf = res.v_buffer; ret = acpiec_getregister(buf, size, &dtype, &ec_data); if (ret <= 0) { dnprintf(10, "%s: failed to read DATA from _CRS\n", DEVNAME(sc)); aml_freevalue(&res); return (1); } buf += ret; size -= ret; ret = acpiec_getregister(buf, size, &ctype, &ec_sc); if (ret <= 0) { dnprintf(10, "%s: failed to read S/C from _CRS\n", DEVNAME(sc)); aml_freevalue(&res); return (1); } buf += ret; size -= ret; if (size != 2 || *buf != RES_TYPE_ENDTAG) { dnprintf(10, "%s: no _CRS end tag\n", DEVNAME(sc)); aml_freevalue(&res); return (1); } aml_freevalue(&res); /* XXX: todo - validate _CRS checksum? */ ecdtdone: dnprintf(10, "%s: Data: 0x%lx, S/C: 0x%lx\n", DEVNAME(sc), ec_data, ec_sc); if (ctype == GAS_SYSTEM_IOSPACE) sc->sc_cmd_bt = aa->aaa_iot; else sc->sc_cmd_bt = aa->aaa_memt; if (bus_space_map(sc->sc_cmd_bt, ec_sc, 1, 0, &sc->sc_cmd_bh)) { dnprintf(10, "%s: failed to map S/C reg.\n", DEVNAME(sc)); return (1); } if (dtype == GAS_SYSTEM_IOSPACE) sc->sc_data_bt = aa->aaa_iot; else sc->sc_data_bt = aa->aaa_memt; if (bus_space_map(sc->sc_data_bt, ec_data, 1, 0, &sc->sc_data_bh)) { dnprintf(10, "%s: failed to map DATA reg.\n", DEVNAME(sc)); bus_space_unmap(sc->sc_cmd_bt, sc->sc_cmd_bh, 1); return (1); } return (0); }
void acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) { struct aml_node *node; struct aml_value res, *pp; u_int64_t addr; int pin, irq, sta; #if NIOAPIC > 0 struct mp_intr_map *map; struct ioapic_softc *apic; #endif pci_chipset_tag_t pc = NULL; pcitag_t tag; pcireg_t reg; int bus, dev, func, nfuncs; if (v->type != AML_OBJTYPE_PACKAGE || v->length != 4) { printf("invalid mapping object\n"); return; } addr = aml_val2int(v->v_package[0]); pin = aml_val2int(v->v_package[1]); if (pin > 3) { return; } pp = v->v_package[2]; if (pp->type == AML_OBJTYPE_NAMEREF) { node = aml_searchname(sc->sc_devnode, pp->v_nameref); if (node == NULL) { printf("Invalid device!\n"); return; } pp = node->value; } if (pp->type == AML_OBJTYPE_OBJREF) { pp = pp->v_objref.ref; } if (pp->type == AML_OBJTYPE_DEVICE) { node = pp->node; if (aml_evalname(sc->sc_acpi, node, "_STA", 0, NULL, &res)) printf("no _STA method\n"); sta = aml_val2int(&res) & STA_ENABLED; aml_freevalue(&res); if (sta == 0) return; if (aml_evalname(sc->sc_acpi, node, "_CRS", 0, NULL, &res)) printf("no _CRS method\n"); if (res.type != AML_OBJTYPE_BUFFER || res.length < 6) { printf("invalid _CRS object\n"); aml_freevalue(&res); return; } aml_parse_resource(res.length, res.v_buffer, acpiprt_getirq, &irq); aml_freevalue(&res); } else { irq = aml_val2int(v->v_package[3]); } #ifdef ACPI_DEBUG printf("%s: %s addr 0x%llx pin %d irq %d\n", DEVNAME(sc), aml_nodename(pp->node), addr, pin, irq); #endif #if NIOAPIC > 0 if (nioapics > 0) { apic = ioapic_find_bybase(irq); if (apic == NULL) { printf("%s: no apic found for irq %d\n", DEVNAME(sc), irq); return; } map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT); if (map == NULL) return; memset(map, 0, sizeof *map); map->ioapic = apic; map->ioapic_pin = irq - apic->sc_apic_vecbase; map->bus_pin = ((addr >> 14) & 0x7c) | (pin & 0x3); map->redir = IOAPIC_REDLO_ACTLO | IOAPIC_REDLO_LEVEL; map->redir |= (IOAPIC_REDLO_DEL_LOPRI << IOAPIC_REDLO_DEL_SHIFT); map->ioapic_ih = APIC_INT_VIA_APIC | ((apic->sc_apicid << APIC_INT_APIC_SHIFT) | (map->ioapic_pin << APIC_INT_PIN_SHIFT)); apic->sc_pins[map->ioapic_pin].ip_map = map; map->next = mp_busses[sc->sc_bus].mb_intrs; mp_busses[sc->sc_bus].mb_intrs = map; return; }