Improved parameters passing and startup file. Symbol _exit() is now part of the startup file.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15362 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
62ea184237
commit
160e3e52ae
|
@ -99,28 +99,32 @@ __sandbox: .long 0xFE9154C0
|
|||
.long 0x0C4519EF
|
||||
.long 32
|
||||
.long __crt0_entry
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
.thumb_func
|
||||
.global _exit
|
||||
_exit:
|
||||
svc #1
|
||||
.exitloop: b .exitloop
|
||||
.align 5
|
||||
|
||||
.bss
|
||||
|
||||
.global __user_heap_end
|
||||
__user_heap_end:
|
||||
.ds.l 1
|
||||
.align 2
|
||||
.global __sb_parameters
|
||||
__sb_parameters:
|
||||
.ds.l 5
|
||||
|
||||
.text
|
||||
/*
|
||||
* CRT0 entry point.
|
||||
*/
|
||||
.align 2
|
||||
.align 2
|
||||
.thumb_func
|
||||
.global __crt0_entry
|
||||
.global __crt0_entry
|
||||
__crt0_entry:
|
||||
/* Popping from the stack the information passed by the
|
||||
loader.*/
|
||||
pop {r8, r9, r10, r11}
|
||||
loader, saving the stack position as end of heap.*/
|
||||
pop {r7, r8, r9, r10}
|
||||
mov r11, sp
|
||||
|
||||
/* PSP stack pointers initialization.*/
|
||||
|
@ -168,9 +172,9 @@ bloop:
|
|||
blo bloop
|
||||
#endif /* CRT0_INIT_BSS == TRUE */
|
||||
|
||||
/* Storing the end of the heap.*/
|
||||
ldr r0, =__user_heap_end
|
||||
str r11, [r0], #0
|
||||
/* Storing the sandbox parameters block.*/
|
||||
ldr r0, =__sb_parameters
|
||||
stmia r0, {r7, r8, r9, r10, r11}
|
||||
|
||||
#if CRT0_CALL_CONSTRUCTORS == TRUE
|
||||
/* Constructors invocation.*/
|
||||
|
@ -186,13 +190,14 @@ endinitloop:
|
|||
#endif /* CRT0_CALL_CONSTRUCTORS == TRUE */
|
||||
|
||||
/* Main program invocation, r0 contains the returned value.*/
|
||||
mov r0, r8
|
||||
mov r1, r9
|
||||
mov r2, r10
|
||||
mov r0, r7
|
||||
mov r1, r8
|
||||
mov r2, r9
|
||||
bl main
|
||||
|
||||
#if CRT0_CALL_DESTRUCTORS == TRUE
|
||||
/* Destructors invocation.*/
|
||||
mov r6, r0
|
||||
ldr r4, =__fini_array_base__
|
||||
ldr r5, =__fini_array_end__
|
||||
finiloop:
|
||||
|
@ -201,10 +206,10 @@ finiloop:
|
|||
ldr r1, [r4], #4
|
||||
blx r1
|
||||
b finiloop
|
||||
mov r0, r6
|
||||
endfiniloop:
|
||||
#endif /* CRT0_CALL_DESTRUCTORS == TRUE */
|
||||
|
||||
.exitloop: b .exitloop
|
||||
b _exit
|
||||
|
||||
#endif /* !defined(__DOXYGEN__) */
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
int main(int argc, char *argv[], char *envp[]) {
|
||||
char *s;
|
||||
unsigned i = 1U;
|
||||
int i = 1;
|
||||
|
||||
printf("argc: %d\r\n", argc);
|
||||
printf("argv: ");
|
||||
|
@ -38,8 +38,10 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||
}
|
||||
printf("\r\n");
|
||||
|
||||
while (true) {
|
||||
while (i <= 10) {
|
||||
printf("#1 Hello World (%u)!!\r\n", i++);
|
||||
sbSleepMilliseconds(500);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -127,16 +127,16 @@ int _isatty_r(struct _reent *r, int fd) {
|
|||
|
||||
__attribute__((used))
|
||||
caddr_t _sbrk_r(struct _reent *r, int incr) {
|
||||
extern uint8_t /*__heap_end__, */__heap_base__;
|
||||
static uint8_t *p = &__heap_base__;
|
||||
extern uint8_t __heap_base__;
|
||||
uint8_t *p = &__heap_base__;
|
||||
uint8_t *prevp;
|
||||
|
||||
prevp = p;
|
||||
/* if ((p + incr > &__heap_end__) ||
|
||||
if ((p + incr > __sb_parameters.heap_end) ||
|
||||
(p + incr < &__heap_base__)) {
|
||||
__errno_r(r) = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
}*/
|
||||
}
|
||||
(void)r;
|
||||
|
||||
p += incr;
|
||||
|
@ -166,13 +166,6 @@ int _kill(int pid, int sig) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((used))
|
||||
void _exit(int code) {
|
||||
|
||||
sbExit((msg_t)code);
|
||||
abort();
|
||||
}
|
||||
|
||||
__attribute__((used))
|
||||
int _getpid(void) {
|
||||
|
||||
|
|
|
@ -53,6 +53,32 @@
|
|||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Type of a parameters structure passed to the sandbox.
|
||||
*/
|
||||
typedef struct sb_parameters {
|
||||
/**
|
||||
* @brief Number of arguments.
|
||||
*/
|
||||
int argc;
|
||||
/**
|
||||
* @brief Vector of arguments.
|
||||
*/
|
||||
char **argv;
|
||||
/**
|
||||
* @brief Pointer to environment variables array.
|
||||
*/
|
||||
char **envp;
|
||||
/**
|
||||
* @brief Address of the physical sandbox end.
|
||||
*/
|
||||
uint8_t *sb_end;
|
||||
/**
|
||||
* @brief Address of heap end.
|
||||
*/
|
||||
uint8_t *heap_end;
|
||||
} sb_parameters_t;
|
||||
|
||||
/**
|
||||
* @brief Type of system time counter.
|
||||
*/
|
||||
|
@ -169,6 +195,8 @@ typedef uint32_t eventflags_t;
|
|||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
extern sb_parameters_t __sb_parameters;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue