summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-08-09 17:55:27 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-08-09 17:55:27 -0600
commitf8961d02c8b37ce75589e3e6a7c09539ea8b2237 (patch)
treedbb20c106af8f8f646eefa5363723498b0ae0a26
parent408ca2c492a6af15c362a5b1e38641d835730cd0 (diff)
downloadnuttx-f8961d02c8b37ce75589e3e6a7c09539ea8b2237.tar.gz
nuttx-f8961d02c8b37ce75589e3e6a7c09539ea8b2237.tar.bz2
nuttx-f8961d02c8b37ce75589e3e6a7c09539ea8b2237.zip
Extend the virtual-to-physical address conversion logic to handle NFS SRM, UDPH SRAM, and external SRAM and PSRAM.
-rw-r--r--nuttx/arch/arm/src/sama5/sam_memories.c324
1 files changed, 290 insertions, 34 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_memories.c b/nuttx/arch/arm/src/sama5/sam_memories.c
index a8df6f93f..3a723f996 100644
--- a/nuttx/arch/arm/src/sama5/sam_memories.c
+++ b/nuttx/arch/arm/src/sama5/sam_memories.c
@@ -63,17 +63,18 @@
*
****************************************************************************/
-static uintptr_t peripha_physregaddr(uintptr_t vregaddr)
+static inline uintptr_t peripha_physregaddr(uintptr_t vregaddr)
{
#if SAM_PERIPHA_PSECTION != SAM_PERIPHA_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * register
+ */
- /* Get the offset into the 1MB section containing the register */
-
- uintptr_t sectoffset = vregaddr & 0x000fffff;
+ uintptr_t sectoffset = vregaddr - SAM_PERIPHA_VSECTION;
- /* Return that offset into the virtual peripheral A base address */
+ /* Add that offset to the physical base address of the memory region */
- return SAM_PERIPHA_PSECTION | sectoffset;
+ return SAM_PERIPHA_PSECTION + sectoffset;
#else
/* 1-to-1 mapping */
@@ -92,17 +93,18 @@ static uintptr_t peripha_physregaddr(uintptr_t vregaddr)
*
****************************************************************************/
-static uintptr_t periphb_physregaddr(uintptr_t vregaddr)
+static inline uintptr_t periphb_physregaddr(uintptr_t vregaddr)
{
#if SAM_PERIPHB_PSECTION != SAM_PERIPHB_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * register
+ */
- /* Get the offset into the 1MB section containing the register */
-
- uintptr_t sectoffset = vregaddr & 0x000fffff;
+ uintptr_t sectoffset = vregaddr - SAM_PERIPHB_VSECTION;
- /* Return that offset into the virtual peripheral A base address */
+ /* Add that offset to the physical base address of the memory region */
- return SAM_PERIPHB_PSECTION | sectoffset;
+ return SAM_PERIPHB_PSECTION + sectoffset;
#else
/* 1-to-1 mapping */
@@ -121,17 +123,18 @@ static uintptr_t periphb_physregaddr(uintptr_t vregaddr)
*
****************************************************************************/
-static uintptr_t sysc_physregaddr(uintptr_t vregaddr)
+static inline uintptr_t sysc_physregaddr(uintptr_t vregaddr)
{
#if SAM_SYSC_PSECTION != SAM_SYSC_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * register
+ */
- /* Get the offset into the 1MB section containing the register */
-
- uintptr_t sectoffset = vregaddr & 0x000fffff;
+ uintptr_t sectoffset = vregaddr - SAM_SYSC_VSECTION;
- /* Return that offset into the virtual peripheral A base address */
+ /* Add that offset to the physical base address of the memory region */
- return SAM_SYSC_PSECTION | sectoffset;
+ return SAM_SYSC_PSECTION + sectoffset;
#else
/* 1-to-1 mapping */
@@ -142,7 +145,7 @@ static uintptr_t sysc_physregaddr(uintptr_t vregaddr)
}
/****************************************************************************
- * Name: isram_physregaddr
+ * Name: isram_physramaddr
*
* Description:
* Give the virtual address of an internal SRAM memory location, return the
@@ -150,17 +153,18 @@ static uintptr_t sysc_physregaddr(uintptr_t vregaddr)
*
****************************************************************************/
-static uintptr_t isram_physregaddr(uintptr_t vregaddr)
+static inline uintptr_t isram_physramaddr(uintptr_t vregaddr)
{
#if SAM_ISRAM_PSECTION != SAM_ISRAM_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
- /* Get the offset into the 1MB section containing the register */
-
- uintptr_t sectoffset = vregaddr & 0x000fffff;
+ uintptr_t sectoffset = vregaddr - SAM_ISRAM_VSECTION;
- /* Return that offset into the virtual peripheral A base address */
+ /* Add that offset to the physical base address of the memory region */
- return SAM_ISRAM_PSECTION | sectoffset;
+ return SAM_ISRAM_PSECTION + sectoffset;
#else
/* 1-to-1 mapping */
@@ -171,7 +175,7 @@ static uintptr_t isram_physregaddr(uintptr_t vregaddr)
}
/****************************************************************************
- * Name: sdram_physregaddr
+ * Name: sdram_physramaddr
*
* Description:
* Give the virtual address of an external SDRAM memory location, return
@@ -180,17 +184,210 @@ static uintptr_t isram_physregaddr(uintptr_t vregaddr)
****************************************************************************/
#ifdef CONFIG_SAMA5_DDRCS
-static uintptr_t sdram_physregaddr(uintptr_t vregaddr)
+static inline uintptr_t sdram_physramaddr(uintptr_t vregaddr)
{
#if SAM_DDRCS_PSECTION != SAM_DDRCS_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_DDRCS_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_DDRCS_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: nfcsram_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an NFC SRAM memory location, return the
+ * physical address of that location
+ *
+ ****************************************************************************/
+
+static inline uintptr_t nfcsram_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_NFCSRAM_PSECTION != SAM_NFCSRAM_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_NFCSRAM_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_NFCSRAM_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
- /* Get the offset into the 1MB section containing the register */
+/****************************************************************************
+ * Name: udphsram_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an UDPH SRAM memory location, return the
+ * physical address of that location
+ *
+ ****************************************************************************/
- uintptr_t sectoffset = vregaddr & 0x000fffff;
+static inline uintptr_t udphsram_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_UDPHSRAM_PSECTION != SAM_UDPHSRAM_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
- /* Return that offset into the virtual peripheral A base address */
+ uintptr_t sectoffset = vregaddr - SAM_UDPHSRAM_VSECTION;
- return SAM_DDRCS_PSECTION | sectoffset;
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_UDPHSRAM_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
+
+/****************************************************************************
+ * Name: ebics0_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an external CS0 SRAM memory location,
+ * return the physical address of that location
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_SAMA5_EBICS0) && (defined(CONFIG_SAMA5_EBICS0_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS0_PSRAM))
+static inline uintptr_t ebics0_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_EBICS0_PSECTION != SAM_EBICS0_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_EBICS0_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_EBICS0_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: ebics1_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an external CS1 SRAM memory location,
+ * return the physical address of that location
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_SAMA5_EBICS1) && (defined(CONFIG_SAMA5_EBICS1_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS1_PSRAM))
+static inline uintptr_t ebics1_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_EBICS1_PSECTION != SAM_EBICS1_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_EBICS1_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_EBICS1_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: ebics2_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an external CS2 SRAM memory location,
+ * return the physical address of that location
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_SAMA5_EBICS2) && (defined(CONFIG_SAMA5_EBICS2_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS2_PSRAM))
+static inline uintptr_t ebics2_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_EBICS2_PSECTION != SAM_EBICS2_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_EBICS2_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_EBICS2_PSECTION + sectoffset;
+
+#else
+ /* 1-to-1 mapping */
+
+ return vregaddr;
+
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: ebics3_physramaddr
+ *
+ * Description:
+ * Give the virtual address of an external CS3 SRAM memory location,
+ * return the physical address of that location
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_SAMA5_EBICS3) && (defined(CONFIG_SAMA5_EBICS3_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS3_PSRAM))
+static inline uintptr_t ebics3_physramaddr(uintptr_t vregaddr)
+{
+#if SAM_EBICS3_PSECTION != SAM_EBICS3_VSECTION
+ /* Get the offset into the virtual memory region section containing the
+ * RAM memory location.
+ */
+
+ uintptr_t sectoffset = vregaddr - SAM_EBICS3_VSECTION;
+
+ /* Add that offset to the physical base address of the memory region */
+
+ return SAM_EBICS3_PSECTION + sectoffset;
#else
/* 1-to-1 mapping */
@@ -266,7 +463,7 @@ uintptr_t sam_physramaddr(uintptr_t vregaddr)
if (vregaddr >= SAM_ISRAM_VSECTION &&
vregaddr < (SAM_ISRAM_VSECTION + SAM_ISRAM_SIZE))
{
- return isram_physregaddr(vregaddr);
+ return isram_physramaddr(vregaddr);
}
#ifdef CONFIG_SAMA5_DDRCS
@@ -275,7 +472,67 @@ uintptr_t sam_physramaddr(uintptr_t vregaddr)
else if (vregaddr >= SAM_DDRCS_VSECTION &&
vregaddr < (SAM_DDRCS_VSECTION + SAMA5_DDRCS_SIZE))
{
- return sdram_physregaddr(vregaddr);
+ return sdram_physramaddr(vregaddr);
+ }
+#endif
+
+ /* Check for NFCS SRAM. */
+
+ if (vregaddr >= SAM_NFCSRAM_VSECTION &&
+ vregaddr < (SAM_NFCSRAM_VSECTION + SAM_NFCSRAM_SIZE))
+ {
+ return nfcsram_physramaddr(vregaddr);
+ }
+
+ /* Check for UDPH SRAM. */
+
+ if (vregaddr >= SAM_UDPHSRAM_VSECTION &&
+ vregaddr < (SAM_UDPHSRAM_VSECTION + SAM_UDPHSRAM_SIZE))
+ {
+ return udphsram_physramaddr(vregaddr);
+ }
+
+#if defined(CONFIG_SAMA5_EBICS0) && (defined(CONFIG_SAMA5_EBICS0_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS0_PSRAM))
+ /* Check for external SRAM or PSRAM on CS0 */
+
+ else if (vregaddr >= SAM_EBICS0_VSECTION &&
+ vregaddr < (SAM_EBICS0_VSECTION + SAMA5_EBICS0_SIZE))
+ {
+ return ebics0_physramaddr(vregaddr);
+ }
+#endif
+
+#if defined(CONFIG_SAMA5_EBICS1) && (defined(CONFIG_SAMA5_EBICS1_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS1_PSRAM))
+ /* Check for external SRAM or PSRAM on CS1 */
+
+ else if (vregaddr >= SAM_EBICS1_VSECTION &&
+ vregaddr < (SAM_EBICS1_VSECTION + SAMA5_EBICS1_SIZE))
+ {
+ return ebics1_physramaddr(vregaddr);
+ }
+#endif
+
+#if defined(CONFIG_SAMA5_EBICS2) && (defined(CONFIG_SAMA5_EBICS2_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS2_PSRAM))
+ /* Check for external SRAM or PSRAM on CS2 */
+
+ else if (vregaddr >= SAM_EBICS2_VSECTION &&
+ vregaddr < (SAM_EBICS2_VSECTION + SAMA5_EBICS2_SIZE))
+ {
+ return ebics2_physramaddr(vregaddr);
+ }
+#endif
+
+#if defined(CONFIG_SAMA5_EBICS3) && (defined(CONFIG_SAMA5_EBICS3_SRAM) || \
+ defined(CONFIG_SAMA5_EBICS3_PSRAM))
+ /* Check for external SRAM or PSRAM on CS3 */
+
+ else if (vregaddr >= SAM_EBICS3_VSECTION &&
+ vregaddr < (SAM_EBICS3_VSECTION + SAMA5_EBICS3_SIZE))
+ {
+ return ebics3_physramaddr(vregaddr);
}
#endif
@@ -286,4 +543,3 @@ uintptr_t sam_physramaddr(uintptr_t vregaddr)
DEBUGPANIC();
return vregaddr;
}
-