mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-29 05:38:00 +00:00
PowerPC PSIM simulator for FreeBSD/PowerPC kernel development.
Submitted by: mp (emblishment by me)
This commit is contained in:
parent
10b84eefce
commit
7f3526b918
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=48720
@ -36,6 +36,7 @@
|
||||
SUBDIR += p-interp
|
||||
SUBDIR += pcemu
|
||||
SUBDIR += prodosemu
|
||||
SUBDIR += psim-freebsd
|
||||
SUBDIR += qcl
|
||||
SUBDIR += quasi88
|
||||
SUBDIR += rtc
|
||||
|
43
emulators/psim-freebsd/Makefile
Normal file
43
emulators/psim-freebsd/Makefile
Normal file
@ -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>
|
1
emulators/psim-freebsd/distinfo
Normal file
1
emulators/psim-freebsd/distinfo
Normal file
@ -0,0 +1 @@
|
||||
MD5 (gdb+dejagnu-20011012.tar.bz2) = 6e9dc1079113a64447b804018e8cfc07
|
69
emulators/psim-freebsd/files/HOW-TO
Normal file
69
emulators/psim-freebsd/files/HOW-TO
Normal file
@ -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)
|
22
emulators/psim-freebsd/files/README.patches
Normal file
22
emulators/psim-freebsd/files/README.patches
Normal file
@ -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
|
7
emulators/psim-freebsd/files/dot.gdbinit
Normal file
7
emulators/psim-freebsd/files/dot.gdbinit
Normal file
@ -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
|
15
emulators/psim-freebsd/files/patch-emul_chirp.c
Normal file
15
emulators/psim-freebsd/files/patch-emul_chirp.c
Normal file
@ -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 */
|
63
emulators/psim-freebsd/files/patch-hw_cpu.c
Normal file
63
emulators/psim-freebsd/files/patch-hw_cpu.c
Normal file
@ -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[] = {
|
13
emulators/psim-freebsd/files/patch-hw_init.c
Normal file
13
emulators/psim-freebsd/files/patch-hw_init.c
Normal file
@ -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 */
|
16
emulators/psim-freebsd/files/patch-hw_tab.c
Normal file
16
emulators/psim-freebsd/files/patch-hw_tab.c
Normal file
@ -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));
|
||||
}
|
17
emulators/psim-freebsd/files/patch-ppc-spr-table
Normal file
17
emulators/psim-freebsd/files/patch-ppc-spr-table
Normal file
@ -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
|
1
emulators/psim-freebsd/pkg-comment
Normal file
1
emulators/psim-freebsd/pkg-comment
Normal file
@ -0,0 +1 @@
|
||||
PowerPC simulator (PSIM) running in the GNU GDB 5
|
3
emulators/psim-freebsd/pkg-descr
Normal file
3
emulators/psim-freebsd/pkg-descr
Normal file
@ -0,0 +1,3 @@
|
||||
PowerPC simulator (PSIM) running in the GNU GDB 5
|
||||
|
||||
WWW: http://sourceware.cygnus.com/psim/
|
4
emulators/psim-freebsd/pkg-plist
Normal file
4
emulators/psim-freebsd/pkg-plist
Normal file
@ -0,0 +1,4 @@
|
||||
@comment $FreeBSD$
|
||||
bin/psim-freebsd
|
||||
share/examples/psim-freebsd/dot.gdbinit
|
||||
%%PORTDOCS%%share/doc/psim-freebsd/HOW-TO
|
Loading…
Reference in New Issue
Block a user