1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
18 #if defined(__386__) || defined(__i386__) || defined(__x86_64__)
19 # define X86_MEM 1 /* Littleendian and unaligned safe */
25 * Access functions for littleendian numbers, possibly misaligned.
27 static inline uint8_t get_8(const uint8_t * p)
32 static inline uint16_t get_16(const uint16_t * p)
35 /* Littleendian and unaligned-capable */
38 const uint8_t *pp = (const uint8_t *)p;
39 return pp[0] + ((uint16_t)pp[1] << 8);
43 static inline uint32_t get_32(const uint32_t * p)
46 /* Littleendian and unaligned-capable */
49 const uint16_t *pp = (const uint16_t *)p;
50 return get_16(pp[0]) + (uint32_t)get_16(pp[1]);
54 static inline uint64_t get_64(const uint64_t * p)
57 /* Littleendian and unaligned-capable */
60 const uint32_t *pp = (const uint32_t *)p;
61 return get_32(pp[0]) + (uint64_t)get_32(pp[1]);
65 static inline void set_8(uint8_t *p, uint8_t v)
70 static inline void set_16(uint16_t *p, uint16_t v)
73 /* Littleendian and unaligned-capable */
76 uint8_t *pp = (uint8_t *) p;
78 pp[1] = ((v >> 8) & 0xff);
82 static inline void set_32(uint32_t *p, uint32_t v)
85 /* Littleendian and unaligned-capable */
88 uint8_t *pp = (uint8_t *) p;
90 pp[1] = ((v >> 8) & 0xff);
91 pp[2] = ((v >> 16) & 0xff);
92 pp[3] = ((v >> 24) & 0xff);
96 static inline void set_64(uint64_t *p, uint64_t v)
99 /* Littleendian and unaligned-capable */
102 uint32_t *pp = (uint32_t *) p;
104 set_32(pp[1], v >> 32);
108 #define LDLINUX_MAGIC 0x3eb202fe
110 /* Patch area for disk-based installers */
112 uint32_t magic; /* LDLINUX_MAGIC */
113 uint32_t instance; /* Per-version value */
114 uint16_t data_sectors;
115 uint16_t adv_sectors;
118 uint16_t maxtransfer;
119 uint16_t advptroffset;
122 uint16_t subvoloffset;
124 uint16_t secptroffset;
129 struct syslinux_extent {
132 } __attribute__((packed));
134 /* FAT bootsector format, also used by other disk-based derivatives */
138 uint16_t bsBytesPerSec;
139 uint8_t bsSecPerClust;
140 uint16_t bsResSectors;
142 uint16_t bsRootDirEnts;
146 uint16_t bsSecPerTrack;
148 uint32_t bsHiddenSecs;
149 uint32_t bsHugeSectors;
155 uint8_t BootSignature;
157 char VolumeLabel[11];
160 } __attribute__ ((packed)) bs16;
168 uint8_t Reserved0[12];
171 uint8_t BootSignature;
173 char VolumeLabel[11];
176 } __attribute__ ((packed)) bs32;
177 } __attribute__ ((packed));
179 uint64_t NextSector; /* Pointer to the first unused sector */
180 uint16_t bsSignature;
181 } __attribute__ ((packed));
183 #define bsHead bsJump
184 #define bsHeadLen offsetof(struct boot_sector, bsOemName)
185 #define bsCode bs32.Code /* The common safe choice */
186 #define bsCodeLen (offsetof(struct boot_sector, bsSignature) - \
187 offsetof(struct boot_sector, bsCode))
189 #endif /* SYSLXINT_H */