Misc fixes to repair some of the breakage to the SAMA5D4-EK elf configuration caused by changes for the knsh configuration

This commit is contained in:
Gregory Nutt 2014-09-11 10:31:12 -06:00
parent a20e584dab
commit 0fc55d042f
6 changed files with 67 additions and 25 deletions

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/include/arch.h * arch/arm/include/arch.h
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -137,6 +137,7 @@ struct group_addrenv_s
FAR uintptr_t *text[ARCH_TEXT_NSECTS]; FAR uintptr_t *text[ARCH_TEXT_NSECTS];
FAR uintptr_t *data[ARCH_DATA_NSECTS]; FAR uintptr_t *data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
FAR uintptr_t *heap[ARCH_HEAP_NSECTS]; FAR uintptr_t *heap[ARCH_HEAP_NSECTS];
/* Initial heap allocation (in bytes). This exists only provide an /* Initial heap allocation (in bytes). This exists only provide an
@ -146,6 +147,7 @@ struct group_addrenv_s
*/ */
size_t heapsize; size_t heapsize;
#endif
}; };
typedef struct group_addrenv_s group_addrenv_t; typedef struct group_addrenv_s group_addrenv_t;

View File

@ -510,6 +510,7 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize,
} }
#endif #endif
#ifdef CONFIG_BUILD_KERNEL
/* Allocate heap space pages */ /* Allocate heap space pages */
ret = up_addrenv_create_region(addrenv->heap, ARCH_HEAP_NSECTS, ret = up_addrenv_create_region(addrenv->heap, ARCH_HEAP_NSECTS,
@ -526,6 +527,7 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize,
*/ */
addrenv->heapsize = (size_t)ret << MM_PGSHIFT; addrenv->heapsize = (size_t)ret << MM_PGSHIFT;
#endif
return OK; return OK;
errout: errout:
@ -564,12 +566,14 @@ int up_addrenv_destroy(FAR group_addrenv_t *addrenv)
up_addrenv_destroy_region(addrenv->data, ARCH_DATA_NSECTS, up_addrenv_destroy_region(addrenv->data, ARCH_DATA_NSECTS,
CONFIG_ARCH_DATA_VBASE); CONFIG_ARCH_DATA_VBASE);
#ifdef CONFIG_BUILD_KERNEL
/* Destroy the heap region */ /* Destroy the heap region */
up_addrenv_destroy_region(addrenv->heap, ARCH_HEAP_NSECTS, up_addrenv_destroy_region(addrenv->heap, ARCH_HEAP_NSECTS,
CONFIG_ARCH_HEAP_VBASE); CONFIG_ARCH_HEAP_VBASE);
memset(addrenv, 0, sizeof(group_addrenv_t)); memset(addrenv, 0, sizeof(group_addrenv_t));
#endif
return OK; return OK;
} }
@ -654,11 +658,13 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
ssize_t up_addrenv_heapsize(FAR const group_addrenv_t *addrenv) ssize_t up_addrenv_heapsize(FAR const group_addrenv_t *addrenv)
{ {
DEBUGASSERT(addrenv); DEBUGASSERT(addrenv);
return (ssize_t)addrenv->heapsize; return (ssize_t)addrenv->heapsize;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: up_addrenv_select * Name: up_addrenv_select
@ -742,6 +748,7 @@ int up_addrenv_select(FAR const group_addrenv_t *addrenv,
} }
} }
#ifdef CONFIG_BUILD_KERNEL
for (vaddr = CONFIG_ARCH_HEAP_VBASE, i = 0; for (vaddr = CONFIG_ARCH_HEAP_VBASE, i = 0;
i < ARCH_HEAP_NSECTS; i < ARCH_HEAP_NSECTS;
vaddr += SECTION_SIZE, i++) vaddr += SECTION_SIZE, i++)
@ -765,6 +772,7 @@ int up_addrenv_select(FAR const group_addrenv_t *addrenv,
mmu_l1_clrentry(vaddr); mmu_l1_clrentry(vaddr);
} }
} }
#endif
return OK; return OK;
} }
@ -812,6 +820,7 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv)
mmu_l1_restore(vaddr, oldenv->data[i]); mmu_l1_restore(vaddr, oldenv->data[i]);
} }
#ifdef CONFIG_BUILD_KERNEL
for (vaddr = CONFIG_ARCH_HEAP_VBASE, i = 0; for (vaddr = CONFIG_ARCH_HEAP_VBASE, i = 0;
i < ARCH_HEAP_NSECTS; i < ARCH_HEAP_NSECTS;
vaddr += SECTION_SIZE, i++) vaddr += SECTION_SIZE, i++)
@ -820,6 +829,7 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv)
mmu_l1_restore(vaddr, oldenv->heap[i]); mmu_l1_restore(vaddr, oldenv->heap[i]);
} }
#endif
return OK; return OK;
} }

View File

@ -136,7 +136,7 @@ static void exec_ctors(FAR void *arg)
int exec_module(FAR const struct binary_s *binp) int exec_module(FAR const struct binary_s *binp)
{ {
FAR struct task_tcb_s *tcb; FAR struct task_tcb_s *tcb;
#ifdef CONFIG_ARCH_ADDRENV #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
save_addrenv_t oldenv; save_addrenv_t oldenv;
#endif #endif
FAR uint32_t *stack; FAR uint32_t *stack;
@ -165,7 +165,7 @@ int exec_module(FAR const struct binary_s *binp)
goto errout; goto errout;
} }
#ifdef CONFIG_ARCH_ADDRENV #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
/* Instantiate the address environment containing the user heap */ /* Instantiate the address environment containing the user heap */
ret = up_addrenv_select(&binp->addrenv, &oldenv); ret = up_addrenv_select(&binp->addrenv, &oldenv);
@ -260,7 +260,7 @@ int exec_module(FAR const struct binary_s *binp)
goto errout_with_stack; goto errout_with_stack;
} }
#ifdef CONFIG_ARCH_ADDRENV #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
/* Restore the address environment of the caller */ /* Restore the address environment of the caller */
ret = up_addrenv_restore(&oldenv); ret = up_addrenv_restore(&oldenv);
@ -281,10 +281,10 @@ errout_with_stack:
goto errout; goto errout;
errout_with_addrenv: errout_with_addrenv:
#ifdef CONFIG_ARCH_ADDRENV #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
(void)up_addrenv_restore(&oldenv); (void)up_addrenv_restore(&oldenv);
#endif
errout_with_tcb: errout_with_tcb:
#endif
kmm_free(tcb); kmm_free(tcb);
errout: errout:
set_errno(err); set_errno(err);

View File

@ -3726,6 +3726,11 @@ Configurations
http://www.nuttx.org/doku.php?id=wiki:nxinternal:memconfigs#task_create http://www.nuttx.org/doku.php?id=wiki:nxinternal:memconfigs#task_create
2014-8-29: System call interface verified. 2014-8-29: System call interface verified.
2014-9-11: There has been some breakage due to changes for the knsh
configuration. This test now hangs after running the first
ELF program. With GDB I can see that the IDLE loop is running
but apparently either ELF main program is deadlocked. Need to
revisit.
knsh: knsh:
An NSH configuration used to test the SAMA5D kenel build configuration. An NSH configuration used to test the SAMA5D kenel build configuration.

View File

@ -368,6 +368,7 @@ CONFIG_PREALLOC_TIMERS=4
# #
# Tasks and Scheduling # Tasks and Scheduling
# #
# CONFIG_INIT_NONE is not set
CONFIG_INIT_ENTRYPOINT=y CONFIG_INIT_ENTRYPOINT=y
# CONFIG_INIT_FILEPATH is not set # CONFIG_INIT_FILEPATH is not set
CONFIG_USER_ENTRYPOINT="elf_main" CONFIG_USER_ENTRYPOINT="elf_main"

View File

@ -47,26 +47,50 @@
************************************************************************/ ************************************************************************/
/* How can we access the errno variable? */ /* How can we access the errno variable? */
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
/* Flat build */
# if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__)
/* We still might be using system calls in user code. If so, then
* user code will have no direct access to the errno variable.
*/
# undef __DIRECT_ERRNO_ACCESS # undef __DIRECT_ERRNO_ACCESS
#if !defined(CONFIG_LIB_SYSCALL)
/* No system calls? Then there can only be direct access */ # else
/* Flat build with no system calls OR internal kernel logic... There
* is direct access.
*/
# define __DIRECT_ERRNO_ACCESS 1
# endif
#elif defined(CONFIG_BUILD_PROTECTED)
# if defined(__KERNEL__)
/* Kernel portion of protected build. Kernel code has direct access */
# define __DIRECT_ERRNO_ACCESS 1 # define __DIRECT_ERRNO_ACCESS 1
#elif !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) # else
/* Flat build... complete access */ /* User portion of protected build. Application code has only indirect
* access
*/
# undef __DIRECT_ERRNO_ACCESS
# endif
#elif defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__)
# if defined(__KERNEL__)
/* Kernel build. Kernel code has direct access */
# define __DIRECT_ERRNO_ACCESS 1 # define __DIRECT_ERRNO_ACCESS 1
#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) # else
/* Kernel portion of protected build. The Kernel has access */ /* User libraries for the kernel. Only indirect access from user
* libraries */
# define __DIRECT_ERRNO_ACCESS 1 # undef __DIRECT_ERRNO_ACCESS
# endif
#elif defined(CONFIG_BUILD_KERNEL) && defined(__KERNEL__)
/* Kernel only build. The kernel has access */
# define __DIRECT_ERRNO_ACCESS 1
#endif #endif
/* Convenience/compatibility definition. /* Convenience/compatibility definition.