Subject: Re: How do I run netbsd ofppc under psim simulator?
To: nldudok1 <nldudok1@olifantasia.com>
From: Andrew Cagney <cagney@mac.com>
List: port-ofppc
Date: 02/16/2002 00:39:50
This is a multi-part message in MIME format.
--------------000304090205060504030007
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

> i all,
> I am trying for a while now to boot a ppc netbsd kernel under the psim simulator but I can't get it to work.
> Can anybody tell me what I need (versions and configuration file) and where to find it.
> Most information I found references dead ftp sites. Especially I don't know what hardware  tree to use. And how to compile and invoke ofwboot. The only version I have that doesn't crash rightaway complaines about no dma in the ide controller and then dies.

With the attached patch applied, and a current GDB,
I can get as far as:

bash-2.04# gdb /usr/src/sys/arch/ofppc/compile/GENERIC/netbsd.gdb
GNU gdb 2002-02-10-cvs
...
This GDB was configured as "powerpc-unknown-netbsd1.5ZA"...
(gdb) target sim -r 0x400000
Connected to the simulator.
(gdb) load
chirp: note descriptor missing load-base
(gdb) run
Starting program: /usr/src/sys/arch/ofppc/compile/GENERIC/netbsd.gdb
NetBSD does not yet support the "gpl,clayton".
Using generic OpenFirmware driver support.
  [ no symbols available ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002
     The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
     The Regents of the University of California.  All rights reserved.

NetBSD 1.5ZA (GENERIC) #0: Sat Feb 16 00:18:00 EST 2002
     boor@localhost:/usr/src/sys/arch/ofppc/compile/GENERIC
total memory = 4096 KB
avail memory = 1388 KB
using 76 buffers containing 304 KB of memory
mainbus0 (root): gpl,clayton
cpu@0 at mainbus0 not configured
memory@0 at mainbus0 not configured
panic: unknown timebase
trap: kernel read DSI @ 0x7c3143f6 by 0x29ef14 (DSISR 0x40000000, err=14)
Press a key to panic.

panic: trap
trap: kernel read DSI @ 0x7c3143f6 by 0x29ef14 (DSISR 0x40000000, err=14)
Press a key to panic.
^C
Program received signal SIGINT, Interrupt.
0x80004004 in ?? ()
(gdb)

The first missing bit is a device tree description.  Dig Dig.  Found the 
attached.  Use it with:

	target sim -f tree

The next missing bit is a disk / root file system.  Wonder what happens 
if I point it at /dev/wd0a ....

Andrew

--------------000304090205060504030007
Content-Type: text/plain;
 name="diffs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diffs"

? fixed-locore.S
? diffs
Index: locore.S
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/ofppc/ofppc/locore.S,v
retrieving revision 1.25
diff -p -r1.25 locore.S
*** locore.S	2001/10/23 01:36:32	1.25
--- locore.S	2002/02/16 05:23:21
*************** idle_u:
*** 77,82 ****
--- 77,86 ----
  openfirmware_entry:
  	.long	0			/* openfirmware entry point */
  
+ 	.section .bss
+ OF_buffer:	
+ 	.space 0x1000
+ 
  /*
   * This symbol is here for the benefit of kvm_mkdb, and is supposed to
   * mark the start of kernel text.
*************** __start:
*** 146,151 ****
--- 150,158 ----
  	li	9,PGOFSET
  	add	8,8,9
  	andc	8,8,9
+ /*   having worked all this out just ignore it.  */
+ 	lis	8,OF_buffer@ha
+ 	addi	8,8,OF_buffer@l
  	lis	9,_C_LABEL(OF_buf)@ha
  	stw	8,_C_LABEL(OF_buf)@l(9)
  	addi	8,8,NBPG
Index: mainbus.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/ofppc/ofppc/mainbus.c,v
retrieving revision 1.7
diff -p -r1.7 mainbus.c
*** mainbus.c	2001/10/23 22:52:14	1.7
--- mainbus.c	2002/02/16 05:23:24
*************** mainbus_attach(struct device *parent, st
*** 148,154 ****
  		/*
  		 * Make sure this isn't one of our "special" child nodes.
  		 */
! 		OF_getprop(node, "name", buf, sizeof(buf));
  		for (ssp = openfirmware_special; (sp = *ssp) != NULL; ssp++) {
  			if (strcmp(buf, sp) == 0)
  				break;
--- 148,154 ----
  		/*
  		 * Make sure this isn't one of our "special" child nodes.
  		 */
! 		of_packagename(node, buf, sizeof(buf));
  		for (ssp = openfirmware_special; (sp = *ssp) != NULL; ssp++) {
  			if (strcmp(buf, sp) == 0)
  				break;
*************** mainbus_print(void *aux, const char *pnp
*** 169,175 ****
  	char name[64];
  
  	if (pnp) {
! 		OF_getprop(oba->oba_phandle, "name", name, sizeof(name));
  		printf("%s at %s", name, pnp);
  	}
  
--- 169,175 ----
  	char name[64];
  
  	if (pnp) {
! 		of_packagename(oba->oba_phandle, name, sizeof(name));
  		printf("%s at %s", name, pnp);
  	}
  

--------------000304090205060504030007
Content-Type: text/plain;
 name="tree"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="tree"

/#address-cells 1

/openprom/options
	./os-emul "chrp
	./oea-memory-size 0x400000
	./use-stdio? false
/openprom/trace
#	./events 1
#	./interrupts 1

/aliases
	./ofdisk0 "/phb/ide/cdrom@0


/phb@0x80000000
	./device_type "pci
	./name "pci
	./#address-cells 3
	./#size-cells 2
	./ranges ni0,0,0,0 0xc0000000 0x10000

/phb/ide@1
	./device_type "ide
	./name "ide
	./assigned-addresses \
		ni0,0,10,1f0 8 \
		ni0,0,14,3f0 8 \
		ni0,0,18,170 8 \
		ni0,0,1c,370 8 \
		ni0,0,20,200 8
	./reg \
		1 0 \
		i0,0,10,0 8 \
		i0,0,18,0 8 \
		i0,0,14,6 1 \
		i0,0,1c,6 1 \
		i0,0,20,0 8
	./ready-delay 1000

/phb/ide@1/cdrom@0
	./device_type "block
	./name "cdrom
	./file "/home/people/cagney/build/Netbsd/fl9660

/phb/com@2
	./device_type "serial"
	./name "com"
	./assigned-addresses \
		ni0,0,10,3f8 8
	./reg \
		2 0 \
		i0,0,10,0 8

# TMP for NetBSD
/cpus
	./device_type "cpus
	./name "cpus
	./timebase-frequency 1000000
/cpus/cpu@0
	./device_type "cpu
	./name "cpu
	./timebase-frequency 1000000



#/options/real-mode? true
#/chosen/netbsd-args "/phb/ide/cdrom@0/netbsd
/chosen/netbsd-args "ofdisk0/netbsd -sd
/chosen/bootpath "ofdisk0:\boot.ppc"
/chosen/bootargs "-s"

/chosen/stdin */phb/com
/chosen/stdout !/chosen/stdin


--------------000304090205060504030007--