mirror of https://github.com/rusefi/ChibiOS.git
Host-side VPAL driver. Added palReadGroupLatch() to PAL driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15663 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
7e4aceb4ca
commit
a5fd0476a9
|
@ -26,8 +26,12 @@
|
||||||
|
|
||||||
#include "startup_defs.h"
|
#include "startup_defs.h"
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* VHAL-related. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
static vhal_pal_conf_t vpal_config1 = {
|
static vhal_pal_conf_t vpal_config1 = {
|
||||||
.nvpio = 1U,
|
.n = 1U,
|
||||||
.vpio = {
|
.vpio = {
|
||||||
[0] = {
|
[0] = {
|
||||||
.permissions = VPIO_PERM_WRITE,
|
.permissions = VPIO_PERM_WRITE,
|
||||||
|
@ -38,6 +42,18 @@ static vhal_pal_conf_t vpal_config1 = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static vhal_pal_conf_t vpal_config2 = {
|
||||||
|
.n = 0U
|
||||||
|
};
|
||||||
|
|
||||||
|
static vhal_conf_t vhal_config1 = {
|
||||||
|
.vpalconf = &vpal_config1
|
||||||
|
};
|
||||||
|
|
||||||
|
static vhal_conf_t vhal_config2 = {
|
||||||
|
.vpalconf = &vpal_config2
|
||||||
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* VFS-related. */
|
/* VFS-related. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -87,6 +103,7 @@ static const sb_config_t sb_config1 = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// .vfs_driver = (vfs_driver_c *)&root_overlay_driver
|
// .vfs_driver = (vfs_driver_c *)&root_overlay_driver
|
||||||
|
.vhalconf = &vhal_config1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Sandbox 2 configuration.*/
|
/* Sandbox 2 configuration.*/
|
||||||
|
@ -106,6 +123,7 @@ static const sb_config_t sb_config2 = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// .vfs_driver = (vfs_driver_c *)&root_overlay_driver
|
// .vfs_driver = (vfs_driver_c *)&root_overlay_driver
|
||||||
|
.vhalconf = &vhal_config2
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *sbx1_argv[] = {
|
static const char *sbx1_argv[] = {
|
||||||
|
|
|
@ -503,6 +503,25 @@ typedef struct {
|
||||||
#define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset)
|
#define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads the group latch.
|
||||||
|
* @note The function can be called from any context.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @param[in] mask group mask, a logic AND is performed on the input
|
||||||
|
* data
|
||||||
|
* @param[in] offset group bit offset within the port
|
||||||
|
* @return The group logic states.
|
||||||
|
*
|
||||||
|
* @special
|
||||||
|
*/
|
||||||
|
#if !defined(pal_lld_readgrouplatch) || defined(__DOXYGEN__)
|
||||||
|
#define palReadGroupLatch(port, mask, offset) \
|
||||||
|
((palReadLatch(port) >> (offset)) & (mask))
|
||||||
|
#else
|
||||||
|
#define palReadGroupLatch(port, mask, offset) pal_lld_readgrouplatch(port, mask, offset)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes a group of bits.
|
* @brief Writes a group of bits.
|
||||||
* @note The operation is not guaranteed to be atomic on all the
|
* @note The operation is not guaranteed to be atomic on all the
|
||||||
|
|
|
@ -84,6 +84,16 @@
|
||||||
#define SB_POSIX_STAT 16
|
#define SB_POSIX_STAT 16
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name VPAL syscall sub-codes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SB_VPAL_WRITE 0
|
||||||
|
#define SB_VPAL_READLATCH 1
|
||||||
|
#define SB_VPAL_READ 2
|
||||||
|
#define SB_VPAL_SETMODE 3
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module pre-compile time settings. */
|
/* Module pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -33,6 +33,12 @@
|
||||||
#include "errcodes.h"
|
#include "errcodes.h"
|
||||||
|
|
||||||
#include "sbhdr.h"
|
#include "sbhdr.h"
|
||||||
|
#include "sbsysc.h"
|
||||||
|
#include "sbconf.h"
|
||||||
|
|
||||||
|
#if (SB_CFG_ENABLE_VHAL == TRUE) || defined (__DOXYGEN__)
|
||||||
|
#include "sbvhal.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module constants. */
|
/* Module constants. */
|
||||||
|
@ -77,8 +83,6 @@
|
||||||
/* Module pre-compile time settings. */
|
/* Module pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#include "sbconf.h"
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Derived constants and error checks. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -249,6 +253,12 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
vfs_driver_c *vfs_driver;
|
vfs_driver_c *vfs_driver;
|
||||||
#endif
|
#endif
|
||||||
|
#if (SB_CFG_ENABLE_VHAL == TRUE) || defined(__DOXYGEN__)
|
||||||
|
/**
|
||||||
|
* @brief VHAL configuration associated to this sandbox.
|
||||||
|
*/
|
||||||
|
const vhal_conf_t *vhalconf;
|
||||||
|
#endif
|
||||||
} sb_config_t;
|
} sb_config_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,16 +339,10 @@ extern "C" {
|
||||||
/* Module inline functions. */
|
/* Module inline functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#include "sbsysc.h"
|
|
||||||
|
|
||||||
#if (SB_CFG_ENABLE_VRQ == TRUE) || defined (__DOXYGEN__)
|
#if (SB_CFG_ENABLE_VRQ == TRUE) || defined (__DOXYGEN__)
|
||||||
#include "sbvrq.h"
|
#include "sbvrq.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (SB_CFG_ENABLE_VHAL == TRUE) || defined (__DOXYGEN__)
|
|
||||||
#include "sbvhal.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sbelf.h"
|
#include "sbelf.h"
|
||||||
#include "sbposix.h"
|
#include "sbposix.h"
|
||||||
#include "sbapi.h"
|
#include "sbapi.h"
|
||||||
|
|
|
@ -54,15 +54,37 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
void sb_api_vhal_pal(struct port_extctx *ectxp) {
|
void sb_api_vhal_pal(struct port_extctx *ectxp) {
|
||||||
unsigned sub = (unsigned)ectxp->r0;
|
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||||
unsigned port = (unsigned)ectxp->r1;
|
uint32_t sub = (unsigned)ectxp->r0;
|
||||||
|
uint32_t vport = (unsigned)ectxp->r1;
|
||||||
|
const vhal_vpio_conf_t *vpiop;
|
||||||
|
ectxp->r0 = 0U;
|
||||||
|
|
||||||
switch (sub) {
|
if (vport >= sbp->config->vhalconf->vpalconf->n) {
|
||||||
case 0:
|
return;
|
||||||
palWriteGroup(GPIOA, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ectxp->r0 = CH_RET_SUCCESS;
|
vpiop = &sbp->config->vhalconf->vpalconf->vpio[vport];
|
||||||
|
|
||||||
|
switch (sub) {
|
||||||
|
case SB_VPAL_WRITE:
|
||||||
|
if ((vpiop->permissions & VPIO_PERM_WRITE) != 0U) {
|
||||||
|
palWriteGroup(vpiop->port, vpiop->mask, vpiop->offset, ectxp->r2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SB_VPAL_READLATCH:
|
||||||
|
if ((vpiop->permissions & VPIO_PERM_READLATCH) != 0U) {
|
||||||
|
ectxp->r0 = palReadGroupLatch(vpiop->port, vpiop->mask, vpiop->offset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SB_VPAL_READ:
|
||||||
|
if ((vpiop->permissions & VPIO_PERM_READ) != 0U) {
|
||||||
|
ectxp->r0 = palReadGroup(vpiop->port, vpiop->mask, vpiop->offset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SB_CFG_ENABLE_VHAL_PAL == TRUE */
|
#endif /* SB_CFG_ENABLE_VHAL_PAL == TRUE */
|
||||||
|
|
|
@ -43,9 +43,10 @@
|
||||||
* @name VPIO permissions
|
* @name VPIO permissions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define VPIO_PERM_READ 1U
|
#define VPIO_PERM_WRITE 1U
|
||||||
#define VPIO_PERM_WRITE 2U
|
#define VPIO_PERM_READ 2U
|
||||||
#define VPIO_PERM_CHANGEMODE 4U
|
#define VPIO_PERM_READLATCH 4U
|
||||||
|
#define VPIO_PERM_SETMODE 8U
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -61,16 +62,21 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type of a VHAL PAL instance configuration structure.
|
* @brief Type of a VPIO configuration structure.
|
||||||
*/
|
*/
|
||||||
typedef struct vhal_pal_conf {
|
typedef struct vhal_vpio_conf {
|
||||||
uint32_t nvpio;
|
|
||||||
struct {
|
|
||||||
uint32_t permissions;
|
uint32_t permissions;
|
||||||
ioportid_t port;
|
ioportid_t port;
|
||||||
ioportmask_t mask;
|
ioportmask_t mask;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
} vpio[];
|
} vhal_vpio_conf_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a VHAL PAL instance configuration structure.
|
||||||
|
*/
|
||||||
|
typedef struct vhal_pal_conf {
|
||||||
|
uint32_t n;
|
||||||
|
vhal_vpio_conf_t vpio[];
|
||||||
} vhal_pal_conf_t;
|
} vhal_pal_conf_t;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** Next ***
|
*** Next ***
|
||||||
|
- NEW: Added palReadGroupLatch() to PAL driver.
|
||||||
- NEW: Added a Posix-favored shell named "msh" (Mini Shell). The shell is able
|
- NEW: Added a Posix-favored shell named "msh" (Mini Shell). The shell is able
|
||||||
to run sub-apps inside the same sandbox. The shell can either be placed
|
to run sub-apps inside the same sandbox. The shell can either be placed
|
||||||
statically in flash or loaded dynamically in RAM.
|
statically in flash or loaded dynamically in RAM.
|
||||||
|
|
Loading…
Reference in New Issue