Replace UINT_TO_PTR and PTR_TO_UINT with explicit grub_addr_t casts.
* include/grub/types.h (UINT_TO_PTR): Removed. All users switched to grub_addr_t casts. (PTR_TO_UINT64): Likewise. (PTR_TO_UINT32): Likewise.
This commit is contained in:
parent
5ef5c51147
commit
f2b60fbdb8
10 changed files with 55 additions and 57 deletions
|
@ -1,3 +1,12 @@
|
|||
2011-12-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Replace UINT_TO_PTR and PTR_TO_UINT with explicit grub_addr_t casts.
|
||||
|
||||
* include/grub/types.h (UINT_TO_PTR): Removed. All users switched to
|
||||
grub_addr_t casts.
|
||||
(PTR_TO_UINT64): Likewise.
|
||||
(PTR_TO_UINT32): Likewise.
|
||||
|
||||
2011-12-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkimage.c (generate_image): Decrease the higher limit
|
||||
|
|
|
@ -166,7 +166,7 @@ grub_acpi_create_ebda (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ebda = (grub_uint8_t *) UINT_TO_PTR ((*((grub_uint16_t *)0x40e)) << 4);
|
||||
ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
|
||||
ebda_kb_len = *(grub_uint16_t *) ebda;
|
||||
if (! ebda || ebda_kb_len > 16)
|
||||
ebda_kb_len = 0;
|
||||
|
@ -174,14 +174,14 @@ grub_acpi_create_ebda (void)
|
|||
|
||||
/* FIXME: use low-memory mm allocation once it's available. */
|
||||
grub_mmap_iterate (find_hook);
|
||||
targetebda = (grub_uint8_t *) UINT_TO_PTR (highestlow);
|
||||
targetebda = (grub_uint8_t *) (grub_addr_t) highestlow;
|
||||
grub_dprintf ("acpi", "creating ebda @%llx\n",
|
||||
(unsigned long long) highestlow);
|
||||
if (! highestlow)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't find space for the new EBDA");
|
||||
|
||||
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
||||
mmapregion = grub_mmap_register ((grub_addr_t) targetebda, ebda_len,
|
||||
GRUB_MEMORY_RESERVED);
|
||||
if (! mmapregion)
|
||||
return grub_errno;
|
||||
|
@ -330,13 +330,13 @@ setup_common_tables (void)
|
|||
if (grub_memcmp (fadt->hdr.signature, GRUB_ACPI_FADT_SIGNATURE,
|
||||
sizeof (fadt->hdr.signature)) == 0)
|
||||
{
|
||||
fadt->dsdt_addr = PTR_TO_UINT32 (table_dsdt);
|
||||
fadt->dsdt_addr = (grub_addr_t) table_dsdt;
|
||||
fadt->facs_addr = facs_addr;
|
||||
|
||||
/* Does a revision 2 exist at all? */
|
||||
if (fadt->hdr.revision >= 3)
|
||||
{
|
||||
fadt->dsdt_xaddr = PTR_TO_UINT64 (table_dsdt);
|
||||
fadt->dsdt_xaddr = (grub_addr_t) table_dsdt;
|
||||
fadt->facs_xaddr = facs_addr;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ setup_common_tables (void)
|
|||
rsdt->creator_rev = root_creator_rev;
|
||||
|
||||
for (cur = acpi_tables; cur; cur = cur->next)
|
||||
*(rsdt_entry++) = PTR_TO_UINT32 (cur->addr);
|
||||
*(rsdt_entry++) = (grub_addr_t) cur->addr;
|
||||
|
||||
/* Recompute checksum. */
|
||||
rsdt->checksum = 0;
|
||||
|
@ -385,7 +385,7 @@ setv1table (void)
|
|||
sizeof (rsdpv1_new->signature));
|
||||
grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
|
||||
rsdpv1_new->revision = 0;
|
||||
rsdpv1_new->rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
||||
rsdpv1_new->rsdt_addr = (grub_addr_t) rsdt_addr;
|
||||
rsdpv1_new->checksum = 0;
|
||||
rsdpv1_new->checksum = 1 + ~grub_byte_checksum (rsdpv1_new,
|
||||
sizeof (*rsdpv1_new));
|
||||
|
@ -410,7 +410,7 @@ setv2table (void)
|
|||
|
||||
xsdt_entry = (grub_uint64_t *)(xsdt + 1);
|
||||
for (cur = acpi_tables; cur; cur = cur->next)
|
||||
*(xsdt_entry++) = PTR_TO_UINT64 (cur->addr);
|
||||
*(xsdt_entry++) = (grub_addr_t) cur->addr;
|
||||
grub_memcpy (&(xsdt->signature), "XSDT", 4);
|
||||
xsdt->length = sizeof (struct grub_acpi_table_header) + 8 * numoftables;
|
||||
xsdt->revision = 1;
|
||||
|
@ -430,12 +430,12 @@ setv2table (void)
|
|||
grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
|
||||
sizeof (rsdpv2_new->rsdpv1.oemid));
|
||||
rsdpv2_new->rsdpv1.revision = rev2;
|
||||
rsdpv2_new->rsdpv1.rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
||||
rsdpv2_new->rsdpv1.rsdt_addr = (grub_addr_t) rsdt_addr;
|
||||
rsdpv2_new->rsdpv1.checksum = 0;
|
||||
rsdpv2_new->rsdpv1.checksum = 1 + ~grub_byte_checksum
|
||||
(&(rsdpv2_new->rsdpv1), sizeof (rsdpv2_new->rsdpv1));
|
||||
rsdpv2_new->length = sizeof (*rsdpv2_new);
|
||||
rsdpv2_new->xsdt_addr = PTR_TO_UINT64 (xsdt);
|
||||
rsdpv2_new->xsdt_addr = (grub_addr_t) xsdt;
|
||||
rsdpv2_new->checksum = 0;
|
||||
rsdpv2_new->checksum = 1 + ~grub_byte_checksum (rsdpv2_new,
|
||||
rsdpv2_new->length);
|
||||
|
@ -507,7 +507,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
|||
/* Set revision variables to replicate the same version as host. */
|
||||
rev1 = ! rsdp->revision;
|
||||
rev2 = rsdp->revision;
|
||||
rsdt = (struct grub_acpi_table_header *) UINT_TO_PTR (rsdp->rsdt_addr);
|
||||
rsdt = (struct grub_acpi_table_header *) (grub_addr_t) rsdp->rsdt_addr;
|
||||
/* Load host tables. */
|
||||
for (entry_ptr = (grub_uint32_t *) (rsdt + 1);
|
||||
entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
|
||||
|
@ -517,7 +517,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
|||
char signature[5];
|
||||
struct efiemu_acpi_table *table;
|
||||
struct grub_acpi_table_header *curtable
|
||||
= (struct grub_acpi_table_header *) UINT_TO_PTR (*entry_ptr);
|
||||
= (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
|
||||
signature[4] = 0;
|
||||
for (i = 0; i < 4;i++)
|
||||
signature[i] = grub_tolower (curtable->signature[i]);
|
||||
|
@ -541,7 +541,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
|||
|
||||
/* Load DSDT if not excluded. */
|
||||
dsdt = (struct grub_acpi_table_header *)
|
||||
UINT_TO_PTR (fadt->dsdt_addr);
|
||||
(grub_addr_t) fadt->dsdt_addr;
|
||||
if (dsdt && (! exclude || ! grub_strword (exclude, "dsdt"))
|
||||
&& (! load_only || grub_strword (load_only, "dsdt"))
|
||||
&& dsdt->length >= sizeof (*dsdt))
|
||||
|
|
|
@ -201,10 +201,10 @@ efiemu_alloc_requests (void)
|
|||
- (requested_memory[reqorder[i]] % GRUB_EFIEMU_PAGESIZE);
|
||||
if (align_overhead == GRUB_EFIEMU_PAGESIZE)
|
||||
align_overhead = 0;
|
||||
curptr = ((grub_uint8_t *)curptr) + align_overhead;
|
||||
curptr = ((grub_uint8_t *) curptr) + align_overhead;
|
||||
|
||||
/* Add the region to memory map */
|
||||
grub_efiemu_add_to_mmap (PTR_TO_UINT64 (typestart),
|
||||
grub_efiemu_add_to_mmap ((grub_addr_t) typestart,
|
||||
curptr - typestart, reqorder[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,10 +97,9 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
|
|||
grub_memcpy (&(conftables[i].vendor_guid), &(cur->guid),
|
||||
sizeof (cur->guid));
|
||||
if (cur->get_table)
|
||||
conftables[i].vendor_table
|
||||
= PTR_TO_UINT64 (cur->get_table (cur->data));
|
||||
conftables[i].vendor_table = (grub_addr_t) cur->get_table (cur->data);
|
||||
else
|
||||
conftables[i].vendor_table = PTR_TO_UINT64 (cur->data);
|
||||
conftables[i].vendor_table = (grub_addr_t) cur->data;
|
||||
}
|
||||
|
||||
err = SUFFIX (grub_efiemu_crc) ();
|
||||
|
|
|
@ -169,7 +169,7 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
|
|||
else
|
||||
ptv_rels[ptv_written].plustype = 0;
|
||||
|
||||
ptv_rels[ptv_written].addr = PTR_TO_UINT64 (addr);
|
||||
ptv_rels[ptv_written].addr = (grub_addr_t) addr;
|
||||
ptv_rels[ptv_written].size = size;
|
||||
ptv_written++;
|
||||
|
||||
|
@ -179,10 +179,10 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
|
|||
|
||||
/* Compute the value */
|
||||
if (minus_handle)
|
||||
value -= PTR_TO_UINT32 (grub_efiemu_mm_obtain_request (minus_handle));
|
||||
value -= (grub_addr_t) grub_efiemu_mm_obtain_request (minus_handle);
|
||||
|
||||
if (plus_handle)
|
||||
value += PTR_TO_UINT32 (grub_efiemu_mm_obtain_request (plus_handle));
|
||||
value += (grub_addr_t) grub_efiemu_mm_obtain_request (plus_handle);
|
||||
|
||||
/* Write the value */
|
||||
switch (size)
|
||||
|
@ -248,16 +248,16 @@ grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
|
|||
switch (cur_relloc->size)
|
||||
{
|
||||
case 8:
|
||||
*((grub_uint64_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
|
||||
*((grub_uint64_t *) (grub_addr_t) cur_relloc->addr) += corr;
|
||||
break;
|
||||
case 4:
|
||||
*((grub_uint32_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
|
||||
*((grub_uint32_t *) (grub_addr_t) cur_relloc->addr) += corr;
|
||||
break;
|
||||
case 2:
|
||||
*((grub_uint16_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
|
||||
*((grub_uint16_t *) (grub_addr_t) cur_relloc->addr) += corr;
|
||||
break;
|
||||
case 1:
|
||||
*((grub_uint8_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
|
||||
*((grub_uint8_t *) (grub_addr_t) cur_relloc->addr) += corr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -734,18 +734,18 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
#else
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
{
|
||||
ptr = UINT_TO_PTR (((grub_efiemu_configuration_table32_t *)
|
||||
ptr = (void *) (grub_addr_t) ((grub_efiemu_configuration_table32_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i]
|
||||
.vendor_table);
|
||||
.vendor_table;
|
||||
guid =
|
||||
((grub_efiemu_configuration_table32_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i].vendor_guid;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = UINT_TO_PTR (((grub_efiemu_configuration_table64_t *)
|
||||
ptr = (void *) (grub_addr_t) ((grub_efiemu_configuration_table64_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i]
|
||||
.vendor_table);
|
||||
.vendor_table;
|
||||
guid =
|
||||
((grub_efiemu_configuration_table64_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i].vendor_guid;
|
||||
|
@ -786,9 +786,9 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
if (! curval->data)
|
||||
return grub_errno;
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
*((grub_uint32_t *)curval->data) = PTR_TO_UINT32 (ptr);
|
||||
*((grub_uint32_t *) curval->data) = (grub_addr_t) ptr;
|
||||
else
|
||||
*((grub_uint64_t *)curval->data) = PTR_TO_UINT64 (ptr);
|
||||
*((grub_uint64_t *) curval->data) = (grub_addr_t) ptr;
|
||||
|
||||
/* Create alias. */
|
||||
for (j = 0; j < sizeof (table_aliases) / sizeof (table_aliases[0]); j++)
|
||||
|
@ -821,10 +821,10 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
return grub_errno;
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
*((grub_uint32_t *) curval->data)
|
||||
= PTR_TO_UINT32 (SYSTEM_TABLE_PTR (runtime_services));
|
||||
= (grub_addr_t) SYSTEM_TABLE_PTR (runtime_services);
|
||||
else
|
||||
*((grub_uint64_t *) curval->data)
|
||||
= PTR_TO_UINT64 (SYSTEM_TABLE_PTR (runtime_services));
|
||||
= (grub_addr_t) SYSTEM_TABLE_PTR (runtime_services);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
params->lfb_depth = mode_info.bpp;
|
||||
params->lfb_line_len = mode_info.pitch;
|
||||
|
||||
params->lfb_base = PTR_TO_UINT32 (framebuffer);
|
||||
params->lfb_base = (grub_addr_t) framebuffer;
|
||||
params->lfb_mode = bitmap ? GRUB_XNU_VIDEO_SPLASH
|
||||
: GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ grub_xnu_boot (void)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
bootparams->efi_system_table = PTR_TO_UINT32 (grub_autoefi_system_table);
|
||||
bootparams->efi_system_table = (grub_addr_t) grub_autoefi_system_table;
|
||||
|
||||
firstruntimepage = (((grub_addr_t) grub_xnu_heap_target_start
|
||||
+ grub_xnu_heap_size + GRUB_XNU_PAGESIZE - 1)
|
||||
|
@ -1077,11 +1077,11 @@ grub_xnu_boot (void)
|
|||
curdesc->virtual_start = curruntimepage << 12;
|
||||
curruntimepage += curdesc->num_pages;
|
||||
if (curdesc->physical_start
|
||||
<= PTR_TO_UINT64 (grub_autoefi_system_table)
|
||||
<= (grub_addr_t) grub_autoefi_system_table
|
||||
&& curdesc->physical_start + (curdesc->num_pages << 12)
|
||||
> PTR_TO_UINT64 (grub_autoefi_system_table))
|
||||
> (grub_addr_t) grub_autoefi_system_table)
|
||||
bootparams->efi_system_table
|
||||
= PTR_TO_UINT64 (grub_autoefi_system_table)
|
||||
= (grub_addr_t) grub_autoefi_system_table
|
||||
- curdesc->physical_start + curdesc->virtual_start;
|
||||
if (SIZEOF_OF_UINTN == 8 && grub_xnu_is_64bit)
|
||||
curdesc->virtual_start |= 0xffffff8000000000ULL;
|
||||
|
|
|
@ -54,7 +54,7 @@ grub_mmap_malign_and_register (grub_uint64_t align, grub_uint64_t size,
|
|||
{
|
||||
/* FIXME: use low-memory mm allocation once it's available. */
|
||||
grub_mmap_iterate (find_hook);
|
||||
ret = UINT_TO_PTR (highestlow);
|
||||
ret = (void *) (grub_addr_t) highestlow;
|
||||
}
|
||||
else
|
||||
ret = grub_memalign (align, size);
|
||||
|
@ -65,7 +65,7 @@ grub_mmap_malign_and_register (grub_uint64_t align, grub_uint64_t size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
*handle = grub_mmap_register (PTR_TO_UINT64 (ret), size, type);
|
||||
*handle = grub_mmap_register ((grub_addr_t) ret, size, type);
|
||||
if (! *handle)
|
||||
{
|
||||
grub_free (ret);
|
||||
|
@ -93,7 +93,7 @@ grub_mmap_free_and_unregister (int handle)
|
|||
grub_mmap_unregister (handle);
|
||||
|
||||
if (addr >= 0x100000)
|
||||
grub_free (UINT_TO_PTR (addr));
|
||||
grub_free ((void *) (grub_addr_t) addr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -101,8 +101,8 @@ preboot (int noreturn __attribute__ ((unused)))
|
|||
grub_memcpy (hooktarget, &grub_machine_mmaphook_start,
|
||||
&grub_machine_mmaphook_end - &grub_machine_mmaphook_start);
|
||||
|
||||
*((grub_uint16_t *) 0x4a) = PTR_TO_UINT32 (hooktarget) >> 4;
|
||||
*((grub_uint16_t *) 0x56) = PTR_TO_UINT32 (hooktarget) >> 4;
|
||||
*((grub_uint16_t *) 0x4a) = ((grub_addr_t) hooktarget) >> 4;
|
||||
*((grub_uint16_t *) 0x56) = ((grub_addr_t) hooktarget) >> 4;
|
||||
*((grub_uint16_t *) 0x48) = &grub_machine_mmaphook_int12
|
||||
- &grub_machine_mmaphook_start;
|
||||
*((grub_uint16_t *) 0x54) = &grub_machine_mmaphook_int15
|
||||
|
|
|
@ -114,9 +114,9 @@ extern grub_efi_system_table64_t *grub_efiemu_system_table64;
|
|||
: (grub_efiemu_system_table32->x \
|
||||
= (y)))
|
||||
#define GRUB_EFIEMU_SYSTEM_TABLE_PTR(x) ((grub_efiemu_sizeof_uintn_t () == 8)\
|
||||
? UINT_TO_PTR \
|
||||
? (void *) (grub_addr_t) \
|
||||
(grub_efiemu_system_table64->x) \
|
||||
: UINT_TO_PTR \
|
||||
: (void *) (grub_addr_t) \
|
||||
(grub_efiemu_system_table32->x))
|
||||
#define GRUB_EFIEMU_SYSTEM_TABLE_VAR(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
|
||||
? (void *) \
|
||||
|
|
|
@ -130,16 +130,6 @@ typedef grub_int32_t grub_ssize_t;
|
|||
# define GRUB_LONG_MIN (-2147483647L - 1)
|
||||
#endif
|
||||
|
||||
#if GRUB_CPU_SIZEOF_VOID_P == 4
|
||||
#define UINT_TO_PTR(x) ((void*)(grub_uint32_t)(x))
|
||||
#define PTR_TO_UINT64(x) ((grub_uint64_t)(grub_uint32_t)(x))
|
||||
#define PTR_TO_UINT32(x) ((grub_uint32_t)(x))
|
||||
#else
|
||||
#define UINT_TO_PTR(x) ((void*)(grub_uint64_t)(x))
|
||||
#define PTR_TO_UINT64(x) ((grub_uint64_t)(x))
|
||||
#define PTR_TO_UINT32(x) ((grub_uint32_t)(grub_uint64_t)(x))
|
||||
#endif
|
||||
|
||||
typedef grub_uint64_t grub_properly_aligned_t;
|
||||
|
||||
#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)]
|
||||
|
|
Loading…
Reference in a new issue