arch/sparc/kernel/ioport.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/ioport.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/ioport.c- Extension
.c- Size
- 8508 bytes
- Lines
- 345
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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
linux/module.hlinux/sched.hlinux/kernel.hlinux/errno.hlinux/types.hlinux/ioport.hlinux/mm.hlinux/slab.hlinux/pci.hlinux/proc_fs.hlinux/seq_file.hlinux/scatterlist.hlinux/dma-map-ops.hlinux/of.hasm/io.hasm/vaddrs.hasm/oplib.hasm/prom.hasm/page.hasm/pgalloc.hasm/dma.hasm/iommu.hasm/io-unit.hasm/leon.h
Detected Declarations
struct xresourcefunction xres_freefunction ioremapfunction of_iounmapfunction _sparc_ioremapfunction _sparc_ioremapfunction sparc_dma_alloc_resourcefunction sparc_dma_free_resourcefunction sbus_set_sbus64function sparc_register_ioportfunction arch_sync_dma_for_cpufunction sparc_io_proc_showfunction register_proc_sparc_ioportexport ioremapexport iounmapexport of_ioremapexport of_iounmapexport sbus_set_sbus64
Annotated Snippet
struct xresource {
struct resource xres; /* Must be first */
int xflag; /* 1 == used */
char xname[XNMLN+1];
};
static struct xresource xresv[XNRES];
static struct xresource *xres_alloc(void) {
struct xresource *xrp;
int n;
xrp = xresv;
for (n = 0; n < XNRES; n++) {
if (xrp->xflag == 0) {
xrp->xflag = 1;
return xrp;
}
xrp++;
}
return NULL;
}
static void xres_free(struct xresource *xrp) {
xrp->xflag = 0;
}
/*
* These are typically used in PCI drivers
* which are trying to be cross-platform.
*
* Bus type is always zero on IIep.
*/
void __iomem *ioremap(phys_addr_t offset, size_t size)
{
char name[14];
sprintf(name, "phys_%08x", (u32)offset);
return _sparc_alloc_io(0, (unsigned long)offset, size, name);
}
EXPORT_SYMBOL(ioremap);
/*
* Complementary to ioremap().
*/
void iounmap(volatile void __iomem *virtual)
{
unsigned long vaddr = (unsigned long) virtual & PAGE_MASK;
struct resource *res;
/*
* XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case.
* This probably warrants some sort of hashing.
*/
if ((res = lookup_resource(&sparc_iomap, vaddr)) == NULL) {
printk("free_io/iounmap: cannot free %lx\n", vaddr);
return;
}
_sparc_free_io(res);
if ((char *)res >= (char*)xresv && (char *)res < (char *)&xresv[XNRES]) {
xres_free((struct xresource *)res);
} else {
kfree(res);
}
}
EXPORT_SYMBOL(iounmap);
void __iomem *of_ioremap(struct resource *res, unsigned long offset,
unsigned long size, char *name)
{
return _sparc_alloc_io(res->flags & 0xF,
res->start + offset,
size, name);
}
EXPORT_SYMBOL(of_ioremap);
void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
{
iounmap(base);
}
EXPORT_SYMBOL(of_iounmap);
/*
* Meat of mapping
*/
static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
unsigned long size, char *name)
{
static int printed_full;
Annotation
- Immediate include surface: `linux/module.h`, `linux/sched.h`, `linux/kernel.h`, `linux/errno.h`, `linux/types.h`, `linux/ioport.h`, `linux/mm.h`, `linux/slab.h`.
- Detected declarations: `struct xresource`, `function xres_free`, `function ioremap`, `function of_iounmap`, `function _sparc_ioremap`, `function _sparc_ioremap`, `function sparc_dma_alloc_resource`, `function sparc_dma_free_resource`, `function sbus_set_sbus64`, `function sparc_register_ioport`.
- Atlas domain: Architecture Layer / arch/sparc.
- 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.