$FreeBSD: ports/emulators/psim-freebsd/files/HOW-TO,v 1.3 2001/10/14 12:35:19 mp Exp $

Instructions for building and running the FreeBSD kernel under PSIM:

1. On a FreeBSD system, check out a new source tree and run:
	# cd src/sys/powerpc/conf
	# config -g GENERIC

2. On a NetBSD PPC system with the source NFS mounted, compile the kernel
   (your mount point may vary):
	# make -m /mnt/share/mk MACHINE_ARCH=powerpc

3. On the FreeBSD system, grap /usr/src/release/write_mfs_in_kernel.c and
   run it using <http://people.freebsd.org/~mp/psim/ppcdisk.bz2> to add
   the md image:

	# ./write_mfs_in_kernel kernel.debug ppcdisk

4. Run the simulator. The following .gdbinit is available as
   /usr/local/share/examples/psim-freebsd/dot.gdbinit:

	display/i $pc
	define pglobal
		print *(struct globaldata *)$sprg0
	end
	target sim -e chirp -r 33554432
	set architecture powerpc:604
	load

# psim-freebsd kernel.debug 
GNU gdb 20011012 (MI_OUT)
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-portbld-freebsd5.0 --target=powerpc-freebsd-elf"...
Connected to the simulator.
The target architecture is assumed to be powerpc:604
chirp: note descriptor missing load-base
(gdb) b cpu_switch
Breakpoint 1 at 0x1d8d58
(gdb) run
Starting program: /usr/vsrc/sys/powerpc/compile/GENERIC/kernel.debug 
Copyright (c) 1992-2001 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT #0: Fri Oct 12 12:47:40 PDT 2001
    root@netppc:/mnt/vsrc/sys/powerpc/compile/GENERIC
CPU: PowerPC Version 0 (Revision 0)
real memory  = 33554432 (32768K bytes)
avail memory = 29794304 (29096K bytes)
Timecounter "powerpc"  frequency 16666666 Hz
rn_init: radix functions require max_keylen be set
Mounting root from ufs:/dev/md0c

Breakpoint 1, 0x001d8d58 in cpu_switch ()
1: x/i $pc  0x1d8d58 <cpu_switch+24>:   mfsprg  r3,0
(gdb) where
#0  0x001d8d58 in cpu_switch ()
#1  0x0014baa4 in mi_switch () at ../../../kern/kern_synch.c:765
#2  0x0014af0c in msleep (ident=0x308cf8, mtx=0x0, priority=68, 
    wmesg=0x1e27f8 "sched", timo=1000) at ../../../kern/kern_synch.c:484
#3  0x001c0e58 in scheduler (dummy=0xcda) at ../../../vm/vm_glue.c:439
#4  0x0011d720 in mi_startup () at ../../../kern/init_main.c:209
#5  0x00114880 in kernel_text ()
(gdb) 

More information on PSIM can be found here: <http://sources.redhat.com/psim>
