git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15316 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
0d1bc937de
commit
7f29f49f66
|
@ -1,6 +1,7 @@
|
|||
# List of the ChibiOS ARMv7-M sandbox host files.
|
||||
SBHOSTSRC = $(CHIBIOS)/os/sb/host/sbhost.c \
|
||||
$(CHIBIOS)/os/sb/host/sbapi.c \
|
||||
$(CHIBIOS)/os/sb/host/sbelf.c \
|
||||
$(CHIBIOS)/os/sb/host/sbposix.c
|
||||
|
||||
SBHOSTASM = $(CHIBIOS)/os/sb/host/compilers/GCC/sbexc.S
|
||||
|
|
|
@ -299,6 +299,7 @@ extern "C" {
|
|||
/*===========================================================================*/
|
||||
|
||||
#include "sbsysc.h"
|
||||
#include "sbelf.h"
|
||||
#include "sbposix.h"
|
||||
#include "sbapi.h"
|
||||
#include "sbhost.h"
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS.
|
||||
|
||||
ChibiOS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation version 3 of the License.
|
||||
|
||||
ChibiOS is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sb/host/sbelf.c
|
||||
* @brief ARM SandBox ELF loader code.
|
||||
*
|
||||
* @addtogroup ARM_SANDBOX_ELF
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "sb.h"
|
||||
|
||||
#if (SB_CFG_ENABLE_VFS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Type of an ELF loader context.
|
||||
*/
|
||||
typedef struct elf_load_context {
|
||||
vfs_file_node_c *fnp;
|
||||
memory_area_t *map;
|
||||
uint8_t *next;
|
||||
} elf_load_context_t;
|
||||
|
||||
/**
|
||||
* @brief Type of an ELF32 header.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char e_ident[16];
|
||||
uint16_t e_type;
|
||||
uint16_t e_machine;
|
||||
uint32_t e_version;
|
||||
uint32_t e_entry;
|
||||
uint32_t e_phoff;
|
||||
uint32_t e_shoff;
|
||||
uint32_t e_flags;
|
||||
uint16_t e_ehsize;
|
||||
uint16_t e_phentsize;
|
||||
uint16_t e_phnum;
|
||||
uint16_t e_shentsize;
|
||||
uint16_t e_shnum;
|
||||
uint16_t e_shstrndx;
|
||||
} elf32_header_t;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static void init_elf_context(elf_load_context_t *ctxp,
|
||||
vfs_file_node_c *fnp,
|
||||
memory_area_t *map) {
|
||||
|
||||
ctxp->fnp = fnp;
|
||||
ctxp->map = map;
|
||||
ctxp->next = map->base;
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
msg_t sbElfLoad(vfs_driver_c *drvp, const char *path, memory_area_t *map) {
|
||||
vfs_file_node_c *fnp;
|
||||
msg_t ret;
|
||||
elf_load_context_t ctx;
|
||||
|
||||
ret = vfsDrvOpenFile(drvp, path, VO_RDONLY, &fnp);
|
||||
CH_RETURN_ON_ERROR(ret);
|
||||
|
||||
init_elf_context(&ctx, fnp, map);
|
||||
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* SB_CFG_ENABLE_VFS == TRUE */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS.
|
||||
|
||||
ChibiOS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation version 3 of the License.
|
||||
|
||||
ChibiOS is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sb/host/sbloader.h
|
||||
* @brief ARM SandBox ELF loader macros and structures.
|
||||
*
|
||||
* @addtogroup sbhost.h
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef SBELF_H
|
||||
#define SBELF_H
|
||||
|
||||
#if (SB_CFG_ENABLE_VFS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
msg_t sbElfLoad(vfs_driver_c *drvp, const char *path, memory_area_t *map);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module inline functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#endif /* SB_CFG_ENABLE_VFS == TRUE */
|
||||
|
||||
#endif /* SBELF_H */
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue