summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-06 16:21:54 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-06 16:21:54 +0000
commita0858f5dc80ec94952af4b32903194c40f61c857 (patch)
treeb105d03e750d647b5222e67870142d62c7ed6557
parent7c64ca00e9dcd6b2d3c0647145aa8cc92e447acd (diff)
downloadnuttx-a0858f5dc80ec94952af4b32903194c40f61c857.tar.gz
nuttx-a0858f5dc80ec94952af4b32903194c40f61c857.tar.bz2
nuttx-a0858f5dc80ec94952af4b32903194c40f61c857.zip
Fix clearing of SRAM when clocks reset
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2923 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/arm/src/arm/arm.h44
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_boot.c48
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c6
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h2
4 files changed, 77 insertions, 23 deletions
diff --git a/nuttx/arch/arm/src/arm/arm.h b/nuttx/arch/arm/src/arm/arm.h
index f87159db4..4dd39e840 100644
--- a/nuttx/arch/arm/src/arm/arm.h
+++ b/nuttx/arch/arm/src/arm/arm.h
@@ -254,6 +254,9 @@
/* Default MMU flags for RAM memory, IO, vector region */
+#define MMU_ROMFLAGS \
+ (PMD_TYPE_SECT|PMD_BIT4|PMD_SECT_AP_READ)
+
#define MMU_MEMFLAGS \
(PMD_TYPE_SECT|PMD_SECT_WB|PMD_BIT4|PMD_SECT_AP_WRITE|PMD_SECT_AP_READ)
@@ -282,6 +285,47 @@
#ifndef __ASSEMBLY__
+/* Get the current value of the CP15 C1 control register */
+
+static inline unsigned int get_cp15c1(void)
+{
+ unsigned int retval;
+ __asm__ __volatile__
+ (
+ "\tmrc p15, 0, %0, c1, c0"
+ : "=r" (retval)
+ :
+ : "memory");
+ return retval;
+}
+
+/* Get the current value of the CP15 C2 page table pointer register */
+
+static inline unsigned int get_cp15c2(void)
+{
+ unsigned int retval;
+ __asm__ __volatile__
+ (
+ "\tmrc p15, 0, %0, c2, c0"
+ : "=r" (retval)
+ :
+ : "memory");
+ return retval;
+}
+/* Get the current value of the CP15 C3 domain access register */
+
+static inline unsigned int get_cp15c3(void)
+{
+ unsigned int retval;
+ __asm__ __volatile__
+ (
+ "\tmrc p15, 0, %0, c3, c0"
+ : "=r" (retval)
+ :
+ : "memory");
+ return retval;
+}
+
/* ARMv4/ARMv5 operation: Invalidate TLB
* ARM926EJ-S operation: Invalidate set-associative
* Data: Should be zero
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c b/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c
index 8840c6fdb..0a6ad34bf 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_boot.c
@@ -285,6 +285,18 @@ static void up_vectormapping(void)
static void up_copyvectorblock(void)
{
+ uint32_t *src;
+ uint32_t *end;
+ uint32_t *dest;
+
+ /* If we are using vectors in low memory but RAM in that area has been marked
+ * read only, then temparily mark the mapping write-able (non-buffered).
+ */
+
+#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING)
+ up_vectorpermissions(MMU_L2_VECTRWFLAGS);
+#endif
+
/* Copy the vectors into ISRAM at the address that will be mapped to the vector
* address:
*
@@ -293,15 +305,21 @@ static void up_copyvectorblock(void)
* LPC313X_VECTOR_VADDR - Virtual address of vector table (0x00000000 or 0xffff0000)
*/
- uint32_t *src = (uint32_t*)&_vector_start;
- uint32_t *end = (uint32_t*)&_vector_end;
- uint32_t *dest = (uint32_t*)LPC313X_VECTOR_VSRAM;
+ src = (uint32_t*)&_vector_start;
+ end = (uint32_t*)&_vector_end;
+ dest = (uint32_t*)LPC313X_VECTOR_VSRAM;
while (src < end)
{
*dest++ = *src++;
}
+ /* Make the vectors read-only, cacheable again */
+
+#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING)
+ up_vectorpermissions(MMU_L2_VECTROFLAGS);
+#endif
+
/* Then set the LPC313x shadow register, LPC313X_SYSCREG_ARM926SHADOWPTR, so that
* the vector table is mapped to address 0x0000:0000 - NOTE: that there is not yet
* full support for the vector table at address 0xffff0000.
@@ -331,14 +349,6 @@ void up_boot(void)
#ifndef CONFIG_ARCH_ROMPGTABLE
up_setupmappings();
- /* If we are using vectors in low memory but RAM in that area has been marked
- * read only, then temparily mark the mapping write-able (non-buffered).
- */
-
-#if defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING)
- up_vectorpermissions(MMU_L2_VECTRWFLAGS);
-#endif
-
/* Provide a special mapping for the IRAM interrupt vector positioned in high
* memory.
*/
@@ -354,12 +364,6 @@ void up_boot(void)
up_copyvectorblock();
- /* Make the vectors read-only, cacheable again */
-
-#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(CONFIG_ARCH_LOWVECTORS) && defined(CONFIG_PAGING)
- up_vectorpermissions(MMU_L2_VECTROFLAGS);
-#endif
-
/* Reset all clocks */
lpc313x_resetclks();
@@ -381,6 +385,16 @@ void up_boot(void)
lpc313x_lowsetup();
+ /* NOTE: Something in the operation of lpc313x_resetclks() causes the first
+ * 6 words of memory to be zeroed, wiping out the interrupt vectors. However,
+ * moving the vector initialization until after the clock setup seems to hang
+ * the system (and I can't step though the clock setup to find why without
+ * losing my JTAG connection). So, the simplest work-around is to simply
+ * initialize the vectors twice.
+ */
+
+ up_copyvectorblock();
+
/* Perform early serial initialization if we are going to use the serial driver */
#ifdef CONFIG_USE_EARLYSERIALINIT
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c b/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c
index 93f9a37b7..5bfde83fc 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_lowputc.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc313x/lpc313x_lowputc.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -340,10 +340,6 @@ void lpc313x_lowsetup(void)
}
/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
* Name: up_lowputc
*
* Description:
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h b/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h
index ad2281237..0539495f9 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_memorymap.h
@@ -183,7 +183,7 @@
/* Section MMU Flags */
-#define LPC313X_SHADOWSPACE_MMUFLAGS MMU_MEMFLAGS
+#define LPC313X_SHADOWSPACE_MMUFLAGS MMU_ROMFLAGS
#define LPC313X_INTSRAM_MMUFLAGS MMU_MEMFLAGS
#define LPC313X_INTSROM_MMUFLAGS MMU_MEMFLAGS
#define LPC313X_APB01_MMUFLAGS MMU_IOFLAGS