Skip to contentSkip to conversation

PPC fixes for qemu/OpenHackWare

Qemu-devel Thayne Harbaugh 4 participants 8 messages Feb 8, 2005 – Feb 9, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

These fixes greatly improve qemu booting on PPC - many Linux distributions with kernel 2.4 now work. It's two big patches (one for qemu, one for OpenHackWare) - let me know if someone prefers them broken out into smaller pieces.

There's still some work to be done to get PREP in good shape as well as a Linux 2.6 kernel to work well - expect some more patches in the near future.

Highlights

* Real serial
* Correct PCI host bridge for PREP (wrong in Pearpc, Qemu and OpenHackWare)
* -Werror building for OpenHackWare
* proper reboot
* HFS OpenHackWare now correctly traverses the B*tree - greatly improves probability of booting *all* HFS based filesystems
* Many, MANY other fixes

Makefile +2 -1
Index: qemu-0.6.1/Makefile
===================================================================
@@ -1,6 +1,7 @@
 -include config-host.mak
 
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing 
+VPATH = $(SRC_PATH)
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -I.
 ifdef CONFIG_DARWIN
 CFLAGS+= -mdynamic-no-pic
 endif
Makefile.target +1 -1
Index: qemu-0.6.1/Makefile.target
===================================================================
@@ -2,7 +2,7 @@
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
-DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
+DEFINES=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
 ifdef CONFIG_USER_ONLY
 VPATH+=:$(SRC_PATH)/linux-user
 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
hw/cuda.c +12 -1
Index: qemu-0.6.1/hw/cuda.c
===================================================================
@@ -87,6 +87,9 @@
 #define CUDA_TIMER_FREQ (4700000 / 6)
 #define CUDA_ADB_POLL_FREQ 50
 
+/* CUDA returns time_t's offset from Jan 1, 1904, not 1970 */
+#define RTC_OFFSET                      2082844800
+
 typedef struct CUDATimer {
     unsigned int latch;
     uint16_t counter_value; /* counter value at load time */
@@ -503,7 +506,7 @@
         break;
     case CUDA_GET_TIME:
         /* XXX: add time support ? */
-        ti = time(NULL);
+        ti = time(NULL) + RTC_OFFSET;
         obuf[0] = CUDA_PACKET;
         obuf[1] = 0;
         obuf[2] = 0;
@@ -522,6 +525,14 @@
         obuf[1] = 0;
         cuda_send_packet_to_host(s, obuf, 2);
         break;
+    case CUDA_POWERDOWN:
+        obuf[0] = CUDA_PACKET;
+        obuf[1] = 0;
+        cuda_send_packet_to_host(s, obuf, 2);
+	qemu_system_shutdown_request();
+	break;
+    case CUDA_MS_RESET:
+	
     default:
         break;
     }
hw/openpic.c +2 -2
Index: qemu-0.6.1/hw/openpic.c
===================================================================
@@ -345,7 +345,7 @@
     int i;
 
     opp->glbc = 0x80000000;
-    /* Initialise controler registers */
+    /* Initialise controller registers */
     opp->frep = ((EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
     opp->veni = VENI;
     opp->spve = 0x000000FF;
@@ -629,7 +629,7 @@
         break;
     case 0x10: /* TIBC */
 	if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
-	    (val & 0x800000000) == 0 &&
+	    (val & 0x80000000) == 0 &&
             (opp->timers[idx].tibc & 0x80000000) != 0)
 	    opp->timers[idx].ticc &= ~0x80000000;
 	opp->timers[idx].tibc = val;
hw/ppc_prep.c +29 -13

60 lines not on this page · raw message

hw/pci.c +19 -3
Index: qemu-0.6.1/hw/pci.c
===================================================================
@@ -698,10 +698,25 @@
                                            PPC_PCIIO_write, s);
     cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory);
 
-    d = pci_register_device(s, "PREP PCI Bridge", sizeof(PCIDevice), 0,
-                            NULL, NULL);
+    /* PCI host bridge */ 
+    d = pci_register_device(s, "PREP Host Bridge - Motorola Raven", sizeof(PCIDevice), 
+                            0, NULL, NULL);
+    d->config[0x00] = 0x57; // vendor_id : Apple
+    d->config[0x01] = 0x10;
+    d->config[0x02] = 0x01; // device_id
+    d->config[0x03] = 0x48;
+    d->config[0x08] = 0x00; // revision
+    d->config[0x0A] = 0x00; // class_sub = pci host
+    d->config[0x0B] = 0x06; // class_base = PCI_bridge
+    d->config[0x0C] = 0x08; // cache_line_size
+    d->config[0x0D] = 0x10; // latency_timer
+    d->config[0x0E] = 0x00; // header_type
+    d->config[0x34] = 0x00; // capabilities_pointer
 
-    /* XXX: put correct IDs */
+    /* PCI to PCI bridge */
+    d = pci_register_device(s, "PREP PCI Bridge - Digital 21154", sizeof(PCIDevice),
+			    0xa0 << 3, NULL, NULL);
+    /* same values as PearPC - check this */
     d->config[0x00] = 0x11; // vendor_id
     d->config[0x01] = 0x10;
     d->config[0x02] = 0x26; // device_id
@@ -710,6 +725,7 @@
     d->config[0x0a] = 0x04; // class_sub = pci2pci
     d->config[0x0b] = 0x06; // class_base = PCI_bridge
     d->config[0x0e] = 0x01; // header_type
+
     return s;
 }
 
vl.c +1 -1
Index: qemu-0.6.1/vl.c
===================================================================
@@ -246,7 +246,7 @@
     for(i = start; i < start + length; i += size) {
         ioport_write_table[bsize][i] = func;
         if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
-            hw_error("register_ioport_read: invalid opaque");
+            hw_error("register_ioport_write: invalid opaque");
         ioport_opaque[i] = opaque;
     }
     return 0;
Changelog +44 -0

56 lines not on this page · raw message

src/main.ld +2 -2
Index: OpenHackWare/src/main.ld
===================================================================
@@ -18,14 +18,14 @@
         . = ALIGN(4) ;
         .text     : { *(.text)    } > bios
         . = ALIGN(4) ;
-        .OpenFirmawre : { *(.OpenFirmware) } > bios
+        .OpenFirmware : { *(.OpenFirmware) } > bios
         . = ALIGN(4) ;
         _data_start = . ;
         .data     : { *(.data)    } > bios
         _data_end = . ;
         . = ALIGN(4) ;
         _OF_vars_start = . ;
-        .OpenFirmawre_vars : { *(.OpenFirmware_vars) } > bios
+        .OpenFirmware_vars : { *(.OpenFirmware_vars) } > bios
         _OF_vars_end = . ;
         . = ALIGN(4) ;
         _sdata_start = . ;
src/bios.h +13 -0
Index: OpenHackWare/src/bios.h
===================================================================
@@ -164,6 +164,7 @@
                            void **cmdline, uint32_t *cmdline_size,
                            void **ramdisk, uint32_t *ramdisk_size);
 
+
 /*****************************************************************************/
 /* bloc.c : bloc devices management */
 typedef struct pos_t {
@@ -197,6 +198,9 @@
 void bd_set_boot_part (bloc_device_t *bd, part_t *partition);
 part_t **_bd_parts (bloc_device_t *bd);
 
+void ide_isa_pc_register (int intf,
+			  uint32_t io_cmd, uint32_t io_ctrl,
+			  unused void *OF_private);
 void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1,
                           uint32_t io_base2, uint32_t io_base3,
                           void *OF_private);
@@ -309,6 +313,7 @@
 extern int vga_fb_bpp;
 extern int vga_fb_depth;
 void vga_prep_init(void);
+void vga_keyboard_init(void);
 void vga_set_address (uint32_t address);
 void vga_set_mode(int width, int height, int depth);
 void vga_set_palette(int i, unsigned int rgba);
@@ -329,6 +334,7 @@
                    unsigned int fgcol, unsigned int bgcol);
 void vga_putchar(int ch);
 void vga_puts(const char *s);
+int vga_getchar(void);
 
 /*****************************************************************************/
 /* bootinfos.c : build structures needed by kernels to boot */
@@ -374,6 +380,8 @@
                      const unsigned char *type);
 int OF_register_serial (const unsigned char *bus, const unsigned char *name,
                         uint32_t io_base, int irq);
+int OF_register_isa_ide (const unsigned char *bus, int intf,
+			 uint32_t io_cmd, uint32_t io_ctrl, unused int irq);
 int OF_register_stdio (const unsigned char *dev_in,
                        const unsigned char *dev_out);
 void OF_vga_register (const unsigned char *name, uint32_t address,
@@ -453,6 +461,8 @@
 unsigned int strlen (const void *buffer);
 int strcmp (const char *str0, const char *str1);
 int strncmp (const char *str0, const char *str1, int maxlen);
+int strncasecmp (const char *str0, const char *str1, int maxlen);
+int tolower (int c);
 char *strcpy (char *dst, const char *src);
 char *strdup (const char *src);
 char *strchr (const char *str, int c);
@@ -525,6 +535,9 @@
 
 /* Console */
 int cs_write (const unsigned char *buf, int len);
+int cs_writeb (uint8_t byte);
+int cs_read (unsigned char *buf, int len);
+int cs_readb (void);
 
 #endif /* !defined (ASSEMBLY_CODE) */
 
src/of.c +65 -33

192 lines not on this page · raw message

src/vectors.S +4 -4
Index: OpenHackWare/src/vectors.S
===================================================================
@@ -285,7 +285,7 @@
         mr      r3, r27                                   ;
         lwzu    r4, 4(r28)                                ;
         bl      outstr                                    ;
-        /* Find message corresponding to the catched exception */
+        /* Find message corresponding to the caught exception */
         srwi    r12, r22, 8                               ;
         cmp     0, r12, r30                               ;
         ble     _dump_excp_msg                            ;
@@ -338,7 +338,7 @@
 .section .rodata
 .align 2
 _BUG_message_0:
-        .string "ERROR: BUG catched...\n"
+        .string "ERROR: BUG caught...\n"
 _BUG_message_1:
         .string " exception"
 _BUG_message_2:
@@ -439,7 +439,7 @@
 _dummy_0:
         .long 0x00000000
 
-registers_area: /* To be loaded in register when an exception is catched */
+registers_area: /* To be loaded in register when an exception is caught */
 _serial_IO:      /* r27 */
         .long 0x800003F8
 _messages_start: /* r28 */
@@ -455,4 +455,4 @@
 .align 2
 save_area: /* Area for r11 save when an exception is skipped */
         .long 0x00000000
-       
\ No newline at end of file
+
src/part.c +19 -14
Index: OpenHackWare/src/part.c
===================================================================
@@ -4,6 +4,8 @@
  * Open Hack'Ware BIOS partitions management
  * 
  * Copyright (c) 2004 Jocelyn Mayer
+ * Bootstrap enhancements Copyright (c) 2005 Matthew S. Wood
+ *                                           [[email protected]]
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +25,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-
 #include "bios.h"
 
 /* Bootable partitions detection and management */
@@ -493,9 +494,7 @@
             /* Free space. Skip it */
             DPRINTF("%s Free part (%d)\n", __func__, i);
             part_register(bd, part, 0, -1, -1);
-        } else if (strncmp("Apple_partition_map", type, 32) == 0 ||
-                   strncmp("Apple_Partition_Map", type, 32) == 0 ||
-                   strncmp("Apple_patition_map", type, 32) == 0) {
+        } else if (strncasecmp("apple_partition_map", type, 32) == 0) {
             DPRINTF("%s Partition map\t%d [%s]\n", __func__, i, type);
             /* We are in the partition map descriptor */
             if (i == 1) {
@@ -523,15 +522,15 @@
             /* Patches: don't care for now */
             DPRINTF("%s Patches part\t%d [%s]\n", __func__, i, type);
             //            part_register(bd, part, 0, 2, -1);
-        } else if (strncmp("Apple_HFS", type, 32) == 0 ||
-                   strncmp("Apple_MFS", type, 32) == 0 ||
-                   strncmp("Apple_UFS", type, 32) == 0 ||
-                   strncmp("Apple_PRODOS", type, 32) == 0 ||
-                   strncmp("Apple_UNIX_SVR2", type, 32) == 0 ||
-                   strncmp("Linux", type, 32) == 0 ||
-                   strncmp("NetBSD/macppc", type, 32) == 0 ||
-                   strncmp("Apple_boot", type, 32) == 0 ||
-                   strncmp("Apple_bootstrap", type, 32) == 0) {
+        } else if (strncasecmp("Apple_HFS", type, 32) == 0 ||
+                   strncasecmp("Apple_MFS", type, 32) == 0 ||
+                   strncasecmp("Apple_UFS", type, 32) == 0 ||
+                   strncasecmp("Apple_PRODOS", type, 32) == 0 ||
+                   strncasecmp("Apple_UNIX_SVR2", type, 32) == 0 ||
+                   strncasecmp("Linux", type, 32) == 0 ||
+                   strncasecmp("NetBSD/macppc", type, 32) == 0 ||
+                   strncasecmp("Apple_boot", type, 32) == 0 ||
+                   strncasecmp("Apple_bootstrap", type, 32) == 0) {
             DPRINTF("%s Fs part\t%d [%s]\n", __func__, i, type);
             /* Filesystems / boot partitions */
             flags = partmap->flags;
@@ -544,10 +543,13 @@
                 name = partmap->name;
             }
             if (partmap->boot_size == 0 || partmap->boot_load == 0) {
-                printf("Not a bootable partition\n");
+                printf("Not a bootable partition (boot_size: %d, "
+		       "boot_load: %d)\n", partmap->boot_size,
+		       partmap->boot_load);
                 part_register(bd, part, 1, 0, 0);
                 if (partmap->boot_size != 0) {
                     boot_part = part;
+		    break;
                 }
             } else {
                 part->boot_start.bloc = partmap->boot_start;
@@ -575,6 +577,7 @@
             DPRINTF("                           load %0x entry %0x %0x\n",
                     partmap->boot_load2, partmap->boot_entry2, HFS_BLOCSIZE);
             boot_part = part;
+	    break;
         } else {
             memcpy(tmp, type, 32);
             tmp[32] = '\0';
@@ -585,6 +588,8 @@
  error:
     free(buffer);
 
+    if (!boot_part)
+	DPRINTF("No bootable partition found.\n");
     return boot_part;
 
 }
src/fs.c +73 -71

264 lines not on this page · raw message

src/pci.c +140 -117

705 lines not on this page · raw message

src/vga.c +340 -0

366 lines not on this page · raw message

src/file.c +7 -1
Index: OpenHackWare/src/file.c
===================================================================
@@ -748,13 +748,19 @@
     }
     mhdr = (void *)buffer;
     MACH_O_MAGIC
+#else
+    /* FIXME - quiet gcc about unused variables */
+    (void)file;
+    (void)dest;
+    (void)entry;
+    (void)end;
 #endif
 
     return -2;
 }
 
 /* PREP boot loader */
-static int file_load_prep (file_t *file, void **dest, void **entry, void **end)
+static int file_load_prep (file_t *file, unused void **dest, unused void **entry, unused void **end)
 {
     unsigned char buffer[512];
 
src/bloc.c +58 -33

184 lines not on this page · raw message

src/main.c +111 -36

250 lines not on this page · raw message

Makefile +5 -5
Index: OpenHackWare/Makefile
===================================================================
@@ -13,9 +13,9 @@
 
 #DEBUG=1
 
-CC:= powerpc-linux-gcc
-LD:= powerpc-linux-ld
-OBJCOPY:= powerpc-linux-objcopy
+CC:= $(CROSS_COMPILE)gcc
+LD:= $(CROSS_COMPILE)ld
+OBJCOPY:= $(CROSS_COMPILE)objcopy
 MKDIR:= mkdir
 CAT:= cat
 TAR:= tar
@@ -34,9 +34,9 @@
 DISTDIR:= .
 SRCDIR:= src
 
-CFLAGS= -Wall -W -O2 -g -fno-builtin -fno-common -nostdinc
+CFLAGS= -Wall -Werror -Os -g -W -fno-builtin -fno-common -nostdinc
 CFLAGS+= -DBUILD_DATE=$(BUILD_DATE) -DBUILD_TIME=$(BUILD_TIME)
-LDFLAGS= -O2 -g -nostdlib
+LDFLAGS= -Os -nostdlib
 
 BIOS_IMAGE_BITS:= 19
 BIOS_IMAGE_SIZE:= $(shell echo $$(( 1 << $(BIOS_IMAGE_BITS) )) )
#1 lore raw
Quoted 11 lines · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux distributions with kernel 2.4 now work. It's two big patches (one for qemu, one for OpenHackWare) - let me know if someone prefers them broken out into smaller pieces.

There's still some work to be done to get PREP in good shape as well as a Linux 2.6 kernel to work well - expect some more patches in the near future.

Highlights

Quoted 8 lines

* Real serial
* Correct PCI host bridge for PREP (wrong in Pearpc, Qemu and OpenHackWare)
* -Werror building for OpenHackWare
* proper reboot
* HFS OpenHackWare now correctly traverses the B*tree - greatly improves probability of booting *all* HFS based filesystems
* Many, MANY other fixes

Very good ! Have you looked at Darwin and Mac OS X ? I feel QEMU (and OpenHackWare) are very close to launch them: at least all the hardware emulation is there. I am unable to look at the problem because I don't have an easy way to recompile the Darwin kernel to insert debug messages... and another problem is that I don't have the time :-)

Fabrice.

#2 lore raw
Quoted 2 lines · Fabrice Bellard
Quoted 1 line · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux

Should be "emulating PPC" rather than "booting on PPC".

Quoted 1 line

Very good !

Thanks - I should mention that Matthew S. Wood did quite a bit of the work.

Quoted 3 lines

Have you looked at Darwin and Mac OS X ? I feel QEMU (and
OpenHackWare) are very close to launch them: at least all the hardware emulation is there.

I haven't looked at them. I'd like to try OSX, but I don't have a copy and haven't bugged the right person for one. Hopefully I'll get around to it, however it isn't as high of a priority as generl PPC emulation.

Quoted 3 lines

I am unable to look at the problem because I don't
have an easy way to recompile the Darwin kernel to insert debug messages... and another problem is that I don't have the time :-)

I might be in the same boat, unfortunately. I'm mostly hoping that if the general problems get fixed then it will be easier for someone to pursue the special case problems. If qemu/OpenHackWare can be show to be generally solid and work well for linux/ppc, then hopefully some that's motivated to have OSX or Darwin will give it a go.

I'm interested to know when the patches will be applied to Qemu and OpenHackWare or when I'll get feedback regarding what needs to be done differently.

Thanks.

#4 lore raw
In reply to Thayne Harbaugh
Quoted 8 lines · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux distributions with kernel 2.4 now work. It's two big patches (one for qemu, one for OpenHackWare) - let me know if someone prefers them broken out into smaller pieces.

There's still some work to be done to get PREP in good shape as well as a Linux 2.6 kernel to work well - expect some more patches in the near future.

Hi.
Thanks for the work. I need to take a close look of your patches because I completely restructured OHW. For example, HFS code is quite different in my working repository (but still have problems on some fs)...

I have a few remarks about the patches:
* in Qemu:
pci_enabled option should not be used for PPC emulation: we don't emulate MCA, so PCI is mandatory for PREP and the Mac target is Mac99 which also always have PCI.
The rest of the patch seems OK, imho.

I can't compare OHW for now, as it seems that most of the patch is cosmetic (blanks, tabs) and as most files have changed. Could you please regenerate the patch using:
--ignore-all-space --ignore-blank-lines --ignore-space-change --minimal -p
options to make it easier to read ?

I'll send you my current working version of OHW by mail so you can compare and see where your patches can still apply easily (while I'll try too...).

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#3 lore raw
In reply to Thayne Harbaugh
Quoted 3 lines

I'm interested to know when the patches will be applied to Qemu and OpenHackWare or when I'll get feedback regarding what needs to be done differently.

Fabrice is the "Father" of QEMU, so you're talking to the person who applies those patches ;)

Thanks,
Hetz

#5 lore raw
In reply to J. Mayer
Quoted 15 lines · J. Mayer
Quoted 8 lines · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux distributions with kernel 2.4 now work. It's two big patches (one for qemu, one for OpenHackWare) - let me know if someone prefers them broken out into smaller pieces.

There's still some work to be done to get PREP in good shape as well as a Linux 2.6 kernel to work well - expect some more patches in the near future.

Hi.
Thanks for the work. I need to take a close look of your patches because I completely restructured OHW. For example, HFS code is quite different in my working repository (but still have problems on some fs)...

Quoted 6 lines

I have a few remarks about the patches:
* in Qemu:
pci_enabled option should not be used for PPC emulation: we don't emulate MCA, so PCI is mandatory for PREP and the Mac target is Mac99 which also always have PCI.
The rest of the patch seems OK, imho.

Okay. I'm shooting in the dark, somewhat. I don't really have any PREP/CHRP hardware - I'm just going off of some random lspci outputs I have found with Google. I do know, however, that the PREP PCI host bridge is incorrect in Pearpc, Qemu and OpenHackWare.

Does anyone have a Linux 2.6 /sys tree for PREP and CHRP? That would be most useful for getting all the ISA, PCI and other devices correct.

Quoted 6 lines

I can't compare OHW for now, as it seems that most of the patch is cosmetic (blanks, tabs) and as most files have changed. Could you please regenerate the patch using:
--ignore-all-space --ignore-blank-lines --ignore-space-change --minimal -p
options to make it easier to read ?

I'm a bit confused. I closely reviewed the patch prior to sending and I didn't notice any instances of whitespace-only diff. There are, however, many lines of spelling changes. :) controler -> controller, recurs -> recurse, to -> too, etc..

Quoted 3 lines

I'll send you my current working version of OHW by mail so you can compare and see where your patches can still apply easily (while I'll try too...).

I'll look for it.

#6 lore raw
Quoted 15 lines · Thayne Harbaugh
Quoted 14 lines · J. Mayer
Quoted 8 lines · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux distributions with kernel 2.4 now work. It's two big patches (one for qemu, one for OpenHackWare) - let me know if someone prefers them broken out into smaller pieces.

There's still some work to be done to get PREP in good shape as well as a Linux 2.6 kernel to work well - expect some more patches in the near future.

Hi.
Thanks for the work. I need to take a close look of your patches because I completely restructured OHW. For example, HFS code is quite different in my working repository (but still have problems on some fs)...

[...]

Quoted 11 lines
Quoted 6 lines

I can't compare OHW for now, as it seems that most of the patch is cosmetic (blanks, tabs) and as most files have changed. Could you please regenerate the patch using:
--ignore-all-space --ignore-blank-lines --ignore-space-change --minimal -p
options to make it easier to read ?

I'm a bit confused. I closely reviewed the patch prior to sending and I didn't notice any instances of whitespace-only diff. There are, however, many lines of spelling changes. :) controler -> controller, recurs -> recurse, to -> too, etc..

Oh well, I looked closer, and you're absolutely right, there are lots of typo I didn't saw at first sight.... I'm sorry about my mistake. But I would still appreciate a diff with -p option, then I have the function name with the diff, which may helps when code has been splitted...

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#7 lore raw
In reply to Thayne Harbaugh
Quoted 1 line · Thayne Harbaugh

These fixes greatly improve qemu booting on PPC - many Linux

<SNIP>

This is a broken-out description of the patch I sent the qemu-0.6.1-ppc.patch I sent the other day:

Fixes for VPATH building (building in a different directory than the source dir).

Makefile +2 -1
Index: qemu-0.6.1/Makefile
===================================================================
@@ -1,6 +1,7 @@
 -include config-host.mak
 
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing 
+VPATH = $(SRC_PATH)
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -I.
 ifdef CONFIG_DARWIN
 CFLAGS+= -mdynamic-no-pic
 endif
Makefile.target +1 -1
Index: qemu-0.6.1/Makefile.target
===================================================================
@@ -2,7 +2,7 @@
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
-DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
+DEFINES=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
 ifdef CONFIG_USER_ONLY
 VPATH+=:$(SRC_PATH)/linux-user
 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)

Corrects time values. This was already committed

hw/cuda.c +12 -1
Index: qemu-0.6.1/hw/cuda.c
===================================================================
@@ -87,6 +87,9 @@
 #define CUDA_TIMER_FREQ (4700000 / 6)
 #define CUDA_ADB_POLL_FREQ 50
 
+/* CUDA returns time_t's offset from Jan 1, 1904, not 1970 */
+#define RTC_OFFSET                      2082844800
+
 typedef struct CUDATimer {
     unsigned int latch;
     uint16_t counter_value; /* counter value at load time */
@@ -503,7 +506,7 @@
         break;
     case CUDA_GET_TIME:
         /* XXX: add time support ? */
-        ti = time(NULL);
+        ti = time(NULL) + RTC_OFFSET;
         obuf[0] = CUDA_PACKET;
         obuf[1] = 0;
         obuf[2] = 0;
@@ -522,6 +525,14 @@
         obuf[1] = 0;
         cuda_send_packet_to_host(s, obuf, 2);
         break;
+    case CUDA_POWERDOWN:
+        obuf[0] = CUDA_PACKET;
+        obuf[1] = 0;
+        cuda_send_packet_to_host(s, obuf, 2);
+	qemu_system_shutdown_request();
+	break;
+    case CUDA_MS_RESET:
+	
     default:
         break;
     }

Spelling fix - already committed.

hw/openpic.c +1 -1
Index: qemu-0.6.1/hw/openpic.c
===================================================================
@@ -345,7 +345,7 @@
     int i;
 
     opp->glbc = 0x80000000;
-    /* Initialise controler registers */
+    /* Initialise controller registers */
     opp->frep = ((EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
     opp->veni = VENI;
     opp->spve = 0x000000FF;

Value 0x800000000 is too large for uint32_t - is this black magic?

Index: qemu-0.6.1/hw/openpic.c
===================================================================
@@ -629,7 +629,7 @@

         break;
     case 0x10: /* TIBC */
 	if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
-	    (val & 0x800000000) == 0 &&
+	    (val & 0x80000000) == 0 &&
             (opp->timers[idx].tibc & 0x80000000) != 0)

opp->timers[idx].ticc &= ~0x80000000;
opp->timers[idx].tibc = val;

This splits pci/isa bus and devices - likely inappropriate and should be dropped.

hw/ppc_prep.c +29 -13

60 lines not on this page · raw message

Adds a Motorola Raven PCI host bridge. Without this none of the PCI devices have a bus to attach to. The other bridge below (0x0426,0x0111) is simply a PCI to PCI bridge.

hw/pci.c +19 -3
Index: qemu-0.6.1/hw/pci.c
===================================================================
@@ -698,10 +698,25 @@
                                            PPC_PCIIO_write, s);
     cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory);
 
-    d = pci_register_device(s, "PREP PCI Bridge", sizeof(PCIDevice), 0,
-                            NULL, NULL);
+    /* PCI host bridge */ 
+    d = pci_register_device(s, "PREP Host Bridge - Motorola Raven", sizeof(PCIDevice), 
+                            0, NULL, NULL);
+    d->config[0x00] = 0x57; // vendor_id : Apple
+    d->config[0x01] = 0x10;
+    d->config[0x02] = 0x01; // device_id
+    d->config[0x03] = 0x48;
+    d->config[0x08] = 0x00; // revision
+    d->config[0x0A] = 0x00; // class_sub = pci host
+    d->config[0x0B] = 0x06; // class_base = PCI_bridge
+    d->config[0x0C] = 0x08; // cache_line_size
+    d->config[0x0D] = 0x10; // latency_timer
+    d->config[0x0E] = 0x00; // header_type
+    d->config[0x34] = 0x00; // capabilities_pointer
 
-    /* XXX: put correct IDs */
+    /* PCI to PCI bridge */
+    d = pci_register_device(s, "PREP PCI Bridge - Digital 21154", sizeof(PCIDevice),
+			    0xa0 << 3, NULL, NULL);
+    /* same values as PearPC - check this */
     d->config[0x00] = 0x11; // vendor_id
     d->config[0x01] = 0x10;
     d->config[0x02] = 0x26; // device_id
@@ -710,6 +725,7 @@
     d->config[0x0a] = 0x04; // class_sub = pci2pci
     d->config[0x0b] = 0x06; // class_base = PCI_bridge
     d->config[0x0e] = 0x01; // header_type
+
     return s;
 }
 

Function name correction in output - I actually prefer using a "%s" scan code with a __func__ argument.

vl.c +1 -1
Index: qemu-0.6.1/vl.c
===================================================================
@@ -246,7 +246,7 @@
     for(i = start; i < start + length; i += size) {
         ioport_write_table[bsize][i] = func;
         if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
-            hw_error("register_ioport_read: invalid opaque");
+            hw_error("register_ioport_write: invalid opaque");
         ioport_opaque[i] = opaque;
     }
     return 0;