arch/sparc/kernel/vio.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/vio.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/vio.c- Extension
.c- Size
- 13315 bytes
- Lines
- 574
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/kernel.hlinux/slab.hlinux/string.hlinux/irq.hlinux/export.hlinux/init.hasm/mdesc.hasm/vio.h
Detected Declarations
struct vio_remove_node_datafunction Copyrightfunction vio_hotplugfunction vio_bus_matchfunction vio_device_probefunction vio_device_removefunction devspec_showfunction type_showfunction modalias_showfunction __vio_register_driverfunction vio_unregister_driverfunction vio_dev_releasefunction show_pciobppath_attrfunction mdesc_for_each_arcfunction vio_vdev_nodefunction vio_fill_channel_infofunction vio_set_intrfunction for_each_child_of_nodefunction vio_addfunction vio_md_node_matchfunction vio_removefunction vio_add_dsfunction vio_initexport __vio_register_driverexport vio_unregister_driverexport vio_vdev_nodeexport vio_set_intr
Annotated Snippet
static int vio_bus_match(struct device *dev, const struct device_driver *drv)
{
struct vio_dev *vio_dev = to_vio_dev(dev);
const struct vio_driver *vio_drv = to_vio_driver(drv);
const struct vio_device_id *matches = vio_drv->id_table;
if (!matches)
return 0;
return vio_match_device(matches, vio_dev) != NULL;
}
static int vio_device_probe(struct device *dev)
{
struct vio_dev *vdev = to_vio_dev(dev);
struct vio_driver *drv = to_vio_driver(dev->driver);
const struct vio_device_id *id;
if (!drv->probe)
return -ENODEV;
id = vio_match_device(drv->id_table, vdev);
if (!id)
return -ENODEV;
/* alloc irqs (unless the driver specified not to) */
if (!drv->no_irq) {
if (vdev->tx_irq == 0 && vdev->tx_ino != ~0UL)
vdev->tx_irq = sun4v_build_virq(vdev->cdev_handle,
vdev->tx_ino);
if (vdev->rx_irq == 0 && vdev->rx_ino != ~0UL)
vdev->rx_irq = sun4v_build_virq(vdev->cdev_handle,
vdev->rx_ino);
}
return drv->probe(vdev, id);
}
static void vio_device_remove(struct device *dev)
{
struct vio_dev *vdev = to_vio_dev(dev);
struct vio_driver *drv = to_vio_driver(dev->driver);
if (drv->remove) {
/*
* Ideally, we would remove/deallocate tx/rx virqs
* here - however, there are currently no support
* routines to do so at the moment. TBD
*/
drv->remove(vdev);
}
}
static ssize_t devspec_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct vio_dev *vdev = to_vio_dev(dev);
const char *str = "none";
if (!strcmp(vdev->type, "vnet-port"))
str = "vnet";
else if (!strcmp(vdev->type, "vdc-port"))
str = "vdisk";
return sprintf(buf, "%s\n", str);
}
static DEVICE_ATTR_RO(devspec);
static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct vio_dev *vdev = to_vio_dev(dev);
return sprintf(buf, "%s\n", vdev->type);
}
static DEVICE_ATTR_RO(type);
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
const struct vio_dev *vdev = to_vio_dev(dev);
return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
}
static DEVICE_ATTR_RO(modalias);
static struct attribute *vio_dev_attrs[] = {
&dev_attr_devspec.attr,
&dev_attr_type.attr,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/string.h`, `linux/irq.h`, `linux/export.h`, `linux/init.h`, `asm/mdesc.h`, `asm/vio.h`.
- Detected declarations: `struct vio_remove_node_data`, `function Copyright`, `function vio_hotplug`, `function vio_bus_match`, `function vio_device_probe`, `function vio_device_remove`, `function devspec_show`, `function type_show`, `function modalias_show`, `function __vio_register_driver`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: pattern 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.