| ... | @@ -15,6 +15,25 @@ pub const DevicePathProtocol = packed struct { | ... | @@ -15,6 +15,25 @@ pub const DevicePathProtocol = packed struct { |
| 15 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, | 15 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, |
| 16 | }; | 16 | }; |
| 17 | | 17 | |
| | 18 | /// Returns the next DevicePathProtocol node in the sequence, if any. |
| | 19 | pub fn next(self: *DevicePathProtocol) ?*DevicePathProtocol { |
| | 20 | if (self.type == .End and @intToEnum(EndDevicePath.Subtype, self.subtype) == .EndEntire) |
| | 21 | return null; |
| | 22 | |
| | 23 | return @ptrCast(*DevicePathProtocol, @ptrCast([*]u8, self) + self.length); |
| | 24 | } |
| | 25 | |
| | 26 | /// Calculates the total length of the device path structure in bytes, including the end of device path node. |
| | 27 | pub fn size(self: *DevicePathProtocol) usize { |
| | 28 | var node = self; |
| | 29 | |
| | 30 | while (node.next()) |next_node| { |
| | 31 | node = next_node; |
| | 32 | } |
| | 33 | |
| | 34 | return (@ptrToInt(node) + node.length) - @ptrToInt(self); |
| | 35 | } |
| | 36 | |
| 18 | pub fn getDevicePath(self: *const DevicePathProtocol) ?DevicePath { | 37 | pub fn getDevicePath(self: *const DevicePathProtocol) ?DevicePath { |
| 19 | return switch (self.type) { | 38 | return switch (self.type) { |
| 20 | .Hardware => blk: { | 39 | .Hardware => blk: { |