Skip to content

Commit

Permalink
Add TARFS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pepepr08 committed Jan 18, 2024
1 parent 19cdc0e commit ba4804c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bsp/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ set(OS_BSP_SRCLIST
src/bsp_start.c
)

# If dynamic loading but also using TARFS, we use our Init to untar and
# set up file system based on tarfile contents
if (RTEMS_DYNAMIC_LOAD AND RTEMS_INCLUDE_TARFS)
list(APPEND OS_BSP_SRCLIST
src/bsp_init.c
src/bsp_setupfs.c # TODO move to only if enabled
)
endif ()

# If not dynamic loading, include Init and config
if (NOT RTEMS_DYNAMIC_LOAD)
list(APPEND OS_BSP_SRCLIST
Expand Down
54 changes: 54 additions & 0 deletions src/bsp/pc-rtems/src/bsp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,40 @@
#include "bsp-impl.h"
#include <rtems.h>

#ifdef RTEMS_INCLUDE_TARFS

#include <rtems/untar.h>
/*
** Tar file symbols
*/
extern int _binary_tarfile_start;
extern int _binary_tarfile_size;
#define TARFILE_START _binary_tarfile_start
#define TARFILE_SIZE _binary_tarfile_size

#endif

/*
** A simple entry point to start from the loader
*/
rtems_task Init(rtems_task_argument ignored)
{

#ifdef RTEMS_INCLUDE_TARFS
/*
** Initialize the file system
*/
printf("Populating Root file system from TAR file.\n");
int status = Untar_FromMemory(
(unsigned char *)(&TARFILE_START),
(unsigned long)&TARFILE_SIZE);
if (status != RTEMS_SUCCESSFUL)
{
printf("Error while untaring from memory\n");
}

#endif

OS_BSPMain();
}

Expand Down Expand Up @@ -95,4 +124,29 @@ rtems_task Init(rtems_task_argument ignored)
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9

/*
** This include file must be AFTER the
** configuration data.
*/
#include <rtems/confdefs.h>

/* TODO Enablibg the GRETH driver is a platform specific setting. This is supposed to be a "generic" rtems psp. */
#ifdef RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define? */

#include <drvmgr/drvmgr.h>

/* Configure Driver manager */
#if defined(RTEMS_DRVMGR_STARTUP) && defined(LEON3) /* if --drvmgr was given to configure */
/* Add Timer and UART Driver for this example */
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
#endif
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
#endif
#endif
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH

#include <drvmgr/drvmgr_confdefs.h>

#endif

0 comments on commit ba4804c

Please sign in to comment.