2 * libefivar - library for the manipulation of EFI variables
3 * Copyright 2012-2015 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "fix_coverity.h"
29 format_edd10_guid(char *buf, size_t size, const char *dp_type, const_efidp dp)
32 efidp_edd10 const *edd_dp = (efidp_edd10 *)dp;
33 format(buf, size, off, dp_type, "EDD10(0x%"PRIx32")",
34 edd_dp->hardware_device);
39 _format_hw_dn(char *buf, size_t size, const_efidp dp)
41 efi_guid_t edd10_guid = EDD10_HARDWARE_VENDOR_PATH_GUID;
43 switch (dp->subtype) {
45 format(buf, size, off, "Pci", "Pci(0x%"PRIx32",0x%"PRIx32")",
46 dp->pci.device, dp->pci.function);
49 format(buf, size, off, "PcCard", "PcCard(0x%"PRIx32")",
53 format(buf, size, off, "MemoryMapped",
54 "MemoryMapped(%"PRIu32",0x%"PRIx64",0x%"PRIx64")",
55 dp->mmio.memory_type, dp->mmio.starting_address,
56 dp->mmio.ending_address);
59 if (!efi_guid_cmp(&dp->hw_vendor.vendor_guid, &edd10_guid)) {
60 format_helper(format_edd10_guid, buf, size, off,
63 format_vendor(buf, size, off, "VenHw", dp);
66 case EFIDP_HW_CONTROLLER:
67 format(buf, size, off, "Ctrl", "Ctrl(0x%"PRIx32")",
68 dp->controller.controller);
71 format(buf, size, off, "BMC", "BMC(%d,0x%"PRIx64")",
72 dp->bmc.interface_type, dp->bmc.base_addr);
75 format(buf, size, off, "Hardware",
76 "HardwarePath(%d,", dp->subtype);
77 format_hex(buf, size, off, "Hardware", (uint8_t *)dp+4,
78 efidp_node_size(dp)-4);
79 format(buf, size, off, "Hardware", ")");
86 efidp_make_pci(uint8_t *buf, ssize_t size, uint8_t device, uint8_t function)
88 efidp_pci *pci = (efidp_pci *)buf;
90 ssize_t req = sizeof (*pci);
91 sz = efidp_make_generic(buf, size, EFIDP_HARDWARE_TYPE, EFIDP_HW_PCI,
93 if (size && sz == req) {
95 pci->function = function;
99 efi_error("efidp_make_generic failed");
105 efidp_make_edd10(uint8_t *buf, ssize_t size, uint32_t hardware_device)
107 efi_guid_t edd10_guid = EDD10_HARDWARE_VENDOR_PATH_GUID;
108 efidp_edd10 *edd_dp = (efidp_edd10 *)buf;
110 ssize_t req = sizeof (*edd_dp);
111 sz = efidp_make_generic(buf, size, EFIDP_HARDWARE_TYPE, EFIDP_HW_VENDOR,
113 if (size && sz == req) {
114 memcpy(&edd_dp->vendor_guid, &edd10_guid, sizeof (edd10_guid));
115 edd_dp->hardware_device = hardware_device;
119 efi_error("efidp_make_generic failed");