Author: afaerber Date: Mon Oct 25 22:48:45 2010 New Revision: 922 URL: http://tracker.coreboot.org/trac/openbios/changeset/922
Log: 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
Modified: trunk/openbios-devel/arch/ppc/qemu/kernel.c trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/arch/ppc/qemu/methods.c trunk/openbios-devel/arch/ppc/qemu/ofmem.c trunk/openbios-devel/drivers/adb_kbd.c trunk/openbios-devel/drivers/escc.c trunk/openbios-devel/drivers/ide.c trunk/openbios-devel/fs/ext2/ext2_fs.c trunk/openbios-devel/fs/grubfs/grubfs_fs.c trunk/openbios-devel/fs/hfs/hfs_fs.c trunk/openbios-devel/fs/hfsplus/hfsp_fs.c trunk/openbios-devel/fs/iso9660/iso9660_fs.c trunk/openbios-devel/kernel/internal.c trunk/openbios-devel/libc/diskio.c trunk/openbios-devel/libc/extra.c trunk/openbios-devel/libopenbios/bindings.c trunk/openbios-devel/libopenbios/bootinfo_load.c trunk/openbios-devel/libopenbios/elf_load.c trunk/openbios-devel/libopenbios/initprogram.c trunk/openbios-devel/libopenbios/ofmem_common.c trunk/openbios-devel/libopenbios/xcoff_load.c trunk/openbios-devel/packages/deblocker.c trunk/openbios-devel/packages/disk-label.c trunk/openbios-devel/packages/mac-parts.c trunk/openbios-devel/packages/nvram.c trunk/openbios-devel/packages/pc-parts.c trunk/openbios-devel/packages/video.c
Modified: trunk/openbios-devel/arch/ppc/qemu/kernel.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/kernel.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/arch/ppc/qemu/kernel.c Mon Oct 25 22:48:45 2010 (r922) @@ -40,13 +40,13 @@ { 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 @@ * to initialize the memory allocator */
- PUSH( (ucell)memory ); - PUSH( (ucell)memory + MEMORY_SIZE ); + PUSH( pointer2cell(memory) ); + PUSH( pointer2cell(memory) + MEMORY_SIZE ); }
int
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/main.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/arch/ppc/qemu/main.c Mon Oct 25 22:48:45 2010 (r922) @@ -183,7 +183,7 @@ 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) "
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/methods.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/arch/ppc/qemu/methods.c Mon Oct 25 22:48:45 2010 (r922) @@ -71,7 +71,7 @@ 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 @@ 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 );
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Mon Oct 25 22:48:45 2010 (r922) @@ -105,7 +105,7 @@
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)
Modified: trunk/openbios-devel/drivers/adb_kbd.c ============================================================================== --- trunk/openbios-devel/drivers/adb_kbd.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/drivers/adb_kbd.c Mon Oct 25 22:48:45 2010 (r922) @@ -556,7 +556,7 @@ char *addr; int len, key, i; len=POP(); - addr=(char *)POP(); + addr=(char *)cell2pointer(POP());
for (i = 0; i < len; i++) { key = adb_kbd_read(my_adb_dev);
Modified: trunk/openbios-devel/drivers/escc.c ============================================================================== --- trunk/openbios-devel/drivers/escc.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/drivers/escc.c Mon Oct 25 22:48:45 2010 (r922) @@ -137,7 +137,7 @@ int len;
len = POP(); - addr = (char *)POP(); + addr = (char *)cell2pointer(POP());
if (len < 1) printk("escc_read: bad len, addr %x len %x\n", (unsigned int)addr, len); @@ -158,7 +158,7 @@ int i, len;
len = POP(); - addr = (unsigned char *)POP(); + addr = (unsigned char *)cell2pointer(POP());
for (i = 0; i < len; i++) { uart_putchar(*address, addr[i]);
Modified: trunk/openbios-devel/drivers/ide.c ============================================================================== --- trunk/openbios-devel/drivers/ide.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/drivers/ide.c Mon Oct 25 22:48:45 2010 (r922) @@ -1190,7 +1190,7 @@ { cell n = POP(), cnt=n; ucell blk = POP(); - unsigned char *dest = (unsigned char *)POP(); + unsigned char *dest = (unsigned char *)cell2pointer(POP()); struct ide_drive *drive = *(struct ide_drive **)idx;
IDE_DPRINTF("ob_ide_read_blocks %lx block=%ld n=%ld\n",
Modified: trunk/openbios-devel/fs/ext2/ext2_fs.c ============================================================================== --- trunk/openbios-devel/fs/ext2/ext2_fs.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/fs/ext2/ext2_fs.c Mon Oct 25 22:48:45 2010 (r922) @@ -144,7 +144,7 @@ ext2_files_read( ext2_info_t *mi ) { int count = POP(); - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP());
ext2_COMMON *common = mi->common; if (common->type != FILE) @@ -177,7 +177,7 @@ static void ext2_files_load( ext2_info_t *mi ) { - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP()); int count;
ext2_COMMON *common = mi->common; @@ -201,14 +201,14 @@ if (common->type != FILE) RET( 0 );
- RET( (ucell) strdup(common->file->path) ); + RET( pointer2cell(strdup(common->file->path)) ); }
/* ( -- cstr ) */ static void ext2_files_get_fstype( ext2_info_t *mi ) { - PUSH( (ucell)strdup("ext2") ); + PUSH( pointer2cell(strdup("ext2")) ); }
/* static method, ( pathstr len ihandle -- ) */
Modified: trunk/openbios-devel/fs/grubfs/grubfs_fs.c ============================================================================== --- trunk/openbios-devel/fs/grubfs/grubfs_fs.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/fs/grubfs/grubfs_fs.c Mon Oct 25 22:48:45 2010 (r922) @@ -238,7 +238,7 @@ grubfs_files_read( grubfs_info_t *mi ) { int count = POP(); - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP());
grubfile_t *file = mi->gfs->fd; int ret; @@ -295,7 +295,7 @@ static void grubfs_files_load( grubfs_info_t *mi ) { - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP()); int count, ret;
grubfile_t *file = mi->gfs->fd; @@ -314,7 +314,7 @@ grubfile_t *file = mi->gfs->fd; const char *path = file->path;
- RET( (ucell) strdup(path) ); + RET( pointer2cell(strdup(path)) ); }
/* ( -- cstr ) */ @@ -323,7 +323,7 @@ { grubfs_t *gfs = mi->gfs;
- PUSH( (ucell)strdup(gfs->fsys->name) ); + PUSH( pointer2cell(strdup(gfs->fsys->name)) ); }
Modified: trunk/openbios-devel/fs/hfs/hfs_fs.c ============================================================================== --- trunk/openbios-devel/fs/hfs/hfs_fs.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/fs/hfs/hfs_fs.c Mon Oct 25 22:48:45 2010 (r922) @@ -359,7 +359,7 @@ hfs_files_read( hfs_info_t *mi ) { int count = POP(); - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP());
hfscommon *common = mi->common; if (common->type != FILE) @@ -402,7 +402,7 @@ static void hfs_files_load( hfs_info_t *mi ) { - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP()); int count;
hfscommon *common = mi->common; @@ -461,14 +461,14 @@ if( strlen(buf) >= sizeof(buf) ) RET( 0 );
- RET( (ucell) strdup(buf+start) ); + RET( pointer2cell(strdup(buf+start)) ); }
/* ( -- cstr ) */ static void hfs_files_get_fstype( hfs_info_t *mi ) { - PUSH( (ucell)strdup("HFS") ); + PUSH( pointer2cell(strdup("HFS")) ); }
/* ( -- cstr|0 ) */ @@ -486,7 +486,7 @@ volname[0] = '\0'; }
- PUSH ((ucell)volname); + PUSH(pointer2cell(volname)); }
/* static method, ( pathstr len ihandle -- ) */
Modified: trunk/openbios-devel/fs/hfsplus/hfsp_fs.c ============================================================================== --- trunk/openbios-devel/fs/hfsplus/hfsp_fs.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/fs/hfsplus/hfsp_fs.c Mon Oct 25 22:48:45 2010 (r922) @@ -264,7 +264,7 @@ hfsp_files_read( hfsp_info_t *mi ) { int count = POP(); - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP());
hfsp_file_t *t = mi->hfspfile; volume *vol = t->rec.tree->vol; @@ -350,7 +350,7 @@ static void hfsp_files_load( hfsp_info_t *mi ) { - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP());
hfsp_file_t *t = mi->hfspfile; volume *vol = t->rec.tree->vol; @@ -388,7 +388,7 @@ static void hfsp_files_get_fstype( hfsp_info_t *mi ) { - PUSH( (ucell)strdup("HFS+") ); + PUSH( pointer2cell(strdup("HFS+")) ); }
/* ( -- cstr ) */ @@ -405,7 +405,7 @@ strncpy( buf, t->path, strlen(t->path) ); buf[strlen(t->path)] = 0;
- PUSH ((ucell)buf); + PUSH(pointer2cell(buf)); }
/* ( -- success? ) */ @@ -434,7 +434,7 @@ volname[0] = '\0'; }
- PUSH ((ucell)volname); + PUSH(pointer2cell(volname)); }
/* static method, ( pathstr len ihandle -- ) */
Modified: trunk/openbios-devel/fs/iso9660/iso9660_fs.c ============================================================================== --- trunk/openbios-devel/fs/iso9660/iso9660_fs.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/fs/iso9660/iso9660_fs.c Mon Oct 25 22:48:45 2010 (r922) @@ -90,7 +90,7 @@ iso9660_files_read( iso9660_info_t *mi ) { int count = POP(); - char *buf = (char *)POP(); + char *buf = (char *)cell2pointer(POP()); int ret;
if ( mi->common->type != FILE ) @@ -137,7 +137,7 @@ static void iso9660_files_load( iso9660_info_t *mi) { - char *buf = (char*)POP(); + char *buf = (char*)cell2pointer(POP()); int ret, size;
if ( mi->common->type != FILE )
Modified: trunk/openbios-devel/kernel/internal.c ============================================================================== --- trunk/openbios-devel/kernel/internal.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/kernel/internal.c Mon Oct 25 22:48:45 2010 (r922) @@ -208,7 +208,7 @@ exit(1); #else void (*funcptr) (void); - funcptr=(void *)POP(); + funcptr=(void *)cell2pointer(POP()); dbg_interp_printk("call: %x", funcptr); funcptr(); #endif @@ -329,7 +329,7 @@ #ifndef FCOMPILER static ucell get_myself(void) { - static ucell **myself = NULL; + static ucell **myself = NULL; if( !myself ) myself = (ucell**)findword("my-self") + 1; return (*myself && **myself) ? (ucell)**myself : 0; @@ -337,35 +337,35 @@
static void doivar(void) { - ucell r, *p = (ucell *)(*(ucell *) PC + sizeof(ucell)); + ucell r, *p = (ucell *)(*(ucell *) cell2pointer(PC) + sizeof(ucell)); ucell ibase = get_myself();
dbg_interp_printk("ivar, offset: %d size: %d (ibase %d)\n", p[0], p[1], ibase );
- r = ibase ? ibase + p[0] : (ucell)&p[2]; + r = ibase ? ibase + p[0] : pointer2cell(&p[2]); PUSH( r ); }
static void doival(void) { - ucell r, *p = (ucell *)(*(ucell *) PC + sizeof(ucell)); + ucell r, *p = (ucell *)(*(ucell *) cell2pointer(PC) + sizeof(ucell)); ucell ibase = get_myself();
dbg_interp_printk("ivar, offset: %d size: %d\n", p[0], p[1] );
- r = ibase ? ibase + p[0] : (ucell)&p[2]; - PUSH( *(ucell *)r ); + r = ibase ? ibase + p[0] : pointer2cell(&p[2]); + PUSH( *(ucell *)cell2pointer(r) ); }
static void doidefer(void) { - ucell *p = (ucell *)(*(ucell *) PC + sizeof(ucell)); + ucell *p = (ucell *)(*(ucell *) cell2pointer(PC) + sizeof(ucell)); ucell ibase = get_myself();
dbg_interp_printk("doidefer, offset: %d size: %d\n", p[0], p[1] );
PUSHR(PC); - PC = ibase ? ibase + p[0] : (ucell)&p[2]; + PC = ibase ? ibase + p[0] : pointer2cell(&p[2]); PC -= sizeof(ucell); } #else
Modified: trunk/openbios-devel/libc/diskio.c ============================================================================== --- trunk/openbios-devel/libc/diskio.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libc/diskio.c Mon Oct 25 22:48:45 2010 (r922) @@ -150,7 +150,7 @@ if( lookup_xt(fdp->ih, "get-path", &fdp->get_path_xt) ) return NULL; call_package( fdp->get_path_xt, fdp->ih ); - return (char*)POP(); + return (char*)cell2pointer(POP()); }
const char * @@ -160,7 +160,7 @@ if( lookup_xt(fdp->ih, "volume-name", &fdp->volume_name_xt) ) return NULL; call_package( fdp->volume_name_xt, fdp->ih ); - return (char*)POP(); + return (char*)cell2pointer(POP()); }
const char * @@ -170,7 +170,7 @@ if( lookup_xt(fdp->ih, "get-fstype", &fdp->get_fstype_xt) ) return NULL; call_package( fdp->get_fstype_xt, fdp->ih ); - return (char*)POP(); + return (char*)cell2pointer(POP()); }
int @@ -183,7 +183,7 @@ if (fd != -1) { fdp = file_descriptors[fd];
- PUSH( (ucell)buf ); + PUSH( pointer2cell(buf) ); PUSH( cnt ); call_package( fdp->read_xt, fdp->ih ); ret = POP();
Modified: trunk/openbios-devel/libc/extra.c ============================================================================== --- trunk/openbios-devel/libc/extra.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libc/extra.c Mon Oct 25 22:48:45 2010 (r922) @@ -39,7 +39,7 @@ i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
- PUSH((ucell)buf); + PUSH(pointer2cell(buf)); PUSH(i); fword("type");
Modified: trunk/openbios-devel/libopenbios/bindings.c ============================================================================== --- trunk/openbios-devel/libopenbios/bindings.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/bindings.c Mon Oct 25 22:48:45 2010 (r922) @@ -28,7 +28,7 @@ void push_str( const char *str ) { - PUSH( (ucell)str ); + PUSH( pointer2cell(str) ); PUSH( str ? strlen(str) : 0 ); }
@@ -101,7 +101,7 @@ void bind_func( const char *name, void (*func)(void) ) { - PUSH( (ucell)func ); + PUSH( pointer2cell(func) ); push_str( name ); fword("is-cfunc"); } @@ -111,7 +111,7 @@ { PUSH_xt( xt ); PUSH( arg ); - PUSH( (cell)func ); + PUSH( pointer2cell(func) ); push_str( name ); fword("is-xt-cfunc"); } @@ -119,7 +119,7 @@ xt_t bind_noname_func( void (*func)(void) ) { - PUSH( (ucell)func ); + PUSH( pointer2cell(func) ); fword("is-noname-cfunc"); return POP_xt(); } @@ -249,7 +249,7 @@ pop_fstr_copy( void ) { int len = POP(); - char *str, *p = (char*)POP(); + char *str, *p = (char*)cell2pointer(POP()); if( !len ) return NULL; str = malloc( len + 1 ); @@ -279,7 +279,7 @@ printk("set_property: NULL phandle\n"); return; } - PUSH((ucell)buf); + PUSH(pointer2cell(buf)); PUSH(len); push_str( name ); PUSH_ph(ph); @@ -309,7 +309,7 @@ len = POP(); if( retlen ) *retlen = len; - return (char*)POP(); + return (char*)cell2pointer(POP()); }
u32 @@ -426,7 +426,7 @@ call1_func( void ) { void (*func)(cell v); - func = (void*)POP(); + func = (void*)cell2pointer(POP());
(*func)( POP() ); } @@ -455,7 +455,7 @@ char *buf = NULL; if( xt ) { enterforth( xt ); - buf = (char*)POP(); + buf = (char*)cell2pointer(POP()); } (*(initfunc)methods[i].func)( buf ); continue; @@ -463,7 +463,7 @@ if( !size ) bind_func( methods[i].name, methods[i].func ); else - bind_xtfunc( methods[i].name, xt, (ucell)methods[i].func, + bind_xtfunc( methods[i].name, xt, pointer2cell(methods[i].func), &call1_func ); }
Modified: trunk/openbios-devel/libopenbios/bootinfo_load.c ============================================================================== --- trunk/openbios-devel/libopenbios/bootinfo_load.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/bootinfo_load.c Mon Oct 25 22:48:45 2010 (r922) @@ -156,7 +156,7 @@ filename = get_filename(bootpath, &directory);
feval("load-base"); - base = (char*)POP(); + base = (char*)cell2pointer(POP());
feval("load-size"); size = POP();
Modified: trunk/openbios-devel/libopenbios/elf_load.c ============================================================================== --- trunk/openbios-devel/libopenbios/elf_load.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/elf_load.c Mon Oct 25 22:48:45 2010 (r922) @@ -478,12 +478,12 @@ Elf_phdr *phdr; size_t size, total_size = 0; char *addr; - cell tmp; + uintptr_t tmp;
/* TODO: manage ELF notes section */ feval("0 state-valid !"); feval("load-base"); - base = (char*)POP(); + base = (char*)cell2pointer(POP());
ehdr = (Elf_ehdr *)base;
Modified: trunk/openbios-devel/libopenbios/initprogram.c ============================================================================== --- trunk/openbios-devel/libopenbios/initprogram.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/initprogram.c Mon Oct 25 22:48:45 2010 (r922) @@ -41,42 +41,42 @@ addr = POP();
#ifdef CONFIG_LOADER_AOUT - if (is_aout((struct exec *)addr)) { + if (is_aout((struct exec *)cell2pointer(addr))) { aout_init_program(); return; } #endif
#ifdef CONFIG_LOADER_BOOTINFO - if (is_bootinfo((char *)addr)) { + if (is_bootinfo((char *)cell2pointer(addr))) { bootinfo_init_program(); return; } #endif
#ifdef CONFIG_LOADER_ELF - if (is_elf((Elf_ehdr *)addr)) { + if (is_elf((Elf_ehdr *)cell2pointer(addr))) { elf_init_program(); return; } #endif
#ifdef CONFIG_LOADER_FCODE - if (is_fcode((unsigned char *)addr)) { + if (is_fcode((unsigned char *)cell2pointer(addr))) { fcode_init_program(); return; } #endif
#ifdef CONFIG_LOADER_FORTH - if (is_forth((char *)addr)) { + if (is_forth((char *)cell2pointer(addr))) { forth_init_program(); return; } #endif
#ifdef CONFIG_LOADER_XCOFF - if (is_xcoff((COFF_filehdr_t *)addr)) { + if (is_xcoff((COFF_filehdr_t *)cell2pointer(addr))) { xcoff_init_program(); return; }
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/ofmem_common.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Mon Oct 25 22:48:45 2010 (r922) @@ -110,7 +110,7 @@
top = ofmem_arch_get_heap_top();
- if( (ucell)ofmem->next_malloc + size > top ) { + if( pointer2cell(ofmem->next_malloc) + size > top ) { printk("out of malloc memory (%x)!\n", size ); return NULL; } @@ -183,10 +183,9 @@ printk("ofmem_set_property: NULL phandle\n"); return; } - PUSH((ucell)buf); + PUSH(pointer2cell(buf)); PUSH(len); - PUSH((ucell)name); - PUSH(strlen(name)); + push_str(name); PUSH_ph(ph); fword("encode-property"); }
Modified: trunk/openbios-devel/libopenbios/xcoff_load.c ============================================================================== --- trunk/openbios-devel/libopenbios/xcoff_load.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/libopenbios/xcoff_load.c Mon Oct 25 22:48:45 2010 (r922) @@ -64,7 +64,7 @@ feval("0 state-valid !");
feval("load-base"); - base = (char*)POP(); + base = (char*)cell2pointer(POP());
fhdr = (COFF_filehdr_t*)base;
@@ -111,22 +111,22 @@
if (strcmp(shdr->s_name, ".text") == 0) {
- memcpy((char*)shdr->s_vaddr, base + shdr->s_scnptr, + memcpy((char*)(uintptr_t)shdr->s_vaddr, base + shdr->s_scnptr, shdr->s_size); total_size += shdr->s_size; #ifdef CONFIG_PPC - flush_icache_range((char*)shdr->s_vaddr, - (char*)(shdr->s_vaddr + shdr->s_size)); + flush_icache_range((char*)(uintptr_t)shdr->s_vaddr, + (char*)(uintptr_t)(shdr->s_vaddr + shdr->s_size)); #endif } else if (strcmp(shdr->s_name, ".data") == 0) {
- memcpy((char*)shdr->s_vaddr, base + shdr->s_scnptr, + memcpy((char*)(uintptr_t)shdr->s_vaddr, base + shdr->s_scnptr, shdr->s_size); total_size += shdr->s_size;
} else if (strcmp(shdr->s_name, ".bss") == 0) {
- memset((void *)shdr->s_vaddr, 0, shdr->s_size); + memset((void *)(uintptr_t)shdr->s_vaddr, 0, shdr->s_size); total_size += shdr->s_size; } else { DPRINTF(" Skip '%s' section\n", shdr->s_name); @@ -137,7 +137,7 @@ DPRINTF("XCOFF entry point: %x\n", *(uint32_t*)ahdr->entry);
// Initialise saved-program-state - PUSH(*(uint32_t*)ahdr->entry); + PUSH(*(uint32_t*)(uintptr_t)ahdr->entry); feval("saved-program-state >sps.entry !"); PUSH(total_size); feval("saved-program-state >sps.file-size !");
Modified: trunk/openbios-devel/packages/deblocker.c ============================================================================== --- trunk/openbios-devel/packages/deblocker.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/deblocker.c Mon Oct 25 22:48:45 2010 (r922) @@ -96,7 +96,7 @@
#define DO_IO( xt, buf, blk, n ) \ - ({ PUSH3((ucell)(buf), blk, n); call_parent(xt); POP(); }) + ({ PUSH3(pointer2cell(buf), blk, n); call_parent(xt); POP(); })
typedef struct { /* block operation */ @@ -141,7 +141,7 @@ do_readwrite( deblk_info_t *di, int is_write, xt_t xt ) { int blk, i, n, len = POP(); - char *dest = (char*)POP(); + char *dest = (char*)cell2pointer(POP()); int last=0, retlen=0; work_t w[3]; ducell mark = ((ducell)di->mark_hi << BITS) | di->mark_lo;
Modified: trunk/openbios-devel/packages/disk-label.c ============================================================================== --- trunk/openbios-devel/packages/disk-label.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/disk-label.c Mon Oct 25 22:48:45 2010 (r922) @@ -80,7 +80,7 @@ call_package(di->parent_seek_xt, my_parent()); POP();
- PUSH((ucell)block0); + PUSH(pointer2cell(block0)); PUSH(sizeof(block0)); call_package(di->parent_read_xt, my_parent()); status = POP(); @@ -88,7 +88,7 @@ goto out;
/* Find partition handler */ - PUSH( (ucell)block0 ); + PUSH( pointer2cell(block0) ); selfword("find-part-handler"); ph = POP_ph(); if( ph ) {
Modified: trunk/openbios-devel/packages/mac-parts.c ============================================================================== --- trunk/openbios-devel/packages/mac-parts.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/mac-parts.c Mon Oct 25 22:48:45 2010 (r922) @@ -42,7 +42,7 @@ DECLARE_NODE( macparts, INSTALL_OPEN, sizeof(macparts_info_t), "+/packages/mac-parts" );
#define SEEK( pos ) ({ DPUSH(pos); call_parent(di->seek_xt); POP(); }) -#define READ( buf, size ) ({ PUSH((ucell)buf); PUSH(size); call_parent(di->read_xt); POP(); }) +#define READ( buf, size ) ({ PUSH(pointer2cell(buf)); PUSH(size); call_parent(di->read_xt); POP(); })
/* ( open -- flag ) */ static void @@ -267,7 +267,7 @@ static void macparts_probe( macparts_info_t *dummy ) { - desc_map_t *dmap = (desc_map_t*)POP(); + desc_map_t *dmap = (desc_map_t*)cell2pointer(POP());
DPRINTF("macparts_probe %x ?= %x\n", dmap->sbSig, DESC_MAP_SIGNATURE); if( __be16_to_cpu(dmap->sbSig) != DESC_MAP_SIGNATURE )
Modified: trunk/openbios-devel/packages/nvram.c ============================================================================== --- trunk/openbios-devel/packages/nvram.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/nvram.c Mon Oct 25 22:48:45 2010 (r922) @@ -167,7 +167,7 @@ void update_nvram( void ) { - PUSH( (ucell)nvram.config->data ); + PUSH( pointer2cell(nvram.config->data) ); PUSH( nvram.config_size ); fword("nvram-store-configs"); arch_nvram_put( nvram.data ); @@ -202,7 +202,7 @@ nvram.config_size = nvpart_size(p) - 0x10;
if( !once++ ) { - PUSH( (ucell)p->data ); + PUSH( pointer2cell(p->data) ); PUSH( nvram.config_size ); fword("nvram-load-configs"); } @@ -256,7 +256,7 @@ nvram_read( nvram_ibuf_t *nd ) { int len = POP(); - char *p = (char*)POP(); + char *p = (char*)cell2pointer(POP()); int n=0;
while( nd->mark_lo < nvram.size && n < len ) { @@ -272,7 +272,7 @@ nvram_write( nvram_ibuf_t *nd ) { int len = POP(); - char *p = (char*)POP(); + char *p = (char*)cell2pointer(POP()); int n=0;
while( nd->mark_lo < nvram.size && n < len ) {
Modified: trunk/openbios-devel/packages/pc-parts.c ============================================================================== --- trunk/openbios-devel/packages/pc-parts.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/pc-parts.c Mon Oct 25 22:48:45 2010 (r922) @@ -38,7 +38,7 @@ DECLARE_NODE( pcparts, INSTALL_OPEN, sizeof(pcparts_info_t), "+/packages/pc-parts" );
#define SEEK( pos ) ({ DPUSH(pos); call_parent(di->seek_xt); POP(); }) -#define READ( buf, size ) ({ PUSH((ucell)buf); PUSH(size); call_parent(di->read_xt); POP(); }) +#define READ( buf, size ) ({ PUSH(pointer2cell(buf)); PUSH(size); call_parent(di->read_xt); POP(); })
/* three helper functions */
@@ -294,7 +294,7 @@ static void pcparts_probe( pcparts_info_t *dummy ) { - unsigned char *buf = (unsigned char *)POP(); + unsigned char *buf = (unsigned char *)cell2pointer(POP());
DPRINTF("probing for PC partitions\n");
Modified: trunk/openbios-devel/packages/video.c ============================================================================== --- trunk/openbios-devel/packages/video.c Mon Oct 25 21:26:40 2010 (r921) +++ trunk/openbios-devel/packages/video.c Mon Oct 25 22:48:45 2010 (r922) @@ -244,7 +244,7 @@ { int count = POP(); int start = POP(); - unsigned char *p = (unsigned char*)POP(); + unsigned char *p = (unsigned char*)cell2pointer(POP()); int i;
for( i=0; i<count; i++, p+=3 ) { @@ -289,7 +289,7 @@ int len;
len = POP(); - addr = (char *)POP(); + addr = (char *)cell2pointer(POP());
console_draw_fstr(addr, len); PUSH(len);