asmc: split the sysctl layer into asmcsysctl.c

Moved the dev.asmc.N tree out of asmc.c

No functional change

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D61300
This commit is contained in:
Abdelkader Boudih committed 2026-11-09 18:35:30 +00:00
1 parent 0b545e5a92
commit c714cde179
6 files changed
+1183 -1106

No files matched your search

+1
View File
@@ -119,6 +119,7 @@ dev/apple_bce/apple_bce_vhci.c optional apple_bce pci usb
dev/asmc/asmc.c optional asmc isa
dev/asmc/asmc_debug.c optional asmc isa asmc_debug
dev/asmc/asmc_pio.c optional asmc isa
dev/asmc/asmc_sysctl.c optional asmc isa
dev/asmc/asmcmmio.c optional asmc isa
dev/axgbe/if_axgbe_pci.c optional axp
dev/axgbe/xgbe-desc.c optional axp
+5 -1052
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2026 Abdelkader Boudih <seuros@FreeBSD.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _DEV_ASMC_ASMC_SYSCTL_H_
#define _DEV_ASMC_ASMC_SYSCTL_H_
/*
* Sysctl subtree builders, one per dev.asmc.N node. asmc_attach() calls these
* in registration order; only add_system can fail, and only because the key
* count it reads is what tells the rest of the driver the SMC is there.
*/
void asmc_sysctl_add_fan(device_t dev, struct sysctl_ctx_list *ctx);
void asmc_sysctl_add_temp(device_t dev, struct sysctl_ctx_list *ctx);
void asmc_sysctl_add_light(device_t dev, struct sysctl_ctx_list *ctx);
void asmc_sysctl_add_sms(device_t dev, struct sysctl_ctx_list *ctx);
int asmc_sysctl_add_system(device_t dev, struct sysctl_ctx_list *ctx);
void asmc_sysctl_add_platform(device_t dev, struct sysctl_ctx_list *ctx);
/* Registered by the core's sensor range scan, one OID per detected key. */
int asmc_sensor_sysctl(SYSCTL_HANDLER_ARGS);
#endif /* _DEV_ASMC_ASMC_SYSCTL_H_ */
+4 -53
View File
@@ -248,59 +248,6 @@ struct asmc_softc {
#define ASMC_KEY_RGEN "RGEN" /* RO; 1 byte ui8 */
#define ASMC_RPLT_MAXLEN 8 /* RPlt key data length */
/*
* Shutdown/sleep cause codes (MSSD/MSSP values).
*
* Positive values indicate normal operation; negative values indicate
* fault conditions.
* Sources: Apple SMC firmware, VirtualSMC docs, macOS
* pmset/powermetrics output.
*/
struct asmc_cause {
int8_t code;
const char *desc; /* shutdown description */
const char *sleep_desc; /* sleep description, or NULL if same */
};
#define ASMC_CAUSE_BUFLEN 48 /* "-128 (temperature-overlimit-timeout)\0" */
static const struct asmc_cause asmc_cause_table[] = {
{ 5, "good-shutdown", "good-sleep" },
{ 3, "power-button", NULL },
{ 2, "low-battery-sleep", NULL },
{ 1, "overtemp-sleep", NULL },
{ 0, "initial", NULL },
{ -1, "health-check", NULL },
{ -2, "power-supply", NULL },
{ -3, "temperature-multisleep", NULL },
{ -4, "sensor-fan", NULL },
{ -30, "temperature-overlimit-timeout",NULL },
{ -40, "pswr-smrst", NULL }, /* power supply watchdog reset */
{ -50, "unmapped", NULL },
{ -60, "low-battery", NULL },
{ -61, "ninja-shutdown", NULL }, /* sudden unexpected power loss */
{ -62, "ninja-restart", NULL },
{ -70, "palm-rest-temperature", NULL },
{ -71, "sodimm-temperature", NULL },
{ -72, "heatpipe-temperature", NULL },
{ -74, "battery-temperature", NULL },
{ -75, "adapter-timeout", NULL },
{ -77, "manual-temperature", NULL },
{ -78, "adapter-current", NULL },
{ -79, "battery-current", NULL },
{ -82, "skin-temperature", NULL },
{ -83, "skin-temperature-sensors", NULL },
{ -84, "backup-temperature", NULL },
{ -86, "cpu-proximity-temperature", NULL },
{ -95, "cpu-temperature", NULL },
{ -100, "power-supply-temperature", NULL },
{ -101, "lcd-temperature", NULL },
{ -102, "rsm-power-fail", NULL },
{ -103, "battery-cuv", NULL }, /* cell under-voltage */
{ -127, "pmu-forced-shutdown", NULL },
{ -128, "unknown", NULL },
};
/*
* SMC key transport, implemented in asmc.c on top of the PIO and MMIO
* backends.
@@ -312,3 +259,7 @@ int asmc_key_getinfo(device_t dev, const char *key, uint8_t *len,
char *type);
int asmc_key_dump_by_index(device_t dev, int index, char *key, char *type,
uint8_t *len);
/* Key readers shared with the sysctl layer. */
int asmc_sms_read(device_t dev, const char *key, int16_t *val);
int asmc_sensor_read(device_t dev, const char *key, int *millivalue);
+1 -1
View File
@@ -1,7 +1,7 @@
.PATH: ${SRCTOP}/sys/dev/asmc
KMOD= asmc
SRCS= asmc.c asmc_pio.c asmcmmio.c opt_acpi.h opt_asmc.h
SRCS= asmc.c asmc_pio.c asmc_sysctl.c asmcmmio.c opt_acpi.h opt_asmc.h
SRCS+= acpi_if.h backlight_if.h bus_if.h device_if.h
.if defined(ASMC_DEBUG)