drivers/soc/apple/rtkit.c
Source file repositories/reference/linux-study-clean/drivers/soc/apple/rtkit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/apple/rtkit.c- Extension
.c- Size
- 25157 bytes
- Lines
- 980
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
rtkit-internal.h
Detected Declarations
struct apple_rtkit_rx_workfunction apple_rtkit_is_runningfunction apple_rtkit_is_crashedfunction apple_rtkit_management_sendfunction apple_rtkit_management_rx_hellofunction apple_rtkit_management_rx_epmapfunction for_each_set_bitfunction for_each_set_bitfunction apple_rtkit_management_rx_iop_pwr_ackfunction apple_rtkit_management_rx_ap_pwr_ackfunction apple_rtkit_management_rxfunction apple_rtkit_common_rx_get_bufferfunction apple_rtkit_free_bufferfunction apple_rtkit_memcpyfunction apple_rtkit_crashlog_rxfunction apple_rtkit_ioreport_rxfunction apple_rtkit_syslog_rx_initfunction should_crop_syslog_charfunction apple_rtkit_syslog_rx_logfunction apple_rtkit_syslog_rxfunction apple_rtkit_oslog_rxfunction apple_rtkit_rx_workfunction apple_rtkit_rxfunction apple_rtkit_send_messagefunction apple_rtkit_pollfunction apple_rtkit_start_epfunction apple_rtkit_wait_for_completionfunction apple_rtkit_reinitfunction apple_rtkit_set_ap_power_statefunction apple_rtkit_set_iop_power_statefunction apple_rtkit_bootfunction apple_rtkit_shutdownfunction apple_rtkit_powerofffunction apple_rtkit_idlefunction apple_rtkit_quiescefunction apple_rtkit_wakefunction apple_rtkit_freefunction apple_rtkit_free_wrapperexport apple_rtkit_is_runningexport apple_rtkit_is_crashedexport apple_rtkit_send_messageexport apple_rtkit_pollexport apple_rtkit_start_epexport apple_rtkit_initexport apple_rtkit_reinitexport apple_rtkit_bootexport apple_rtkit_shutdownexport apple_rtkit_poweroff
Annotated Snippet
struct apple_rtkit_rx_work {
struct apple_rtkit *rtk;
u8 ep;
u64 msg;
struct work_struct work;
};
bool apple_rtkit_is_running(struct apple_rtkit *rtk)
{
if (rtk->crashed)
return false;
if ((rtk->iop_power_state & 0xff) != APPLE_RTKIT_PWR_STATE_ON)
return false;
if ((rtk->ap_power_state & 0xff) != APPLE_RTKIT_PWR_STATE_ON)
return false;
return true;
}
EXPORT_SYMBOL_GPL(apple_rtkit_is_running);
bool apple_rtkit_is_crashed(struct apple_rtkit *rtk)
{
return rtk->crashed;
}
EXPORT_SYMBOL_GPL(apple_rtkit_is_crashed);
static int apple_rtkit_management_send(struct apple_rtkit *rtk, u8 type,
u64 msg)
{
int ret;
msg &= ~APPLE_RTKIT_MGMT_TYPE;
msg |= FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, type);
ret = apple_rtkit_send_message(rtk, APPLE_RTKIT_EP_MGMT, msg, NULL, false);
if (ret)
dev_err(rtk->dev, "RTKit: Failed to send management message: %d\n", ret);
return ret;
}
static void apple_rtkit_management_rx_hello(struct apple_rtkit *rtk, u64 msg)
{
u64 reply;
int min_ver = FIELD_GET(APPLE_RTKIT_MGMT_HELLO_MINVER, msg);
int max_ver = FIELD_GET(APPLE_RTKIT_MGMT_HELLO_MAXVER, msg);
int want_ver = min(APPLE_RTKIT_MAX_SUPPORTED_VERSION, max_ver);
dev_dbg(rtk->dev, "RTKit: Min ver %d, max ver %d\n", min_ver, max_ver);
if (min_ver > APPLE_RTKIT_MAX_SUPPORTED_VERSION) {
dev_err(rtk->dev, "RTKit: Firmware min version %d is too new\n",
min_ver);
goto abort_boot;
}
if (max_ver < APPLE_RTKIT_MIN_SUPPORTED_VERSION) {
dev_err(rtk->dev, "RTKit: Firmware max version %d is too old\n",
max_ver);
goto abort_boot;
}
dev_info(rtk->dev, "RTKit: Initializing (protocol version %d)\n",
want_ver);
rtk->version = want_ver;
reply = FIELD_PREP(APPLE_RTKIT_MGMT_HELLO_MINVER, want_ver);
reply |= FIELD_PREP(APPLE_RTKIT_MGMT_HELLO_MAXVER, want_ver);
apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_HELLO_REPLY, reply);
return;
abort_boot:
rtk->boot_result = -EINVAL;
complete_all(&rtk->epmap_completion);
}
static void apple_rtkit_management_rx_epmap(struct apple_rtkit *rtk, u64 msg)
{
int i, ep;
u64 reply;
unsigned long bitmap = FIELD_GET(APPLE_RTKIT_MGMT_EPMAP_BITMAP, msg);
u32 base = FIELD_GET(APPLE_RTKIT_MGMT_EPMAP_BASE, msg);
dev_dbg(rtk->dev,
"RTKit: received endpoint bitmap 0x%lx with base 0x%x\n",
bitmap, base);
for_each_set_bit(i, &bitmap, 32) {
ep = 32 * base + i;
Annotation
- Immediate include surface: `rtkit-internal.h`.
- Detected declarations: `struct apple_rtkit_rx_work`, `function apple_rtkit_is_running`, `function apple_rtkit_is_crashed`, `function apple_rtkit_management_send`, `function apple_rtkit_management_rx_hello`, `function apple_rtkit_management_rx_epmap`, `function for_each_set_bit`, `function for_each_set_bit`, `function apple_rtkit_management_rx_iop_pwr_ack`, `function apple_rtkit_management_rx_ap_pwr_ack`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.