| ... | @@ -87,7 +87,10 @@ pub const DevicePathProtocol = packed struct { | ... | @@ -87,7 +87,10 @@ pub const DevicePathProtocol = packed struct { |
| 87 | }, | 87 | }, |
| 88 | .Acpi => blk: { | 88 | .Acpi => blk: { |
| 89 | const acpi: ?AcpiDevicePath = switch (@intToEnum(AcpiDevicePath.Subtype, self.subtype)) { | 89 | const acpi: ?AcpiDevicePath = switch (@intToEnum(AcpiDevicePath.Subtype, self.subtype)) { |
| 90 | else => null, // TODO | 90 | .Acpi => .{ .Acpi = @ptrCast(*const AcpiDevicePath.BaseAcpiDevicePath, self) }, |
| | 91 | .ExpandedAcpi => .{ .ExpandedAcpi = @ptrCast(*const AcpiDevicePath.ExpandedAcpiDevicePath, self) }, |
| | 92 | .Adr => .{ .Adr = @ptrCast(*const AcpiDevicePath.AdrDevicePath, self) }, |
| | 93 | _ => null, |
| 91 | }; | 94 | }; |
| 92 | break :blk if (acpi) |a| .{ .Acpi = a } else null; | 95 | break :blk if (acpi) |a| .{ .Acpi = a } else null; |
| 93 | }, | 96 | }, |
| ... | @@ -173,58 +176,92 @@ pub const HardwareDevicePath = union(Subtype) { | ... | @@ -173,58 +176,92 @@ pub const HardwareDevicePath = union(Subtype) { |
| 173 | type: DevicePathType, | 176 | type: DevicePathType, |
| 174 | subtype: Subtype, | 177 | subtype: Subtype, |
| 175 | length: u16, | 178 | length: u16, |
| 176 | // TODO | 179 | function: u8, |
| | 180 | device: u8, |
| 177 | }; | 181 | }; |
| 178 | | 182 | |
| 179 | pub const PcCardDevicePath = packed struct { | 183 | pub const PcCardDevicePath = packed struct { |
| 180 | type: DevicePathType, | 184 | type: DevicePathType, |
| 181 | subtype: Subtype, | 185 | subtype: Subtype, |
| 182 | length: u16, | 186 | length: u16, |
| 183 | // TODO | 187 | function_number: u8, |
| 184 | }; | 188 | }; |
| 185 | | 189 | |
| 186 | pub const MemoryMappedDevicePath = packed struct { | 190 | pub const MemoryMappedDevicePath = packed struct { |
| 187 | type: DevicePathType, | 191 | type: DevicePathType, |
| 188 | subtype: Subtype, | 192 | subtype: Subtype, |
| 189 | length: u16, | 193 | length: u16, |
| 190 | // TODO | 194 | memory_type: u32, |
| | 195 | start_address: u64, |
| | 196 | end_address: u64, |
| 191 | }; | 197 | }; |
| 192 | | 198 | |
| 193 | pub const VendorDevicePath = packed struct { | 199 | pub const VendorDevicePath = packed struct { |
| 194 | type: DevicePathType, | 200 | type: DevicePathType, |
| 195 | subtype: Subtype, | 201 | subtype: Subtype, |
| 196 | length: u16, | 202 | length: u16, |
| 197 | // TODO | 203 | vendor_guid: Guid, |
| 198 | }; | 204 | }; |
| 199 | | 205 | |
| 200 | pub const ControllerDevicePath = packed struct { | 206 | pub const ControllerDevicePath = packed struct { |
| 201 | type: DevicePathType, | 207 | type: DevicePathType, |
| 202 | subtype: Subtype, | 208 | subtype: Subtype, |
| 203 | length: u16, | 209 | length: u16, |
| 204 | // TODO | 210 | controller_number: u32, |
| 205 | }; | 211 | }; |
| 206 | | 212 | |
| 207 | pub const BmcDevicePath = packed struct { | 213 | pub const BmcDevicePath = packed struct { |
| 208 | type: DevicePathType, | 214 | type: DevicePathType, |
| 209 | subtype: Subtype, | 215 | subtype: Subtype, |
| 210 | length: u16, | 216 | length: u16, |
| 211 | // TODO | 217 | interface_type: u8, |
| | 218 | base_address: usize, |
| 212 | }; | 219 | }; |
| 213 | }; | 220 | }; |
| 214 | | 221 | |
| 215 | pub const AcpiDevicePath = union(Subtype) { | 222 | pub const AcpiDevicePath = union(Subtype) { |
| 216 | Acpi: void, // TODO | 223 | Acpi: *const BaseAcpiDevicePath, |
| 217 | ExpandedAcpi: void, // TODO | 224 | ExpandedAcpi: *const ExpandedAcpiDevicePath, |
| 218 | Adr: void, // TODO | 225 | Adr: *const AdrDevicePath, |
| 219 | Nvdimm: void, // TODO | | |
| 220 | | 226 | |
| 221 | pub const Subtype = enum(u8) { | 227 | pub const Subtype = enum(u8) { |
| 222 | Acpi = 1, | 228 | Acpi = 1, |
| 223 | ExpandedAcpi = 2, | 229 | ExpandedAcpi = 2, |
| 224 | Adr = 3, | 230 | Adr = 3, |
| 225 | Nvdimm = 4, | | |
| 226 | _, | 231 | _, |
| 227 | }; | 232 | }; |
| | 233 | |
| | 234 | pub const BaseAcpiDevicePath = packed struct { |
| | 235 | type: DevicePathType, |
| | 236 | subtype: Subtype, |
| | 237 | length: u16, |
| | 238 | hid: u32, |
| | 239 | uid: u32, |
| | 240 | }; |
| | 241 | |
| | 242 | pub const ExpandedAcpiDevicePath = packed struct { |
| | 243 | type: DevicePathType, |
| | 244 | subtype: Subtype, |
| | 245 | length: u16, |
| | 246 | hid: u32, |
| | 247 | uid: u32, |
| | 248 | cid: u32, |
| | 249 | // variable length u16[*:0] strings |
| | 250 | // hid_str, uid_str, cid_str |
| | 251 | }; |
| | 252 | |
| | 253 | pub const AdrDevicePath = packed struct { |
| | 254 | type: DevicePathType, |
| | 255 | subtype: Subtype, |
| | 256 | length: u16, |
| | 257 | adr: u32, |
| | 258 | // multiple adr entries can optionally follow |
| | 259 | pub fn adrs(self: *const AdrDevicePath) []const u32 { |
| | 260 | // self.length is a minimum of 8 with one adr which is size 4. |
| | 261 | var entries = (self.length - 4) / @sizeOf(u32); |
| | 262 | return @ptrCast([*]const u32, &self.adr)[0..entries]; |
| | 263 | } |
| | 264 | }; |
| 228 | }; | 265 | }; |
| 229 | | 266 | |
| 230 | pub const MessagingDevicePath = union(Subtype) { | 267 | pub const MessagingDevicePath = union(Subtype) { |