Fixes for backwards relocator

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-11-26 22:51:00 +01:00
parent f93415cfee
commit bbd46b0966
2 changed files with 8 additions and 9 deletions

View file

@ -27,13 +27,11 @@
#ifdef __x86_64__ #ifdef __x86_64__
#define RAX %rax #define RAX %rax
#define RCX %rcx #define RCX %rcx
#define RDX %rdx
#define RDI %rdi #define RDI %rdi
#define RSI %rdi #define RSI %rdi
#else #else
#define RAX %eax #define RAX %eax
#define RCX %ecx #define RCX %ecx
#define RDX %edx
#define RDI %edi #define RDI %edi
#define RSI %esi #define RSI %esi
#endif #endif
@ -97,7 +95,7 @@ RELOCATOR_VARIABLE(size)
#ifdef BACKWARD #ifdef BACKWARD
add RCX, RSI add RCX, RSI
add RDX, RDI add RCX, RDI
#endif #endif
#ifndef BACKWARD #ifndef BACKWARD

View file

@ -20,6 +20,7 @@
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) \ + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) \
+ (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) \ + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) \
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)) + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN))
#define PRE_REGION_SIZE (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
void * void *
PREFIX (alloc) (grub_size_t size) PREFIX (alloc) (grub_size_t size)
@ -32,7 +33,7 @@ PREFIX (alloc) (grub_size_t size)
*(grub_size_t *) playground = size; *(grub_size_t *) playground = size;
return playground + RELOCATOR_SIZEOF (forward); return playground + PRE_REGION_SIZE;
} }
void * void *
@ -40,7 +41,7 @@ PREFIX (realloc) (void *relocator, grub_size_t size)
{ {
char *playground; char *playground;
playground = (char *) relocator - RELOCATOR_SIZEOF (forward); playground = (char *) relocator - PRE_REGION_SIZE;
playground = grub_realloc (playground, size + MAX_OVERHEAD); playground = grub_realloc (playground, size + MAX_OVERHEAD);
if (!playground) if (!playground)
@ -48,14 +49,14 @@ PREFIX (realloc) (void *relocator, grub_size_t size)
*(grub_size_t *) playground = size; *(grub_size_t *) playground = size;
return playground + RELOCATOR_SIZEOF (forward); return playground + PRE_REGION_SIZE;
} }
void void
PREFIX(free) (void *relocator) PREFIX(free) (void *relocator)
{ {
if (relocator) if (relocator)
grub_free ((char *) relocator - RELOCATOR_SIZEOF (forward)); grub_free ((char *) relocator - PRE_REGION_SIZE);
} }
grub_err_t grub_err_t
@ -65,7 +66,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
grub_size_t size; grub_size_t size;
char *playground; char *playground;
playground = (char *) relocator - RELOCATOR_SIZEOF (forward); playground = (char *) relocator - PRE_REGION_SIZE;
size = *(grub_size_t *) playground; size = *(grub_size_t *) playground;
grub_dprintf ("relocator", grub_dprintf ("relocator",
@ -94,7 +95,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
if (UINT_TO_PTR (dest) >= relocator) if (UINT_TO_PTR (dest) >= relocator)
{ {
int overhead; int overhead;
overhead = overhead = dest -
ALIGN_UP (dest - RELOCATOR_SIZEOF (backward) - RELOCATOR_ALIGN, ALIGN_UP (dest - RELOCATOR_SIZEOF (backward) - RELOCATOR_ALIGN,
RELOCATOR_ALIGN); RELOCATOR_ALIGN);
grub_dprintf ("relocator", grub_dprintf ("relocator",