Switch hwaddr to 64-bits to match upstream.

This also fixes a bug in a constant declaration in
hw/android/android_mips.c

Change-Id: I4913aa8f7ba329aca8ed265342f2af9b1bad3058
diff --git a/arch_init.c b/arch_init.c
index 9e659b0..7ed8a8b 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -262,7 +262,7 @@
         return 0;
     }
 
-    if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
+    if (cpu_physical_sync_dirty_bitmap(0, UINT64_MAX) != 0) {
         qemu_file_set_error(f, -errno);
         return 0;
     }
diff --git a/hw/android/android_mips.c b/hw/android/android_mips.c
index 2f13a1e..c6725c4 100644
--- a/hw/android/android_mips.c
+++ b/hw/android/android_mips.c
@@ -54,7 +54,7 @@
 
 /* Board init.  */
 
-#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
+#define VIRT_TO_PHYS_ADDEND (0xffffffff80000000LL)
 
 #define PHYS_TO_VIRT(x) ((x) | ~(target_ulong)0x7fffffff)
 
@@ -110,7 +110,7 @@
     cmdline = ram_size - TARGET_PAGE_SIZE;
     char kernel_cmd[1024];
     if (initrd_size > 0)
-        sprintf (kernel_cmd, "%s rd_start=0x" TARGET_FMT_lx " rd_size=%li",
+        sprintf (kernel_cmd, "%s rd_start=0x%" HWADDR_PRIx " rd_size=%li",
                        kernel_cmdline,
                        (hwaddr)PHYS_TO_VIRT(initrd_offset),
                        (long int)initrd_size);
diff --git a/hw/android/goldfish/audio.c b/hw/android/goldfish/audio.c
index 9259a75..9d15b8c 100644
--- a/hw/android/goldfish/audio.c
+++ b/hw/android/goldfish/audio.c
@@ -419,7 +419,9 @@
 	    return s->read_buffer_available;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_audio_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_audio_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -494,7 +496,9 @@
             break;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_audio_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_audio_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/battery.c b/hw/android/goldfish/battery.c
index 6624176..41abcba 100644
--- a/hw/android/goldfish/battery.c
+++ b/hw/android/goldfish/battery.c
@@ -114,7 +114,9 @@
 		    return s->capacity;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_battery_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_battery_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -132,7 +134,9 @@
             break;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_audio_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_audio_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/device.c b/hw/android/goldfish/device.c
index bcba751..3b11a14 100644
--- a/hw/android/goldfish/device.c
+++ b/hw/android/goldfish/device.c
@@ -143,7 +143,9 @@
         case PDEV_BUS_IRQ_COUNT:
             return s->current ? s->current->irq_count : 0;
     default:
-        cpu_abort (cpu_single_env, "goldfish_bus_read: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "goldfish_bus_read: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         return 0;
     }
 }
@@ -170,7 +172,9 @@
                     goldfish_bus_op_init(s);
                     break;
                 default:
-                    cpu_abort (cpu_single_env, "goldfish_bus_write: Bad PDEV_BUS_OP value %x\n", value);
+                    cpu_abort(cpu_single_env,
+                              "goldfish_bus_write: Bad PDEV_BUS_OP value %x\n",
+                              value);
             };
             break;
         case PDEV_BUS_GET_NAME:
@@ -184,7 +188,9 @@
             goldfish_64bit_guest = 1;
             break;
         default:
-            cpu_abort (cpu_single_env, "goldfish_bus_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_bus_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/fb.c b/hw/android/goldfish/fb.c
index 8738321..d6eba54 100644
--- a/hw/android/goldfish/fb.c
+++ b/hw/android/goldfish/fb.c
@@ -588,7 +588,9 @@
             return goldfish_fb_get_pixel_format(s);
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_fb_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_fb_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -630,7 +632,9 @@
             s->need_update = 1;
             break;
         default:
-            cpu_abort (cpu_single_env, "goldfish_fb_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_fb_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/interrupt.c b/hw/android/goldfish/interrupt.c
index 6b6abb0..23a1610 100644
--- a/hw/android/goldfish/interrupt.c
+++ b/hw/android/goldfish/interrupt.c
@@ -110,7 +110,9 @@
         return 0;
     }
     default:
-        cpu_abort (cpu_single_env, "goldfish_int_read: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "goldfish_int_read: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         return 0;
     }
 }
@@ -142,7 +144,9 @@
             break;
 
     default:
-        cpu_abort (cpu_single_env, "goldfish_int_write: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "goldfish_int_write: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         return;
     }
     goldfish_int_update(s);
diff --git a/hw/android/goldfish/mmc.c b/hw/android/goldfish/mmc.c
index a2beb68..fbbeed6 100644
--- a/hw/android/goldfish/mmc.c
+++ b/hw/android/goldfish/mmc.c
@@ -484,7 +484,9 @@
             return ret;
         }
         default:
-            cpu_abort(cpu_single_env, "goldfish_mmc_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_mmc_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -534,7 +536,9 @@
             break;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_mmc_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_mmc_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/nand.c b/hw/android/goldfish/nand.c
index 67fce20..47c5ffb 100644
--- a/hw/android/goldfish/nand.c
+++ b/hw/android/goldfish/nand.c
@@ -604,7 +604,9 @@
         }
         break;
     default:
-        cpu_abort(cpu_single_env, "nand_dev_write: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "nand_dev_write: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         break;
     }
 }
@@ -652,7 +654,9 @@
         return (uint32_t)(dev->max_size >> 32);
 
     default:
-        cpu_abort(cpu_single_env, "nand_dev_read: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "nand_dev_read: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         return 0;
     }
 }
diff --git a/hw/android/goldfish/timer.c b/hw/android/goldfish/timer.c
index b8921e5..afdd8a5 100644
--- a/hw/android/goldfish/timer.c
+++ b/hw/android/goldfish/timer.c
@@ -83,7 +83,9 @@
         case TIMER_TIME_HIGH:
             return s->now_ns >> 32;
         default:
-            cpu_abort (cpu_single_env, "goldfish_timer_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_timer_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -115,7 +117,9 @@
             goldfish_device_set_irq(&s->dev, 0, 0);
             break;
         default:
-            cpu_abort (cpu_single_env, "goldfish_timer_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_timer_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
@@ -167,7 +171,9 @@
         case 0x4:
             return s->now >> 32;
         default:
-            cpu_abort (cpu_single_env, "goldfish_rtc_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_rtc_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
             return 0;
     }
 }
@@ -186,7 +192,9 @@
             goldfish_device_set_irq(&s->dev, 0, 0);
             break;
         default:
-            cpu_abort (cpu_single_env, "goldfish_rtc_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_rtc_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/android/goldfish/trace.c b/hw/android/goldfish/trace.c
index 9ca4cd2..c6f31c9 100644
--- a/hw/android/goldfish/trace.c
+++ b/hw/android/goldfish/trace.c
@@ -229,7 +229,9 @@
 
     default:
         if (offset < 4096) {
-            cpu_abort(cpu_single_env, "trace_dev_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "trace_dev_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
         } else {
             D("%s: offset=%d (0x%x) value=%d (0x%x)\n", __FUNCTION__, offset,
               offset, value, value);
@@ -251,7 +253,9 @@
 
     default:
         if (offset < 4096) {
-            cpu_abort(cpu_single_env, "trace_dev_read: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "trace_dev_read: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
         } else {
             D("%s: offset=%d (0x%x)\n", __FUNCTION__, offset, offset);
         }
diff --git a/hw/android/goldfish/tty.c b/hw/android/goldfish/tty.c
index 7f032b1..9e04c6c 100644
--- a/hw/android/goldfish/tty.c
+++ b/hw/android/goldfish/tty.c
@@ -84,7 +84,9 @@
         case TTY_BYTES_READY:
             return s->data_count;
     default:
-        cpu_abort (cpu_single_env, "goldfish_tty_read: Bad offset %x\n", offset);
+        cpu_abort(cpu_single_env,
+                  "goldfish_tty_read: Bad offset %" HWADDR_PRIx "\n",
+                  offset);
         return 0;
     }
 }
@@ -173,7 +175,9 @@
             break;
 
         default:
-            cpu_abort (cpu_single_env, "goldfish_tty_write: Bad offset %x\n", offset);
+            cpu_abort(cpu_single_env,
+                      "goldfish_tty_write: Bad offset %" HWADDR_PRIx "\n",
+                      offset);
     }
 }
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index beb36b5..f7f84ad 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -949,7 +949,7 @@
 #if TARGET_PHYS_ADDR_BITS == 32
         hw_error("To much RAM for 32-bit physical address");
 #else
-        ram_addr = qemu_ram_alloc(above_4g_mem_size);
+        ram_addr = qemu_ram_alloc(NULL, "pc.ram.high", above_4g_mem_size);
         cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
                                      ram_addr);
diff --git a/include/exec/hwaddr.h b/include/exec/hwaddr.h
index 7c4a771..ef62eb4 100644
--- a/include/exec/hwaddr.h
+++ b/include/exec/hwaddr.h
@@ -1,27 +1,22 @@
 /* Define hwaddr if it exists.  */
 
-#ifndef TARGPHYS_H
-#define TARGPHYS_H
+#ifndef HWADDR_H
+#define HWADDR_H
 
 #include <stdint.h>
 
-#ifndef TARGET_PHYS_ADDR_BITS
-#define TARGET_PHYS_ADDR_BITS 32
-#endif
-
-#ifdef TARGET_PHYS_ADDR_BITS
+#define HWADDR_BITS 64
 /* hwaddr is the type of a physical address (its size can
    be different from 'target_ulong').  */
 
-#if TARGET_PHYS_ADDR_BITS == 32
-typedef uint32_t hwaddr;
-#define TARGET_PHYS_ADDR_MAX UINT32_MAX
-#define TARGET_FMT_plx "%08x"
-#elif TARGET_PHYS_ADDR_BITS == 64
 typedef uint64_t hwaddr;
-#define TARGET_PHYS_ADDR_MAX UINT64_MAX
+#define HWADDR_MAX UINT64_MAX
 #define TARGET_FMT_plx "%016" PRIx64
-#endif
-#endif
+#define HWADDR_PRId PRId64
+#define HWADDR_PRIi PRIi64
+#define HWADDR_PRIo PRIo64
+#define HWADDR_PRIu PRIu64
+#define HWADDR_PRIx PRIx64
+#define HWADDR_PRIX PRIX64
 
 #endif
diff --git a/include/hw/loader.h b/include/hw/loader.h
index c262a74..5c75ef9 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -13,7 +13,7 @@
 int load_elf(const char *filename, int64_t address_offset,
              uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
 int load_aout(const char *filename, hwaddr addr, int max_sz);
-int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+int load_uimage(const char *filename, hwaddr *ep, target_ulong *loadaddr,
                 int *is_linux);
 
 /**