diff --git a/arch/ppc/qemu/kernel.c b/arch/ppc/qemu/kernel.c
index cafa167..c7ca2be 100644
--- a/arch/ppc/qemu/kernel.c
+++ b/arch/ppc/qemu/kernel.c
@@ -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 >= (ucell)(unsigned long) dict && PC <= (ucell)(unsigned long) dict + dicthead )
+		addr = *(ucell *)(unsigned long) 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 - (ucell)(unsigned long) 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( (ucell)(unsigned long)memory );
+	PUSH( (ucell)(unsigned long)memory + MEMORY_SIZE );
 }
 
 int
diff --git a/arch/ppc/qemu/main.c b/arch/ppc/qemu/main.c
index 2d4ae5a..10442ad 100644
--- a/arch/ppc/qemu/main.c
+++ b/arch/ppc/qemu/main.c
@@ -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 *)(addr_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) "
diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c
index bf65101..fd2ce3f 100644
--- a/arch/ppc/qemu/methods.c
+++ b/arch/ppc/qemu/methods.c
@@ -75,7 +75,7 @@ static void
 tty_read( void )
 {
 	int ch, len = POP();
-	char *p = (char*)POP();
+	char *p = (char*)(addr_t)POP();
 	int ret=0;
 
 	if( len > 0 ) {
@@ -95,7 +95,7 @@ static void
 tty_write( void )
 {
 	int i, len = POP();
-	char *p = (char*)POP();
+	char *p = (char*)(addr_t)POP();
 	for( i=0; i<len; i++ )
 		putchar( *p++ );
 	RET( len );
diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c
index 189dae3..3ba9dfb 100644
--- a/arch/ppc/qemu/ofmem.c
+++ b/arch/ppc/qemu/ofmem.c
@@ -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*)(addr_t)(get_heap_top() - OFMEM_SIZE);
 }
 
 void* ofmem_arch_get_malloc_base(void)
diff --git a/arch/ppc/qemu/rtas-tokens.c b/arch/ppc/qemu/rtas-tokens.c
index d9c3a48..95a9282 100644
--- a/arch/ppc/qemu/rtas-tokens.c
+++ b/arch/ppc/qemu/rtas-tokens.c
@@ -22,7 +22,7 @@ void rtas_interface(rtas_args_t*, void*);
 #define DATA(addr) (*(volatile unsigned char *)(addr + 16))
 #define Tx_BUF_EMP      0x4     /* Tx Buffer empty */
 
-static void uart_putchar(int port, unsigned char c)
+static void uart_putchar(long port, unsigned char c)
 {
     while (!(CTRL(port) & Tx_BUF_EMP))
         ;
@@ -33,7 +33,7 @@ static void serial_putchar(char c)
 {
 	unsigned long addr = 0x80800000;
 	volatile unsigned char *serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET + 0x20;
-	uart_putchar((int)serial_dev, c);
+	uart_putchar((long)serial_dev, c);
 }
 
 void dprintk(const char* s);
@@ -53,7 +53,7 @@ void rtas_interface(rtas_args_t* params, void* privateData)
 {
 	switch (params->token) {
 		case DISPLAY_CHARACTER: {
-			dprintk("display-character");
+			//dprintk("display-character");
 			serial_putchar((char)params->args[0]);
 			params->args[params->nargs] = 0;
 			break;
diff --git a/arch/ppc/qemu/start.S b/arch/ppc/qemu/start.S
index d9c61a7..617139a 100644
--- a/arch/ppc/qemu/start.S
+++ b/arch/ppc/qemu/start.S
@@ -207,6 +207,7 @@ VECTOR( 0x300, "DSI" ):
 	mtctr	r3
 	bctrl
 	ba	exception_return
+//	EXCEPTION_EPILOGUE
 
 VECTOR( 0x400, "ISI" ):
 	EXCEPTION_PREAMBLE
@@ -215,6 +216,7 @@ VECTOR( 0x400, "ISI" ):
 	mtctr	r3
 	bctrl
 	ba	exception_return
+//	EXCEPTION_EPILOGUE
 
 	ILLEGAL_VECTOR( 0x500 )
 	ILLEGAL_VECTOR( 0x600 )
diff --git a/arch/ppc64/qemu/ldscript b/arch/ppc64/qemu/ldscript
index 7a42c22..1d8aa8e 100644
--- a/arch/ppc64/qemu/ldscript
+++ b/arch/ppc64/qemu/ldscript
@@ -1,5 +1,5 @@
 OUTPUT_FORMAT(elf64-powerpc)
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common64)
 
 /* Initial load address
  */
diff --git a/arch/ppc64/qemu/rtas-ldscript b/arch/ppc64/qemu/rtas-ldscript
index 1f4973c..bfa29e7 100644
--- a/arch/ppc64/qemu/rtas-ldscript
+++ b/arch/ppc64/qemu/rtas-ldscript
@@ -1,5 +1,5 @@
 OUTPUT_FORMAT(binary)
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common64)
 
 SECTIONS
 {
diff --git a/drivers/adb_kbd.c b/drivers/adb_kbd.c
index e65ba71..ab875e0 100644
--- a/drivers/adb_kbd.c
+++ b/drivers/adb_kbd.c
@@ -483,7 +483,7 @@ static int adb_kbd_read (void *private)
     int key;
     int ret;
 
-    kbd = (void *)dev->state;
+    kbd = (void *)(unsigned long)dev->state;
 
     if (kbd->len > 0) {
         ret = kbd->sequence[kbd->len-- - 1];
@@ -531,7 +531,7 @@ void *adb_kbd_new (char *path, void *private)
 			ADB_kbd_us, ADB_sequences);
         kbd->next_key = -1;
         kbd->len = 0;
-	dev->state = (int32_t)kbd;
+	dev->state = (int32_t)(unsigned long)kbd;
 	my_adb_dev = dev;
     }
 
@@ -556,7 +556,7 @@ static void keyboard_read(void)
 	char *addr;
 	int len, key, i;
 	len=POP();
-	addr=(char *)POP();
+	addr=(char *)(unsigned long)POP();
 
 	for (i = 0; i < len; i++) {
 		key = adb_kbd_read(my_adb_dev);
diff --git a/drivers/cuda.c b/drivers/cuda.c
index 4c44b8f..51fd3f2 100644
--- a/drivers/cuda.c
+++ b/drivers/cuda.c
@@ -65,12 +65,12 @@
 
 static uint8_t cuda_readb (cuda_t *dev, int reg)
 {
-	    return *(volatile uint8_t *)(dev->base + reg);
+	    return *(volatile uint8_t *)(unsigned long)(dev->base + reg);
 }
 
 static void cuda_writeb (cuda_t *dev, int reg, uint8_t val)
 {
-	    *(volatile uint8_t *)(dev->base + reg) = val;
+	    *(volatile uint8_t *)(unsigned long)(dev->base + reg) = val;
 }
 
 static void cuda_wait_irq (cuda_t *dev)
diff --git a/drivers/escc.c b/drivers/escc.c
index dbf8262..aa54147 100644
--- a/drivers/escc.c
+++ b/drivers/escc.c
@@ -54,19 +54,19 @@ static volatile unsigned char *serial_dev;
 #define Rx_CH_AV        0x1     /* Rx Character Available */
 #define Tx_BUF_EMP      0x4     /* Tx Buffer empty */
 
-int uart_charav(int port)
+int uart_charav(addr_t port)
 {
     return (CTRL(port) & Rx_CH_AV) != 0;
 }
 
-char uart_getchar(int port)
+char uart_getchar(addr_t port)
 {
     while (!uart_charav(port))
         ;
     return DATA(port) & 0177;
 }
 
-static void uart_putchar(int port, unsigned char c)
+static void uart_putchar(addr_t port, unsigned char c)
 {
     if (!serial_dev)
         return;
@@ -114,9 +114,9 @@ int uart_init(uint64_t port, unsigned long speed)
     return -1;
 }
 
-void serial_putchar(int c)
+void serial_putchar(addr_t c)
 {
-    uart_putchar((int)serial_dev, (unsigned char) (c & 0xff));
+    uart_putchar((addr_t)serial_dev, (unsigned char) (c & 0xff));
 }
 
 void serial_cls(void)
@@ -137,10 +137,10 @@ escc_read(unsigned long *address)
     int len;
 
     len = POP();
-    addr = (char *)POP();
+    addr = (char *)(unsigned long)POP();
 
     if (len < 1)
-        printk("escc_read: bad len, addr %x len %x\n", (unsigned int)addr, len);
+        printk("escc_read: bad len, addr %lx len %x\n", (unsigned long)addr, len);
 
     if (uart_charav(*address)) {
         *addr = (char)uart_getchar(*address);
@@ -158,7 +158,7 @@ escc_write(unsigned long *address)
     int i, len;
 
     len = POP();
-    addr = (unsigned char *)POP();
+    addr = (unsigned char *)(unsigned long)POP();
 
     for (i = 0; i < len; i++) {
         uart_putchar(*address, addr[i]);
@@ -369,7 +369,7 @@ ob_zs_init(uint64_t base, uint64_t offset, int intr, int slave, int keyboard)
 #else
 
 static void
-escc_add_channel(const char *path, const char *node, uint32_t addr,
+escc_add_channel(const char *path, const char *node, addr_t addr,
                  uint32_t offset)
 {
     char buf[64], tty[32];
@@ -430,7 +430,7 @@ escc_add_channel(const char *path, const char *node, uint32_t addr,
 }
 
 void
-escc_init(const char *path, unsigned long addr)
+escc_init(const char *path, addr_t addr)
 {
     char buf[64];
     int props[2];
diff --git a/drivers/ide.c b/drivers/ide.c
index 7006720..76cb7fb 100644
--- a/drivers/ide.c
+++ b/drivers/ide.c
@@ -1190,7 +1190,7 @@ ob_ide_read_blocks(int *idx)
 {
 	cell n = POP(), cnt=n;
 	ucell blk = POP();
-        unsigned char *dest = (unsigned char *)POP();
+        unsigned char *dest = (unsigned char *)(unsigned long)POP();
 	struct ide_drive *drive = *(struct ide_drive **)idx;
 
         IDE_DPRINTF("ob_ide_read_blocks %lx block=%ld n=%ld\n",
diff --git a/drivers/macio.c b/drivers/macio.c
index 022dd67..d52e0b2 100644
--- a/drivers/macio.c
+++ b/drivers/macio.c
@@ -43,7 +43,7 @@ arch_nvram_size( void )
                 return NW_IO_NVRAM_SIZE >> NW_IO_NVRAM_SHIFT;
 }
 
-void macio_nvram_init(const char *path, uint32_t addr)
+void macio_nvram_init(const char *path, addr_t addr)
 {
 	phandle_t chosen, aliases;
 	phandle_t dnode;
@@ -145,7 +145,7 @@ arch_nvram_get( char *buf )
 }
 
 static void
-openpic_init(const char *path, uint32_t addr)
+openpic_init(const char *path, addr_t addr)
 {
         phandle_t target_node;
         phandle_t dnode;
@@ -238,7 +238,7 @@ NODE_METHODS(ob_macio) = {
 };
 
 void
-ob_macio_heathrow_init(const char *path, uint32_t addr)
+ob_macio_heathrow_init(const char *path, addr_t addr)
 {
         phandle_t aliases;
 
@@ -253,7 +253,7 @@ ob_macio_heathrow_init(const char *path, uint32_t addr)
 }
 
 void
-ob_macio_keylargo_init(const char *path, uint32_t addr)
+ob_macio_keylargo_init(const char *path, addr_t addr)
 {
         phandle_t aliases;
 
diff --git a/drivers/macio.h b/drivers/macio.h
index d580387..cddc01f 100644
--- a/drivers/macio.h
+++ b/drivers/macio.h
@@ -1,5 +1,5 @@
 extern phandle_t pic_handle;
 
-void ob_macio_heathrow_init(const char *path, uint32_t addr);
-void ob_macio_keylargo_init(const char *path, uint32_t addr);
-void macio_nvram_init(const char *path, uint32_t addr);
+void ob_macio_heathrow_init(const char *path, addr_t addr);
+void ob_macio_keylargo_init(const char *path, addr_t addr);
+void macio_nvram_init(const char *path, addr_t addr);
diff --git a/fs/ext2/ext2_fs.c b/fs/ext2/ext2_fs.c
index 970fb4d..8c3c639 100644
--- a/fs/ext2/ext2_fs.c
+++ b/fs/ext2/ext2_fs.c
@@ -144,7 +144,7 @@ static void
 ext2_files_read( ext2_info_t *mi )
 {
 	int count = POP();
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 
 	ext2_COMMON *common = mi->common;
 	if (common->type != FILE)
@@ -177,7 +177,7 @@ ext2_files_seek( ext2_info_t *mi )
 static void
 ext2_files_load( ext2_info_t *mi )
 {
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 	int count;
 
 	ext2_COMMON *common = mi->common;
@@ -201,14 +201,14 @@ ext2_files_get_path( ext2_info_t *mi )
 	if (common->type != FILE)
 		RET( 0 );
 
-	RET( (ucell) strdup(common->file->path) );
+	RET( (ucell)(unsigned long) strdup(common->file->path) );
 }
 
 /* ( -- cstr ) */
 static void
 ext2_files_get_fstype( ext2_info_t *mi )
 {
-	PUSH( (ucell)strdup("ext2") );
+	PUSH( (ucell)(unsigned long)strdup("ext2") );
 }
 
 /* static method, ( pathstr len ihandle -- ) */
diff --git a/fs/grubfs/grubfs_fs.c b/fs/grubfs/grubfs_fs.c
index fc61943..984b159 100644
--- a/fs/grubfs/grubfs_fs.c
+++ b/fs/grubfs/grubfs_fs.c
@@ -238,7 +238,7 @@ static void
 grubfs_files_read( grubfs_info_t *mi )
 {
 	int count = POP();
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 
 	grubfile_t *file = mi->gfs->fd;
         int ret;
@@ -295,7 +295,7 @@ grubfs_files_seek( grubfs_info_t *mi )
 static void
 grubfs_files_load( grubfs_info_t *mi )
 {
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 	int count, ret;
 
 	grubfile_t *file = mi->gfs->fd;
@@ -314,7 +314,7 @@ grubfs_files_get_path( grubfs_info_t *mi )
 	grubfile_t *file = mi->gfs->fd;
 	const char *path = file->path;
 
-	RET( (ucell) strdup(path) );
+	RET( (ucell)(unsigned long) strdup(path) );
 }
 
 /* ( -- cstr ) */
@@ -323,7 +323,7 @@ grubfs_files_get_fstype( grubfs_info_t *mi )
 {
 	grubfs_t *gfs = mi->gfs;
 
-	PUSH( (ucell)strdup(gfs->fsys->name) );
+	PUSH( (ucell)(unsigned long)strdup(gfs->fsys->name) );
 }
 
 
diff --git a/fs/hfs/hfs_fs.c b/fs/hfs/hfs_fs.c
index 293dc18..fbc962f 100644
--- a/fs/hfs/hfs_fs.c
+++ b/fs/hfs/hfs_fs.c
@@ -359,7 +359,7 @@ static void
 hfs_files_read( hfs_info_t *mi )
 {
 	int count = POP();
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 
 	hfscommon *common = mi->common;
 	if (common->type != FILE)
@@ -402,7 +402,7 @@ hfs_files_seek( hfs_info_t *mi )
 static void
 hfs_files_load( hfs_info_t *mi )
 {
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 	int count;
 
 	hfscommon *common = mi->common;
@@ -461,14 +461,14 @@ hfs_files_get_path( hfs_info_t *mi )
 	if( strlen(buf) >= sizeof(buf) )
 		RET( 0 );
 
-	RET( (ucell) strdup(buf+start) );
+	RET( (ucell)(unsigned long) strdup(buf+start) );
 }
 
 /* ( -- cstr ) */
 static void
 hfs_files_get_fstype( hfs_info_t *mi )
 {
-	PUSH( (ucell)strdup("HFS") );
+	PUSH( (ucell)(unsigned long)strdup("HFS") );
 }
 
 /* ( -- cstr|0 ) */
@@ -486,7 +486,7 @@ hfs_files_volume_name( hfs_info_t *mi )
                 volname[0] = '\0';
         }
 
-	PUSH ((ucell)volname);
+	PUSH ((ucell)(unsigned long)volname);
 }
 
 /* static method, ( pathstr len ihandle -- ) */
diff --git a/fs/hfsplus/hfsp_fs.c b/fs/hfsplus/hfsp_fs.c
index 9c3deb3..5db3781 100644
--- a/fs/hfsplus/hfsp_fs.c
+++ b/fs/hfsplus/hfsp_fs.c
@@ -264,7 +264,7 @@ static void
 hfsp_files_read( hfsp_info_t *mi )
 {
 	int count = POP();
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 
 	hfsp_file_t *t = mi->hfspfile;
 	volume *vol = t->rec.tree->vol;
@@ -350,7 +350,7 @@ hfsp_files_seek( hfsp_info_t *mi )
 static void
 hfsp_files_load( hfsp_info_t *mi )
 {
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 
 	hfsp_file_t *t = mi->hfspfile;
 	volume *vol = t->rec.tree->vol;
@@ -388,7 +388,7 @@ hfsp_files_load( hfsp_info_t *mi )
 static void
 hfsp_files_get_fstype( hfsp_info_t *mi )
 {
-	PUSH( (ucell)strdup("HFS+") );
+	PUSH( (ucell)(unsigned long)strdup("HFS+") );
 }
 
 /* ( -- cstr ) */
@@ -405,7 +405,7 @@ hfsp_files_get_path( hfsp_info_t *mi )
 	strncpy( buf, t->path, strlen(t->path) );
 	buf[strlen(t->path)] = 0;
 
-	PUSH ((ucell)buf);
+	PUSH ((ucell)(unsigned long)buf);
 }
 
 /* ( -- success? ) */
@@ -434,7 +434,7 @@ hfsp_files_volume_name( hfsp_info_t *mi )
                 volname[0] = '\0';
         }
 
-	PUSH ((ucell)volname);
+	PUSH ((ucell)(unsigned long)volname);
 }
 
 /* static method, ( pathstr len ihandle -- ) */
diff --git a/fs/iso9660/iso9660_fs.c b/fs/iso9660/iso9660_fs.c
index 3fb5c16..0b435c7 100644
--- a/fs/iso9660/iso9660_fs.c
+++ b/fs/iso9660/iso9660_fs.c
@@ -90,7 +90,7 @@ static void
 iso9660_files_read( iso9660_info_t *mi )
 {
 	int count = POP();
-	char *buf = (char *)POP();
+	char *buf = (char *)(unsigned long)POP();
 	int ret;
  
 	if ( mi->common->type != FILE )
@@ -137,7 +137,7 @@ iso9660_files_offset( iso9660_info_t *mi )
 static void
 iso9660_files_load( iso9660_info_t *mi)
 {
-	char *buf = (char*)POP();
+	char *buf = (char*)(unsigned long)POP();
 	int ret, size;
  
 	if ( mi->common->type != FILE )
diff --git a/include/arch/ppc/io.h b/include/arch/ppc/io.h
index d7c78a0..dda3a4f 100644
--- a/include/arch/ppc/io.h
+++ b/include/arch/ppc/io.h
@@ -22,15 +22,15 @@ extern uint32_t isa_io_base;
  * are arrays of bytes, and byte-swapping is not appropriate in
  * that case.  - paulus
  */
-#define insw(port, buf, ns)	_insw((uint16_t *)((port)+isa_io_base), (buf), (ns))
-#define outsw(port, buf, ns)	_outsw((uint16_t *)((port)+isa_io_base), (buf), (ns))
-
-#define inb(port)		in_8((uint8_t *)((port)+isa_io_base))
-#define outb(val, port)		out_8((uint8_t *)((port)+isa_io_base), (val))
-#define inw(port)		in_le16((uint16_t *)((port)+isa_io_base))
-#define outw(val, port)		out_le16((uint16_t *)((port)+isa_io_base), (val))
-#define inl(port)		in_le32((uint32_t *)((port)+isa_io_base))
-#define outl(val, port)		out_le32((uint32_t *)((port)+isa_io_base), (val))
+#define insw(port, buf, ns)	_insw((uint16_t *)(unsigned long)((port)+isa_io_base), (buf), (ns))
+#define outsw(port, buf, ns)	_outsw((uint16_t *)(unsigned long)((port)+isa_io_base), (buf), (ns))
+
+#define inb(port)		in_8((uint8_t *)(unsigned long)((port)+isa_io_base))
+#define outb(val, port)		out_8((uint8_t *)(unsigned long)((port)+isa_io_base), (val))
+#define inw(port)		in_le16((uint16_t *)(unsigned long)((port)+isa_io_base))
+#define outw(val, port)		out_le16((uint16_t *)(unsigned long)((port)+isa_io_base), (val))
+#define inl(port)		in_le32((uint32_t *)(unsigned long)((port)+isa_io_base))
+#define outl(val, port)		out_le32((uint32_t *)(unsigned long)((port)+isa_io_base), (val))
 
 /*
  * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
diff --git a/include/arch/ppc/types.h b/include/arch/ppc/types.h
index cb999dc..49e0e6b 100644
--- a/include/arch/ppc/types.h
+++ b/include/arch/ppc/types.h
@@ -35,6 +35,8 @@ typedef uint32_t	ucell;
 typedef int64_t		dcell;
 typedef uint64_t	ducell;
 
+typedef unsigned long addr_t;
+
 #define FMT_cell    "%d"
 #define FMT_ucell   "%u"
 #define FMT_ucellx  "%08x"
@@ -47,7 +49,11 @@ typedef uint64_t	ducell;
 #define bitspercell	(sizeof(cell)<<3)
 #define bitsperdcell	(sizeof(dcell)<<3)
 
+#ifdef __powerpc64__
+#define BITS		32
+#else
 #define BITS		32
+#endif
 
 /* size named types */
 
diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h
index 0a44063..2341f69 100644
--- a/include/drivers/drivers.h
+++ b/include/drivers/drivers.h
@@ -119,9 +119,9 @@ void serial_putchar(int c);
 #endif
 #ifdef CONFIG_DRIVER_ESCC
 int uart_init(uint64_t port, unsigned long speed);
-int uart_charav(int port);
-char uart_getchar(int port);
-void serial_putchar(int c);
+int uart_charav(addr_t port);
+char uart_getchar(addr_t port);
+void serial_putchar(addr_t c);
 void serial_cls(void);
 #ifdef CONFIG_DRIVER_ESCC_SUN
 int keyboard_dataready(void);
diff --git a/kernel/cross.h b/kernel/cross.h
index d4cfff1..6ea65c8 100644
--- a/kernel/cross.h
+++ b/kernel/cross.h
@@ -103,8 +103,8 @@
 /* bit width handling */
 
 #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
-#define pointer2cell(x) ((ucell)(x))
-#define cell2pointer(x) ((u8 *)(x))
+#define pointer2cell(x) ((ucell)(unsigned long)(x))
+#define cell2pointer(x) ((u8 *)(unsigned long)(x))
 #if BITS==32
 #define FMT_CELL_x "x"
 #define FMT_CELL_d "d"
diff --git a/kernel/internal.c b/kernel/internal.c
index be1f216..bc928bf 100644
--- a/kernel/internal.c
+++ b/kernel/internal.c
@@ -50,7 +50,7 @@ char xtname[MAXNFALEN];
 /* instead of pointing to an explicit 0 variable we
  * point behind the pointer.
  */
-static ucell t[] = { DOCOL, 0, (ucell)(t+3), 0 };
+static ucell t[] = { DOCOL, 0, /*(ucell)(t+3)*/0, 0 };
 static ucell *trampoline = t;
 #endif
 
@@ -208,7 +208,7 @@ static void call(void)
 	exit(1);
 #else
 	void (*funcptr) (void);
-	funcptr=(void *)POP();
+	funcptr=(void *)cell2pointer(POP());
 	dbg_interp_printk("call: %x", funcptr);
 	funcptr();
 #endif
@@ -329,43 +329,51 @@ static void doplusloop(void)
 #ifndef FCOMPILER
 static ucell get_myself(void)
 {
-        static ucell **myself = NULL;
+#ifdef __powerpc64__
+	static ucell *myself_ptr = NULL;
+	if (myself_ptr == NULL)
+		myself_ptr = (ucell *)cell2pointer(findword("my-self")) + 1;
+	ucell *myself = (ucell *)cell2pointer(*myself_ptr);
+	return (myself != NULL) ? *myself : 0;
+#else
+	static ucell **myself = NULL;
 	if( !myself )
 		myself = (ucell**)findword("my-self") + 1;
 	return (*myself && **myself) ? (ucell)**myself : 0;
+#endif
 }
 
 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] : (ucell)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] : (ucell)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] : (ucell)pointer2cell(&p[2]);
 	PC -= sizeof(ucell);
 }
 #else
diff --git a/libc/diskio.c b/libc/diskio.c
index 9f0fd0a..2fea7a5 100644
--- a/libc/diskio.c
+++ b/libc/diskio.c
@@ -150,7 +150,7 @@ get_file_path( int fd )
 	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*)(unsigned long)POP();
 }
 
 const char *
@@ -160,7 +160,7 @@ get_volume_name( int fd )
 	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*)(unsigned long)POP();
 }
 
 const char *
@@ -170,7 +170,7 @@ get_fstype( int fd )
 	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*)(unsigned long)POP();
 }
 
 int
@@ -183,7 +183,7 @@ read_io( int fd, void *buf, size_t cnt )
 	if (fd != -1) {
 		fdp = file_descriptors[fd];
 
-		PUSH( (ucell)buf );
+		PUSH( (ucell)(unsigned long)buf );
 		PUSH( cnt );
 		call_package( fdp->read_xt, fdp->ih );
 		ret = POP();
diff --git a/libc/extra.c b/libc/extra.c
index 5823afb..6fa02a7 100644
--- a/libc/extra.c
+++ b/libc/extra.c
@@ -39,7 +39,7 @@ int forth_printf( const char *fmt, ... )
 	i = vsnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 
-	PUSH((ucell)buf);
+	PUSH((ucell)(unsigned long)buf);
 	PUSH(i);
 	fword("type");
 
diff --git a/libopenbios/bindings.c b/libopenbios/bindings.c
index f6bc8de..64bbc01 100644
--- a/libopenbios/bindings.c
+++ b/libopenbios/bindings.c
@@ -20,6 +20,8 @@
 #include "libc/stdlib.h"
 #include "libc/byteorder.h"
 
+#define pointer2cell(x) ((ucell)(unsigned long)(x))
+#define cell2pointer(x) ((void*)(unsigned long)(x))
 
 /************************************************************************/
 /*	forth interface glue						*/
@@ -28,7 +30,7 @@
 void
 push_str( const char *str )
 {
-	PUSH( (ucell)str );
+	PUSH( (ucell)pointer2cell(str) );
 	PUSH( str ? strlen(str) : 0 );
 }
 
@@ -101,7 +103,7 @@ _parword( const char *method, xt_t *cache_xt )
 void
 bind_func( const char *name, void (*func)(void) )
 {
-	PUSH( (ucell)func );
+	PUSH( (ucell)pointer2cell(func) );
 	push_str( name );
 	fword("is-cfunc");
 }
@@ -111,7 +113,7 @@ bind_xtfunc( const char *name, xt_t xt, ucell arg, void (*func)(void) )
 {
 	PUSH_xt( xt );
 	PUSH( arg );
-	PUSH( (cell)func );
+	PUSH( (cell)pointer2cell(func) );
 	push_str( name );
 	fword("is-xt-cfunc");
 }
@@ -119,7 +121,7 @@ bind_xtfunc( const char *name, xt_t xt, ucell arg, void (*func)(void) )
 xt_t
 bind_noname_func( void (*func)(void) )
 {
-	PUSH( (ucell)func );
+	PUSH( (ucell)pointer2cell(func) );
 	fword("is-noname-cfunc");
 	return POP_xt();
 }
@@ -249,7 +251,7 @@ char *
 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 +281,7 @@ set_property( phandle_t ph, const char *name, const char *buf, int len )
 		printk("set_property: NULL phandle\n");
 		return;
 	}
-	PUSH((ucell)buf);
+	PUSH((ucell)pointer2cell(buf));
 	PUSH(len);
 	push_str( name );
 	PUSH_ph(ph);
@@ -309,7 +311,7 @@ get_property( phandle_t ph, const char *name, int *retlen )
 	len = POP();
 	if( retlen )
 		*retlen = len;
-	return (char*)POP();
+	return (char*)cell2pointer(POP());
 }
 
 u32
@@ -426,7 +428,7 @@ static void
 call1_func( void )
 {
 	void (*func)(cell v);
-	func = (void*)POP();
+	func = (void*)cell2pointer(POP());
 
 	(*func)( POP() );
 }
@@ -455,7 +457,7 @@ add_methods( int flags, int size, const method_t *methods, int nmet )
 			char *buf = NULL;
 			if( xt ) {
 				enterforth( xt );
-				buf = (char*)POP();
+				buf = (char*)cell2pointer(POP());
 			}
 			(*(initfunc)methods[i].func)( buf );
 			continue;
@@ -463,7 +465,7 @@ add_methods( int flags, int size, const method_t *methods, int nmet )
 		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, (ucell)pointer2cell(methods[i].func),
 				     &call1_func );
 	}
 
diff --git a/libopenbios/bootinfo_load.c b/libopenbios/bootinfo_load.c
index ceabdeb..1397282 100644
--- a/libopenbios/bootinfo_load.c
+++ b/libopenbios/bootinfo_load.c
@@ -156,7 +156,7 @@ bootinfo_init_program(void)
 	filename = get_filename(bootpath, &directory);
 
 	feval("load-base");
-	base = (char*)POP();
+	base = (char*)(unsigned long)POP();
 
 	feval("load-size");
 	size = POP();
diff --git a/libopenbios/elf_load.c b/libopenbios/elf_load.c
index 36ae449..a67ee2e 100644
--- a/libopenbios/elf_load.c
+++ b/libopenbios/elf_load.c
@@ -478,12 +478,12 @@ elf_init_program(void)
 	Elf_phdr *phdr;
 	size_t size, total_size = 0;
 	char *addr;
-	cell tmp;
+	unsigned long tmp;
 
 	/* TODO: manage ELF notes section */
 	feval("0 state-valid !");
 	feval("load-base");
-	base = (char*)POP();
+	base = (char*)(unsigned long)POP();
 
 	ehdr = (Elf_ehdr *)base;
 
diff --git a/libopenbios/initprogram.c b/libopenbios/initprogram.c
index 01be705..3aad3e5 100644
--- a/libopenbios/initprogram.c
+++ b/libopenbios/initprogram.c
@@ -30,6 +30,7 @@
 #include "libopenbios/forth_load.h"
 #include "libopenbios/xcoff_load.h"
 
+#define cell2pointer(x) ((void*)(unsigned long)(x))
 
 void init_program(void)
 {
@@ -41,42 +42,42 @@ void init_program(void)
 	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;
 	}
diff --git a/libopenbios/ofmem_common.c b/libopenbios/ofmem_common.c
index aacfb06..fad37f8 100644
--- a/libopenbios/ofmem_common.c
+++ b/libopenbios/ofmem_common.c
@@ -110,7 +110,7 @@ void* ofmem_malloc( size_t size )
 
 	top = ofmem_arch_get_heap_top();
 
-	if( (ucell)ofmem->next_malloc + size > top ) {
+	if( (ucell)(unsigned long)ofmem->next_malloc + size > top ) {
 		printk("out of malloc memory (%x)!\n", size );
 		return NULL;
 	}
@@ -183,9 +183,9 @@ ofmem_set_property( phandle_t ph, const char *name, const char *buf, int len )
 		printk("ofmem_set_property: NULL phandle\n");
 		return;
 	}
-	PUSH((ucell)buf);
+	PUSH((ucell)(unsigned long)buf);
 	PUSH(len);
-	PUSH((ucell)name);
+	PUSH((ucell)(unsigned long)name);
 	PUSH(strlen(name));
 	PUSH_ph(ph);
 	fword("encode-property");
diff --git a/libopenbios/xcoff_load.c b/libopenbios/xcoff_load.c
index 9868463..edd1f63 100644
--- a/libopenbios/xcoff_load.c
+++ b/libopenbios/xcoff_load.c
@@ -34,6 +34,8 @@ extern void             flush_icache_range( char *start, char *stop );
     do { } while (0)
 #endif
 
+#define cell2pointer(x) ((void*)(unsigned long)(x))
+
 int 
 is_xcoff(COFF_filehdr_t *fhdr)
 {
@@ -64,7 +66,7 @@ xcoff_init_program(void)
 	feval("0 state-valid !");
 
 	feval("load-base");
-	base = (char*)POP();
+	base = (char*)cell2pointer(POP());
 
 	fhdr = (COFF_filehdr_t*)base;
 
@@ -111,22 +113,22 @@ xcoff_init_program(void)
 
 		if (strcmp(shdr->s_name, ".text") == 0) {
 
-			memcpy((char*)shdr->s_vaddr, base + shdr->s_scnptr,
+			memcpy((char*)(unsigned long)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*)(unsigned long)shdr->s_vaddr,
+					 (char*)(unsigned long)(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*)(unsigned long)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 *)(unsigned long)shdr->s_vaddr, 0, shdr->s_size);
 			total_size += shdr->s_size;
 		} else {
 			DPRINTF("    Skip '%s' section\n", shdr->s_name);
@@ -137,7 +139,7 @@ xcoff_init_program(void)
 	DPRINTF("XCOFF entry point: %x\n", *(uint32_t*)ahdr->entry);
 
 	// Initialise saved-program-state
-	PUSH(*(uint32_t*)ahdr->entry);
+	PUSH(*(uint32_t*)(unsigned long)ahdr->entry);
 	feval("saved-program-state >sps.entry !");
 	PUSH(total_size);
 	feval("saved-program-state >sps.file-size !");
diff --git a/packages/deblocker.c b/packages/deblocker.c
index db66d12..60ab727 100644
--- a/packages/deblocker.c
+++ b/packages/deblocker.c
@@ -96,7 +96,7 @@ deblk_tell( deblk_info_t *di )
 
 
 #define DO_IO( xt, buf, blk, n )	\
-	({ PUSH3((ucell)(buf), blk, n); call_parent(xt); POP(); })
+	({ PUSH3((ucell)(unsigned long)(buf), blk, n); call_parent(xt); POP(); })
 
 typedef struct {
 	/* block operation */
@@ -141,7 +141,7 @@ static int
 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*)(unsigned long)POP();
 	int last=0, retlen=0;
 	work_t w[3];
 	ducell mark = ((ducell)di->mark_hi << BITS) | di->mark_lo;
diff --git a/packages/disk-label.c b/packages/disk-label.c
index c7b894a..ea2eef2 100644
--- a/packages/disk-label.c
+++ b/packages/disk-label.c
@@ -80,7 +80,7 @@ dlabel_open( dlabel_info_t *di )
 	call_package(di->parent_seek_xt, my_parent());
 	POP();
 
-	PUSH((ucell)block0);
+	PUSH((ucell)(unsigned long)block0);
 	PUSH(sizeof(block0));
 	call_package(di->parent_read_xt, my_parent());
 	status = POP();
@@ -88,7 +88,7 @@ dlabel_open( dlabel_info_t *di )
 		goto out;
 
 	/* Find partition handler */
-	PUSH( (ucell)block0 );
+	PUSH( (ucell)(unsigned long)block0 );
 	selfword("find-part-handler");
 	ph = POP_ph();
 	if( ph ) {
diff --git a/packages/mac-parts.c b/packages/mac-parts.c
index ee28ce8..0f3a68d 100644
--- a/packages/mac-parts.c
+++ b/packages/mac-parts.c
@@ -42,7 +42,7 @@ typedef struct {
 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((ucell)(unsigned long)buf); PUSH(size); call_parent(di->read_xt); POP(); })
 
 /* ( open -- flag ) */
 static void
@@ -267,7 +267,7 @@ out:
 static void
 macparts_probe( macparts_info_t *dummy )
 {
-	desc_map_t *dmap = (desc_map_t*)POP();
+	desc_map_t *dmap = (desc_map_t*)(unsigned long)POP();
 
 	DPRINTF("macparts_probe %x ?= %x\n", dmap->sbSig, DESC_MAP_SIGNATURE);
 	if( __be16_to_cpu(dmap->sbSig) != DESC_MAP_SIGNATURE )
diff --git a/packages/nvram.c b/packages/nvram.c
index 4052655..8c0504c 100644
--- a/packages/nvram.c
+++ b/packages/nvram.c
@@ -167,7 +167,7 @@ show_partitions( void )
 void
 update_nvram( void )
 {
-	PUSH( (ucell)nvram.config->data );
+	PUSH( (ucell)(unsigned long)nvram.config->data );
 	PUSH( nvram.config_size );
 	fword("nvram-store-configs");
 	arch_nvram_put( nvram.data );
@@ -202,7 +202,7 @@ nvconf_init( void )
 				nvram.config_size = nvpart_size(p) - 0x10;
 
 				if( !once++ ) {
-					PUSH( (ucell)p->data );
+					PUSH( (ucell)(unsigned long)p->data );
 					PUSH( nvram.config_size );
 					fword("nvram-load-configs");
 				}
@@ -256,7 +256,7 @@ static void
 nvram_read( nvram_ibuf_t *nd )
 {
 	int len = POP();
-	char *p = (char*)POP();
+	char *p = (char*)(unsigned long)POP();
 	int n=0;
 
 	while( nd->mark_lo < nvram.size && n < len ) {
@@ -272,7 +272,7 @@ static void
 nvram_write( nvram_ibuf_t *nd )
 {
 	int len = POP();
-	char *p = (char*)POP();
+	char *p = (char*)(unsigned long)POP();
 	int n=0;
 
 	while( nd->mark_lo < nvram.size && n < len ) {
diff --git a/packages/pc-parts.c b/packages/pc-parts.c
index 2ec6707..b626548 100644
--- a/packages/pc-parts.c
+++ b/packages/pc-parts.c
@@ -38,7 +38,7 @@ typedef struct {
 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((ucell)(unsigned long)buf); PUSH(size); call_parent(di->read_xt); POP(); })
 
 /* three helper functions */
 
@@ -294,7 +294,7 @@ pcparts_open( pcparts_info_t *di )
 static void
 pcparts_probe( pcparts_info_t *dummy )
 {
-	unsigned char *buf = (unsigned char *)POP();
+	unsigned char *buf = (unsigned char *)(unsigned long)POP();
 
 	DPRINTF("probing for PC partitions\n");
 
diff --git a/packages/video.c b/packages/video.c
index 32a4469..a2718a2 100644
--- a/packages/video.c
+++ b/packages/video.c
@@ -244,7 +244,7 @@ video_set_colors( void )
 {
 	int count = POP();
 	int start = POP();
-	unsigned char *p = (unsigned char*)POP();
+	unsigned char *p = (unsigned char*)(unsigned long)POP();
 	int i;
 
 	for( i=0; i<count; i++, p+=3 ) {
@@ -289,7 +289,7 @@ video_write(void)
     int len;
 
     len = POP();
-    addr = (char *)POP();
+    addr = (char *)(unsigned long)POP();
 
     console_draw_fstr(addr, len);
     PUSH(len);
