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 {...@@ -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, // TODO90 .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 // TODO179 function: u8,
180 device: u8,
177 };181 };
178182
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 // TODO187 function_number: u8,
184 };188 };
185189
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 // TODO194 memory_type: u32,
195 start_address: u64,
196 end_address: u64,
191 };197 };
192198
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 // TODO203 vendor_guid: Guid,
198 };204 };
199205
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 // TODO210 controller_number: u32,
205 };211 };
206212
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 // TODO217 interface_type: u8,
218 base_address: usize,
212 };219 };
213};220};
214221
215pub const AcpiDevicePath = union(Subtype) {222pub const AcpiDevicePath = union(Subtype) {
216 Acpi: void, // TODO223 Acpi: *const BaseAcpiDevicePath,
217 ExpandedAcpi: void, // TODO224 ExpandedAcpi: *const ExpandedAcpiDevicePath,
218 Adr: void, // TODO225 Adr: *const AdrDevicePath,
219 Nvdimm: void, // TODO
220226
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};
229266
230pub const MessagingDevicePath = union(Subtype) {267pub const MessagingDevicePath = union(Subtype) {