void acpiec_sci_event(struct acpiec_softc *sc) { u_int8_t evt; sc->sc_gotsci = 0; acpiec_wait(sc, EC_STAT_IBF, 0); bus_space_write_1(sc->sc_cmd_bt, sc->sc_cmd_bh, 0, EC_CMD_QR); acpiec_wait(sc, EC_STAT_OBF, EC_STAT_OBF); evt = bus_space_read_1(sc->sc_data_bt, sc->sc_data_bh, 0); if (evt) { dnprintf(10, "%s: sci_event: 0x%02x\n", DEVNAME(sc), (int)evt); aml_evalnode(sc->sc_acpi, sc->sc_events[evt].event, 0, NULL, NULL); } }
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); }
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 aibs_getpack(struct aibs_softc *sc, struct aml_node *n, int64_t i, struct aml_value *res) { struct aml_value req; req.type = AML_OBJTYPE_INTEGER; req.v_integer = i; if (aml_evalnode(sc->sc_acpi, n, 1, &req, res)) { dprintf("%s: %s: %lld: evaluation failed\n", DEVNAME(sc), n->name, i); aml_freevalue(res); return (-1); } if (res->type != AML_OBJTYPE_PACKAGE) { dprintf("%s: %s: %lld: not a package: type %i\n", DEVNAME(sc), n->name, i, res->type); aml_freevalue(res); return (-1); } return (0); }
void acpicpu_attach(struct device *parent, struct device *self, void *aux) { struct acpicpu_softc *sc = (struct acpicpu_softc *)self; struct acpi_attach_args *aa = aux; struct aml_value res; int i; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node; SLIST_INIT(&sc->sc_cstates); sc->sc_pss = NULL; printf(": %s: ", sc->sc_devnode->name); if (aml_evalnode(sc->sc_acpi, sc->sc_devnode, 0, NULL, &res) == 0) { if (res.type == AML_OBJTYPE_PROCESSOR) { sc->sc_cpu = res.v_processor.proc_id; sc->sc_pblk_addr = res.v_processor.proc_addr; sc->sc_pblk_len = res.v_processor.proc_len; } aml_freevalue(&res); } sc->sc_duty_off = sc->sc_acpi->sc_fadt->duty_offset; sc->sc_duty_wid = sc->sc_acpi->sc_fadt->duty_width; if (!valid_throttle(sc->sc_duty_off, sc->sc_duty_wid, sc->sc_pblk_addr)) sc->sc_flags |= FLAGS_NOTHROTTLE; #ifdef ACPI_DEBUG printf(": %s: ", sc->sc_devnode->name); printf("\n: hdr:%x pblk:%x,%x duty:%x,%x pstate:%x (%d throttling states)\n", sc->sc_acpi->sc_fadt->hdr_revision, sc->sc_pblk_addr, sc->sc_pblk_len, sc->sc_duty_off, sc->sc_duty_wid, sc->sc_acpi->sc_fadt->pstate_cnt, CPU_MAXSTATE(sc)); #endif /* Get C-States from _CST or FADT */ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_CST", 0, NULL, &res) == 0) { aml_foreachpkg(&res, 1, acpicpu_add_cstatepkg, sc); aml_freevalue(&res); } else { /* Some systems don't export a full PBLK, reduce functionality */ if (sc->sc_pblk_len < 5) sc->sc_flags |= FLAGS_NO_C2; if (sc->sc_pblk_len < 6) sc->sc_flags |= FLAGS_NO_C3; acpicpu_add_cstate(sc, ACPI_STATE_C2, sc->sc_acpi->sc_fadt->p_lvl2_lat, -1, sc->sc_pblk_addr + 4); acpicpu_add_cstate(sc, ACPI_STATE_C3, sc->sc_acpi->sc_fadt->p_lvl3_lat, -1, sc->sc_pblk_addr + 5); } if (acpicpu_getpss(sc)) { /* XXX not the right test but has to do for now */ sc->sc_flags |= FLAGS_NOPSS; goto nopss; } #ifdef ACPI_DEBUG for (i = 0; i < sc->sc_pss_len; i++) { dnprintf(20, "%d %d %d %d %d %d\n", sc->sc_pss[i].pss_core_freq, sc->sc_pss[i].pss_power, sc->sc_pss[i].pss_trans_latency, sc->sc_pss[i].pss_bus_latency, sc->sc_pss[i].pss_ctrl, sc->sc_pss[i].pss_status); } dnprintf(20, "\n"); #endif /* XXX this needs to be moved to probe routine */ if (acpicpu_getpct(sc)) return; /* Notify BIOS we are handing p-states */ if (sc->sc_acpi->sc_fadt->pstate_cnt) acpi_write_pmreg(sc->sc_acpi, ACPIREG_SMICMD, 0, sc->sc_acpi->sc_fadt->pstate_cnt); for (i = 0; i < sc->sc_pss_len; i++) printf("%d%s", sc->sc_pss[i].pss_core_freq, i < sc->sc_pss_len - 1 ? ", " : " MHz\n"); aml_register_notify(sc->sc_devnode, NULL, acpicpu_notify, sc, ACPIDEV_NOPOLL); if (setperf_prio < 30) { cpu_setperf = acpicpu_setperf; setperf_prio = 30; acpi_hasprocfvs = 1; } acpicpu_sc[sc->sc_dev.dv_unit] = sc; return; nopss: if (sc->sc_flags & FLAGS_NOTHROTTLE) printf("no performance/throttling supported\n"); }
int aibs_getvalue(struct aibs_softc *sc, int64_t i, int64_t *v) { struct aml_node *n = sc->sc_gitmnode; struct aml_value req, res; struct aibs_cmd_buffer cmd; struct aibs_ret_buffer ret; enum aml_objecttype type; if (sc->sc_mode) { cmd.id = i; cmd.param1 = 0; cmd.param2 = 0; type = req.type = AML_OBJTYPE_BUFFER; req.v_buffer = (uint8_t *)&cmd; req.length = sizeof(cmd); } else { switch (ATK_TYPE(i)) { case ATK_TYPE_TEMP: n = sc->sc_rtmpnode; break; case ATK_TYPE_FAN: n = sc->sc_rfannode; break; case ATK_TYPE_VOLT: n = sc->sc_rvltnode; break; default: return (-1); } type = req.type = AML_OBJTYPE_INTEGER; req.v_integer = i; } if (aml_evalnode(sc->sc_acpi, n, 1, &req, &res)) { dprintf("%s: %s: %lld: evaluation failed\n", DEVNAME(sc), n->name, i); aml_freevalue(&res); return (-1); } if (res.type != type) { dprintf("%s: %s: %lld: not an integer: type %i\n", DEVNAME(sc), n->name, i, res.type); aml_freevalue(&res); return (-1); } if (sc->sc_mode) { if (res.length < sizeof(ret)) { dprintf("%s: %s: %lld: result buffer too small\n", DEVNAME(sc), n->name, i); aml_freevalue(&res); return (-1); } memcpy(&ret, res.v_buffer, sizeof(ret)); if (ret.flags == 0) { dprintf("%s: %s: %lld: bad flags in result\n", DEVNAME(sc), n->name, i); aml_freevalue(&res); return (-1); } *v = ret.value; } else { *v = res.v_integer; } aml_freevalue(&res); return (0); }