authorgravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-13 15:44:29-05:00
committergravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-13 15:47:14-05:00
logae084c5f59b0436a8fcb1b924008a16d90a9fe86
tree904fef98b4a3aeab9ec80acf372fe83840f110a9
parent322757c4e13acbe866e6b3431cd3b6b8ce68efb7

std/os/uefi: Complete AcpiDevicePath and HardwareDevicePaths


1 files changed, 49 insertions(+), 12 deletions(-)

lib/std/os/uefi/protocols/device_path_protocol.zig+49-12
......@@ -87,7 +87,10 @@ pub const DevicePathProtocol = packed struct {
8787 },
8888 .Acpi => blk: {
8989 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,
9194 };
9295 break :blk if (acpi) |a| .{ .Acpi = a } else null;
9396 },
......@@ -173,58 +176,92 @@ pub const HardwareDevicePath = union(Subtype) {
173176 type: DevicePathType,
174177 subtype: Subtype,
175178 length: u16,
176 // TODO
179 function: u8,
180 device: u8,
177181 };
178182
179183 pub const PcCardDevicePath = packed struct {
180184 type: DevicePathType,
181185 subtype: Subtype,
182186 length: u16,
183 // TODO
187 function_number: u8,
184188 };
185189
186190 pub const MemoryMappedDevicePath = packed struct {
187191 type: DevicePathType,
188192 subtype: Subtype,
189193 length: u16,
190 // TODO
194 memory_type: u32,
195 start_address: u64,
196 end_address: u64,
191197 };
192198
193199 pub const VendorDevicePath = packed struct {
194200 type: DevicePathType,
195201 subtype: Subtype,
196202 length: u16,
197 // TODO
203 vendor_guid: Guid,
198204 };
199205
200206 pub const ControllerDevicePath = packed struct {
201207 type: DevicePathType,
202208 subtype: Subtype,
203209 length: u16,
204 // TODO
210 controller_number: u32,
205211 };
206212
207213 pub const BmcDevicePath = packed struct {
208214 type: DevicePathType,
209215 subtype: Subtype,
210216 length: u16,
211 // TODO
217 interface_type: u8,
218 base_address: usize,
212219 };
213220};
214221
215222pub const AcpiDevicePath = union(Subtype) {
216 Acpi: void, // TODO
217 ExpandedAcpi: void, // TODO
218 Adr: void, // TODO
219 Nvdimm: void, // TODO
223 Acpi: *const BaseAcpiDevicePath,
224 ExpandedAcpi: *const ExpandedAcpiDevicePath,
225 Adr: *const AdrDevicePath,
220226
221227 pub const Subtype = enum(u8) {
222228 Acpi = 1,
223229 ExpandedAcpi = 2,
224230 Adr = 3,
225 Nvdimm = 4,
226231 _,
227232 };
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 };
228265};
229266
230267pub const MessagingDevicePath = union(Subtype) {