diff --git a/src/hulk/pci.d b/src/hulk/pci.d index 141661d..80fb184 100644 --- a/src/hulk/pci.d +++ b/src/hulk/pci.d @@ -29,14 +29,36 @@ struct Pci */ struct Address { - /** Bus number (0-255). */ - ubyte bus_nr; + uint address; - /** Device number (0-31). */ - ubyte device_nr; + this(ubyte bus_nr, ubyte device_nr, ubyte function_nr) + { + this.address = (bus_nr << 16u) | (device_nr << 8u) | function_nr; + } - /** Function number (0-7). */ - ubyte function_nr; + /** + * Bus number (0-255). + */ + public @property ubyte bus_nr() const + { + return cast(ubyte)(address >> 16u); + } + + /** + * Device number (0-31). + */ + public @property ubyte device_nr() const + { + return cast(ubyte)(address >> 8u); + } + + /** + * Function number (0-7). + */ + public @property ubyte function_nr() const + { + return cast(ubyte)address; + } } /** @@ -44,14 +66,36 @@ struct Pci */ struct Type { - /** Class ID. */ - ubyte class_id; + uint type; - /** Subclass ID. */ - ubyte subclass_id; + this(ubyte class_id, ubyte subclass_id, ubyte interface_id) + { + this.type = (class_id << 16u) | (subclass_id << 8u) | interface_id; + } - /** Interface ID. */ - ubyte interface_id; + /** + * Class ID. + */ + public @property ubyte class_id() const + { + return cast(ubyte)(type >> 16u); + } + + /** + * Subclass ID. + */ + public @property ubyte subclass_id() const + { + return cast(ubyte)(type >> 8u); + } + + /** + * Interface ID. + */ + public @property ubyte interface_id() const + { + return cast(ubyte)type; + } } /** @@ -69,9 +113,7 @@ struct Pci { this.config = config; this.address = address; - type.class_id = config.class_id; - type.subclass_id = config.subclass_id; - type.interface_id = config.interface_id; + type = Type(config.class_id, config.subclass_id, config.interface_id); Klog.writefln("Found PCI device %04x:%04x (%02x:%02x:%02x) at %02u:%02u.%u", config.vendor_id, config.device_id, type.class_id, type.subclass_id, type.interface_id,