2 * libefiboot - library for the manipulation of EFI boot variables
3 * Copyright 2012-2015 Red Hat, Inc.
4 * Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
21 #ifndef _EFIBOOT_LINUX_H
22 #define _EFIBOOT_LINUX_H
24 struct pci_root_info {
25 uint16_t pci_root_domain;
27 uint32_t pci_root_acpi_hid;
28 uint64_t pci_root_acpi_uid;
29 char *pci_root_acpi_uid_str;
65 uint32_t ata_print_id;
77 unsigned int controllernum;
82 uint32_t edd10_devicenum;
84 struct pci_root_info pci_root;
85 struct pci_dev_info pci_dev;
88 struct scsi_info scsi_info;
89 struct sas_info sas_info;
90 struct sata_info sata_info;
91 struct nvme_info nvme_info;
92 efi_guid_t nvdimm_label;
101 bus_type_unknown = 0, /* XXX remove later */
102 interface_type_unknown = 0, /* XXX remove later */
104 ata, atapi, scsi, sata, sas,
105 usb, i1394, fibre, i2o,
113 enum interface_type interface_type;
118 struct dev_probe **probes;
119 unsigned int n_probes;
125 unsigned int controllernum;
126 unsigned int disknum;
130 uint32_t edd10_devicenum;
135 struct pci_root_info pci_root;
136 unsigned int n_pci_devs;
137 struct pci_dev_info *pci_dev;
140 struct scsi_info scsi_info;
141 struct sas_info sas_info;
142 struct sata_info sata_info;
143 struct nvme_info nvme_info;
144 efi_guid_t nvdimm_label;
151 extern int eb_disk_info_from_fd(int fd, struct disk_info *info);
152 extern int HIDDEN set_disk_and_part_name(struct disk_info *info);
153 extern int make_blockdev_path(uint8_t *buf, ssize_t size,
154 struct disk_info *info);
156 extern int eb_nvme_ns_id(int fd, uint32_t *ns_id);
158 extern int HIDDEN get_partition_number(const char *devpath);
160 int UNUSED get_sector_size(int filedes);
162 extern int HIDDEN find_parent_devpath(const char * const child,
165 extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size,
166 const char * const ifname);
168 #define read_sysfs_file(buf, fmt, args...) \
170 uint8_t *buf_ = NULL; \
171 ssize_t bufsize_ = -1; \
174 bufsize_ = get_file(&buf_, "/sys/" fmt, ## args); \
175 if (bufsize_ > 0) { \
176 uint8_t *buf2_ = alloca(bufsize_); \
179 memcpy(buf2_, buf_, bufsize_); \
181 *(buf) = (__typeof__(*(buf)))buf2_; \
187 #define sysfs_readlink(linkbuf, fmt, args...) \
189 char *_lb = alloca(PATH_MAX+1); \
194 _rc = asprintfa(&_pn, "/sys/" fmt, ## args); \
197 _rc = _linksz = readlink(_pn, _lb, PATH_MAX); \
199 _lb[_linksz] = '\0'; \
201 efi_error("readlink of %s failed", _pn);\
204 efi_error("could not allocate memory"); \
209 #define sysfs_stat(statbuf, fmt, args...) \
214 rc_ = asprintfa(&pn_, "/sys/" fmt, ## args); \
216 rc_ = stat(pn_, statbuf); \
218 efi_error("could not stat %s", pn_); \
220 efi_error("could not allocate memory"); \
225 #define sysfs_opendir(fmt, args...) \
231 rc_ = asprintfa(&pn_, "/sys/" fmt, ## args); \
233 dir_ = opendir(pn_); \
235 efi_error("could not open %s", pn_); \
237 efi_error("could not allocate memory"); \
242 #define DEV_PROVIDES_ROOT 1
243 #define DEV_PROVIDES_HD 2
247 enum interface_type *iftypes;
249 ssize_t (*parse)(struct device *dev, const char * const current);
250 ssize_t (*create)(struct device *dev,
251 uint8_t *buf, ssize_t size, ssize_t off);
252 char *(*make_part_name)(struct device *dev);
255 extern ssize_t parse_scsi_link(const char *current, uint32_t *host,
256 uint32_t *bus, uint32_t *device,
257 uint32_t *target, uint64_t *lun);
259 #define set_part(x, y) /* XXX remove later */
261 /* device support implementations */
262 extern struct dev_probe i2o_parser;
263 extern struct dev_probe scsi_parser;
264 extern struct dev_probe ata_parser;
267 #endif /* _EFIBOOT_LINUX_H */