dslinux/linux-2.6.x/include/asm-arm/arch-nds gbarom-macro.S

amadeus dslinux_amadeus at user.in-berlin.de
Wed Aug 30 14:05:28 CEST 2006


Update of /cvsroot/dslinux/dslinux/linux-2.6.x/include/asm-arm/arch-nds
In directory antilope:/tmp/cvs-serv4723/linux-2.6.x/include/asm-arm/arch-nds

Modified Files:
	gbarom-macro.S 
Log Message:
Optimizing switched SD driver

Index: gbarom-macro.S
===================================================================
RCS file: /cvsroot/dslinux/dslinux/linux-2.6.x/include/asm-arm/arch-nds/gbarom-macro.S,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gbarom-macro.S	28 Aug 2006 18:43:34 -0000	1.2
+++ gbarom-macro.S	30 Aug 2006 12:05:26 -0000	1.3
@@ -25,7 +25,7 @@
 
 /*****************************************************************************/
 /*
- * Prefix macro. This macro does all the magic required to switch the 
+ * GBA prefix macro. This macro does all the magic required to switch the 
  * GBA ROM space from RAM mode to IO mode (exclusive the switching itself,
  * which is device dependent).
  * This is a macro and not a function, because the stack(!) may be in GBA
@@ -36,7 +36,7 @@
  * R3 and IP are used and altered. If you need more registers, you
  * must reserve these registers BEFORE calling this macro.
  */
-	.macro	prefix
+	.macro	gba_prefix
 	@ Disable interrupts
 	ldr	r3, =NDS_IME		@ interrupt mask register
 	mov	ip, #0			@ 0 = disable
@@ -64,7 +64,7 @@
 
 /*****************************************************************************/
 /*
- * Suffix macro. This macro does all the magic required to switch the
+ * GBA suffix macro. This macro does all the magic required to switch the
  * GBA ROM space from IO mode to RAM mode (exclusive the switching itself,
  * which is device dependent).
  * This is a macro and not a function, because the stack(!) may be in GBA
@@ -73,7 +73,7 @@
  *
  * Register R0 is not altered and used as a return register.
  */
-	.macro	suffix
+	.macro	gba_suffix
 	@ be safe that all switching commands before are executed
 	mov	ip, #0
 	mcr	p15, 0, ip, c7, c10, 4	@ drain write buffer
@@ -107,7 +107,6 @@
 /* sc_setmode: supercard SD/CF GBA ROM/RAM/IO switching.
    Use only register R3 and IP.
    NOTE: this macro destroys the RAM contents at address SC_LOCK. */
-
 	.macro	sc_setmode  mode
 	ldr	r3, =SC_LOCK
 	ldr	ip, =SC_PATTERN
@@ -118,6 +117,32 @@
 	strh	ip, [r3]
 	.endm
 
+/* sc_set_io: set mode to I/O, save old value @SC_LOCK in R2.
+   Use register R2, R3, IP. */
+	.macro	sc_set_io
+	ldr	r3, =SC_LOCK
+	ldr	ip, =SC_PATTERN
+	ldrh	r2, [r3]
+	strh	ip, [r3]
+	strh	ip, [r3]
+	mov	ip, #SC_MODE_IO
+	strh	ip, [r3]
+	strh	ip, [r3]
+	.endm
+
+/* sc_set_ram: set mode to RAM, restore old value @SC_LOCK from R2.
+   Use register R2, R3, IP. */
+	.macro	sc_set_ram
+	ldr	r3, =SC_LOCK
+	ldr	ip, =SC_PATTERN
+	strh	ip, [r3]
+	strh	ip, [r3]
+	mov	ip, #SC_MODE_RAM
+	strh	ip, [r3]
+	strh	ip, [r3]
+	strh	r2, [r3]
+	.endm
+
 /*****************************************************************************/
 /*
  * M3 Adapter SD/CF ROM/RAM/IO switching.
@@ -185,13 +210,15 @@
 	.endm
 /* 
  * m3_set_rw: if the previous mode of M3SD/CF was "ROM",
- * allow write access. Use only register R3 and IP.
+ * allow write access. Use only register R2, R3 and IP.
  */
 	.macro	m3_set_rw
 	ldr	r3, =0x09FFEFFE
 	ldr	ip, =0xAA55
-	swph	ip, ip, [r3]	@ be carefull not to overwrite memory
+	ldrh	r2, [r3]	@ read old value @ 0x09FFEFFE
 	strh	ip, [r3]
+	strh	ip, [r3]
+	strh	r2, [r3]	@ restore old value
 	.endm
 
 /*****************************************************************************/




More information about the dslinux-commit mailing list