diff options
author | obrien <obrien@FreeBSD.org> | 2001-10-13 05:42:54 +0800 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-10-13 05:42:54 +0800 |
commit | 7b0e7fb5d9536e702ae5a7be155131872bc196b9 (patch) | |
tree | c641f4d715c1d1fdb5b66689247c13de6eba9fa5 | |
parent | 69ba7e0a0624c0ec9f939a08fcbfea0a232e28a2 (diff) | |
download | freebsd-ports-graphics-7b0e7fb5d9536e702ae5a7be155131872bc196b9.tar.gz freebsd-ports-graphics-7b0e7fb5d9536e702ae5a7be155131872bc196b9.tar.zst freebsd-ports-graphics-7b0e7fb5d9536e702ae5a7be155131872bc196b9.zip |
PowerPC PSIM simulator for FreeBSD/PowerPC kernel development.
Submitted by: mp (emblishment by me)
-rw-r--r-- | emulators/Makefile | 1 | ||||
-rw-r--r-- | emulators/psim-freebsd/Makefile | 43 | ||||
-rw-r--r-- | emulators/psim-freebsd/distinfo | 1 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/HOW-TO | 69 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/README.patches | 22 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/dot.gdbinit | 7 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/patch-emul_chirp.c | 15 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/patch-hw_cpu.c | 63 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/patch-hw_init.c | 13 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/patch-hw_tab.c | 16 | ||||
-rw-r--r-- | emulators/psim-freebsd/files/patch-ppc-spr-table | 17 | ||||
-rw-r--r-- | emulators/psim-freebsd/pkg-comment | 1 | ||||
-rw-r--r-- | emulators/psim-freebsd/pkg-descr | 3 | ||||
-rw-r--r-- | emulators/psim-freebsd/pkg-plist | 4 |
14 files changed, 275 insertions, 0 deletions
diff --git a/emulators/Makefile b/emulators/Makefile index f17e3aad6d1..b3372851f37 100644 --- a/emulators/Makefile +++ b/emulators/Makefile @@ -36,6 +36,7 @@ SUBDIR += p-interp SUBDIR += pcemu SUBDIR += prodosemu + SUBDIR += psim-freebsd SUBDIR += qcl SUBDIR += quasi88 SUBDIR += rtc diff --git a/emulators/psim-freebsd/Makefile b/emulators/psim-freebsd/Makefile new file mode 100644 index 00000000000..d6f36485ba2 --- /dev/null +++ b/emulators/psim-freebsd/Makefile @@ -0,0 +1,43 @@ +# ex:ts=8 +# Ports collection makefile for: GDB 5.1 PowerPC simulator +# Date created: 12 October 2001 +# Whom: Mark Peek <mp@FreeBSD.org> +# David O'Brien <obrien@NUXI.com> +# $FreeBSD$ +# + +SNAPDATE= 2001-10-12 +SNAPVER= ${SNAPDATE:S/-//g} + +PORTNAME= psim-freebsd +PORTVERSION= ${SNAPVER} +CATEGORIES= emulators +MASTER_SITES= ${MASTER_SITE_SOURCEWARE} +MASTER_SITE_SUBDIR= gdb/snapshots +DISTNAME= gdb+dejagnu-${SNAPVER} + +MAINTAINER= mp@FreeBSD.org + +USE_BZIP2= yes + +.include <bsd.port.pre.mk> + +USE_GMAKE= yes +GNU_CONFIGURE= yes +CONFIGURE_TARGET= ${ARCH}-portbld-freebsd${OSREL} +CONFIGURE_ARGS= --enable-psim --target=powerpc-freebsd-elf --program-suffix=psim + +pre-configure: + cd ${WRKSRC} ; ${RM} -rf dejagnu expect tcl texinfo + +do-install: + ${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb ${PREFIX}/bin/${PORTNAME} + ${MKDIR} ${PREFIX}/share/examples/${PORTNAME} + ${INSTALL_DATA} ${FILESDIR}/dot.gdbinit \ + ${PREFIX}/share/examples/${PORTNAME} +.if !defined(NOPORTDOCS) + @${MKDIR} ${DOCSDIR} + ${INSTALL_DATA} ${FILESDIR}/HOW-TO ${DOCSDIR} +.endif + +.include <bsd.port.post.mk> diff --git a/emulators/psim-freebsd/distinfo b/emulators/psim-freebsd/distinfo new file mode 100644 index 00000000000..5f727c648a8 --- /dev/null +++ b/emulators/psim-freebsd/distinfo @@ -0,0 +1 @@ +MD5 (gdb+dejagnu-20011012.tar.bz2) = 6e9dc1079113a64447b804018e8cfc07 diff --git a/emulators/psim-freebsd/files/HOW-TO b/emulators/psim-freebsd/files/HOW-TO new file mode 100644 index 00000000000..1522bb9baaf --- /dev/null +++ b/emulators/psim-freebsd/files/HOW-TO @@ -0,0 +1,69 @@ +$FreeBSD$ + +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, apply the Makefile.patch + to add the proper CWARN flags and remove the "-elf" flag. + + 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 + +5. 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) diff --git a/emulators/psim-freebsd/files/README.patches b/emulators/psim-freebsd/files/README.patches new file mode 100644 index 00000000000..cb5ea275581 --- /dev/null +++ b/emulators/psim-freebsd/files/README.patches @@ -0,0 +1,22 @@ +$FreeBSD$ + +Patch comments: + +sim/ppc/emul_chirp.c: +Add a mapping for the kernel to obtain the mapping for the +OpenFirmware callback. + +sim/ppc/hw_cpu.c: +Add the device type and timebase-frequency to the cpu device. +Add code to create an instance of the cpu for the translation of the +OpenFirmware callback. + +sim/ppc/hw_init.c: +Allow the simulator to load a dynamically linked OEA environment. + +sim/ppc/hw_tab.c: +Ignore warnings for the improper alignment of the htab. A better fix would be +to properly align the htab when the memory is allocated in the first place. + +sim/ppc/ppc-spr-table: +Correct 2 of the SPR entries to allow "info all-registers" to work when the diff --git a/emulators/psim-freebsd/files/dot.gdbinit b/emulators/psim-freebsd/files/dot.gdbinit new file mode 100644 index 00000000000..b4e6b167420 --- /dev/null +++ b/emulators/psim-freebsd/files/dot.gdbinit @@ -0,0 +1,7 @@ +display/i $pc +define pglobal + print *(struct globaldata *)$sprg0 +end +target sim -e chirp -r 33554432 +set architecture powerpc:604 +load diff --git a/emulators/psim-freebsd/files/patch-emul_chirp.c b/emulators/psim-freebsd/files/patch-emul_chirp.c new file mode 100644 index 00000000000..06b6ec622ed --- /dev/null +++ b/emulators/psim-freebsd/files/patch-emul_chirp.c @@ -0,0 +1,15 @@ +diff -r -u sim/ppc/emul_chirp.c /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/emul_chirp.c +--- sim/ppc/emul_chirp.c Thu Apr 15 18:35:09 1999 ++++ /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/emul_chirp.c Sun Oct 7 16:16:57 2001 +@@ -1884,6 +1884,11 @@ + (unsigned long)chirp->sizeof_code); + tree_parse(node, "./wimg %d", 0x7); + tree_parse(node, "./pp %d", 0x2); ++ node = tree_parse(root, "/cpus/cpu@0"); ++ tree_parse(node, "./translations 0x%lx 0x%lx 0x%0lx 0x%0lx 0x%0lx", ++ (unsigned long)chirp->code_va, (unsigned long)chirp->sizeof_code, ++ (unsigned long)chirp->code_ra, 0); ++ node = tree_parse(root, "/chosen/mmu */cpus/cpu@0"); + } + + /* map in the program to run */ diff --git a/emulators/psim-freebsd/files/patch-hw_cpu.c b/emulators/psim-freebsd/files/patch-hw_cpu.c new file mode 100644 index 00000000000..dedb2c75363 --- /dev/null +++ b/emulators/psim-freebsd/files/patch-hw_cpu.c @@ -0,0 +1,63 @@ +diff -r -u sim/ppc/hw_cpu.c /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_cpu.c +--- sim/ppc/hw_cpu.c Thu Apr 15 18:35:09 1999 ++++ /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_cpu.c Sun Oct 7 16:16:57 2001 +@@ -110,6 +110,8 @@ + { + hw_cpu_device *hw_cpu = (hw_cpu_device*)device_data(me); + /* populate the node with properties */ ++ device_add_string_property(me, "device_type", "cpu"); ++ device_add_integer_property(me, "timebase-frequency", 0x00fe502a); + /* clear our data */ + memset(hw_cpu, 0x0, sizeof(hw_cpu_device)); + hw_cpu->cpu_nr = device_find_integer_property(me, "cpu-nr"); +@@ -148,6 +150,42 @@ + } + } + ++/* An instance of the cpu */ ++ ++typedef struct _hw_cpu_instance { ++ unsigned_word pos; ++ hw_cpu_device *cpu; ++ device *me; ++} hw_cpu_instance; ++ ++static void ++hw_cpu_instance_delete(device_instance *instance) ++{ ++ hw_cpu_instance *data = device_instance_data(instance); ++ zfree(data); ++} ++ ++static const device_instance_callbacks hw_cpu_instance_callbacks = { ++ hw_cpu_instance_delete, ++ NULL, ++ NULL, ++ NULL, ++}; ++ ++static device_instance * ++hw_cpu_create_instance(device *me, ++ const char *path, ++ const char *args) ++{ ++ hw_cpu_device *cpu = device_data(me); ++ hw_cpu_instance *data = ZALLOC(hw_cpu_instance); ++ data->cpu = cpu; ++ data->me = me; ++ return device_create_instance_from(me, NULL, ++ data, ++ path, args, ++ &hw_cpu_instance_callbacks); ++} + + static device_callbacks const hw_cpu_callbacks = { + { hw_cpu_init_address, }, /* init */ +@@ -156,6 +194,7 @@ + { NULL, }, /* DMA */ + { hw_cpu_interrupt_event, NULL, hw_cpu_interrupt_ports }, /* interrupts */ + { NULL, NULL, }, ++ hw_cpu_create_instance, + }; + + const device_descriptor hw_cpu_device_descriptor[] = { diff --git a/emulators/psim-freebsd/files/patch-hw_init.c b/emulators/psim-freebsd/files/patch-hw_init.c new file mode 100644 index 00000000000..e6481a876f8 --- /dev/null +++ b/emulators/psim-freebsd/files/patch-hw_init.c @@ -0,0 +1,13 @@ +diff -r -u sim/ppc/hw_init.c /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_init.c +--- sim/ppc/hw_init.c Thu May 10 10:48:10 2001 ++++ /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_init.c Fri Oct 12 11:31:51 2001 +@@ -350,7 +350,8 @@ + )); + + /* If there is an .interp section, it means it needs a shared library interpreter. */ +- if (strcmp(".interp", bfd_get_section_name(abfd, the_section)) == 0) ++ if (current_environment != OPERATING_ENVIRONMENT ++ && strcmp(".interp", bfd_get_section_name(abfd, the_section)) == 0) + error("Shared libraries are not yet supported.\n"); + + /* determine the devices access */ diff --git a/emulators/psim-freebsd/files/patch-hw_tab.c b/emulators/psim-freebsd/files/patch-hw_tab.c new file mode 100644 index 00000000000..d188e6d8796 --- /dev/null +++ b/emulators/psim-freebsd/files/patch-hw_tab.c @@ -0,0 +1,16 @@ +diff -r -u sim/ppc/hw_htab.c /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_htab.c +--- sim/ppc/hw_htab.c Thu Apr 15 18:35:09 1999 ++++ /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/hw_htab.c Sun Oct 7 16:16:57 2001 +@@ -224,10 +224,12 @@ + } + *htaborg = htab_ra; + *htabmask = MASKED32(htab_nr_bytes - 1, 7, 31-6); ++#if 0 + if ((htab_ra & INSERTED32(*htabmask, 7, 15)) != 0) { + device_error(parent, "htaborg 0x%lx not aligned to htabmask 0x%lx", + (unsigned long)*htaborg, (unsigned long)*htabmask); + } ++#endif + DTRACE(htab, ("htab - htaborg=0x%lx htabmask=0x%lx\n", + (unsigned long)*htaborg, (unsigned long)*htabmask)); + } diff --git a/emulators/psim-freebsd/files/patch-ppc-spr-table b/emulators/psim-freebsd/files/patch-ppc-spr-table new file mode 100644 index 00000000000..bfde32193fb --- /dev/null +++ b/emulators/psim-freebsd/files/patch-ppc-spr-table @@ -0,0 +1,17 @@ +diff -r -u sim/ppc/ppc-spr-table /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/ppc-spr-table +--- sim/ppc/ppc-spr-table Thu Apr 15 18:35:11 1999 ++++ /local2/gcc/ppc/gdb+dejagnu-20011007/sim/ppc/ppc-spr-table Fri Oct 12 11:05:25 2001 +@@ -69,6 +69,7 @@ + MMCR1:956:0:0 + PMC3:957:0:0 + PMC4:958:0:0 ++SDA:959:0:0 + DMISS:976:0:0 + DCMP:977:0:0 + HASH1:978:0:0 +@@ -85,4 +86,4 @@ + THRM1:1020:0:0 + THRM2:1021:0:0 + THRM3:1022:0:0 +-HID15:1023:0:0 ++PIR:1023:0:0 diff --git a/emulators/psim-freebsd/pkg-comment b/emulators/psim-freebsd/pkg-comment new file mode 100644 index 00000000000..b74cbfba51b --- /dev/null +++ b/emulators/psim-freebsd/pkg-comment @@ -0,0 +1 @@ +PowerPC simulator (PSIM) running in the GNU GDB 5 diff --git a/emulators/psim-freebsd/pkg-descr b/emulators/psim-freebsd/pkg-descr new file mode 100644 index 00000000000..1728b5d2a5b --- /dev/null +++ b/emulators/psim-freebsd/pkg-descr @@ -0,0 +1,3 @@ +PowerPC simulator (PSIM) running in the GNU GDB 5 + +WWW: http://sourceware.cygnus.com/psim/ diff --git a/emulators/psim-freebsd/pkg-plist b/emulators/psim-freebsd/pkg-plist new file mode 100644 index 00000000000..5c48a29e76f --- /dev/null +++ b/emulators/psim-freebsd/pkg-plist @@ -0,0 +1,4 @@ +@comment $FreeBSD$ +bin/psim-freebsd +share/examples/psim-freebsd/dot.gdbinit +%%PORTDOCS%%share/doc/psim-freebsd/HOW-TO |