acpi/pstate: Add binary form for available CPU power domain frequencies
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 27 Jun 2015 04:13:20 +0000 (12:13 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 27 Jun 2015 12:13:32 +0000 (20:13 +0800)
sys/dev/acpica/acpi_cpu_pstate.c

index a819d90..844031b 100644 (file)
@@ -144,6 +144,7 @@ static void acpi_pst_set_pstate_handler(netmsg_t);
 static void    acpi_pst_get_pstate_handler(netmsg_t);
 
 static int     acpi_pst_sysctl_freqs(SYSCTL_HANDLER_ARGS);
+static int     acpi_pst_sysctl_freqs_bin(SYSCTL_HANDLER_ARGS);
 static int     acpi_pst_sysctl_members(SYSCTL_HANDLER_ARGS);
 static int     acpi_pst_sysctl_select(SYSCTL_HANDLER_ARGS);
 static int     acpi_pst_sysctl_global(SYSCTL_HANDLER_ARGS);
@@ -1021,6 +1022,13 @@ acpi_pst_postattach(void *arg __unused)
                                dom, 0, acpi_pst_sysctl_freqs, "A",
                                "available frequencies");
 
+               SYSCTL_ADD_PROC(&dom->pd_sysctl_ctx,
+                               SYSCTL_CHILDREN(dom->pd_sysctl_tree),
+                               OID_AUTO, "available_bin",
+                               CTLTYPE_OPAQUE | CTLFLAG_RD,
+                               dom, 0, acpi_pst_sysctl_freqs_bin, "IU",
+                               "available frequencies (binary format)");
+
                SYSCTL_ADD_PROC(&dom->pd_sysctl_ctx,
                                SYSCTL_CHILDREN(dom->pd_sysctl_tree),
                                OID_AUTO, "members",
@@ -1082,6 +1090,20 @@ acpi_pst_sysctl_freqs(SYSCTL_HANDLER_ARGS)
        return error;
 }
 
+static int
+acpi_pst_sysctl_freqs_bin(SYSCTL_HANDLER_ARGS)
+{
+       struct acpi_pst_domain *dom = arg1;
+       uint32_t freqs[ACPI_NPSTATE_MAX];
+       int cnt, i;
+
+       cnt = acpi_npstates - dom->pd_sstart;
+       for (i = 0; i < cnt; ++i)
+               freqs[i] = acpi_pstates[dom->pd_sstart + i].st_freq;
+
+       return sysctl_handle_opaque(oidp, freqs, cnt * sizeof(freqs[0]), req);
+}
+
 static int
 acpi_pst_sysctl_members(SYSCTL_HANDLER_ARGS)
 {