use MIPS_TLB_NB constant (Ralf Baechle)
[qemu] / hw / mips_r4k.c
index 1b6a801..44f1ba4 100644 (file)
@@ -78,14 +78,14 @@ void cpu_mips_irqctrl_init (void)
 {
 }
 
-/* MIPS R4K timer */
 uint32_t cpu_mips_get_random (CPUState *env)
 {
-    uint64_t now = qemu_get_clock(vm_clock);
+    uint32_t now = qemu_get_clock(vm_clock);
 
-    return (uint32_t)now & 0x0000000F;
+    return now % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired;
 }
 
+/* MIPS R4K timer */
 uint32_t cpu_mips_get_count (CPUState *env)
 {
     return env->CP0_Count +
@@ -257,8 +257,9 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
     if (linux_boot) {
         kernel_base = KERNEL_LOAD_ADDR;
         /* now we can load the kernel */
-        kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
-        if (kernel_size < 0) {
+        kernel_size = load_image(kernel_filename,
+                                phys_ram_base + (kernel_base - 0x80000000));
+        if (kernel_size == (target_ulong) -1) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n", 
                     kernel_filename);
             exit(1);
@@ -268,7 +269,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
             initrd_base = INITRD_LOAD_ADDR;
             initrd_size = load_image(initrd_filename,
                                      phys_ram_base + initrd_base);
-            if (initrd_size < 0) {
+            if (initrd_size == (target_ulong) -1) {
                 fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", 
                         initrd_filename);
                 exit(1);
@@ -284,22 +285,21 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
         initrd_base = 0;
         initrd_size = 0;
     }
-    /* XXX: should not be ! */
-    printf("%s: init VGA\n", __func__);
-    vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size, 
-                   vga_ram_size);
-
 
     /* Init internal devices */
     cpu_mips_clock_init(cpu_single_env);
     cpu_mips_irqctrl_init();
 
-    isa_mem_base = 0x78000000;
-    /* Register 64 KB of ISA IO space at random address */
+    /* Register 64 KB of ISA IO space at 0x14000000 */
     io_memory = cpu_register_io_memory(0, io_read, io_write, NULL);
-    cpu_register_physical_memory(0x70000000, 0x00010000, io_memory);
+    cpu_register_physical_memory(0x14000000, 0x00010000, io_memory);
+    isa_mem_base = 0x10000000;
+
     serial_init(0x3f8, 4, serial_hds[0]);
-    printf("%s: done\n", __func__);
+    vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size, 
+                   vga_ram_size);
+
+    isa_ne2000_init(0x300, 9, &nd_table[0]);
 }
 
 QEMUMachine mips_machine = {