mirror of https://github.com/rusefi/ChibiOS.git
Posix API preparation, not complete. Added license checks for SB.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12989 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
328ab9ae0f
commit
f7d500c20f
|
@ -53,7 +53,8 @@ static THD_FUNCTION(Unprivileged1, arg) {
|
|||
.r0_base = (uint32_t)&__flash7_start__,
|
||||
.r0_end = (uint32_t)&__flash7_end__,
|
||||
.r1_base = (uint32_t)&__ram7_start__,
|
||||
.r1_end = (uint32_t)&__ram7_end__
|
||||
.r1_end = (uint32_t)&__ram7_end__,
|
||||
.stdio_stream = (SandboxStream *)&SD2
|
||||
};
|
||||
sb_class_t sbx1;
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#define CH_CUSTOMER_LIC_NIL TRUE
|
||||
#define CH_CUSTOMER_LIC_OSLIB TRUE
|
||||
#define CH_CUSTOMER_LIC_EX TRUE
|
||||
#define CH_CUSTOMER_LIC_SB TRUE
|
||||
#define CH_CUSTOMER_LIC_PORT_CM0 TRUE
|
||||
#define CH_CUSTOMER_LIC_PORT_CM3 TRUE
|
||||
#define CH_CUSTOMER_LIC_PORT_CM4 TRUE
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @file sb/common/sberr.h
|
||||
* @brief ARMv7-M sandbox common macros and structures.
|
||||
*
|
||||
* @addtogroup ARMV7M_SANDBOX_ERRORS
|
||||
* @addtogroup ARM_SANDBOX_ERRORS
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -33,13 +33,14 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Sandbox API error codes
|
||||
* @name Sandbox API error codes
|
||||
* @{
|
||||
*/
|
||||
#define SB_ERR_NOERROR 0U
|
||||
#define SB_ERR_NOT_IMPLEMENTED 0xFFFFFFFFU
|
||||
#define SB_ERR_MEMORY_FAULT 0xFFFFFFFEU
|
||||
#define SB_ERR_API_USAGE 0xFFFFFFFDU
|
||||
#define SB_ERR_NOT_IMPLEMENTED ((uint32_t)(-88)) /* ENOSYS */
|
||||
#define SB_ERR_MEMORY_FAULT ((uint32_t)(-14)) /* EFAULT */
|
||||
#define SB_ERR_API_USAGE ((uint32_t)(-16)) /* EBUSY */
|
||||
#define SB_ERR_INV_ARGUMENT ((uint32_t)(-22)) /* EINVAL */
|
||||
|
||||
#define SB_ERR_ERRORMASK 0xFFFFFF00U
|
||||
#define SB_ERR_ISERROR(x) (((x) & SB_ERR_ERRORMASK) == SB_ERR_ERRORMASK)
|
||||
|
|
|
@ -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/sbapi.c \
|
||||
$(CHIBIOS)/os/sb/host/sbposix.c
|
||||
|
||||
SBHOSTASM = $(CHIBIOS)/os/sb/host/compilers/GCC/sbexc.S
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
/**
|
||||
* @file sb/host/sbhost.c
|
||||
* @brief ARMv7-M sandbox host API code.
|
||||
* @brief ARM sandbox host API code.
|
||||
*
|
||||
* @addtogroup ARMV7M_SANDBOX_HOSTAPI
|
||||
* @addtogroup ARM_SANDBOX_HOSTAPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "sbhost.h"
|
||||
#include "sb.h"
|
||||
|
||||
#if defined(SB_INCLUDE_USERAPI)
|
||||
#include "sbuserapi.h"
|
||||
|
@ -40,6 +40,7 @@
|
|||
* @name Standard API handlers
|
||||
* @{
|
||||
*/
|
||||
#define SB_SVC0_HANDLER sb_api_stdio
|
||||
#define SB_SVC1_HANDLER sb_api_exit
|
||||
#define SB_SVC2_HANDLER sb_api_get_systime
|
||||
#define SB_SVC3_HANDLER sb_api_get_frequency
|
||||
|
@ -921,6 +922,37 @@ static void sb_undef_handler(struct port_extctx *ectxp) {
|
|||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
void sb_api_stdio(struct port_extctx *ectxp) {
|
||||
|
||||
switch (ectxp->r0) {
|
||||
case SB_POSIX_OPEN:
|
||||
ectxp->r0 = sb_posix_open((const char *)ectxp->r1,
|
||||
(int)ectxp->r2);
|
||||
break;
|
||||
case SB_POSIX_CLOSE:
|
||||
ectxp->r0 = sb_posix_close((int)ectxp->r1);
|
||||
break;
|
||||
case SB_POSIX_READ:
|
||||
ectxp->r0 = sb_posix_read((int)ectxp->r1,
|
||||
(void *)ectxp->r2,
|
||||
(size_t)ectxp->r3);
|
||||
break;
|
||||
case SB_POSIX_WRITE:
|
||||
ectxp->r0 = sb_posix_write((int)ectxp->r1,
|
||||
(const void *)ectxp->r2,
|
||||
(size_t)ectxp->r3);
|
||||
break;
|
||||
case SB_POSIX_LSEEK:
|
||||
ectxp->r0 = sb_posix_lseek((int)ectxp->r1,
|
||||
(off_t)ectxp->r2,
|
||||
(int)ectxp->r3);
|
||||
break;
|
||||
default:
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sb_api_exit(struct port_extctx *ectxp) {
|
||||
|
||||
chThdExit((msg_t )ectxp->r0);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
/**
|
||||
* @file sb/host/sbapi.h
|
||||
* @brief ARMv7-M sandbox host API macros and structures.
|
||||
* @brief ARM sandbox host API macros and structures.
|
||||
*
|
||||
* @addtogroup ARMV7M_SANDBOX_HOSTAPI
|
||||
* @addtogroup ARM_SANDBOX_HOSTAPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -40,14 +40,6 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if CH_CFG_ST_RESOLUTION != 32
|
||||
#error "SandBox requires CH_CFG_ST_RESOLUTION == 32"
|
||||
#endif
|
||||
|
||||
#if CH_CFG_INTERVALS_SIZE != 32
|
||||
#error "SandBox requires CH_CFG_INTERVALS_SIZE == 32"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
@ -57,6 +49,44 @@
|
|||
*/
|
||||
typedef void (*port_syscall_t)(struct port_extctx *ectx);
|
||||
|
||||
/**
|
||||
* @brief Sandbox Stream interface methods.
|
||||
* @note Is intentionally compatible with HAL streams but we have to
|
||||
* duplicate is because we don't want dependencies with HAL in
|
||||
* this subsystem.
|
||||
*/
|
||||
struct SandboxStreamVMT {
|
||||
/**
|
||||
* @brief Stream write buffer method.
|
||||
*/
|
||||
size_t (*write)(void *instance, const uint8_t *bp, size_t n);
|
||||
/**
|
||||
* @brief Stream read buffer method.
|
||||
*/
|
||||
size_t (*read)(void *instance, uint8_t *bp, size_t n);
|
||||
/**
|
||||
* @brief Channel put method, blocking.
|
||||
*/
|
||||
msg_t (*put)(void *instance, uint8_t b);
|
||||
/**
|
||||
* @brief Channel get method, blocking.
|
||||
*/
|
||||
msg_t (*get)(void *instance);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Sandbox Stream class.
|
||||
* @note Is intentionally compatible with HAL streams but we have to
|
||||
* duplicate is because we don't want dependencies with HAL in
|
||||
* this subsystem.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Virtual Methods Table.
|
||||
*/
|
||||
const struct SandboxStreamVMT *vmt;
|
||||
} SandboxStream;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
@ -68,6 +98,7 @@ typedef void (*port_syscall_t)(struct port_extctx *ectx);
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void sb_api_stdio(struct port_extctx *ectxp);
|
||||
void sb_api_exit(struct port_extctx *ctxp);
|
||||
void sb_api_get_systime(struct port_extctx *ctxp);
|
||||
void sb_api_get_frequency(struct port_extctx *ctxp);
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
/**
|
||||
* @file sb/host/sbhost.c
|
||||
* @brief ARMv7-M sandbox code.
|
||||
* @brief ARM sandbox host code.
|
||||
*
|
||||
* @addtogroup ARMV7M_SANDBOX
|
||||
* @addtogroup ARM_SANDBOX
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "sbhost.h"
|
||||
#include "sb.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
/**
|
||||
* @file sb/host/sbhost.h
|
||||
* @brief ARMv7-M sandbox macros and structures.
|
||||
* @brief ARM sandbox host macros and structures.
|
||||
*
|
||||
* @addtogroup ARMV7M_SANDBOX
|
||||
* @addtogroup ARM_SANDBOX
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -51,10 +51,6 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if PORT_USE_SYSCALL == FALSE
|
||||
#error "sandbox requires PORT_USE_SYSCALL"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
@ -81,6 +77,13 @@ typedef struct {
|
|||
* @note Zero if not used.
|
||||
*/
|
||||
uint32_t r1_end;
|
||||
/**
|
||||
* @brief Sandbox stream.
|
||||
* @note Set this to @p NULL if standard I/O is not needed.
|
||||
* @note By design you can use HAL streams here, you need to use
|
||||
* a cast however.
|
||||
*/
|
||||
SandboxStream *stdio_stream;
|
||||
} sb_config_t;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue