From 1baefe884e2baee4fed6b252bc12b2cbe46d1d70 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 13 Mar 2013 17:32:37 +0000 Subject: [PATCH] Fixe to kernel build and syscalls. git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5738 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/armv6-m/up_svcall.c | 11 +++++++---- arch/arm/src/armv7-m/up_svcall.c | 17 +++++++++++++---- arch/arm/src/lpc17xx/lpc17_allocateheap.c | 12 ++++++++++-- arch/arm/src/lpc17xx/lpc17_sdcard.c | 14 +++++++------- arch/arm/src/lpc17xx/lpc17_sdcard.h | 1 - arch/arm/src/sam3u/sam3u_allocateheap.c | 12 ++++++------ 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/arch/arm/src/armv6-m/up_svcall.c b/arch/arm/src/armv6-m/up_svcall.c index 7c2bf0f2c9a..b1bf1e4ec73 100644 --- a/arch/arm/src/armv6-m/up_svcall.c +++ b/arch/arm/src/armv6-m/up_svcall.c @@ -110,12 +110,14 @@ static void dispatch_syscall(void) { __asm__ __volatile__ ( - " push {r4}\n" /* Save R4 */ + " push {r4, r5}\n" /* Save R4 and R5 */ + " mov r5, lr\n" /* Save lr in R5 */ " ldr r4, =g_stublookup\n" /* R4=The base of the stub lookup table */ " lsl r0, r0, #2\n" /* R0=Offset of the stub for this syscall */ " ldr r4, [r4, r0]\n" /* R4=Address of the stub for this syscall */ - " blx r5\n" /* Call the stub (modifies R14) */ - " pop {r4}\n" /* Restore R4 */ + " blx r5\n" /* Call the stub (modifies lr) */ + " mov lr, r5\n" /* Restore lr */ + " pop {r4, r5}\n" /* Restore R4 and R5*/ " mov r2, r0\n" /* R2=Saves return value in R0 */ " mov r0, #3\n" /* R0=SYS_syscall_return */ " svc 0" /* Return from the syscall */ @@ -321,7 +323,8 @@ int up_svcall(int irq, FAR void *context) current_regs[REG_R12], current_regs[REG_R13], current_regs[REG_R14], current_regs[REG_R15]); #ifdef CONFIG_NUTTX_KERNEL svcdbg("xPSR: %08x BASEPRI: %08x EXEC_RETURN: %08x\n", - current_regs[REG_XPSR], current_regs[REG_BASEPRI], current_regs[REG_EXC_RETURN]); + current_regs[REG_XPSR], current_regs[REG_BASEPRI], + current_regs[REG_EXC_RETURN]); #else svcdbg("xPSR: %08x BASEPRI: %08x\n", current_regs[REG_XPSR], current_regs[REG_BASEPRI]); diff --git a/arch/arm/src/armv7-m/up_svcall.c b/arch/arm/src/armv7-m/up_svcall.c index 13cce36ef49..8321cd3bb03 100644 --- a/arch/arm/src/armv7-m/up_svcall.c +++ b/arch/arm/src/armv7-m/up_svcall.c @@ -112,9 +112,13 @@ static void dispatch_syscall(void) { __asm__ __volatile__ ( + " push {r4}\n" /* Save R4 */ + " mov r4, lr\n" /* Save lr in R4 */ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */ - " blx ip\n" /* Call the stub (modifies R14)*/ + " blx ip\n" /* Call the stub (modifies lr)*/ + " mov lr, r4\n" /* Restore lr */ + " pop {r4}\n" /* Restore r4 */ " mov r2, r0\n" /* R2=Saved return value in R0 */ " mov r0, #3\n" /* R0=SYS_syscall_return */ " svc 0" /* Return from the syscall */ @@ -152,7 +156,7 @@ int up_svcall(int irq, FAR void *context) regs[REG_R8], regs[REG_R9], regs[REG_R10], regs[REG_R11], regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]); #ifdef REG_EXC_RETURN - svcdbg(" PSR: %08x LR: %08x\n", regs[REG_XPSR], current_regs[REG_EXC_RETURN]); + svcdbg(" PSR: %08x LR: %08x\n", regs[REG_XPSR], regs[REG_EXC_RETURN]); #else svcdbg(" PSR: %08x\n", regs[REG_XPSR]); #endif @@ -265,7 +269,7 @@ int up_svcall(int irq, FAR void *context) rtcb->xcp.sysreturn = 0; /* The return value must be in R0-R1. dispatch_syscall() temporarily - * moved the value for R0 to R2. + * moved the value for R0 into R2. */ current_regs[REG_R0] = current_regs[REG_R2]; @@ -322,7 +326,12 @@ int up_svcall(int irq, FAR void *context) svcdbg(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n", current_regs[REG_R8], current_regs[REG_R9], current_regs[REG_R10], current_regs[REG_R11], current_regs[REG_R12], current_regs[REG_R13], current_regs[REG_R14], current_regs[REG_R15]); - svcdbg(" PSR=%08x\n", current_regs[REG_XPSR]); +#ifdef REG_EXC_RETURN + svcdbg(" PSR: %08x LR: %08x\n", + current_regs[REG_XPSR], current_regs[REG_EXC_RETURN]); +#else + svcdbg(" PSR: %08x\n", current_regs[REG_XPSR]); +#endif } else { diff --git a/arch/arm/src/lpc17xx/lpc17_allocateheap.c b/arch/arm/src/lpc17xx/lpc17_allocateheap.c index edd5100b3f2..f316570f55f 100644 --- a/arch/arm/src/lpc17xx/lpc17_allocateheap.c +++ b/arch/arm/src/lpc17xx/lpc17_allocateheap.c @@ -300,10 +300,18 @@ void up_addregion(void) */ #ifdef LPC17_AHB_HEAPBASE +#if defined(CONFIG_NUTTX_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) - /* Yes... Add the AHB SRAM heap region. */ + /* Yes.. allow user-mode access to the AHB SRAM user heap memory */ + + lpc17_mpu_uheap((uintptr_t)LPC17_AHB_HEAPBASE, LPC17_AHB_HEAPSIZE); + +#endif + + /* Add the AHB SRAM user heap region. */ + + kumm_addregion((FAR void*)LPC17_AHB_HEAPBASE, LPC17_AHB_HEAPSIZE); - kmm_addregion((FAR void*)LPC17_AHB_HEAPBASE, LPC17_AHB_HEAPSIZE); #endif } #endif diff --git a/arch/arm/src/lpc17xx/lpc17_sdcard.c b/arch/arm/src/lpc17xx/lpc17_sdcard.c index f52a9a35e2a..b38061404d6 100644 --- a/arch/arm/src/lpc17xx/lpc17_sdcard.c +++ b/arch/arm/src/lpc17xx/lpc17_sdcard.c @@ -1546,7 +1546,7 @@ static void lpc17_widebus(FAR struct sdio_dev_s *dev, bool wide) static void lpc17_clock(FAR struct sdio_dev_s *dev, enum sdio_clock_e rate) { - uint32_t clock; + uint32_t clkcr; switch (rate) { @@ -1554,39 +1554,39 @@ static void lpc17_clock(FAR struct sdio_dev_s *dev, enum sdio_clock_e rate) default: case CLOCK_SDIO_DISABLED: - clock = LPC17_CLCKCR_INIT; + clkcr = LPC17_CLCKCR_INIT; return; /* Enable in initial ID mode clocking (<400KHz) */ case CLOCK_IDMODE: - clock = (LPC17_CLCKCR_INIT | SDCARD_CLOCK_CLKEN); + clkcr = (LPC17_CLCKCR_INIT | SDCARD_CLOCK_CLKEN); break; /* Enable in MMC normal operation clocking */ case CLOCK_MMC_TRANSFER: - clock = (SDCARD_CLOCK_MMCXFR | SDCARD_CLOCK_CLKEN); + clkcr = (SDCARD_CLOCK_MMCXFR | SDCARD_CLOCK_CLKEN); break; /* SD normal operation clocking (wide 4-bit mode) */ case CLOCK_SD_TRANSFER_4BIT: #ifndef CONFIG_SDIO_WIDTH_D1_ONLY - clock = (SDCARD_CLOCK_SDWIDEXFR | SDCARD_CLOCK_CLKEN); + clkcr = (SDCARD_CLOCK_SDWIDEXFR | SDCARD_CLOCK_CLKEN); break; #endif /* SD normal operation clocking (narrow 1-bit mode) */ case CLOCK_SD_TRANSFER_1BIT: - clock = (SDCARD_CLOCK_SDXFR | SDCARD_CLOCK_CLKEN); + clkcr = (SDCARD_CLOCK_SDXFR | SDCARD_CLOCK_CLKEN); break; } /* Set the new clock frequency along with the clock enable/disable bit */ - lpc17_setclock(clock); + lpc17_setclock(clkcr); } /**************************************************************************** diff --git a/arch/arm/src/lpc17xx/lpc17_sdcard.h b/arch/arm/src/lpc17xx/lpc17_sdcard.h index 3cb4132b2f6..66eb68b9bc3 100644 --- a/arch/arm/src/lpc17xx/lpc17_sdcard.h +++ b/arch/arm/src/lpc17xx/lpc17_sdcard.h @@ -124,4 +124,3 @@ void sdio_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect); #endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_LPC17XX_LPC17_SDCARD_H */ - diff --git a/arch/arm/src/sam3u/sam3u_allocateheap.c b/arch/arm/src/sam3u/sam3u_allocateheap.c index 0c122aeaea9..86d5fbf3687 100644 --- a/arch/arm/src/sam3u/sam3u_allocateheap.c +++ b/arch/arm/src/sam3u/sam3u_allocateheap.c @@ -198,22 +198,22 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { - /* Add the region */ - - kmm_addregion((FAR void*)SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); - /* Allow user access to the heap memory */ sam3u_mpu_uheap(SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); /* Add the region */ -#if CONFIG_MM_REGIONS > 2 - kmm_addregion((FAR void*)SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); + kumm_addregion((FAR void*)SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); +#if CONFIG_MM_REGIONS > 2 /* Allow user access to the heap memory */ sam3u_mpu_uheap(SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); + + /* Add the region */ + + kumm_addregion((FAR void*)SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); #endif } #endif