Index: include/grub/i386/pc/memory.h =================================================================== --- include/grub/i386/pc/memory.h (revisiĆ³n: 2447) +++ include/grub/i386/pc/memory.h (copia de trabajo) @@ -126,6 +126,32 @@ } #endif +typedef union +{ + struct + { + /* Given that i386 is little-endian, this order matches the in-memory + format of CPU realmode far pointers. */ + grub_uint16_t offset; + grub_uint16_t segment; + } __attribute__ ((packed)); + grub_uint32_t raw_bits; +} grub_machine_farptr; + +static inline void * +grub_machine_real2linear (grub_machine_farptr ptr) +{ + return UINT_TO_PTR ((((grub_uint32_t) ptr.segment) << 4) + ptr.offset); +} + +static inline grub_machine_farptr +grub_machine_linear2real (void *addr) +{ + grub_machine_farptr ret = { { PTR_TO_UINT32 (addr) & 0x0000000F, + (PTR_TO_UINT32 (addr) & 0x000FFFF0) >> 4 } }; + return ret; +} + #endif #endif /* ! GRUB_MEMORY_MACHINE_HEADER */