forked from Imagelibrary/rtems
2009-04-28 Chris Johns <chrisj@rtems.org>
* bootcard.c, include/bootcard.h: Remove argc/argv/envp and
replace with a single BSP boot command line a BSP can optionally
support.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2009-04-28 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
|
* bootcard.c, include/bootcard.h: Remove argc/argv/envp and
|
||||||
|
replace with a single BSP boot command line a BSP can optionally
|
||||||
|
support.
|
||||||
|
|
||||||
2009-03-10 Eric Norum <norume@aps.anl.gov>
|
2009-03-10 Eric Norum <norume@aps.anl.gov>
|
||||||
|
|
||||||
* bootcard.c: Swap order of RTEMS Workspace and Malloc Heap. This
|
* bootcard.c: Swap order of RTEMS Workspace and Malloc Heap. This
|
||||||
|
|||||||
@@ -48,9 +48,10 @@
|
|||||||
#include <bsp/bootcard.h>
|
#include <bsp/bootcard.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since there is a forward reference
|
* At most a single pointer to the cmdline for those target
|
||||||
|
* short on memory and not supporting a command line.
|
||||||
*/
|
*/
|
||||||
char *rtems_progname;
|
const char *bsp_boot_cmdline;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Are we using a single heap for the RTEMS Workspace and C Program Heap?
|
* Are we using a single heap for the RTEMS Workspace and C Program Heap?
|
||||||
@@ -114,21 +115,15 @@ static rtems_status_code bootcard_bsp_libc_helper(
|
|||||||
* as much as possible.
|
* as much as possible.
|
||||||
*/
|
*/
|
||||||
int boot_card(
|
int boot_card(
|
||||||
int argc,
|
const char *cmdline
|
||||||
char **argv,
|
|
||||||
char **envp
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static char *argv_pointer = NULL;
|
rtems_interrupt_level bsp_isr_level;
|
||||||
static char *envp_pointer = NULL;
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
char **argv_p = &argv_pointer;
|
void *work_area_start = NULL;
|
||||||
char **envp_p = &envp_pointer;
|
intptr_t work_area_size = 0;
|
||||||
rtems_interrupt_level bsp_isr_level;
|
void *heap_start = NULL;
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
intptr_t heap_size = 0;
|
||||||
void *work_area_start = NULL;
|
|
||||||
intptr_t work_area_size = 0;
|
|
||||||
void *heap_start = NULL;
|
|
||||||
intptr_t heap_size = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special case for PowerPC: The interrupt disable mask is stored in SPRG0.
|
* Special case for PowerPC: The interrupt disable mask is stored in SPRG0.
|
||||||
@@ -143,22 +138,7 @@ int boot_card(
|
|||||||
*/
|
*/
|
||||||
rtems_interrupt_disable( bsp_isr_level );
|
rtems_interrupt_disable( bsp_isr_level );
|
||||||
|
|
||||||
/*
|
bsp_boot_cmdline = cmdline;
|
||||||
* Set things up so we have real pointers for argv and envp.
|
|
||||||
* If the BSP has passed us something useful, then pass it on.
|
|
||||||
* Somehow we need to eventually make this available to
|
|
||||||
* a real main() in user land. :)
|
|
||||||
*/
|
|
||||||
if ( argv ) argv_p = argv;
|
|
||||||
if ( envp ) envp_p = envp;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the program name in case some application cares.
|
|
||||||
*/
|
|
||||||
if ((argc > 0) && argv && argv[0])
|
|
||||||
rtems_progname = argv[0];
|
|
||||||
else
|
|
||||||
rtems_progname = "RTEMS";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Invoke Board Support Package initialization routine written in C.
|
* Invoke Board Support Package initialization routine written in C.
|
||||||
@@ -169,7 +149,8 @@ int boot_card(
|
|||||||
* Find out where the block of memory the BSP will use for
|
* Find out where the block of memory the BSP will use for
|
||||||
* the RTEMS Workspace and the C Program Heap is.
|
* the RTEMS Workspace and the C Program Heap is.
|
||||||
*/
|
*/
|
||||||
bsp_get_work_area(&work_area_start, &work_area_size, &heap_start, &heap_size);
|
bsp_get_work_area(&work_area_start, (ssize_t*) &work_area_size,
|
||||||
|
&heap_start, (ssize_t*) &heap_size);
|
||||||
|
|
||||||
if ( work_area_size <= Configuration.work_space_size ) {
|
if ( work_area_size <= Configuration.work_space_size ) {
|
||||||
printk( "bootcard: Work space too big for work area!\n");
|
printk( "bootcard: Work space too big for work area!\n");
|
||||||
|
|||||||
93
c/src/lib/libbsp/shared/bspinit.c
Normal file
93
c/src/lib/libbsp/shared/bspinit.c
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 1989-2009.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <bsp.h>
|
||||||
|
#include <bsp/bootcard.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine calls main from a confdefs.h default Init task
|
||||||
|
* set up. The bootcard will provide the task argument as
|
||||||
|
* command line string (ASCIIZ).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main (int argc, char* argv[]);
|
||||||
|
|
||||||
|
void Init (rtems_task_argument arg)
|
||||||
|
{
|
||||||
|
const char* boot_cmdline = *((const char**) arg);
|
||||||
|
char* cmdline = 0;
|
||||||
|
char* command;
|
||||||
|
int argc = 0;
|
||||||
|
char** argv = NULL;
|
||||||
|
int result = -124;
|
||||||
|
|
||||||
|
if (boot_cmdline)
|
||||||
|
{
|
||||||
|
cmdline = malloc (strlen (boot_cmdline) + 1);
|
||||||
|
|
||||||
|
if (cmdline)
|
||||||
|
{
|
||||||
|
strcpy (cmdline, boot_cmdline);
|
||||||
|
|
||||||
|
command = cmdline;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Break the line up into arguments with "" being ignored.
|
||||||
|
*/
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
command = strtok (command, " \t\r\n");
|
||||||
|
if (command == NULL)
|
||||||
|
break;
|
||||||
|
argc++;
|
||||||
|
command = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
argv = calloc (argc, sizeof (char*));
|
||||||
|
|
||||||
|
if (argv)
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
|
||||||
|
command = cmdline;
|
||||||
|
argv[0] = command;
|
||||||
|
|
||||||
|
for (a = 1; a < argc; a++)
|
||||||
|
{
|
||||||
|
command += strlen (command) + 1;
|
||||||
|
argv[a] = command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
argc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RTEMS_NETWORKING
|
||||||
|
rtems_bsdnet_initialize_network ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
result = main (argc, argv);
|
||||||
|
|
||||||
|
free (argv);
|
||||||
|
free (cmdline);
|
||||||
|
|
||||||
|
exit (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By making this a weak alias and a user can provide there own.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Init (rtems_task_argument arg) __attribute__ ((weak));
|
||||||
@@ -60,7 +60,7 @@ void bsp_get_work_area(
|
|||||||
ssize_t *heap_size
|
ssize_t *heap_size
|
||||||
);
|
);
|
||||||
|
|
||||||
int boot_card( int argc, char **argv, char **envp);
|
int boot_card( const char *cmdline );
|
||||||
|
|
||||||
void bsp_libc_init( void *heap_start, size_t heap_size, size_t sbrk_amount);
|
void bsp_libc_init( void *heap_start, size_t heap_size, size_t sbrk_amount);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user