/* Code for managing symbols and pointers in efiemu */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
static int ptv_written = 0;
static int ptv_alloc = 0;
static int ptv_handle = 0;
static int relocated_handle = 0;
static int ptv_requested = 0;
struct grub_efiemu_sym
{
char *name;
int handle;
};
void
grub_efiemu_free_syms (void)
{
{
cur = d;
}
efiemu_syms = 0;
ptv_written = 0;
ptv_alloc = 0;
ptv_requested = 0;
ptv_handle = 0;
relocated_handle = 0;
}
/* Announce that the module will need NUM allocators */
/* Because of deferred memory allocation all the relocators have to be
announced during phase 1*/
{
if (ptv_alloc)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"symbols have already been allocated");
if (num < 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"can't request negative symbols");
ptv_requested += num;
return GRUB_ERR_NONE;
}
/* Resolve the symbol name NAME and set HANDLE and OFF accordingly */
{
{
return GRUB_ERR_NONE;
}
}
/* Register symbol named NAME in memory handle HANDLE at offset OFF */
{
if (!cur)
efiemu_syms = cur;
return 0;
}
/* Go from phase 1 to phase 2. Must be called before similar function in mm.c */
grub_efiemu_alloc_syms (void)
{
return grub_errno;
}
{
* sizeof (struct grub_efiemu_ptv_rel));
*relocated = 0;
return GRUB_ERR_NONE;
}
/* Write value (pointer to memory PLUS_HANDLE)
- (pointer to memory MINUS_HANDLE) + VALUE to ADDR assuming that the
size SIZE bytes. If PTV_NEEDED is 1 then announce it to runtime that this
value needs to be recomputed before going to virtual mode
*/
{
/* Announce relocator to runtime */
if (ptv_needed)
{
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"your module didn't declare efiemu "
" relocators correctly");
if (minus_handle)
else
if (plus_handle)
else
ptv_written++;
/* memset next value to zero to mark the end */
}
/* Compute the value */
if (minus_handle)
if (plus_handle)
/* Write the value */
switch (size)
{
case 8:
break;
case 4:
break;
case 2:
break;
case 1:
break;
default:
}
return GRUB_ERR_NONE;
}
__attribute__ ((unused)),
{
/* Ensure that we are called only once */
if (*ptv_relocated)
*ptv_relocated = 1;
/* Correct addresses using information supplied by grub */
{
/* Compute correction */
for (descptr = virtual_map;
{
}
/* Apply correction */
switch (cur_relloc->size)
{
case 8:
break;
case 4:
break;
case 2:
break;
case 1:
break;
}
}
/* Recompute crc32 of system table and runtime services */
if (grub_efiemu_sizeof_uintn_t () == 4)
return grub_efiemu_crc32 ();
else
return grub_efiemu_crc64 ();
}