Skip to content

Commit 5e1e6ca

Browse files
pepepr08Jacob Hageman
authored andcommitted
Part #1447, Add TARFS functionality
1 parent 19cdc0e commit 5e1e6ca

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/bsp/pc-rtems/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ set(OS_BSP_SRCLIST
1010
src/bsp_start.c
1111
)
1212

13+
# If dynamic loading but also using TARFS, we use our Init to untar and
14+
# set up file system based on tarfile contents
15+
if (RTEMS_DYNAMIC_LOAD AND RTEMS_INCLUDE_TARFS)
16+
list(APPEND OS_BSP_SRCLIST
17+
src/bsp_init.c
18+
src/bsp_setupfs.c # TODO move to only if enabled
19+
)
20+
endif ()
21+
1322
# If not dynamic loading, include Init and config
1423
if (NOT RTEMS_DYNAMIC_LOAD)
1524
list(APPEND OS_BSP_SRCLIST

src/bsp/pc-rtems/src/bsp_init.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,40 @@
3030
#include "bsp-impl.h"
3131
#include <rtems.h>
3232

33+
#ifdef RTEMS_INCLUDE_TARFS
34+
35+
#include <rtems/untar.h>
36+
/*
37+
** Tar file symbols
38+
*/
39+
extern int _binary_tarfile_start;
40+
extern int _binary_tarfile_size;
41+
#define TARFILE_START _binary_tarfile_start
42+
#define TARFILE_SIZE _binary_tarfile_size
43+
44+
#endif
45+
3346
/*
3447
** A simple entry point to start from the loader
3548
*/
3649
rtems_task Init(rtems_task_argument ignored)
3750
{
51+
52+
#ifdef RTEMS_INCLUDE_TARFS
53+
/*
54+
** Initialize the file system
55+
*/
56+
printf("Populating Root file system from TAR file.\n");
57+
int status = Untar_FromMemory(
58+
(unsigned char *)(&TARFILE_START),
59+
(unsigned long)&TARFILE_SIZE);
60+
if (status != RTEMS_SUCCESSFUL)
61+
{
62+
printf("Error while untaring from memory\n");
63+
}
64+
65+
#endif
66+
3867
OS_BSPMain();
3968
}
4069

@@ -95,4 +124,29 @@ rtems_task Init(rtems_task_argument ignored)
95124
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
96125
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9
97126

127+
/*
128+
** This include file must be AFTER the
129+
** configuration data.
130+
*/
98131
#include <rtems/confdefs.h>
132+
133+
/* TODO Enablibg the GRETH driver is a platform specific setting. This is supposed to be a "generic" rtems psp. */
134+
#ifdef RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define? */
135+
136+
#include <drvmgr/drvmgr.h>
137+
138+
/* Configure Driver manager */
139+
#if defined(RTEMS_DRVMGR_STARTUP) && defined(LEON3) /* if --drvmgr was given to configure */
140+
/* Add Timer and UART Driver for this example */
141+
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
142+
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
143+
#endif
144+
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
145+
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
146+
#endif
147+
#endif
148+
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH
149+
150+
#include <drvmgr/drvmgr_confdefs.h>
151+
152+
#endif

0 commit comments

Comments
 (0)