1 #ifndef PXE_TYPES_H 2 #define PXE_TYPES_H 3 4 /** @file 5 * 6 * PXE data types 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER ); 11 12 #include <stdint.h> 13 #include <errno.h> /* PXE status codes */ 14 15 /** @addtogroup pxe Preboot eXecution Environment (PXE) API 16 * @{ 17 */ 18 19 /** @defgroup pxe_types PXE data types 20 * 21 * Basic PXE data types such as #UINT16_t, #ADDR32_t, #SEGSEL_t etc. 22 * 23 * These definitions are based on Table 1-1 ("Data Type Definitions") 24 * in the Intel PXE specification version 2.1. They have been 25 * generalised to non-x86 architectures where possible. 26 * 27 * @{ 28 */ 29 30 /** An 8-bit unsigned integer */ 31 typedef uint8_t UINT8_t; 32 33 /** A 16-bit unsigned integer */ 34 typedef uint16_t UINT16_t; 35 36 /** A 32-bit unsigned integer */ 37 typedef uint32_t UINT32_t; 38 39 /** A PXE exit code. 40 * 41 * Permitted values are #PXENV_EXIT_SUCCESS and #PXENV_EXIT_FAILURE. 42 * 43 */ 44 typedef UINT16_t PXENV_EXIT_t; 45 #define PXENV_EXIT_SUCCESS 0x0000 /**< No error occurred */ 46 #define PXENV_EXIT_FAILURE 0x0001 /**< An error occurred */ 47 48 /** A PXE status code. 49 * 50 * Status codes are defined in errno.h. 51 * 52 */ 53 typedef UINT16_t PXENV_STATUS_t; 54 55 /** An IPv4 address. 56 * 57 * @note This data type is in network (big-endian) byte order. 58 * 59 */ 60 typedef UINT32_t IP4_t; 61 62 /** A UDP port. 63 * 64 * @note This data type is in network (big-endian) byte order. 65 * 66 */ 67 typedef UINT16_t UDP_PORT_t; 68 69 /** Maximum length of a MAC address */ 70 #define MAC_ADDR_LEN 16 71 72 /** A MAC address */ 73 typedef UINT8_t MAC_ADDR_t[MAC_ADDR_LEN]; 74 75 #ifndef HAVE_ARCH_ADDR32 76 /** A physical address. 77 * 78 * For x86, this is a 32-bit physical address, and is therefore 79 * limited to the low 4GB. 80 * 81 */ 82 typedef UINT32_t ADDR32_t; 83 #endif 84 85 #ifndef HAVE_ARCH_SEGSEL 86 /** A segment selector. 87 * 88 * For x86, this is a real mode segment (0x0000-0xffff), or a 89 * protected-mode segment selector, such as could be loaded into a 90 * segment register. 91 * 92 */ 93 typedef UINT16_t SEGSEL_t; 94 #endif 95 96 #ifndef HAVE_ARCH_OFF16 97 /** An offset within a segment identified by #SEGSEL 98 * 99 * For x86, this is a 16-bit offset. 100 * 101 */ 102 typedef UINT16_t OFF16_t; 103 #endif 104 105 /** A segment:offset address 106 * 107 * For x86, this is a 16-bit real-mode or protected-mode 108 * segment:offset address. 109 * 110 */ 111 typedef struct s_SEGOFF16 { 112 OFF16_t offset; /**< Offset within the segment */ 113 SEGSEL_t segment; /**< Segment selector */ 114 } PACKED SEGOFF16_t; 115 116 /** A segment descriptor */ 117 typedef struct s_SEGDESC { 118 SEGSEL_t segment_address; /**< Segment selector */ 119 ADDR32_t Physical_address; /**< Segment base address */ 120 OFF16_t Seg_size; /**< Size of the segment */ 121 } PACKED SEGDESC_t; 122 123 /** @} */ /* pxe_types */ 124 125 /** @} */ /* pxe */ 126 127 #endif /* PXE_TYPES_H */ 128