drivers/misc/xilinx_tmr_inject.c
Source file repositories/reference/linux-study-clean/drivers/misc/xilinx_tmr_inject.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/xilinx_tmr_inject.c- Extension
.c- Size
- 4493 bytes
- Lines
- 173
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
asm/xilinx_mb_manager.hlinux/module.hlinux/of.hlinux/debugfs.hlinux/platform_device.hlinux/fault-inject.h
Detected Declarations
struct xtmr_inject_devfunction xtmr_inject_writefunction xtmr_inject_readfunction xtmr_inject_setfunction xtmr_init_debugfsfunction xtmr_inject_initfunction xtmr_inject_probefunction xtmr_inject_remove
Annotated Snippet
struct xtmr_inject_dev {
void __iomem *regs;
u32 magic;
};
static DECLARE_FAULT_ATTR(inject_fault);
static char *inject_request;
module_param(inject_request, charp, 0);
MODULE_PARM_DESC(inject_request, "default fault injection attributes");
static struct dentry *dbgfs_root;
/* IO accessors */
static inline void xtmr_inject_write(struct xtmr_inject_dev *xtmr_inject,
u32 addr, u32 value)
{
iowrite32(value, xtmr_inject->regs + addr);
}
static inline u32 xtmr_inject_read(struct xtmr_inject_dev *xtmr_inject,
u32 addr)
{
return ioread32(xtmr_inject->regs + addr);
}
static int xtmr_inject_set(void *data, u64 val)
{
if (val != 1)
return -EINVAL;
xmb_inject_err();
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(xtmr_inject_fops, NULL, xtmr_inject_set, "%llu\n");
static void xtmr_init_debugfs(struct xtmr_inject_dev *xtmr_inject)
{
struct dentry *dir;
dbgfs_root = debugfs_create_dir("xtmr_inject", NULL);
dir = fault_create_debugfs_attr("inject_fault", dbgfs_root,
&inject_fault);
debugfs_create_file("inject_fault", 0200, dir, NULL,
&xtmr_inject_fops);
}
static void xtmr_inject_init(struct xtmr_inject_dev *xtmr_inject)
{
u32 cr_val;
if (inject_request)
setup_fault_attr(&inject_fault, inject_request);
/* Allow fault injection */
cr_val = xtmr_inject->magic |
(1 << XTMR_INJECT_CR_IE_SHIFT) |
(1 << XTMR_INJECT_CR_CPUID_SHIFT);
xtmr_inject_write(xtmr_inject, XTMR_INJECT_CR_OFFSET,
cr_val);
/* Initialize the address inject and instruction inject registers */
xtmr_inject_write(xtmr_inject, XTMR_INJECT_AIR_OFFSET,
XMB_INJECT_ERR_OFFSET);
xtmr_inject_write(xtmr_inject, XTMR_INJECT_IIR_OFFSET,
XMB_INJECT_ERR_OFFSET & XTMR_INJECT_IIR_ADDR_MASK);
}
/**
* xtmr_inject_probe - Driver probe function
* @pdev: Pointer to the platform_device structure
*
* This is the driver probe routine. It does all the memory
* allocation for the device.
*
* Return: 0 on success and failure value on error
*/
static int xtmr_inject_probe(struct platform_device *pdev)
{
struct xtmr_inject_dev *xtmr_inject;
int err;
xtmr_inject = devm_kzalloc(&pdev->dev, sizeof(*xtmr_inject),
GFP_KERNEL);
if (!xtmr_inject)
return -ENOMEM;
xtmr_inject->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(xtmr_inject->regs))
return PTR_ERR(xtmr_inject->regs);
err = of_property_read_u32(pdev->dev.of_node, "xlnx,magic",
&xtmr_inject->magic);
if (err < 0) {
Annotation
- Immediate include surface: `asm/xilinx_mb_manager.h`, `linux/module.h`, `linux/of.h`, `linux/debugfs.h`, `linux/platform_device.h`, `linux/fault-inject.h`.
- Detected declarations: `struct xtmr_inject_dev`, `function xtmr_inject_write`, `function xtmr_inject_read`, `function xtmr_inject_set`, `function xtmr_init_debugfs`, `function xtmr_inject_init`, `function xtmr_inject_probe`, `function xtmr_inject_remove`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: source 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.