This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-08-03 14:30:51 +02:00
parent 23a2f35a0b
commit 7c8f178d02
2 changed files with 27 additions and 7 deletions

View file

@ -19,6 +19,9 @@
#ifndef GRUB_RELOCATOR_CPU_HEADER #ifndef GRUB_RELOCATOR_CPU_HEADER
#define GRUB_RELOCATOR_CPU_HEADER 1 #define GRUB_RELOCATOR_CPU_HEADER 1
#include <grub/types.h>
#include <grub/err.h>
struct grub_relocator32_state struct grub_relocator32_state
{ {
grub_uint32_t esp; grub_uint32_t esp;
@ -29,12 +32,10 @@ struct grub_relocator32_state
grub_uint32_t eip; grub_uint32_t eip;
}; };
void * void *grub_relocator32_alloc (grub_size_t size);
grub_relocator32_alloc (grub_size_t size); grub_err_t grub_relocator32_boot (void *relocator, grub_uint32_t dest,
grub_err_t struct grub_relocator32_state state);
grub_relocator32_boot (void *relocator, grub_uint32_t dest, void *grub_relocator32_realloc (void *relocator, grub_size_t size);
struct grub_relocator32_state state); void grub_relocator32_free (void *relocator);
void
grub_relocator32_free (void *relocator);
#endif /* ! GRUB_RELOCATOR_CPU_HEADER */ #endif /* ! GRUB_RELOCATOR_CPU_HEADER */

View file

@ -80,6 +80,25 @@ grub_relocator32_alloc (grub_size_t size)
return playground + RELOCATOR_SIZEOF (forward); return playground + RELOCATOR_SIZEOF (forward);
} }
void *
grub_relocator32_realloc (void *relocator, grub_size_t size)
{
char *playground;
playground = (char *) relocator - RELOCATOR_SIZEOF (forward);
playground = grub_realloc (playground,
(RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
+ size
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN));
if (!playground)
return 0;
*(grub_size_t *) playground = size;
return playground + RELOCATOR_SIZEOF (forward);
}
void void
grub_relocator32_free (void *relocator) grub_relocator32_free (void *relocator)
{ {