iPXE
pxe_types.h
Go to the documentation of this file.
00001 #ifndef PXE_TYPES_H
00002 #define PXE_TYPES_H
00003 
00004 /** @file
00005  *
00006  * PXE data types
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <errno.h> /* PXE status codes */
00014 
00015 /** @addtogroup pxe Preboot eXecution Environment (PXE) API
00016  *  @{
00017  */
00018 
00019 /** @defgroup pxe_types PXE data types
00020  *
00021  * Basic PXE data types such as #UINT16_t, #ADDR32_t, #SEGSEL_t etc.
00022  *
00023  * These definitions are based on Table 1-1 ("Data Type Definitions")
00024  * in the Intel PXE specification version 2.1.  They have been
00025  * generalised to non-x86 architectures where possible.
00026  *
00027  * @{
00028  */
00029 
00030 /** An 8-bit unsigned integer */
00031 typedef uint8_t UINT8_t;
00032 
00033 /** A 16-bit unsigned integer */
00034 typedef uint16_t UINT16_t;
00035 
00036 /** A 32-bit unsigned integer */
00037 typedef uint32_t UINT32_t;
00038 
00039 /** A PXE exit code.
00040  *
00041  * Permitted values are #PXENV_EXIT_SUCCESS and #PXENV_EXIT_FAILURE.
00042  *
00043  */
00044 typedef UINT16_t PXENV_EXIT_t;
00045 #define PXENV_EXIT_SUCCESS      0x0000  /**< No error occurred */
00046 #define PXENV_EXIT_FAILURE      0x0001  /**< An error occurred */
00047 
00048 /** A PXE status code.
00049  *
00050  * Status codes are defined in errno.h.
00051  *
00052  */
00053 typedef UINT16_t PXENV_STATUS_t;
00054 
00055 /** An IPv4 address.
00056  *
00057  * @note This data type is in network (big-endian) byte order.
00058  *
00059  */
00060 typedef UINT32_t IP4_t;
00061 
00062 /** A UDP port.
00063  *
00064  * @note This data type is in network (big-endian) byte order.
00065  *
00066  */
00067 typedef UINT16_t UDP_PORT_t;
00068 
00069 /** Maximum length of a MAC address */
00070 #define MAC_ADDR_LEN 16
00071 
00072 /** A MAC address */
00073 typedef UINT8_t MAC_ADDR_t[MAC_ADDR_LEN];
00074 
00075 #ifndef HAVE_ARCH_ADDR32
00076 /** A physical address.
00077  *
00078  * For x86, this is a 32-bit physical address, and is therefore
00079  * limited to the low 4GB.
00080  *
00081  */
00082 typedef UINT32_t ADDR32_t;
00083 #endif
00084 
00085 #ifndef HAVE_ARCH_SEGSEL
00086 /** A segment selector.
00087  *
00088  * For x86, this is a real mode segment (0x0000-0xffff), or a
00089  * protected-mode segment selector, such as could be loaded into a
00090  * segment register.
00091  *
00092  */
00093 typedef UINT16_t SEGSEL_t;
00094 #endif
00095 
00096 #ifndef HAVE_ARCH_OFF16
00097 /** An offset within a segment identified by #SEGSEL
00098  *
00099  * For x86, this is a 16-bit offset.
00100  *
00101  */
00102 typedef UINT16_t OFF16_t;
00103 #endif
00104 
00105 /** A segment:offset address
00106  *
00107  * For x86, this is a 16-bit real-mode or protected-mode
00108  * segment:offset address.
00109  *
00110  */
00111 typedef struct s_SEGOFF16 {
00112         OFF16_t         offset;         /**< Offset within the segment */
00113         SEGSEL_t        segment;        /**< Segment selector */
00114 } __attribute__ (( packed )) SEGOFF16_t;
00115 
00116 /** A segment descriptor */
00117 typedef struct s_SEGDESC {
00118         SEGSEL_t        segment_address;        /**< Segment selector */
00119         ADDR32_t        Physical_address;       /**< Segment base address */
00120         OFF16_t         Seg_size;               /**< Size of the segment */
00121 } __attribute__ (( packed )) SEGDESC_t;
00122 
00123 /** @} */ /* pxe_types */
00124 
00125 /** @} */ /* pxe */
00126 
00127 #endif /* PXE_TYPES_H */