Fixe to kernel build and syscalls.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5738 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
1125cbdc2d
commit
5be9588ed4
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -70,7 +70,7 @@ OBJS = $(COBJS)
|
|||
# Targets:
|
||||
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: depend clean distclean
|
||||
.PHONY: nuttx_user.elf depend clean distclean
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
|
|
@ -70,7 +70,7 @@ OBJS = $(COBJS)
|
|||
# Targets:
|
||||
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: depend clean distclean
|
||||
.PHONY: nuttx_user.elf depend clean distclean
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
|
|
@ -49,10 +49,12 @@
|
|||
|
||||
/* Macro Name: ASSERT, ASSERTCODE, et al. */
|
||||
|
||||
#undef ASSERT
|
||||
#undef ASSERTCODE
|
||||
#undef DEBUGASSERT
|
||||
#undef PANIC
|
||||
#undef ASSERT - Assert if the condition is not true
|
||||
#undef ASSERTCODE - Assert with an error code if the condition is not true
|
||||
#undef VERIFY - Assert if a function returns a negative value
|
||||
#undef DEBUGASSERT - Like ASSERT, but only if CONFIG_DEBUG is defined
|
||||
#undef DEBUGVERIFY - Like VERIFY, but only if CONFIG_DEBUG is defined
|
||||
#undef PANIC - Unconditional error with code
|
||||
|
||||
#ifdef CONFIG_HAVE_FILENAME
|
||||
|
||||
|
@ -62,11 +64,17 @@
|
|||
# define ASSERTCODE(f, code) \
|
||||
{ if (!(f)) up_assert_code((const uint8_t *)__FILE__, (int)__LINE__, code); }
|
||||
|
||||
# define VERIFY(f) \
|
||||
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
||||
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define DEBUGASSERT(f) \
|
||||
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
||||
# define DEBUGVERIFY(f) \
|
||||
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
|
||||
# else
|
||||
# define DEBUGASSERT(f)
|
||||
# define DEBUGVERIFY(f) ((void)(f))
|
||||
# endif /* CONFIG_DEBUG */
|
||||
|
||||
# define PANIC(code) \
|
||||
|
@ -79,11 +87,17 @@
|
|||
# define ASSERTCODE(f, code) \
|
||||
{ if (!(f)) up_assert_code(code); }
|
||||
|
||||
# define VERIFY(f) \
|
||||
{ if ((f) < 0) up_assert(); }
|
||||
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define DEBUGASSERT(f) \
|
||||
{ if (!(f)) up_assert(); }
|
||||
# define DEBUGVERIFY(f) \
|
||||
{ if ((f) < 0) up_assert(); }
|
||||
# else
|
||||
# define DEBUGASSERT(f)
|
||||
# define DEBUGVERIFY(f) ((void)(f))
|
||||
# endif /* CONFIG_DEBUG */
|
||||
|
||||
# define PANIC(code) \
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <assert.h>
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_NUTTX_KERNEL) || !defined(__KERNEL__)
|
||||
|
|
|
@ -225,6 +225,10 @@ int group_allocate(FAR struct task_tcb_s *tcb)
|
|||
ret = env_dup(group);
|
||||
if (ret < 0)
|
||||
{
|
||||
#if CONFIG_NFILE_STREAMS > 0 && defined(CONFIG_NUTTX_KERNEL) && \
|
||||
defined(CONFIG_MM_KERNEL_HEAP)
|
||||
kufree(group->tg_streamlist);
|
||||
#endif
|
||||
kfree(group);
|
||||
tcb->cmn.group = NULL;
|
||||
return ret;
|
||||
|
|
|
@ -80,14 +80,14 @@
|
|||
|
||||
int group_setupidlefiles(FAR struct task_tcb_s *tcb)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
FAR struct task_group_s *group = tcb->cmn.group;
|
||||
#endif
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_DEV_CONSOLE)
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
DEBUGASSERT(group);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,8 +39,9 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
@ -463,28 +464,28 @@ void os_start(void)
|
|||
/* Allocate the IDLE group and suppress child status. */
|
||||
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
(void)group_allocate(&g_idletcb);
|
||||
DEBUGVERIFY(group_allocate(&g_idletcb));
|
||||
#endif
|
||||
|
||||
/* Create stdout, stderr, stdin on the IDLE task. These will be
|
||||
* inherited by all of the threads created by the IDLE task.
|
||||
*/
|
||||
|
||||
(void)group_setupidlefiles(&g_idletcb);
|
||||
DEBUGVERIFY(group_setupidlefiles(&g_idletcb));
|
||||
|
||||
/* Complete initialization of the IDLE group. Suppress retention
|
||||
* of child status in the IDLE group.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
(void)group_initialize(&g_idletcb);
|
||||
DEBUGVERIFY(group_initialize(&g_idletcb));
|
||||
g_idletcb.cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT;
|
||||
#endif
|
||||
|
||||
/* Bring Up the System ****************************************************/
|
||||
/* Create initial tasks and bring-up the system */
|
||||
|
||||
(void)os_bringup();
|
||||
DEBUGVERIFY(os_bringup());
|
||||
|
||||
/* The IDLE Loop **********************************************************/
|
||||
/* When control is return to this point, the system is idle. */
|
||||
|
|
Loading…
Reference in New Issue