[vmips] VMIPS v1.3.1 patch to fix CP0 context register (Linux runs!)

Cable Guy donimus at gmail.com
Wed Feb 2 16:57:54 CST 2005


This has taken a lot longer than I thought it would.  I wanted to put
together an RPM of my toolchain to distribute along with this patch
but getting RPM to handle building a cross-compiling toolchain is near
impossible as far as I can tell.  So I won't be doing that.  The setup
and maintenance of the toolchain, uClibc, BusyBox and the kernel's
initial RAM disk is something I have down to a science :)  But it
would take many pages to describe and explain so I'll leave that for
another time.

I also wanted to include my patches and files that allow the VMIPS
sample/xmboot ROM monitor code to link right in with the Linux kernel 
This includes handling the building of uClibc, BusyBox, and the
creation of the Linux initial ram disk (initrd) that gets embedded
into the kernel.  These things are incredibly intertwined and between
the cross-compiler, uClibc, BusyBox, the kernel headers and the kernel
configuration there is a fine line that separates them and prevents
circular dependencies.  Amost everything depends on almost everything
else.  I've found it best to rebuild everything when I make a change
to any one piece.  It takes longer and is probably unecessary, but it
gives me peace of mind.  Regardless, now that Linux boots on VMIPS the
need for merging the xmboot code into the kernel is not as great: I
was doing it mainly for debugging purposes and gdb symbol visibility.

I will try to answer any questions anyone might have.  Please post
them to the VMIPS mailing list.  Keep in mind that I am not a miracle
worker.  I almost gave up on this several times.  It all seems so
very, very fragile at times; like it's all hanging by a single thread
that's very easy to break.  When you change one little thing it will
break somewhere else that appears totally unrelated.  A lot of that
may have been due to the bug in the VMIPS exception handling.

The good news is that the VMIPS bug was one that could very easily
cause major disruptions to the way normal MIPS code is supposed to
run.  Since finding the root cause of this problem in the VMIPS code
it all seems a LOT more stable now.

I'm not suer how Gmail handles the formatting of the patch text so if
something else needs to be done let me know.  I was going to gzip the
patch files and post them as attachments but some mailing list
software deletes attachments so I pasted them inline below.

===================================================

This patch alters the Linux 2.4.28 kernel source so that:

1. "make mrproper" in the kernel source root directory will no longer
erase your .config file.  This is not a VMIPS patch per se, but it's a
change I make to every kernel source tree I work with.
2. Modifies the kernel command line parameters for VMIPS
3. Fixes the MIPS kernel shutdown/halt code so that interrupts are
disabled before returning to the ROM monitor
4.Handles initrd processing correctly
5. Reduce the number of RAMDISKs from 16 to 2 for performance

The kernel config file is a bare minimum setup to run Linux.  It
should be possible to enable other options and features now but I have
not tried anything beyond this.  If someone were to code up a virtual
ethernet device for VMIPS there are a LOT of other things that could
be done, such as using an NFS-mounted root filesystem which would be
the starting point for really stress-testing VMIPS.  You could then
run real Linux components and not be limited to uClibc and BusyBox. 
That would be way cool.

*** begin patch -- cut here ***
diff -urN linux-2.4.28/Makefile linux-2.4.28-vmips/Makefile
--- linux-2.4.28/Makefile	2004-11-17 06:54:22.000000000 -0500
+++ linux-2.4.28-vmips/Makefile	2005-01-12 10:29:29.000000000 -0500
@@ -243,7 +243,7 @@
 	drivers/sound/pndsperm.c \
 	drivers/sound/pndspini.c \
 	drivers/atm/fore200e_*_fw.c drivers/atm/.fore200e_*.fw \
-	.version .config* config.in config.old \
+	.version config.in config.old \
 	scripts/tkparse scripts/kconfig.tk scripts/kconfig.tmp \
 	scripts/lxdialog/*.o scripts/lxdialog/lxdialog \
 	.menuconfig.log \
diff -urN linux-2.4.28/arch/mips/dec/prom/cmdline.c
linux-2.4.28-vmips/arch/mips/dec/prom/cmdline.c
--- linux-2.4.28/arch/mips/dec/prom/cmdline.c	2003-08-25
07:44:39.000000000 -0400
+++ linux-2.4.28-vmips/arch/mips/dec/prom/cmdline.c	2005-01-11
03:28:35.000000000 -0500
@@ -13,7 +13,7 @@
 
 #undef PROM_DEBUG
 
-char arcs_cmdline[CL_SIZE];
+char arcs_cmdline[CL_SIZE] = { "root=/dev/ram0 rw load_ramdisk=1
console=ttyS3,9600n8" };
 
 void __init prom_init_cmdline(s32 argc, s32 *argv, u32 magic)
 {
diff -urN linux-2.4.28/arch/mips/dec/reset.c
linux-2.4.28-vmips/arch/mips/dec/reset.c
--- linux-2.4.28/arch/mips/dec/reset.c	2003-08-25 07:44:39.000000000 -0400
+++ linux-2.4.28-vmips/arch/mips/dec/reset.c	2005-01-19 09:05:24.000000000 -0500
@@ -7,22 +7,26 @@
 
 #include <asm/addrspace.h>
 #include <asm/ptrace.h>
+#include <asm/system.h>
 
 #define back_to_prom()	(((void (*)(void))KSEG1ADDR(0x1fc00000))())
 
 void dec_machine_restart(char *command)
 {
+	local_irq_disable();
 	back_to_prom();
 }
 
 void dec_machine_halt(void)
 {
+	local_irq_disable();
 	back_to_prom();
 }
 
 void dec_machine_power_off(void)
 {
     /* DECstations don't have a software power switch */
+	local_irq_disable();
 	back_to_prom();
 }
 
diff -urN linux-2.4.28/arch/mips/kernel/setup.c
linux-2.4.28-vmips/arch/mips/kernel/setup.c
--- linux-2.4.28/arch/mips/kernel/setup.c	2004-02-18 08:36:30.000000000 -0500
+++ linux-2.4.28-vmips/arch/mips/kernel/setup.c	2004-12-15
03:44:44.000000000 -0500
@@ -381,10 +381,15 @@
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Board specific code should have set up initrd_start and initrd_end */
 	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
-	if (&__rd_start != &__rd_end) {
+
+	// Well, DECStation setup DOES NOT initialize these properly so
+	// let's do it regardless of what __rd_start and __rd_end are set to.
+
+
+//	if (&__rd_start != &__rd_end) {
 		initrd_start = (unsigned long)&__rd_start;
 		initrd_end = (unsigned long)&__rd_end;
-	}
+//	}
 	initrd_below_start_ok = 1;
 	if (initrd_start) {
 		unsigned long initrd_size = ((unsigned char *)initrd_end) -
((unsigned char *)initrd_start);
diff -urN linux-2.4.28/drivers/block/rd.c linux-2.4.28-vmips/drivers/block/rd.c
--- linux-2.4.28/drivers/block/rd.c	2004-08-07 19:26:04.000000000 -0400
+++ linux-2.4.28-vmips/drivers/block/rd.c	2005-01-06 09:20:13.000000000 -0500
@@ -61,7 +61,7 @@
 #include <linux/blkpg.h>
 
 /* The RAM disk size is now a parameter */
-#define NUM_RAMDISKS 16		/* This cannot be overridden (yet) */ 
+#define NUM_RAMDISKS 2		/* This cannot be overridden (yet) */ 
 
 #ifdef CONFIG_BLK_DEV_INITRD
 static int initrd_users;
diff -urN linux-2.4.28/include/asm-mips/page.h
linux-2.4.28-vmips/include/asm-mips/page.h
--- linux-2.4.28/include/asm-mips/page.h	2004-02-18 08:36:32.000000000 -0500
+++ linux-2.4.28-vmips/include/asm-mips/page.h	2005-01-18
05:30:56.000000000 -0500
@@ -13,8 +13,6 @@
 #include <linux/config.h>
 #include <asm/break.h>
 
-#ifdef __KERNEL__
-
 /*
  * PAGE_SHIFT determines the page size
  */
@@ -30,6 +28,8 @@
 #define PAGE_SIZE	(1L << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
+#ifdef __KERNEL__
+
 #ifndef __ASSEMBLY__
 
 #include <asm/cacheflush.h>
diff -urN linux-2.4.28/include/asm-mips64/page.h
linux-2.4.28-vmips/include/asm-mips64/page.h
--- linux-2.4.28/include/asm-mips64/page.h	2004-02-18 08:36:32.000000000 -0500
+++ linux-2.4.28-vmips/include/asm-mips64/page.h	2005-01-05
01:41:44.000000000 -0500
@@ -12,8 +12,6 @@
 #include <linux/config.h>
 #include <asm/break.h>
 
-#ifdef __KERNEL__
-
 /*
  * PAGE_SHIFT determines the page size
  */
@@ -29,6 +27,8 @@
 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
+#ifdef __KERNEL__
+
 #ifndef __ASSEMBLY__
 
 #include <asm/cacheflush.h>
diff -urN linux-2.4.28/.config linux-2.4.28-vmips/.config
--- linux-2.4.28/.config	1969-12-31 19:00:00.000000000 -0500
+++ linux-2.4.28-vmips/.config	2005-01-18 05:30:14.000000000 -0500
@@ -0,0 +1,513 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+CONFIG_MIPS32=y
+# CONFIG_MIPS64 is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_MIPS_BOSPORUS is not set
+# CONFIG_MIPS_MIRAGE is not set
+# CONFIG_MIPS_DB1000 is not set
+# CONFIG_MIPS_DB1100 is not set
+# CONFIG_MIPS_DB1500 is not set
+# CONFIG_MIPS_PB1000 is not set
+# CONFIG_MIPS_PB1100 is not set
+# CONFIG_MIPS_PB1500 is not set
+# CONFIG_MIPS_HYDROGEN3 is not set
+# CONFIG_MIPS_PB1550 is not set
+# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_MIPS_MTX1 is not set
+# CONFIG_COGENT_CSB250 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_CASIO_E55 is not set
+# CONFIG_MIPS_COBALT is not set
+CONFIG_DECSTATION=y
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_HP_LASERJET is not set
+# CONFIG_IBM_WORKPAD is not set
+# CONFIG_LASAT is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SEAD is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_MOMENCO_OCELOT_G is not set
+# CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_JAGUAR_ATX is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_NEC_OSPREY is not set
+# CONFIG_NEC_EAGLE is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_NINO is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SIBYTE_SB1xxx_SOC is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_TANBAC_TB0226 is not set
+# CONFIG_TANBAC_TB0229 is not set
+# CONFIG_TOSHIBA_JMR3927 is not set
+# CONFIG_TOSHIBA_RBTX4927 is not set
+# CONFIG_VICTOR_MPC30X is not set
+# CONFIG_ZAO_CAPCELLA is not set
+# CONFIG_HIGHMEM is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_BOOT_ELF32=y
+CONFIG_IRQ_CPU=y
+CONFIG_L1_CACHE_SHIFT=4
+CONFIG_NEW_TIME_C=y
+CONFIG_NONCOHERENT_IO=y
+# CONFIG_MIPS_AU1000 is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+CONFIG_CPU_R3000=y
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_RM9000 is not set
+# CONFIG_CPU_SB1 is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_CPU_ADVANCED is not set
+# CONFIG_CPU_HAS_LLSC is not set
+# CONFIG_CPU_HAS_LLDSCD is not set
+CONFIG_CPU_HAS_WB=y
+# CONFIG_CPU_HAS_SYNC is not set
+
+#
+# General setup
+#
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_NET=y
+# CONFIG_PCI is not set
+# CONFIG_ISA is not set
+# CONFIG_TC is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+# CONFIG_HOTPLUG_PCI is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+CONFIG_KCORE_ELF=y
+# CONFIG_KCORE_AOUT is not set
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_MIPS32_COMPAT is not set
+# CONFIG_MIPS32_O32 is not set
+# CONFIG_MIPS32_N32 is not set
+# CONFIG_BINFMT_ELF32 is not set
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_OOM_KILLER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play configuration
+#
+# CONFIG_PNP is not set
+# CONFIG_ISAPNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_CISS_SCSI_TAPE is not set
+# CONFIG_CISS_MONITOR_THREAD is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_BLK_STATS is not set
+
+#
+# MIPS initrd options
+#
+# CONFIG_EMBEDDED_RAMDISK is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_MD_MULTIPATH is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK_DEV is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+# CONFIG_INET is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+
+#
+# Appletalk devices
+#
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+# CONFIG_FUSION_BOOT is not set
+# CONFIG_FUSION_ISENSE is not set
+# CONFIG_FUSION_CTL is not set
+# CONFIG_FUSION_LAN is not set
+
+#
+# Network device support
+#
+# CONFIG_NETDEVICES is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_UINPUT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+# CONFIG_CYCLADES is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_DIGI is not set
+# CONFIG_ESPSERIAL is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_SYNCLINK is not set
+# CONFIG_SYNCLINKMP is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_RISCOM8 is not set
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+# CONFIG_SERIAL_TX3912 is not set
+# CONFIG_SERIAL_TX3912_CONSOLE is not set
+# CONFIG_SERIAL_TXX9 is not set
+# CONFIG_SERIAL_TXX9_CONSOLE is not set
+# CONFIG_TXX927_SERIAL is not set
+CONFIG_SERIAL_DEC=y
+CONFIG_SERIAL_DEC_CONSOLE=y
+CONFIG_DZ=y
+# CONFIG_ZS is not set
+# CONFIG_UNIX98_PTYS is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_IPMI_PANIC_EVENT is not set
+# CONFIG_IPMI_DEVICE_INTERFACE is not set
+# CONFIG_IPMI_KCS is not set
+# CONFIG_IPMI_WATCHDOG is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_SCx200 is not set
+# CONFIG_SCx200_GPIO is not set
+# CONFIG_AMD_PM768 is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_MIPS_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+
+#
+# Direct Rendering Manager (XFree86 DRI support)
+#
+# CONFIG_DRM is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+# CONFIG_QFMT_V2 is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BEFS_DEBUG is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_TMPFS is not set
+CONFIG_RAMFS=y
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_ZISOFS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_TRACE is not set
+# CONFIG_XFS_DEBUG is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_NFS_FS is not set
+# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_ROOT_NFS is not set
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+# CONFIG_NFSD_TCP is not set
+# CONFIG_SUNRPC is not set
+# CONFIG_LOCKD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_ZISOFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# Support for USB gadgets
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BLUEZ is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_RUNTIME_DEBUG is not set
+# CONFIG_KGDB is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
+CONFIG_LOG_BUF_SHIFT=0
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC32 is not set
+CONFIG_ZLIB_INFLATE=y
+# CONFIG_ZLIB_DEFLATE is not set
*** end patch -- cut here ***

===================================================

This patch corrects the way VMIPS handles the CP0 Context register
during an exception.  I found the information to make this change at
http://cgi.cse.unsw.edu.au/~cs3231/doc/mips.php  Under the
"c0_context" heading it talks about the BadVPN field in relation to
the failing virtual address and KUSEG faults.  Additionally, under the
"Exceptions" section, it talks about what happens to the various
registers when an exception occurs.  NOTE: It appears as though
c0_vaddr also needs to be set for exceptions AdEL and AdES.  VMIPS
doesn't do this.  I tried adding some code to do it but ran into some
problems so I undid my changes in that area.  Perhaps a little more
needs to be done in that area, but Linux works without those changes
so I left it alone.  After applying this patch I did a trace of the
TLB table contents and the weirdness I had observed disappeared and
Linux actually ran on the VMIPS virtual machine.  What a great
program.

*** start patch -- cut here ***
diff -urN vmips-1.3.1/cpzero.cc vmips-1.3.1-patched/cpzero.cc
--- vmips-1.3.1/cpzero.cc	2005-01-06 16:04:54.000000000 -0500
+++ vmips-1.3.1-patched/cpzero.cc	2005-01-21 08:00:53.928288000 -0500
@@ -134,8 +134,10 @@
 			return vaddr - KSEG1_CONST_TRANSLATION;
 		case KSEG2:
 		case KSEG2_top:
+			*cacheable = true;
 			return tlb_translate(KSEG2, vaddr, mode, cacheable, client);
 		default: /* KUSEG */
+			*cacheable = true;
 			return tlb_translate(KUSEG, vaddr, mode, cacheable, client);
 		}
 	}
@@ -154,7 +156,7 @@
 CPZero::load_addr_trans_excp_info(uint32 va, uint32 vpn, TLBEntry *match)
 {
 	reg[BadVAddr] = va;
-	reg[Context] = (reg[Context] & ~Context_BadVPN_MASK) | (vpn >> 6);
+	reg[Context] = (reg[Context] & ~Context_BadVPN_MASK) | ((vpn &
Context_VPN_MASK) >> 10);
 	reg[EntryHi] = (va & EntryHi_VPN_MASK) | (reg[EntryHi] & ~EntryHi_VPN_MASK);
 }
 
diff -urN vmips-1.3.1/cpzeroreg.h vmips-1.3.1-patched/cpzeroreg.h
--- vmips-1.3.1/cpzeroreg.h	2003-05-29 01:17:28.000000000 -0400
+++ vmips-1.3.1-patched/cpzeroreg.h	2005-01-21 07:59:40.738288000 -0500
@@ -109,6 +109,7 @@
 #define Context_PTEBase_MASK 0xffe00000          /* Page Table Base (31-21) */
 #define Context_BadVPN_MASK 0x001ffffc      /* Bad Virtual Page num. (20-2) */
 #define Context_MASK 0xfffffffc
+#define Context_VPN_MASK 0x7ffff000
 
 /* (5) PageMask is only on the R4k */
 #define PageMask_MASK 0x00000000
*** end patch -- cut here ***

Have fun and sorry for the delay in getting this posted.


More information about the Vmips mailing list