drivers/soc/apple/sart.c
Source file repositories/reference/linux-study-clean/drivers/soc/apple/sart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/apple/sart.c- Extension
.c- Size
- 10212 bytes
- Lines
- 379
- 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.
- 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
linux/soc/apple/sart.hlinux/atomic.hlinux/bits.hlinux/bitfield.hlinux/device.hlinux/io.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/types.h
Detected Declarations
struct apple_sart_opsstruct apple_sartfunction sart0_get_entryfunction sart0_set_entryfunction sart2_get_entryfunction sart2_set_entryfunction sart3_get_entryfunction sart3_set_entryfunction apple_sart_probefunction sart_set_entryfunction apple_sart_add_allowed_regionfunction apple_sart_remove_allowed_regionfunction apple_sart_shutdownexport devm_apple_sart_getexport apple_sart_add_allowed_regionexport apple_sart_remove_allowed_region
Annotated Snippet
struct apple_sart_ops {
void (*get_entry)(struct apple_sart *sart, int index, u8 *flags,
phys_addr_t *paddr, size_t *size);
void (*set_entry)(struct apple_sart *sart, int index, u8 flags,
phys_addr_t paddr_shifted, size_t size_shifted);
/* This is probably a bitfield but the exact meaning of each bit is unknown. */
unsigned int flags_allow;
unsigned int size_shift;
unsigned int paddr_shift;
size_t size_max;
};
struct apple_sart {
struct device *dev;
void __iomem *regs;
const struct apple_sart_ops *ops;
unsigned long protected_entries;
unsigned long used_entries;
};
static void sart0_get_entry(struct apple_sart *sart, int index, u8 *flags,
phys_addr_t *paddr, size_t *size)
{
u32 cfg = readl(sart->regs + APPLE_SART0_CONFIG(index));
phys_addr_t paddr_ = readl(sart->regs + APPLE_SART0_PADDR(index));
size_t size_ = FIELD_GET(APPLE_SART0_CONFIG_SIZE, cfg);
*flags = FIELD_GET(APPLE_SART0_CONFIG_FLAGS, cfg);
*size = size_ << APPLE_SART0_CONFIG_SIZE_SHIFT;
*paddr = paddr_ << APPLE_SART0_PADDR_SHIFT;
}
static void sart0_set_entry(struct apple_sart *sart, int index, u8 flags,
phys_addr_t paddr_shifted, size_t size_shifted)
{
u32 cfg;
cfg = FIELD_PREP(APPLE_SART0_CONFIG_FLAGS, flags);
cfg |= FIELD_PREP(APPLE_SART0_CONFIG_SIZE, size_shifted);
writel(paddr_shifted, sart->regs + APPLE_SART0_PADDR(index));
writel(cfg, sart->regs + APPLE_SART0_CONFIG(index));
}
static struct apple_sart_ops sart_ops_v0 = {
.get_entry = sart0_get_entry,
.set_entry = sart0_set_entry,
.flags_allow = APPLE_SART0_FLAGS_ALLOW,
.size_shift = APPLE_SART0_CONFIG_SIZE_SHIFT,
.paddr_shift = APPLE_SART0_PADDR_SHIFT,
.size_max = APPLE_SART0_CONFIG_SIZE_MAX,
};
static void sart2_get_entry(struct apple_sart *sart, int index, u8 *flags,
phys_addr_t *paddr, size_t *size)
{
u32 cfg = readl(sart->regs + APPLE_SART2_CONFIG(index));
phys_addr_t paddr_ = readl(sart->regs + APPLE_SART2_PADDR(index));
size_t size_ = FIELD_GET(APPLE_SART2_CONFIG_SIZE, cfg);
*flags = FIELD_GET(APPLE_SART2_CONFIG_FLAGS, cfg);
*size = size_ << APPLE_SART2_CONFIG_SIZE_SHIFT;
*paddr = paddr_ << APPLE_SART2_PADDR_SHIFT;
}
static void sart2_set_entry(struct apple_sart *sart, int index, u8 flags,
phys_addr_t paddr_shifted, size_t size_shifted)
{
u32 cfg;
cfg = FIELD_PREP(APPLE_SART2_CONFIG_FLAGS, flags);
cfg |= FIELD_PREP(APPLE_SART2_CONFIG_SIZE, size_shifted);
writel(paddr_shifted, sart->regs + APPLE_SART2_PADDR(index));
writel(cfg, sart->regs + APPLE_SART2_CONFIG(index));
}
static struct apple_sart_ops sart_ops_v2 = {
.get_entry = sart2_get_entry,
.set_entry = sart2_set_entry,
.flags_allow = APPLE_SART2_FLAGS_ALLOW,
.size_shift = APPLE_SART2_CONFIG_SIZE_SHIFT,
.paddr_shift = APPLE_SART2_PADDR_SHIFT,
.size_max = APPLE_SART2_CONFIG_SIZE_MAX,
};
static void sart3_get_entry(struct apple_sart *sart, int index, u8 *flags,
phys_addr_t *paddr, size_t *size)
Annotation
- Immediate include surface: `linux/soc/apple/sart.h`, `linux/atomic.h`, `linux/bits.h`, `linux/bitfield.h`, `linux/device.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct apple_sart_ops`, `struct apple_sart`, `function sart0_get_entry`, `function sart0_set_entry`, `function sart2_get_entry`, `function sart2_set_entry`, `function sart3_get_entry`, `function sart3_set_entry`, `function apple_sart_probe`, `function sart_set_entry`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration implementation candidate.
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.