From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 00:33:55 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF7EE1065670;
	Sun, 28 Mar 2010 00:33:55 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AEAE08FC12;
	Sun, 28 Mar 2010 00:33:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S0XtK3046788;
	Sun, 28 Mar 2010 00:33:55 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S0XtDT046786;
	Sun, 28 Mar 2010 00:33:55 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280033.o2S0XtDT046786@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 00:33:55 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205782 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 00:33:55 -0000

Author: jmallett
Date: Sun Mar 28 00:33:55 2010
New Revision: 205782
URL: http://svn.freebsd.org/changeset/base/205782

Log:
  More PTR_ADDU and PTR_SUBU.

Modified:
  user/jmallett/octeon/sys/mips/mips/support.S

Modified: user/jmallett/octeon/sys/mips/mips/support.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 00:10:09 2010	(r205781)
+++ user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 00:33:55 2010	(r205782)
@@ -745,7 +745,7 @@ LEAF(memcpy)
 ALEAF(bcopy)
 ALEAF(ovbcopy)
 	.set	noreorder
-	addu	t0, a0, a2		# t0 = end of s1 region
+	PTR_ADDU	t0, a0, a2		# t0 = end of s1 region
 	sltu	t1, a1, t0
 	sltu	t2, a0, a1
 	and	t1, t1, t2		# t1 = true if from < to < (from+len)
@@ -753,11 +753,11 @@ ALEAF(ovbcopy)
 	slt	t2, a2, 12		# check for small copy
 
 	ble	a2, zero, 2f
-	addu	t1, a1, a2		# t1 = end of to region
+	PTR_ADDU	t1, a1, a2		# t1 = end of to region
 1:
 	lb	v1, -1(t0)		# copy bytes backwards,
-	subu	t0, t0, 1		#   doesnt happen often so do slow way
-	subu	t1, t1, 1
+	PTR_SUBU	t0, t0, 1		#   doesnt happen often so do slow way
+	PTR_SUBU	t1, t1, 1
 	bne	t0, a0, 1b
 	sb	v1, 0(t1)
 2:
@@ -767,59 +767,59 @@ forward:
 	bne	t2, zero, smallcpy	# do a small bcopy
 	xor	v1, a0, a1		# compare low two bits of addresses
 	and	v1, v1, 3
-	subu	a3, zero, a1		# compute # bytes to word align address
+	PTR_SUBU	a3, zero, a1		# compute # bytes to word align address
 	beq	v1, zero, aligned	# addresses can be word aligned
 	and	a3, a3, 3
 
 	beq	a3, zero, 1f
-	subu	a2, a2, a3		# subtract from remaining count
+	PTR_SUBU	a2, a2, a3		# subtract from remaining count
 	LWHI	v1, 0(a0)		# get next 4 bytes (unaligned)
 	LWLO	v1, 3(a0)
-	addu	a0, a0, a3
+	PTR_ADDU	a0, a0, a3
 	SWHI	v1, 0(a1)		# store 1, 2, or 3 bytes to align a1
-	addu	a1, a1, a3
+	PTR_ADDU	a1, a1, a3
 1:
 	and	v1, a2, 3		# compute number of words left
-	subu	a3, a2, v1
+	PTR_SUBU	a3, a2, v1
 	move	a2, v1
-	addu	a3, a3, a0		# compute ending address
+	PTR_ADDU	a3, a3, a0		# compute ending address
 2:
 	LWHI	v1, 0(a0)		# copy words a0 unaligned, a1 aligned
 	LWLO	v1, 3(a0)
-	addu	a0, a0, 4
+	PTR_ADDU	a0, a0, 4
 	sw	v1, 0(a1)
-	addu	a1, a1, 4
+	PTR_ADDU	a1, a1, 4
 	bne	a0, a3, 2b
 	nop				# We have to do this mmu-bug.
 	b	smallcpy
 	nop
 aligned:
 	beq	a3, zero, 1f
-	subu	a2, a2, a3		# subtract from remaining count
+	PTR_SUBU	a2, a2, a3		# subtract from remaining count
 	LWHI	v1, 0(a0)		# copy 1, 2, or 3 bytes to align
-	addu	a0, a0, a3
+	PTR_ADDU	a0, a0, a3
 	SWHI	v1, 0(a1)
-	addu	a1, a1, a3
+	PTR_ADDU	a1, a1, a3
 1:
 	and	v1, a2, 3		# compute number of whole words left
-	subu	a3, a2, v1
+	PTR_SUBU	a3, a2, v1
 	move	a2, v1
-	addu	a3, a3, a0		# compute ending address
+	PTR_ADDU	a3, a3, a0		# compute ending address
 2:
 	lw	v1, 0(a0)		# copy words
-	addu	a0, a0, 4
+	PTR_ADDU	a0, a0, 4
 	sw	v1, 0(a1)
 	bne	a0, a3, 2b
-	addu	a1, a1, 4
+	PTR_ADDU	a1, a1, 4
 smallcpy:
 	ble	a2, zero, 2f
-	addu	a3, a2, a0		# compute ending address
+	PTR_ADDU	a3, a2, a0		# compute ending address
 1:
 	lbu	v1, 0(a0)		# copy bytes
-	addu	a0, a0, 1
+	PTR_ADDU	a0, a0, 1
 	sb	v1, 0(a1)
 	bne	a0, a3, 1b
-	addu	a1, a1, 1	   # MMU BUG ? can not do -1(a1) at 0x80000000!!
+	PTR_ADDU	a1, a1, 1	   # MMU BUG ? can not do -1(a1) at 0x80000000!!
 2:
 	j	ra
 	nop
@@ -839,19 +839,19 @@ LEAF(memset)
 	sll	t2, t1, 16		# shift that left 16
 	or	t1, t2, t1		# or together
 
-	subu	t0, zero, a0		# compute # bytes to word align address
+	PTR_SUBU	t0, zero, a0		# compute # bytes to word align address
 	and	t0, t0, 3
 	beq	t0, zero, 1f		# skip if word aligned
-	subu	a2, a2, t0		# subtract from remaining count
+	PTR_SUBU	a2, a2, t0		# subtract from remaining count
 	SWHI	t1, 0(a0)		# store 1, 2, or 3 bytes to align
-	addu	a0, a0, t0
+	PTR_ADDU	a0, a0, t0
 1:
 	and	v1, a2, 3		# compute number of whole words left
-	subu	t0, a2, v1
-	subu	a2, a2, t0
-	addu	t0, t0, a0		# compute ending address
+	PTR_SUBU	t0, a2, v1
+	PTR_SUBU	a2, a2, t0
+	PTR_ADDU	t0, t0, a0		# compute ending address
 2:
-	addu	a0, a0, 4		# clear words
+	PTR_ADDU	a0, a0, 4		# clear words
 #ifdef MIPS3_5900
 	nop
 	nop
@@ -863,9 +863,9 @@ LEAF(memset)
 
 memsetsmallclr:
 	ble	a2, zero, 2f
-	addu	t0, a2, a0		# compute ending address
+	PTR_ADDU	t0, a2, a0		# compute ending address
 1:
-	addu	a0, a0, 1		# clear bytes
+	PTR_ADDU	a0, a0, 1		# clear bytes
 #ifdef MIPS3_5900
 	nop
 	nop

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 00:58:21 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3847B106566B;
	Sun, 28 Mar 2010 00:58:20 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 46D6C8FC2B;
	Sun, 28 Mar 2010 00:58:20 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S0wKjS052116;
	Sun, 28 Mar 2010 00:58:20 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S0wKEL052111;
	Sun, 28 Mar 2010 00:58:20 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280058.o2S0wKEL052111@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 00:58:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205783 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 00:58:21 -0000

Author: jmallett
Date: Sun Mar 28 00:58:19 2010
New Revision: 205783
URL: http://svn.freebsd.org/changeset/base/205783

Log:
  o) Push XKPHYS stuff into pmap aggressively.
  o) Fix some pointer-width issues in exception.S and use <machine/asm.h>'s macros
     for things rather than file-local ones.
  o) Go back to making the PDE entries pointers for now.

Modified:
  user/jmallett/octeon/sys/mips/include/cpuregs.h
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/mips/exception.S
  user/jmallett/octeon/sys/mips/mips/locore.S
  user/jmallett/octeon/sys/mips/mips/pmap.c

Modified: user/jmallett/octeon/sys/mips/include/cpuregs.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpuregs.h	Sun Mar 28 00:33:55 2010	(r205782)
+++ user/jmallett/octeon/sys/mips/include/cpuregs.h	Sun Mar 28 00:58:19 2010	(r205783)
@@ -103,6 +103,9 @@
 #define MIPS_KSEG2_START		MIPS_KSSEG_START
 #define MIPS_KSEG2_END			MIPS_KSSEG_END
 
+#define	MIPS_XKPHYS_START		0x8000000000000000
+#define	MIPS_XKPHYS_END			0xbfffffffffffffff
+
 #define	MIPS_XKPHYS_CCA_UC		0x02	/* Uncached.  */
 #define	MIPS_XKPHYS_CCA_CNC		0x03	/* Cacheable non-coherent.  */
 

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sun Mar 28 00:33:55 2010	(r205782)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sun Mar 28 00:58:19 2010	(r205783)
@@ -84,7 +84,7 @@ struct tlb {
 };
 
 typedef int32_t pt_entry_t;
-typedef int32_t pd_entry_t;
+typedef pt_entry_t *pd_entry_t;
 
 #define	PDESIZE		sizeof(pd_entry_t)	/* for assembly files */
 #define	PTESIZE		sizeof(pt_entry_t)	/* for assembly files */

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Sun Mar 28 00:33:55 2010	(r205782)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Sun Mar 28 00:58:19 2010	(r205783)
@@ -77,26 +77,12 @@
 #endif
 
 #ifdef WITH_64BIT_CP0
-#define _SLL	dsll
-#define	_SRL	dsrl
-#define	_MFC0	dmfc0
-#define	_MTC0	dmtc0
 #define WIRED_SHIFT 34
 #else
-#define _SLL	sll
-#define	_SRL	srl
-#define	_MFC0	mfc0
-#define	_MTC0	mtc0
 #define WIRED_SHIFT 2
 #endif
+
 	.set	noreorder			# Noreorder is default style!
-#if defined(ISA_MIPS32)
-	.set	mips32
-#elif defined(ISA_MIPS64)
-	.set	mips64
-#elif defined(ISA_MIPS3)
-	.set	mips3
-#endif
 
 /*
  * Reasonable limit
@@ -152,10 +138,13 @@ MipsDoTLBMiss:
 	GET_CPU_PCPU(k1)
 	PTR_L	k1, PC_SEGBASE(k1)
 	beqz	k1, 2f			      #05: make sure segbase is not null
+#if defined(__mips_n64)
+	andi	k0, k0, 0x7f8			#06: k0=seg offset (mask 0x7)
+#else
 	andi	k0, k0, 0x7fc			#06: k0=seg offset (mask 0x3)
-#xxx mips64 unsafe?
+#endif
 	PTR_ADDU	k1, k0, k1			#07: k1=seg entry address
-	lw	k1, 0(k1)			#08: k1=seg entry
+	PTR_L	k1, 0(k1)			#08: k1=seg entry
 	mfc0	k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
 	beq	k1, zero, 2f			#0a: ==0 -- no page table
 	srl	k0, PGSHIFT - 2			#0b: k0=VPN (aka va>>10)
@@ -165,12 +154,12 @@ MipsDoTLBMiss:
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
 	lw	k0, 0(k1)			#0e: k0=lo0 pte
 	lw	k1, 4(k1)			#0f: k1=lo1 pte
-	_SLL	k0, k0, WIRED_SHIFT		#10: keep bottom 30 bits
-	_SRL	k0, k0, WIRED_SHIFT		#11: keep bottom 30 bits
-	_MTC0	k0, COP_0_TLB_LO0		#12: lo0 is loaded
-	_SLL	k1, k1, WIRED_SHIFT		#13: keep bottom 30 bits
-	_SRL	k1, k1, WIRED_SHIFT		#14: keep bottom 30 bits
-	_MTC0	k1, COP_0_TLB_LO1		#15: lo1 is loaded
+	PTR_SLL	k0, k0, WIRED_SHIFT		#10: keep bottom 30 bits
+	PTR_SRL	k0, k0, WIRED_SHIFT		#11: keep bottom 30 bits
+	MTC0	k0, COP_0_TLB_LO0		#12: lo0 is loaded
+	PTR_SLL	k1, k1, WIRED_SHIFT		#13: keep bottom 30 bits
+	PTR_SRL	k1, k1, WIRED_SHIFT		#14: keep bottom 30 bits
+	MTC0	k1, COP_0_TLB_LO1		#15: lo1 is loaded
 	HAZARD_DELAY
 	tlbwr					#1a: write to tlb
 	HAZARD_DELAY
@@ -341,7 +330,7 @@ SlowFault:
 	RESTORE_REG(t1, MULHI, sp)	;\
 	mtlo	t0			;\
 	mthi	t1			;\
-	_MTC0	v0, COP_0_EXC_PC	;\
+	MTC0	v0, COP_0_EXC_PC	;\
 	.set noat		        ;\
 	RESTORE_REG(AT, AST, sp)	;\
 	RESTORE_REG(v0, V0, sp)		;\
@@ -545,7 +534,7 @@ NNON_LEAF(MipsUserGenException, CALLFRAM
 	mthi	t1
 	RESTORE_U_PCB_REG(a0, PC, k1)
 	RESTORE_U_PCB_REG(v0, V0, k1)
-        _MTC0	a0, COP_0_EXC_PC	# set return address
+        MTC0	a0, COP_0_EXC_PC	# set return address
 	RESTORE_U_PCB_REG(v1, V1, k1)
 	RESTORE_U_PCB_REG(a0, A0, k1)
 	RESTORE_U_PCB_REG(a1, A1, k1)
@@ -789,7 +778,7 @@ NNON_LEAF(MipsUserIntr, CALLFRAME_SIZ, r
 	RESTORE_U_PCB_REG(t2, PC, k1)
 	mtlo	t0
 	mthi	t1
-	_MTC0	t2, COP_0_EXC_PC	# set return address
+	MTC0	t2, COP_0_EXC_PC	# set return address
 	RESTORE_U_PCB_REG(v0, V0, k1)
 	RESTORE_U_PCB_REG(v1, V1, k1)
 	RESTORE_U_PCB_REG(a0, A0, k1)
@@ -849,9 +838,13 @@ NLEAF(MipsTLBInvalidException)
 	nop
 
 	srl	k0, SEGSHIFT - 2
+#if defined(__mips_n64)
+	andi	k0, 0xff8
+#else
 	andi	k0, 0xffc
+#endif
 	PTR_ADDU	k1, k1, k0
-	lw	k1, 0(k1)
+	PTR_L	k1, 0(k1)
 	beqz	k1, 3f			/* invalid page table page pointer */
 	nop
 
@@ -871,28 +864,28 @@ NLEAF(MipsTLBInvalidException)
 
 even_page:
 	lw	k0, 0(k1)
-	_SLL	k0, k0, WIRED_SHIFT
-	_SRL	k0, k0, WIRED_SHIFT
-	_MTC0	k0, COP_0_TLB_LO0
+	PTR_SLL	k0, k0, WIRED_SHIFT
+	PTR_SRL	k0, k0, WIRED_SHIFT
+	MTC0	k0, COP_0_TLB_LO0
 
 	lw	k0, 4(k1)
-	_SLL	k0, k0, WIRED_SHIFT
-	_SRL	k0, k0, WIRED_SHIFT
-	_MTC0	k0, COP_0_TLB_LO1
+	PTR_SLL	k0, k0, WIRED_SHIFT
+	PTR_SRL	k0, k0, WIRED_SHIFT
+	MTC0	k0, COP_0_TLB_LO1
 
 	b	tlb_insert_entry
 	nop
 
 odd_page:
 	lw	k0, 0(k1)
-	_SLL	k0, k0, WIRED_SHIFT
-	_SRL	k0, k0, WIRED_SHIFT
-	_MTC0	k0, COP_0_TLB_LO1
+	PTR_SLL	k0, k0, WIRED_SHIFT
+	PTR_SRL	k0, k0, WIRED_SHIFT
+	MTC0	k0, COP_0_TLB_LO1
 
 	lw	k0, -4(k1)
-	_SLL	k0, k0, WIRED_SHIFT
-	_SRL	k0, k0, WIRED_SHIFT
-	_MTC0	k0, COP_0_TLB_LO0
+	PTR_SLL	k0, k0, WIRED_SHIFT
+	PTR_SRL	k0, k0, WIRED_SHIFT
+	MTC0	k0, COP_0_TLB_LO0
 
 tlb_insert_entry:
 	tlbp
@@ -1012,10 +1005,13 @@ NLEAF(MipsTLBMissException)
 	srl	k0, 20				# k0=seg offset (almost)
 	PTR_L	k1, %lo(_C_LABEL(kernel_segmap))(k1)  # k1=segment tab base
 	beq	k1, zero, _C_LABEL(MipsKernGenException)  # ==0 -- no seg tab
+#if defined(__mips_n64)
+	andi	k0, k0, 0xff8			# k0=seg offset (mask 0x7)
+#else
 	andi	k0, k0, 0xffc			# k0=seg offset (mask 0x3)
-#xxx mips64 unsafe
+#endif
 	PTR_ADDU	k1, k0, k1			# k1=seg entry address
-	lw	k1, 0(k1)			# k1=seg entry
+	PTR_L	k1, 0(k1)			# k1=seg entry
 	mfc0	k0, COP_0_BAD_VADDR		# k0=bad address (again)
 	beq	k1, zero, _C_LABEL(MipsKernGenException)  # ==0 -- no page table
 	srl	k0, 10				# k0=VPN (aka va>>10)
@@ -1024,12 +1020,12 @@ NLEAF(MipsTLBMissException)
 	PTR_ADDU	k1, k1, k0			# k1=pte address
 	lw	k0, 0(k1)			# k0=lo0 pte
 	lw	k1, 4(k1)			# k1=lo1 pte
-	_SLL	k0, WIRED_SHIFT			# chop bits [31..30]
-	_SRL	k0, WIRED_SHIFT			# chop bits [31..30]
-	_MTC0	k0, COP_0_TLB_LO0		# lo0 is loaded
-	_SLL	k1, WIRED_SHIFT			# chop bits [31..30]
-	_SRL	k1, WIRED_SHIFT			# chop bits [31..30]
-	_MTC0	k1, COP_0_TLB_LO1		# lo1 is loaded
+	PTR_SLL	k0, WIRED_SHIFT			# chop bits [31..30]
+	PTR_SRL	k0, WIRED_SHIFT			# chop bits [31..30]
+	MTC0	k0, COP_0_TLB_LO0		# lo0 is loaded
+	PTR_SLL	k1, WIRED_SHIFT			# chop bits [31..30]
+	PTR_SRL	k1, WIRED_SHIFT			# chop bits [31..30]
+	MTC0	k1, COP_0_TLB_LO1		# lo1 is loaded
 
 	HAZARD_DELAY
 	tlbwr					# write to tlb
@@ -1196,10 +1192,10 @@ NESTED_NOPROFILE(MipsCacheException, KER
 	.mask	0x80000000, -4
 	PTR_LA	k0, _C_LABEL(panic)		# return to panic
 	PTR_LA	a0, 9f				# panicstr
-	_MFC0	a1, COP_0_ERROR_PC
+	MFC0	a1, COP_0_ERROR_PC
 	mfc0	a2, COP_0_CACHE_ERR		# 3rd arg cache error
 
-	_MTC0	k0, COP_0_ERROR_PC		# set return address
+	MTC0	k0, COP_0_ERROR_PC		# set return address
 
 	mfc0	k0, COP_0_STATUS_REG		# restore status
 	li	k1, SR_DIAG_DE			# ignore further errors

Modified: user/jmallett/octeon/sys/mips/mips/locore.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/locore.S	Sun Mar 28 00:33:55 2010	(r205782)
+++ user/jmallett/octeon/sys/mips/mips/locore.S	Sun Mar 28 00:58:19 2010	(r205783)
@@ -181,7 +181,7 @@ VECTOR(_locore, unknown)
 	PTR_L	a0, TD_PCB(sp)
 	REG_LI	t0, ~7
 	and	a0, a0, t0
-	subu    sp, a0, CALLFRAME_SIZ
+	PTR_SUBU	sp, a0, CALLFRAME_SIZ
 
 	jal	_C_LABEL(mi_startup)		# mi_startup(frame)
 	sw	zero, CALLFRAME_SIZ - 8(sp)	# Zero out old fp for debugger

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 00:33:55 2010	(r205782)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 00:58:19 2010	(r205783)
@@ -200,6 +200,7 @@ static void pmap_update_page_action(void
 
 #endif
 
+#if !defined(__mips_n64)
 struct local_sysmaps {
 	struct mtx lock;
 	pt_entry_t CMAP1;
@@ -218,6 +219,7 @@ struct local_sysmaps {
  */
 static struct local_sysmaps sysmap_lmem[MAXCPU];
 caddr_t virtual_sys_start = (caddr_t)0;
+#endif
 
 pt_entry_t *
 pmap_segmap(pmap_t pmap, vm_offset_t va)
@@ -274,10 +276,14 @@ pmap_steal_memory(vm_size_t size)
 
 	pa = phys_avail[0];
 	phys_avail[0] += size;
+#if defined(__mips_n64)
+	va = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, pa);
+#else
 	if (pa >= MIPS_KSEG0_LARGEST_PHYS) {
 		panic("Out of memory below 512Meg?");
 	}
 	va = MIPS_PHYS_TO_KSEG0(pa);
+#endif
 	bzero((caddr_t)va, size);
 	return va;
 }
@@ -292,7 +298,9 @@ pmap_bootstrap(void)
 	pt_entry_t *pgtab;
 	pt_entry_t *pte;
 	int i, j;
+#if !defined(__mips_n64)
 	int memory_larger_than_512meg = 0;
+#endif
 
 	/* Sort. */
 again:
@@ -303,9 +311,11 @@ again:
 		phys_avail[i] = round_page(phys_avail[i]);
 		phys_avail[i + 1] = trunc_page(phys_avail[i + 1]);
 
+#if !defined(__mips_n64)
 		if (phys_avail[i + 1] >= MIPS_KSEG0_LARGEST_PHYS) {
 			memory_larger_than_512meg++;
 		}
+#endif
 		if (i < 2)
 			continue;
 		if (phys_avail[i - 2] > phys_avail[i]) {
@@ -381,6 +391,7 @@ again:
 		printf("pcpu is available at virtual address %p.\n", pcpup);
 #endif
 
+#if !defined(__mips_n64)
 	/*
 	 * Steal some virtual space that will not be in kernel_segmap. This
 	 * va memory space will be used to map in kernel pages that are
@@ -401,6 +412,7 @@ again:
 		}
 	}
 	virtual_sys_start = (caddr_t)virtual_avail;
+#endif
 	/*
 	 * Allocate segment table for the kernel
 	 */
@@ -410,6 +422,7 @@ again:
 	 * Allocate second level page tables for the kernel
 	 */
 	nkpt = NKPT;
+#if !defined(__mips_n64)
 	if (memory_larger_than_512meg) {
 		/*
 		 * If we have a large memory system we CANNOT afford to hit
@@ -426,6 +439,7 @@ again:
 		 */
 		nkpt = (PAGE_SIZE / sizeof(pd_entry_t)) - pmap_segshift(virtual_avail);
 	}
+#endif
 	pgtab = (pt_entry_t *)pmap_steal_memory(PAGE_SIZE * nkpt);
 
 	/*
@@ -1075,6 +1089,9 @@ pmap_pinit(pmap_t pmap)
 	ptdpg->valid = VM_PAGE_BITS_ALL;
 
 	ptdpa = VM_PAGE_TO_PHYS(ptdpg);
+#if defined(__mips_n64)
+	ptdva = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, ptdpa);
+#else
 	if (ptdpa < MIPS_KSEG0_LARGEST_PHYS) {
 		ptdva = MIPS_PHYS_TO_KSEG0(ptdpa);
 	} else {
@@ -1083,6 +1100,7 @@ pmap_pinit(pmap_t pmap)
 			panic("pmap_pinit: unable to allocate kva");
 		pmap_kenter(ptdva, ptdpa);
 	}
+#endif
 
 	pmap->pm_segtab = (pd_entry_t *)ptdva;
 	if ((ptdpg->flags & PG_ZERO) == 0)
@@ -1151,6 +1169,9 @@ _pmap_allocpte(pmap_t pmap, unsigned pte
 	pmap->pm_stats.resident_count++;
 
 	ptepa = VM_PAGE_TO_PHYS(m);
+#if defined(__mips_n64)
+	pteva = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, ptepa);
+#else
 	if (ptepa < MIPS_KSEG0_LARGEST_PHYS) {
 		pteva = MIPS_PHYS_TO_KSEG0(ptepa);
 	} else {
@@ -1159,6 +1180,7 @@ _pmap_allocpte(pmap_t pmap, unsigned pte
 			panic("_pmap_allocpte: unable to allocate kva");
 		pmap_kenter(pteva, ptepa);
 	}
+#endif
 
 	pmap->pm_segtab[ptepindex] = (pd_entry_t)pteva;
 
@@ -1329,6 +1351,9 @@ pmap_growkernel(vm_offset_t addr)
 		nkpt++;
 
 		ptppaddr = VM_PAGE_TO_PHYS(nkpg);
+#if defined(__mips_n64)
+		pte = (pt_entry_t *)MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, ptppaddr);
+#else
 		if (ptppaddr >= MIPS_KSEG0_LARGEST_PHYS) {
 			/*
 			 * We need to do something here, but I am not sure
@@ -1341,7 +1366,8 @@ pmap_growkernel(vm_offset_t addr)
 			panic("Gak, can't handle a k-page table outside of lower 512Meg");
 		}
 		pte = (pt_entry_t *)MIPS_PHYS_TO_KSEG0(ptppaddr);
-		segtab_pde(kernel_segmap, kernel_vm_end) = (pd_entry_t)(intptr_t)pte;
+#endif
+		segtab_pde(kernel_segmap, kernel_vm_end) = pte;
 
 		/*
 		 * The R[4-7]?00 stores only one copy of the Global bit in
@@ -2160,7 +2186,9 @@ void *
 pmap_kenter_temporary(vm_paddr_t pa, int i)
 {
 	vm_offset_t va;
+#if !defined(__mips_n64)
 	int int_level;
+#endif
 	if (i != 0)
 		printf("%s: ERROR!!! More than one page of virtual address mapping not supported\n",
 		    __func__);
@@ -2171,6 +2199,9 @@ pmap_kenter_temporary(vm_paddr_t pa, int
 		    TRUE);
 	} else
 #endif
+#if defined(__mips_n64)
+	va = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, pa);
+#else
 	if (pa < MIPS_KSEG0_LARGEST_PHYS) {
 		va = MIPS_PHYS_TO_KSEG0(pa);
 	} else {
@@ -2191,12 +2222,14 @@ pmap_kenter_temporary(vm_paddr_t pa, int
 		va = (vm_offset_t)sysm->CADDR1;
 		restoreintr(int_level);
 	}
+#endif
 	return ((void *)va);
 }
 
 void
 pmap_kenter_temporary_free(vm_paddr_t pa)
 {
+#if !defined(__mips_n64)
 	int cpu;
 	int int_level;
 	struct local_sysmaps *sysm;
@@ -2214,6 +2247,7 @@ pmap_kenter_temporary_free(vm_paddr_t pa
 		sysm->CMAP1 = 0;
 		sysm->valid1 = 0;
 	}
+#endif
 }
 
 /*
@@ -2321,7 +2355,9 @@ pmap_zero_page(vm_page_t m)
 {
 	vm_offset_t va;
 	vm_paddr_t phys = VM_PAGE_TO_PHYS(m);
+#if !defined(__mips_n64)
 	int int_level;
+#endif
 #ifdef VM_ALLOC_WIRED_TLB_PG_POOL
 	if (need_wired_tlb_page_pool) {
 		struct fpage *fp1;
@@ -2342,6 +2378,14 @@ pmap_zero_page(vm_page_t m)
 		 */
 	} else
 #endif
+#if defined(__mips_n64)
+	{
+		va = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phys);
+		bzero((caddr_t)va, PAGE_SIZE);
+
+		mips_dcache_wbinv_range(va, PAGE_SIZE);
+	}
+#else
 	if (phys < MIPS_KSEG0_LARGEST_PHYS) {
 
 		va = MIPS_PHYS_TO_KSEG0(phys);
@@ -2368,7 +2412,7 @@ pmap_zero_page(vm_page_t m)
 		sched_unpin();
 		PMAP_LGMEM_UNLOCK(sysm);
 	}
-
+#endif
 }
 
 /*
@@ -2382,7 +2426,9 @@ pmap_zero_page_area(vm_page_t m, int off
 {
 	vm_offset_t va;
 	vm_paddr_t phys = VM_PAGE_TO_PHYS(m);
+#if !defined(__mips_n64)
 	int int_level;
+#endif
 #ifdef VM_ALLOC_WIRED_TLB_PG_POOL
 	if (need_wired_tlb_page_pool) {
 		struct fpage *fp1;
@@ -2401,6 +2447,13 @@ pmap_zero_page_area(vm_page_t m, int off
 		mtx_unlock(&sysmaps->lock);
 	} else
 #endif
+#if defined(__mips_n64)
+	{
+		va = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phys);
+		bzero((char *)(caddr_t)va + off, size);
+		mips_dcache_wbinv_range(va + off, size);
+	}
+#else
 	if (phys < MIPS_KSEG0_LARGEST_PHYS) {
 		va = MIPS_PHYS_TO_KSEG0(phys);
 		bzero((char *)(caddr_t)va + off, size);
@@ -2425,6 +2478,7 @@ pmap_zero_page_area(vm_page_t m, int off
 		sched_unpin();
 		PMAP_LGMEM_UNLOCK(sysm);
 	}
+#endif
 }
 
 void
@@ -2432,7 +2486,9 @@ pmap_zero_page_idle(vm_page_t m)
 {
 	vm_offset_t va;
 	vm_paddr_t phys = VM_PAGE_TO_PHYS(m);
+#if !defined(__mips_n64)
 	int int_level;
+#endif
 #ifdef VM_ALLOC_WIRED_TLB_PG_POOL
 	if (need_wired_tlb_page_pool) {
 		sched_pin();
@@ -2442,6 +2498,13 @@ pmap_zero_page_idle(vm_page_t m)
 		sched_unpin();
 	} else
 #endif
+#if defined(__mips_n64)
+	{
+		va = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phys);
+		bzero((caddr_t)va, PAGE_SIZE);
+		mips_dcache_wbinv_range(va, PAGE_SIZE);
+	}
+#else
 	if (phys < MIPS_KSEG0_LARGEST_PHYS) {
 		va = MIPS_PHYS_TO_KSEG0(phys);
 		bzero((caddr_t)va, PAGE_SIZE);
@@ -2466,7 +2529,7 @@ pmap_zero_page_idle(vm_page_t m)
 		sched_unpin();
 		PMAP_LGMEM_UNLOCK(sysm);
 	}
-
+#endif
 }
 
 /*
@@ -2481,7 +2544,9 @@ pmap_copy_page(vm_page_t src, vm_page_t 
 	vm_offset_t va_src, va_dst;
 	vm_paddr_t phy_src = VM_PAGE_TO_PHYS(src);
 	vm_paddr_t phy_dst = VM_PAGE_TO_PHYS(dst);
+#if !defined(__mips_n64)
 	int int_level;
+#endif
 #ifdef VM_ALLOC_WIRED_TLB_PG_POOL
 	if (need_wired_tlb_page_pool) {
 		struct fpage *fp1, *fp2;
@@ -2510,6 +2575,14 @@ pmap_copy_page(vm_page_t src, vm_page_t 
 	} else
 #endif
 	{
+#if defined(__mips_n64)
+		pmap_flush_pvcache(src);
+		mips_dcache_wbinv_range_index(MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_dst), NBPG);
+		va_src = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_src);
+		va_dst = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_dst);
+		bcopy((caddr_t)va_src, (caddr_t)va_dst, PAGE_SIZE);
+		mips_dcache_wbinv_range(va_dst, PAGE_SIZE);
+#else
 		if ((phy_src < MIPS_KSEG0_LARGEST_PHYS) && (phy_dst < MIPS_KSEG0_LARGEST_PHYS)) {
 			/* easy case, all can be accessed via KSEG0 */
 			/*
@@ -2571,6 +2644,7 @@ pmap_copy_page(vm_page_t src, vm_page_t 
 			sched_unpin();
 			PMAP_LGMEM_UNLOCK(sysm);
 		}
+#endif
 	}
 }
 
@@ -3323,17 +3397,24 @@ pmap_kextract(vm_offset_t va)
 	    (va < (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_ALLOC_OFFSET))))
 		pa = MIPS_KSEG0_TO_PHYS(va);
 #endif
+#if defined(__mips_n64)
+	else if (va >= MIPS_XKPHYS_START && va < MIPS_XKPHYS_END)
+		pa = MIPS_XKPHYS_TO_PHYS(va);
+#endif
 	else if (va >= MIPS_KSEG2_START && va < VM_MAX_KERNEL_ADDRESS) {
 		pt_entry_t *ptep;
 
 		/* Is the kernel pmap initialized? */
 		if (kernel_pmap->pm_active) {
+#if !defined(__mips_n64)
 			if (va >= (vm_offset_t)virtual_sys_start) {
+#endif
 				/* Its inside the virtual address range */
 				ptep = pmap_pte(kernel_pmap, va);
 				if (ptep)
 					pa = mips_tlbpfn_to_paddr(*ptep) |
 					    (va & PAGE_MASK);
+#if !defined(__mips_n64)
 			} else {
 				int i;
 
@@ -3356,6 +3437,7 @@ pmap_kextract(vm_offset_t va)
 					}
 				}
 			}
+#endif
 		}
 	}
 	return pa;

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 01:45:27 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 31101106566C;
	Sun, 28 Mar 2010 01:45:27 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 21F288FC17;
	Sun, 28 Mar 2010 01:45:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S1jQTj062457;
	Sun, 28 Mar 2010 01:45:26 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S1jQt7062455;
	Sun, 28 Mar 2010 01:45:26 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280145.o2S1jQt7062455@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 01:45:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205784 - user/jmallett/octeon/sys/mips/include
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 01:45:27 -0000

Author: jmallett
Date: Sun Mar 28 01:45:26 2010
New Revision: 205784
URL: http://svn.freebsd.org/changeset/base/205784

Log:
  Remove some unused definitions.

Modified:
  user/jmallett/octeon/sys/mips/include/pmap.h

Modified: user/jmallett/octeon/sys/mips/include/pmap.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pmap.h	Sun Mar 28 00:58:19 2010	(r205783)
+++ user/jmallett/octeon/sys/mips/include/pmap.h	Sun Mar 28 01:45:26 2010	(r205784)
@@ -49,14 +49,8 @@
 #include <machine/vmparam.h>
 #include <machine/pte.h>
 
-#define	VADDR(pdi, pti)	((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT)))
-
 #define	NKPT		120	/* actual number of kernel page tables */
 
-#ifndef NKPDE
-#define	NKPDE		255	/* addressable number of page tables/pde's */
-#endif
-
 #ifndef LOCORE
 
 #include <sys/queue.h>

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 02:21:58 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DFBAC106566B;
	Sun, 28 Mar 2010 02:21:58 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D01468FC0C;
	Sun, 28 Mar 2010 02:21:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S2LwI4070550;
	Sun, 28 Mar 2010 02:21:58 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S2LwV7070546;
	Sun, 28 Mar 2010 02:21:58 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280221.o2S2LwV7070546@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 02:21:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205785 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 02:21:59 -0000

Author: jmallett
Date: Sun Mar 28 02:21:58 2010
New Revision: 205785
URL: http://svn.freebsd.org/changeset/base/205785

Log:
  o) Remove some files we don't use yet.  If we end up needing something like
     them, we can evaluate what to use.
  o) Remove the two references to the R3K-style TLB since we don't and don't plan
     to support it AFAIK.
  o) Expose TLB CP0 registers as 64-bit on n64.

Deleted:
  user/jmallett/octeon/sys/mips/include/archtype.h
  user/jmallett/octeon/sys/mips/include/rm7000.h
Modified:
  user/jmallett/octeon/sys/mips/include/cpufunc.h
  user/jmallett/octeon/sys/mips/include/cpuregs.h
  user/jmallett/octeon/sys/mips/mips/trap.c

Modified: user/jmallett/octeon/sys/mips/include/cpufunc.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpufunc.h	Sun Mar 28 01:45:26 2010	(r205784)
+++ user/jmallett/octeon/sys/mips/include/cpufunc.h	Sun Mar 28 02:21:58 2010	(r205785)
@@ -87,10 +87,6 @@ mips_wbflush(void)
 {
 	__asm __volatile ("sync" : : : "memory");
 	mips_barrier();
-#if 0
-	__asm __volatile("mtc0 %0, $12\n" /* MIPS_COP_0_STATUS */
-	   : : "r" (flag));
-#endif
 }
 
 static __inline void
@@ -112,16 +108,6 @@ mips_tlbp(void)
 {
 	__asm __volatile ("tlbp");
 	mips_barrier();
-#if 0
-	register_t ret;
-	register_t tmp;
-
-	__asm __volatile("mfc0	%0, $12\n" /* MIPS_COP_0_STATUS */
-	 		 "and	%1, %0, $~1\n" /* MIPS_SR_INT_IE */
-			 "mtc0	%1, $12\n" /* MIPS_COP_0_STATUS */
-			 : "=r" (ret), "=r" (tmp));
-	return (ret);
-#endif
 }
 
 static __inline void
@@ -136,12 +122,6 @@ mips_tlbwi(void)
 {
 	__asm __volatile ("tlbwi");
 	mips_barrier();
-#if 0
-	__asm __volatile("mfc %0, $12\n" /* MIPS_COP_0_STATUS */
-	    		 "or  %0, %0, $1\n" /* MIPS_SR_INT_IE */
-			 "mtc0 %0, $12\n" /* MIPS_COP_0_STATUS */
-			 : "=r" (tmp));
-#endif
 }
 
 static __inline void
@@ -152,8 +132,7 @@ mips_tlbwr(void)
 }
 
 
-#if 0	/* XXX mips64 */
-
+#if defined(__mips_n32) || defined(__mips_n64)
 #define	MIPS_RDRW64_COP0(n,r)					\
 static __inline uint64_t					\
 mips_rd_ ## n (void)						\
@@ -176,10 +155,12 @@ mips_wr_ ## n (uint64_t a0)					\
 	mips_barrier();						\
 } struct __hack
 
+#if defined(__mips_n64)
 MIPS_RDRW64_COP0(entrylo0, MIPS_COP_0_TLB_LO0);
 MIPS_RDRW64_COP0(entrylo1, MIPS_COP_0_TLB_LO1);
 MIPS_RDRW64_COP0(entryhi, MIPS_COP_0_TLB_HI);
 MIPS_RDRW64_COP0(pagemask, MIPS_COP_0_TLB_PG_MASK);
+#endif
 MIPS_RDRW64_COP0(xcontext, MIPS_COP_0_TLB_XCONTEXT);
 
 #undef	MIPS_RDRW64_COP0
@@ -254,11 +235,12 @@ MIPS_RDRW32_COP0(cause, MIPS_COP_0_CAUSE
 MIPS_RDRW32_COP0(status, MIPS_COP_0_STATUS);
 
 /* XXX: Some of these registers are specific to MIPS32. */
+#if !defined(__mips_n64)
 MIPS_RDRW32_COP0(entrylo0, MIPS_COP_0_TLB_LO0);
 MIPS_RDRW32_COP0(entrylo1, MIPS_COP_0_TLB_LO1);
-MIPS_RDRW32_COP0(entrylow, MIPS_COP_0_TLB_LOW);
 MIPS_RDRW32_COP0(entryhi, MIPS_COP_0_TLB_HI);
 MIPS_RDRW32_COP0(pagemask, MIPS_COP_0_TLB_PG_MASK);
+#endif
 MIPS_RDRW32_COP0(prid, MIPS_COP_0_PRID);
 MIPS_RDRW32_COP0(watchlo, MIPS_COP_0_WATCH_LO);
 MIPS_RDRW32_COP0_SEL(watchlo, MIPS_COP_0_WATCH_LO, 1);

Modified: user/jmallett/octeon/sys/mips/include/cpuregs.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpuregs.h	Sun Mar 28 01:45:26 2010	(r205784)
+++ user/jmallett/octeon/sys/mips/include/cpuregs.h	Sun Mar 28 02:21:58 2010	(r205785)
@@ -490,7 +490,6 @@
  *				     (3=32bit, 6=64bit, i=impl dep)
  *  0	MIPS_COP_0_TLB_INDEX	3333 TLB Index.
  *  1	MIPS_COP_0_TLB_RANDOM	3333 TLB Random.
- *  2	MIPS_COP_0_TLB_LOW	3... r3k TLB entry low.
  *  2	MIPS_COP_0_TLB_LO0	.636 r4k TLB entry low.
  *  3	MIPS_COP_0_TLB_LO1	.636 r4k TLB entry low, extended.
  *  4	MIPS_COP_0_TLB_CONTEXT	3636 TLB Context.
@@ -550,10 +549,6 @@
 #define	MIPS_COP_0_EXC_PC	_(14)
 #define	MIPS_COP_0_PRID		_(15)
 
-
-/* MIPS-I */
-#define	MIPS_COP_0_TLB_LOW	_(2)
-
 /* MIPS-III */
 #define	MIPS_COP_0_TLB_LO0	_(2)
 #define	MIPS_COP_0_TLB_LO1	_(3)

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Sun Mar 28 01:45:26 2010	(r205784)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Sun Mar 28 02:21:58 2010	(r205785)
@@ -83,8 +83,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/mips_opcode.h>
 #include <machine/frame.h>
 #include <machine/regnum.h>
-#include <machine/rm7000.h>
-#include <machine/archtype.h>
 #include <machine/asm.h>
 
 #ifdef DDB

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 02:44:34 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4F3D11065670;
	Sun, 28 Mar 2010 02:44:34 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4049F8FC1A;
	Sun, 28 Mar 2010 02:44:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S2iXwi075611;
	Sun, 28 Mar 2010 02:44:33 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S2iXd9075609;
	Sun, 28 Mar 2010 02:44:33 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280244.o2S2iXd9075609@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 02:44:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205786 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 02:44:34 -0000

Author: jmallett
Date: Sun Mar 28 02:44:33 2010
New Revision: 205786
URL: http://svn.freebsd.org/changeset/base/205786

Log:
  Move a big instruction out of a branch delay slot.

Modified:
  user/jmallett/octeon/sys/mips/mips/swtch.S

Modified: user/jmallett/octeon/sys/mips/mips/swtch.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/swtch.S	Sun Mar 28 02:21:58 2010	(r205785)
+++ user/jmallett/octeon/sys/mips/mips/swtch.S	Sun Mar 28 02:44:33 2010	(r205786)
@@ -319,8 +319,9 @@ entry0:
 	mfc0	s0, COP_0_TLB_INDEX
 	nop
 pgm:
-	bltz	s0, entry0set
 	REG_LI	t1, MIPS_KSEG0_START		# invalidate tlb entry
+	bltz	s0, entry0set
+	nop
 	sll	s0, PAGE_SHIFT + 1
 	addu	t1, s0
 	mtc0	t1, COP_0_TLB_HI

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 02:48:39 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C5DCE106564A;
	Sun, 28 Mar 2010 02:48:39 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B55148FC08;
	Sun, 28 Mar 2010 02:48:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S2mdlq076542;
	Sun, 28 Mar 2010 02:48:39 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S2mdEU076528;
	Sun, 28 Mar 2010 02:48:39 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280248.o2S2mdEU076528@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 02:48:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205787 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 02:48:39 -0000

Author: jmallett
Date: Sun Mar 28 02:48:39 2010
New Revision: 205787
URL: http://svn.freebsd.org/changeset/base/205787

Log:
  o) Spell PAGE_SIZE as PAGE_SIZE not NBPG, etc.
  o) Expand some macros related to tlb.S.
  o) Make some page-related macros more consistent.

Modified:
  user/jmallett/octeon/sys/mips/include/cpu.h
  user/jmallett/octeon/sys/mips/include/param.h
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/mips/exception.S
  user/jmallett/octeon/sys/mips/mips/genassym.c
  user/jmallett/octeon/sys/mips/mips/locore.S
  user/jmallett/octeon/sys/mips/mips/mp_machdep.c
  user/jmallett/octeon/sys/mips/mips/mpboot.S
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/support.S
  user/jmallett/octeon/sys/mips/mips/tlb.S
  user/jmallett/octeon/sys/mips/mips/trap.c
  user/jmallett/octeon/sys/mips/mips/vm_machdep.c

Modified: user/jmallett/octeon/sys/mips/include/cpu.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpu.h	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/include/cpu.h	Sun Mar 28 02:48:39 2010	(r205787)
@@ -516,16 +516,6 @@ extern int intr_nesting_level;
 			: "r" (func), "r" (arg0), "r" (arg1), "r" (arg2)  /* inputs */ \
 			: "$31", "$4", "$5", "$6");
 
-#define	MachSetPID			Mips_SetPID
-#define	MachTLBUpdate   		Mips_TLBUpdate
-#define	mips_TBIS			Mips_TLBFlushAddr
-#define	MIPS_TBIAP()			mips_TBIAP(num_tlbentries)
-#define	MachSetWIRED(index)		Mips_SetWIRED(index)
-#define	MachTLBFlush(count)		Mips_TLBFlush(count)
-#define	MachTLBGetPID(pid)		(pid = Mips_TLBGetPID())
-#define	MachTLBRead(tlbno, tlbp)	Mips_TLBRead(tlbno, tlbp)
-#define	MachFPTrap(sr, cause, pc)	MipsFPTrap(sr, cause, pc)
-
 /*
  * Enable realtime clock (always enabled).
  */

Modified: user/jmallett/octeon/sys/mips/include/param.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/param.h	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/include/param.h	Sun Mar 28 02:48:39 2010	(r205787)
@@ -102,10 +102,6 @@
 #define	CACHE_LINE_SHIFT	6
 #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
 
-#define	NBPG		4096		/* bytes/page */
-#define	PGOFSET		(NBPG-1)	/* byte offset into page */
-#define	PGSHIFT		12		/* LOG2(NBPG) */
-
 #define	PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
 #define	PAGE_SIZE	(1<<PAGE_SHIFT) /* bytes/page */
 #define	PAGE_MASK	(PAGE_SIZE-1)
@@ -128,8 +124,8 @@
 #define	UPAGES			2
 
 /* pages ("clicks") (4096 bytes) to disk blocks */
-#define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
-#define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
+#define	ctod(x)		((x) << (PAGE_SHIFT - DEV_BSHIFT))
+#define	dtoc(x)		((x) >> (PAGE_SHIFT - DEV_BSHIFT))
 
 /*
  * Map a ``block device block'' to a file system block.
@@ -140,18 +136,18 @@
 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
 
 /*
- * Conversion macros
+ * Mach derived conversion macros
  */
-#define	mips_round_page(x)	((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1))
-#define	mips_trunc_page(x)	((unsigned long)(x) & ~(NBPG-1))
-#define	mips_btop(x)		((unsigned long)(x) >> PGSHIFT)
-#define	mips_ptob(x)		((unsigned long)(x) << PGSHIFT)
-#define	round_page		mips_round_page
-#define	trunc_page		mips_trunc_page
-#define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
-#define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
+#define round_page(x)		(((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
+#define trunc_page(x)		((unsigned long)(x) & ~PAGE_MASK)
+
+#define atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
+#define ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
+
+#define mips_btop(x)		((unsigned long)(x) >> PAGE_SHIFT)
+#define mips_ptob(x)		((unsigned long)(x) << PAGE_SHIFT)
 
-#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
+#define	pgtok(x)		((unsigned long)(x) * (PAGE_SIZE / 1024))
 
 #ifndef _KERNEL
 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sun Mar 28 02:48:39 2010	(r205787)
@@ -121,12 +121,11 @@ typedef pt_entry_t *pd_entry_t;
 
 #define	PTE_SHIFT	6
 #define	pfn_is_ext(x)	((x) & 0x3c000000)
-#define	vad_to_pfn(x)	(((unsigned)(x) >> PTE_SHIFT) & PTE_FRAME)
-#define	vad_to_pfn64(x)	((quad_t)(x) >> PTE_SHIFT) & PTE_FRAME)
+#define	vad_to_pfn(x)	(((vm_offset_t)(x) >> PTE_SHIFT) & PTE_FRAME)
 #define	pfn_to_vad(x)	(((x) & PTE_FRAME) << PTE_SHIFT)
 
 /* User virtual to pte offset in page table */
-#define	vad_to_pte_offset(adr)	(((adr) >> PGSHIFT) & (NPTEPG -1))
+#define	vad_to_pte_offset(adr)	(((adr) >> PAGE_SHIFT) & (NPTEPG -1))
 
 #define	mips_pg_v(entry)	((entry) & PTE_V)
 #define	mips_pg_wired(entry)	((entry) & PTE_WIRED)

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Sun Mar 28 02:48:39 2010	(r205787)
@@ -147,7 +147,7 @@ MipsDoTLBMiss:
 	PTR_L	k1, 0(k1)			#08: k1=seg entry
 	mfc0	k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
 	beq	k1, zero, 2f			#0a: ==0 -- no page table
-	srl	k0, PGSHIFT - 2			#0b: k0=VPN (aka va>>10)
+	srl	k0, PAGE_SHIFT - 2			#0b: k0=VPN (aka va>>10)
 
 	andi	k0, k0, ((NPTEPG/2) - 1) << 3	#0c: k0=page tab offset
 #xxx mips64 unsafe?
@@ -849,7 +849,7 @@ NLEAF(MipsTLBInvalidException)
 	nop
 
 	mfc0	k0, COP_0_BAD_VADDR
-	srl	k0, PGSHIFT - 2
+	srl	k0, PAGE_SHIFT - 2
 	andi	k0, 0xffc
 	PTR_ADDU	k1, k1, k0
 
@@ -933,7 +933,7 @@ tlb_insert_random:
 	sll	k1, k1, PAGE_SHIFT + 1
 
 	PTR_LA	k0, _C_LABEL(pcpu_space)
-	PTR_ADDU	k0, (NBPG * 2)
+	PTR_ADDU	k0, (PAGE_SIZE * 2)
 	PTR_ADDU	k0, k0, k1
 
 	/*

Modified: user/jmallett/octeon/sys/mips/mips/genassym.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/genassym.c	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/genassym.c	Sun Mar 28 02:48:39 2010	(r205787)
@@ -91,8 +91,8 @@ ASSYM(VM_KERNEL_ALLOC_OFFSET, VM_KERNEL_
 ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
 ASSYM(SIGFPE, SIGFPE);
 ASSYM(PAGE_SHIFT, PAGE_SHIFT);
-ASSYM(PGSHIFT, PGSHIFT);
-ASSYM(NBPG, NBPG);
+ASSYM(PAGE_SIZE, PAGE_SIZE);
+ASSYM(PAGE_MASK, PAGE_MASK);
 ASSYM(SEGSHIFT, SEGSHIFT);
 ASSYM(NPTEPG, NPTEPG);
 ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);

Modified: user/jmallett/octeon/sys/mips/mips/locore.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/locore.S	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/locore.S	Sun Mar 28 02:48:39 2010	(r205787)
@@ -166,7 +166,7 @@ VECTOR(_locore, unknown)
 	 * Initialize stack and call machine startup.
 	 */
 	PTR_LA	sp, _C_LABEL(pcpu_space)
-	addiu	sp, (NBPG * 2) - CALLFRAME_SIZ
+	addiu	sp, (PAGE_SIZE * 2) - CALLFRAME_SIZ
 
 	sw	zero, CALLFRAME_SIZ - 4(sp)	# Zero out old ra for debugger
 	sw	zero, CALLFRAME_SIZ - 8(sp)	# Zero out old fp for debugger

Modified: user/jmallett/octeon/sys/mips/mips/mp_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sun Mar 28 02:48:39 2010	(r205787)
@@ -246,7 +246,7 @@ smp_init_secondary(u_int32_t cpuid)
 	mips_dcache_wbinv_all();
 	mips_icache_sync_all();
 
-	MachSetPID(0);
+	Mips_SetPID(0);
 
 	pcpu_init(PCPU_ADDR(cpuid), cpuid, sizeof(struct pcpu));
 	dpcpu_init(dpcpu, cpuid);

Modified: user/jmallett/octeon/sys/mips/mips/mpboot.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/mpboot.S	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/mpboot.S	Sun Mar 28 02:48:39 2010	(r205787)
@@ -53,7 +53,7 @@ GLOBAL(mpentry)
 	 * Initialize stack and call machine startup
 	 */
 	PTR_LA	sp, _C_LABEL(pcpu_space)
-	addiu	sp, (NBPG * 2) - CALLFRAME_SIZ
+	addiu	sp, (PAGE_SIZE * 2) - CALLFRAME_SIZ
 	sll	t0, s0, PAGE_SHIFT + 1
 	addu	sp, sp, t0
 

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 02:48:39 2010	(r205787)
@@ -134,7 +134,7 @@ __FBSDID("$FreeBSD$");
 #define	NUSERPGTBLS		(pmap_segshift(VM_MAXUSER_ADDRESS))
 #define	MIPS_SEGSIZE		(1L << SEGSHIFT)
 #define	mips_segtrunc(va)	((va) & ~(MIPS_SEGSIZE-1))
-#define	pmap_TLB_invalidate_all() MIPS_TBIAP()
+#define	pmap_TLB_invalidate_all() mips_TBIAP(num_tlbentries)
 #define	pmap_va_asid(pmap, va)	((va) | ((pmap)->pm_asid[PCPU_GET(cpuid)].asid << VMTLB_PID_SHIFT))
 #define	is_kernel_pmap(x)	((x) == kernel_pmap)
 
@@ -471,7 +471,7 @@ again:
 	kernel_pmap->pm_asid[0].asid = PMAP_ASID_RESERVED;
 	kernel_pmap->pm_asid[0].gen = 0;
 	pmap_max_asid = VMNUM_PIDS;
-	MachSetPID(0);
+	Mips_SetPID(0);
 }
 
 /*
@@ -587,8 +587,8 @@ pmap_invalidate_page_action(void *arg)
 		pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
 		return;
 	}
-	va = pmap_va_asid(pmap, (va & ~PGOFSET));
-	mips_TBIS(va);
+	va = pmap_va_asid(pmap, (va & ~PAGE_MASK));
+	Mips_TLBFlushAddr(va);
 }
 
 static void
@@ -596,9 +596,9 @@ pmap_TLB_invalidate_kernel(vm_offset_t v
 {
 	u_int32_t pid;
 
-	MachTLBGetPID(pid);
+	pid = Mips_TLBGetPID();
 	va = va | (pid << VMTLB_PID_SHIFT);
-	mips_TBIS(va);
+	Mips_TLBFlushAddr(va);
 }
 
 struct pmap_update_page_arg {
@@ -639,7 +639,7 @@ pmap_update_page_action(void *arg)
 		return;
 	}
 	va = pmap_va_asid(pmap, va);
-	MachTLBUpdate(va, pte);
+	Mips_TLBUpdate(va, pte);
 }
 
 static void
@@ -647,10 +647,10 @@ pmap_TLB_update_kernel(vm_offset_t va, p
 {
 	u_int32_t pid;
 
-	MachTLBGetPID(pid);
+	pid = Mips_TLBGetPID();
 	va = va | (pid << VMTLB_PID_SHIFT);
 
-	MachTLBUpdate(va, pte);
+	Mips_TLBUpdate(va, pte);
 }
 
 /*
@@ -743,7 +743,7 @@ pmap_kremove(vm_offset_t va)
 	/*
 	 * Write back all caches from the page being destroyed
 	 */
-	mips_dcache_wbinv_range_index(va, NBPG);
+	mips_dcache_wbinv_range_index(va, PAGE_SIZE);
 
 	pte = pmap_pte(kernel_pmap, va);
 	*pte = PTE_G;
@@ -866,19 +866,19 @@ pmap_init_fpage()
 	 * Make up start at an even page number so we can wire down the
 	 * fpage area in the tlb with a single tlb entry.
 	 */
-	if ((((vm_offset_t)kva) >> PGSHIFT) & 1) {
+	if ((((vm_offset_t)kva) >> PAGE_SHIFT) & 1) {
 		/*
 		 * 'kva' is not even-page aligned. Adjust it and free the
 		 * first page which is unused.
 		 */
-		kmem_free(kernel_map, (vm_offset_t)kva, NBPG);
-		kva = ((vm_offset_t)kva) + NBPG;
+		kmem_free(kernel_map, (vm_offset_t)kva, PAGE_SIZE);
+		kva = ((vm_offset_t)kva) + PAGE_SIZE;
 	} else {
 		/*
 		 * 'kva' is even page aligned. We don't need the last page,
 		 * free it.
 		 */
-		kmem_free(kernel_map, ((vm_offset_t)kva) + FSPACE, NBPG);
+		kmem_free(kernel_map, ((vm_offset_t)kva) + FSPACE, PAGE_SIZE);
 	}
 
 	for (i = 0; i < MAXCPU; i++) {
@@ -1655,7 +1655,7 @@ pmap_remove_page(struct pmap *pmap, vm_o
 	/*
 	 * Write back all caches from the page being destroyed
 	 */
-	mips_dcache_wbinv_range_index(va, NBPG);
+	mips_dcache_wbinv_range_index(va, PAGE_SIZE);
 
 	/*
 	 * get a local va for mappings for this pmap.
@@ -1742,7 +1742,7 @@ pmap_remove_all(vm_page_t m)
 		 * the page being destroyed
 	 	 */
 		if (m->md.pv_list_count == 1) 
-			mips_dcache_wbinv_range_index(pv->pv_va, NBPG);
+			mips_dcache_wbinv_range_index(pv->pv_va, PAGE_SIZE);
 
 		pv->pv_pmap->pm_stats.resident_count--;
 
@@ -2041,8 +2041,8 @@ validate:
 	 */
 	if (!is_kernel_pmap(pmap) && (pmap == &curproc->p_vmspace->vm_pmap) &&
 	    (prot & VM_PROT_EXECUTE)) {
-		mips_icache_sync_range(va, NBPG);
-		mips_dcache_wbinv_range(va, NBPG);
+		mips_icache_sync_range(va, PAGE_SIZE);
+		mips_dcache_wbinv_range(va, PAGE_SIZE);
 	}
 	vm_page_unlock_queues();
 	PMAP_UNLOCK(pmap);
@@ -2171,8 +2171,8 @@ pmap_enter_quick_locked(pmap_t pmap, vm_
 		 * unresolvable TLB miss may occur. */
 		if (pmap == &curproc->p_vmspace->vm_pmap) {
 			va &= ~PAGE_MASK;
-			mips_icache_sync_range(va, NBPG);
-			mips_dcache_wbinv_range(va, NBPG);
+			mips_icache_sync_range(va, PAGE_SIZE);
+			mips_dcache_wbinv_range(va, PAGE_SIZE);
 		}
 	}
 	return (mpte);
@@ -2577,7 +2577,7 @@ pmap_copy_page(vm_page_t src, vm_page_t 
 	{
 #if defined(__mips_n64)
 		pmap_flush_pvcache(src);
-		mips_dcache_wbinv_range_index(MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_dst), NBPG);
+		mips_dcache_wbinv_range_index(MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_dst), PAGE_SIZE);
 		va_src = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_src);
 		va_dst = MIPS_PHYS_TO_XKPHYS(MIPS_XKPHYS_CCA_CNC, phy_dst);
 		bcopy((caddr_t)va_src, (caddr_t)va_dst, PAGE_SIZE);
@@ -2591,7 +2591,7 @@ pmap_copy_page(vm_page_t src, vm_page_t 
 			 */
 			pmap_flush_pvcache(src);
 			mips_dcache_wbinv_range_index(
-			    MIPS_PHYS_TO_KSEG0(phy_dst), NBPG);
+			    MIPS_PHYS_TO_KSEG0(phy_dst), PAGE_SIZE);
 			va_src = MIPS_PHYS_TO_KSEG0(phy_src);
 			va_dst = MIPS_PHYS_TO_KSEG0(phy_dst);
 			bcopy((caddr_t)va_src, (caddr_t)va_dst, PAGE_SIZE);
@@ -3112,7 +3112,7 @@ pmap_activate(struct thread *td)
 	pmap_asid_alloc(pmap);
 	if (td == curthread) {
 		PCPU_SET(segbase, pmap->pm_segtab);
-		MachSetPID(pmap->pm_asid[PCPU_GET(cpuid)].asid);
+		Mips_SetPID(pmap->pm_asid[PCPU_GET(cpuid)].asid);
 	}
 
 	PCPU_SET(curpmap, pmap);
@@ -3285,7 +3285,7 @@ pmap_asid_alloc(pmap)
 	    pmap->pm_asid[PCPU_GET(cpuid)].gen == PCPU_GET(asid_generation));
 	else {
 		if (PCPU_GET(next_asid) == pmap_max_asid) {
-			MIPS_TBIAP();
+			mips_TBIAP(num_tlbentries);
 			PCPU_SET(asid_generation,
 			    (PCPU_GET(asid_generation) + 1) & ASIDGEN_MASK);
 			if (PCPU_GET(asid_generation) == 0) {
@@ -3451,7 +3451,7 @@ pmap_flush_pvcache(vm_page_t m)
 	if (m != NULL) {
 		for (pv = TAILQ_FIRST(&m->md.pv_list); pv;
 	    	    pv = TAILQ_NEXT(pv, pv_list)) {
-			mips_dcache_wbinv_range_index(pv->pv_va, NBPG);
+			mips_dcache_wbinv_range_index(pv->pv_va, PAGE_SIZE);
 		}
 	}
 }
@@ -3464,7 +3464,7 @@ pmap_save_tlb(void)
 	cpu = PCPU_GET(cpuid);
 
 	for (tlbno = 0; tlbno < num_tlbentries; ++tlbno)
-		MachTLBRead(tlbno, &tlbstash[cpu][tlbno]);
+		Mips_TLBRead(tlbno, &tlbstash[cpu][tlbno]);
 }
 
 #ifdef DDB

Modified: user/jmallett/octeon/sys/mips/mips/support.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 02:48:39 2010	(r205787)
@@ -185,7 +185,7 @@ END(fillw)
  * mem_zero_page(addr);
  */
 LEAF(mem_zero_page)
-	li	v0, NBPG
+	li	v0, PAGE_SIZE
 1:
 	subu	v0, 8
 	sd	zero, 0(a0)

Modified: user/jmallett/octeon/sys/mips/mips/tlb.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/tlb.S	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/tlb.S	Sun Mar 28 02:48:39 2010	(r205787)
@@ -225,7 +225,7 @@ LEAF(Mips_TLBFlush)
 	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
 	#
-	sll	t3, t1, PGSHIFT + 1
+	sll	t3, t1, PAGE_SHIFT + 1
 	li	v0, MIPS_KSEG0_START		# invalid address
 	addu	v0, t3
 /*
@@ -284,7 +284,7 @@ LEAF(Mips_TLBFlushAddr)
 	# address calculated by following expression:
 	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
-	sll	v0, PGSHIFT + 1
+	sll	v0, PAGE_SHIFT + 1
 	addu	t1, v0
 	MTC0	t1, COP_0_TLB_HI		# Mark entry high as invalid
 
@@ -467,7 +467,7 @@ LEAF(mips_TBIAP)
 	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
 	#
-	sll	t3, t1, PGSHIFT + 1
+	sll	t3, t1, PAGE_SHIFT + 1
 	li	v0, MIPS_KSEG0_START		# invalid address
 	addu	v0, t3
 
@@ -492,7 +492,7 @@ LEAF(mips_TBIAP)
 	tlbwi					# invalidate the TLB entry
 2:
 	addu	t1, t1, 1
-	addu	v0, 1 << (PGSHIFT + 1)
+	addu	v0, 1 << (PAGE_SHIFT + 1)
 	bne	t1, t2, 1b
 	nop
 

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Sun Mar 28 02:48:39 2010	(r205787)
@@ -330,7 +330,7 @@ trap(struct trapframe *trapframe)
 #ifdef SMP
 		printf("cpuid = %d\n", PCPU_GET(cpuid));
 #endif
-		MachTLBGetPID(pid);
+		pid = Mips_TLBGetPID();
 		printf("badaddr = %#jx, pc = %#jx, ra = %#jx, sp = %#jx, sr = %jx, pid = %d, ASID = %u\n",
 		    (intmax_t)trapframe->badvaddr, (intmax_t)trapframe->pc, (intmax_t)trapframe->ra,
 		    (intmax_t)trapframe->sp, (intmax_t)trapframe->sr,
@@ -379,12 +379,12 @@ trap(struct trapframe *trapframe)
 			if (!(pte = pmap_segmap(kernel_pmap,
 			    trapframe->badvaddr)))
 				panic("trap: ktlbmod: invalid segmap");
-			pte += (trapframe->badvaddr >> PGSHIFT) & (NPTEPG - 1);
+			pte += (trapframe->badvaddr >> PAGE_SHIFT) & (NPTEPG - 1);
 			entry = *pte;
 #ifdef SMP
 			/* It is possible that some other CPU changed m-bit */
 			if (!mips_pg_v(entry) || (entry & mips_pg_m_bit())) {
-				trapframe->badvaddr &= ~PGOFSET;
+				trapframe->badvaddr &= ~PAGE_MASK;
 				pmap_update_page(kernel_pmap,
 				    trapframe->badvaddr, entry);
 				PMAP_UNLOCK(kernel_pmap);
@@ -402,7 +402,7 @@ trap(struct trapframe *trapframe)
 			}
 			entry |= mips_pg_m_bit();
 			*pte = entry;
-			trapframe->badvaddr &= ~PGOFSET;
+			trapframe->badvaddr &= ~PAGE_MASK;
 			pmap_update_page(kernel_pmap, trapframe->badvaddr, entry);
 			pa = mips_tlbpfn_to_paddr(entry);
 			if (!page_is_managed(pa))
@@ -422,12 +422,12 @@ trap(struct trapframe *trapframe)
 			PMAP_LOCK(pmap);
 			if (!(pte = pmap_segmap(pmap, trapframe->badvaddr)))
 				panic("trap: utlbmod: invalid segmap");
-			pte += (trapframe->badvaddr >> PGSHIFT) & (NPTEPG - 1);
+			pte += (trapframe->badvaddr >> PAGE_SHIFT) & (NPTEPG - 1);
 			entry = *pte;
 #ifdef SMP
 			/* It is possible that some other CPU changed m-bit */
 			if (!mips_pg_v(entry) || (entry & mips_pg_m_bit())) {
-				trapframe->badvaddr = (trapframe->badvaddr & ~PGOFSET);
+				trapframe->badvaddr = (trapframe->badvaddr & ~PAGE_MASK);
 				pmap_update_page(pmap, trapframe->badvaddr, entry);
 				PMAP_UNLOCK(pmap);
 				goto out;
@@ -446,7 +446,7 @@ trap(struct trapframe *trapframe)
 			}
 			entry |= mips_pg_m_bit();
 			*pte = entry;
-			trapframe->badvaddr = (trapframe->badvaddr & ~PGOFSET);
+			trapframe->badvaddr = (trapframe->badvaddr & ~PAGE_MASK);
 			pmap_update_page(pmap, trapframe->badvaddr, entry);
 			trapframe->badvaddr |= (pmap->pm_asid[PCPU_GET(cpuid)].asid << VMTLB_PID_SHIFT);
 			pa = mips_tlbpfn_to_paddr(entry);
@@ -932,7 +932,7 @@ dofault:
 #endif
 
 	case T_FPE + T_USER:
-		MachFPTrap(trapframe->sr, trapframe->cause, trapframe->pc);
+		MipsFPTrap(trapframe->sr, trapframe->cause, trapframe->pc);
 		goto out;
 
 	case T_OVFLOW + T_USER:

Modified: user/jmallett/octeon/sys/mips/mips/vm_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sun Mar 28 02:44:33 2010	(r205786)
+++ user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sun Mar 28 02:48:39 2010	(r205787)
@@ -234,7 +234,7 @@ cpu_thread_swapin(struct thread *td)
 	 */
 	if (!(pte = pmap_segmap(kernel_pmap, td->td_md.md_realstack)))
 		panic("cpu_thread_swapin: invalid segmap");
-	pte += ((vm_offset_t)td->td_md.md_realstack >> PGSHIFT) & (NPTEPG - 1);
+	pte += ((vm_offset_t)td->td_md.md_realstack >> PAGE_SHIFT) & (NPTEPG - 1);
 
 	for (i = 0; i < KSTACK_PAGES - 1; i++) {
 		td->td_md.md_upte[i] = *pte & ~(PTE_RO|PTE_WIRED);
@@ -270,7 +270,7 @@ cpu_thread_alloc(struct thread *td)
 
 	if (!(pte = pmap_segmap(kernel_pmap, td->td_md.md_realstack)))
 		panic("cpu_thread_alloc: invalid segmap");
-	pte += ((vm_offset_t)td->td_md.md_realstack >> PGSHIFT) & (NPTEPG - 1);
+	pte += ((vm_offset_t)td->td_md.md_realstack >> PAGE_SHIFT) & (NPTEPG - 1);
 
 	for (i = 0; i < KSTACK_PAGES - 1; i++) {
 		td->td_md.md_upte[i] = *pte & ~(PTE_RO|PTE_WIRED);

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 03:00:19 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 43945106564A;
	Sun, 28 Mar 2010 03:00:19 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3387C8FC14;
	Sun, 28 Mar 2010 03:00:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2S30JQF079145;
	Sun, 28 Mar 2010 03:00:19 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2S30JX5079137;
	Sun, 28 Mar 2010 03:00:19 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201003280300.o2S30JX5079137@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sun, 28 Mar 2010 03:00:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205788 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 03:00:19 -0000

Author: jmallett
Date: Sun Mar 28 03:00:18 2010
New Revision: 205788
URL: http://svn.freebsd.org/changeset/base/205788

Log:
  Consistency:
  o) Remove some extern functions for which there are drop-in replacements using
     inline functions.

Modified:
  user/jmallett/octeon/sys/mips/include/cpu.h
  user/jmallett/octeon/sys/mips/mips/cpu.c
  user/jmallett/octeon/sys/mips/mips/machdep.c
  user/jmallett/octeon/sys/mips/mips/mp_machdep.c
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/support.S
  user/jmallett/octeon/sys/mips/mips/tlb.S

Modified: user/jmallett/octeon/sys/mips/include/cpu.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpu.h	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/include/cpu.h	Sun Mar 28 03:00:18 2010	(r205788)
@@ -456,11 +456,6 @@ struct user;
 
 u_int32_t mips_cp0_config1_read(void);
 int Mips_ConfigCache(void);
-void Mips_SetWIRED(int);
-void Mips_SetPID(int);
-u_int Mips_GetCOUNT(void);
-void Mips_SetCOMPARE(u_int);
-u_int Mips_GetCOMPARE(void);
 
 void Mips_SyncCache(void);
 void Mips_SyncDCache(vm_offset_t, int);
@@ -538,13 +533,9 @@ void setsoftintr1(void);
 void clearsoftintr1(void);
 
 
-u_int32_t mips_cp0_status_read(void);
-void mips_cp0_status_write(u_int32_t);
-
 int disableintr(void);
 void restoreintr(int);
 int enableintr(void);
-int Mips_TLBGetPID(void);
 
 void swi_vm(void *);
 void cpu_halt(void);

Modified: user/jmallett/octeon/sys/mips/mips/cpu.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/cpu.c	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/cpu.c	Sun Mar 28 03:00:18 2010	(r205788)
@@ -135,9 +135,9 @@ mips_cpu_init(void)
 	platform_cpu_init();
 	mips_get_identity(&cpuinfo);
 	num_tlbentries = cpuinfo.tlb_nentries;
-	Mips_SetWIRED(0);
+	mips_wr_wired(0);
 	Mips_TLBFlush(num_tlbentries);
-	Mips_SetWIRED(VMWIRED_ENTRIES);
+	mips_wr_wired(VMWIRED_ENTRIES);
 	mips_config_cache(&cpuinfo);
 	mips_vector_init();
 

Modified: user/jmallett/octeon/sys/mips/mips/machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/machdep.c	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/machdep.c	Sun Mar 28 03:00:18 2010	(r205788)
@@ -377,7 +377,7 @@ mips_vector_init(void)
 	enableintr();
 
 	/* Clear BEV in SR so we start handling our own exceptions */
-	mips_cp0_status_write(mips_cp0_status_read() & ~SR_BOOT_EXC_VEC);
+	mips_wr_status(mips_rd_status() & ~SR_BOOT_EXC_VEC);
 
 }
 
@@ -507,7 +507,7 @@ get_cyclecount(void)
 void
 cpu_idle(int busy)
 {
-	if (mips_cp0_status_read() & SR_INT_ENAB)
+	if (mips_rd_status() & SR_INT_ENAB)
 		__asm __volatile ("wait");
 	else
 		panic("ints disabled in idleproc!");

Modified: user/jmallett/octeon/sys/mips/mips/mp_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sun Mar 28 03:00:18 2010	(r205788)
@@ -235,9 +235,9 @@ smp_init_secondary(u_int32_t cpuid)
 	int ipi_int_mask, clock_int_mask;
 
 	/* TLB */
-	Mips_SetWIRED(0);
+	mips_wr_wired(0);
 	Mips_TLBFlush(num_tlbentries);
-	Mips_SetWIRED(VMWIRED_ENTRIES);
+	mips_wr_wired(VMWIRED_ENTRIES);
 
 	/*
 	 * We assume that the L1 cache on the APs is identical to the one
@@ -246,7 +246,7 @@ smp_init_secondary(u_int32_t cpuid)
 	mips_dcache_wbinv_all();
 	mips_icache_sync_all();
 
-	Mips_SetPID(0);
+	mips_wr_entryhi(0 << VMTLB_PID_SHIFT);
 
 	pcpu_init(PCPU_ADDR(cpuid), cpuid, sizeof(struct pcpu));
 	dpcpu_init(dpcpu, cpuid);

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sun Mar 28 03:00:18 2010	(r205788)
@@ -471,7 +471,7 @@ again:
 	kernel_pmap->pm_asid[0].asid = PMAP_ASID_RESERVED;
 	kernel_pmap->pm_asid[0].gen = 0;
 	pmap_max_asid = VMNUM_PIDS;
-	Mips_SetPID(0);
+	mips_wr_entryhi(0 << VMTLB_PID_SHIFT);
 }
 
 /*
@@ -596,7 +596,7 @@ pmap_TLB_invalidate_kernel(vm_offset_t v
 {
 	u_int32_t pid;
 
-	pid = Mips_TLBGetPID();
+	pid = mips_rd_entryhi() & VMTLB_PID;
 	va = va | (pid << VMTLB_PID_SHIFT);
 	Mips_TLBFlushAddr(va);
 }
@@ -647,7 +647,7 @@ pmap_TLB_update_kernel(vm_offset_t va, p
 {
 	u_int32_t pid;
 
-	pid = Mips_TLBGetPID();
+	pid = mips_rd_entryhi() & VMTLB_PID;
 	va = va | (pid << VMTLB_PID_SHIFT);
 
 	Mips_TLBUpdate(va, pte);
@@ -3112,7 +3112,7 @@ pmap_activate(struct thread *td)
 	pmap_asid_alloc(pmap);
 	if (td == curthread) {
 		PCPU_SET(segbase, pmap->pm_segtab);
-		Mips_SetPID(pmap->pm_asid[PCPU_GET(cpuid)].asid);
+		mips_wr_entryhi(pmap->pm_asid[PCPU_GET(cpuid)].asid << VMTLB_PID_SHIFT);
 	}
 
 	PCPU_SET(curpmap, pmap);

Modified: user/jmallett/octeon/sys/mips/mips/support.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/support.S	Sun Mar 28 03:00:18 2010	(r205788)
@@ -656,83 +656,6 @@ LEAF(fswintrberr)
 	li	v0, -1
 END(fswintrberr)
 
-/*--------------------------------------------------------------------------
- *
- * Mips_GetCOUNT --
- *
- *	Mips_GetCOUNT()
- *
- * Results:
- *	Returns the current COUNT reg.
- *
- * Side effects:
- *	None.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_GetCOUNT)
-	mfc0	v0, COP_0_COUNT
-	nop	#???
-	nop	#???
-	j	ra
-	nop
-END(Mips_GetCOUNT)
-
-/*--------------------------------------------------------------------------
- *
- * Mips_SetCOMPARE --
- *
- *	Mips_SetCOMPARE()
- *
- * Results:
- *	Sets a new value to the COMPARE register.
- *
- * Side effects:
- *	The COMPARE equal interrupt is acknowledged.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_SetCOMPARE)
-	mtc0	a0, COP_0_COMPARE
-	j	ra
-	nop
-END(Mips_SetCOMPARE)
-
-LEAF(Mips_GetCOMPARE)
-	mfc0	v0, COP_0_COMPARE
-	j	ra
-	nop
-END(Mips_GetCOMPARE)
-
-/*
- * u_int32_t mips_cp0_status_read(void)
- *
- *	Return the current value of the CP0 Status register.
- */
-LEAF(mips_cp0_status_read)
-	mfc0	v0, COP_0_STATUS_REG
-	j	ra
-	nop
-END(mips_cp0_status_read)
-
-/*
- * void mips_cp0_status_write(u_int32_t)
- *
- *	Set the value of the CP0 Status register.
- *
- *	Note: This is almost certainly not the way you want to write a
- *	"permanent" value to to the CP0 Status register, since it gets
- *	saved in trap frames and restores.
- */
-LEAF(mips_cp0_status_write)
-	mtc0	a0, COP_0_STATUS_REG
-	nop
-	nop
-	j	ra
-	nop
-END(mips_cp0_status_write)
-
-
 /*
  * memcpy(to, from, len)
  * {ov}bcopy(from, to, len)

Modified: user/jmallett/octeon/sys/mips/mips/tlb.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/tlb.S	Sun Mar 28 02:48:39 2010	(r205787)
+++ user/jmallett/octeon/sys/mips/mips/tlb.S	Sun Mar 28 03:00:18 2010	(r205788)
@@ -134,68 +134,6 @@ END(Mips_TLBWriteIndexed)
 
 /*--------------------------------------------------------------------------
  *
- * Mips_SetPID(int pid);
- *
- *	Write the given pid into the TLB pid reg.
- *
- * Results:
- *	None.
- *
- * Side effects:
- *	PID set in the entry hi register.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_SetPID)
-	MTC0	a0, COP_0_TLB_HI		# Write the hi reg value
-	nop					# required for QED5230
-	nop					# required for QED5230
-	j	ra
-	nop
-END(Mips_SetPID)
-
-/*--------------------------------------------------------------------------
- *
- * Mips_SetWIRED(int wired);
- *
- *	Write the given value into the TLB wired reg.
- *
- * Results:
- *	None.
- *
- * Side effects:
- *	WIRED set in the wired register.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_SetWIRED)
-	mtc0	a0, COP_0_TLB_WIRED
-	j	ra
-	nop
-END(Mips_SetWIRED)
-
-/*--------------------------------------------------------------------------
- *
- * Mips_GetWIRED(void);
- *
- *	Get the value from the TLB wired reg.
- *
- * Results:
- *	Value of wired reg.
- *
- * Side effects:
- *	None.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_GetWIRED)
-	mfc0	v0, COP_0_TLB_WIRED
-	j	ra
-	nop
-END(Mips_GetWIRED)
-
-/*--------------------------------------------------------------------------
- *
  * Mips_TLBFlush(tlbsize);
  *
  *	Flush the "random" entries from the TLB.
@@ -427,26 +365,6 @@ END(Mips_TLBRead)
 
 /*--------------------------------------------------------------------------
  *
- * Mips_TLBGetPID(void);
- *
- * Results:
- *	Returns the current TLB pid reg.
- *
- * Side effects:
- *	None.
- *
- *--------------------------------------------------------------------------
- */
-LEAF(Mips_TLBGetPID)
-	MFC0	v0, COP_0_TLB_HI		# get PID
-	j	ra
-	and	v0, v0, VMTLB_PID		# mask off PID
-END(Mips_TLBGetPID)
-
-
-
-/*--------------------------------------------------------------------------
- *
  * void mips_TBIAP(int sizeofTLB);
  *
  * Invalidate TLB entries belong to per process user spaces while

From owner-svn-src-user@FreeBSD.ORG  Sun Mar 28 21:14:09 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 584651065701;
	Sun, 28 Mar 2010 21:14:09 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 48A2D8FC12;
	Sun, 28 Mar 2010 21:14:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2SLE946046578;
	Sun, 28 Mar 2010 21:14:09 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2SLE9vt046574;
	Sun, 28 Mar 2010 21:14:09 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201003282114.o2SLE9vt046574@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Sun, 28 Mar 2010 21:14:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205807 - user/edwin/calendar
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 28 Mar 2010 21:14:09 -0000

Author: edwin
Date: Sun Mar 28 21:14:08 2010
New Revision: 205807
URL: http://svn.freebsd.org/changeset/base/205807

Log:
  Get rid of the last obstacle for WARNS=7.

Modified:
  user/edwin/calendar/calendar.h
  user/edwin/calendar/day.c
  user/edwin/calendar/io.c

Modified: user/edwin/calendar/calendar.h
==============================================================================
--- user/edwin/calendar/calendar.h	Sun Mar 28 20:19:41 2010	(r205806)
+++ user/edwin/calendar/calendar.h	Sun Mar 28 21:14:08 2010	(r205807)
@@ -54,7 +54,6 @@
 
 extern struct passwd *pw;
 extern int doall;
-extern struct iovec header[];
 extern time_t t1, t2;
 extern const char *calendarFile;
 extern int yrdays;
@@ -158,6 +157,7 @@ void	setnsequences(char *);
 
 /* day.c */
 extern const struct tm tm0;
+extern char dayname[];
 void	settimes(time_t,int before, int after, int friday, struct tm *tp1, struct tm *tp2);
 time_t	Mktime(char *);
 

Modified: user/edwin/calendar/day.c
==============================================================================
--- user/edwin/calendar/day.c	Sun Mar 28 20:19:41 2010	(r205806)
+++ user/edwin/calendar/day.c	Sun Mar 28 21:14:08 2010	(r205807)
@@ -43,10 +43,9 @@ __FBSDID("$FreeBSD$");
 
 #include "calendar.h"
 
-//struct tm		tp1, tp2;
 time_t			time1, time2;
 const struct tm		tm0;
-char			dayname[10];
+char			dayname[100];
 int			year1, year2;
 
 
@@ -69,14 +68,13 @@ settimes(time_t now, int before, int aft
 	localtime_r(&time2, tp2);
 	year2 = 1900 + tp2->tm_year;
 
-	header[5].iov_base = dayname;
+	strftime(dayname, sizeof(dayname) - 1, "%A, %d %B %Y", tp1);
 
 	oldl = NULL;
 	lbufp = setlocale(LC_TIME, NULL);
 	if (lbufp != NULL && (oldl = strdup(lbufp)) == NULL)
 		errx(1, "cannot allocate memory");
 	(void)setlocale(LC_TIME, "C");
-	header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", &tp);
 	(void)setlocale(LC_TIME, (oldl != NULL ? oldl : ""));
 	if (oldl != NULL)
 		free(oldl);

Modified: user/edwin/calendar/io.c
==============================================================================
--- user/edwin/calendar/io.c	Sun Mar 28 20:19:41 2010	(r205806)
+++ user/edwin/calendar/io.c	Sun Mar 28 21:14:08 2010	(r205807)
@@ -72,16 +72,6 @@ char	path[MAXPATHLEN];
 struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
 struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice;
 
-struct iovec header[] = {
-	{"From: ", 6},
-	{NULL, 0},
-	{" (Reminder Service)\nTo: ", 24},
-	{NULL, 0},
-	{"\nSubject: ", 10},
-	{NULL, 0},
-	{"'s Calendar\nPrecedence: bulk\n\n", 30},
-};
-
 #define	REPLACE(string, slen, struct_) \
 		if (strncasecmp(buf, (string), (slen)) == 0 && buf[(slen)]) { \
 			if (struct_.name != NULL)			      \
@@ -120,6 +110,7 @@ cal(void)
 	tm.tm_hour = 0;
 	tm.tm_wday = 0;
 
+	count = 0;
 	if ((fp = opencal()) == NULL)
 		return;
 	while (fgets(buf, sizeof(buf), stdin) != NULL) {
@@ -351,9 +342,14 @@ closecal(FILE *fp)
 	/* parent -- write to pipe input */
 	(void)close(pdes[0]);
 
-	header[1].iov_base = header[3].iov_base = pw->pw_name;
-	header[1].iov_len = header[3].iov_len = strlen(pw->pw_name);
-	writev(pdes[1], header, 7);
+	write(pdes[1], "From: \"Reminder Service\" <", 26);
+	write(pdes[1], pw->pw_name, strlen(pw->pw_name));
+	write(pdes[1], ">\nTo: <", 7);
+	write(pdes[1], pw->pw_name, strlen(pw->pw_name));
+	write(pdes[1], ">\nSubject: ", 12);
+	write(pdes[1], dayname, strlen(dayname));
+	write(pdes[1], "'s Calendar\nPrecedence: bulk\n\n", 30);
+
 	while ((nread = read(fileno(fp), buf, sizeof(buf))) > 0)
 		(void)write(pdes[1], buf, nread);
 	(void)close(pdes[1]);

From owner-svn-src-user@FreeBSD.ORG  Mon Mar 29 00:23:46 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id ABD7A106566B;
	Mon, 29 Mar 2010 00:23:46 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9BF808FC08;
	Mon, 29 Mar 2010 00:23:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2T0NkKW090771;
	Mon, 29 Mar 2010 00:23:46 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2T0NkAb090769;
	Mon, 29 Mar 2010 00:23:46 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201003290023.o2T0NkAb090769@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Mon, 29 Mar 2010 00:23:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205814 - user/dougb/portmaster
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Mar 2010 00:23:46 -0000

Author: dougb
Date: Mon Mar 29 00:23:46 2010
New Revision: 205814
URL: http://svn.freebsd.org/changeset/base/205814

Log:
  Make the handling of the backup package directory more rational,
  and avoid needless work.

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Mon Mar 29 00:14:34 2010	(r205813)
+++ user/dougb/portmaster/portmaster	Mon Mar 29 00:23:46 2010	(r205814)
@@ -1237,13 +1237,13 @@ init_packages_var () {
 
 	PACKAGES=`pm_make -f/usr/share/mk/bsd.port.mk -V PACKAGES 2>/dev/null`
 	if [ -z "$PACKAGES" ]; then
-		if [ -d /usr/ports/packages ]; then
+		if [ -d /usr/ports/packages -a -w /usr/ports/packages ]; then
 			PACKAGES='/usr/ports/packages'
 		else
-			if [ -d /usr/ports/ ]; then
+			if [ -d /usr/ports/ -a -w /usr/ports/ ]; then
 				PACKAGES='/usr/ports/packages'
 			else
-				fail 'The value of PACKAGES cannot be empty'
+fail 'The value of PACKAGES cannot be empty and the directory must be writable'
 			fi
 		fi
 	fi
@@ -1255,16 +1255,16 @@ init_packages () {
 
 	init_packages_var
 
-	if [ -z "$NO_BACKUP" ]; then
-		pbu=$PACKAGES/portmaster-backup
+	[ -n "$NO_BACKUP" ] && return
 
-		if [ ! -d "$pbu" ]; then
-			[ -n "$PM_SU_VERBOSE" ] &&
-				echo "===>>> Creating $pbu"
-			pm_mkdir_s $pbu
-		fi
-		export pbu
+	pbu=$PACKAGES/portmaster-backup
+
+	if [ ! -d "$pbu" ]; then
+		[ -n "$PM_SU_VERBOSE" ] &&
+			echo "===>>> Creating $pbu"
+		pm_mkdir_s $pbu
 	fi
+	export pbu
 }
 
 pm_pkg_create () {
@@ -2379,7 +2379,7 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S
 		fi
 	fi
 
-	[ -n "$NO_BACKUP" -a -z "$MAKE_PACKAGE" ] || init_packages
+	[ -n "$NO_BACKUP" -a -z "$MAKE_PACKAGE" ] || init_packages_var
 	[ -z "$NO_BACKUP" -a -z "$BACKUP" ] && export NB_DELETE
 
 	# Set the file name here so it's visible to the children

From owner-svn-src-user@FreeBSD.ORG  Mon Mar 29 03:06:09 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8C5021065676;
	Mon, 29 Mar 2010 03:06:09 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 796688FC1B;
	Mon, 29 Mar 2010 03:06:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2T369hM026727;
	Mon, 29 Mar 2010 03:06:09 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2T369am026726;
	Mon, 29 Mar 2010 03:06:09 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201003290306.o2T369am026726@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Mon, 29 Mar 2010 03:06:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205818 - user/dougb/portmaster
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Mar 2010 03:06:09 -0000

Author: dougb
Date: Mon Mar 29 03:06:08 2010
New Revision: 205818
URL: http://svn.freebsd.org/changeset/base/205818

Log:
  Allow -r to actually accept glob patterns, as advertised in the docs

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Mon Mar 29 01:24:20 2010	(r205817)
+++ user/dougb/portmaster/portmaster	Mon Mar 29 03:06:08 2010	(r205818)
@@ -1030,7 +1030,21 @@ while getopts 'BCDFGHKLPRabde:fghilm:nop
 	n)	NO_ACTION=nopt; ARGS="-n $ARGS" ;;
 	o)	REPLACE_ORIGIN=oopt ;;
 	p)	portdir="${OPTARG#$pd/}" ; portdir=${portdir%/} ;;
-	r)	UPDATE_REQ_BYS=ropt ; portdir=`origin_from_pdb $OPTARG` ;;
+	r)	UPDATE_REQ_BYS=ropt
+		if [ -d "$pdb/$OPTARG" ]; then
+			glob_dirs=$OPTARG
+		else
+			port=`globstrip $OPTARG`
+			glob_dirs=`find $pdb -maxdepth 1 -type d -name ${port}\*`
+			case "$glob_dirs" in
+			*\*|'') fail "$pdb/$port does not exist" ;;
+			# Match a newline in multiple responses from find
+			*'
+'*)				fail 'The argument to -r must match only one port' ;;
+			esac
+			unset port
+		fi
+		portdir=`origin_from_pdb ${glob_dirs##*/}` ; unset glob_dirs ;;
 	s)	CLEAN_STALE=sopt ;;
 	t)	RECURSE_THOROUGH=topt; ARGS="-t $ARGS" ;;
 	u)	echo "===>>> The -u option has been deprecated" ; echo '' ;;

From owner-svn-src-user@FreeBSD.ORG  Mon Mar 29 04:01:03 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5D0B61065670;
	Mon, 29 Mar 2010 04:01:03 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4AD3F8FC1A;
	Mon, 29 Mar 2010 04:01:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2T413gG039209;
	Mon, 29 Mar 2010 04:01:03 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2T413fP039208;
	Mon, 29 Mar 2010 04:01:03 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201003290401.o2T413fP039208@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Mon, 29 Mar 2010 04:01:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205819 - user/dougb/portmaster
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Mar 2010 04:01:03 -0000

Author: dougb
Date: Mon Mar 29 04:01:02 2010
New Revision: 205819
URL: http://svn.freebsd.org/changeset/base/205819

Log:
  Document the new --packages-delete option

Modified:
  user/dougb/portmaster/portmaster.8

Modified: user/dougb/portmaster/portmaster.8
==============================================================================
--- user/dougb/portmaster/portmaster.8	Mon Mar 29 03:06:08 2010	(r205818)
+++ user/dougb/portmaster/portmaster.8	Mon Mar 29 04:01:02 2010	(r205819)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2010
+.Dd March 28, 2010
 .Dt PORTMASTER 8
 .Os
 .Sh NAME
@@ -38,6 +38,7 @@ Common Flags:
 .Op Fl -delete-build-only
 .Op Fl -always-fetch
 .Op Fl -local-packagedir=<path>
+.Op Fl -delete-packages
 .Op Fl -no-confirm
 .Op Fl -no-term-title
 .Op Fl m Ar arguments for make
@@ -82,16 +83,19 @@ and/or multiple globs from /var/db/pkg
 .Op Fl -packages-if-newer
 .Op Fl -always-fetch
 .Op Fl -local-packagedir=<path>
+.Op Fl -delete-packages
 .Fl P|--packages
 .Nm
 .Op Fl -packages-if-newer
 .Op Fl -always-fetch
 .Op Fl -local-packagedir=<path>
+.Op Fl -delete-packages
 .Fl PP|--packages-only
 .Nm
 .Op Fl -packages-if-newer
 .Op Fl -always-fetch
 .Op Fl -local-packagedir=<path>
+.Op Fl -delete-packages
 .Fl -packages-build
 .Nm
 .Fl [l|L]
@@ -411,6 +415,8 @@ in the category subdirectories, such as
 .Pa <path>/devel ,
 .Pa <path>/ports-mgmt ,
 etc.
+.It Fl -delete-packages
+after installing from a package, delete it
 .It Fl -no-confirm
 do not ask the user to confirm the list of ports to
 be installed and/or updated before proceeding
@@ -606,6 +612,9 @@ along with their related options.
 # Specify a local package repository (--local-packagedir)
 # LOCAL_PACKAGEDIR=<path>
 #
+# Delete packages after they are installed (--delete-packages)
+# PM_DELETE_PACKAGES=pm_delete_packages
+#
 # Suppress the build confirmation message (--no-confirm)
 # PM_NO_CONFIRM=pm_no_confirm
 #

From owner-svn-src-user@FreeBSD.ORG  Mon Mar 29 06:54:31 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 65B46106564A;
	Mon, 29 Mar 2010 06:54:31 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3BAD08FC14;
	Mon, 29 Mar 2010 06:54:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2T6sUaH077170;
	Mon, 29 Mar 2010 06:54:30 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2T6sUFl077168;
	Mon, 29 Mar 2010 06:54:30 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201003290654.o2T6sUFl077168@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Mon, 29 Mar 2010 06:54:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205822 - user/edwin/calendar
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Mar 2010 06:54:31 -0000

Author: edwin
Date: Mon Mar 29 06:54:30 2010
New Revision: 205822
URL: http://svn.freebsd.org/changeset/base/205822

Log:
  Add $FreeBSD$ keyword.

Modified:
  user/edwin/calendar/sunpos.c

Modified: user/edwin/calendar/sunpos.c
==============================================================================
--- user/edwin/calendar/sunpos.c	Mon Mar 29 06:49:20 2010	(r205821)
+++ user/edwin/calendar/sunpos.c	Mon Mar 29 06:54:30 2010	(r205822)
@@ -24,6 +24,9 @@
  * 
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 /*
  * This code is created to match the formulas available at:
  * Formula and examples obtained from "How to Calculate alt/az: SAAO" at

From owner-svn-src-user@FreeBSD.ORG  Mon Mar 29 07:54:20 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF51A1065670;
	Mon, 29 Mar 2010 07:54:20 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A69118FC0C;
	Mon, 29 Mar 2010 07:54:20 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2T7sKsB090565;
	Mon, 29 Mar 2010 07:54:20 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2T7sKvj090563;
	Mon, 29 Mar 2010 07:54:20 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201003290754.o2T7sKvj090563@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Mon, 29 Mar 2010 07:54:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205829 - user/dougb/portmaster
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 29 Mar 2010 07:54:20 -0000

Author: dougb
Date: Mon Mar 29 07:54:20 2010
New Revision: 205829
URL: http://svn.freebsd.org/changeset/base/205829

Log:
  Minor updates from ports version 2.20:
  1. Add a 'sleep 5' to the warning about /etc/portmaster.rc
  2. Don't init_packages() if -F
  3. In the INIT phase revert the change to init_packages_var
  4. Add one more missing $PM_SU_CMD to the package fetch

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Mon Mar 29 07:09:27 2010	(r205828)
+++ user/dougb/portmaster/portmaster	Mon Mar 29 07:54:20 2010	(r205829)
@@ -28,7 +28,7 @@ if [ -z "$PM_PARENT_PID" ]; then
 		echo '       Your portmaster.rc is in /etc, however support for the file in this'
 		echo '       location is deprecated, and will be removed in a future version.'
 		echo '' ; echo '       The proper location for this file is /usr/local/etc'
-		echo '' ; . /etc/portmaster.rc
+		echo '' ; sleep 5 ; . /etc/portmaster.rc
 	fi
 	[ -r /usr/local/etc/portmaster.rc ] && . /usr/local/etc/portmaster.rc
 
@@ -1267,6 +1267,8 @@ fail 'The value of PACKAGES cannot be em
 init_packages () {
 	# Global: pbu
 
+	[ -n "$FETCH_ONLY" ] && return
+
 	init_packages_var
 
 	[ -n "$NO_BACKUP" ] && return
@@ -2393,7 +2395,7 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S
 		fi
 	fi
 
-	[ -n "$NO_BACKUP" -a -z "$MAKE_PACKAGE" ] || init_packages_var
+	[ -n "$NO_BACKUP" -a -z "$MAKE_PACKAGE" ] || init_packages
 	[ -z "$NO_BACKUP" -a -z "$BACKUP" ] && export NB_DELETE
 
 	# Set the file name here so it's visible to the children
@@ -2897,7 +2899,7 @@ fetch_package () {
 		[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Fetching ${1}.tbz"
 		$PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null || {
 			pm_unlink_s ${ppd}/${1}.tbz;
-			fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null; }
+			$PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null; }
 	fi
 }
 	if [ -z "$PACKAGESITE" ]; then

From owner-svn-src-user@FreeBSD.ORG  Tue Mar 30 22:31:31 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 04798106566C;
	Tue, 30 Mar 2010 22:31:31 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E898C8FC1B;
	Tue, 30 Mar 2010 22:31:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2UMVU47014254;
	Tue, 30 Mar 2010 22:31:30 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2UMVUif014252;
	Tue, 30 Mar 2010 22:31:30 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201003302231.o2UMVUif014252@svn.freebsd.org>
From: Doug Barton <dougb@FreeBSD.org>
Date: Tue, 30 Mar 2010 22:31:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205939 - user/dougb/portmaster
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 30 Mar 2010 22:31:31 -0000

Author: dougb
Date: Tue Mar 30 22:31:30 2010
New Revision: 205939
URL: http://svn.freebsd.org/changeset/base/205939

Log:
  Call init_packages() in pm_pkg_create() so that if a parallel portmaster
  cleaned up empty package directories we can still create packages. Also,
  call init_packages() unconditionally in -s mode. The function has been
  optimized sufficiently so that concerns about doing duplicate work are no
  longer valid, and it's safer at this point to just do it.
  
  Add a pm_sv() for printing verbose messages when using sudo, and convert
  existing messages to use it. This cleans up the code quite a bit, and will
  also help in debugging efforts.
  
  Use pm_make_s (sudo version) for the 'clean' target. In the normal case
  this is not necessary since the port is built as the unprivileged user,
  however some ports (e.g., thunderbird-3) do 'stuff' in the 'install'
  target (which is priviliged) that the unprivileged user can't undo.

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Tue Mar 30 21:54:25 2010	(r205938)
+++ user/dougb/portmaster/portmaster	Tue Mar 30 22:31:30 2010	(r205939)
@@ -141,16 +141,14 @@ safe_exit () {
 	[ -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ] &&
 		files=`find $pdb -type f -name PM_UPGRADE_DONE_FLAG`
 	if [ -n "$files" ]; then
-		[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Deleting 'install complete' flags"
+		pm_sv Deleting \'install complete\' flags
 		pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete
 	fi
 	# Outdent
 			fi
 			if [ -z "$BACKUP" -a -z "$NO_BACKUP" -a \
 			    -n "$NB_DELETE" ]; then
-				[ -n "$PM_SU_VERBOSE" ] &&
-		echo "===>>> Deleting safety packages for successful installs"
+				pm_sv Deleting safety packages for successful installs
 				pm_cd $pbu || fail "Cannot cd to $pbu"
 				pm_rm_s $NB_DELETE
 			fi
@@ -158,8 +156,7 @@ safe_exit () {
 
 		[ -n "$pbu" ] && pbu=`find $pbu -type d -empty 2>/dev/null`
 		if [ -d "$pbu" ]; then
-			[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Removing empty backup package directory"
+			pm_sv Removing empty backup package directory
 			pm_rmdir_s $pbu
 		fi
 
@@ -386,6 +383,8 @@ pm_rm_s           () { $PM_SU_CMD /bin/r
 pm_rmdir_s        () { $PM_SU_CMD /bin/rmdir $*; }
 pm_unlink_s       () { /bin/test -e $1 && $PM_SU_CMD /bin/unlink $1; }
 
+pm_sv             () { [ -n "$PM_SU_VERBOSE" ] && echo "===>>> SUDO $*"; }
+
 #=============== End functions we always want to have ===============
 
 packages_init () {
@@ -484,7 +483,7 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then
 
 		PM_INDEX="${INDEXDIR}/${INDEXFILE}"
 		index_time=`stat -f '%Ua' $PM_INDEX`
-		[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Updating INDEX file"
+		pm_sv Updating INDEX file
 		$PM_SU_CMD $FETCHINDEX ${PM_INDEX}.bz2 ${MASTER_SITE_INDEX}${INDEXFILE}.bz2
 		if [ $index_time -ne `stat -f '%Ua' $PM_INDEX` ]; then
 			temp_index=`pm_mktemp index`
@@ -1276,8 +1275,7 @@ init_packages () {
 	pbu=$PACKAGES/portmaster-backup
 
 	if [ ! -d "$pbu" ]; then
-		[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Creating $pbu"
+		pm_sv Creating $pbu
 		pm_mkdir_s $pbu
 	fi
 	export pbu
@@ -1286,6 +1284,8 @@ init_packages () {
 pm_pkg_create () {
 	local pkgdir
 
+	init_packages
+
 	if [ "$1" = "$PACKAGES" ]; then
 		for pkgdir in All Latest ${portdir%/*}; do
 			pm_mkdir_s ${PACKAGES}/${pkgdir} ||
@@ -1376,13 +1376,12 @@ delete_dist_list () {
 
 	local dir
 
-	[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Deleting $dist_list"
+	pm_sv Deleting $dist_list
 	pm_unlink_s $dist_list
 
 	dir=`find ${dist_list%/distfiles} -type d -empty 2>/dev/null`
 	if [ -d "$dir" ]; then
-		[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Deleting the $dir directory"
+		pm_sv Deleting the $dir directory
 		pm_rmdir_s $dir
 	fi
 }
@@ -1695,11 +1694,7 @@ if [ -n "$CLEAN_STALE" ]; then
 		echo -n "===>>> ${iport} is no longer depended on, delete? y/n [n] "
 		read answer
 		case "$answer" in
-		[yY])	if [ -n "$BACKUP" ]; then
-				[ -z "$PACKAGES" ] && init_packages
-				pm_pkg_create $pbu $iport
-			fi
-
+		[yY])	[ -n "$BACKUP" ] && { init_packages ; pm_pkg_create $pbu $iport; }
 			[ -z "$DONT_SCRUB_DISTFILES" ] &&
 				delete_all_distfiles $origin
 
@@ -2319,8 +2314,7 @@ multiport () {
 make_config () {
 	config_type=config-conditional
 	[ -n "$FORCE_CONFIG" ] && config_type=config
-	[ -n "$PM_SU_VERBOSE" ] &&
-		echo "===>>> Running 'make $config_type'"
+	pm_sv Running \'make $config_type\'
 	pm_cd_pd $portdir
 	pm_make_s $config_type
 }
@@ -2367,10 +2361,9 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S
 		echo -n "       -[rf] run of ${0##*/}, delete them? y/n [n] "
 		read answer
 		case "$answer" in
-		[yY]) [ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Deleting 'install complete' flags"
-		pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete ;;
-		*) echo -n "===>>> Enable the -R option? y/n [n] "
+		[yY])	pm_sv Deleting \'install complete\' flags
+			pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete ;;
+		*)	echo -n "===>>> Enable the -R option? y/n [n] "
 			read answer
 			case "$answer" in
 			[yY]) RESTART=Ropt ; ARGS="-R $ARGS" ;;
@@ -2865,7 +2858,7 @@ fetch_package () {
 	fi
 
 	if [ ! -d "$ppd" ]; then
-		[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Creating $ppd"
+		pm_sv Creating $ppd
 		pm_mkdir_s $ppd
 	fi
 
@@ -2896,7 +2889,7 @@ fetch_package () {
 			fi
 		fi
 
-		[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Fetching ${1}.tbz"
+		pm_sv Fetching ${1}.tbz
 		$PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null || {
 			pm_unlink_s ${ppd}/${1}.tbz;
 			$PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null; }
@@ -3121,13 +3114,11 @@ if [ -n "$upg_port" ]; then
 		done
 		if [ -n "$temp" ]; then
 			if [ ! -d "$LOCALBASE_COMPAT/pkg" ]; then
-				[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Creating $LOCALBASE_COMPAT/pkg for -w"
+				pm_sv Creating $LOCALBASE_COMPAT/pkg for -w
 				pm_mkdir_s $LOCALBASE_COMPAT/pkg
 			fi
 
-			[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Copying old shared libraries for -w"
+			pm_sv Copying old shared libraries for -w
 			$PM_SU_CMD cp -p $temp $LOCALBASE_COMPAT/pkg/
 		fi
 
@@ -3141,14 +3132,12 @@ if [ -n "$upg_port" ]; then
 		# Delete any existing versions of the new port
 		iport=`iport_from_origin $portdir`
 		if [ -n "$iport" ]; then
-			[ -n "$PM_SU_VERBOSE" ] &&
-				echo "===>>> Running pkg_delete for $iport"
+			pm_sv Running pkg_delete for $iport
 			pm_pkg_delete_s -f $iport
 		fi
 	fi
 
-	[ -n "$PM_SU_VERBOSE" ] &&
-		echo "===>>> Running pkg_delete for $upg_port"
+	pm_sv Running pkg_delete for $upg_port
 	pm_pkg_delete_s -f $upg_port
 	[ -z "$PM_INDEX_ONLY" ] && pm_cd_pd $portdir
 fi
@@ -3169,7 +3158,7 @@ install_failed () {
 }
 
 if [ -z "$use_package" ]; then
-	[ -n "$PM_SU_VERBOSE" ] && echo "===>>> Running make install"
+	pm_sv Running make install
 
 	if [ -n "$PM_SU_UNSET_PORT_LOG_ARGS" ]; then
 		unset port_log_args
@@ -3210,8 +3199,7 @@ if [ -z "$temp" -a -d "$LOCALBASE_COMPAT
 	done
 
 	if [ -n "$files" ]; then
-		[ -n "$PM_SU_VERBOSE" ] &&
-	echo "===>>> Removing old shared libraries, and running ldconfig"
+		pm_sv Removing old shared libraries, and running ldconfig
 		pm_rm_s $files
 		$PM_SU_CMD /etc/rc.d/ldconfig start > /dev/null
 	fi
@@ -3220,8 +3208,7 @@ fi
 
 [ -z "$temp" ] && temp=`find $LOCALBASE_COMPAT/pkg -type d -empty 2>/dev/null`
 if [ -d "$temp" ]; then
-	[ -n "$PM_SU_VERBOSE" ] &&
-		echo "===>>> Deleting the empty $LOCALBASE_COMPAT/pkg"
+	pm_sv Deleting the empty $LOCALBASE_COMPAT/pkg
 	pm_rmdir_s $temp
 fi
 unset temp
@@ -3237,8 +3224,7 @@ if [ -n "$distfiles" ]; then
 	dist_list=`pm_make_b -V OPTIONSFILE`
 	dist_list="${dist_list%options}distfiles"
 	if [ ! -d "${dist_list%/distfiles}" ]; then
-		[ -n "$PM_SU_VERBOSE" ] &&
-			echo "===>>> Creating ${dist_list%/distfiles}"
+		pm_sv Creating ${dist_list%/distfiles}
 		pm_mkdir_s ${dist_list%/distfiles}
 	fi
 
@@ -3264,8 +3250,7 @@ if [ -n "$distfiles" ]; then
 			echo "${ds}$file" >> $DI_FILES
 	done
 
-	[ -n "$PM_SU_VERBOSE" ] &&
-		echo "===>>> Installing $dist_list"
+	pm_sv Installing $dist_list
 	pm_install_s $dist_list_temp $dist_list
 	pm_unlink $dist_list_temp ; unset ds dist_list_temp
 fi
@@ -3291,7 +3276,8 @@ fi
 
 if [ -z "$use_package" ]; then
 	[ -z "$DONT_POST_CLEAN" ] && {
-		pm_make clean NOCLEANDEPENDS=ncd2 ; echo ''; }
+		pm_sv Running \'make clean\'
+		pm_make_s clean NOCLEANDEPENDS=ncd2 ; echo ''; }
 fi
 
 check_dependency_files $portdir $new_port

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 06:37:44 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7E53E106564A;
	Wed, 31 Mar 2010 06:37:44 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6C8858FC16;
	Wed, 31 Mar 2010 06:37:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2V6biWn023018;
	Wed, 31 Mar 2010 06:37:44 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2V6bi5J023006;
	Wed, 31 Mar 2010 06:37:44 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201003310637.o2V6bi5J023006@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Wed, 31 Mar 2010 06:37:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205962 - user/edwin/calendar
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 06:37:44 -0000

Author: edwin
Date: Wed Mar 31 06:37:44 2010
New Revision: 205962
URL: http://svn.freebsd.org/changeset/base/205962

Log:
  Sync with freshly commited code.

Modified:
  user/edwin/calendar/calendar.c
  user/edwin/calendar/calendar.h
  user/edwin/calendar/dates.c
  user/edwin/calendar/day.c
  user/edwin/calendar/events.c
  user/edwin/calendar/io.c
  user/edwin/calendar/locale.c
  user/edwin/calendar/parsedata.c
  user/edwin/calendar/pathnames.h
  user/edwin/calendar/pom.c
  user/edwin/calendar/sunpos.c

Modified: user/edwin/calendar/calendar.c
==============================================================================
--- user/edwin/calendar/calendar.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/calendar.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/calendar.h
==============================================================================
--- user/edwin/calendar/calendar.h	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/calendar.h	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/dates.c
==============================================================================
--- user/edwin/calendar/dates.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/dates.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 1992-2009 Edwin Groothuis. All rights reserved.
+ * Copyright (c) 1992-2009 Edwin Groothuis <edwin@FreeBSD.org>.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: user/edwin/calendar/day.c
==============================================================================
--- user/edwin/calendar/day.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/day.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/events.c
==============================================================================
--- user/edwin/calendar/events.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/events.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 1992-2009 Edwin Groothuis. All rights reserved.
+ * Copyright (c) 1992-2009 Edwin Groothuis <edwin@FreeBSD.org>.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: user/edwin/calendar/io.c
==============================================================================
--- user/edwin/calendar/io.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/io.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/locale.c
==============================================================================
--- user/edwin/calendar/locale.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/locale.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/parsedata.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 1992-2009 Edwin Groothuis. All rights reserved.
+ * Copyright (c) 1992-2009 Edwin Groothuis <edwin@FreeBSD.org>.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,9 +40,9 @@ __FBSDID("$FreeBSD$");
 static char *showflags(int flags);
 static int isonlydigits(char *s, int nostar);
 static const char *getmonthname(int i);
-static int checkmonth(char *s, int *len, int *offset, const char **month);
+static int checkmonth(char *s, size_t *len, size_t *offset, const char **month);
 static const char *getdayofweekname(int i);
-static int checkdayofweek(char *s, int *len, int *offset, const char **dow);
+static int checkdayofweek(char *s, size_t *len, size_t *offset, const char **dow);
 static int indextooffset(char *s);
 static int parseoffset(char *s);
 static char *floattoday(int year, double f);
@@ -771,7 +772,7 @@ getmonthname(int i)
 }
 
 static int
-checkmonth(char *s, int *len, int *offset, const char **month)
+checkmonth(char *s, size_t *len, size_t *offset, const char **month)
 {
 	struct fixs *n;
 	int i;
@@ -822,7 +823,7 @@ getdayofweekname(int i)
 }
 
 static int
-checkdayofweek(char *s, int *len, int *offset, const char **dow)
+checkdayofweek(char *s, size_t *len, size_t *offset, const char **dow)
 {
 	struct fixs *n;
 	int i;

Modified: user/edwin/calendar/pathnames.h
==============================================================================
--- user/edwin/calendar/pathnames.h	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/pathnames.h	Wed Mar 31 06:37:44 2010	(r205962)
@@ -10,10 +10,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/pom.c
==============================================================================
--- user/edwin/calendar/pom.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/pom.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -12,10 +12,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.

Modified: user/edwin/calendar/sunpos.c
==============================================================================
--- user/edwin/calendar/sunpos.c	Wed Mar 31 05:23:35 2010	(r205961)
+++ user/edwin/calendar/sunpos.c	Wed Mar 31 06:37:44 2010	(r205962)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2009-2010 Edwin Groothuis. All rights reserved.
+ * Copyright (c) 2009-2010 Edwin Groothuis <edwin@FreeBSD.org>.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 06:49:40 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4E108106566B;
	Wed, 31 Mar 2010 06:49:40 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3D86E8FC13;
	Wed, 31 Mar 2010 06:49:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2V6neT7025734;
	Wed, 31 Mar 2010 06:49:40 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2V6neVF025732;
	Wed, 31 Mar 2010 06:49:40 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201003310649.o2V6neVF025732@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Wed, 31 Mar 2010 06:49:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205963 - user/edwin/calendar
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 06:49:40 -0000

Author: edwin
Date: Wed Mar 31 06:49:39 2010
New Revision: 205963
URL: http://svn.freebsd.org/changeset/base/205963

Log:
  Syn with head

Modified:
  user/edwin/calendar/calendar.1

Modified: user/edwin/calendar/calendar.1
==============================================================================
--- user/edwin/calendar/calendar.1	Wed Mar 31 06:37:44 2010	(r205962)
+++ user/edwin/calendar/calendar.1	Wed Mar 31 06:49:39 2010	(r205963)
@@ -9,10 +9,6 @@
 .\" 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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"     This product includes software developed by the University of
-.\"     California, Berkeley and its contributors.
 .\" 4. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 06:50:25 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7DBD11065670;
	Wed, 31 Mar 2010 06:50:25 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6DBB88FC20;
	Wed, 31 Mar 2010 06:50:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2V6oPjQ025941;
	Wed, 31 Mar 2010 06:50:25 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2V6oP4N025939;
	Wed, 31 Mar 2010 06:50:25 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201003310650.o2V6oP4N025939@svn.freebsd.org>
From: Edwin Groothuis <edwin@FreeBSD.org>
Date: Wed, 31 Mar 2010 06:50:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205964 - user/edwin/calendar
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 06:50:25 -0000

Author: edwin
Date: Wed Mar 31 06:50:25 2010
New Revision: 205964
URL: http://svn.freebsd.org/changeset/base/205964

Log:
  Be able to use "Month/DoW(+-)\d+" as alternative for Last, First,
  second third etc.

Modified:
  user/edwin/calendar/parsedata.c

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Wed Mar 31 06:49:39 2010	(r205963)
+++ user/edwin/calendar/parsedata.c	Wed Mar 31 06:50:25 2010	(r205964)
@@ -884,6 +884,11 @@ indextooffset(char *s)
 	int i;
 	struct fixs *n;
 
+	if (s[0] == '+')
+		return(strtoll(s + 1, NULL, 10));
+	if (s[0] == '-')
+		return(-strtoll(s + 1, NULL, 10));
+
 	for (i = 0; i < 6; i++) {
 		if (strcasecmp(s, sequences[i]) == 0) {
 			if (i == 5)

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 12:22:56 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 08E071065672;
	Wed, 31 Mar 2010 12:22:56 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id ECEEB8FC13;
	Wed, 31 Mar 2010 12:22:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2VCMtE2005308;
	Wed, 31 Mar 2010 12:22:55 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2VCMtr4005306;
	Wed, 31 Mar 2010 12:22:55 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201003311222.o2VCMtr4005306@svn.freebsd.org>
From: Dag-Erling Smorgrav <des@FreeBSD.org>
Date: Wed, 31 Mar 2010 12:22:55 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205977 - user/des/svnsup/src/libsvnsup
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 12:22:56 -0000

Author: des
Date: Wed Mar 31 12:22:55 2010
New Revision: 205977
URL: http://svn.freebsd.org/changeset/base/205977

Log:
  useless cast

Modified:
  user/des/svnsup/src/libsvnsup/svnsup_string.c

Modified: user/des/svnsup/src/libsvnsup/svnsup_string.c
==============================================================================
--- user/des/svnsup/src/libsvnsup/svnsup_string.c	Wed Mar 31 08:17:32 2010	(r205976)
+++ user/des/svnsup/src/libsvnsup/svnsup_string.c	Wed Mar 31 12:22:55 2010	(r205977)
@@ -105,7 +105,7 @@ svnsup_buf_fencode(FILE *f, const unsign
 	if (svnsup_buf_is_safe(buf, size))
 		return (fprintf(f, "%zu[%.*s]", size, (int)size, buf));
 	len = fprintf(f, "%zu{", size);
-	len += svnsup_base64_fencode(f, (const unsigned char *)buf, size);
+	len += svnsup_base64_fencode(f, buf, size);
 	len += fprintf(f, "}");
 	return (len);
 }

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 21:12:28 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0C978106566B;
	Wed, 31 Mar 2010 21:12:28 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EF4C68FC15;
	Wed, 31 Mar 2010 21:12:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2VLCR8p023448;
	Wed, 31 Mar 2010 21:12:27 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2VLCRE5023444;
	Wed, 31 Mar 2010 21:12:27 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201003312112.o2VLCRE5023444@svn.freebsd.org>
From: Dag-Erling Smorgrav <des@FreeBSD.org>
Date: Wed, 31 Mar 2010 21:12:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206003 - user/des/svnsup/src/libsvnsup
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 21:12:28 -0000

Author: des
Date: Wed Mar 31 21:12:27 2010
New Revision: 206003
URL: http://svn.freebsd.org/changeset/base/206003

Log:
  MD5 handling - currently, conversion to and from string

Added:
  user/des/svnsup/src/libsvnsup/svnsup_md5.c   (contents, props changed)
  user/des/svnsup/src/libsvnsup/svnsup_md5.h   (contents, props changed)
Modified:
  user/des/svnsup/src/libsvnsup/Makefile.am

Modified: user/des/svnsup/src/libsvnsup/Makefile.am
==============================================================================
--- user/des/svnsup/src/libsvnsup/Makefile.am	Wed Mar 31 20:55:13 2010	(r206002)
+++ user/des/svnsup/src/libsvnsup/Makefile.am	Wed Mar 31 21:12:27 2010	(r206003)
@@ -5,7 +5,9 @@ lib_LIBRARIES = libsvnsup.a
 libsvnsup_a_SOURCES = \
 	svnsup_base64.c \
 	svnsup_delta.c \
+	svnsup_md5.c \
 	svnsup_string.c
 
 noinst_HEADERS = \
-	svnsup.h
+	svnsup.h \
+	svnsup_md5.h

Added: user/des/svnsup/src/libsvnsup/svnsup_md5.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/src/libsvnsup/svnsup_md5.c	Wed Mar 31 21:12:27 2010	(r206003)
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+
+#include <assert.h>
+#include <ctype.h>
+
+#include "svnsup_md5.h"
+
+// XXX error handling and documentation
+
+static unsigned int
+x2i(char x)
+{
+
+	assert(x != '\0');
+	switch (x) {
+	case '0': case '1': case '2': case '3': case '4':
+	case '5': case '6': case '7': case '8': case '9':
+		return (x - '0');
+	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+		return (x - 'A');
+	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+		return (x - 'a');
+	}
+	assert(0);
+}
+
+void
+md5s2b(const char *md5s, svnsup_md5 *md5p)
+{
+	unsigned char *md5b = md5p->md5;
+	int i;
+
+	for (i = 0; i < 16; ++i) {
+		md5b[i] = x2i(*md5s++) << 4;
+		md5b[i] |= x2i(*md5s++);
+	}
+	assert(*md5s == '\0');
+}
+
+static char
+i2x(unsigned int i)
+{
+
+	assert(i < 16);
+	return (i + (i < 10) ? '0' : 'a');
+}
+
+void
+md5b2s(const svnsup_md5 *md5p, char *md5s)
+{
+	const unsigned char *md5b = md5p->md5;
+	int i;
+
+	for (i = 0; i < 32; ++md5b) {
+		md5s[i++] = i2x(*md5b >> 4);
+		md5s[i++] = i2x(*md5b & 0x0f);
+	}
+	assert(*md5s == '\0');
+}

Added: user/des/svnsup/src/libsvnsup/svnsup_md5.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/src/libsvnsup/svnsup_md5.h	Wed Mar 31 21:12:27 2010	(r206003)
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_MD5_H_INCLUDED
+#define SVNSUP_MD5_H_INCLUDED
+
+typedef struct svnsup_md5 {
+	unsigned char md5[16];
+} svnsup_md5;
+
+void md5s2b(const char *, svnsup_md5 *);
+void md5b2s(const svnsup_md5 *, char *);
+
+#endif

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 21:33:52 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 239BB106566B;
	Wed, 31 Mar 2010 21:33:52 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 103018FC1A;
	Wed, 31 Mar 2010 21:33:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2VLXpCv028366;
	Wed, 31 Mar 2010 21:33:51 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2VLXpUx028354;
	Wed, 31 Mar 2010 21:33:51 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201003312133.o2VLXpUx028354@svn.freebsd.org>
From: Dag-Erling Smorgrav <des@FreeBSD.org>
Date: Wed, 31 Mar 2010 21:33:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206006 - in user/des/svnsup: . bin bin/apply
	bin/distill include include/svnsup lib lib/libsvnsup
	src/apply src/distill src/libsvnsup
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 21:33:52 -0000

Author: des
Date: Wed Mar 31 21:33:51 2010
New Revision: 206006
URL: http://svn.freebsd.org/changeset/base/206006

Log:
  reorg

Added:
  user/des/svnsup/bin/Makefile.am   (contents, props changed)
  user/des/svnsup/bin/apply/
     - copied from r206003, user/des/svnsup/src/apply/
  user/des/svnsup/bin/distill/
     - copied from r206003, user/des/svnsup/src/distill/
  user/des/svnsup/include/Makefile.am   (contents, props changed)
  user/des/svnsup/include/svnsup/Makefile.am   (contents, props changed)
  user/des/svnsup/include/svnsup/svnsup.h
     - copied unchanged from r206003, user/des/svnsup/src/libsvnsup/svnsup.h
  user/des/svnsup/lib/Makefile.am   (contents, props changed)
  user/des/svnsup/lib/libsvnsup/
     - copied from r206003, user/des/svnsup/src/libsvnsup/
Directory Properties:
  user/des/svnsup/bin/   (props changed)
  user/des/svnsup/include/   (props changed)
  user/des/svnsup/include/svnsup/   (props changed)
  user/des/svnsup/lib/   (props changed)
Deleted:
  user/des/svnsup/lib/libsvnsup/svnsup.h
  user/des/svnsup/src/apply/
  user/des/svnsup/src/distill/
  user/des/svnsup/src/libsvnsup/
Modified:
  user/des/svnsup/Makefile.am
  user/des/svnsup/bin/apply/Makefile.am
  user/des/svnsup/bin/distill/Makefile.am
  user/des/svnsup/configure.ac
  user/des/svnsup/lib/libsvnsup/Makefile.am
  user/des/svnsup/lib/libsvnsup/svnsup_md5.c

Modified: user/des/svnsup/Makefile.am
==============================================================================
--- user/des/svnsup/Makefile.am	Wed Mar 31 21:32:52 2010	(r206005)
+++ user/des/svnsup/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -2,4 +2,4 @@
 
 DISTCHECK_CONFIGURE_FLAGS = CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS}
 
-SUBDIRS = src
+SUBDIRS = include lib bin

Added: user/des/svnsup/bin/Makefile.am
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/bin/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -0,0 +1,11 @@
+# $Id$
+
+if ENABLE_DISTILL
+DISTILL_SUBDIR = distill
+endif
+
+if ENABLE_APPLY
+APPLY_SUBDIR = apply
+endif
+
+SUBDIRS = ${DISTILL_SUBDIR} ${APPLY_SUBDIR}

Modified: user/des/svnsup/bin/apply/Makefile.am
==============================================================================
--- user/des/svnsup/src/apply/Makefile.am	Wed Mar 31 21:12:27 2010	(r206003)
+++ user/des/svnsup/bin/apply/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -6,7 +6,7 @@ svnsup_apply_SOURCES = \
 	main.c
 
 svnsup_apply_CPPFLAGS = \
-	-I$(top_builddir)/src/libsvnsup
+	-I$(top_srcdir)/include/svnsup
 
 svnsup_apply_LDADD = \
-        $(top_builddir)/src/libsvnsup/libsvnsup.a
+        $(top_builddir)/lib/libsvnsup/libsvnsup.a

Modified: user/des/svnsup/bin/distill/Makefile.am
==============================================================================
--- user/des/svnsup/src/distill/Makefile.am	Wed Mar 31 21:12:27 2010	(r206003)
+++ user/des/svnsup/bin/distill/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -15,11 +15,11 @@ svnsup_distill_SOURCES = \
 	txdelta.c
 
 svnsup_distill_CPPFLAGS = \
-	-I$(top_builddir)/src/libsvnsup \
+	-I$(top_srcdir)/include/svnsup \
 	${APR_1_CFLAGS}
 
 svnsup_distill_LDADD = \
-	$(top_builddir)/src/libsvnsup/libsvnsup.a \
+	$(top_builddir)/lib/libsvnsup/libsvnsup.a \
 	${APR_1_LDADD} \
 	${SVN_DELTA_1_LIBS} \
 	${SVN_CLIENT_1_LIBS} \

Modified: user/des/svnsup/configure.ac
==============================================================================
--- user/des/svnsup/configure.ac	Wed Mar 31 21:32:52 2010	(r206005)
+++ user/des/svnsup/configure.ac	Wed Mar 31 21:33:51 2010	(r206006)
@@ -3,7 +3,7 @@
 #
 AC_PREREQ([2.59])
 AC_INIT([svnsup], [1.0], [des@des.no])
-AC_CONFIG_SRCDIR([src/distill/distill.c])
+AC_CONFIG_SRCDIR([include/svnsup/svnsup.h])
 AM_CONFIG_HEADER([config.h])
 AM_INIT_AUTOMAKE
 
@@ -131,9 +131,12 @@ AS_IF([test x"$enable_distill" = x"yes"]
 #
 AC_CONFIG_FILES([
 	Makefile
-	src/Makefile
-	src/libsvnsup/Makefile
-	src/distill/Makefile
-	src/apply/Makefile
+	include/Makefile
+	include/svnsup/Makefile
+	lib/Makefile
+	lib/libsvnsup/Makefile
+	bin/Makefile
+	bin/apply/Makefile
+	bin/distill/Makefile
 ])
 AC_OUTPUT

Added: user/des/svnsup/include/Makefile.am
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -0,0 +1,3 @@
+# $Id$
+
+DISTILL_SUBDIR = svnsup

Added: user/des/svnsup/include/svnsup/Makefile.am
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -0,0 +1 @@
+# $Id$

Copied: user/des/svnsup/include/svnsup/svnsup.h (from r206003, user/des/svnsup/src/libsvnsup/svnsup.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/svnsup.h	Wed Mar 31 21:33:51 2010	(r206006, copy of r206003, user/des/svnsup/src/libsvnsup/svnsup.h)
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_H_INCLUDED
+#define SVNSUP_H_INCLUDED
+
+typedef enum svnsup_err {
+	SVNSUP_ERR_NONE,
+	SVNSUP_ERR_MEMORY,
+	SVNSUP_ERR_UNKNOWN,
+	SVNSUP_ERR_MAX,
+} svnsup_err_t;
+
+/*
+ * svnsup_delta.c
+ */
+typedef struct svnsup_delta *svnsup_delta_t;
+typedef struct svnsup_delta_file *svnsup_delta_file_t;
+
+int svnsup_create_delta(svnsup_delta_t *);
+int svnsup_close_delta(svnsup_delta_t);
+
+int svnsup_delta_root(svnsup_delta_t, const char *);
+int svnsup_delta_uuid(svnsup_delta_t, const char *);
+int svnsup_delta_path(svnsup_delta_t, const char *);
+int svnsup_delta_comment(svnsup_delta_t, const char *, ...);
+int svnsup_delta_meta(svnsup_delta_t, const char *, const char *, ...);
+int svnsup_delta_create_directory(svnsup_delta_t, const char *);
+int svnsup_delta_remove(svnsup_delta_t, const char *);
+int svnsup_delta_text(svnsup_delta_t, const char *, size_t,
+    unsigned int *);
+
+int svnsup_delta_create_file(svnsup_delta_t, svnsup_delta_file_t *,
+    const char *);
+int svnsup_delta_open_file(svnsup_delta_t, svnsup_delta_file_t *,
+    const char *);
+int svnsup_delta_file_checksum(svnsup_delta_file_t, const char *);
+int svnsup_delta_file_text(svnsup_delta_file_t, const char *, size_t,
+    unsigned int *);
+int svnsup_delta_file_copy(svnsup_delta_file_t, off_t, size_t);
+int svnsup_delta_file_repeat(svnsup_delta_file_t, off_t, size_t);
+int svnsup_delta_file_insert(svnsup_delta_file_t, unsigned int, off_t, size_t);
+int svnsup_delta_close_file(svnsup_delta_file_t, const char *);
+
+/*
+ * svnsup_string.c
+ */
+int svnsup_string_is_safe(const char *);
+int svnsup_buf_is_safe(const unsigned char *, size_t);
+char *svnsup_string_encode(const char *);
+char *svnsup_buf_encode(const unsigned char *, size_t);
+
+#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
+size_t svnsup_string_fencode(FILE *, const char *);
+size_t svnsup_buf_fencode(FILE *, const unsigned char *, size_t);
+#endif
+
+/*
+ * svnsup_base64.c
+ */
+size_t svnsup_base64_encode(char *, const unsigned char *, size_t);
+size_t svnsup_base64_decode(unsigned char *, const char *, size_t);
+#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
+size_t svnsup_base64_fencode(FILE *, const unsigned char *, size_t);
+/* no fdecode yet */
+#endif
+
+#endif

Added: user/des/svnsup/lib/Makefile.am
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/lib/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -0,0 +1,3 @@
+# $Id$
+
+SUBDIRS = libsvnsup

Modified: user/des/svnsup/lib/libsvnsup/Makefile.am
==============================================================================
--- user/des/svnsup/src/libsvnsup/Makefile.am	Wed Mar 31 21:12:27 2010	(r206003)
+++ user/des/svnsup/lib/libsvnsup/Makefile.am	Wed Mar 31 21:33:51 2010	(r206006)
@@ -9,5 +9,7 @@ libsvnsup_a_SOURCES = \
 	svnsup_string.c
 
 noinst_HEADERS = \
-	svnsup.h \
 	svnsup_md5.h
+
+libsvnsup_a_CPPFLAGS = \
+	-I$(top_srcdir)/include/svnsup

Modified: user/des/svnsup/lib/libsvnsup/svnsup_md5.c
==============================================================================
--- user/des/svnsup/src/libsvnsup/svnsup_md5.c	Wed Mar 31 21:12:27 2010	(r206003)
+++ user/des/svnsup/lib/libsvnsup/svnsup_md5.c	Wed Mar 31 21:33:51 2010	(r206006)
@@ -55,6 +55,7 @@ x2i(char x)
 		return (x - 'a');
 	}
 	assert(0);
+	return (0);
 }
 
 void

From owner-svn-src-user@FreeBSD.ORG  Wed Mar 31 22:11:19 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6025C1065743;
	Wed, 31 Mar 2010 22:11:19 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4D48F8FC08;
	Wed, 31 Mar 2010 22:11:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2VMBJ43037567;
	Wed, 31 Mar 2010 22:11:19 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2VMBJLh037552;
	Wed, 31 Mar 2010 22:11:19 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201003312211.o2VMBJLh037552@svn.freebsd.org>
From: Dag-Erling Smorgrav <des@FreeBSD.org>
Date: Wed, 31 Mar 2010 22:11:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206016 - in user/des/svnsup: bin/apply bin/distill
	include/svnsup lib/libsvnsup
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Mar 2010 22:11:19 -0000

Author: des
Date: Wed Mar 31 22:11:19 2010
New Revision: 206016
URL: http://svn.freebsd.org/changeset/base/206016

Log:
  More reorg

Added:
  user/des/svnsup/include/svnsup/base64.h   (contents, props changed)
  user/des/svnsup/include/svnsup/delta.h   (contents, props changed)
  user/des/svnsup/include/svnsup/md5.h
     - copied unchanged from r206006, user/des/svnsup/lib/libsvnsup/svnsup_md5.h
  user/des/svnsup/include/svnsup/string.h   (contents, props changed)
Deleted:
  user/des/svnsup/lib/libsvnsup/svnsup_md5.h
Modified:
  user/des/svnsup/bin/apply/Makefile.am
  user/des/svnsup/bin/distill/Makefile.am
  user/des/svnsup/bin/distill/distill.h
  user/des/svnsup/include/svnsup/Makefile.am
  user/des/svnsup/include/svnsup/svnsup.h
  user/des/svnsup/lib/libsvnsup/Makefile.am
  user/des/svnsup/lib/libsvnsup/svnsup_base64.c
  user/des/svnsup/lib/libsvnsup/svnsup_delta.c
  user/des/svnsup/lib/libsvnsup/svnsup_md5.c
  user/des/svnsup/lib/libsvnsup/svnsup_string.c

Modified: user/des/svnsup/bin/apply/Makefile.am
==============================================================================
--- user/des/svnsup/bin/apply/Makefile.am	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/bin/apply/Makefile.am	Wed Mar 31 22:11:19 2010	(r206016)
@@ -6,7 +6,7 @@ svnsup_apply_SOURCES = \
 	main.c
 
 svnsup_apply_CPPFLAGS = \
-	-I$(top_srcdir)/include/svnsup
+	-I$(top_srcdir)/include
 
 svnsup_apply_LDADD = \
         $(top_builddir)/lib/libsvnsup/libsvnsup.a

Modified: user/des/svnsup/bin/distill/Makefile.am
==============================================================================
--- user/des/svnsup/bin/distill/Makefile.am	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/bin/distill/Makefile.am	Wed Mar 31 22:11:19 2010	(r206016)
@@ -15,7 +15,7 @@ svnsup_distill_SOURCES = \
 	txdelta.c
 
 svnsup_distill_CPPFLAGS = \
-	-I$(top_srcdir)/include/svnsup \
+	-I$(top_srcdir)/include \
 	${APR_1_CFLAGS}
 
 svnsup_distill_LDADD = \

Modified: user/des/svnsup/bin/distill/distill.h
==============================================================================
--- user/des/svnsup/bin/distill/distill.h	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/bin/distill/distill.h	Wed Mar 31 22:11:19 2010	(r206016)
@@ -43,7 +43,7 @@
 #include <subversion-1/svn_path.h>
 #include <subversion-1/svn_ra.h>
 
-#include "svnsup.h"
+#include "svnsup/svnsup.h"
 
 extern int debug;
 extern int verbose;

Modified: user/des/svnsup/include/svnsup/Makefile.am
==============================================================================
--- user/des/svnsup/include/svnsup/Makefile.am	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/include/svnsup/Makefile.am	Wed Mar 31 22:11:19 2010	(r206016)
@@ -1 +1,8 @@
 # $Id$
+
+noinst_HEADERS = \
+	base64.h \
+	delta.h \
+	md5.h \
+	string.h \
+	svnsup.h

Added: user/des/svnsup/include/svnsup/base64.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/base64.h	Wed Mar 31 22:11:19 2010	(r206016)
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_BASE64_H_INCLUDED
+#define SVNSUP_BASE64_H_INCLUDED
+
+size_t svnsup_base64_encode(char *, const unsigned char *, size_t);
+size_t svnsup_base64_decode(unsigned char *, const char *, size_t);
+#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
+size_t svnsup_base64_fencode(FILE *, const unsigned char *, size_t);
+/* no fdecode yet */
+#endif
+
+#endif

Added: user/des/svnsup/include/svnsup/delta.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/delta.h	Wed Mar 31 22:11:19 2010	(r206016)
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_DELTA_H_INCLUDED
+#define SVNSUP_DELTA_H_INCLUDED
+
+typedef struct svnsup_delta *svnsup_delta_t;
+typedef struct svnsup_delta_file *svnsup_delta_file_t;
+
+int svnsup_create_delta(svnsup_delta_t *);
+int svnsup_close_delta(svnsup_delta_t);
+
+int svnsup_delta_root(svnsup_delta_t, const char *);
+int svnsup_delta_uuid(svnsup_delta_t, const char *);
+int svnsup_delta_path(svnsup_delta_t, const char *);
+int svnsup_delta_comment(svnsup_delta_t, const char *, ...);
+int svnsup_delta_meta(svnsup_delta_t, const char *, const char *, ...);
+int svnsup_delta_create_directory(svnsup_delta_t, const char *);
+int svnsup_delta_remove(svnsup_delta_t, const char *);
+int svnsup_delta_text(svnsup_delta_t, const char *, size_t,
+    unsigned int *);
+
+int svnsup_delta_create_file(svnsup_delta_t, svnsup_delta_file_t *,
+    const char *);
+int svnsup_delta_open_file(svnsup_delta_t, svnsup_delta_file_t *,
+    const char *);
+int svnsup_delta_file_checksum(svnsup_delta_file_t, const char *);
+int svnsup_delta_file_text(svnsup_delta_file_t, const char *, size_t,
+    unsigned int *);
+int svnsup_delta_file_copy(svnsup_delta_file_t, off_t, size_t);
+int svnsup_delta_file_repeat(svnsup_delta_file_t, off_t, size_t);
+int svnsup_delta_file_insert(svnsup_delta_file_t, unsigned int, off_t, size_t);
+int svnsup_delta_close_file(svnsup_delta_file_t, const char *);
+
+#endif

Copied: user/des/svnsup/include/svnsup/md5.h (from r206006, user/des/svnsup/lib/libsvnsup/svnsup_md5.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/md5.h	Wed Mar 31 22:11:19 2010	(r206016, copy of r206006, user/des/svnsup/lib/libsvnsup/svnsup_md5.h)
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_MD5_H_INCLUDED
+#define SVNSUP_MD5_H_INCLUDED
+
+typedef struct svnsup_md5 {
+	unsigned char md5[16];
+} svnsup_md5;
+
+void md5s2b(const char *, svnsup_md5 *);
+void md5b2s(const svnsup_md5 *, char *);
+
+#endif

Added: user/des/svnsup/include/svnsup/string.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/des/svnsup/include/svnsup/string.h	Wed Mar 31 22:11:19 2010	(r206016)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2009 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef SVNSUP_STRING_H_INCLUDED
+#define SVNSUP_STRING_H_INCLUDED
+
+int svnsup_string_is_safe(const char *);
+int svnsup_buf_is_safe(const unsigned char *, size_t);
+char *svnsup_string_encode(const char *);
+char *svnsup_buf_encode(const unsigned char *, size_t);
+
+#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
+size_t svnsup_string_fencode(FILE *, const char *);
+size_t svnsup_buf_fencode(FILE *, const unsigned char *, size_t);
+#endif
+
+#endif

Modified: user/des/svnsup/include/svnsup/svnsup.h
==============================================================================
--- user/des/svnsup/include/svnsup/svnsup.h	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/include/svnsup/svnsup.h	Wed Mar 31 22:11:19 2010	(r206016)
@@ -27,68 +27,13 @@
  * $Id$
  */
 
-#ifndef SVNSUP_H_INCLUDED
-#define SVNSUP_H_INCLUDED
+#ifndef SVNSUP_SVNSUP_H_INCLUDED
+#define SVNSUP_SVNSUP_H_INCLUDED
 
-typedef enum svnsup_err {
-	SVNSUP_ERR_NONE,
-	SVNSUP_ERR_MEMORY,
-	SVNSUP_ERR_UNKNOWN,
-	SVNSUP_ERR_MAX,
-} svnsup_err_t;
-
-/*
- * svnsup_delta.c
- */
-typedef struct svnsup_delta *svnsup_delta_t;
-typedef struct svnsup_delta_file *svnsup_delta_file_t;
-
-int svnsup_create_delta(svnsup_delta_t *);
-int svnsup_close_delta(svnsup_delta_t);
-
-int svnsup_delta_root(svnsup_delta_t, const char *);
-int svnsup_delta_uuid(svnsup_delta_t, const char *);
-int svnsup_delta_path(svnsup_delta_t, const char *);
-int svnsup_delta_comment(svnsup_delta_t, const char *, ...);
-int svnsup_delta_meta(svnsup_delta_t, const char *, const char *, ...);
-int svnsup_delta_create_directory(svnsup_delta_t, const char *);
-int svnsup_delta_remove(svnsup_delta_t, const char *);
-int svnsup_delta_text(svnsup_delta_t, const char *, size_t,
-    unsigned int *);
-
-int svnsup_delta_create_file(svnsup_delta_t, svnsup_delta_file_t *,
-    const char *);
-int svnsup_delta_open_file(svnsup_delta_t, svnsup_delta_file_t *,
-    const char *);
-int svnsup_delta_file_checksum(svnsup_delta_file_t, const char *);
-int svnsup_delta_file_text(svnsup_delta_file_t, const char *, size_t,
-    unsigned int *);
-int svnsup_delta_file_copy(svnsup_delta_file_t, off_t, size_t);
-int svnsup_delta_file_repeat(svnsup_delta_file_t, off_t, size_t);
-int svnsup_delta_file_insert(svnsup_delta_file_t, unsigned int, off_t, size_t);
-int svnsup_delta_close_file(svnsup_delta_file_t, const char *);
-
-/*
- * svnsup_string.c
- */
-int svnsup_string_is_safe(const char *);
-int svnsup_buf_is_safe(const unsigned char *, size_t);
-char *svnsup_string_encode(const char *);
-char *svnsup_buf_encode(const unsigned char *, size_t);
-
-#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
-size_t svnsup_string_fencode(FILE *, const char *);
-size_t svnsup_buf_fencode(FILE *, const unsigned char *, size_t);
-#endif
-
-/*
- * svnsup_base64.c
- */
-size_t svnsup_base64_encode(char *, const unsigned char *, size_t);
-size_t svnsup_base64_decode(unsigned char *, const char *, size_t);
-#ifdef FOPEN_MAX /* defined by stdio.h, cf. IEEE 1003.1 */
-size_t svnsup_base64_fencode(FILE *, const unsigned char *, size_t);
-/* no fdecode yet */
-#endif
+#include <svnsup/base64.h>
+#include <svnsup/delta.h>
+#include <svnsup/error.h>
+#include <svnsup/md5.h>
+#include <svnsup/string.h>
 
 #endif

Modified: user/des/svnsup/lib/libsvnsup/Makefile.am
==============================================================================
--- user/des/svnsup/lib/libsvnsup/Makefile.am	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/lib/libsvnsup/Makefile.am	Wed Mar 31 22:11:19 2010	(r206016)
@@ -8,8 +8,5 @@ libsvnsup_a_SOURCES = \
 	svnsup_md5.c \
 	svnsup_string.c
 
-noinst_HEADERS = \
-	svnsup_md5.h
-
 libsvnsup_a_CPPFLAGS = \
-	-I$(top_srcdir)/include/svnsup
+	-I$(top_srcdir)/include

Modified: user/des/svnsup/lib/libsvnsup/svnsup_base64.c
==============================================================================
--- user/des/svnsup/lib/libsvnsup/svnsup_base64.c	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/lib/libsvnsup/svnsup_base64.c	Wed Mar 31 22:11:19 2010	(r206016)
@@ -36,7 +36,7 @@
 #include <assert.h>
 #include <stdio.h>
 
-#include "svnsup.h"
+#include <svnsup/base64.h>
 
 static const char b64enc[64] = {
 	'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',

Modified: user/des/svnsup/lib/libsvnsup/svnsup_delta.c
==============================================================================
--- user/des/svnsup/lib/libsvnsup/svnsup_delta.c	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/lib/libsvnsup/svnsup_delta.c	Wed Mar 31 22:11:19 2010	(r206016)
@@ -39,7 +39,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "svnsup.h"
+#include <svnsup/delta.h>
+#include <svnsup/error.h>
+#include <svnsup/string.h>
 
 // XXX missing I/O error handling
 

Modified: user/des/svnsup/lib/libsvnsup/svnsup_md5.c
==============================================================================
--- user/des/svnsup/lib/libsvnsup/svnsup_md5.c	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/lib/libsvnsup/svnsup_md5.c	Wed Mar 31 22:11:19 2010	(r206016)
@@ -36,7 +36,7 @@
 #include <assert.h>
 #include <ctype.h>
 
-#include "svnsup_md5.h"
+#include <svnsup/md5.h>
 
 // XXX error handling and documentation
 

Modified: user/des/svnsup/lib/libsvnsup/svnsup_string.c
==============================================================================
--- user/des/svnsup/lib/libsvnsup/svnsup_string.c	Wed Mar 31 22:11:06 2010	(r206015)
+++ user/des/svnsup/lib/libsvnsup/svnsup_string.c	Wed Mar 31 22:11:19 2010	(r206016)
@@ -38,7 +38,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "svnsup.h"
+#include <svnsup/base64.h>
+#include <svnsup/string.h>
 
 /*
  * Safe to send as is

From owner-svn-src-user@FreeBSD.ORG  Thu Apr  1 23:22:17 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C8BD6106564A;
	Thu,  1 Apr 2010 23:22:17 +0000 (UTC)
	(envelope-from kmacy@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B8BBC8FC12;
	Thu,  1 Apr 2010 23:22:17 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o31NMH9L076496;
	Thu, 1 Apr 2010 23:22:17 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o31NMHZs076494;
	Thu, 1 Apr 2010 23:22:17 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201004012322.o31NMHZs076494@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Thu, 1 Apr 2010 23:22:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206059 - user/kmacy/head_page_lock/sys/vm
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 01 Apr 2010 23:22:17 -0000

Author: kmacy
Date: Thu Apr  1 23:22:17 2010
New Revision: 206059
URL: http://svn.freebsd.org/changeset/base/206059

Log:
  fix notowned assert

Modified:
  user/kmacy/head_page_lock/sys/vm/vm_page.h

Modified: user/kmacy/head_page_lock/sys/vm/vm_page.h
==============================================================================
--- user/kmacy/head_page_lock/sys/vm/vm_page.h	Thu Apr  1 22:52:09 2010	(r206058)
+++ user/kmacy/head_page_lock/sys/vm/vm_page.h	Thu Apr  1 23:22:17 2010	(r206059)
@@ -275,7 +275,7 @@ extern struct vpglocks vm_page_queue_loc
 
 #ifdef VM_PAGE_LOCK
 #define	vm_page_lockptr(m)		pmap_page_lockptr(m)
-#define	vm_page_lock_queues_assert_notowned()   mtx_assert(vm_page_lockptr((m)), MA_NOTOWNED)
+#define	vm_page_lock_queues_assert_notowned()   mtx_assert(vm_page_queue_mtx, MA_NOTOWNED)
 #else
 #define	vm_page_lockptr(m)		(&vm_page_queue_mtx)
 #define	vm_page_lock_queues_assert_notowned()   

From owner-svn-src-user@FreeBSD.ORG  Thu Apr  1 23:35:35 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B3BC2106564A;
	Thu,  1 Apr 2010 23:35:35 +0000 (UTC)
	(envelope-from kmacy@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A3A908FC08;
	Thu,  1 Apr 2010 23:35:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o31NZZpY079744;
	Thu, 1 Apr 2010 23:35:35 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o31NZZJr079741;
	Thu, 1 Apr 2010 23:35:35 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201004012335.o31NZZJr079741@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Thu, 1 Apr 2010 23:35:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206060 - user/kmacy/head_page_lock/sys/vm
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 01 Apr 2010 23:35:35 -0000

Author: kmacy
Date: Thu Apr  1 23:35:35 2010
New Revision: 206060
URL: http://svn.freebsd.org/changeset/base/206060

Log:
  fix previous fix
  fix style

Modified:
  user/kmacy/head_page_lock/sys/vm/vm_page.c
  user/kmacy/head_page_lock/sys/vm/vm_page.h

Modified: user/kmacy/head_page_lock/sys/vm/vm_page.c
==============================================================================
--- user/kmacy/head_page_lock/sys/vm/vm_page.c	Thu Apr  1 23:22:17 2010	(r206059)
+++ user/kmacy/head_page_lock/sys/vm/vm_page.c	Thu Apr  1 23:35:35 2010	(r206060)
@@ -1318,6 +1318,7 @@ vm_pageq_remove_locked(vm_page_t m)
 void
 vm_pageq_remove(vm_page_t m)
 {
+
 	vm_page_lock_queues_assert_notowned();
 	_vm_pageq_remove(m, FALSE);
 }

Modified: user/kmacy/head_page_lock/sys/vm/vm_page.h
==============================================================================
--- user/kmacy/head_page_lock/sys/vm/vm_page.h	Thu Apr  1 23:22:17 2010	(r206059)
+++ user/kmacy/head_page_lock/sys/vm/vm_page.h	Thu Apr  1 23:35:35 2010	(r206060)
@@ -275,7 +275,7 @@ extern struct vpglocks vm_page_queue_loc
 
 #ifdef VM_PAGE_LOCK
 #define	vm_page_lockptr(m)		pmap_page_lockptr(m)
-#define	vm_page_lock_queues_assert_notowned()   mtx_assert(vm_page_queue_mtx, MA_NOTOWNED)
+#define	vm_page_lock_queues_assert_notowned()   mtx_assert(&vm_page_queue_mtx, MA_NOTOWNED)
 #else
 #define	vm_page_lockptr(m)		(&vm_page_queue_mtx)
 #define	vm_page_lock_queues_assert_notowned()   

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 02:17:16 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 19B3B106566B;
	Fri,  2 Apr 2010 02:17:16 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0868D8FC12;
	Fri,  2 Apr 2010 02:17:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o322HFJA017572;
	Fri, 2 Apr 2010 02:17:15 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o322HFSf017568;
	Fri, 2 Apr 2010 02:17:15 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020217.o322HFSf017568@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 02:17:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206062 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 02:17:16 -0000

Author: jmallett
Date: Fri Apr  2 02:17:15 2010
New Revision: 206062
URL: http://svn.freebsd.org/changeset/base/206062

Log:
  Go back to 64-bit PTEs on N64.  Nothing much has been updated for this but some
  format strings.
  
  Ifdef out some code that's only used by the recursive mappings that are used to
  map >=512mb pages in the page table on O32 and N32.

Modified:
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/trap.c

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Fri Apr  2 01:53:48 2010	(r206061)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Fri Apr  2 02:17:15 2010	(r206062)
@@ -83,7 +83,7 @@ struct tlb {
 	int	tlb_lo1;
 };
 
-typedef int32_t pt_entry_t;
+typedef unsigned long pt_entry_t;
 typedef pt_entry_t *pd_entry_t;
 
 #define	PDESIZE		sizeof(pd_entry_t)	/* for assembly files */

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Fri Apr  2 01:53:48 2010	(r206061)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Fri Apr  2 02:17:15 2010	(r206062)
@@ -974,11 +974,14 @@ pmap_unmap_fpage(vm_paddr_t pa, struct f
 static int
 _pmap_unwire_pte_hold(pmap_t pmap, vm_page_t m)
 {
+#if !defined(__mips_n64)
 	vm_offset_t pteva;
+#endif
 
 	/*
 	 * unmap the page table page
 	 */
+#if !defined(__mips_n64)
 	pteva = (vm_offset_t)pmap->pm_segtab[m->pindex];
 	if (pteva >= VM_MIN_KERNEL_ADDRESS) {
 		pmap_kremove(pteva);
@@ -988,6 +991,7 @@ _pmap_unwire_pte_hold(pmap_t pmap, vm_pa
 		    ("_pmap_unwire_pte_hold: 0x%0lx is not in kseg0",
 		    (long)pteva));
 	}
+#endif
 
 	pmap->pm_segtab[m->pindex] = 0;
 	--pmap->pm_stats.resident_count;
@@ -1285,6 +1289,7 @@ pmap_release(pmap_t pmap)
 	ptdva = (vm_offset_t)pmap->pm_segtab;
 	ptdpg = PHYS_TO_VM_PAGE(vtophys(ptdva));
 
+#if !defined(__mips_n64)
 	if (ptdva >= VM_MIN_KERNEL_ADDRESS) {
 		pmap_kremove(ptdva);
 		kmem_free(kernel_map, ptdva, PAGE_SIZE);
@@ -1292,6 +1297,7 @@ pmap_release(pmap_t pmap)
 		KASSERT(MIPS_IS_KSEG0_ADDR(ptdva),
 		    ("pmap_release: 0x%0lx is not in kseg0", (long)ptdva));
 	}
+#endif
 
 	ptdpg->wire_count--;
 	atomic_subtract_int(&cnt.v_wire_count, 1);
@@ -2024,7 +2030,7 @@ validate:
 			if (origpte & PTE_M) {
 				KASSERT((origpte & PTE_RW),
 				    ("pmap_enter: modified page not writable:"
-				    " va: %p, pte: 0x%x", (void *)va, origpte));
+				    " va: %p, pte: 0x%lx", (void *)va, origpte));
 				if (page_is_managed(opa))
 					vm_page_dirty(om);
 			}
@@ -2718,7 +2724,7 @@ pmap_remove_pages(pmap_t pmap)
 		m = PHYS_TO_VM_PAGE(mips_tlbpfn_to_paddr(tpte));
 
 		KASSERT(m < &vm_page_array[vm_page_array_size],
-		    ("pmap_remove_pages: bad tpte %x", tpte));
+		    ("pmap_remove_pages: bad tpte %lx", tpte));
 
 		pv->pv_pmap->pm_stats.resident_count--;
 

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Fri Apr  2 01:53:48 2010	(r206061)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Fri Apr  2 02:17:15 2010	(r206062)
@@ -1349,7 +1349,7 @@ log_illegal_instruction(const char *msg,
 	if (!(pc & 3) &&
 	    useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) {
 		/* dump page table entry for faulting instruction */
-		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#x\n",
+		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#lx\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 
 		addr = (unsigned int *)(intptr_t)pc;
@@ -1358,7 +1358,7 @@ log_illegal_instruction(const char *msg,
 		log(LOG_ERR, "%08x %08x %08x %08x\n",
 		    addr[0], addr[1], addr[2], addr[3]);
 	} else {
-		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#x\n",
+		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#lx\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 	}
 }
@@ -1413,7 +1413,7 @@ log_bad_page_fault(char *msg, struct tra
 	    (trap_type != T_BUS_ERR_IFETCH) &&
 	    useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) {
 		/* dump page table entry for faulting instruction */
-		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#x\n",
+		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#lx\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 
 		addr = (unsigned int *)(intptr_t)pc;
@@ -1422,7 +1422,7 @@ log_bad_page_fault(char *msg, struct tra
 		log(LOG_ERR, "%08x %08x %08x %08x\n",
 		    addr[0], addr[1], addr[2], addr[3]);
 	} else {
-		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#x\n",
+		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#lx\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 	}
 	/*	panic("Bad trap");*/

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 04:42:03 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 87EEE106566B;
	Fri,  2 Apr 2010 04:42:03 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DCF98FC12;
	Fri,  2 Apr 2010 04:42:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o324g3q4050080;
	Fri, 2 Apr 2010 04:42:03 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o324g3Vj050079;
	Fri, 2 Apr 2010 04:42:03 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201004020442.o324g3Vj050079@svn.freebsd.org>
From: Warner Losh <imp@FreeBSD.org>
Date: Fri, 2 Apr 2010 04:42:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206065 - user/imp/nopriv
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 04:42:03 -0000

Author: imp
Date: Fri Apr  2 04:42:02 2010
New Revision: 206065
URL: http://svn.freebsd.org/changeset/base/206065

Log:
  port of netbsd nopriv install branch

Added:
     - copied from r206064, head/
Directory Properties:
  user/imp/nopriv/   (props changed)

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 05:14:58 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0C95E106566C;
	Fri,  2 Apr 2010 05:14:58 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EEFD58FC12;
	Fri,  2 Apr 2010 05:14:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o325Ev6M057561;
	Fri, 2 Apr 2010 05:14:57 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o325Ev7f057558;
	Fri, 2 Apr 2010 05:14:57 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201004020514.o325Ev7f057558@svn.freebsd.org>
From: Warner Losh <imp@FreeBSD.org>
Date: Fri, 2 Apr 2010 05:14:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206070 - user/imp/nopriv/usr.bin/xinstall
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 05:14:58 -0000

Author: imp
Date: Fri Apr  2 05:14:57 2010
New Revision: 206070
URL: http://svn.freebsd.org/changeset/base/206070

Log:
  First cut at merging some features from NetBSD's install:
  o add ability to generate mtree meta files based on what's installed.
  o add ability to set destdir, so the metadata in the above file can filter that
  o add some rudamentary support for generating digests of the files
  
  there's still some problems with this code (sizes that are generated
  seem to be wrong) and there's some additional pieces that are needed
  from NetBSD's install as well as hacks to the build system.  We're
  installing about 17k files now.  10k are recorded in the metadata
  file, while 7k aren't.  The vast majority of which are links of some
  flavor or another.
  
  Pieces to merge still: nopriv install and support for using install to
  manage links rather than using ln.
  
  Also, ee installs its nls files to the wrong place, which will need to
  be fixed.  The metadata shows this.

Modified:
  user/imp/nopriv/usr.bin/xinstall/Makefile
  user/imp/nopriv/usr.bin/xinstall/xinstall.c

Modified: user/imp/nopriv/usr.bin/xinstall/Makefile
==============================================================================
--- user/imp/nopriv/usr.bin/xinstall/Makefile	Fri Apr  2 05:12:46 2010	(r206069)
+++ user/imp/nopriv/usr.bin/xinstall/Makefile	Fri Apr  2 05:14:57 2010	(r206070)
@@ -5,4 +5,9 @@ PROG=		xinstall
 PROGNAME=	install
 MAN=		install.1
 
+.PATH:		${.CURDIR}/../../usr.sbin/mtree
+CFLAGS+=	-I${.CURDIR}/../../usr.sbin/mtree
+LDADD+=		-lmd
+DPADD+=		${LIBMD}
+
 .include <bsd.prog.mk>

Modified: user/imp/nopriv/usr.bin/xinstall/xinstall.c
==============================================================================
--- user/imp/nopriv/usr.bin/xinstall/xinstall.c	Fri Apr  2 05:12:46 2010	(r206069)
+++ user/imp/nopriv/usr.bin/xinstall/xinstall.c	Fri Apr  2 05:14:57 2010	(r206070)
@@ -64,6 +64,16 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 #include <sysexits.h>
 #include <unistd.h>
+#include <vis.h>
+
+#include <md5.h>
+#if 0
+#include <rmd160.h>
+#include <sha1.h>
+#include <sha2.h>
+#endif
+
+#include "mtree.h"
 
 /* Bootstrap aid - this doesn't exist in most older releases */
 #ifndef MAP_FAILED
@@ -82,11 +92,29 @@ struct group *gp;
 gid_t gid;
 uid_t uid;
 int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
+char	*group, *owner, *fflags, *tags;
 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 const char *suffix = BACKUP_SUFFIX;
+const char *metafile = NULL;
+FILE *metafp;
+char *destdir;
+
+enum {
+        DIGEST_NONE = 0,
+        DIGEST_MD5,
+#if 0
+        DIGEST_RMD160,
+        DIGEST_SHA1,
+        DIGEST_SHA256,
+        DIGEST_SHA384,
+        DIGEST_SHA512,
+#endif
+} digesttype = DIGEST_NONE;
+char    *digest;
+
 
 static int	compare(int, const char *, size_t, int, const char *, size_t);
-static void	copy(int, const char *, int, const char *, off_t);
+static char    *copy(int, const char *, int, const char *, off_t);
 static int	create_newfile(const char *, int, struct stat *);
 static int	create_tempfile(const char *, char *, size_t);
 static void	install(const char *, const char *, u_long, u_int);
@@ -95,6 +123,8 @@ static u_long	numeric_id(const char *, c
 static void	strip(const char *);
 static int	trymmap(int);
 static void	usage(void);
+static void	metadata_log(const char *, const char *, struct timeval *,
+	            const char *, const char *, off_t);
 
 int
 main(int argc, char *argv[])
@@ -104,13 +134,15 @@ main(int argc, char *argv[])
 	u_long fset;
 	int ch, no_target;
 	u_int iflags;
-	char *flags;
-	const char *group, *owner, *to_name;
+	const char *to_name;
 
 	iflags = 0;
 	group = owner = NULL;
-	while ((ch = getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1)
+	while ((ch = getopt(argc, argv, "a:B:bCcdf:g:Mm:o:pSsv")) != -1)
 		switch((char)ch) {
+		case 'a':
+			metafile = optarg;
+			break;
 		case 'B':
 			suffix = optarg;
 			/* FALLTHROUGH */
@@ -127,14 +159,17 @@ main(int argc, char *argv[])
 			dodir = 1;
 			break;
 		case 'f':
-			flags = optarg;
-			if (strtofflags(&flags, &fset, NULL))
-				errx(EX_USAGE, "%s: invalid flag", flags);
+			fflags = optarg;
+			if (strtofflags(&fflags, &fset, NULL))
+				errx(EX_USAGE, "%s: invalid flag", fflags);
 			iflags |= SETFLAGS;
 			break;
 		case 'g':
 			group = optarg;
 			break;
+		case 'h':
+			digest = optarg;
+			break;
 		case 'M':
 			nommap = 1;
 			break;
@@ -160,6 +195,9 @@ main(int argc, char *argv[])
 		case 'v':
 			verbose = 1;
 			break;
+		case 'T':
+			tags = optarg;
+			break;
 		case '?':
 		default:
 			usage();
@@ -182,6 +220,30 @@ main(int argc, char *argv[])
 	if (argc == 0 || (argc == 1 && !dodir))
 		usage();
 
+        if (digest) {
+                if (0) {
+                } else if (strcmp(digest, "none") == 0) {
+                        digesttype = DIGEST_NONE;
+                } else if (strcmp(digest, "md5") == 0) {
+                        digesttype = DIGEST_MD5;
+#if 0
+                } else if (strcmp(digest, "rmd160") == 0) {
+                        digesttype = DIGEST_RMD160;
+                } else if (strcmp(digest, "sha1") == 0) {
+                        digesttype = DIGEST_SHA1;
+                } else if (strcmp(digest, "sha256") == 0) {
+                        digesttype = DIGEST_SHA256;
+                } else if (strcmp(digest, "sha384") == 0) {
+                        digesttype = DIGEST_SHA384;
+                } else if (strcmp(digest, "sha512") == 0) {
+                        digesttype = DIGEST_SHA512;
+                } else {
+#endif
+                        warnx("unknown digest `%s'", digest);
+                        usage();
+                }
+        }
+                                
 	/* need to make a temp copy so we can compare stripped version */
 	if (docompare && dostrip)
 		safecopy = 1;
@@ -203,6 +265,12 @@ main(int argc, char *argv[])
 	} else
 		uid = (uid_t)-1;
 
+	if (metafile) {
+		if ((metafp = fopen(metafile, "a")) == NULL)
+			warn("open %s", metafile);
+	} else
+		digesttype = DIGEST_NONE;
+
 	if (dodir) {
 		for (; *argv != NULL; ++argv)
 			install_dir(*argv);
@@ -277,11 +345,20 @@ install(const char *from_name, const cha
 	int devnull, files_match, from_fd, serrno, target;
 	int tempcopy, temp_fd, to_fd;
 	char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN];
+	char *digestresult = NULL;
+	struct timeval	tv[2];
+	off_t		size;
 
 	files_match = 0;
 	from_fd = -1;
 	to_fd = -1;
 
+	if (stat(from_name, &from_sb))
+		err(1, "%s: stat", from_name);
+	size = from_sb.st_size;
+	TIMESPEC_TO_TIMEVAL(&tv[0], &from_sb.st_atimespec);
+	TIMESPEC_TO_TIMEVAL(&tv[1], &from_sb.st_mtimespec);
+
 	/* If try to install NULL file to a directory, fails. */
 	if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) {
 		if (stat(from_name, &from_sb))
@@ -348,7 +425,7 @@ install(const char *from_name, const cha
 				    from_name, to_name);
 		}
 		if (!devnull)
-			copy(from_fd, from_name, to_fd,
+			digestresult = copy(from_fd, from_name, to_fd,
 			     tempcopy ? tempfile : to_name, from_sb.st_size);
 	}
 
@@ -514,6 +591,8 @@ install(const char *from_name, const cha
 		}
 	}
 
+	metadata_log(to_name, "file", /* tv */NULL, NULL, digestresult, size);
+	free(digestresult);
 	(void)close(to_fd);
 	if (!devnull)
 		(void)close(from_fd);
@@ -650,7 +729,7 @@ create_newfile(const char *path, int tar
  * copy --
  *	copy from one file to another
  */
-static void
+static char *
 copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
     off_t size)
 {
@@ -658,6 +737,42 @@ copy(int from_fd, const char *from_name,
 	int serrno;
 	char *p, buf[MAXBSIZE];
 	int done_copy;
+	MD5_CTX		ctxMD5;
+#if 0
+	RMD160_CTX	ctxRMD160;
+	SHA1_CTX	ctxSHA1;
+	SHA256_CTX	ctxSHA256;
+	SHA384_CTX	ctxSHA384;
+	SHA512_CTX	ctxSHA512;
+#endif
+
+	switch (digesttype) {
+	case DIGEST_MD5:
+		MD5Init(&ctxMD5);
+		break;
+#if 0
+	case DIGEST_RMD160:
+		RMD160Init(&ctxRMD160);
+		break;
+	case DIGEST_SHA1:
+		SHA1Init(&ctxSHA1);
+		break;
+	case DIGEST_SHA256:
+		SHA256_Init(&ctxSHA256);
+		break;
+	case DIGEST_SHA384:
+		SHA384_Init(&ctxSHA384);
+		break;
+	case DIGEST_SHA512:
+		SHA512_Init(&ctxSHA512);
+		break;
+#endif
+	case DIGEST_NONE:
+		if (to_fd < 0)
+			return NULL; /* no need to do anything */
+	default:
+		break;
+	}
 
 	/* Rewind file descriptors. */
 	if (lseek(from_fd, (off_t)0, SEEK_SET) == (off_t)-1)
@@ -680,6 +795,30 @@ copy(int from_fd, const char *from_name,
 			errno = nw > 0 ? EIO : serrno;
 			err(EX_OSERR, "%s", to_name);
 		}
+		switch (digesttype) {
+		case DIGEST_MD5:
+			MD5Update(&ctxMD5, p, size);
+			break;
+#if 0
+		case DIGEST_RMD160:
+			RMD160Update(&ctxRMD160, p, size);
+			break;
+		case DIGEST_SHA1:
+			SHA1Update(&ctxSHA1, p, size);
+			break;
+		case DIGEST_SHA256:
+			SHA256_Update(&ctxSHA256, p, size);
+			break;
+		case DIGEST_SHA384:
+			SHA384_Update(&ctxSHA384, p, size);
+			break;
+		case DIGEST_SHA512:
+			SHA512_Update(&ctxSHA512, p, size);
+			break;
+#endif
+		default:
+			break;
+		}
 		done_copy = 1;
 	}
 	if (!done_copy) {
@@ -690,6 +829,30 @@ copy(int from_fd, const char *from_name,
 				errno = nw > 0 ? EIO : serrno;
 				err(EX_OSERR, "%s", to_name);
 			}
+		switch (digesttype) {
+		case DIGEST_MD5:
+			MD5Update(&ctxMD5, buf, nr);
+			break;
+#if 0
+		case DIGEST_RMD160:
+			RMD160Update(&ctxRMD160, buf, nr);
+			break;
+		case DIGEST_SHA1:
+			SHA1Update(&ctxSHA1, buf, nr);
+			break;
+		case DIGEST_SHA256:
+			SHA256_Update(&ctxSHA256, buf, nr);
+			break;
+		case DIGEST_SHA384:
+			SHA384_Update(&ctxSHA384, buf, nr);
+			break;
+		case DIGEST_SHA512:
+			SHA512_Update(&ctxSHA512, buf, nr);
+			break;
+#endif
+		default:
+			break;
+		}
 		if (nr != 0) {
 			serrno = errno;
 			(void)unlink(to_name);
@@ -697,6 +860,24 @@ copy(int from_fd, const char *from_name,
 			err(EX_OSERR, "%s", from_name);
 		}
 	}
+	switch (digesttype) {
+	case DIGEST_MD5:
+		return MD5End(&ctxMD5, NULL);
+#if 0
+	case DIGEST_RMD160:
+		return RMD160End(&ctxRMD160, NULL);
+	case DIGEST_SHA1:
+		return SHA1End(&ctxSHA1, NULL);
+	case DIGEST_SHA256:
+		return SHA256_End(&ctxSHA256, NULL);
+	case DIGEST_SHA384:
+		return SHA384_End(&ctxSHA384, NULL);
+	case DIGEST_SHA512:
+		return SHA512_End(&ctxSHA512, NULL);
+#endif
+	default:
+		return NULL;
+	}
 }
 
 /*
@@ -804,3 +985,91 @@ trymmap(int fd)
 #endif
 	return (0);
 }
+
+/*
+ * metadata_log --
+ *	if metafp is not NULL, output mtree(8) full path name and settings to
+ *	metafp, to allow permissions to be set correctly by other tools,
+ *	or to allow integrity checks to be performed.
+ */
+static void
+metadata_log(const char *path, const char *type, struct timeval *tv,
+	const char *slink, const char *digestresult, off_t size)
+{
+#if 0
+	static const char	extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
+#endif
+	const char	*p;
+	char		*buf;
+	size_t		destlen;
+	struct flock	metalog_lock;
+
+	if (!metafp)	
+		return;
+	buf = (char *)malloc(4 * strlen(path) + 1);	/* buf for strsvis(3) */
+	if (buf == NULL) {
+		warnx("%s", strerror(ENOMEM));
+		return;
+	}
+							/* lock log file */
+	metalog_lock.l_start = 0;
+	metalog_lock.l_len = 0;
+	metalog_lock.l_whence = SEEK_SET;
+	metalog_lock.l_type = F_WRLCK;
+	if (fcntl(fileno(metafp), F_SETLKW, &metalog_lock) == -1) {
+		warn("can't lock %s", metafile);
+		free(buf);
+		return;
+	}
+
+	p = path;					/* remove destdir */
+	if (destdir) {
+		destlen = strlen(destdir);
+		if (strncmp(p, destdir, destlen) == 0 &&
+		    (p[destlen] == '/' || p[destlen] == '\0'))
+			p += destlen;
+	}
+	while (*p && *p == '/')				/* remove leading /s */
+		p++;
+#if 0
+	/* Need to import this to do things totally right */
+	strsvis(buf, p, VIS_CSTYLE, extra);		/* encode name */
+#else
+	strvis(buf, p, VIS_CSTYLE);		/* encode name */
+#endif
+	p = buf;
+							/* print details */
+	fprintf(metafp, ".%s%s type=%s", *p ? "/" : "", p, type);
+	if (owner)
+		fprintf(metafp, " uname=%s", owner);
+	if (group)
+		fprintf(metafp, " gname=%s", group);
+	fprintf(metafp, " mode=%#o", mode);
+	if (slink) {
+#if 0
+		strsvis(buf, slink, VIS_CSTYLE, extra);	/* encode link */
+#else
+		strvis(buf, slink, VIS_CSTYLE);	/* encode link */
+#endif
+		fprintf(metafp, " link=%s", buf);
+	}
+	if (*type == 'f') /* type=file */
+		fprintf(metafp, " size=%lld", (long long)size);
+	if (tv != NULL && dopreserve)
+		fprintf(metafp, " time=%lld.%ld",
+			(long long)tv[1].tv_sec, (long)tv[1].tv_usec);
+	if (digestresult && digest)
+		fprintf(metafp, " %s=%s", digest, digestresult);
+	if (fflags)
+		fprintf(metafp, " flags=%s", fflags);
+	if (tags)
+		fprintf(metafp, " tags=%s", tags);
+	fputc('\n', metafp);
+	fflush(metafp);					/* flush output */
+							/* unlock log file */
+	metalog_lock.l_type = F_UNLCK;
+	if (fcntl(fileno(metafp), F_SETLKW, &metalog_lock) == -1) {
+		warn("can't unlock %s", metafile);
+	}
+	free(buf);
+}

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 05:21:45 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B78A21065741;
	Fri,  2 Apr 2010 05:21:45 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A62118FC15;
	Fri,  2 Apr 2010 05:21:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o325Lj2V059108;
	Fri, 2 Apr 2010 05:21:45 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o325Lj9j059100;
	Fri, 2 Apr 2010 05:21:45 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201004020521.o325Lj9j059100@svn.freebsd.org>
From: Warner Losh <imp@FreeBSD.org>
Date: Fri, 2 Apr 2010 05:21:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206072 - user/imp/nopriv/usr.sbin/mtree
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 05:21:45 -0000

Author: imp
Date: Fri Apr  2 05:21:45 2010
New Revision: 206072
URL: http://svn.freebsd.org/changeset/base/206072

Log:
  Start to merge functionality from NetBSD.  Merge the ability to
  specify the full path instead of the relative path.  This brings in
  all of NetBSD's spec.c, with other bits and pieces to support it.
  
  This is a work in progress.  At the very least we need to cut over to
  mtree_err in a few more places.  We need to bring in the merge code as
  well, so we can merge the BSD.foo.mtree files with the metadata files
  to allow the nopriv build to use makefs to build images.  mtree gets
  cranky if you don't list all the dirs before files in the dirs...

Modified:
  user/imp/nopriv/usr.sbin/mtree/Makefile
  user/imp/nopriv/usr.sbin/mtree/compare.c
  user/imp/nopriv/usr.sbin/mtree/extern.h
  user/imp/nopriv/usr.sbin/mtree/misc.c
  user/imp/nopriv/usr.sbin/mtree/mtree.h
  user/imp/nopriv/usr.sbin/mtree/spec.c
  user/imp/nopriv/usr.sbin/mtree/verify.c

Modified: user/imp/nopriv/usr.sbin/mtree/Makefile
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/Makefile	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/Makefile	Fri Apr  2 05:21:45 2010	(r206072)
@@ -8,8 +8,8 @@ MAN=	mtree.8 mtree.5
 SRCS=	compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
 SRCS+=	specspec.c
 
-CFLAGS+= -DMD5 -DSHA1 -DRMD160 -DSHA256
-DPADD=	${LIBMD}
-LDADD=	-lmd
+CFLAGS+= -DMD5 -DSHA1 -DRMD160 -DSHA256 -Dst_mtim=st_mtimespec
+DPADD=	${LIBMD} ${LIBUTIL}
+LDADD=	-lmd -lutil
 
 .include <bsd.prog.mk>

Modified: user/imp/nopriv/usr.sbin/mtree/compare.c
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/compare.c	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/compare.c	Fri Apr  2 05:21:45 2010	(r206072)
@@ -381,7 +381,7 @@ rlink(char *name)
 	char tbuf[MAXPATHLEN];
 
 	if ((len = readlink(name, tbuf, sizeof(tbuf) - 1)) == -1)
-		err(1, "line %d: %s", lineno, name);
+		mtree_err("%s", name);
 	tbuf[len] = '\0';
 	strvis(lbuf, tbuf, VIS_WHITE | VIS_OCTAL);
 	return (lbuf);

Modified: user/imp/nopriv/usr.sbin/mtree/extern.h
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/extern.h	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/extern.h	Fri Apr  2 05:21:45 2010	(r206072)
@@ -31,19 +31,26 @@
  */
 extern uint32_t crc_total;
 
+void	 addtag(slist_t *, char *);
 #ifdef _FTS_H_
 int	 compare(char *, NODE *, FTSENT *);
 #endif
 int	 crc(int, uint32_t *, off_t *);
 void	 cwalk(void);
+void	 dump_nodes(const char *, NODE *, int);
 char	*flags_to_string(u_long);
 
-const char	*inotype(u_int);
+int	 matchtags(NODE *);
+const char *nodetype(u_int);
 u_int	 parsekey(char *, int *);
+void	 parsetags(slist_t *, char *);
+u_int	 parsetype(const char *);
 char	*rlink(char *);
 NODE	*mtree_readspec(FILE *fi);
 int	mtree_verifyspec(FILE *fi);
 int	mtree_specspec(FILE *fi, FILE *fj);
+void	 mtree_err(const char *, ...)
+	    __attribute__((__format__(__printf__, 1, 2)));
 
 int	 check_excludes(const char *, const char *);
 void	 init_excludes(void);
@@ -52,7 +59,7 @@ const char * ftype(u_int type);
 
 extern int ftsoptions;
 extern u_int keys;
-extern int lineno;
+extern size_t mtree_lineno;
 extern int dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, wflag;
 #ifdef MAXPATHLEN
 extern char fullpath[MAXPATHLEN];

Modified: user/imp/nopriv/usr.sbin/mtree/misc.c
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/misc.c	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/misc.c	Fri Apr  2 05:21:45 2010	(r206072)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/stat.h>
 #include <err.h>
 #include <fts.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <unistd.h>
 #include "mtree.h"
@@ -83,6 +84,21 @@ static KEY keylist[] = {
 	{"uname",	F_UNAME,	NEEDVALUE},
 };
 
+static KEY typelist[] = {
+	{"block",	F_BLOCK,	0},
+	{"char",	F_CHAR,		0},
+	{"dir",		F_DIR,		0},
+#ifdef S_IFDOOR
+	{"door",	F_DOOR,		0},
+#endif
+	{"fifo",	F_FIFO,		0},
+	{"file",	F_FILE,		0},
+	{"link",	F_LINK,		0},
+	{"socket",	F_SOCK,		0},
+};
+
+slist_t	excludetags, includetags;
+
 int keycompare(const void *, const void *);
 
 u_int
@@ -94,13 +110,27 @@ parsekey(char *name, int *needvaluep)
 	k = (KEY *)bsearch(&tmp, keylist, sizeof(keylist) / sizeof(KEY),
 	    sizeof(KEY), keycompare);
 	if (k == NULL)
-		errx(1, "line %d: unknown keyword %s", lineno, name);
+		mtree_err("unknown keyword %s", name);
 
 	if (needvaluep)
 		*needvaluep = k->flags & NEEDVALUE ? 1 : 0;
 	return (k->val);
 }
 
+u_int
+parsetype(const char *name)
+{
+	KEY *k, tmp;
+
+	tmp.name = name;
+	k = (KEY *)bsearch(&tmp, typelist, sizeof(typelist) / sizeof(KEY),
+	    sizeof(KEY), keycompare);
+	if (k == NULL)
+		mtree_err("unknown file type `%s'", name);
+
+	return (k->val);
+}
+
 int
 keycompare(const void *a, const void *b)
 {
@@ -122,3 +152,123 @@ flags_to_string(u_long fflags)
 
 	return string;
 }
+
+void
+mtree_err(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vwarnx(fmt, ap);
+	va_end(ap);
+	if (mtree_lineno)
+		warnx("failed at line %lu of the specification",
+		    (u_long) mtree_lineno);
+	exit(1);
+	/* NOTREACHED */
+}
+
+void
+addtag(slist_t *list, char *elem)
+{
+
+#define	TAG_CHUNK 20
+
+	if ((list->count % TAG_CHUNK) == 0) {
+		char **new;
+
+		new = (char **)realloc(list->list, (list->count + TAG_CHUNK)
+		    * sizeof(char *));
+		if (new == NULL)
+			mtree_err("memory allocation error");
+		list->list = new;
+	}
+	list->list[list->count] = elem;
+	list->count++;
+}
+
+void
+parsetags(slist_t *list, char *args)
+{
+	char	*p, *e;
+	int	len;
+
+	if (args == NULL) {
+		addtag(list, NULL);
+		return;
+	}
+	while ((p = strsep(&args, ",")) != NULL) {
+		if (*p == '\0')
+			continue;
+		len = strlen(p) + 3;	/* "," + p + ",\0" */
+		if ((e = malloc(len)) == NULL)
+			mtree_err("memory allocation error");
+		snprintf(e, len, ",%s,", p);
+		addtag(list, e);
+	}
+}
+
+/*
+ * matchtags
+ *	returns 0 if there's a match from the exclude list in the node's tags,
+ *	or there's an include list and no match.
+ *	return 1 otherwise.
+ */
+int
+matchtags(NODE *node)
+{
+	int	i;
+
+	if (node->tags) {
+		for (i = 0; i < excludetags.count; i++)
+			if (strstr(node->tags, excludetags.list[i]))
+				break;
+		if (i < excludetags.count)
+			return (0);
+
+		for (i = 0; i < includetags.count; i++)
+			if (strstr(node->tags, includetags.list[i]))
+				break;
+		if (i > 0 && i == includetags.count)
+			return (0);
+	} else if (includetags.count > 0) {
+		return (0);
+	}
+	return (1);
+}
+
+u_int
+nodetoino(u_int type)
+{
+
+	switch (type) {
+	case F_BLOCK:
+		return S_IFBLK;
+	case F_CHAR:
+		return S_IFCHR;
+	case F_DIR:
+		return S_IFDIR;
+	case F_FIFO:
+		return S_IFIFO;
+	case F_FILE:
+		return S_IFREG;
+	case F_LINK:
+		return S_IFLNK;
+#ifdef S_IFSOCK
+	case F_SOCK:
+		return S_IFSOCK;
+#endif
+	default:
+		printf("unknown type %d", type);
+		abort();
+	}
+	/* NOTREACHED */
+}
+
+const char *
+nodetype(u_int type)
+{
+
+	return (inotype(nodetoino(type)));
+}
+

Modified: user/imp/nopriv/usr.sbin/mtree/mtree.h
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/mtree.h	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/mtree.h	Fri Apr  2 05:21:45 2010	(r206072)
@@ -48,6 +48,12 @@ typedef struct _node {
 	char	*sha1digest;			/* SHA-1 digest */
 	char	*sha256digest;			/* SHA-256 digest */
 	char	*rmd160digest;			/* RIPEMD160 digest */
+	char	*sha384digest;			/* SHA384 digest */
+	char	*sha512digest;			/* SHA512 digest */
+	char	*tags;				/* tags, comma delimited,
+						 * also with leading and
+						 * trailing commas */
+	size_t	lineno;				/* line # entry came from */
 	char	*slink;				/* symbolic link reference */
 	uid_t	st_uid;				/* uid */
 	gid_t	st_gid;				/* gid */
@@ -56,29 +62,32 @@ typedef struct _node {
 	u_long	st_flags;			/* flags */
 	nlink_t	st_nlink;			/* link count */
 
-#define	F_CKSUM	0x0001				/* check sum */
-#define	F_DONE	0x0002				/* directory done */
-#define	F_GID	0x0004				/* gid */
-#define	F_GNAME	0x0008				/* group name */
-#define	F_IGN	0x0010				/* ignore */
-#define	F_MAGIC	0x0020				/* name has magic chars */
-#define	F_MODE	0x0040				/* mode */
-#define	F_NLINK	0x0080				/* number of links */
-#define	F_SIZE	0x0100				/* size */
-#define	F_SLINK	0x0200				/* link count */
-#define	F_TIME	0x0400				/* modification time */
-#define	F_TYPE	0x0800				/* file type */
-#define	F_UID	0x1000				/* uid */
-#define	F_UNAME	0x2000				/* user name */
-#define	F_VISIT	0x4000				/* file visited */
-#define F_MD5	0x8000				/* MD5 digest */
-#define F_NOCHANGE 0x10000			/* If owner/mode "wrong", do */
-						/* not change */
-#define	F_SHA1	0x20000				/* SHA-1 digest */
-#define	F_RMD160 0x40000			/* RIPEMD160 digest */
-#define	F_FLAGS	0x80000				/* file flags */
-#define	F_SHA256	0x100000				/* SHA-256 digest */
-#define F_OPT	0x200000			/* existence optional */
+#define	F_CKSUM		0x00000001		/* cksum(1) check sum */
+#define	F_DEV		0x00000002		/* device type */
+#define	F_DONE		0x00000004		/* directory done */
+#define	F_FLAGS		0x00000008		/* file flags */
+#define	F_GID		0x00000010		/* gid */
+#define	F_GNAME		0x00000020		/* group name */
+#define	F_IGN		0x00000040		/* ignore */
+#define	F_MAGIC		0x00000080		/* name has magic chars */
+#define	F_MD5		0x00000100		/* MD5 digest */
+#define	F_MODE		0x00000200		/* mode */
+#define	F_NLINK		0x00000400		/* number of links */
+#define	F_OPT		0x00000800		/* existence optional */
+#define	F_RMD160	0x00001000		/* RMD-160 digest */
+#define	F_SHA1		0x00002000		/* SHA1 digest */
+#define	F_SIZE		0x00004000		/* size */
+#define	F_SLINK		0x00008000		/* symbolic link */
+#define	F_TAGS		0x00010000		/* tags */
+#define	F_TIME		0x00020000		/* modification time */
+#define	F_TYPE		0x00040000		/* file type */
+#define	F_UID		0x00080000		/* uid */
+#define	F_UNAME		0x00100000		/* user name */
+#define	F_VISIT		0x00200000		/* file visited */
+#define	F_SHA256	0x00800000		/* SHA256 digest */
+#define	F_SHA384	0x01000000		/* SHA384 digest */
+#define	F_SHA512	0x02000000		/* SHA512 digest */
+#define F_NOCHANGE	0x04000000		/* No change */	
 	u_int	flags;				/* items set */
 
 #define	F_BLOCK	0x001				/* block special */
@@ -93,6 +102,22 @@ typedef struct _node {
 	char	name[1];			/* file name (must be last) */
 } NODE;
 
+typedef struct {
+	char  **list;
+	int	count;
+} slist_t;
+
 #define	RP(p)	\
 	((p)->fts_path[0] == '.' && (p)->fts_path[1] == '/' ? \
 	    (p)->fts_path + 2 : (p)->fts_path)
+
+/*
+ * prototypes for functions published to other programs which want to use
+ * the specfile parser but don't want to pull in all of "extern.h"
+ */
+const char	*inotype(u_int);
+u_int		 nodetoino(u_int);
+int		 setup_getid(const char *);
+NODE		*spec(FILE *);
+void		 free_nodes(NODE *);
+char		*vispath(const char *);

Modified: user/imp/nopriv/usr.sbin/mtree/spec.c
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/spec.c	Fri Apr  2 05:15:27 2010	(r206071)
+++ user/imp/nopriv/usr.sbin/mtree/spec.c	Fri Apr  2 05:21:45 2010	(r206072)
@@ -1,3 +1,5 @@
+/*	$NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $	*/
+
 /*-
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -134,181 +136,515 @@ mtree_readspec(FILE *fi)
 			last->flags |= F_DONE;
 			continue;
 
-noparent:		errx(1, "line %d: no parent node", lineno);
+noparent:		mtree_err("no parent node");
+		}
+
+		plen = strlen(p) + 1;
+		if (plen > tnamelen) {
+			if ((ntname = realloc(tname, plen)) == NULL)
+				mtree_err("realloc: %s", strerror(errno));
+			tname = ntname;
+			tnamelen = plen;
+		}
+		if (strunvis(tname, p) == -1)
+			mtree_err("strunvis failed on `%s'", p);
+		p = tname;
+
+		pathparent = NULL;
+		if (strchr(p, '/') != NULL) {
+			cur = root;
+			for (; (e = strchr(p, '/')) != NULL; p = e+1) {
+				if (p == e)
+					continue;	/* handle // */
+				*e = '\0';
+				if (strcmp(p, ".") != 0) {
+					while (cur &&
+					    strcmp(cur->name, p) != 0) {
+						cur = cur->next;
+					}
+				}
+				if (cur == NULL || cur->type != F_DIR) {
+					mtree_err("%s: %s", tname,
+					"missing directory in specification");
+				}
+				*e = '/';
+				pathparent = cur;
+				cur = cur->child;
+			}
+			if (*p == '\0')
+				mtree_err("%s: empty leaf element", tname);
 		}
 
 		if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
-			errx(1, "calloc");
+			mtree_err("%s", strerror(errno));
 		*centry = ginfo;
+		centry->lineno = mtree_lineno;
+		strcpy(centry->name, p);
 #define	MAGIC	"?*["
 		if (strpbrk(p, MAGIC))
 			centry->flags |= F_MAGIC;
-		if (strunvis(centry->name, p) == -1)
-			errx(1, "filename %s is ill-encoded", p);
-		set(NULL, centry);
+		set(next, centry);
 
-		if (!root) {
+		if (root == NULL) {
+				/*
+				 * empty tree
+				 */
+			if (strcmp(centry->name, ".") != 0 ||
+			    centry->type != F_DIR)
+				mtree_err(
+				    "root node must be the directory `.'");
 			last = root = centry;
 			root->parent = root;
+		} else if (pathparent != NULL) {
+				/*
+				 * full path entry; add or replace
+				 */
+			centry->parent = pathparent;
+			addchild(pathparent, centry);
+			last = centry;
+		} else if (strcmp(centry->name, ".") == 0) {
+				/*
+				 * duplicate "." entry; always replace
+				 */
+			replacenode(root, centry);
 		} else if (last->type == F_DIR && !(last->flags & F_DONE)) {
+				/*
+				 * new relative child in current dir;
+				 * add or replace
+				 */
 			centry->parent = last;
-			last = last->child = centry;
+			addchild(last, centry);
+			last = centry;
 		} else {
+				/*
+				 * new relative child in parent dir
+				 * (after encountering ".." entry);
+				 * add or replace
+				 */
 			centry->parent = last->parent;
-			centry->prev = last;
-			last = last->next = centry;
+			addchild(last->parent, centry);
+			last = centry;
 		}
 	}
 	return (root);
 }
 
+void
+free_nodes(NODE *root)
+{
+	NODE	*cur, *next;
+
+	if (root == NULL)
+		return;
+
+	next = NULL;
+	for (cur = root; cur != NULL; cur = next) {
+		next = cur->next;
+		free_nodes(cur->child);
+		REPLACEPTR(cur->slink, NULL);
+		REPLACEPTR(cur->md5digest, NULL);
+		REPLACEPTR(cur->rmd160digest, NULL);
+		REPLACEPTR(cur->sha1digest, NULL);
+		REPLACEPTR(cur->sha256digest, NULL);
+		REPLACEPTR(cur->sha384digest, NULL);
+		REPLACEPTR(cur->sha512digest, NULL);
+		REPLACEPTR(cur->tags, NULL);
+		REPLACEPTR(cur, NULL);
+	}
+}
+
+/*
+ * appendfield --
+ *	Like printf(), but output a space either before or after
+ *	the regular output, according to the pathlast flag.
+ */
+static int
+appendfield(int pathlast, const char *fmt, ...)
+{
+	va_list ap;
+	int result;
+
+	va_start(ap, fmt);
+	if (!pathlast)
+		printf(" ");
+	result = vprintf(fmt, ap);
+	if (pathlast)
+		printf(" ");
+	va_end(ap);
+	return result;
+}
+
+/*
+ * dump_nodes --
+ *	dump the NODEs from `cur', based in the directory `dir'.
+ *	if pathlast is none zero, print the path last, otherwise print
+ *	it first.
+ */
+void
+dump_nodes(const char *dir, NODE *root, int pathlast)
+{
+	NODE	*cur;
+	char	path[MAXPATHLEN];
+	const char *name;
+	char	*str;
+	char	*p, *q;
+
+	for (cur = root; cur != NULL; cur = cur->next) {
+		if (cur->type != F_DIR && !matchtags(cur))
+			continue;
+
+		if (snprintf(path, sizeof(path), "%s%s%s",
+		    dir, *dir ? "/" : "", cur->name)
+		    >= (int)sizeof(path))
+			mtree_err("Pathname too long.");
+
+		if (!pathlast)
+			printf("%s", vispath(path));
+
+#define MATCHFLAG(f)	((keys & (f)) && (cur->flags & (f)))
+		if (MATCHFLAG(F_TYPE))
+			appendfield(pathlast, "type=%s", nodetype(cur->type));
+		if (MATCHFLAG(F_UID | F_UNAME)) {
+			if (keys & F_UNAME &&
+			    (name = user_from_uid(cur->st_uid, 1)) != NULL)
+				appendfield(pathlast, "uname=%s", name);
+			else
+				appendfield(pathlast, "uid=%u", cur->st_uid);
+		}
+		if (MATCHFLAG(F_GID | F_GNAME)) {
+			if (keys & F_GNAME &&
+			    (name = group_from_gid(cur->st_gid, 1)) != NULL)
+				appendfield(pathlast, "gname=%s", name);
+			else
+				appendfield(pathlast, "gid=%u", cur->st_gid);
+		}
+		if (MATCHFLAG(F_MODE))
+			appendfield(pathlast, "mode=%#o", cur->st_mode);
+#if 0
+		if (MATCHFLAG(F_DEV) &&
+		    (cur->type == F_BLOCK || cur->type == F_CHAR))
+			appendfield(pathlast, "device=%#llx", (long long)cur->st_rdev);
+#endif
+		if (MATCHFLAG(F_NLINK))
+			appendfield(pathlast, "nlink=%d", cur->st_nlink);
+		if (MATCHFLAG(F_SLINK))
+			appendfield(pathlast, "link=%s", vispath(cur->slink));
+		if (MATCHFLAG(F_SIZE))
+			appendfield(pathlast, "size=%lld", (long long)cur->st_size);
+		if (MATCHFLAG(F_TIME))
+			appendfield(pathlast, "time=%lld.%ld ",
+			    (long long)cur->st_mtimespec.tv_sec,
+			    cur->st_mtimespec.tv_nsec);
+		if (MATCHFLAG(F_CKSUM))
+			appendfield(pathlast, "cksum=%lu", cur->cksum);
+		if (MATCHFLAG(F_MD5))
+			appendfield(pathlast, "md5=%s", cur->md5digest);
+		if (MATCHFLAG(F_RMD160))
+			appendfield(pathlast, "rmd160=%s", cur->rmd160digest);
+		if (MATCHFLAG(F_SHA1))
+			appendfield(pathlast, "sha1=%s", cur->sha1digest);
+		if (MATCHFLAG(F_SHA256))
+			appendfield(pathlast, "sha256=%s", cur->sha256digest);
+		if (MATCHFLAG(F_SHA384))
+			appendfield(pathlast, "sha384=%s", cur->sha384digest);
+		if (MATCHFLAG(F_SHA512))
+			appendfield(pathlast, "sha512=%s", cur->sha512digest);
+		if (MATCHFLAG(F_FLAGS)) {
+			str = flags_to_string(cur->st_flags);
+			appendfield(pathlast, "flags=%s", str);
+			free(str);
+		}
+		if (MATCHFLAG(F_IGN))
+			appendfield(pathlast, "ignore");
+		if (MATCHFLAG(F_OPT))
+			appendfield(pathlast, "optional");
+		if (MATCHFLAG(F_TAGS)) {
+			/* don't output leading or trailing commas */
+			p = cur->tags;
+			while (*p == ',')
+				p++;
+			q = p + strlen(p);
+			while(q > p && q[-1] == ',')
+				q--;
+			appendfield(pathlast, "tags=%.*s", (int)(q - p), p);
+		}
+		puts(pathlast ? vispath(path) : "");
+
+		if (cur->child)
+			dump_nodes(path, cur->child, pathlast);
+	}
+}
+
+/*
+ * vispath --
+ *	strsvis(3) encodes path, which must not be longer than MAXPATHLEN
+ *	characters long, and returns a pointer to a static buffer containing
+ *	the result.
+ */
+char *
+vispath(const char *path)
+{
+//	const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
+	static char pathbuf[4*MAXPATHLEN + 1];
+
+//	strsvis(pathbuf, path, VIS_CSTYLE, extra);
+	strvis(pathbuf, path, VIS_CSTYLE);
+	return(pathbuf);
+}
+
+#if 0
+static dev_t
+parsedev(char *arg)
+{
+#define MAX_PACK_ARGS	3
+	u_long	numbers[MAX_PACK_ARGS];
+	char	*p, *ep, *dev;
+	int	argc;
+	pack_t	*pack;
+	dev_t	result;
+	const char *error = NULL;
+
+	if ((dev = strchr(arg, ',')) != NULL) {
+		*dev++='\0';
+		if ((pack = pack_find(arg)) == NULL)
+			mtree_err("unknown format `%s'", arg);
+		argc = 0;
+		while ((p = strsep(&dev, ",")) != NULL) {
+			if (*p == '\0')
+				mtree_err("missing number");
+			numbers[argc++] = strtoul(p, &ep, 0);
+			if (*ep != '\0')
+				mtree_err("invalid number `%s'",
+				    p);
+			if (argc > MAX_PACK_ARGS)
+				mtree_err("too many arguments");
+		}
+		if (argc < 2)
+			mtree_err("not enough arguments");
+		result = (*pack)(argc, numbers, &error);
+		if (error != NULL)
+			mtree_err("%s", error);
+	} else {
+		result = (dev_t)strtoul(arg, &ep, 0);
+		if (*ep != '\0')
+			mtree_err("invalid device `%s'", arg);
+	}
+	return (result);
+}
+#endif
+
+static void
+replacenode(NODE *cur, NODE *new)
+{
+
+#define REPLACE(x)	cur->x = new->x
+#define REPLACESTR(x)	REPLACEPTR(cur->x,new->x)
+
+	if (cur->type != new->type) {
+		if (mtree_Mflag) {
+				/*
+				 * merge entries with different types; we
+				 * don't want children retained in this case.
+				 */
+			REPLACE(type);
+			free_nodes(cur->child);
+			cur->child = NULL;
+		} else {
+			mtree_err(
+			    "existing entry for `%s', type `%s'"
+			    " does not match type `%s'",
+			    cur->name, nodetype(cur->type),
+			    nodetype(new->type));
+		}
+	}
+
+	REPLACE(st_size);
+	REPLACE(st_mtimespec);
+	REPLACESTR(slink);
+	if (cur->slink != NULL) {
+		if ((cur->slink = strdup(new->slink)) == NULL)
+			mtree_err("memory allocation error");
+		if (strunvis(cur->slink, new->slink) == -1)
+			mtree_err("strunvis failed on `%s'", new->slink);
+		free(new->slink);
+	}
+	REPLACE(st_uid);
+	REPLACE(st_gid);
+	REPLACE(st_mode);
+//	REPLACE(st_rdev);
+	REPLACE(st_flags);
+	REPLACE(st_nlink);
+	REPLACE(cksum);
+	REPLACESTR(md5digest);
+	REPLACESTR(rmd160digest);
+	REPLACESTR(sha1digest);
+	REPLACESTR(sha256digest);
+	REPLACESTR(sha384digest);
+	REPLACESTR(sha512digest);
+	REPLACESTR(tags);
+	REPLACE(lineno);
+	REPLACE(flags);
+	free(new);
+}
+
 static void
 set(char *t, NODE *ip)
 {
-	int type;
-	char *kw, *val = NULL;
+	int	type, value, len;
+	char	*kw, *val, *md, *ep;
+	void	*m;
 	struct group *gr;
 	struct passwd *pw;
-	mode_t *m;
-	int value;
-	char *ep;
 
-	for (; (kw = strtok(t, "= \t\n")); t = NULL) {
+	while ((kw = strsep(&t, "= \t")) != NULL) {
+		if (*kw == '\0')
+			continue;
+		if (strcmp(kw, "all") == 0)
+			mtree_err("invalid keyword `all'");
 		ip->flags |= type = parsekey(kw, &value);
-		if (value && (val = strtok(NULL, " \t\n")) == NULL)
-			errx(1, "line %d: missing value", lineno);
-		switch(type) {
+		if (!value)
+			/* Just set flag bit (F_IGN and F_OPT) */
+			continue;
+		while ((val = strsep(&t, " \t")) != NULL && *val == '\0')
+			continue;
+		if (val == NULL)
+			mtree_err("missing value");
+		switch (type) {
 		case F_CKSUM:
 			ip->cksum = strtoul(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid checksum %s",
-				lineno, val);
+				mtree_err("invalid checksum `%s'", val);
 			break;
-		case F_MD5:
-			ip->md5digest = strdup(val);
-			if(!ip->md5digest)
-				errx(1, "strdup");
-			break;
-		case F_SHA1:
-			ip->sha1digest = strdup(val);
-			if(!ip->sha1digest)
-				errx(1, "strdup");
-			break;
-		case F_SHA256:
-			ip->sha256digest = strdup(val);
-			if(!ip->sha256digest)
-				errx(1, "strdup");
-			break;
-		case F_RMD160:
-			ip->rmd160digest = strdup(val);
-			if(!ip->rmd160digest)
-				errx(1, "strdup");
+#if 0
+		case F_DEV:
+			ip->st_rdev = parsedev(val);
 			break;
+#endif
 		case F_FLAGS:
 			if (strcmp("none", val) == 0)
 				ip->st_flags = 0;
 			else if (strtofflags(&val, &ip->st_flags, NULL) != 0)
-				errx(1, "line %d: invalid flag %s",lineno, val);
- 			break;
+				mtree_err("invalid flag `%s'", val);
+			break;
 		case F_GID:
-			ip->st_gid = strtoul(val, &ep, 10);
+			ip->st_gid = (gid_t)strtoul(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid gid %s", lineno, val);
+				mtree_err("invalid gid `%s'", val);
 			break;
 		case F_GNAME:
+			if (mtree_Wflag)	/* don't parse if whacking */
+				break;
 			if ((gr = getgrnam(val)) == NULL)
-			    errx(1, "line %d: unknown group %s", lineno, val);
+				mtree_err("unknown group %s", val);
 			ip->st_gid = gr->gr_gid;
 			break;
-		case F_IGN:
-			/* just set flag bit */
+		case F_MD5:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->md5digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
 			break;
 		case F_MODE:
 			if ((m = setmode(val)) == NULL)
-				errx(1, "line %d: invalid file mode %s",
-				lineno, val);
+				mtree_err("cannot set file mode `%s' (%s)",
+				    val, strerror(errno));
 			ip->st_mode = getmode(m, 0);
 			free(m);
 			break;
 		case F_NLINK:
-			ip->st_nlink = strtoul(val, &ep, 10);
+			ip->st_nlink = (nlink_t)strtoul(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid link count %s",
-				lineno,  val);
+				mtree_err("invalid link count `%s'", val);
+			break;
+		case F_RMD160:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->rmd160digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
 			break;
-		case F_OPT:
-			/* just set flag bit */
+		case F_SHA1:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->sha1digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
 			break;
 		case F_SIZE:
-			ip->st_size = strtoq(val, &ep, 10);
+			ip->st_size = (off_t)strtoll(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid size %s",
-				lineno, val);
+				mtree_err("invalid size `%s'", val);
 			break;
 		case F_SLINK:
-			ip->slink = malloc(strlen(val) + 1);
-			if (ip->slink == NULL)
-				errx(1, "malloc");
+			if ((ip->slink = strdup(val)) == NULL)
+				mtree_err("memory allocation error");
 			if (strunvis(ip->slink, val) == -1)
-				errx(1, "symlink %s is ill-encoded", val);
+				mtree_err("strunvis failed on `%s'", val);
+			break;
+		case F_TAGS:
+			len = strlen(val) + 3;	/* "," + str + ",\0" */
+			if ((ip->tags = malloc(len)) == NULL)
+				mtree_err("memory allocation error");
+			snprintf(ip->tags, len, ",%s,", val);
 			break;
 		case F_TIME:
-			ip->st_mtimespec.tv_sec = strtoul(val, &ep, 10);
-			if (*ep == '.') {
-				/* Note: we require exactly nine
-				 * digits after the decimal point. */
-				val = ep + 1;
-				ip->st_mtimespec.tv_nsec
-				    = strtoul(val, &ep, 10);
-			} else
-				ip->st_mtimespec.tv_nsec = 0;
+			ip->st_mtimespec.tv_sec =
+			    (time_t)strtoll(val, &ep, 10);
+			if (*ep != '.')
+				mtree_err("invalid time `%s'", val);
+			val = ep + 1;
+			ip->st_mtimespec.tv_nsec = strtol(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid time %s",
-				    lineno, val);
+				mtree_err("invalid time `%s'", val);
 			break;
 		case F_TYPE:
-			switch(*val) {
-			case 'b':
-				if (!strcmp(val, "block"))
-					ip->type = F_BLOCK;
-				break;
-			case 'c':
-				if (!strcmp(val, "char"))
-					ip->type = F_CHAR;
-				break;
-			case 'd':
-				if (!strcmp(val, "dir"))
-					ip->type = F_DIR;
-				break;
-			case 'f':
-				if (!strcmp(val, "file"))
-					ip->type = F_FILE;
-				if (!strcmp(val, "fifo"))
-					ip->type = F_FIFO;
-				break;
-			case 'l':
-				if (!strcmp(val, "link"))
-					ip->type = F_LINK;
-				break;
-			case 's':
-				if (!strcmp(val, "socket"))
-					ip->type = F_SOCK;
-				break;
-			default:
-				errx(1, "line %d: unknown file type %s",
-				lineno, val);
-			}
+			ip->type = parsetype(val);
 			break;
 		case F_UID:
-			ip->st_uid = strtoul(val, &ep, 10);
+			ip->st_uid = (uid_t)strtoul(val, &ep, 10);
 			if (*ep)
-				errx(1, "line %d: invalid uid %s", lineno, val);
+				mtree_err("invalid uid `%s'", val);
 			break;
 		case F_UNAME:
+			if (mtree_Wflag)	/* don't parse if whacking */
+				break;
 			if ((pw = getpwnam(val)) == NULL)
-			    errx(1, "line %d: unknown user %s", lineno, val);
+				mtree_err("unknown user %s", val);
 			ip->st_uid = pw->pw_uid;
 			break;
+		case F_SHA256:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->sha256digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
+			break;
+		case F_SHA384:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->sha384digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
+			break;
+		case F_SHA512:
+			if (val[0]=='0' && val[1]=='x')
+				md=&val[2];
+			else
+				md=val;
+			if ((ip->sha512digest = strdup(md)) == NULL)
+				mtree_err("memory allocation error");
+			break;
+		default:
+			mtree_err(
+			    "set(): unsupported key type 0x%x (INTERNAL ERROR)",
+			    type);
+			/* NOTREACHED */
 		}
 	}
 }
@@ -318,6 +654,152 @@ unset(char *t, NODE *ip)
 {
 	char *p;
 
-	while ((p = strtok(t, "\n\t ")))
+	while ((p = strsep(&t, " \t")) != NULL) {
+		if (*p == '\0')
+			continue;
 		ip->flags &= ~parsekey(p, NULL);
+	}
+}
+
+/*
+ * addchild --
+ *	Add the centry node as a child of the pathparent node.	If
+ *	centry is a duplicate, call replacenode().  If centry is not
+ *	a duplicate, insert it into the linked list referenced by
+ *	pathparent->child.  Keep the list sorted if Sflag is set.
+ */
+static void
+addchild(NODE *pathparent, NODE *centry)
+{
+	NODE *samename;      /* node with the same name as centry */
+	NODE *replacepos;    /* if non-NULL, centry should replace this node */
+	NODE *insertpos;     /* if non-NULL, centry should be inserted
+			      * after this node */
+	NODE *cur;           /* for stepping through the list */
+	NODE *last;          /* the last node in the list */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 05:32:45 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3D8C3106566B;
	Fri,  2 Apr 2010 05:32:45 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2C7738FC0C;
	Fri,  2 Apr 2010 05:32:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o325WjAG061511;
	Fri, 2 Apr 2010 05:32:45 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o325WjiY061509;
	Fri, 2 Apr 2010 05:32:45 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201004020532.o325WjiY061509@svn.freebsd.org>
From: Warner Losh <imp@FreeBSD.org>
Date: Fri, 2 Apr 2010 05:32:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206073 - user/imp/nopriv/usr.sbin/mtree
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 05:32:45 -0000

Author: imp
Date: Fri Apr  2 05:32:44 2010
New Revision: 206073
URL: http://svn.freebsd.org/changeset/base/206073

Log:
  Fix mismerge from my trial tree...  $FreeBSD$ really messed me up..

Modified:
  user/imp/nopriv/usr.sbin/mtree/spec.c

Modified: user/imp/nopriv/usr.sbin/mtree/spec.c
==============================================================================
--- user/imp/nopriv/usr.sbin/mtree/spec.c	Fri Apr  2 05:21:45 2010	(r206072)
+++ user/imp/nopriv/usr.sbin/mtree/spec.c	Fri Apr  2 05:32:44 2010	(r206073)
@@ -29,6 +29,35 @@
  * SUCH DAMAGE.
  */
 
+/*-
+ * Copyright (c) 2001-2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn of Wasabi Systems.
+ *
+ * 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.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #if 0
 #ifndef lint
 static char sccsid[] = "@(#)spec.c	8.1 (Berkeley) 6/6/93";
@@ -36,97 +65,94 @@ static char sccsid[] = "@(#)spec.c	8.1 (
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
+__RCSID("$NetBSD: spec.c,v 1.78 2009/09/22 04:38:21 apb Exp $");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/stat.h>
+
+#include <assert.h>
 #include <ctype.h>
-#include <err.h>
 #include <errno.h>
-#include <fts.h>
 #include <grp.h>
 #include <pwd.h>
+#include <stdarg.h>
+#include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 #include <vis.h>
+#include <libutil.h>
+
 #include "mtree.h"
 #include "extern.h"
 
-int lineno;				/* Current spec line number. */
+size_t	mtree_lineno;			/* Current spec line number */
+int	mtree_Mflag;			/* Merge duplicate entries */
+int	mtree_Wflag;			/* Don't "whack" permissions */
+int	mtree_Sflag;			/* Sort entries */
 
-static void	 set(char *, NODE *);
-static void	 unset(char *, NODE *);
+#if 0
+static	dev_t	parsedev(char *);
+#endif
+static	void	replacenode(NODE *, NODE *);
+static	void	set(char *, NODE *);
+static	void	unset(char *, NODE *);
+static	void	addchild(NODE *, NODE *);
+static	int	nodecmp(const NODE *, const NODE *);
+static	int	appendfield(int, const char *, ...);
+
+#define REPLACEPTR(x,v)	do { if ((x)) free((x)); (x) = (v); } while (0)
 
 NODE *
-mtree_readspec(FILE *fi)
+mtree_readspec(FILE *fp)
 {
-	NODE *centry, *last;
-	char *p;
+	NODE *centry, *last, *pathparent, *cur;
+	char *p, *e, *next;
 	NODE ginfo, *root;
-	int c_cur, c_next;
-	char buf[2048];
-
-	centry = last = root = NULL;
-	bzero(&ginfo, sizeof(ginfo));
-	c_cur = c_next = 0;
-	for (lineno = 1; fgets(buf, sizeof(buf), fi);
-	    ++lineno, c_cur = c_next, c_next = 0) {
-		/* Skip empty lines. */
-		if (buf[0] == '\n')
-			continue;
-
-		/* Find end of line. */
-		if ((p = index(buf, '\n')) == NULL)
-			errx(1, "line %d too long", lineno);
-
-		/* See if next line is continuation line. */
-		if (p[-1] == '\\') {
-			--p;
-			c_next = 1;
-		}
-
-		/* Null-terminate the line. */
-		*p = '\0';
+	char *buf, *tname, *ntname;
+	size_t tnamelen, plen;
 
+	root = NULL;
+	centry = last = NULL;
+	tname = NULL;
+	tnamelen = 0;
+	memset(&ginfo, 0, sizeof(ginfo));
+	for (mtree_lineno = 0;
+	    (buf = fparseln(fp, NULL, &mtree_lineno, NULL,
+		FPARSELN_UNESCCOMM));
+	    free(buf)) {
 		/* Skip leading whitespace. */
-		for (p = buf; *p && isspace(*p); ++p);
+		for (p = buf; *p && isspace((unsigned char)*p); ++p)
+			continue;
 
-		/* If nothing but whitespace or comment char, continue. */
-		if (!*p || *p == '#')
+		/* If nothing but whitespace, continue. */
+		if (!*p)
 			continue;
 
 #ifdef DEBUG
-		(void)fprintf(stderr, "line %d: {%s}\n", lineno, p);
+		fprintf(stderr, "line %lu: {%s}\n",
+		    (u_long)mtree_lineno, p);
 #endif
-		if (c_cur) {
-			set(p, centry);
-			continue;
-		}
-
 		/* Grab file name, "$", "set", or "unset". */
-		if ((p = strtok(p, "\n\t ")) == NULL)
-			errx(1, "line %d: missing field", lineno);
-
-		if (p[0] == '/')
-			switch(p[1]) {
-			case 's':
-				if (strcmp(p + 1, "set"))
-					break;
-				set(NULL, &ginfo);
-				continue;
-			case 'u':
-				if (strcmp(p + 1, "unset"))
-					break;
-				unset(NULL, &ginfo);
-				continue;
-			}
+		next = buf;
+		while ((p = strsep(&next, " \t")) != NULL && *p == '\0')
+			continue;
+		if (p == NULL)
+			mtree_err("missing field");
 
-		if (index(p, '/'))
-			errx(1, "line %d: slash character in file name",
-			lineno);
+		if (p[0] == '/') {
+			if (strcmp(p + 1, "set") == 0)
+				set(next, &ginfo);
+			else if (strcmp(p + 1, "unset") == 0)
+				unset(next, &ginfo);
+			else
+				mtree_err("invalid specification `%s'", p);
+			continue;
+		}
 
-		if (!strcmp(p, "..")) {
+		if (strcmp(p, "..") == 0) {
 			/* Don't go up, if haven't gone down. */
-			if (!root)
+			if (root == NULL)
 				goto noparent;
 			if (last->type != F_DIR || last->flags & F_DONE) {
 				if (last == root)

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 05:43:12 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 23B2C106566B;
	Fri,  2 Apr 2010 05:43:12 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 134F98FC16;
	Fri,  2 Apr 2010 05:43:12 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o325hBX3063817;
	Fri, 2 Apr 2010 05:43:11 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o325hBg6063815;
	Fri, 2 Apr 2010 05:43:11 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020543.o325hBg6063815@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 05:43:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206074 - user/jmallett/octeon/sys/mips/include
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 05:43:12 -0000

Author: jmallett
Date: Fri Apr  2 05:43:11 2010
New Revision: 206074
URL: http://svn.freebsd.org/changeset/base/206074

Log:
  Go back to 32-bit PTEs.

Modified:
  user/jmallett/octeon/sys/mips/include/pte.h

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Fri Apr  2 05:32:44 2010	(r206073)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Fri Apr  2 05:43:11 2010	(r206074)
@@ -83,7 +83,7 @@ struct tlb {
 	int	tlb_lo1;
 };
 
-typedef unsigned long pt_entry_t;
+typedef unsigned int pt_entry_t;
 typedef pt_entry_t *pd_entry_t;
 
 #define	PDESIZE		sizeof(pd_entry_t)	/* for assembly files */

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 05:49:14 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C2069106564A;
	Fri,  2 Apr 2010 05:49:14 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B10B38FC14;
	Fri,  2 Apr 2010 05:49:14 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o325nEtH065181;
	Fri, 2 Apr 2010 05:49:14 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o325nEPL065178;
	Fri, 2 Apr 2010 05:49:14 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020549.o325nEPL065178@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 05:49:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206075 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 05:49:14 -0000

Author: jmallett
Date: Fri Apr  2 05:49:14 2010
New Revision: 206075
URL: http://svn.freebsd.org/changeset/base/206075

Log:
  o) Adjust format for PTEs.
  o) Fix O32 build of trap.c with TRAP_DEBUG.

Modified:
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/trap.c

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Fri Apr  2 05:43:11 2010	(r206074)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Fri Apr  2 05:49:14 2010	(r206075)
@@ -2030,7 +2030,7 @@ validate:
 			if (origpte & PTE_M) {
 				KASSERT((origpte & PTE_RW),
 				    ("pmap_enter: modified page not writable:"
-				    " va: %p, pte: 0x%lx", (void *)va, origpte));
+				    " va: %p, pte: 0x%x", (void *)va, origpte));
 				if (page_is_managed(opa))
 					vm_page_dirty(om);
 			}
@@ -2724,7 +2724,7 @@ pmap_remove_pages(pmap_t pmap)
 		m = PHYS_TO_VM_PAGE(mips_tlbpfn_to_paddr(tpte));
 
 		KASSERT(m < &vm_page_array[vm_page_array_size],
-		    ("pmap_remove_pages: bad tpte %lx", tpte));
+		    ("pmap_remove_pages: bad tpte %x", tpte));
 
 		pv->pv_pmap->pm_stats.resident_count--;
 

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Fri Apr  2 05:43:11 2010	(r206074)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Fri Apr  2 05:49:14 2010	(r206075)
@@ -330,7 +330,7 @@ trap(struct trapframe *trapframe)
 #ifdef SMP
 		printf("cpuid = %d\n", PCPU_GET(cpuid));
 #endif
-		pid = Mips_TLBGetPID();
+		pid = mips_rd_entryhi() & VMTLB_PID;
 		printf("badaddr = %#jx, pc = %#jx, ra = %#jx, sp = %#jx, sr = %jx, pid = %d, ASID = %u\n",
 		    (intmax_t)trapframe->badvaddr, (intmax_t)trapframe->pc, (intmax_t)trapframe->ra,
 		    (intmax_t)trapframe->sp, (intmax_t)trapframe->sr,
@@ -355,7 +355,7 @@ trap(struct trapframe *trapframe)
 		    ((type & ~T_USER) != T_SYSCALL)) {
 			if (++count == 3) {
 				trap_frame_dump(trapframe);
-				panic("too many faults at %x\n", last_badvaddr);
+				panic("too many faults at %p\n", (void *)last_badvaddr);
 			}
 		} else {
 			last_badvaddr = this_badvaddr;
@@ -738,7 +738,7 @@ dofault:
 			}
 #ifdef TRAP_DEBUG
 			for (i = 0; i < nargs; i++) {
-				printf("args[%d] = %#llx\n", i, args[i]);
+				printf("args[%d] = %#jx\n", i, (intmax_t)args[i]);
 			}
 #endif
 #ifdef KTRACE
@@ -1349,7 +1349,7 @@ log_illegal_instruction(const char *msg,
 	if (!(pc & 3) &&
 	    useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) {
 		/* dump page table entry for faulting instruction */
-		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#lx\n",
+		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#x\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 
 		addr = (unsigned int *)(intptr_t)pc;
@@ -1358,7 +1358,7 @@ log_illegal_instruction(const char *msg,
 		log(LOG_ERR, "%08x %08x %08x %08x\n",
 		    addr[0], addr[1], addr[2], addr[3]);
 	} else {
-		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#lx\n",
+		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#x\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 	}
 }
@@ -1413,7 +1413,7 @@ log_bad_page_fault(char *msg, struct tra
 	    (trap_type != T_BUS_ERR_IFETCH) &&
 	    useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) {
 		/* dump page table entry for faulting instruction */
-		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#lx\n",
+		log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#x\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 
 		addr = (unsigned int *)(intptr_t)pc;
@@ -1422,7 +1422,7 @@ log_bad_page_fault(char *msg, struct tra
 		log(LOG_ERR, "%08x %08x %08x %08x\n",
 		    addr[0], addr[1], addr[2], addr[3]);
 	} else {
-		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#lx\n",
+		log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#x\n",
 		    (intmax_t)pc, (void *)(intptr_t)*pdep, ptep ? *ptep : 0);
 	}
 	/*	panic("Bad trap");*/

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 06:06:50 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B7004106564A;
	Fri,  2 Apr 2010 06:06:50 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 700D08FC0A;
	Fri,  2 Apr 2010 06:06:50 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3266owG069139;
	Fri, 2 Apr 2010 06:06:50 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3266odj069136;
	Fri, 2 Apr 2010 06:06:50 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020606.o3266odj069136@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 06:06:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206076 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 06:06:50 -0000

Author: jmallett
Date: Fri Apr  2 06:06:50 2010
New Revision: 206076
URL: http://svn.freebsd.org/changeset/base/206076

Log:
  Add a macro, CLEAR_PTE_WIRED, to clear software-managed PTE bits.

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S
  user/jmallett/octeon/sys/mips/mips/tlb.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 05:49:14 2010	(r206075)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:06:50 2010	(r206076)
@@ -66,21 +66,12 @@
 
 #include "assym.s"
 
-#if defined(ISA_MIPS32)
-#undef WITH_64BIT_CP0
-#elif defined(ISA_MIPS64)
-#define WITH_64BIT_CP0
-#elif defined(ISA_MIPS3)
-#define WITH_64BIT_CP0
-#else
-#error "Please write the code for this ISA"
-#endif
-
-#ifdef WITH_64BIT_CP0
-#define WIRED_SHIFT 34
-#else
-#define WIRED_SHIFT 2
-#endif
+/*
+ * Clear the software-managed bits in a PTE in register pr.
+ */
+#define	CLEAR_PTE_WIRED(pr)							\
+	sll		pr, 2 ;							\
+	srl		pr, 2			# keep bottom 30 bits
 
 	.set	noreorder			# Noreorder is default style!
 
@@ -154,11 +145,9 @@ MipsDoTLBMiss:
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
 	lw	k0, 0(k1)			#0e: k0=lo0 pte
 	lw	k1, 4(k1)			#0f: k1=lo1 pte
-	PTR_SLL	k0, k0, WIRED_SHIFT		#10: keep bottom 30 bits
-	PTR_SRL	k0, k0, WIRED_SHIFT		#11: keep bottom 30 bits
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO0		#12: lo0 is loaded
-	PTR_SLL	k1, k1, WIRED_SHIFT		#13: keep bottom 30 bits
-	PTR_SRL	k1, k1, WIRED_SHIFT		#14: keep bottom 30 bits
+	CLEAR_PTE_WIRED(k1)
 	MTC0	k1, COP_0_TLB_LO1		#15: lo1 is loaded
 	HAZARD_DELAY
 	tlbwr					#1a: write to tlb
@@ -864,13 +853,11 @@ NLEAF(MipsTLBInvalidException)
 
 even_page:
 	lw	k0, 0(k1)
-	PTR_SLL	k0, k0, WIRED_SHIFT
-	PTR_SRL	k0, k0, WIRED_SHIFT
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO0
 
 	lw	k0, 4(k1)
-	PTR_SLL	k0, k0, WIRED_SHIFT
-	PTR_SRL	k0, k0, WIRED_SHIFT
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO1
 
 	b	tlb_insert_entry
@@ -878,13 +865,11 @@ even_page:
 
 odd_page:
 	lw	k0, 0(k1)
-	PTR_SLL	k0, k0, WIRED_SHIFT
-	PTR_SRL	k0, k0, WIRED_SHIFT
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO1
 
 	lw	k0, -4(k1)
-	PTR_SLL	k0, k0, WIRED_SHIFT
-	PTR_SRL	k0, k0, WIRED_SHIFT
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO0
 
 tlb_insert_entry:
@@ -1020,11 +1005,9 @@ NLEAF(MipsTLBMissException)
 	PTR_ADDU	k1, k1, k0			# k1=pte address
 	lw	k0, 0(k1)			# k0=lo0 pte
 	lw	k1, 4(k1)			# k1=lo1 pte
-	PTR_SLL	k0, WIRED_SHIFT			# chop bits [31..30]
-	PTR_SRL	k0, WIRED_SHIFT			# chop bits [31..30]
+	CLEAR_PTE_WIRED(k0)
 	MTC0	k0, COP_0_TLB_LO0		# lo0 is loaded
-	PTR_SLL	k1, WIRED_SHIFT			# chop bits [31..30]
-	PTR_SRL	k1, WIRED_SHIFT			# chop bits [31..30]
+	CLEAR_PTE_WIRED(k1)
 	MTC0	k1, COP_0_TLB_LO1		# lo1 is loaded
 
 	HAZARD_DELAY

Modified: user/jmallett/octeon/sys/mips/mips/tlb.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/tlb.S	Fri Apr  2 05:49:14 2010	(r206075)
+++ user/jmallett/octeon/sys/mips/mips/tlb.S	Fri Apr  2 06:06:50 2010	(r206076)
@@ -65,21 +65,13 @@
 
 #include "assym.s"
 
-#if defined(ISA_MIPS32)
-#undef WITH_64BIT_CP0
-#elif defined(ISA_MIPS64)
-#define WITH_64BIT_CP0
-#elif defined(ISA_MIPS3)
-#define WITH_64BIT_CP0
-#else
-#error "Please write the code for this ISA"
-#endif
-
-#ifdef WITH_64BIT_CP0
-#define WIRED_SHIFT 34
-#else
-#define WIRED_SHIFT 2
-#endif
+/*
+ * Clear the software-managed bits in a PTE in register pr.
+ */
+#define	CLEAR_PTE_WIRED(pr)							\
+	sll		pr, 2 ;							\
+	srl		pr, 2			# keep bottom 30 bits
+
 	.set	noreorder			# Noreorder is default style!
 
 #define	ITLBNOPFIX	nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
@@ -266,8 +258,7 @@ LEAF(Mips_TLBUpdate)
 	and	a2, a1, PTE_G			# Copy global bit
 	MIPS_CPU_NOP_DELAY
 	tlbp					# Probe for the entry.
-	PTR_SLL	a1, a1, WIRED_SHIFT
-	PTR_SRL	a1, a1, WIRED_SHIFT
+	CLEAR_PTE_WIRED(a1)
 	nop
 	mfc0	v0, COP_0_TLB_INDEX		# See what we got
 	bne	t1, zero, 2f			# Decide even odd

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 06:10:58 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A7400106564A;
	Fri,  2 Apr 2010 06:10:58 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 963558FC0A;
	Fri,  2 Apr 2010 06:10:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o326AwBe070062;
	Fri, 2 Apr 2010 06:10:58 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o326AwI9070060;
	Fri, 2 Apr 2010 06:10:58 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020610.o326AwI9070060@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 06:10:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206077 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 06:10:58 -0000

Author: jmallett
Date: Fri Apr  2 06:10:58 2010
New Revision: 206077
URL: http://svn.freebsd.org/changeset/base/206077

Log:
  Use MFC0 and MTC0 macros for badvaddr and exc_pc, which may be 64-bit.

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:06:50 2010	(r206076)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:10:58 2010	(r206077)
@@ -106,7 +106,7 @@
 	.set	noat
 VECTOR(MipsTLBMiss, unknown)
 	j	_C_LABEL(MipsDoTLBMiss)
-	mfc0	k0, COP_0_BAD_VADDR		# get the fault address
+	MFC0	k0, COP_0_BAD_VADDR		# get the fault address
 	nop
 VECTOR_END(MipsTLBMiss)
 
@@ -136,7 +136,7 @@ MipsDoTLBMiss:
 #endif
 	PTR_ADDU	k1, k0, k1			#07: k1=seg entry address
 	PTR_L	k1, 0(k1)			#08: k1=seg entry
-	mfc0	k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
+	MFC0	k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
 	beq	k1, zero, 2f			#0a: ==0 -- no page table
 	srl	k0, PAGE_SHIFT - 2			#0b: k0=VPN (aka va>>10)
 
@@ -291,8 +291,8 @@ SlowFault:
 	mfhi	v1			;\
 	mfc0	a0, COP_0_STATUS_REG	;\
 	mfc0	a1, COP_0_CAUSE_REG	;\
-	mfc0	a2, COP_0_BAD_VADDR	;\
-	mfc0	a3, COP_0_EXC_PC	;\
+	MFC0	a2, COP_0_BAD_VADDR	;\
+	MFC0	a3, COP_0_EXC_PC	;\
 	SAVE_REG(v0, MULLO, sp)		;\
 	SAVE_REG(v1, MULHI, sp)		;\
 	SAVE_REG(a0, SR, sp)		;\
@@ -450,12 +450,12 @@ NNON_LEAF(MipsUserGenException, CALLFRAM
 	SAVE_U_PCB_REG(s2, S2, k1)
 	SAVE_U_PCB_REG(s3, S3, k1)
 	SAVE_U_PCB_REG(s4, S4, k1)
-	mfc0	a2, COP_0_BAD_VADDR		# Third arg is the fault addr
+	MFC0	a2, COP_0_BAD_VADDR		# Third arg is the fault addr
 	SAVE_U_PCB_REG(s5, S5, k1)
 	SAVE_U_PCB_REG(s6, S6, k1)
 	SAVE_U_PCB_REG(s7, S7, k1)
 	SAVE_U_PCB_REG(t8, T8, k1)
-	mfc0	a3, COP_0_EXC_PC		# Fourth arg is the pc.
+	MFC0	a3, COP_0_EXC_PC		# Fourth arg is the pc.
 	SAVE_U_PCB_REG(t9, T9, k1)
 	SAVE_U_PCB_REG(gp, GP, k1)
 	SAVE_U_PCB_REG(sp, SP, k1)
@@ -689,7 +689,7 @@ NNON_LEAF(MipsUserIntr, CALLFRAME_SIZ, r
 	mfhi	v1
 	mfc0	a0, COP_0_STATUS_REG
 	mfc0	a1, COP_0_CAUSE_REG
-	mfc0	a3, COP_0_EXC_PC
+	MFC0	a3, COP_0_EXC_PC
 	SAVE_U_PCB_REG(v0, MULLO, k1)
 	SAVE_U_PCB_REG(v1, MULHI, k1)
 	SAVE_U_PCB_REG(a0, SR, k1)
@@ -806,7 +806,7 @@ NLEAF(MipsTLBInvalidException)
 	.set noat
 	.set noreorder
 
-	mfc0	k0, COP_0_BAD_VADDR
+	MFC0	k0, COP_0_BAD_VADDR
 	li	k1, VM_MAXUSER_ADDRESS
 	sltu	k1, k0, k1
 	bnez	k1, 1f
@@ -837,7 +837,7 @@ NLEAF(MipsTLBInvalidException)
 	beqz	k1, 3f			/* invalid page table page pointer */
 	nop
 
-	mfc0	k0, COP_0_BAD_VADDR
+	MFC0	k0, COP_0_BAD_VADDR
 	srl	k0, PAGE_SHIFT - 2
 	andi	k0, 0xffc
 	PTR_ADDU	k1, k1, k0
@@ -982,7 +982,7 @@ END(MipsTLBInvalidException)
  */
 NLEAF(MipsTLBMissException)
 	.set	noat
-	mfc0	k0, COP_0_BAD_VADDR		# k0=bad address
+	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address
 	li	k1, (VM_MAX_KERNEL_ADDRESS)	# check fault address against
 	sltu	k1, k1, k0			# upper bound of kernel_segmap
 	bnez	k1, _C_LABEL(MipsKernGenException)  # out of bound
@@ -997,7 +997,7 @@ NLEAF(MipsTLBMissException)
 #endif
 	PTR_ADDU	k1, k0, k1			# k1=seg entry address
 	PTR_L	k1, 0(k1)			# k1=seg entry
-	mfc0	k0, COP_0_BAD_VADDR		# k0=bad address (again)
+	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address (again)
 	beq	k1, zero, _C_LABEL(MipsKernGenException)  # ==0 -- no page table
 	srl	k0, 10				# k0=VPN (aka va>>10)
 	andi	k0, k0, 0xff8			# k0=page tab offset

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 06:15:46 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A99951065670;
	Fri,  2 Apr 2010 06:15:46 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7E9908FC14;
	Fri,  2 Apr 2010 06:15:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o326FkMs071155;
	Fri, 2 Apr 2010 06:15:46 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o326FkLv071153;
	Fri, 2 Apr 2010 06:15:46 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020615.o326FkLv071153@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 06:15:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206078 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 06:15:46 -0000

Author: jmallett
Date: Fri Apr  2 06:15:46 2010
New Revision: 206078
URL: http://svn.freebsd.org/changeset/base/206078

Log:
  Remove a few _C_LABEL().

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:10:58 2010	(r206077)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:15:46 2010	(r206078)
@@ -105,7 +105,7 @@
 
 	.set	noat
 VECTOR(MipsTLBMiss, unknown)
-	j	_C_LABEL(MipsDoTLBMiss)
+	j	MipsDoTLBMiss
 	MFC0	k0, COP_0_BAD_VADDR		# get the fault address
 	nop
 VECTOR_END(MipsTLBMiss)
@@ -153,7 +153,7 @@ MipsDoTLBMiss:
 	tlbwr					#1a: write to tlb
 	HAZARD_DELAY
 	eret					#1f: retUrn from exception
-1:	j _C_LABEL(MipsTLBMissException)	#20: kernel exception
+1:	j	MipsTLBMissException		#20: kernel exception
 	nop					#21: branch delay slot
 2:	j	SlowFault			#22: no page table present
 	nop					#23: branch delay slot
@@ -813,9 +813,9 @@ NLEAF(MipsTLBInvalidException)
 	nop
 
 	/* badvaddr = kernel address */
-	lui	k1, %hi(_C_LABEL(kernel_segmap))
+	lui	k1, %hi(kernel_segmap)
 	b	2f
-	PTR_L	k1, %lo(_C_LABEL(kernel_segmap))(k1)
+	PTR_L	k1, %lo(kernel_segmap)(k1)
 
 1:
 	/* badvaddr = user address */
@@ -985,11 +985,11 @@ NLEAF(MipsTLBMissException)
 	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address
 	li	k1, (VM_MAX_KERNEL_ADDRESS)	# check fault address against
 	sltu	k1, k1, k0			# upper bound of kernel_segmap
-	bnez	k1, _C_LABEL(MipsKernGenException)  # out of bound
-	lui	k1, %hi(_C_LABEL(kernel_segmap))  # k1=hi of segbase
+	bnez	k1, MipsKernGenException	# out of bound
+	lui	k1, %hi(kernel_segmap)		# k1=hi of segbase
 	srl	k0, 20				# k0=seg offset (almost)
-	PTR_L	k1, %lo(_C_LABEL(kernel_segmap))(k1)  # k1=segment tab base
-	beq	k1, zero, _C_LABEL(MipsKernGenException)  # ==0 -- no seg tab
+	PTR_L	k1, %lo(kernel_segmap)(k1)	# k1=segment tab base
+	beq	k1, zero, MipsKernGenException	# ==0 -- no seg tab
 #if defined(__mips_n64)
 	andi	k0, k0, 0xff8			# k0=seg offset (mask 0x7)
 #else
@@ -998,7 +998,7 @@ NLEAF(MipsTLBMissException)
 	PTR_ADDU	k1, k0, k1			# k1=seg entry address
 	PTR_L	k1, 0(k1)			# k1=seg entry
 	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address (again)
-	beq	k1, zero, _C_LABEL(MipsKernGenException)  # ==0 -- no page table
+	beq	k1, zero, MipsKernGenException	# ==0 -- no page table
 	srl	k0, 10				# k0=VPN (aka va>>10)
 	andi	k0, k0, 0xff8			# k0=page tab offset
 #xxx mips64 unsafe

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 06:24:17 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3F8371065672;
	Fri,  2 Apr 2010 06:24:17 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2D5178FC0A;
	Fri,  2 Apr 2010 06:24:17 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o326OHrO073046;
	Fri, 2 Apr 2010 06:24:17 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o326OHdI073044;
	Fri, 2 Apr 2010 06:24:17 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020624.o326OHdI073044@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 06:24:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206079 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 06:24:17 -0000

Author: jmallett
Date: Fri Apr  2 06:24:16 2010
New Revision: 206079
URL: http://svn.freebsd.org/changeset/base/206079

Log:
  o) Adjust some shifts, etc., for N64.
  o) Adjust style in some places to allow for long instruction names used by
     <machine/asm.h> and to reduce diffs between near-identical sections of
     code.

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:15:46 2010	(r206078)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:24:16 2010	(r206079)
@@ -102,12 +102,12 @@
  *
  *
  */
-
-	.set	noat
 VECTOR(MipsTLBMiss, unknown)
+	.set push
+	.set noat
 	j	MipsDoTLBMiss
 	MFC0	k0, COP_0_BAD_VADDR		# get the fault address
-	nop
+	.set pop
 VECTOR_END(MipsTLBMiss)
 
 /*
@@ -122,43 +122,42 @@ VECTOR_END(MipsTLBMiss)
  * let the processor trap to load the correct value after service.
  *----------------------------------------------------------------------------
  */
+ 	.set push
+	.set noat
 MipsDoTLBMiss:
-						#k0 already has BadVA
-	bltz	k0, 1f				#02: k0<0 -> 1f (kernel fault)
-	srl	k0, k0, SEGSHIFT - 2		#03: k0=seg offset (almost)
+	bltz		k0, 1f				#02: k0<0 -> 1f (kernel fault)
+	srl		k0, k0, SEGSHIFT - 2		#03: k0=seg offset (almost)
+
 	GET_CPU_PCPU(k1)
-	PTR_L	k1, PC_SEGBASE(k1)
-	beqz	k1, 2f			      #05: make sure segbase is not null
+	PTR_L		k1, PC_SEGBASE(k1)
+	beqz		k1, 2f				#05: make sure segbase is not null
 #if defined(__mips_n64)
-	andi	k0, k0, 0x7f8			#06: k0=seg offset (mask 0x7)
+	andi		k0, k0, 0xff8			#06: k0=seg offset (mask 0x7)
 #else
-	andi	k0, k0, 0x7fc			#06: k0=seg offset (mask 0x3)
+	andi		k0, k0, 0x7fc			#06: k0=seg offset (mask 0x3)
 #endif
 	PTR_ADDU	k1, k0, k1			#07: k1=seg entry address
-	PTR_L	k1, 0(k1)			#08: k1=seg entry
-	MFC0	k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
-	beq	k1, zero, 2f			#0a: ==0 -- no page table
-	srl	k0, PAGE_SHIFT - 2			#0b: k0=VPN (aka va>>10)
-
-	andi	k0, k0, ((NPTEPG/2) - 1) << 3	#0c: k0=page tab offset
-#xxx mips64 unsafe?
+	PTR_L		k1, 0(k1)			#08: k1=seg entry
+	MFC0		k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
+	beq		k1, zero, 2f			#0a: ==0 -- no page table
+	srl		k0, PAGE_SHIFT - 2		#0b: k0=VPN (aka va>>10)
+	andi		k0, k0, 0xff8			#0c: k0=page tab offset
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
-	lw	k0, 0(k1)			#0e: k0=lo0 pte
-	lw	k1, 4(k1)			#0f: k1=lo1 pte
+	lw		k0, 0(k1)			#0e: k0=lo0 pte
+	lw		k1, 4(k1)			#0f: k1=lo1 pte
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO0		#12: lo0 is loaded
+	MTC0		k0, COP_0_TLB_LO0		#12: lo0 is loaded
 	CLEAR_PTE_WIRED(k1)
-	MTC0	k1, COP_0_TLB_LO1		#15: lo1 is loaded
+	MTC0		k1, COP_0_TLB_LO1		#15: lo1 is loaded
 	HAZARD_DELAY
-	tlbwr					#1a: write to tlb
+	tlbwr						#1a: write to tlb
 	HAZARD_DELAY
-	eret					#1f: retUrn from exception
-1:	j	MipsTLBMissException		#20: kernel exception
-	nop					#21: branch delay slot
-2:	j	SlowFault			#22: no page table present
-	nop					#23: branch delay slot
-
-	.set	at
+	eret						#1f: retUrn from exception
+1:	j		MipsTLBMissException		#20: kernel exception
+	nop						#21: branch delay slot
+2:	j		SlowFault			#22: no page table present
+	nop						#23: branch delay slot
+	.set pop
 
 /*
  * This code is copied to the general exception vector address to
@@ -806,78 +805,86 @@ NLEAF(MipsTLBInvalidException)
 	.set noat
 	.set noreorder
 
-	MFC0	k0, COP_0_BAD_VADDR
-	li	k1, VM_MAXUSER_ADDRESS
-	sltu	k1, k0, k1
-	bnez	k1, 1f
+	MFC0		k0, COP_0_BAD_VADDR
+	li		k1, VM_MAXUSER_ADDRESS
+	sltu		k1, k0, k1
+	bnez		k1, 1f
 	nop
 
-	/* badvaddr = kernel address */
-	lui	k1, %hi(kernel_segmap)
-	b	2f
-	PTR_L	k1, %lo(kernel_segmap)(k1)
+	/* Kernel address.  */
+	lui		k1, %hi(kernel_segmap)		# k1=hi of segbase
+	b		2f
+	PTR_L		k1, %lo(kernel_segmap)(k1)	# k1=segment tab base
 
-1:
-	/* badvaddr = user address */
+1:	/* User address.  */
 	GET_CPU_PCPU(k1)
-	PTR_L	k1, PC_SEGBASE(k1)
+	PTR_L		k1, PC_SEGBASE(k1)
 
-2:
-	beqz	k1, 3f			/* invalid page directory pointer */
+2:	/* Validate page directory pointer.  */
+	beqz		k1, 3f
 	nop
 
-	srl	k0, SEGSHIFT - 2
 #if defined(__mips_n64)
-	andi	k0, 0xff8
+	PTR_SRL		k0, SEGSHIFT - 3		# k0=seg offset (almost)
+#else
+	PTR_SRL		k0, SEGSHIFT - 2		# k0=seg offset (almost)
+#endif
+	beq		k1, zero, MipsKernGenException	# ==0 -- no seg tab
+#if defined(__mips_n64)
+	andi		k0, k0, 0x1ff8			# k0=seg offset (mask 0x7)
 #else
-	andi	k0, 0xffc
+	andi		k0, k0, 0xffc			# k0=seg offset (mask 0x3)
 #endif
-	PTR_ADDU	k1, k1, k0
-	PTR_L	k1, 0(k1)
-	beqz	k1, 3f			/* invalid page table page pointer */
+	PTR_ADDU	k1, k0, k1			# k1=seg entry address
+	PTR_L		k1, 0(k1)			# k1=seg entry
+
+	/* Validate page table pointer.  */
+	beqz		k1, 3f
 	nop
 
-	MFC0	k0, COP_0_BAD_VADDR
-	srl	k0, PAGE_SHIFT - 2
-	andi	k0, 0xffc
-	PTR_ADDU	k1, k1, k0
+	MFC0		k0, COP_0_BAD_VADDR		# k0=bad address (again)
+	PTR_SRL		k0, PAGE_SHIFT - 2		# k0=VPN
+	andi		k0, k0, 0xffc			# k0=page tab offset
+	PTR_ADDU	k1, k1, k0			# k1=pte address
+	lw		k0, 0(k1)			# k0=this PTE
 
-	lw	k0, 0(k1)
-	andi	k0, PTE_V
-	beqz	k0, 3f			/* invalid page table entry */
+	/* Validate page table entry.  */
+	andi		k0, PTE_V
+	beqz		k0, 3f
 	nop
 
-	andi	k0, k1, 4
-	bnez	k0, odd_page
+	/* Is this the odd or even entry?  */
+	andi		k0, k1, 4
+	bnez		k0, odd_page
 	nop
 
 even_page:
-	lw	k0, 0(k1)
+	lw		k0, 0(k1)
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO0
+	MTC0		k0, COP_0_TLB_LO0
 
-	lw	k0, 4(k1)
+	lw		k0, 4(k1)
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO1
+	MTC0		k0, COP_0_TLB_LO1
 
-	b	tlb_insert_entry
+	b		tlb_insert_entry
 	nop
 
 odd_page:
-	lw	k0, 0(k1)
+	lw		k0, 0(k1)
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO1
+	MTC0		k0, COP_0_TLB_LO1
 
-	lw	k0, -4(k1)
+	lw		k0, -4(k1)
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO0
+	MTC0		k0, COP_0_TLB_LO0
 
 tlb_insert_entry:
 	tlbp
 	HAZARD_DELAY
-	mfc0	k0, COP_0_TLB_INDEX
+	mfc0		k0, COP_0_TLB_INDEX
 	HAZARD_DELAY
-	bltz	k0, tlb_insert_random
+	bltz		k0, tlb_insert_random
 	nop
 	tlbwi
 	eret
@@ -982,33 +989,36 @@ END(MipsTLBInvalidException)
  */
 NLEAF(MipsTLBMissException)
 	.set	noat
-	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address
-	li	k1, (VM_MAX_KERNEL_ADDRESS)	# check fault address against
-	sltu	k1, k1, k0			# upper bound of kernel_segmap
-	bnez	k1, MipsKernGenException	# out of bound
-	lui	k1, %hi(kernel_segmap)		# k1=hi of segbase
-	srl	k0, 20				# k0=seg offset (almost)
-	PTR_L	k1, %lo(kernel_segmap)(k1)	# k1=segment tab base
-	beq	k1, zero, MipsKernGenException	# ==0 -- no seg tab
+	MFC0		k0, COP_0_BAD_VADDR		# k0=bad address
+	li		k1, VM_MAX_KERNEL_ADDRESS	# check fault address against
+	sltu		k1, k1, k0			# upper bound of kernel_segmap
+	bnez		k1, MipsKernGenException	# out of bound
+	lui		k1, %hi(kernel_segmap)		# k1=hi of segbase
+#if defined(__mips_n64)
+	PTR_SRL		k0, SEGSHIFT - 3		# k0=seg offset (almost)
+#else
+	PTR_SRL		k0, SEGSHIFT - 2		# k0=seg offset (almost)
+#endif
+	PTR_L		k1, %lo(kernel_segmap)(k1)	# k1=segment tab base
+	beq		k1, zero, MipsKernGenException	# ==0 -- no seg tab
 #if defined(__mips_n64)
-	andi	k0, k0, 0xff8			# k0=seg offset (mask 0x7)
+	andi		k0, k0, 0x1ff8			# k0=seg offset (mask 0x7)
 #else
-	andi	k0, k0, 0xffc			# k0=seg offset (mask 0x3)
+	andi		k0, k0, 0xffc			# k0=seg offset (mask 0x3)
 #endif
 	PTR_ADDU	k1, k0, k1			# k1=seg entry address
-	PTR_L	k1, 0(k1)			# k1=seg entry
-	MFC0	k0, COP_0_BAD_VADDR		# k0=bad address (again)
-	beq	k1, zero, MipsKernGenException	# ==0 -- no page table
-	srl	k0, 10				# k0=VPN (aka va>>10)
-	andi	k0, k0, 0xff8			# k0=page tab offset
-#xxx mips64 unsafe
+	PTR_L		k1, 0(k1)			# k1=seg entry
+	MFC0		k0, COP_0_BAD_VADDR		# k0=bad address (again)
+	beq		k1, zero, MipsKernGenException	# ==0 -- no page table
+	PTR_SRL		k0, PAGE_SHIFT - 2		# k0=VPN
+	andi		k0, k0, 0xff8			# k0=page tab offset
 	PTR_ADDU	k1, k1, k0			# k1=pte address
-	lw	k0, 0(k1)			# k0=lo0 pte
-	lw	k1, 4(k1)			# k1=lo1 pte
+	lw		k0, 0(k1)			# k0=lo0 pte
+	lw		k1, 4(k1)			# k1=lo1 pte
 	CLEAR_PTE_WIRED(k0)
-	MTC0	k0, COP_0_TLB_LO0		# lo0 is loaded
+	MTC0		k0, COP_0_TLB_LO0		# lo0 is loaded
 	CLEAR_PTE_WIRED(k1)
-	MTC0	k1, COP_0_TLB_LO1		# lo1 is loaded
+	MTC0		k1, COP_0_TLB_LO1		# lo1 is loaded
 
 	HAZARD_DELAY
 	tlbwr					# write to tlb

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 06:41:46 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 419331065670;
	Fri,  2 Apr 2010 06:41:46 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 311158FC0A;
	Fri,  2 Apr 2010 06:41:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o326fkx4076829;
	Fri, 2 Apr 2010 06:41:46 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o326fktv076827;
	Fri, 2 Apr 2010 06:41:46 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004020641.o326fktv076827@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 2 Apr 2010 06:41:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206080 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 06:41:46 -0000

Author: jmallett
Date: Fri Apr  2 06:41:45 2010
New Revision: 206080
URL: http://svn.freebsd.org/changeset/base/206080

Log:
  Fix a SEGSHIFT use for N64.

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:24:16 2010	(r206079)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Fri Apr  2 06:41:45 2010	(r206080)
@@ -126,7 +126,11 @@ VECTOR_END(MipsTLBMiss)
 	.set noat
 MipsDoTLBMiss:
 	bltz		k0, 1f				#02: k0<0 -> 1f (kernel fault)
-	srl		k0, k0, SEGSHIFT - 2		#03: k0=seg offset (almost)
+#if defined(__mips_n64)
+	PTR_SRL		k0, k0, SEGSHIFT - 3		#03: k0=seg offset (almost)
+#else
+	PTR_SRL		k0, k0, SEGSHIFT - 2		#03: k0=seg offset (almost)
+#endif
 
 	GET_CPU_PCPU(k1)
 	PTR_L		k1, PC_SEGBASE(k1)

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 21:15:43 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0D2EA106564A;
	Fri,  2 Apr 2010 21:15:43 +0000 (UTC)
	(envelope-from kmacy@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F08A38FC12;
	Fri,  2 Apr 2010 21:15:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o32LFgkr078830;
	Fri, 2 Apr 2010 21:15:42 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o32LFg3x078828;
	Fri, 2 Apr 2010 21:15:42 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201004022115.o32LFg3x078828@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Fri, 2 Apr 2010 21:15:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206114 - user/kmacy/head_page_lock/sys/amd64/amd64
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 21:15:43 -0000

Author: kmacy
Date: Fri Apr  2 21:15:42 2010
New Revision: 206114
URL: http://svn.freebsd.org/changeset/base/206114

Log:
  - reduce coverage of pv_lock
  - make pv_entry_count atomic to eliminate pv_lock from the exit path

Modified:
  user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c

Modified: user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c
==============================================================================
--- user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c	Fri Apr  2 21:05:28 2010	(r206113)
+++ user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c	Fri Apr  2 21:15:42 2010	(r206114)
@@ -160,15 +160,13 @@ __FBSDID("$FreeBSD$");
 #define PMAP_INLINE
 #endif
 
-#define PV_STATS
 #ifdef PV_STATS
 #define PV_STAT(x)	do { x ; } while (0)
 #else
 #define PV_STAT(x)	do { } while (0)
 #endif
 
-#define	CACHE_LINE_FETCH_SIZE	128
-#define	PA_LOCK_PAD		CACHE_LINE_FETCH_SIZE
+#define	PA_LOCK_PAD	CACHE_LINE_SIZE
 
 struct vp_lock {
 	struct mtx	vp_lock;
@@ -184,10 +182,10 @@ struct vp_lock {
 #define	PA_UNLOCK(pa)	mtx_unlock(PA_LOCKPTR(pa))
 #define	PA_LOCK_ASSERT(pa, a)	mtx_assert(PA_LOCKPTR(pa), (a))
 
-#define	PA_LOCK_COUNT	64
+#define	PA_LOCK_COUNT	256
 
-struct mtx pv_lock __aligned(128);
-struct vp_lock pa_lock[PA_LOCK_COUNT] __aligned(128);
+struct mtx pv_lock __aligned(CACHE_LINE_SIZE);
+struct vp_lock pa_lock[PA_LOCK_COUNT] __aligned(CACHE_LINE_SIZE);
 
 
 struct pmap kernel_pmap_store;
@@ -228,7 +226,8 @@ static u_int64_t	DMPDPphys;	/* phys addr
 /*
  * Data for the pv entry allocation mechanism
  */
-static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0;
+static int pv_entry_count __aligned(CACHE_LINE_SIZE);
+static int pv_entry_max = 0, pv_entry_high_water = 0;
 static struct md_page *pv_table;
 static int shpgperproc = PMAP_SHPGPERPROC;
 
@@ -313,18 +312,24 @@ ls_init(struct lock_stack *ls)
 	ls->ls_top = 0;
 }
 
+
+#define ls_push(ls, m)	_ls_push((ls), (m), LOCK_FILE, LOCK_LINE)
+
 static void
-ls_push(struct lock_stack *ls, struct mtx *lock)
+_ls_push(struct lock_stack *ls, struct mtx *lock, char *file, int line)
 {
 
 	KASSERT(ls->ls_top < LS_MAX, ("lock stack overflow"));
 	
 	ls->ls_array[ls->ls_top] = lock;
 	ls->ls_top++;
-	mtx_lock(lock);
+#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE)	
+	_mtx_lock_flags(lock, 0, file, line);
+#else
+	_get_sleep_lock(lock, curthread, 0, file, line);
+#endif
 }
 
-
 static int
 ls_trypush(struct lock_stack *ls, struct mtx *lock)
 {
@@ -542,9 +547,9 @@ pa_tryrelock(pmap_t pmap, vm_paddr_t pa,
 	if (PA_TRYLOCK(pa))
 		return 0;
 	PMAP_UNLOCK(pmap);
+	atomic_add_int((volatile int *)&pmap_tryrelock_restart, 1);
 	PA_LOCK(pa);
 	PMAP_LOCK(pmap);
-	atomic_add_int((volatile int *)&pmap_tryrelock_restart, 1);
 
 	return (EAGAIN);
 }
@@ -2122,10 +2127,11 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	int idx, field, bit;
 
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
-	mtx_lock(&pv_lock);
+
+	atomic_add_int(&pv_entry_count, -1);
 	PV_STAT(pv_entry_frees++);
 	PV_STAT(pv_entry_spare++);
-	pv_entry_count--;
+	mtx_lock(&pv_lock);
 	pc = pv_to_chunk(pv);
 	idx = pv - &pc->pc_pventry[0];
 	field = idx / 64;
@@ -2169,9 +2175,10 @@ get_pv_entry(pmap_t pmap)
 	vm_page_t m;
 
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
-	mtx_lock(&pv_lock);
+
+	atomic_add_int(&pv_entry_count, 1);
 	PV_STAT(pv_entry_allocs++);
-	pv_entry_count++;
+	mtx_lock(&pv_lock);
 	if (pv_entry_count > pv_entry_high_water)
 		if (ratecheck(&lastprint, &printinterval))
 			printf("Approaching the limit on PV entries, consider "
@@ -2195,8 +2202,8 @@ get_pv_entry(pmap_t pmap)
 				TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
 				TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list);
 			}
-			PV_STAT(pv_entry_spare--);
 			mtx_unlock(&pv_lock);
+			PV_STAT(pv_entry_spare--);
 			return (pv);
 		}
 	}
@@ -2205,9 +2212,9 @@ get_pv_entry(pmap_t pmap)
 	    VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL) | VM_ALLOC_NOOBJ |
 	    VM_ALLOC_WIRED);
 	if (m == NULL) {
-		pv_entry_count--;
-		PV_STAT(pc_chunk_tryfail++);
 		mtx_unlock(&pv_lock);
+		PV_STAT(pc_chunk_tryfail++);
+		atomic_add_int(&pv_entry_count, -1);
 		return (NULL);
 	}
 	PV_STAT(pc_chunk_count++);
@@ -4366,12 +4373,10 @@ restart:
 					} else
 						vm_page_dirty(m);
 				}
-				mtx_lock(&pv_lock);
 				/* Mark free */
 				PV_STAT(pv_entry_frees++);
 				PV_STAT(pv_entry_spare++);
-				pv_entry_count--;
-				mtx_unlock(&pv_lock);
+				atomic_add_int(&pv_entry_count, -1);
 				pc->pc_map[field] |= bitmask;
 				if ((tpte & PG_PS) != 0) {
 					pmap->pm_stats.resident_count -= NBPDR / PAGE_SIZE;

From owner-svn-src-user@FreeBSD.ORG  Fri Apr  2 21:35:10 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B3B481065670;
	Fri,  2 Apr 2010 21:35:10 +0000 (UTC)
	(envelope-from kmacy@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 974B08FC0C;
	Fri,  2 Apr 2010 21:35:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o32LZA9f083129;
	Fri, 2 Apr 2010 21:35:10 GMT (envelope-from kmacy@svn.freebsd.org)
Received: (from kmacy@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o32LZA3e083127;
	Fri, 2 Apr 2010 21:35:10 GMT (envelope-from kmacy@svn.freebsd.org)
Message-Id: <201004022135.o32LZA3e083127@svn.freebsd.org>
From: Kip Macy <kmacy@FreeBSD.org>
Date: Fri, 2 Apr 2010 21:35:10 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206115 - user/kmacy/head_page_lock/sys/amd64/amd64
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Apr 2010 21:35:10 -0000

Author: kmacy
Date: Fri Apr  2 21:35:10 2010
New Revision: 206115
URL: http://svn.freebsd.org/changeset/base/206115

Log:
  -remove pv list lock
   - spare pv entries are protected by the pmap lock and the md_page
     pv_list is protected by the page lock

Modified:
  user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c

Modified: user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c
==============================================================================
--- user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c	Fri Apr  2 21:15:42 2010	(r206114)
+++ user/kmacy/head_page_lock/sys/amd64/amd64/pmap.c	Fri Apr  2 21:35:10 2010	(r206115)
@@ -184,7 +184,6 @@ struct vp_lock {
 
 #define	PA_LOCK_COUNT	256
 
-struct mtx pv_lock __aligned(CACHE_LINE_SIZE);
 struct vp_lock pa_lock[PA_LOCK_COUNT] __aligned(CACHE_LINE_SIZE);
 
 
@@ -720,7 +719,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 	for (i = 0; i < PA_LOCK_COUNT; i++)
 		mtx_init(&pa_lock[i].vp_lock, "page lock", NULL,
 		    MTX_DEF | MTX_RECURSE | MTX_DUPOK);
-	mtx_init(&pv_lock, "pv list lock", NULL, MTX_DEF);
 
 }
 
@@ -2131,7 +2129,6 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	atomic_add_int(&pv_entry_count, -1);
 	PV_STAT(pv_entry_frees++);
 	PV_STAT(pv_entry_spare++);
-	mtx_lock(&pv_lock);
 	pc = pv_to_chunk(pv);
 	idx = pv - &pc->pc_pventry[0];
 	field = idx / 64;
@@ -2142,7 +2139,6 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 ||
 	    pc->pc_map[2] != PC_FREE2) {
 		TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
-		mtx_unlock(&pv_lock);
 		return;
 	}
 	PV_STAT(pv_entry_spare -= _NPCPV);
@@ -2151,7 +2147,6 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	/* entire chunk is free, return it */
 	m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
 	dump_drop_page(m->phys_addr);
-	mtx_unlock(&pv_lock);
 	KASSERT(m->wire_count == 1, ("wire_count == %d", m->wire_count));
 	m->wire_count--;
 	atomic_subtract_int(&cnt.v_wire_count, 1);
@@ -2178,7 +2173,6 @@ get_pv_entry(pmap_t pmap)
 
 	atomic_add_int(&pv_entry_count, 1);
 	PV_STAT(pv_entry_allocs++);
-	mtx_lock(&pv_lock);
 	if (pv_entry_count > pv_entry_high_water)
 		if (ratecheck(&lastprint, &printinterval))
 			printf("Approaching the limit on PV entries, consider "
@@ -2202,7 +2196,6 @@ get_pv_entry(pmap_t pmap)
 				TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
 				TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list);
 			}
-			mtx_unlock(&pv_lock);
 			PV_STAT(pv_entry_spare--);
 			return (pv);
 		}
@@ -2212,7 +2205,6 @@ get_pv_entry(pmap_t pmap)
 	    VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL) | VM_ALLOC_NOOBJ |
 	    VM_ALLOC_WIRED);
 	if (m == NULL) {
-		mtx_unlock(&pv_lock);
 		PV_STAT(pc_chunk_tryfail++);
 		atomic_add_int(&pv_entry_count, -1);
 		return (NULL);
@@ -2230,7 +2222,6 @@ get_pv_entry(pmap_t pmap)
 	TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
 	PV_STAT(pv_entry_spare += _NPCPV - 1);
 
-	mtx_unlock(&pv_lock);
 	return (pv);
 }
 
@@ -4410,14 +4401,12 @@ restart:
 			}
 		}
 		if (allfree) {
-			mtx_lock(&pv_lock);
 			PV_STAT(pv_entry_spare -= _NPCPV);
 			PV_STAT(pc_chunk_count--);
 			PV_STAT(pc_chunk_frees++);
 			TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
 			m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
 			dump_drop_page(m->phys_addr);
-			mtx_unlock(&pv_lock);
 			KASSERT(m->wire_count == 1,
 			    ("wire_count == %d", m->wire_count));
 			m->wire_count = 0;

From owner-svn-src-user@FreeBSD.ORG  Sat Apr  3 03:31:15 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15D1E106566C;
	Sat,  3 Apr 2010 03:31:14 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BC2858FC08;
	Sat,  3 Apr 2010 03:31:14 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o333VECv065136;
	Sat, 3 Apr 2010 03:31:14 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o333VEYm065124;
	Sat, 3 Apr 2010 03:31:14 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004030331.o333VEYm065124@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sat, 3 Apr 2010 03:31:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206119 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Apr 2010 03:31:15 -0000

Author: jmallett
Date: Sat Apr  3 03:31:14 2010
New Revision: 206119
URL: http://svn.freebsd.org/changeset/base/206119

Log:
  Checkpoint a WIP...
  o) Move to 8K pages from 4K pages and use a single PTE to populate TLBLo0 and
     TLBLo1, with the PFN adjusted appropriately in TLBLo1.
  o) Keep the same kstack and uarea size (8K) and move to using a single page for
     both.
  
     Note that we can remove the awkward (and broken) allocation of 3 pages to
     get a kstack and the subsequent modification to ensure that the kstack would
     not have to share its TLB entry and would fit into a single TLB entry.
  
     This means we can also remove mdthread's realstack.
  o) Likewise remove similar balancing acts in fpage allocation.
  o) Don't use pmap_update_page in pmap_kenter, use pmap_invalidate_page.  We do
     a lot of pmap_kenter calls in a row at early startup in particular and it
     doesn't make sense to keep thrashing the TLB.

Modified:
  user/jmallett/octeon/sys/mips/include/param.h
  user/jmallett/octeon/sys/mips/include/proc.h
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/mips/exception.S
  user/jmallett/octeon/sys/mips/mips/genassym.c
  user/jmallett/octeon/sys/mips/mips/machdep.c
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/swtch.S
  user/jmallett/octeon/sys/mips/mips/tlb.S
  user/jmallett/octeon/sys/mips/mips/trap.c
  user/jmallett/octeon/sys/mips/mips/vm_machdep.c

Modified: user/jmallett/octeon/sys/mips/include/param.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/param.h	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/include/param.h	Sat Apr  3 03:31:14 2010	(r206119)
@@ -102,26 +102,20 @@
 #define	CACHE_LINE_SHIFT	6
 #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
 
-#define	PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
+#define	PAGE_SHIFT	13		/* LOG2(PAGE_SIZE) */
 #define	PAGE_SIZE	(1<<PAGE_SHIFT) /* bytes/page */
 #define	PAGE_MASK	(PAGE_SIZE-1)
 #define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
 
 #define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
 
-#define	BLKDEV_IOSIZE	2048		/* xxx: Why is this 1/2 page? */
+#define	BLKDEV_IOSIZE	2048		/* xxx: Why is this 1/4 page? */
 #define	MAXDUMPPGS	1		/* xxx: why is this only one? */
 
-/*
- * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
- *
- * Although we allocate 3 pages for the kernel stack we end up using
- * only the 2 pages that are aligned on a (PAGE_SIZE * 2) boundary.
- */
-#define	KSTACK_PAGES		3	/* kernel stack*/
+#define	KSTACK_PAGES		1	/* kernel stack*/
 #define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
 
-#define	UPAGES			2
+#define	UPAGES			1
 
 /* pages ("clicks") (4096 bytes) to disk blocks */
 #define	ctod(x)		((x) << (PAGE_SHIFT - DEV_BSHIFT))

Modified: user/jmallett/octeon/sys/mips/include/proc.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/proc.h	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/include/proc.h	Sat Apr  3 03:31:14 2010	(r206119)
@@ -44,7 +44,7 @@
  */
 struct mdthread {
 	int	md_flags;		/* machine-dependent flags */
-	int	md_upte[KSTACK_PAGES - 1]; /* ptes for mapping u pcb */
+	int	md_upte[KSTACK_PAGES];	/* ptes for mapping u pcb */
 	int	md_ss_addr;		/* single step address for ptrace */
 	int	md_ss_instr;		/* single step instruction for ptrace */
 	register_t	md_saved_intr;
@@ -53,7 +53,6 @@ struct mdthread {
 	int	md_pc_ctrl;		/* performance counter control */
 	int	md_pc_count;		/* performance counter */
 	int	md_pc_spill;		/* performance counter spill */
-	vm_offset_t	md_realstack;
 	void	*md_tls;
 };
 

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 03:31:14 2010	(r206119)
@@ -102,7 +102,7 @@ typedef pt_entry_t *pd_entry_t;
 /*#define	PTE_NV		0x00000000       Not Used */
 #define	PTE_M		0x00000004
 #define	PTE_RW		PTE_M
-#define PTE_ODDPG       0x00001000 
+#define PTE_ODDPG       0x00000040 
 /*#define	PG_ATTR		0x0000003f  Not Used */
 #define	PTE_UNCACHED	0x00000010
 #ifdef CPU_SB1
@@ -119,10 +119,11 @@ typedef pt_entry_t *pd_entry_t;
 #define PTE_HVPN        0xffffe000      /* Hardware page no mask */
 #define PTE_ASID        0x000000ff      /* Address space ID */
 
+#define	TLB_PAGE_SHIFT	(PAGE_SHIFT - 1)
 #define	PTE_SHIFT	6
 #define	pfn_is_ext(x)	((x) & 0x3c000000)
-#define	vad_to_pfn(x)	(((vm_offset_t)(x) >> PTE_SHIFT) & PTE_FRAME)
-#define	pfn_to_vad(x)	(((x) & PTE_FRAME) << PTE_SHIFT)
+#define	vad_to_pfn(x)	((((vm_offset_t)(x) >> TLB_PAGE_SHIFT) << PTE_SHIFT) & PTE_FRAME)
+#define	pfn_to_vad(x)	((((x) & PTE_FRAME) >> PTE_SHIFT) << TLB_PAGE_SHIFT)
 
 /* User virtual to pte offset in page table */
 #define	vad_to_pte_offset(adr)	(((adr) >> PAGE_SHIFT) & (NPTEPG -1))

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 03:31:14 2010	(r206119)
@@ -148,11 +148,10 @@ MipsDoTLBMiss:
 	andi		k0, k0, 0xff8			#0c: k0=page tab offset
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
 	lw		k0, 0(k1)			#0e: k0=lo0 pte
-	lw		k1, 4(k1)			#0f: k1=lo1 pte
 	CLEAR_PTE_WIRED(k0)
 	MTC0		k0, COP_0_TLB_LO0		#12: lo0 is loaded
-	CLEAR_PTE_WIRED(k1)
-	MTC0		k1, COP_0_TLB_LO1		#15: lo1 is loaded
+	addu		k0, PTE_ODDPG
+	MTC0		k0, COP_0_TLB_LO1		#15: lo1 is loaded
 	HAZARD_DELAY
 	tlbwr						#1a: write to tlb
 	HAZARD_DELAY
@@ -857,33 +856,12 @@ NLEAF(MipsTLBInvalidException)
 	beqz		k0, 3f
 	nop
 
-	/* Is this the odd or even entry?  */
-	andi		k0, k1, 4
-	bnez		k0, odd_page
-	nop
-
-even_page:
 	lw		k0, 0(k1)
 	CLEAR_PTE_WIRED(k0)
 	MTC0		k0, COP_0_TLB_LO0
-
-	lw		k0, 4(k1)
-	CLEAR_PTE_WIRED(k0)
-	MTC0		k0, COP_0_TLB_LO1
-
-	b		tlb_insert_entry
-	nop
-
-odd_page:
-	lw		k0, 0(k1)
-	CLEAR_PTE_WIRED(k0)
+	addu		k0, PTE_ODDPG
 	MTC0		k0, COP_0_TLB_LO1
 
-	lw		k0, -4(k1)
-	CLEAR_PTE_WIRED(k0)
-	MTC0		k0, COP_0_TLB_LO0
-
-tlb_insert_entry:
 	tlbp
 	HAZARD_DELAY
 	mfc0		k0, COP_0_TLB_INDEX
@@ -913,7 +891,7 @@ tlb_insert_random:
 	 */
 	GET_CPU_PCPU(k1)
 	PTR_L	k0, PC_CURTHREAD(k1)
-	PTR_L	k0, TD_REALKSTACK(k0)
+	PTR_L	k0, TD_KSTACK(k0)
 	sltu	k0, k0, sp
 	bnez	k0, _C_LABEL(MipsKernGenException)
 	nop
@@ -929,7 +907,7 @@ tlb_insert_random:
 	sll	k1, k1, PAGE_SHIFT + 1
 
 	PTR_LA	k0, _C_LABEL(pcpu_space)
-	PTR_ADDU	k0, (PAGE_SIZE * 2)
+	PTR_ADDU	k0, PAGE_SIZE * 2
 	PTR_ADDU	k0, k0, k1
 
 	/*
@@ -960,7 +938,7 @@ tlb_insert_random:
 	 */
 	GET_CPU_PCPU(k1)
 	PTR_L	k0, PC_CURTHREAD(k1)
-	PTR_S	zero, TD_REALKSTACK(k0)
+	PTR_S	zero, TD_KSTACK(k0)
 
 	move	a1, a0
 	PANIC("kernel stack overflow - trapframe at %p")
@@ -1018,12 +996,10 @@ NLEAF(MipsTLBMissException)
 	andi		k0, k0, 0xff8			# k0=page tab offset
 	PTR_ADDU	k1, k1, k0			# k1=pte address
 	lw		k0, 0(k1)			# k0=lo0 pte
-	lw		k1, 4(k1)			# k1=lo1 pte
 	CLEAR_PTE_WIRED(k0)
 	MTC0		k0, COP_0_TLB_LO0		# lo0 is loaded
-	CLEAR_PTE_WIRED(k1)
-	MTC0		k1, COP_0_TLB_LO1		# lo1 is loaded
-
+	addu		k0, PTE_ODDPG
+	MTC0		k0, COP_0_TLB_LO1		# lo1 is loaded
 	HAZARD_DELAY
 	tlbwr					# write to tlb
 	HAZARD_DELAY

Modified: user/jmallett/octeon/sys/mips/mips/genassym.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/genassym.c	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/genassym.c	Sat Apr  3 03:31:14 2010	(r206119)
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
 
 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
 ASSYM(TD_UPTE, offsetof(struct thread, td_md.md_upte));
-ASSYM(TD_REALKSTACK, offsetof(struct thread, td_md.md_realstack));
+ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack));
 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
 ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
 ASSYM(TD_FRAME, offsetof(struct thread, td_frame));

Modified: user/jmallett/octeon/sys/mips/mips/machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/machdep.c	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/machdep.c	Sat Apr  3 03:31:14 2010	(r206119)
@@ -302,14 +302,13 @@ mips_proc0_init(void)
 		(long)kstack0));
 	thread0.td_kstack = kstack0;
 	thread0.td_kstack_pages = KSTACK_PAGES;
-	thread0.td_md.md_realstack = roundup2(thread0.td_kstack, PAGE_SIZE * 2);
 	/* 
 	 * Do not use cpu_thread_alloc to initialize these fields 
 	 * thread0 is the only thread that has kstack located in KSEG0 
 	 * while cpu_thread_alloc handles kstack allocated in KSEG2.
 	 */
-	thread0.td_pcb = (struct pcb *)(thread0.td_md.md_realstack +
-	    (thread0.td_kstack_pages - 1) * PAGE_SIZE) - 1;
+	thread0.td_pcb = (struct pcb *)(thread0.td_kstack +
+	    thread0.td_kstack_pages * PAGE_SIZE) - 1;
 	thread0.td_frame = &thread0.td_pcb->pcb_regs;
 
 	/* Steal memory for the dynamic per-cpu area. */

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 03:31:14 2010	(r206119)
@@ -729,7 +729,13 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 	opte = *pte;
 	*pte = npte;
 
-	pmap_update_page(kernel_pmap, va, npte);
+	/*
+	 * The original code did an update_page() here, but
+	 * we often do a lot of pmap_kenter() calls and then
+	 * start using the addresses later, at which point
+	 * the TLB has overflown many times.
+	 */
+	pmap_invalidate_page(kernel_pmap, va);
 }
 
 /*
@@ -851,36 +857,11 @@ pmap_init_fpage()
 	int i, j;
 	struct sysmaps *sysmaps;
 
-	/*
-	 * We allocate a total of (FPAGES*MAXCPU + FPAGES_SHARED + 1) pages
-	 * at first. FPAGES & FPAGES_SHARED should be EVEN Then we'll adjust
-	 * 'kva' to be even-page aligned so that the fpage area can be wired
-	 * in the TLB with a single TLB entry.
-	 */
 	kva = kmem_alloc_nofault(kernel_map,
-	    (FPAGES * MAXCPU + 1 + FPAGES_SHARED) * PAGE_SIZE);
+	    (FPAGES * MAXCPU + FPAGES_SHARED) * PAGE_SIZE);
 	if ((void *)kva == NULL)
 		panic("pmap_init_fpage: fpage allocation failed");
 
-	/*
-	 * Make up start at an even page number so we can wire down the
-	 * fpage area in the tlb with a single tlb entry.
-	 */
-	if ((((vm_offset_t)kva) >> PAGE_SHIFT) & 1) {
-		/*
-		 * 'kva' is not even-page aligned. Adjust it and free the
-		 * first page which is unused.
-		 */
-		kmem_free(kernel_map, (vm_offset_t)kva, PAGE_SIZE);
-		kva = ((vm_offset_t)kva) + PAGE_SIZE;
-	} else {
-		/*
-		 * 'kva' is even page aligned. We don't need the last page,
-		 * free it.
-		 */
-		kmem_free(kernel_map, ((vm_offset_t)kva) + FSPACE, PAGE_SIZE);
-	}
-
 	for (i = 0; i < MAXCPU; i++) {
 		sysmaps = &sysmaps_pcpu[i];
 		mtx_init(&sysmaps->lock, "SYSMAPS", NULL, MTX_DEF);

Modified: user/jmallett/octeon/sys/mips/mips/swtch.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/swtch.S	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/swtch.S	Sat Apr  3 03:31:14 2010	(r206119)
@@ -293,36 +293,28 @@ blocked_loop:
 	PTR_S	a1, PC_CURTHREAD(a3)
 	PTR_L	a2, TD_PCB(a1)
 	PTR_S	a2, PC_CURPCB(a3)
-	PTR_L	v0, TD_REALKSTACK(a1)
+	PTR_L	v0, TD_KSTACK(a1)
 	li	s0, (MIPS_KSEG2_START+VM_KERNEL_ALLOC_OFFSET)		# If Uarea addr is below kseg2,
 	bltu	v0, s0, sw2			# no need to insert in TLB.
-	lw	a1, TD_UPTE+0(s7)		# t0 = first u. pte
-	lw	a2, TD_UPTE+4(s7)		# t1 = 2nd u. pte
-	and	s0, v0, PTE_ODDPG
-	beq	s0, zero, entry0
-	nop
-
-	PANIC_KSEG0("USPACE sat on odd page boundary", t1)
-
+	lw	a1, TD_UPTE(s7)			# t0 = u. pte
 /*
  * Wiredown the USPACE of newproc in TLB entry#0.  Check whether target
  * USPACE is already in another place of TLB before that, and if so
  * invalidate that TLB entry.
- * NOTE: This is hard coded to UPAGES == 2.
+ * NOTE: This is hard coded to UPAGES == 1.
  * Also, there should be no TLB faults at this point.
  */
-entry0:
-	mtc0	v0, COP_0_TLB_HI		# VPN = va
+	MTC0	v0, COP_0_TLB_HI		# VPN = va
 	HAZARD_DELAY
 	tlbp					# probe VPN
 	HAZARD_DELAY
 	mfc0	s0, COP_0_TLB_INDEX
 	nop
-pgm:
-	REG_LI	t1, MIPS_KSEG0_START		# invalidate tlb entry
+
+	li	t1, MIPS_KSEG0_START		# invalidate tlb entry
 	bltz	s0, entry0set
 	nop
-	sll	s0, PAGE_SHIFT + 1
+	sll	s0, PAGE_SHIFT
 	addu	t1, s0
 	mtc0	t1, COP_0_TLB_HI
 	mtc0	zero, COP_0_TLB_LO0
@@ -331,13 +323,13 @@ pgm:
 	tlbwi
 	HAZARD_DELAY
 	mtc0	v0, COP_0_TLB_HI		# set VPN again
+
 entry0set:
 /* SMP!! - Works only for  unshared TLB case - i.e. no v-cpus */
 	mtc0	zero, COP_0_TLB_INDEX		# TLB entry #0
-#	or	a1, PG_G
-	mtc0	a1, COP_0_TLB_LO0		# upte[0]
-#	or	a2, PG_G
-	mtc0	a2, COP_0_TLB_LO1		# upte[1]
+	mtc0	a1, COP_0_TLB_LO0		# upte
+	addu	a1, PTE_ODDPG
+	mtc0	a1, COP_0_TLB_LO1		# upte + odd
 	HAZARD_DELAY
 	tlbwi					# set TLB entry #0
 	HAZARD_DELAY

Modified: user/jmallett/octeon/sys/mips/mips/tlb.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/tlb.S	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/tlb.S	Sat Apr  3 03:31:14 2010	(r206119)
@@ -152,10 +152,10 @@ LEAF(Mips_TLBFlush)
 	#
 	# Load invalid entry, each TLB entry should have it's own bogus 
 	# address calculated by following expression:
-	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
+	# MIPS_KSEG0_START + i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
 	#
-	sll	t3, t1, PAGE_SHIFT + 1
+	sll	t3, t1, PAGE_SHIFT
 	li	v0, MIPS_KSEG0_START		# invalid address
 	addu	v0, t3
 /*
@@ -166,7 +166,7 @@ LEAF(Mips_TLBFlush)
 	ITLBNOPFIX
 	MTC0	v0, COP_0_TLB_HI		# Mark entry high as invalid
 	addu	t1, t1, 1			# Increment index.
-	addu	v0, v0, 8 * 1024
+	addu	v0, v0, PAGE_SIZE
 	MIPS_CPU_NOP_DELAY
 	tlbwi					# Write the TLB entry.
 	MIPS_CPU_NOP_DELAY
@@ -212,9 +212,9 @@ LEAF(Mips_TLBFlushAddr)
 	nop
 	# Load invalid entry, each TLB entry should have it's own bogus 
 	# address calculated by following expression:
-	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
+	# MIPS_KSEG0_START + i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
-	sll	v0, PAGE_SHIFT + 1
+	sll	v0, PAGE_SHIFT
 	addu	t1, v0
 	MTC0	t1, COP_0_TLB_HI		# Mark entry high as invalid
 
@@ -250,26 +250,24 @@ LEAF(Mips_TLBUpdate)
 	mfc0	v1, COP_0_STATUS_REG		# Save the status register.
 	mtc0	zero, COP_0_STATUS_REG		# Disable interrupts
 	ITLBNOPFIX
-	and	t1, a0, 0x1000			# t1 = Even/Odd flag
 	li	v0, (PTE_HVPN | PTE_ASID)
 	and	a0, a0, v0
 	MFC0	t0, COP_0_TLB_HI		# Save current PID
 	MTC0	a0, COP_0_TLB_HI		# Init high reg
-	and	a2, a1, PTE_G			# Copy global bit
 	MIPS_CPU_NOP_DELAY
 	tlbp					# Probe for the entry.
 	CLEAR_PTE_WIRED(a1)
 	nop
+
 	mfc0	v0, COP_0_TLB_INDEX		# See what we got
-	bne	t1, zero, 2f			# Decide even odd
-# EVEN
-	nop
 	bltz	v0, 1f				# index < 0 => !found
 	MIPS_CPU_NOP_DELAY
 
 	tlbr					# update, read entry first
 	MIPS_CPU_NOP_DELAY
 	MTC0	a1, COP_0_TLB_LO0		# init low reg0.
+	addu	a1, PTE_ODDPG
+	MTC0	a1, COP_0_TLB_LO1		# init low reg1.
 	MIPS_CPU_NOP_DELAY
 	tlbwi					# update slot found
 	b	4f
@@ -278,34 +276,11 @@ LEAF(Mips_TLBUpdate)
 	mtc0	zero, COP_0_TLB_PG_MASK 	# init mask.
 	MTC0	a0, COP_0_TLB_HI		# init high reg.
 	MTC0	a1, COP_0_TLB_LO0		# init low reg0.
-	MTC0	a2, COP_0_TLB_LO1		# init low reg1.
-	MIPS_CPU_NOP_DELAY
-	tlbwr					# enter into a random slot
-	MIPS_CPU_NOP_DELAY
-	b	4f
-	nop
-# ODD
-2:
-	nop
-	bltz	v0, 3f				# index < 0 => !found
-	MIPS_CPU_NOP_DELAY
-
-	tlbr					# read the entry first
-	MIPS_CPU_NOP_DELAY
-	MTC0	a1, COP_0_TLB_LO1		# init low reg1.
-	MIPS_CPU_NOP_DELAY
-	tlbwi					# update slot found
-	MIPS_CPU_NOP_DELAY
-	b	4f
-	nop
-3:
-	mtc0	zero, COP_0_TLB_PG_MASK		# init mask.
-	MTC0	a0, COP_0_TLB_HI		# init high reg.
-	MTC0	a2, COP_0_TLB_LO0		# init low reg0.
+	addu	a1, PTE_ODDPG
 	MTC0	a1, COP_0_TLB_LO1		# init low reg1.
 	MIPS_CPU_NOP_DELAY
 	tlbwr					# enter into a random slot
-
+	MIPS_CPU_NOP_DELAY
 4:						# Make shure pipeline
 	MIPS_CPU_NOP_DELAY
 	MTC0	t0, COP_0_TLB_HI		# restore PID
@@ -373,10 +348,10 @@ LEAF(mips_TBIAP)
 	#
 	# Load invalid entry, each TLB entry should have it's own bogus 
 	# address calculated by following expression:
-	# MIPS_KSEG0_START + 2 * i * PAGE_SIZE;
+	# MIPS_KSEG0_START + i * PAGE_SIZE;
 	# One bogus value for every TLB entry might cause MCHECK exception
 	#
-	sll	t3, t1, PAGE_SHIFT + 1
+	sll	t3, t1, PAGE_SHIFT
 	li	v0, MIPS_KSEG0_START		# invalid address
 	addu	v0, t3
 
@@ -401,7 +376,7 @@ LEAF(mips_TBIAP)
 	tlbwi					# invalidate the TLB entry
 2:
 	addu	t1, t1, 1
-	addu	v0, 1 << (PAGE_SHIFT + 1)
+	addu	v0, PAGE_SIZE
 	bne	t1, t2, 1b
 	nop
 

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Sat Apr  3 03:31:14 2010	(r206119)
@@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/syslog.h>
 
 
+#define TRAP_DEBUG
 #ifdef TRAP_DEBUG
 int trap_debug = 1;
 #endif

Modified: user/jmallett/octeon/sys/mips/mips/vm_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sat Apr  3 00:47:48 2010	(r206118)
+++ user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sat Apr  3 03:31:14 2010	(r206119)
@@ -215,16 +215,6 @@ cpu_thread_swapin(struct thread *td)
 {
 	pt_entry_t *pte;
 	int i;
-	vm_offset_t unused_kstack_page;
-
-	/*
-	 * Unmap the unused kstack page.
-	 */
-	unused_kstack_page = td->td_kstack;
-	if (td->td_md.md_realstack == td->td_kstack)
-		unused_kstack_page += (KSTACK_PAGES - 1) * PAGE_SIZE;
-
-	pmap_kremove(unused_kstack_page);
 
 	/*
 	 * The kstack may be at a different physical address now.
@@ -232,11 +222,11 @@ cpu_thread_swapin(struct thread *td)
 	 * part of the thread struct so cpu_switch() can quickly map in
 	 * the pcb struct and kernel stack.
 	 */
-	if (!(pte = pmap_segmap(kernel_pmap, td->td_md.md_realstack)))
+	if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack)))
 		panic("cpu_thread_swapin: invalid segmap");
-	pte += ((vm_offset_t)td->td_md.md_realstack >> PAGE_SHIFT) & (NPTEPG - 1);
+	pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1);
 
-	for (i = 0; i < KSTACK_PAGES - 1; i++) {
+	for (i = 0; i < KSTACK_PAGES; i++) {
 		td->td_md.md_upte[i] = *pte & ~(PTE_RO|PTE_WIRED);
 		pte++;
 	}
@@ -250,29 +240,18 @@ cpu_thread_swapout(struct thread *td)
 void
 cpu_thread_alloc(struct thread *td)
 {
-	vm_offset_t unused_kstack_page;
 	pt_entry_t *pte;
 	int i;
 
-	if (td->td_kstack & (1 << PAGE_SHIFT)) {
-		td->td_md.md_realstack = td->td_kstack + PAGE_SIZE;
-		unused_kstack_page = td->td_kstack;
-	} else {
-		td->td_md.md_realstack = td->td_kstack;
-		unused_kstack_page = td->td_kstack +
-					(KSTACK_PAGES - 1) * PAGE_SIZE;
-	}
-	pmap_kremove(unused_kstack_page);
-
-	td->td_pcb = (struct pcb *)(td->td_md.md_realstack +
-	    (td->td_kstack_pages - 1) * PAGE_SIZE) - 1;
+	td->td_pcb = (struct pcb *)(td->td_kstack +
+	    td->td_kstack_pages * PAGE_SIZE) - 1;
 	td->td_frame = &td->td_pcb->pcb_regs;
 
-	if (!(pte = pmap_segmap(kernel_pmap, td->td_md.md_realstack)))
+	if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack)))
 		panic("cpu_thread_alloc: invalid segmap");
-	pte += ((vm_offset_t)td->td_md.md_realstack >> PAGE_SHIFT) & (NPTEPG - 1);
+	pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1);
 
-	for (i = 0; i < KSTACK_PAGES - 1; i++) {
+	for (i = 0; i < KSTACK_PAGES; i++) {
 		td->td_md.md_upte[i] = *pte & ~(PTE_RO|PTE_WIRED);
 		pte++;
 	}

From owner-svn-src-user@FreeBSD.ORG  Sat Apr  3 07:12:04 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5B1601065670;
	Sat,  3 Apr 2010 07:12:04 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 490158FC0C;
	Sat,  3 Apr 2010 07:12:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o337C4OQ013473;
	Sat, 3 Apr 2010 07:12:04 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o337C4Pk013459;
	Sat, 3 Apr 2010 07:12:04 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004030712.o337C4Pk013459@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sat, 3 Apr 2010 07:12:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206120 - in user/jmallett/octeon/sys: conf
	mips/include mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Apr 2010 07:12:04 -0000

Author: jmallett
Date: Sat Apr  3 07:12:03 2010
New Revision: 206120
URL: http://svn.freebsd.org/changeset/base/206120

Log:
  o) Provide an interface to basic TLB operations one might want to do in C
     in C using inline assembly.
  o) Remove duplication of various PTE bits by switching to my <machine/pte.h>
     and converting existing code to use it.
  o) Rename CLEAR_PTE_WIRED to CLEAR_PTE_SWBITS since it clears PG_W and PG_RO.
  o) Be consistent in how PTE bits are tested, set and cleared, except where
     there is a change beyond simply clearing or setting bits.
  o) Un-generalize a couple of pmap functions used in only one place.
  o) Provide a convenient helper macro for getting the ASID.
  o) Remove unused TLB access routines from cpufunc.h since they can live very
     comfortably in tlb.c now.

Added:
  user/jmallett/octeon/sys/mips/include/tlb.h
  user/jmallett/octeon/sys/mips/mips/tlb.c
Deleted:
  user/jmallett/octeon/sys/mips/mips/tlb.S
Modified:
  user/jmallett/octeon/sys/conf/files.mips
  user/jmallett/octeon/sys/mips/include/cpu.h
  user/jmallett/octeon/sys/mips/include/cpufunc.h
  user/jmallett/octeon/sys/mips/include/pmap.h
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/include/vm.h
  user/jmallett/octeon/sys/mips/mips/cpu.c
  user/jmallett/octeon/sys/mips/mips/exception.S
  user/jmallett/octeon/sys/mips/mips/machdep.c
  user/jmallett/octeon/sys/mips/mips/mp_machdep.c
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/swtch.S
  user/jmallett/octeon/sys/mips/mips/trap.c
  user/jmallett/octeon/sys/mips/mips/vm_machdep.c

Modified: user/jmallett/octeon/sys/conf/files.mips
==============================================================================
--- user/jmallett/octeon/sys/conf/files.mips	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/conf/files.mips	Sat Apr  3 07:12:03 2010	(r206120)
@@ -44,7 +44,7 @@ mips/mips/vm_machdep.c		standard
 mips/mips/fp.S			standard
 mips/mips/pm_machdep.c		standard
 mips/mips/swtch.S		standard
-mips/mips/tlb.S			standard
+mips/mips/tlb.c			standard
 
 mips/mips/bus_space_generic.c 	standard
 mips/mips/busdma_machdep.c 	standard

Modified: user/jmallett/octeon/sys/mips/include/cpu.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpu.h	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/include/cpu.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -451,7 +451,6 @@ extern union cpuprid cpu_id;
 #if defined(_KERNEL) && !defined(_LOCORE)
 extern union cpuprid fpu_id;
 
-struct tlb;
 struct user;
 
 u_int32_t mips_cp0_config1_read(void);
@@ -466,12 +465,6 @@ void Mips_HitInvalidateDCache(vm_offset_
 void Mips_SyncICache(vm_offset_t, int);
 void Mips_InvalidateICache(vm_offset_t, int);
 
-void Mips_TLBFlush(int);
-void Mips_TLBFlushAddr(vm_offset_t);
-void Mips_TLBWriteIndexed(int, struct tlb *);
-void Mips_TLBUpdate(vm_offset_t, unsigned);
-void Mips_TLBRead(int, struct tlb *);
-void mips_TBIAP(int);
 void wbflush(void);
 
 extern u_int32_t cpu_counter_interval;	/* Number of counter ticks/tick */

Modified: user/jmallett/octeon/sys/mips/include/cpufunc.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/cpufunc.h	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/include/cpufunc.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -102,36 +102,6 @@ mips_write_membar(void)
 }
 
 #ifdef _KERNEL
-
-static __inline void
-mips_tlbp(void)
-{
-	__asm __volatile ("tlbp");
-	mips_barrier();
-}
-
-static __inline void
-mips_tlbr(void)
-{
-	__asm __volatile ("tlbr");
-	mips_barrier();
-}
-
-static __inline void
-mips_tlbwi(void)
-{
-	__asm __volatile ("tlbwi");
-	mips_barrier();
-}
-
-static __inline void
-mips_tlbwr(void)
-{
-	__asm __volatile ("tlbwr");
-	mips_barrier();
-}
-
-
 #if defined(__mips_n32) || defined(__mips_n64)
 #define	MIPS_RDRW64_COP0(n,r)					\
 static __inline uint64_t					\

Modified: user/jmallett/octeon/sys/mips/include/pmap.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pmap.h	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/include/pmap.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -98,6 +98,7 @@ pt_entry_t *pmap_segmap(pmap_t pmap, vm_
 vm_offset_t pmap_kextract(vm_offset_t va);
 
 #define	vtophys(va)	pmap_kextract(((vm_offset_t) (va)))
+#define	pmap_asid(pmap)	(pmap)->pm_asid[PCPU_GET(cpuid)].asid
 
 extern struct pmap	kernel_pmap_store;
 #define kernel_pmap	(&kernel_pmap_store)
@@ -210,11 +211,6 @@ pmap_map_fpage(vm_paddr_t pa, struct fpa
     boolean_t check_unmaped);
 void pmap_unmap_fpage(vm_paddr_t pa, struct fpage *fp);
 
-/*
- * Function to save TLB contents so that they may be inspected in the debugger.
- */
-extern void pmap_save_tlb(void);
-
 #endif				/* _KERNEL */
 
 #endif				/* !LOCORE */

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -1,13 +1,6 @@
-/*	$OpenBSD: pte.h,v 1.4 1998/01/28 13:46:25 pefo Exp $	*/
-
 /*-
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1992, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department and Ralph Campbell.
+ * Copyright (c) 2004-2010 Juli Mallett <jmallett@FreeBSD.org>
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -17,18 +10,11 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * 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)
@@ -37,117 +23,129 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	from: Utah Hdr: pte.h 1.11 89/09/03
- *	from: @(#)pte.h 8.1 (Berkeley) 6/10/93
- *	JNPR: pte.h,v 1.1.4.1 2007/09/10 06:20:19 girish
  * $FreeBSD$
  */
 
-#ifndef _MACHINE_PTE_H_
+#ifndef	_MACHINE_PTE_H_
 #define	_MACHINE_PTE_H_
 
-#include <machine/endian.h>
-
-/*
- * MIPS hardware page table entry
- */
-
 #ifndef _LOCORE
-struct pte {
-#if BYTE_ORDER == BIG_ENDIAN
-unsigned int	pg_prot:2,		/* SW: access control */
-		pg_pfnum:24,		/* HW: core page frame number or 0 */
-		pg_attr:3,		/* HW: cache attribute */
-		pg_m:1,			/* HW: modified (dirty) bit */
-		pg_v:1,			/* HW: valid bit */
-		pg_g:1;			/* HW: ignore pid bit */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN
-unsigned int	pg_g:1,			/* HW: ignore pid bit */
-		pg_v:1,			/* HW: valid bit */
-		pg_m:1,			/* HW: modified (dirty) bit */
-		pg_attr:3,		/* HW: cache attribute */
-		pg_pfnum:24,		/* HW: core page frame number or 0 */
-		pg_prot:2;		/* SW: access control */
+	/* 32-bit PTE.  */
+typedef	uint32_t pt_entry_t;
+
+	/* Page directory entry.  */
+typedef	pt_entry_t *pd_entry_t;
 #endif
-};
 
 /*
- * Structure defining an tlb entry data set.
+ * Given a virtual address, get the offset of its PTE within its page
+ * directory page.
  */
+#define	PDE_OFFSET(va)	(((vm_offset_t)(va) >> PAGE_SHIFT) & (NPTEPG - 1))
 
-struct tlb {
-	int	tlb_mask;
-	int	tlb_hi;
-	int	tlb_lo0;
-	int	tlb_lo1;
-};
+/*
+ * TLB and PTE management.  Most things operate within the context of
+ * EntryLo0,1, and begin with TLBLO_.  Things which work with EntryHi
+ * start with TLBHI_.  PTE bits begin with PG_.
+ *
+ * Note that while the TLB uses 4K pages, our PTEs correspond to VM pages,
+ * which in turn are 8K.  This corresponds well to the fact that each TLB
+ * entry maps 2 TLB pages (one even, one odd.)
+ */
+#define	TLB_PAGE_SHIFT	(PAGE_SHIFT - 1)
+#define	TLB_PAGE_SIZE	(1 << TLB_PAGE_SHIFT)
+#define	TLB_PAGE_MASK	(TLB_PAGE_SIZE - 1)
 
-typedef unsigned int pt_entry_t;
-typedef pt_entry_t *pd_entry_t;
+/*
+ * TLB PageMask register.  Has mask bits set above the default, 4K, page mask.
+ */
+#define	TLBMASK_SHIFT	(TLB_PAGE_SHIFT + 1)
+#define	TLBMASK_MASK	((PAGE_MASK >> TLBMASK_SHIFT) << TLBMASK_SHIFT)
 
-#define	PDESIZE		sizeof(pd_entry_t)	/* for assembly files */
-#define	PTESIZE		sizeof(pt_entry_t)	/* for assembly files */
+/*
+ * PFN for EntryLo register.  Upper bits are 0, which is to say that
+ * bit 29 is the last hardware bit;  Bits 30 and upwards (EntryLo is
+ * 64 bit though it can be referred to in 32-bits providing 2 software
+ * bits safely.  We use it as 64 bits to get many software bits, and
+ * god knows what else.) are unacknowledged by hardware.  They may be
+ * written as anything, but otherwise they have as much meaning as
+ * other 0 fields.
+ */
+#define	TLBLO_SWBITS_SHIFT	(30)
+#define	TLBLO_PFN_SHIFT		(6 + (PAGE_SHIFT - TLBMASK_SHIFT))
+#define	TLBLO_PFN_MASK		(0x03FFFFFC0)
+#define	TLBLO_PA_TO_PFN(pa)	((((pa) >> TLB_PAGE_SHIFT) << TLBLO_PFN_SHIFT) & TLBLO_PFN_MASK)
+#define	TLBLO_PFN_ODD		(TLBLO_PA_TO_PFN(TLB_PAGE_SIZE))
+#define	TLBLO_PFN_TO_PA(pfn)	(((pfn) >> TLBLO_PFN_SHIFT) << TLB_PAGE_SHIFT)
+#define	TLBLO_PTE_TO_PFN(pte)	((pte) & TLBLO_PFN_MASK)
+#define	TLBLO_PTE_TO_PA(pte)	(TLBLO_PFN_TO_PA(TLBLO_PTE_TO_PFN((pte))))
 
-#endif /* _LOCORE */
+/*
+ * VPN for EntryHi register.  Upper two bits select user, supervisor,
+ * or kernel.  Bits 61 to 40 copy bit 63.  VPN2 is bits 39 and down to
+ * as low as 13, down to PAGE_SHIFT, to index 2 TLB pages*.  From bit 12
+ * to bit 8 there is a 5-bit 0 field.  Low byte is ASID.
+ *
+ * Note that in FreeBSD, we map 2 TLB pages is equal to 1 VM page.
+ */
+#if defined(__mips_n64)
+#define	TLBHI_R_SHIFT		62
+#define	TLBHI_R_USER		(0x00UL << TLBHI_R_SHIFT)
+#define	TLBHI_R_SUPERVISOR	(0x01UL << TLBHI_R_SHIFT)
+#define	TLBHI_R_KERNEL		(0x03UL << TLBHI_R_SHIFT)
+#define	TLBHI_R_MASK		(0x03UL << TLBHI_R_SHIFT)
+#define	TLBHI_VA_R(va)		((va) & TLBHI_R_MASK)
+#define	TLBHI_FILL_SHIFT	48
+#define	TLBHI_FILL_MASK		((0x7FFFFUL) << TLBHI_FILL_SHIFT)
+#define	TLBHI_VA_FILL(va)	((((va) & (1UL << 63)) != 0 ? TLBHI_FILL_MASK : 0))
+#define	TLBHI_VPN2_SHIFT	(PAGE_SHIFT)
+#define	TLBHI_VPN2_MASK		(((~((1UL << TLBHI_VPN2_SHIFT) - 1)) << (63 - TLBHI_FILL_SHIFT)) >> (63 - TLBHI_FILL_SHIFT))
+#define	TLBHI_VA_TO_VPN2(va)	((va) & TLBHI_VPN2_MASK)
+#define	TLBHI_ENTRY(va, asid)	((TLBHI_VA_R((va))) /* Region. */ | \
+				 (TLBHI_VA_FILL((va))) /* Fill. */ | \
+				 (TLBHI_VA_TO_VPN2((va))) /* VPN2. */ | \
+				 ((asid)))
+#else
+#define	TLBHI_ENTRY(va, asid)	(((va) & ~PAGE_MASK) | (asid))
+#endif
 
-#define	PT_ENTRY_NULL	((pt_entry_t *) 0)
+/*
+ * TLB flags managed in hardware:
+ * 	C:	Cache attribute.
+ * 	D:	Dirty bit.  This means a page is writable.  It is not
+ * 		set at first, and a write is trapped, and the dirty
+ * 		bit is set.  See also PG_RO.
+ * 	V:	Valid bit.  Obvious, isn't it?
+ * 	G:	Global bit.  This means that this mapping is present
+ * 		in EVERY address space, and to ignore the ASID when
+ * 		it is matched.
+ */
+#define	PG_C(attr)	((attr & 0x07) << 3)
+#define	PG_C_UC		(PG_C(0x02))
+#define	PG_C_CNC	(PG_C(0x03))
+#define	PG_D		0x04
+#define	PG_V		0x02
+#define	PG_G		0x01
 
-#define	PTE_WIRED	0x80000000	/* SW */
-#define	PTE_W		PTE_WIRED
-#define	PTE_RO		0x40000000	/* SW */
+/*
+ * VM flags managed in software:
+ * 	RO:	Read only.  Never set PG_D on this page, and don't
+ * 		listen to requests to write to it.
+ * 	W:	Wired.  ???
+ */
+#define	PG_RO	(0x01 << TLBLO_SWBITS_SHIFT)
+#define	PG_W	(0x02 << TLBLO_SWBITS_SHIFT)
 
-#define	PTE_G		0x00000001	/* HW */
-#define	PTE_V		0x00000002
-/*#define	PTE_NV		0x00000000       Not Used */
-#define	PTE_M		0x00000004
-#define	PTE_RW		PTE_M
-#define PTE_ODDPG       0x00000040 
-/*#define	PG_ATTR		0x0000003f  Not Used */
-#define	PTE_UNCACHED	0x00000010
-#ifdef CPU_SB1
-#define	PTE_CACHE	0x00000028	/* cacheable coherent */
-#else
-#define	PTE_CACHE	0x00000018
-#endif
-/*#define	PG_CACHEMODE	0x00000038 Not Used*/
-#define	PTE_ROPAGE	(PTE_V | PTE_RO | PTE_CACHE) /* Write protected */
-#define	PTE_RWPAGE	(PTE_V | PTE_M | PTE_CACHE)  /* Not wr-prot not clean */
-#define	PTE_CWPAGE	(PTE_V | PTE_CACHE)	   /* Not wr-prot but clean */
-#define	PTE_IOPAGE	(PTE_G | PTE_V | PTE_M | PTE_UNCACHED)
-#define	PTE_FRAME	0x3fffffc0
-#define PTE_HVPN        0xffffe000      /* Hardware page no mask */
-#define PTE_ASID        0x000000ff      /* Address space ID */
+/*
+ * PTE management functions for bits defined above.
+ *
+ * XXX Can make these atomics, but some users of them are using PTEs in local
+ * registers and such and don't need the overhead.
+ */
+#define	pte_clear(pte, bit)	((*pte) &= ~(bit))
+#define	pte_set(pte, bit)	((*pte) |= (bit))
+#define	pte_test(pte, bit)	(((*pte) & (bit)) == (bit))
 
-#define	TLB_PAGE_SHIFT	(PAGE_SHIFT - 1)
-#define	PTE_SHIFT	6
-#define	pfn_is_ext(x)	((x) & 0x3c000000)
-#define	vad_to_pfn(x)	((((vm_offset_t)(x) >> TLB_PAGE_SHIFT) << PTE_SHIFT) & PTE_FRAME)
-#define	pfn_to_vad(x)	((((x) & PTE_FRAME) >> PTE_SHIFT) << TLB_PAGE_SHIFT)
-
-/* User virtual to pte offset in page table */
-#define	vad_to_pte_offset(adr)	(((adr) >> PAGE_SHIFT) & (NPTEPG -1))
-
-#define	mips_pg_v(entry)	((entry) & PTE_V)
-#define	mips_pg_wired(entry)	((entry) & PTE_WIRED)
-#define	mips_pg_m_bit()		(PTE_M)
-#define	mips_pg_rw_bit()	(PTE_M)
-#define	mips_pg_ro_bit()	(PTE_RO)
-#define	mips_pg_ropage_bit()	(PTE_ROPAGE)
-#define	mips_pg_rwpage_bit()	(PTE_RWPAGE)
-#define	mips_pg_cwpage_bit()	(PTE_CWPAGE)
-#define	mips_pg_global_bit()	(PTE_G)
-#define	mips_pg_wired_bit()	(PTE_WIRED)
-#define	mips_tlbpfn_to_paddr(x)	pfn_to_vad((x))
-#define	mips_paddr_to_tlbpfn(x)	vad_to_pfn((x))
-
-/* These are not used */
-#define	PTE_SIZE_4K	0x00000000
-#define	PTE_SIZE_16K	0x00006000
-#define	PTE_SIZE_64K	0x0001e000
-#define	PTE_SIZE_256K	0x0007e000
-#define	PTE_SIZE_1M	0x001fe000
-#define	PTE_SIZE_4M	0x007fe000
-#define	PTE_SIZE_16M	0x01ffe000
+	/* Internal API for the MIPS PMAP.  */
 
-#endif	/* !_MACHINE_PTE_H_ */
+#endif /* !_MACHINE_PTE_H_ */

Added: user/jmallett/octeon/sys/mips/include/tlb.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/jmallett/octeon/sys/mips/include/tlb.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2004-2010 Juli Mallett <jmallett@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.
+ * 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
+ * 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
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_MACHINE_TLB_H_
+#define	_MACHINE_TLB_H_
+
+void tlb_invalidate_address(struct pmap *, vm_offset_t);
+void tlb_invalidate_all(void);
+void tlb_update(struct pmap *, vm_offset_t, pt_entry_t);
+
+#endif /* !_MACHINE_TLB_H_ */

Modified: user/jmallett/octeon/sys/mips/include/vm.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/vm.h	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/include/vm.h	Sat Apr  3 07:12:03 2010	(r206120)
@@ -32,8 +32,8 @@
 #include <machine/pte.h>
 
 /* Memory attributes. */
-#define	VM_MEMATTR_UNCACHED			((vm_memattr_t)PTE_UNCACHED)
-#define	VM_MEMATTR_CACHEABLE_NONCOHERENT	((vm_memattr_t)PTE_CACHE)
+#define	VM_MEMATTR_UNCACHED			((vm_memattr_t)PG_C_UC)
+#define	VM_MEMATTR_CACHEABLE_NONCOHERENT	((vm_memattr_t)PG_C_CNC)
 
 #define	VM_MEMATTR_DEFAULT		VM_MEMATTR_CACHEABLE_NONCOHERENT
 

Modified: user/jmallett/octeon/sys/mips/mips/cpu.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/cpu.c	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/mips/cpu.c	Sat Apr  3 07:12:03 2010	(r206120)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/locore.h>
 #include <machine/pte.h>
+#include <machine/tlb.h>
 #include <machine/hwfunc.h>
 
 struct mips_cpuinfo cpuinfo;
@@ -136,7 +137,7 @@ mips_cpu_init(void)
 	mips_get_identity(&cpuinfo);
 	num_tlbentries = cpuinfo.tlb_nentries;
 	mips_wr_wired(0);
-	Mips_TLBFlush(num_tlbentries);
+	tlb_invalidate_all();
 	mips_wr_wired(VMWIRED_ENTRIES);
 	mips_config_cache(&cpuinfo);
 	mips_vector_init();

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 07:12:03 2010	(r206120)
@@ -69,7 +69,7 @@
 /*
  * Clear the software-managed bits in a PTE in register pr.
  */
-#define	CLEAR_PTE_WIRED(pr)							\
+#define	CLEAR_PTE_SWBITS(pr)							\
 	sll		pr, 2 ;							\
 	srl		pr, 2			# keep bottom 30 bits
 
@@ -148,9 +148,9 @@ MipsDoTLBMiss:
 	andi		k0, k0, 0xff8			#0c: k0=page tab offset
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
 	lw		k0, 0(k1)			#0e: k0=lo0 pte
-	CLEAR_PTE_WIRED(k0)
+	CLEAR_PTE_SWBITS(k0)
 	MTC0		k0, COP_0_TLB_LO0		#12: lo0 is loaded
-	addu		k0, PTE_ODDPG
+	addu		k0, TLBLO_PFN_ODD
 	MTC0		k0, COP_0_TLB_LO1		#15: lo1 is loaded
 	HAZARD_DELAY
 	tlbwr						#1a: write to tlb
@@ -852,14 +852,14 @@ NLEAF(MipsTLBInvalidException)
 	lw		k0, 0(k1)			# k0=this PTE
 
 	/* Validate page table entry.  */
-	andi		k0, PTE_V
+	andi		k0, PG_V
 	beqz		k0, 3f
 	nop
 
 	lw		k0, 0(k1)
-	CLEAR_PTE_WIRED(k0)
+	CLEAR_PTE_SWBITS(k0)
 	MTC0		k0, COP_0_TLB_LO0
-	addu		k0, PTE_ODDPG
+	addu		k0, TLBLO_PFN_ODD
 	MTC0		k0, COP_0_TLB_LO1
 
 	tlbp
@@ -996,9 +996,9 @@ NLEAF(MipsTLBMissException)
 	andi		k0, k0, 0xff8			# k0=page tab offset
 	PTR_ADDU	k1, k1, k0			# k1=pte address
 	lw		k0, 0(k1)			# k0=lo0 pte
-	CLEAR_PTE_WIRED(k0)
+	CLEAR_PTE_SWBITS(k0)
 	MTC0		k0, COP_0_TLB_LO0		# lo0 is loaded
-	addu		k0, PTE_ODDPG
+	addu		k0, TLBLO_PFN_ODD
 	MTC0		k0, COP_0_TLB_LO1		# lo1 is loaded
 	HAZARD_DELAY
 	tlbwr					# write to tlb

Modified: user/jmallett/octeon/sys/mips/mips/machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/machdep.c	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/mips/machdep.c	Sat Apr  3 07:12:03 2010	(r206120)
@@ -428,7 +428,7 @@ mips_pcpu_tlb_init(struct pcpu *pcpu)
 	 */
 	memset(&tlb, 0, sizeof(tlb));
 	pa = vtophys(pcpu);
-	lobits = PTE_RW | PTE_V | PTE_G | PTE_CACHE;
+	lobits = PG_D | PG_V | PG_G | PG_C_CNC;
 	tlb.tlb_hi = (vm_offset_t)pcpup;
 	tlb.tlb_lo0 = mips_paddr_to_tlbpfn(pa) | lobits;
 	tlb.tlb_lo1 = mips_paddr_to_tlbpfn(pa + PAGE_SIZE) | lobits;

Modified: user/jmallett/octeon/sys/mips/mips/mp_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/mips/mp_machdep.c	Sat Apr  3 07:12:03 2010	(r206120)
@@ -128,7 +128,6 @@ mips_ipi_handler(void *arg)
 			CTR0(KTR_SMP, "IPI_STOP or IPI_STOP_HARD");
 
 			savectx(&stoppcbs[cpu]);
-			pmap_save_tlb();
 
 			/* Indicate we are stopped */
 			atomic_set_int(&stopped_cpus, cpumask);
@@ -236,7 +235,7 @@ smp_init_secondary(u_int32_t cpuid)
 
 	/* TLB */
 	mips_wr_wired(0);
-	Mips_TLBFlush(num_tlbentries);
+	tlb_invalidate_all();
 	mips_wr_wired(VMWIRED_ENTRIES);
 
 	/*

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 03:31:14 2010	(r206119)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 07:12:03 2010	(r206120)
@@ -98,6 +98,7 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/cache.h>
 #include <machine/md_var.h>
+#include <machine/tlb.h>
 
 #if defined(DIAGNOSTIC)
 #define	PMAP_DIAGNOSTIC
@@ -123,19 +124,9 @@ __FBSDID("$FreeBSD$");
 #define	pmap_pde(m, v)		(&((m)->pm_segtab[pmap_segshift((v))]))
 #define	segtab_pde(m, v)	((m)[pmap_segshift((v))])
 
-#define	pmap_pte_w(pte)		((*(int *)pte & PTE_W) != 0)
-#define	pmap_pde_v(pte)		((*(int *)pte) != 0)
-#define	pmap_pte_m(pte)		((*(int *)pte & PTE_M) != 0)
-#define	pmap_pte_v(pte)		((*(int *)pte & PTE_V) != 0)
-
-#define	pmap_pte_set_w(pte, v)	((v)?(*(int *)pte |= PTE_W):(*(int *)pte &= ~PTE_W))
-#define	pmap_pte_set_prot(pte, v) ((*(int *)pte &= ~PG_PROT), (*(int *)pte |= (v)))
-
 #define	NUSERPGTBLS		(pmap_segshift(VM_MAXUSER_ADDRESS))
 #define	MIPS_SEGSIZE		(1L << SEGSHIFT)
 #define	mips_segtrunc(va)	((va) & ~(MIPS_SEGSIZE-1))
-#define	pmap_TLB_invalidate_all() mips_TBIAP(num_tlbentries)
-#define	pmap_va_asid(pmap, va)	((va) | ((pmap)->pm_asid[PCPU_GET(cpuid)].asid << VMTLB_PID_SHIFT))
 #define	is_kernel_pmap(x)	((x) == kernel_pmap)
 
 struct pmap kernel_pmap_store;
@@ -153,8 +144,6 @@ unsigned pmap_max_asid;		/* max ASID sup
 
 vm_offset_t kernel_vm_end;
 
-static struct tlb tlbstash[MAXCPU][MIPS_MAX_TLB_ENTRIES];
-
 static void pmap_asid_alloc(pmap_t pmap);
 
 /*
@@ -170,27 +159,27 @@ struct sysmaps sysmaps_pcpu[MAXCPU];
 
 static PMAP_INLINE void free_pv_entry(pv_entry_t pv);
 static pv_entry_t get_pv_entry(pmap_t locked_pmap);
-static __inline void pmap_changebit(vm_page_t m, int bit, boolean_t setem);
+static __inline void pmap_clear_modified_bit(vm_page_t m);
 
 static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va,
     vm_page_t m, vm_prot_t prot, vm_page_t mpte);
 static int pmap_remove_pte(struct pmap *pmap, pt_entry_t *ptq, vm_offset_t va);
 static void pmap_remove_page(struct pmap *pmap, vm_offset_t va);
 static void pmap_remove_entry(struct pmap *pmap, vm_page_t m, vm_offset_t va);
-static boolean_t pmap_testbit(vm_page_t m, int bit);
+static boolean_t pmap_check_modified_bit(vm_page_t m);
 static void 
 pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t mpte,
     vm_page_t m, boolean_t wired);
 static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, vm_page_t mpte,
     vm_offset_t va, vm_page_t m);
+static __inline void
+pmap_invalidate_page(pmap_t pmap, vm_offset_t va);
 
 static vm_page_t pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags);
 
 static vm_page_t _pmap_allocpte(pmap_t pmap, unsigned ptepindex, int flags);
 static int pmap_unuse_pt(pmap_t, vm_offset_t, vm_page_t);
 static int init_pte_prot(vm_offset_t va, vm_page_t m, vm_prot_t prot);
-static void pmap_TLB_invalidate_kernel(vm_offset_t);
-static void pmap_TLB_update_kernel(vm_offset_t, pt_entry_t);
 static void pmap_init_fpage(void);
 
 #ifdef SMP
@@ -244,7 +233,7 @@ pmap_pte(pmap_t pmap, vm_offset_t va)
 	if (pmap) {
 		pdeaddr = pmap_segmap(pmap, va);
 		if (pdeaddr) {
-			return pdeaddr + vad_to_pte_offset(va);
+			return pdeaddr + PDE_OFFSET(va);
 		}
 	}
 	return ((pt_entry_t *)0);
@@ -401,8 +390,8 @@ again:
 	 */
 	if (memory_larger_than_512meg) {
 		for (i = 0; i < MAXCPU; i++) {
-			sysmap_lmem[i].CMAP1 = PTE_G;
-			sysmap_lmem[i].CMAP2 = PTE_G;
+			pte_set(&sysmap_lmem[i].CMAP1, PG_G);
+			pte_set(&sysmap_lmem[i].CMAP2, PG_G);
 			sysmap_lmem[i].CADDR1 = (caddr_t)virtual_avail;
 			virtual_avail += PAGE_SIZE;
 			sysmap_lmem[i].CADDR2 = (caddr_t)virtual_avail;
@@ -450,7 +439,7 @@ again:
 	 * in the tlb.
 	 */
 	for (i = 0, pte = pgtab; i < (nkpt * NPTEPG); i++, pte++)
-		*pte = PTE_G;
+		*pte = PG_G;
 
 	/*
 	 * The segment table contains the KVA of the pages in the second
@@ -524,7 +513,7 @@ pmap_init(void)
 static int
 pmap_nw_modified(pt_entry_t pte)
 {
-	if ((pte & (PTE_M | PTE_RO)) == (PTE_M | PTE_RO))
+	if (pte_test(&pte, PG_RO) == pte_est(&pte, PG_D))
 		return (1);
 	else
 		return (0);
@@ -547,7 +536,11 @@ pmap_invalidate_all_action(void *arg)
 #endif
 
 	if (pmap->pm_active & PCPU_GET(cpumask)) {
-		pmap_TLB_invalidate_all();
+		/*
+		 * XXX/juli
+		 * Add something like TBIAP.
+		 */
+		tlb_invalidate_all();
 	} else
 		pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
 }
@@ -578,7 +571,7 @@ pmap_invalidate_page_action(void *arg)
 #endif
 
 	if (is_kernel_pmap(pmap)) {
-		pmap_TLB_invalidate_kernel(va);
+		tlb_invalidate_address(pmap, va);
 		return;
 	}
 	if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation))
@@ -587,18 +580,7 @@ pmap_invalidate_page_action(void *arg)
 		pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
 		return;
 	}
-	va = pmap_va_asid(pmap, (va & ~PAGE_MASK));
-	Mips_TLBFlushAddr(va);
-}
-
-static void
-pmap_TLB_invalidate_kernel(vm_offset_t va)
-{
-	u_int32_t pid;
-
-	pid = mips_rd_entryhi() & VMTLB_PID;
-	va = va | (pid << VMTLB_PID_SHIFT);
-	Mips_TLBFlushAddr(va);
+	tlb_invalidate_address(pmap, va);
 }
 
 struct pmap_update_page_arg {
@@ -629,7 +611,7 @@ pmap_update_page_action(void *arg)
 
 #endif
 	if (is_kernel_pmap(pmap)) {
-		pmap_TLB_update_kernel(va, pte);
+		tlb_update(pmap, va, pte);
 		return;
 	}
 	if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation))
@@ -638,19 +620,7 @@ pmap_update_page_action(void *arg)
 		pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
 		return;
 	}
-	va = pmap_va_asid(pmap, va);
-	Mips_TLBUpdate(va, pte);
-}
-
-static void
-pmap_TLB_update_kernel(vm_offset_t va, pt_entry_t pte)
-{
-	u_int32_t pid;
-
-	pid = mips_rd_entryhi() & VMTLB_PID;
-	va = va | (pid << VMTLB_PID_SHIFT);
-
-	Mips_TLBUpdate(va, pte);
+	tlb_update(pmap, va, pte);
 }
 
 /*
@@ -668,7 +638,7 @@ pmap_extract(pmap_t pmap, vm_offset_t va
 	PMAP_LOCK(pmap);
 	pte = pmap_pte(pmap, va);
 	if (pte) {
-		retval = mips_tlbpfn_to_paddr(*pte) | (va & PAGE_MASK);
+		retval = TLBLO_PTE_TO_PA(*pte) | (va & PAGE_MASK);
 	}
 	PMAP_UNLOCK(pmap);
 	return retval;
@@ -684,17 +654,17 @@ pmap_extract(pmap_t pmap, vm_offset_t va
 vm_page_t
 pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
 {
-	pt_entry_t pte;
+	pt_entry_t *pte;
 	vm_page_t m;
 
 	m = NULL;
 	vm_page_lock_queues();
 	PMAP_LOCK(pmap);
 
-	pte = *pmap_pte(pmap, va);
-	if (pte != 0 && pmap_pte_v(&pte) &&
-	    ((pte & PTE_RW) || (prot & VM_PROT_WRITE) == 0)) {
-		m = PHYS_TO_VM_PAGE(mips_tlbpfn_to_paddr(pte));
+	pte = pmap_pte(pmap, va);
+	if (pte_test(pte, PG_V) && (pte_test(pte, PG_D) ||
+	    (prot & VM_PROT_WRITE) == 0)) {
+		m = PHYS_TO_VM_PAGE(TLBLO_PTE_TO_PA(*pte));
 		vm_page_hold(m);
 	}
 	vm_page_unlock_queues();
@@ -712,23 +682,23 @@ pmap_extract_and_hold(pmap_t pmap, vm_of
  /* PMAP_INLINE */ void
 pmap_kenter(vm_offset_t va, vm_paddr_t pa)
 {
-	register pt_entry_t *pte;
-	pt_entry_t npte, opte;
+	pt_entry_t *pte;
+	pt_entry_t npte;
 
 #ifdef PMAP_DEBUG
 	printf("pmap_kenter:  va: %p -> pa: %p\n", (void *)va, (void *)pa);
 #endif
-	npte = mips_paddr_to_tlbpfn(pa) | PTE_RW | PTE_V | PTE_G | PTE_W;
+	npte = TLBLO_PA_TO_PFN(pa) | PG_D | PG_V | PG_G | PG_W;
 
 	if (is_cacheable_mem(pa))
-		npte |= PTE_CACHE;
+		npte |= PG_C_CNC;
 	else
-		npte |= PTE_UNCACHED;
+		npte |= PG_C_UC;
 
 	pte = pmap_pte(kernel_pmap, va);
-	opte = *pte;
 	*pte = npte;
 
+#if 0
 	/*
 	 * The original code did an update_page() here, but
 	 * we often do a lot of pmap_kenter() calls and then
@@ -736,6 +706,9 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 	 * the TLB has overflown many times.
 	 */
 	pmap_invalidate_page(kernel_pmap, va);
+#else
+	pmap_update_page(kernel_pmap, va, npte);
+#endif
 }
 
 /*
@@ -744,7 +717,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
  /* PMAP_INLINE */ void
 pmap_kremove(vm_offset_t va)
 {
-	register pt_entry_t *pte;
+	pt_entry_t *pte;
 
 	/*
 	 * Write back all caches from the page being destroyed
@@ -752,7 +725,7 @@ pmap_kremove(vm_offset_t va)
 	mips_dcache_wbinv_range_index(va, PAGE_SIZE);
 
 	pte = pmap_pte(kernel_pmap, va);
-	*pte = PTE_G;
+	*pte = PG_G;
 	pmap_invalidate_page(kernel_pmap, va);
 }
 
@@ -887,7 +860,7 @@ vm_offset_t
 pmap_map_fpage(vm_paddr_t pa, struct fpage *fp, boolean_t check_unmaped)
 {
 	vm_offset_t kva;
-	register pt_entry_t *pte;
+	pt_entry_t *pte;
 	pt_entry_t npte;
 
 	KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
@@ -903,11 +876,11 @@ pmap_map_fpage(vm_paddr_t pa, struct fpa
 	fp->state = TRUE;
 	kva = fp->kva;
 
-	npte = mips_paddr_to_tlbpfn(pa) | PTE_RW | PTE_V | PTE_G | PTE_W | PTE_CACHE;
+	npte = TLBLO_PA_TO_PFN(pa) | PG_D | PG_V | PG_G | PG_W | PG_C_CNC;
 	pte = pmap_pte(kernel_pmap, kva);
 	*pte = npte;
 
-	pmap_TLB_update_kernel(kva, npte);
+	pmap_update_page(kernel_pmap, kva, npte);
 
 	return (kva);
 }
@@ -919,7 +892,7 @@ void
 pmap_unmap_fpage(vm_paddr_t pa, struct fpage *fp)
 {
 	vm_offset_t kva;
-	register pt_entry_t *pte;
+	pt_entry_t *pte;
 
 	KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
 	/*
@@ -931,8 +904,8 @@ pmap_unmap_fpage(vm_paddr_t pa, struct f
 	kva = fp->kva;
 
 	pte = pmap_pte(kernel_pmap, kva);
-	*pte = PTE_G;
-	pmap_TLB_invalidate_kernel(kva);
+	*pte = PG_G;
+	pmap_invalidate_page(kernel_pmap, kva);
 
 	fp->state = FALSE;
 
@@ -1364,7 +1337,7 @@ pmap_growkernel(vm_offset_t addr)
 		 * produce a global bit to store in the tlb.
 		 */
 		for (i = 0; i < NPTEPG; i++, pte++)
-			*pte = PTE_G;
+			*pte = PG_G;
 
 		kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) &
 		    ~(PAGE_SIZE * NPTEPG - 1);
@@ -1444,12 +1417,12 @@ retry:
 			KASSERT(pte != NULL, ("pte"));
 			oldpte = loadandclear((u_int *)pte);
 			if (is_kernel_pmap(pmap))
-				*pte = PTE_G;
-			KASSERT((oldpte & PTE_W) == 0,
+				*pte = PG_G;
+			KASSERT(!pte_test(&oldpte, PG_W),
 			    ("wired pte for unwired page"));
 			if (m->md.pv_flags & PV_TABLE_REF)
 				vm_page_flag_set(m, PG_REFERENCED);
-			if (oldpte & PTE_M)
+			if (pte_test(&oldpte, PG_D))
 				vm_page_dirty(m);
 			pmap_invalidate_page(pmap, va);
 			TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist);
@@ -1591,17 +1564,17 @@ pmap_remove_pte(struct pmap *pmap, pt_en
 
 	oldpte = loadandclear((u_int *)ptq);
 	if (is_kernel_pmap(pmap))
-		*ptq = PTE_G;
+		*ptq = PG_G;
 
-	if (oldpte & PTE_W)
+	if (pte_test(&oldpte, PG_W))
 		pmap->pm_stats.wired_count -= 1;
 
 	pmap->pm_stats.resident_count -= 1;
-	pa = mips_tlbpfn_to_paddr(oldpte);
+	pa = TLBLO_PTE_TO_PA(oldpte);
 
 	if (page_is_managed(pa)) {
 		m = PHYS_TO_VM_PAGE(pa);
-		if (oldpte & PTE_M) {
+		if (pte_test(&oldpte, PG_D)) {
 #if defined(PMAP_DIAGNOSTIC)
 			if (pmap_nw_modified(oldpte)) {
 				printf(
@@ -1626,7 +1599,7 @@ pmap_remove_pte(struct pmap *pmap, pt_en
 static void
 pmap_remove_page(struct pmap *pmap, vm_offset_t va)
 {
-	register pt_entry_t *ptq;
+	pt_entry_t *ptq;
 
 	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
@@ -1635,7 +1608,7 @@ pmap_remove_page(struct pmap *pmap, vm_o
 	/*
 	 * if there is no pte for this address, just skip it!!!
 	 */
-	if (!ptq || !pmap_pte_v(ptq)) {
+	if (!ptq || !pte_test(ptq, PG_V)) {
 		return;
 	}
 
@@ -1711,8 +1684,8 @@ out:
 void
 pmap_remove_all(vm_page_t m)
 {
-	register pv_entry_t pv;
-	register pt_entry_t *pte, tpte;
+	pv_entry_t pv;
+	pt_entry_t *pte, tpte;
 
 	KASSERT((m->flags & PG_FICTITIOUS) == 0,
 	    ("pmap_remove_all: page %p is fictitious", m));
@@ -1737,15 +1710,15 @@ pmap_remove_all(vm_page_t m)
 
 		tpte = loadandclear((u_int *)pte);
 		if (is_kernel_pmap(pv->pv_pmap))
-			*pte = PTE_G;
+			*pte = PG_G;
 
-		if (tpte & PTE_W)
+		if (pte_test(&tpte, PG_W))
 			pv->pv_pmap->pm_stats.wired_count--;
 
 		/*
 		 * Update the vm_page_t clean and reference bits.
 		 */
-		if (tpte & PTE_M) {
+		if (pte_test(&tpte, PG_D)) {
 #if defined(PMAP_DIAGNOSTIC)
 			if (pmap_nw_modified(tpte)) {
 				printf(
@@ -1806,13 +1779,13 @@ pmap_protect(pmap_t pmap, vm_offset_t sv
 		 * If pte is invalid, skip this page
 		 */
 		pte = pmap_pte(pmap, sva);
-		if (!pmap_pte_v(pte)) {
+		if (!pte_test(pte, PG_V)) {
 			sva += PAGE_SIZE;
 			continue;
 		}
 retry:
 		obits = pbits = *pte;
-		pa = mips_tlbpfn_to_paddr(pbits);
+		pa = TLBLO_PTE_TO_PA(pbits);
 
 		if (page_is_managed(pa)) {
 			m = PHYS_TO_VM_PAGE(pa);
@@ -1820,12 +1793,13 @@ retry:
 				vm_page_flag_set(m, PG_REFERENCED);
 				m->md.pv_flags &= ~PV_TABLE_REF;
 			}
-			if (pbits & PTE_M) {
+			if (pte_test(&pbits, PG_D)) {
 				vm_page_dirty(m);
 				m->md.pv_flags &= ~PV_TABLE_MOD;
 			}
 		}
-		pbits = (pbits & ~PTE_M) | PTE_RO;
+		pte_clear(&pbits, PG_D);
+		pte_set(&pbits, PG_RO);
 
 		if (pbits != *pte) {
 			if (!atomic_cmpset_int((u_int *)pte, obits, pbits))
@@ -1855,7 +1829,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, 
     vm_prot_t prot, boolean_t wired)
 {
 	vm_offset_t pa, opa;
-	register pt_entry_t *pte;
+	pt_entry_t *pte;
 	pt_entry_t origpte, newpte;
 	vm_page_t mpte, om;
 	int rw = 0;
@@ -1893,21 +1867,21 @@ pmap_enter(pmap_t pmap, vm_offset_t va, 
 	pa = VM_PAGE_TO_PHYS(m);
 	om = NULL;
 	origpte = *pte;
-	opa = mips_tlbpfn_to_paddr(origpte);
+	opa = TLBLO_PTE_TO_PA(origpte);
 
 	/*
 	 * Mapping has not changed, must be protection or wiring change.
 	 */
-	if ((origpte & PTE_V) && (opa == pa)) {
+	if (pte_test(&origpte, PG_V) && opa == pa) {
 		/*
 		 * Wiring change, just update stats. We don't worry about
 		 * wiring PT pages as they remain resident as long as there
 		 * are valid mappings in them. Hence, if a user page is
 		 * wired, the PT page will be also.
 		 */
-		if (wired && ((origpte & PTE_W) == 0))
+		if (wired && !pte_test(&origpte, PG_W))
 			pmap->pm_stats.wired_count++;
-		else if (!wired && (origpte & PTE_W))
+		else if (!wired && pte_test(&origpte, PG_W))
 			pmap->pm_stats.wired_count--;
 
 #if defined(PMAP_DIAGNOSTIC)
@@ -1938,7 +1912,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, 
 	 * handle validating new mapping.
 	 */
 	if (opa) {
-		if (origpte & PTE_W)
+		if (pte_test(&origpte, PG_W))
 			pmap->pm_stats.wired_count--;
 
 		if (page_is_managed(opa)) {
@@ -1981,35 +1955,34 @@ validate:
 	/*

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-user@FreeBSD.ORG  Sat Apr  3 07:27:34 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5D2D2106566B;
	Sat,  3 Apr 2010 07:27:34 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4C0358FC08;
	Sat,  3 Apr 2010 07:27:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o337RW6d016963;
	Sat, 3 Apr 2010 07:27:32 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o337RWWm016958;
	Sat, 3 Apr 2010 07:27:32 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004030727.o337RWWm016958@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sat, 3 Apr 2010 07:27:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206123 - in user/jmallett/octeon/sys/mips: include mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Apr 2010 07:27:34 -0000

Author: jmallett
Date: Sat Apr  3 07:27:32 2010
New Revision: 206123
URL: http://svn.freebsd.org/changeset/base/206123

Log:
  o) Add a macro which masks the software-managed bits in the PTE.
  o) Use PDE_OFFSET() in a couple of places that should use it.
  o) Move a reduced-in-features tlb show command to tlb.c.

Modified:
  user/jmallett/octeon/sys/mips/include/pte.h
  user/jmallett/octeon/sys/mips/mips/pmap.c
  user/jmallett/octeon/sys/mips/mips/tlb.c
  user/jmallett/octeon/sys/mips/mips/vm_machdep.c

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 07:19:31 2010	(r206122)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 07:27:32 2010	(r206123)
@@ -72,6 +72,7 @@ typedef	pt_entry_t *pd_entry_t;
  * other 0 fields.
  */
 #define	TLBLO_SWBITS_SHIFT	(30)
+#define	TLBLO_SWBITS_MASK	(0x3U << TLBLO_SWBITS_SHIFT)
 #define	TLBLO_PFN_SHIFT		(6 + (PAGE_SHIFT - TLBMASK_SHIFT))
 #define	TLBLO_PFN_MASK		(0x03FFFFFC0)
 #define	TLBLO_PA_TO_PFN(pa)	((((pa) >> TLB_PAGE_SHIFT) << TLBLO_PFN_SHIFT) & TLBLO_PFN_MASK)

Modified: user/jmallett/octeon/sys/mips/mips/pmap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 07:19:31 2010	(r206122)
+++ user/jmallett/octeon/sys/mips/mips/pmap.c	Sat Apr  3 07:27:32 2010	(r206123)
@@ -68,7 +68,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_ddb.h"
 #include "opt_msgbuf.h"
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -3406,53 +3405,3 @@ pmap_flush_pvcache(vm_page_t m)
 		}
 	}
 }
-
-#if 0
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(tlb, ddb_dump_tlb)
-{
-	int cpu, tlbno;
-	struct tlb *tlb;
-
-	if (have_addr)
-		cpu = ((addr >> 4) % 16) * 10 + (addr % 16);
-	else
-		cpu = PCPU_GET(cpuid);
-
-	if (cpu < 0 || cpu >= mp_ncpus) {
-		db_printf("Invalid CPU %d\n", cpu);
-		return;
-	} else
-		db_printf("CPU %d:\n", cpu);
-
-	if (cpu == PCPU_GET(cpuid))
-		pmap_save_tlb();
-
-	for (tlbno = 0; tlbno < num_tlbentries; ++tlbno) {
-		tlb = &tlbstash[cpu][tlbno];
-		if (pte_test(&tlb->tlb_lo0, PG_V) ||
-		    pte_test(&tlb->tlb_lo1, PG_V)) {
-			printf("TLB %2d vad 0x%0lx ",
-				tlbno, (long)(tlb->tlb_hi & 0xffffff00));
-		} else {
-			printf("TLB*%2d vad 0x%0lx ",
-				tlbno, (long)(tlb->tlb_hi & 0xffffff00));
-		}
-		printf("0=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo0));
-		printf("%c", tlb->tlb_lo0 & PG_V ? 'V' : '-');
-		printf("%c", tlb->tlb_lo0 & PG_D ? 'D' : '-');
-		printf("%c", tlb->tlb_lo0 & PG_G ? 'G' : '-');
-		printf(" atr %x ", (tlb->tlb_lo0 >> 3) & 7);
-		printf("1=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo1));
-		printf("%c", tlb->tlb_lo1 & PG_V ? 'V' : '-');
-		printf("%c", tlb->tlb_lo1 & PG_D ? 'D' : '-');
-		printf("%c", tlb->tlb_lo1 & PG_G ? 'G' : '-');
-		printf(" atr %x ", (tlb->tlb_lo1 >> 3) & 7);
-		printf(" sz=%x pid=%x\n", tlb->tlb_mask,
-		       (tlb->tlb_hi & 0x000000ff));
-	}
-}
-#endif	/* DDB */
-#endif

Modified: user/jmallett/octeon/sys/mips/mips/tlb.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/tlb.c	Sat Apr  3 07:19:31 2010	(r206122)
+++ user/jmallett/octeon/sys/mips/mips/tlb.c	Sat Apr  3 07:27:32 2010	(r206123)
@@ -26,6 +26,8 @@
  * $FreeBSD$
  */
 
+#include "opt_ddb.h"
+
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
@@ -137,3 +139,37 @@ tlb_invalidate_one(unsigned i)
 	mips_wr_index(i);
 	tlb_write_indexed();
 }
+
+#ifdef DDB
+#include <ddb/ddb.h>
+
+DB_SHOW_COMMAND(tlb, ddb_dump_tlb)
+{
+	register_t ehi, elo0, elo1;
+	unsigned i;
+
+	db_printf("Beginning TLB dump...\n");
+	for (i = 0; i < num_tlbentries; i++) {
+		if (i == mips_rd_wired()) {
+			if (i != 0)
+				db_printf("^^^ WIRED ENTRIES ^^^\n");
+			else
+				db_printf("(No wired entries.)\n");
+		}
+		mips_wr_index(i);
+		tlb_read();
+
+		ehi = mips_rd_entryhi();
+		elo0 = mips_rd_entrylo0();
+		elo1 = mips_rd_entrylo1();
+
+		if (elo0 == 0 && elo1 == 0)
+			continue;
+
+		db_printf("#%u\t=> %jx\n", i, (intmax_t)ehi);
+		db_printf(" Lo0\t%jx\n", (intmax_t)elo0);
+		db_printf(" Lo1\t%jx\n", (intmax_t)elo1);
+	}
+	db_printf("Finished.\n");
+}
+#endif

Modified: user/jmallett/octeon/sys/mips/mips/vm_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sat Apr  3 07:19:31 2010	(r206122)
+++ user/jmallett/octeon/sys/mips/mips/vm_machdep.c	Sat Apr  3 07:27:32 2010	(r206123)
@@ -224,10 +224,10 @@ cpu_thread_swapin(struct thread *td)
 	 */
 	if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack)))
 		panic("cpu_thread_swapin: invalid segmap");
-	pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1);
+	pte += PDE_OFFSET(td->td_kstack);
 
 	for (i = 0; i < KSTACK_PAGES; i++) {
-		td->td_md.md_upte[i] = *pte & ~(PG_RO | PG_W);
+		td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK;
 		pte++;
 	}
 }
@@ -249,10 +249,10 @@ cpu_thread_alloc(struct thread *td)
 
 	if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack)))
 		panic("cpu_thread_alloc: invalid segmap");
-	pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1);
+	pte += PDE_OFFSET(td->td_kstack);
 
 	for (i = 0; i < KSTACK_PAGES; i++) {
-		td->td_md.md_upte[i] = *pte & ~(PG_RO | PG_W);
+		td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK;
 		pte++;
 	}
 }

From owner-svn-src-user@FreeBSD.ORG  Sat Apr  3 07:55:54 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4F4641065670;
	Sat,  3 Apr 2010 07:55:54 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3F40C8FC1E;
	Sat,  3 Apr 2010 07:55:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o337ts86023310;
	Sat, 3 Apr 2010 07:55:54 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o337tsJM023308;
	Sat, 3 Apr 2010 07:55:54 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004030755.o337tsJM023308@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sat, 3 Apr 2010 07:55:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206126 - user/jmallett/octeon/sys/mips/include
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Apr 2010 07:55:54 -0000

Author: jmallett
Date: Sat Apr  3 07:55:53 2010
New Revision: 206126
URL: http://svn.freebsd.org/changeset/base/206126

Log:
  Fix the EntryHi fill field use.

Modified:
  user/jmallett/octeon/sys/mips/include/pte.h

Modified: user/jmallett/octeon/sys/mips/include/pte.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 07:51:34 2010	(r206125)
+++ user/jmallett/octeon/sys/mips/include/pte.h	Sat Apr  3 07:55:53 2010	(r206126)
@@ -96,14 +96,11 @@ typedef	pt_entry_t *pd_entry_t;
 #define	TLBHI_R_KERNEL		(0x03UL << TLBHI_R_SHIFT)
 #define	TLBHI_R_MASK		(0x03UL << TLBHI_R_SHIFT)
 #define	TLBHI_VA_R(va)		((va) & TLBHI_R_MASK)
-#define	TLBHI_FILL_SHIFT	48
-#define	TLBHI_FILL_MASK		((0x7FFFFUL) << TLBHI_FILL_SHIFT)
-#define	TLBHI_VA_FILL(va)	((((va) & (1UL << 63)) != 0 ? TLBHI_FILL_MASK : 0))
+#define	TLBHI_FILL_SHIFT	40
 #define	TLBHI_VPN2_SHIFT	(PAGE_SHIFT)
 #define	TLBHI_VPN2_MASK		(((~((1UL << TLBHI_VPN2_SHIFT) - 1)) << (63 - TLBHI_FILL_SHIFT)) >> (63 - TLBHI_FILL_SHIFT))
 #define	TLBHI_VA_TO_VPN2(va)	((va) & TLBHI_VPN2_MASK)
 #define	TLBHI_ENTRY(va, asid)	((TLBHI_VA_R((va))) /* Region. */ | \
-				 (TLBHI_VA_FILL((va))) /* Fill. */ | \
 				 (TLBHI_VA_TO_VPN2((va))) /* VPN2. */ | \
 				 ((asid)))
 #else

From owner-svn-src-user@FreeBSD.ORG  Sat Apr  3 08:24:28 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B9982106564A;
	Sat,  3 Apr 2010 08:24:28 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A973E8FC12;
	Sat,  3 Apr 2010 08:24:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o338OSjM029633;
	Sat, 3 Apr 2010 08:24:28 GMT (envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o338OScN029632;
	Sat, 3 Apr 2010 08:24:28 GMT (envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004030824.o338OScN029632@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Sat, 3 Apr 2010 08:24:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r206127 - user/jmallett/octeon/sys/mips/mips
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Apr 2010 08:24:28 -0000

Author: jmallett
Date: Sat Apr  3 08:24:28 2010
New Revision: 206127
URL: http://svn.freebsd.org/changeset/base/206127

Log:
  Fix page table offsets now that we're not using pairs of entries.

Modified:
  user/jmallett/octeon/sys/mips/mips/exception.S

Modified: user/jmallett/octeon/sys/mips/mips/exception.S
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 07:55:53 2010	(r206126)
+++ user/jmallett/octeon/sys/mips/mips/exception.S	Sat Apr  3 08:24:28 2010	(r206127)
@@ -145,7 +145,7 @@ MipsDoTLBMiss:
 	MFC0		k0, COP_0_BAD_VADDR		#09: k0=bad address (again)
 	beq		k1, zero, 2f			#0a: ==0 -- no page table
 	srl		k0, PAGE_SHIFT - 2		#0b: k0=VPN (aka va>>10)
-	andi		k0, k0, 0xff8			#0c: k0=page tab offset
+	andi		k0, k0, 0xffc			#0c: k0=page tab offset
 	PTR_ADDU	k1, k1, k0			#0d: k1=pte address
 	lw		k0, 0(k1)			#0e: k0=lo0 pte
 	CLEAR_PTE_SWBITS(k0)
@@ -993,7 +993,7 @@ NLEAF(MipsTLBMissException)
 	MFC0		k0, COP_0_BAD_VADDR		# k0=bad address (again)
 	beq		k1, zero, MipsKernGenException	# ==0 -- no page table
 	PTR_SRL		k0, PAGE_SHIFT - 2		# k0=VPN
-	andi		k0, k0, 0xff8			# k0=page tab offset
+	andi		k0, k0, 0xffc			# k0=page tab offset
 	PTR_ADDU	k1, k1, k0			# k1=pte address
 	lw		k0, 0(k1)			# k0=lo0 pte
 	CLEAR_PTE_SWBITS(k0)