Don't assume that pointer and cell size are identical, part 1

On ppc64, cell size is 32 bits but pointers are 64-bit.
Thus, direct casts result in warnings, treated as errors.

Use [u]intptr_t cast or cell2pointer and pointer2cell macros as necessary.

v2:
* Drop changes related to physical addresses since physical addresses may be
  wider than pointers (e.g., 36 bits on sparc32, as pointed out by Blue).
* Drop changes to cell2pointer() and pointer2cell() for now.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@922 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Andreas Färber
2010-10-25 20:48:45 +00:00
committed by Andreas Färber
parent 28516584d1
commit 380cd335cc
27 changed files with 93 additions and 94 deletions

View File

@@ -40,13 +40,13 @@ forth_segv_handler( char *segv_addr )
{
ucell addr = 0xdeadbeef;
if( PC >= (ucell) dict && PC <= (ucell) dict + dicthead )
addr = *(ucell *) PC;
if( PC >= pointer2cell(dict) && PC <= pointer2cell(dict) + dicthead )
addr = *(ucell *)cell2pointer(PC);
printk("panic: segmentation violation at %x\n", (int)segv_addr);
printk("dict=0x%x here=0x%x(dict+0x%x) pc=0x%x(dict+0x%x)\n",
(int)dict, (int)(dict + dicthead), dicthead,
PC, PC - (ucell) dict);
printk("panic: segmentation violation at 0x%p\n", segv_addr);
printk("dict=0x%p here=0x%p(dict+0x%x) pc=0x%x(dict+0x%x)\n",
dict, (char*)dict + dicthead, dicthead,
PC, PC - pointer2cell(dict));
printk("dstackcnt=%d rstackcnt=%d instruction=%x\n",
dstackcnt, rstackcnt, addr);
@@ -75,8 +75,8 @@ init_memory( void )
* to initialize the memory allocator
*/
PUSH( (ucell)memory );
PUSH( (ucell)memory + MEMORY_SIZE );
PUSH( pointer2cell(memory) );
PUSH( pointer2cell(memory) + MEMORY_SIZE );
}
int

View File

@@ -183,7 +183,7 @@ static void check_preloaded_kernel(void)
kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
if (kernel_size) {
kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR);
kernel_cmdline = (const char *) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE);
kernel_cmdline = (const char *)(uintptr_t) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE);
initrd_image = fw_cfg_read_i32(FW_CFG_INITRD_ADDR);
initrd_size = fw_cfg_read_i32(FW_CFG_INITRD_SIZE);
printk("[ppc] Kernel already loaded (0x%8.8lx + 0x%8.8lx) "

View File

@@ -71,7 +71,7 @@ static void
tty_read( void )
{
int ch, len = POP();
char *p = (char*)POP();
char *p = (char*)cell2pointer(POP());
int ret=0;
if( len > 0 ) {
@@ -91,7 +91,7 @@ static void
tty_write( void )
{
int i, len = POP();
char *p = (char*)POP();
char *p = (char*)cell2pointer(POP());
for( i=0; i<len; i++ )
putchar( *p++ );
RET( len );

View File

@@ -105,7 +105,7 @@ static inline size_t ALIGN_SIZE(size_t x, size_t a)
ofmem_t* ofmem_arch_get_private(void)
{
return (ofmem_t*)(get_heap_top() - OFMEM_SIZE);
return (ofmem_t*)cell2pointer(get_heap_top() - OFMEM_SIZE);
}
void* ofmem_arch_get_malloc_base(void)