PERFORCE change 101019 for review

Wojciech A. Koszek wkoszek at FreeBSD.org
Sat Jul 8 14:19:02 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=101019

Change 101019 by wkoszek at wkoszek_laptop on 2006/07/08 14:18:39

	
	Bring some readable macros from juli's code to include/asm.h. Remove
	those from include/asmacros.h. One is used by the kernelland, and
	another one by the userland, but I don't need to distinguish this
	differece, since we've concentrated on the kernel side of the
	problem.
	
	Bring juli's locore.S stuff. Should be reviewed and checked with the
	MIPS 4Kc specification. The last page of "Hardware initialization"
	chapter gives nice description how this should look like.
	Addtionally NetBSD's locore.S also have probably some differences
	from what I've noticed.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/include/asm.h#2 edit
.. //depot/projects/mips2/src/sys/mips/include/asmacros.h#2 edit
.. //depot/projects/mips2/src/sys/mips/mips/locore.S#5 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/include/asm.h#2 (text+ko) ====

@@ -96,14 +96,40 @@
 #endif
 #endif
 
-#ifdef notyet
+/*
+ * XXXMIPS: I don't like #ifdef noyet, since vim doesn't seem to understand
+ * it.
+ */
+#if 0
 /*
  * Load the global pointer.
  */
 #define	LDGP(reg)						\
 	ldgp	gp, 0(reg)
+#endif /* notyet */
+
+/*
+ * XXXMIPS: Stolen from juli's code.
+ * begin
+ */
+
+#define	GLOBAL(sym)						\
+	.globl sym; sym:
 
-#endif
+#define	XLEAF(sym)						\
+	.globl sym; sym:
+
+#define	LEAF(sym)						\
+	.globl sym; sym: .frame sp, 0, ra
+
+#define	ENTRY(sym)						\
+	.text; .globl sym; sym:
+
+#define	END(sym)
+
+/* XXXMIPS: end */
+
+
 
 #define RCSID(x)	.text; .asciz x
 

==== //depot/projects/mips2/src/sys/mips/include/asmacros.h#2 (text+ko) ====

@@ -34,6 +34,7 @@
 
 #include <sys/cdefs.h>
 
+#if 0
 /* XXX too much duplication in various asm*.h's. */
 
 /*
@@ -190,5 +191,5 @@
 	addq $PC_ ## member, reg
 
 #endif /* LOCORE */
-
+#endif
 #endif /* !_MACHINE_ASMACROS_H_ */

==== //depot/projects/mips2/src/sys/mips/mips/locore.S#5 (text+ko) ====

@@ -1,21 +1,21 @@
 /*-
- * Copyright (c) 2006 Fill this file and put your name here
+ * Copyright (c) 2003-2004 Juli Mallett <jmallett at FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
@@ -23,16 +23,96 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
+ * $FreeBSD$
  */
 
-#include "assym.s"
 #include <machine/asm.h>
 #include <machine/asmacros.h>
-__FBSDID("$FreeBSD$");
+#include <machine/cpuregs.h>
+#include <machine/param.h>
+
+#include "assym.s"
+
+	.data
+GLOBAL(stackspace)
+	.space PAGE_SIZE /* Smaller than it should be since it's temp. */
+GLOBAL(topstack)
+
+	.set noreorder
 
+	.text
+GLOBAL(btext)
+ENTRY(_start)
+	/*
+	 * t0: Bits to preserve if set:
+	 * 	Soft reset
+	 *	Boot exception vectors (firmware-provided)
+	 */
+	li	t0, MIPS_SR_BEV | MIPS_SR_SR
+	/*
+	 * t1: Bits to set explicitly:
+	 *	Kernel mode is 64-bit
+	 *	Enable FPU
+	 */
 /*
- * XXXMIPS: Fill this later.
+ * XXXMIPS: look at this. I think "Kernel mode is 64-bit" == MIPS_SR_KX, so
+ * it's probably worth to remove it soon.
  */
-ENTRY(btext)
-ENTRY(_start)
+	li	t1, MIPS_SR_KX | MIPS_SR_COP_1_BIT
+
+	/*
+	 * Read coprocessor 0 status register, clear bits not
+	 * preserved (namely, clearing interrupt bits), and set
+	 * bits we want to explicitly set.
+	 */
+	mfc0	t2, MIPS_COP_0_STATUS
+	and	t2, t0
+	or	t2, t1
+	mtc0	t2, MIPS_COP_0_STATUS
+	COP0_SYNC
+	/* Extra nops for the FPU to spin up. */
+
+	/* Clear cause register. */
+	mtc0	zero, MIPS_COP_0_CAUSE
+	COP0_SYNC
+
+	/* Read and store the PrID FPU ID for CPU identification. */
+	mfc0	t0, MIPS_COP_0_PRID
+	cfc1	t1, MIPS_FPU_ID
+	sw	t0, cpu_id
+	sw	t1, fpu_id
+
+	/*
+	 * Set up the GP.
+	 * XXXMIPS: I did 'dla' -> 'la' conversion here.
+	 */
+	la	gp, _gp
+
+	/*
+	 * Set up our temporary stack.
+	 * XXXMIPS: I did 'dla' -> 'la' conversion here.
+	 */
+	la	sp, topstack
+
+
+
+	/* Call the platform-specific startup code. */
+	jal	platform_start
+	nop
+
+	/*
+	 * XXXMIPS: invalid opcodes here.
+	 */
+#if 0
+	lw	k0, pcpup
+	lw	k0, PC_CURTHREAD(k0)
+	lw	k0, TD_PCB(k0)
+	lw	k0, PCB_REG_SP(k0)
+#endif
+
+	/* Start MI things rolling. */
+	jal	mi_startup
 	nop
+
+	/* NOTREACHED */
+END(start)


More information about the p4-projects mailing list