/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _LIBUEFI_RT_PATH_IMPL_H_
#define _LIBUEFI_RT_PATH_IMPL_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Private definitions for UEFI run time path library interfaces.
*/
/*
* uefi_device_path_t type definitions
*/
#define UEFI_HARDWARE_PATH 0x01
#define UEFI_ACPI_PATH 0x02
#define UEFI_MESSAGE_PATH 0x03
#define UEFI_MEDIA_PATH 0x04
#define UEFI_BIOS_PATH 0x05
#define UEFI_END_PATH 0x7f
/*
* subtypes
*/
#define UEFI_PCI 1
#define UEFI_CTRL 5
#define UEFI_HARD_DRIVE 1
#define UEFI_FILE_PATH 4
#define UEFI_ACPI 1
#define UEFI_ACPIE 2
#define UEFI_ATAPI 1
#define UEFI_SCSI 2
#define UEFI_FIBRE 3
#define UEFI_FIBRE_EX 21
#define UEFI_USB 5
#define UEFI_SATA 18
#define UEFI_MACADDR 11
#define UEFI_END_ENTIRE 0xff
#define UEFI_END_INSTANCE 0x01
/*
* signature type in hard drive media path
*/
#define UEFI_NO_SIG 0x0
#define UEFI_MBR_SIG 0x1
#define UEFI_GUID_SIG 0x2
/*
* partition type in hard drive media path
*/
#define UEFI_MBR 0x1
#define UEFI_GPT 0x2
/*
* Generic structure header for device path that gives the length
* of the specific structure. Specific structures contain the
* same first 3 fields.
*/
typedef struct uefi_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
} uefi_device_path_t;
typedef char *uefirt_bootopt_buff_t;
typedef struct uefi_file_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint16_t path_name[];
} uefi_file_path_t;
typedef struct uefi_pci_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint8_t function_number;
uint8_t device_number;
} uefi_pci_device_path_t;
typedef struct uefi_ctrl_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint32_t ctrl_number;
} uefi_ctrl_device_path_t;
#pragma pack(1)
typedef struct uefi_hard_drive_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint32_t part_number;
uint64_t part_start;
uint64_t part_size;
uint8_t part_sig[16];
uint8_t part_format;
uint8_t sig_type;
} uefi_hard_drive_path_t;
typedef struct uefi_scsi_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint16_t target;
uint16_t lun;
} uefi_scsi_device_path_t;
typedef struct uefi_atapi_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint8_t channel;
uint8_t drive;
uint16_t lun;
} uefi_atapi_device_path_t;
typedef struct uefi_fibre_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint64_t wwn;
uint64_t lun;
} uefi_fibre_device_path_t;
typedef struct uefi_usb_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint8_t ppn;
uint8_t in;
} uefi_usb_device_path_t;
typedef struct uefi_sata_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint16_t port;
uint16_t port_mult;
uint16_t lun;
} uefi_sata_device_path_t;
typedef struct uefi_acpi_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint32_t hid;
uint32_t uid;
} uefi_acpi_device_path_t;
typedef struct uefi_bios_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint16_t device_type;
uint16_t status_flag;
char desc_str[];
} uefi_bios_device_path_t;
typedef struct uefi_macaddr_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint8_t mac_addr[32];
uint8_t iff_type;
} uefi_macaddr_device_path_t;
typedef struct uefi_acpie_device_path {
uint8_t type;
uint8_t subtype;
uint16_t len;
uint32_t hid;
uint32_t uid;
uint32_t cid;
/*
* Combined _HIDSTR, _UIDSTR, _CIDStr. Each string is NULL-terminated
* even if not present.
*/
char id_str[];
} uefi_acpie_device_path_t;
#pragma pack()
/*
* Corresponds to the data elements needed to construct
* a firmware Boot#### property according to section 3.1.3
* of the UEFI spec. The actual in firmware property format cannot be
* represented by a C structure. But this is used to represent
* that data in the library.
*/
typedef struct uefi_load_option {
UINT32 attr;
UINT16 dpath_len;
CHAR16 *desc;
uefi_device_path_t **dpath_list;
void *optdata;
UINTN optdata_len;
} uefi_load_option_t;
typedef struct uefi_lib_impl {
size_t memlist_size;
size_t memlist_end;
void **memlist_addr;
int uefirt_fd;
} uefi_lib_impl_t;
#define BOOT_NAME_SZ 9
#define MEMLIST_INCREMENT 20
#define EPRINT(fmt ...) \
if (uefirt_path_eprint == -1) { \
if (getenv("UEFIRT_PATH_EPRINT")) { \
uefirt_path_eprint = 1; \
} else { \
uefirt_path_eprint = 0; \
} \
} \
if (uefirt_path_eprint) { \
(void) fprintf(stderr, ##fmt); \
}
#define DPRINT(fmt ...) \
if (uefirt_path_debug == -1) { \
if (getenv("UEFIRT_PATH_DEBUG")) { \
uefirt_path_debug = 1; \
} else { \
uefirt_path_debug = 0; \
} \
} \
if (uefirt_path_debug) { \
(void) fprintf(stdout, ##fmt); \
}
#ifdef __cplusplus
}
#endif
#endif /* _LIBUEFI_RT_PATH_IMPL_H_ */