16.10 Device Registration and Template System

<< Click to Display Table of Contents >>

Navigation:  ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 16 – Device Model & DMA >

16.10 Device Registration and Template System

16.10.1 DeviceCatalog

 

DeviceCatalog (mmio_DeviceCatalog.h, ~130 lines) is the template database for all device types. It stores DeviceTemplate instances keyed by template ID (e.g., "qlogic_isp1020"), PCI vendor:device ID, or device class. Built-in templates are registered during initialization via initializeBuiltins(), which populates templates for SCSI controllers, NICs, UARTs, IDE controllers, bridge devices, and class defaults.

 

Lookup methods: getTemplate(key) for template-ID lookup, lookupByPciId(vendorId, deviceId) for PCI enumeration, lookupByPciSubsystemId() for subsystem-specific matching, and lookupByClass(cls) for device-class defaults. Custom templates can be added via addTemplate() for user-configured devices.

 


 

16.10.2 DeviceTemplate

 

DeviceTemplate (mmio_deviceTemplate.h, ~208 lines) is the complete specification for a device type. It contains:

 

Identity and metadata: displayName, vendorName, templateId, mmio_DeviceClass, PCI vendorId/deviceId/revision/classCode

Resource requirements: QVector<BarTemplate> for MMIO windows (base address, size, access attributes), QVector<IrqTemplate> for interrupt lines

DMA capabilities: dmaMask (32-bit or 64-bit addressing), DMA support flags

Defaults: IPL level, MSI support, trigger mode (Edge/Level), routing policy

 

Each IrqTemplate specifies: IPL level, SCB vector index, trigger mode, routing policy (FixedCPU, RoundRobin, LowestIPL), and affinity CPU. This allows device interrupt behavior to be fully declarative — new devices can be added to the catalog without modifying any interrupt delivery code.

 


 

16.10.3 Device Attachment Flow

 

Device attachment during system initialization follows a four-phase sequence: template lookup from DeviceCatalog based on configuration, MMIO region allocation and registration with MMIOManager (assigns PA range, sets access policy per BarTemplate), IRQ vector registration with the coreLib/ IRQ system (assigns vector, IPL, routing policy per IrqTemplate), and device initialize() call with allocated resources (hoseId, basePA, irqVector, ipl).

 

Devices that fail initialization or resource allocation are recorded as degraded via DegradedDeviceEntry — the system boots with reduced functionality rather than aborting. This allows partial device configurations to be tested incrementally.

 

See Also: mmioLib/mmio_DeviceCatalog.h (~130 lines); mmioLib/mmio_deviceTemplate.h (~208 lines); coreLib/mmio_core.h – DegradedDeviceEntry, DegradedDeviceInfo.