Index: mmap/i386/pc/mmap_helper.S =================================================================== --- mmap/i386/pc/mmap_helper.S (revisiĆ³n: 2447) +++ mmap/i386/pc/mmap_helper.S (copia de trabajo) @@ -48,9 +48,8 @@ popf /* ljmp */ .byte 0xea -VARIABLE (grub_machine_mmaphook_int15offset) +VARIABLE (grub_machine_mmaphook_oldint15) .word 0 -VARIABLE (grub_machine_mmaphook_int15segment) .word 0 e801: Index: mmap/i386/pc/mmap.c =================================================================== --- mmap/i386/pc/mmap.c (revisiĆ³n: 2447) +++ mmap/i386/pc/mmap.c (copia de trabajo) @@ -25,17 +25,20 @@ #define min(a,b) (((a) < (b)) ? (a) : (b)) +#define OFFSET_IN_ASM(addr) ( PTR_TO_UINT (addr) \ + - PTR_TO_UINT (&grub_machine_mmaphook_start) ) + static void *hooktarget = 0; +/* Not a null pointer, the real mode IVT is actually at address 0:0 */ +static grub_machine_farptr *grub_machine_ivt = 0; -extern grub_uint8_t grub_machine_mmaphook_start; -extern grub_uint8_t grub_machine_mmaphook_end; -extern grub_uint8_t grub_machine_mmaphook_int12; -extern grub_uint8_t grub_machine_mmaphook_int15; +extern const void grub_machine_mmaphook_start; +extern const void grub_machine_mmaphook_end; +extern const void grub_machine_mmaphook_int12; +extern const void grub_machine_mmaphook_int15; -static grub_uint16_t grub_machine_mmaphook_int12offset = 0; -static grub_uint16_t grub_machine_mmaphook_int12segment = 0; -extern grub_uint16_t grub_machine_mmaphook_int15offset; -extern grub_uint16_t grub_machine_mmaphook_int15segment; +static grub_machine_farptr grub_machine_mmaphook_oldint12; +extern grub_machine_farptr grub_machine_mmaphook_oldint15; extern grub_uint16_t grub_machine_mmaphook_mmap_num; extern grub_uint16_t grub_machine_mmaphook_kblow; @@ -73,9 +76,8 @@ grub_dprintf ("mmap", "installing preboot handlers\n"); - hookmmapcur = hookmmap = (struct grub_e820_mmap_entry *) - ((grub_uint8_t *) hooktarget + (&grub_machine_mmaphook_end - - &grub_machine_mmaphook_start)); + hookmmapcur = hookmmap = UINT_TO_PTR (PTR_TO_UINT (hooktarget) + + OFFSET_IN_ASM(&grub_machine_mmaphook_end)); grub_mmap_iterate (fill_hook); grub_machine_mmaphook_mmap_num = hookmmapcur - hookmmap; @@ -90,24 +92,23 @@ *((grub_uint16_t *) 0x413) = grub_mmap_get_lower () >> 10; /* Save old interrupt handlers. */ - grub_machine_mmaphook_int12offset = *((grub_uint16_t *) 0x48); - grub_machine_mmaphook_int12segment = *((grub_uint16_t *) 0x4a); - grub_machine_mmaphook_int15offset = *((grub_uint16_t *) 0x54); - grub_machine_mmaphook_int15segment = *((grub_uint16_t *) 0x56); + grub_machine_mmaphook_oldint12 = grub_machine_ivt[0x12]; + grub_machine_mmaphook_oldint15 = grub_machine_ivt[0x15]; grub_dprintf ("mmap", "hooktarget = %p\n", hooktarget); /* Install the interrupt handlers. */ grub_memcpy (hooktarget, &grub_machine_mmaphook_start, - &grub_machine_mmaphook_end - &grub_machine_mmaphook_start); + OFFSET_IN_ASM(&grub_machine_mmaphook_end)); - *((grub_uint16_t *) 0x4a) = PTR_TO_UINT32 (hooktarget) >> 4; - *((grub_uint16_t *) 0x56) = PTR_TO_UINT32 (hooktarget) >> 4; - *((grub_uint16_t *) 0x48) = &grub_machine_mmaphook_int12 - - &grub_machine_mmaphook_start; - *((grub_uint16_t *) 0x54) = &grub_machine_mmaphook_int15 - - &grub_machine_mmaphook_start; + void* newint12 = UINT_TO_PTR (PTR_TO_UINT (hooktarget) + + OFFSET_IN_ASM(&grub_machine_mmaphook_int12)); + void* newint15 = UINT_TO_PTR (PTR_TO_UINT (hooktarget) + + OFFSET_IN_ASM(&grub_machine_mmaphook_int15)); + grub_machine_ivt[0x12] = grub_machine_linear2real(newint12); + grub_machine_ivt[0x15] = grub_machine_linear2real(newint15); + return GRUB_ERR_NONE; } @@ -115,10 +116,8 @@ preboot_rest (void) { /* Restore old interrupt handlers. */ - *((grub_uint16_t *) 0x48) = grub_machine_mmaphook_int12offset; - *((grub_uint16_t *) 0x4a) = grub_machine_mmaphook_int12segment; - *((grub_uint16_t *) 0x54) = grub_machine_mmaphook_int15offset; - *((grub_uint16_t *) 0x56) = grub_machine_mmaphook_int15segment; + grub_machine_ivt[0x12] = grub_machine_mmaphook_oldint12; + grub_machine_ivt[0x15] = grub_machine_mmaphook_oldint15; return GRUB_ERR_NONE; } @@ -161,12 +160,11 @@ hooktarget = 0; } - hooksize = &grub_machine_mmaphook_end - &grub_machine_mmaphook_start + hooksize = OFFSET_IN_ASM(&grub_machine_mmaphook_end) + regcount * sizeof (struct grub_e820_mmap_entry); /* Allocate an integer number of KiB. */ hooksize = ((hooksize - 1) | 0x3ff) + 1; - slots_available = (hooksize - (&grub_machine_mmaphook_end - - &grub_machine_mmaphook_start)) + slots_available = (hooksize - OFFSET_IN_ASM(&grub_machine_mmaphook_end)) / sizeof (struct grub_e820_mmap_entry); reentry = 1;