changeset 795:2568adc4834e

Improvements in cache & MMU handling - from Paul Fine <pfine@delcomsys.com>
author gthomas
date Tue, 04 Mar 2003 17:18:47 +0000
parents 0b204117867f
children 6f7cf296f8a2
files packages/hal/powerpc/mpc8260/current/ChangeLog packages/hal/powerpc/mpc8260/current/include/var_cache.h packages/hal/powerpc/ts6/current/ChangeLog packages/hal/powerpc/ts6/current/cdl/hal_powerpc_ts6.cdl packages/hal/powerpc/ts6/current/misc/redboot_RAM.ecm packages/hal/powerpc/ts6/current/misc/redboot_ROM.ecm packages/hal/powerpc/ts6/current/misc/redboot_ROMRAM.ecm packages/hal/powerpc/ts6/current/src/hal_aux.c packages/hal/powerpc/ts6/current/src/ts6.S packages/hal/powerpc/vads/current/ChangeLog packages/hal/powerpc/vads/current/cdl/hal_powerpc_vads.cdl
diffstat 11 files changed, 105 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/powerpc/mpc8260/current/ChangeLog
+++ b/packages/hal/powerpc/mpc8260/current/ChangeLog
@@ -1,3 +1,9 @@
+2003-03-04  Paul Fine <pfine@delcomsys.com>
+	
+	* include/var_cache.h: Modify the HAL_DCACHE_SYNC macro to look
+	like the MACRO defined in the PPC60x HAL.
+	
+
 2002-12-12  Gary Thomas  <gthomas@ecoscentric.com>
 2002-12-12  Patrick Doyle <wpd@delcomsys.com>
 
--- a/packages/hal/powerpc/mpc8260/current/include/var_cache.h
+++ b/packages/hal/powerpc/mpc8260/current/include/var_cache.h
@@ -137,35 +137,15 @@
 
 
 // Synchronize the contents of the cache with memory.
-// Use a brute force method until something better appears in my head
-// By loading memory from 0x0 to HAL_DCACHE_SIZE, incremented by
-// HAL_DCACHE_LINE_SIZE, it will ensure that the contents of the data
-// cache is known.  Then, I will traverse the loop again, this time
-// flushing the address, not loading it.
-#if 1
+// Use the macro defined in the PPC60x HAL as of January 2003.
 #define HAL_DCACHE_SYNC()                                       \
     CYG_MACRO_START                                             \
-    volatile cyg_uint32 tmp1,tmp2;          \
-    for (tmp1 = 0; tmp1 < HAL_DCACHE_SIZE; tmp1 += HAL_DCACHE_LINE_SIZE) \
-        tmp2 = *((cyg_uint32 *) tmp1);      \
-    HAL_DCACHE_FLUSH(0x0, HAL_DCACHE_SIZE); \
+    cyg_int32 i;                                                \
+    cyg_uint32 *__base = (cyg_uint32 *) (0);                    \
+    for(i=0;i< (HAL_DCACHE_SIZE/HAL_DCACHE_LINE_SIZE);i++,__base += HAL_DCACHE_LINE_SIZE/4){                                                    \
+        asm volatile ("lwz %%r0,0(%0);"::"r"(__base):"r0");     \
+    }                                                           \
     CYG_MACRO_END
-#else
-#define HAL_DCACHE_SYNC()                                       \
-    CYG_MACRO_START                                             \
-    cyg_uint32 __base = 0x0, _tmp;                              \
-    cyg_int32 __size = HAL_DCACHE_SIZE;                         \
-    while (__size > 0) {                                        \
-        asm volatile (                                          \
-                      "lwz %0,0(%1);"                           \
-                      :"=r" (_tmp) : "r" (__base)               \
-                     );                                         \
-        __base += HAL_DCACHE_LINE_SIZE;                         \
-        __size -= HAL_DCACHE_LINE_SIZE;                         \
-    }                                                           \
-    HAL_DCACHE_FLUSH( 0x0 , HAL_DCACHE_SIZE );                  \
-    CYG_MACRO_END
-#endif
 
 // Query the state of the data cache
 #define HAL_DCACHE_IS_ENABLED(_state_)                          \
@@ -307,10 +287,13 @@
     asm volatile ("sync;"                             \
                   "mfspr %0, %2;"                     \
                   "ori   %1, %0, 0x8000;"             \
-                  "isync;"                            \
                   "mtspr %2, %1;"                     \
-                  "ori   %1, %0, 0x0800;"             \
+                  "isync;"                            \
+                  "sync;"                             \
+                  "ori   %1, %1, 0x0800;"             \
                   "mtspr %2, %1;"                     \
+                  "isync;"                            \
+                  "sync;"                             \
                   "mtspr %2, %0;"                     \
                   "isync;"                            \
                   "sync;"                             \
--- a/packages/hal/powerpc/ts6/current/ChangeLog
+++ b/packages/hal/powerpc/ts6/current/ChangeLog
@@ -1,3 +1,18 @@
+2003-03-04  Paul Fine <pfine@delcomsys.com>
+	
+	* cdl/hal_powerpc_ts6.cdl: Now that the cache control macros
+	are correct and quicc2 ethernet driver has been fixed with respect
+	to caching operations, allow the cache to be enabled at startup.
+	* src/ts6.S: Make SDRAM test global, so that RedBoot (for ROM)
+	can invoke the test.
+	* src/hal_aux.c : Add RedBoot command to test SDRAM.  Also modify
+	the initialization of the Serial Periphial Interface (SPI)
+	controller in the CPM. Also removed some debug code.
+	* redboot_RAM.ecm:
+	* redboot_ROM.ecm:
+	* redboot_ROMRAM.ecm: Bumped DCS version to 1.17, added
+	REDBOOT_BACKUP option.
+
 2002-12-12  Gary Thomas  <gthomas@ecoscentric.com>
 2002-12-12  Patrick Doyle <wpd@delcomsys.com>
 
--- a/packages/hal/powerpc/ts6/current/cdl/hal_powerpc_ts6.cdl
+++ b/packages/hal/powerpc/ts6/current/cdl/hal_powerpc_ts6.cdl
@@ -67,9 +67,6 @@ cdl_package CYGPKG_HAL_POWERPC_TS6 {
     implements    CYGINT_HAL_DEBUG_GDB_STUBS_BREAK
     implements    CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT
 
-    requires { CYGSEM_HAL_ENABLE_DCACHE_ON_STARTUP == 0 }
-    requires { CYGSEM_HAL_ENABLE_ICACHE_ON_STARTUP == 0 }
-
     define_proc {
         puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H   <pkgconf/hal_powerpc_mpc8260.h>"
         puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_powerpc_ts6.h>"
--- a/packages/hal/powerpc/ts6/current/misc/redboot_RAM.ecm
+++ b/packages/hal/powerpc/ts6/current/misc/redboot_RAM.ecm
@@ -56,7 +56,7 @@ cdl_component CYGBLD_BUILD_REDBOOT {
 };
 
 cdl_option CYGDAT_REDBOOT_CUSTOM_VERSION {
-    user_value 1 "DCS Version 1.16"
+    user_value 1 "DCS Version 1.17"
 };
 
 cdl_option CYGBLD_REDBOOT_MIN_IMAGE_SIZE {
@@ -71,6 +71,10 @@ cdl_option CYGNUM_REDBOOT_FLASH_RESERVED
     user_value 1
 };
 
+cdl_option CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP {
+    user_value 1
+};
+
 cdl_option CYGBLD_ISO_STRTOK_R_HEADER {
     inferred_value 1 <cyg/libc/string/string.h>
 };
--- a/packages/hal/powerpc/ts6/current/misc/redboot_ROM.ecm
+++ b/packages/hal/powerpc/ts6/current/misc/redboot_ROM.ecm
@@ -60,7 +60,7 @@ cdl_component CYGBLD_BUILD_REDBOOT {
 };
 
 cdl_option CYGDAT_REDBOOT_CUSTOM_VERSION {
-    user_value 1 "DCS Version 1.16"
+    user_value 1 "DCS Version 1.17"
 };
 
 cdl_option CYGBLD_REDBOOT_MIN_IMAGE_SIZE {
@@ -75,6 +75,10 @@ cdl_option CYGNUM_REDBOOT_FLASH_RESERVED
     user_value 0x40000
 };
 
+cdl_option CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP {
+    user_value 1
+};
+
 cdl_option CYGBLD_ISO_STRTOK_R_HEADER {
     inferred_value 1 <cyg/libc/string/string.h>
 };
--- a/packages/hal/powerpc/ts6/current/misc/redboot_ROMRAM.ecm
+++ b/packages/hal/powerpc/ts6/current/misc/redboot_ROMRAM.ecm
@@ -78,6 +78,10 @@ cdl_option CYGNUM_REDBOOT_FLASH_RESERVED
     user_value 1
 };
 
+cdl_option CYGOPT_REDBOOT_FIS_REDBOOT_BACKUP {
+    user_value 1
+};
+
 cdl_option CYGBLD_ISO_STRTOK_R_HEADER {
     inferred_value 1 <cyg/libc/string/string.h>
 };
--- a/packages/hal/powerpc/ts6/current/src/hal_aux.c
+++ b/packages/hal/powerpc/ts6/current/src/hal_aux.c
@@ -64,6 +64,36 @@
 #include <cyg/hal/hal_intr.h>
 #include <cyg/hal/mpc8260.h>            // Needed for IMMR structure
 
+#ifdef CYG_HAL_STARTUP_ROM
+#ifdef CYGPKG_REDBOOT
+#include <pkgconf/redboot.h>
+#include <redboot.h>
+// Exported CLI function
+RedBoot_cmd("sdram_test", 
+            "test the sdram", 
+            "",
+            do_sdram_test 
+    );
+
+void
+do_sdram_test(int argc, char *argv[])
+{
+    unsigned long oldints;
+
+    diag_printf("Starting test for SDRAM.\n");
+    diag_printf("D18 will indicate PASS/FAIL (Green/Red).\n");
+    diag_printf("Resetting board will be necessary after test completion.\n");
+    HAL_DISABLE_INTERRUPTS(oldints);
+    memory_test();
+}
+#endif
+#endif
+// For Baud Rate Calculation, see MPC8260 PowerQUICC II User's Manual
+// 16.3 UART Baud Rate Examples, page 16-5.
+#define UART_BIT_RATE(n) \
+    (((int)(CYGHWR_HAL_POWERPC_BOARD_SPEED*1000000))/(n * 64))
+#define UART_BAUD_RATE CYGNUM_HAL_TS6_DIAG_BAUD
+
 // The memory map is weakly defined, allowing the application to redefine
 // it if necessary. The regions defined below are the minimum requirements.
 CYGARC_MEMDESC_TABLE CYGBLD_ATTRIB_WEAK = {
@@ -87,12 +117,6 @@ CYGARC_MEMDESC_TABLE CYGBLD_ATTRIB_WEAK 
 
 volatile t_PQ2IMM  *IMM;   /* IMM base pointer */
 
-// Define some space in high SDRAM that I can use for debugging
-#define nPFDEBUG
-#ifdef PFDEBUG
-cyg_uint32 *dbg_values = (cyg_uint32 *) 0x00FFFF00;
-#endif
-
 //--------------------------------------------------------------------------
 // Platform init code.
 void
@@ -159,17 +183,20 @@ hal_platform_init(void)
     IMM->io_regs[PORT_D].podr |= 0x00000800;
     IMM->io_regs[PORT_D].pdat |= 0x09800000;
 
+#ifdef USE_CPM_SPI_CONTROLLER
     // Dedicated Pin assignments for SPI
     IMM->io_regs[PORT_D].ppar |= 0x0000F000;
     IMM->io_regs[PORT_D].podr &= 0xFFFF0FFF;
     IMM->io_regs[PORT_D].pdir |= 0x0000F000;
-
+#else
+    // The ts6 board does not use the SPI controller provided by the CPM,
+    // instead it is left up to the application to control the SPI.
+    // Therefore, initialize the SPI specific pins as General Purpose I/O
+    // and Bi-directional.
+    IMM->io_regs[PORT_D].ppar &= 0xFFFF0FFF; /* General Purpose I/O */
+    IMM->io_regs[PORT_D].pdir &= 0xFFFF0FFF; /* input or Bi-directional */
+#endif
 
-#ifdef PFDEBUG
-  int i;
-  for(i = 0; i < 20;i++)
-    dbg_values[i] = 0;
-#endif
 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
     hal_if_init();
 #endif
--- a/packages/hal/powerpc/ts6/current/src/ts6.S
+++ b/packages/hal/powerpc/ts6/current/src/ts6.S
@@ -1476,6 +1476,7 @@ count_done:
    #
    # Use two loops, the outer loop goes from 0 to 0x3ff and counts
    # by 1.  The inner loop goes from 0 to 0xfffc and counts by 4.
+ .globl     memory_test
 memory_test:	
 
    #Turn on Green Led
@@ -1527,6 +1528,14 @@ memwrite_loop2:
    add      r6,r3,r5
    stwx     r6,r5,r3      # Store the value at r6 in the memory addressed
 	                  # by the sum of r3 and r5
+   nop
+   nop
+   nop
+#   lwzx     r10,r5,r3     # Read the value into r10 from the memory addressed
+	                  # by the sum of r3 and r5
+#   cmpw     r6,r10        # compare values to confirm write 
+#   bne      mem_error
+	
    cmpi	    0,0,r5,0
    bne      memwrite_loop2 # branch if r5 != 0
 
@@ -1557,10 +1566,10 @@ memread_loop1:
 memread_loop2:
    addi     r5,r5,-4      # subtract 1 from r5
 	
-   add      r6,r3,r5
-   lwzx     r10,r5,r3     # Read the value into r10 from the memory addressed
+   add      r16,r3,r5
+   lwzx     r20,r5,r3     # Read the value into r20 from the memory addressed
 	                  # by the sum of r3 and r5
-   cmpw     r6,r10        # compare values
+   cmpw     r16,r20        # compare values
    bne      mem_error
 	
    cmpi	    0,0,r5,0
--- a/packages/hal/powerpc/vads/current/ChangeLog
+++ b/packages/hal/powerpc/vads/current/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-04  Paul Fine <pfine@delcomsys.com>
+	
+	* cdl/hal_powerpc_vads.cdl: Now that the cache control macros
+	are correct and quicc2 ethernet driver has been fixed with respect
+	to caching operations, allow the cache, and MMU, to be enabled at
+	startup.
+
 2002-12-12  Gary Thomas  <gthomas@ecoscentric.com>
 2002-12-12  Patrick Doyle <wpd@delcomsys.com>
 
--- a/packages/hal/powerpc/vads/current/cdl/hal_powerpc_vads.cdl
+++ b/packages/hal/powerpc/vads/current/cdl/hal_powerpc_vads.cdl
@@ -124,7 +124,7 @@ cdl_package CYGPKG_HAL_POWERPC_VADS {
     cdl_option CYGHWR_HAL_POWERPC_DISABLE_MMU {
         display       "DISABLE MMU"
         flavor        bool
-        default_value 1
+        default_value 0
 	#        calculated    1
         description   "
             This option will disable the MMU enabled."