Saved 1 parameter in VIO calls.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16334 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
d64f5151c5
commit
5a2a48ae62
|
@ -168,7 +168,7 @@ typedef uint32_t eventflags_t;
|
|||
|
||||
#define __syscall0rr(x) \
|
||||
register uint32_t r0 asm ("r0"); \
|
||||
register uint32_t r0 asm ("r1"); \
|
||||
register uint32_t r1 asm ("r1"); \
|
||||
asm volatile ("svc " #x : "=r" (r0), "=r" (r1) : : "memory")
|
||||
|
||||
#define __syscall1r(x, p1) \
|
||||
|
@ -177,7 +177,7 @@ typedef uint32_t eventflags_t;
|
|||
|
||||
#define __syscall1rr(x, p1) \
|
||||
register uint32_t r0 asm ("r0") = (uint32_t)(p1); \
|
||||
register uint32_t r0 asm ("r1"); \
|
||||
register uint32_t r1 asm ("r1"); \
|
||||
asm volatile ("svc " #x : "=r" (r0), "=r" (r1) : \
|
||||
"r" (r0) : \
|
||||
"memory")
|
||||
|
|
|
@ -100,6 +100,22 @@ typedef struct vio_conf {
|
|||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Sub-code part of VIO calls 1st parameter.
|
||||
*
|
||||
* @param[n] n the VIO 1st parameter
|
||||
* @return The VIO call sub-code.
|
||||
*/
|
||||
#define VIO_CALL_SUBCODE(n) ((uint32_t)(n) & 0xFFU)
|
||||
|
||||
/**
|
||||
* @brief Unit identifier part of VIO calls 1st parameter.
|
||||
*
|
||||
* @param[n] n the VIO 1st parameter
|
||||
* @return The VIO call unit identifier.
|
||||
*/
|
||||
#define VIO_CALL_UNIT(n) ((uint32_t)(n) >> 24)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
|
||||
void sb_fastc_vio_gpio(struct port_extctx *ectxp) {
|
||||
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||
uint32_t sub = (unsigned)ectxp->r0;
|
||||
uint32_t unit = (unsigned)ectxp->r1;
|
||||
uint32_t sub = VIO_CALL_SUBCODE(ectxp->r0);
|
||||
uint32_t unit = VIO_CALL_UNIT(ectxp->r0);
|
||||
const vio_gpio_unit_t *unitp;
|
||||
ectxp->r0 = 0U;
|
||||
|
||||
|
@ -69,25 +69,25 @@ void sb_fastc_vio_gpio(struct port_extctx *ectxp) {
|
|||
switch (sub) {
|
||||
case SB_VGPIO_WRITE:
|
||||
if ((unitp->permissions & VIO_GPIO_PERM_WRITE) != 0U) {
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r2);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r1);
|
||||
}
|
||||
break;
|
||||
case SB_VGPIO_SET:
|
||||
if ((unitp->permissions & VIO_GPIO_PERM_WRITE) != 0U) {
|
||||
uint32_t val = palReadGroup(unitp->port, unitp->mask, unitp->offset);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r2 | val);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r1 | val);
|
||||
}
|
||||
break;
|
||||
case SB_VGPIO_CLEAR:
|
||||
if ((unitp->permissions & VIO_GPIO_PERM_WRITE) != 0U) {
|
||||
uint32_t val = palReadGroup(unitp->port, unitp->mask, unitp->offset);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r2 & ~val);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r1 & ~val);
|
||||
}
|
||||
break;
|
||||
case SB_VGPIO_TOGGLE:
|
||||
if ((unitp->permissions & VIO_GPIO_PERM_WRITE) != 0U) {
|
||||
uint32_t val = palReadGroup(unitp->port, unitp->mask, unitp->offset);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r2 ^ val);
|
||||
palWriteGroup(unitp->port, unitp->mask, unitp->offset, ectxp->r1 ^ val);
|
||||
}
|
||||
break;
|
||||
case SB_VGPIO_READLATCH:
|
||||
|
|
|
@ -62,8 +62,8 @@ static void vspi_cb(void *ip) {
|
|||
|
||||
void sb_sysc_vio_spi(struct port_extctx *ectxp) {
|
||||
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||
uint32_t sub = ectxp->r0;
|
||||
uint32_t unit = ectxp->r1;
|
||||
uint32_t sub = VIO_CALL_SUBCODE(ectxp->r0);
|
||||
uint32_t unit = VIO_CALL_UNIT(ectxp->r0);
|
||||
ectxp->r0 = (uint32_t)CH_RET_INNER_ERROR;
|
||||
const vio_spi_unit_t *unitp;
|
||||
|
||||
|
@ -108,8 +108,8 @@ void sb_sysc_vio_spi(struct port_extctx *ectxp) {
|
|||
|
||||
void sb_fastc_vio_spi(struct port_extctx *ectxp) {
|
||||
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||
uint32_t sub = ectxp->r0;
|
||||
uint32_t unit = ectxp->r1;
|
||||
uint32_t sub = VIO_CALL_SUBCODE(ectxp->r0);
|
||||
uint32_t unit = VIO_CALL_UNIT(ectxp->r0);
|
||||
const vio_spi_unit_t *unitp;
|
||||
|
||||
/* Returned value in case of error or illegal sub-code.*/
|
||||
|
@ -130,7 +130,7 @@ void sb_fastc_vio_spi(struct port_extctx *ectxp) {
|
|||
switch (sub) {
|
||||
case SB_VSPI_SETCFG:
|
||||
{
|
||||
uint32_t conf = ectxp->r2;
|
||||
uint32_t conf = ectxp->r1;
|
||||
const vio_spi_config_t *confp;
|
||||
|
||||
/* Check on configuration index.*/
|
||||
|
|
|
@ -62,8 +62,8 @@ static void vuart_cb(void *ip) {
|
|||
|
||||
void sb_sysc_vio_uart(struct port_extctx *ectxp) {
|
||||
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||
uint32_t sub = ectxp->r0;
|
||||
uint32_t unit = ectxp->r1;
|
||||
uint32_t sub = VIO_CALL_SUBCODE(ectxp->r0);
|
||||
uint32_t unit = VIO_CALL_UNIT(ectxp->r0);
|
||||
ectxp->r0 = (uint32_t)CH_RET_INNER_ERROR;
|
||||
const vio_uart_unit_t *unitp;
|
||||
|
||||
|
@ -108,8 +108,8 @@ void sb_sysc_vio_uart(struct port_extctx *ectxp) {
|
|||
|
||||
void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
||||
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||
uint32_t sub = ectxp->r0;
|
||||
uint32_t unit = ectxp->r1;
|
||||
uint32_t sub = VIO_CALL_SUBCODE(ectxp->r0);
|
||||
uint32_t unit = VIO_CALL_UNIT(ectxp->r0);
|
||||
const vio_uart_unit_t *unitp;
|
||||
|
||||
/* Returned value in case of error or illegal sub-code.*/
|
||||
|
@ -130,7 +130,7 @@ void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
|||
switch (sub) {
|
||||
case SB_VUART_SETCFG:
|
||||
{
|
||||
uint32_t conf = ectxp->r2;
|
||||
uint32_t conf = ectxp->r1;
|
||||
const vio_uart_config_t *confp;
|
||||
|
||||
/* Check on configuration index.*/
|
||||
|
@ -172,8 +172,8 @@ void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
|||
}
|
||||
case SB_VUART_READ:
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)ectxp->r2;
|
||||
size_t n = (size_t)ectxp->r3;
|
||||
uint8_t *buffer = (uint8_t *)ectxp->r1;
|
||||
size_t n = (size_t)ectxp->r2;
|
||||
|
||||
if (!sb_is_valid_write_range(sbp, buffer, n)) {
|
||||
ectxp->r0 = (uint32_t)0;
|
||||
|
@ -186,8 +186,8 @@ void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
|||
}
|
||||
case SB_VUART_WRITE:
|
||||
{
|
||||
const uint8_t *buffer = (const uint8_t *)ectxp->r2;
|
||||
size_t n = (size_t)ectxp->r3;
|
||||
const uint8_t *buffer = (const uint8_t *)ectxp->r1;
|
||||
size_t n = (size_t)ectxp->r2;
|
||||
|
||||
if (!sb_is_valid_read_range(sbp, buffer, n)) {
|
||||
ectxp->r0 = (uint32_t)0;
|
||||
|
@ -205,13 +205,13 @@ void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
|||
}
|
||||
case SB_VUART_PUT:
|
||||
{
|
||||
sioPutX(unitp->siop, (uint_fast16_t)ectxp->r2);
|
||||
sioPutX(unitp->siop, (uint_fast16_t)ectxp->r1);
|
||||
ectxp->r0 = (uint32_t)0;
|
||||
break;
|
||||
}
|
||||
case SB_VUART_WREN:
|
||||
{
|
||||
sioWriteEnableFlagsX(unitp->siop, (sioevents_t)ectxp->r2);
|
||||
sioWriteEnableFlagsX(unitp->siop, (sioevents_t)ectxp->r1);
|
||||
ectxp->r0 = (uint32_t)0;
|
||||
break;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ void sb_fastc_vio_uart(struct port_extctx *ectxp) {
|
|||
case SB_VUART_GCEVT:
|
||||
{
|
||||
ectxp->r0 = (uint32_t)sioGetAndClearEventsX(unitp->siop,
|
||||
(sioevents_t)ectxp->r2);
|
||||
(sioevents_t)ectxp->r1);
|
||||
break;
|
||||
}
|
||||
case SB_VUART_GEVT:
|
||||
|
|
|
@ -80,6 +80,15 @@ typedef unsigned halclkpt_t;
|
|||
#define __MK_VECTOR(n) __sb_vector##n
|
||||
#define MK_VECTOR(n) __MK_VECTOR(n)
|
||||
|
||||
/**
|
||||
* @brief Builds a VIO call 1st parameter.
|
||||
*
|
||||
* @param[in] c the sub-code
|
||||
* @param[in] u the unit identifier
|
||||
* @return The formatted VIO call 1st parameter.
|
||||
*/
|
||||
#define VIO_CALL(c, u) (((uint32_t)(u) << 24) | (uint32_t)(c))
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -233,39 +233,39 @@ extern "C" {
|
|||
__attribute__((always_inline))
|
||||
static inline uint32_t __pal_lld_readport(ioportid_t port) {
|
||||
|
||||
__syscall2r(96, SB_VGPIO_READ, port);
|
||||
__syscall1r(96, VIO_CALL(SB_VGPIO_READ, port));
|
||||
return (ioportmask_t)r0;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline uint32_t __pal_lld_readlatch(ioportid_t port) {
|
||||
|
||||
__syscall2r(96, SB_VGPIO_READLATCH, port);
|
||||
__syscall1r(96, VIO_CALL(SB_VGPIO_READLATCH, port));
|
||||
return (ioportmask_t)r0;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void __pal_lld_writeport(ioportid_t port, uint32_t bits) {
|
||||
|
||||
__syscall3r(96, SB_VGPIO_WRITE, port, bits);
|
||||
__syscall2r(96, VIO_CALL(SB_VGPIO_WRITE, port), bits);
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void __pal_lld_setport(ioportid_t port, uint32_t bits) {
|
||||
|
||||
__syscall3r(96, SB_VGPIO_SET, port, bits);
|
||||
__syscall2r(96, VIO_CALL(SB_VGPIO_SET, port), bits);
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void __pal_lld_clearport(ioportid_t port, uint32_t bits) {
|
||||
|
||||
__syscall3r(96, SB_VGPIO_CLEAR, port, bits);
|
||||
__syscall2r(96, VIO_CALL(SB_VGPIO_CLEAR, port), bits);
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void __pal_lld_toggleport(ioportid_t port, uint32_t bits) {
|
||||
|
||||
__syscall3r(96, SB_VGPIO_TOGGLE, port, bits);
|
||||
__syscall2r(96, VIO_CALL(SB_VGPIO_TOGGLE, port), bits);
|
||||
}
|
||||
|
||||
#endif /* HAL_USE_PAL == TRUE */
|
||||
|
|
|
@ -66,21 +66,21 @@ static const SIOConfig default_config = {
|
|||
CC_FORCE_INLINE
|
||||
static inline uint32_t __sio_vuart_init(uint32_t nvuart) {
|
||||
|
||||
__syscall2r(225, SB_VUART_INIT, nvuart);
|
||||
__syscall1r(225, VIO_CALL(SB_VUART_INIT, nvuart));
|
||||
return (uint32_t)r0;
|
||||
}
|
||||
|
||||
CC_FORCE_INLINE
|
||||
static inline uint32_t __sio_vuart_deinit(uint32_t nvuart) {
|
||||
|
||||
__syscall2r(225, SB_VUART_DEINIT, nvuart);
|
||||
__syscall1r(225, VIO_CALL(SB_VUART_DEINIT, nvuart));
|
||||
return (uint32_t)r0;
|
||||
}
|
||||
|
||||
CC_FORCE_INLINE
|
||||
static inline uint32_t __sio_vuart_setcfg(uint32_t nvuart, uint32_t ncfg) {
|
||||
|
||||
__syscall3r(225, SB_VUART_SETCFG, nvuart, ncfg);
|
||||
__syscall2r(225, VIO_CALL(SB_VUART_SETCFG, nvuart), ncfg);
|
||||
return (uint32_t)r0;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ msg_t sio_lld_configure(SIODriver *siop, const SIOConfig *config) {
|
|||
*/
|
||||
bool sio_lld_is_rx_empty(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_ISRXE, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_ISRXE, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (bool)r0;
|
||||
|
@ -237,7 +237,7 @@ bool sio_lld_is_rx_empty(SIODriver *siop) {
|
|||
*/
|
||||
bool sio_lld_is_rx_idle(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_ISRXI, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_ISRXI, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (bool)r0;
|
||||
|
@ -257,7 +257,7 @@ bool sio_lld_is_rx_idle(SIODriver *siop) {
|
|||
*/
|
||||
bool sio_lld_has_rx_errors(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_HASERR, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_HASERR, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (bool)r0;
|
||||
|
@ -275,7 +275,7 @@ bool sio_lld_has_rx_errors(SIODriver *siop) {
|
|||
*/
|
||||
bool sio_lld_is_tx_full(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_ISTXF, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_ISTXF, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (bool)r0;
|
||||
|
@ -293,7 +293,7 @@ bool sio_lld_is_tx_full(SIODriver *siop) {
|
|||
*/
|
||||
bool sio_lld_is_tx_ongoing(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_ISTXO, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_ISTXO, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (bool)r0;
|
||||
|
@ -306,7 +306,7 @@ bool sio_lld_is_tx_ongoing(SIODriver *siop) {
|
|||
*/
|
||||
void sio_lld_update_enable_flags(SIODriver *siop) {
|
||||
|
||||
__syscall3r(97, SB_VUART_WREN, siop->nvuart, siop->enabled);
|
||||
__syscall2r(97, VIO_CALL(SB_VUART_WREN, siop->nvuart), siop->enabled);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ void sio_lld_update_enable_flags(SIODriver *siop) {
|
|||
*/
|
||||
sioevents_t sio_lld_get_and_clear_errors(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_GCERR, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_GCERR, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (sioevents_t)r0;
|
||||
|
@ -337,7 +337,7 @@ sioevents_t sio_lld_get_and_clear_errors(SIODriver *siop) {
|
|||
*/
|
||||
sioevents_t sio_lld_get_and_clear_events(SIODriver *siop, sioevents_t events) {
|
||||
|
||||
__syscall3r(97, SB_VUART_GCEVT, siop->nvuart, events);
|
||||
__syscall2r(97, VIO_CALL(SB_VUART_GCEVT, siop->nvuart), events);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (sioevents_t)r0;
|
||||
|
@ -353,7 +353,7 @@ sioevents_t sio_lld_get_and_clear_events(SIODriver *siop, sioevents_t events) {
|
|||
*/
|
||||
sioevents_t sio_lld_get_events(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_GEVT, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_GEVT, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (sioevents_t)r0;
|
||||
|
@ -372,7 +372,7 @@ sioevents_t sio_lld_get_events(SIODriver *siop) {
|
|||
*/
|
||||
size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n) {
|
||||
|
||||
__syscall4r(97, SB_VUART_READ, siop->nvuart, buffer, n);
|
||||
__syscall3r(97, VIO_CALL(SB_VUART_READ, siop->nvuart), buffer, n);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (size_t)r0;
|
||||
|
@ -391,7 +391,7 @@ size_t sio_lld_read(SIODriver *siop, uint8_t *buffer, size_t n) {
|
|||
*/
|
||||
size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n) {
|
||||
|
||||
__syscall4r(97, SB_VUART_WRITE, siop->nvuart, buffer, n);
|
||||
__syscall3r(97, VIO_CALL(SB_VUART_WRITE, siop->nvuart), buffer, n);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (size_t)r0;
|
||||
|
@ -408,7 +408,7 @@ size_t sio_lld_write(SIODriver *siop, const uint8_t *buffer, size_t n) {
|
|||
*/
|
||||
msg_t sio_lld_get(SIODriver *siop) {
|
||||
|
||||
__syscall2r(97, SB_VUART_GET, siop->nvuart);
|
||||
__syscall1r(97, VIO_CALL(SB_VUART_GET, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (size_t)r0;
|
||||
|
@ -425,7 +425,7 @@ msg_t sio_lld_get(SIODriver *siop) {
|
|||
*/
|
||||
void sio_lld_put(SIODriver *siop, uint_fast16_t data) {
|
||||
|
||||
__syscall3r(97, SB_VUART_PUT, siop->nvuart, data);
|
||||
__syscall2r(97, VIO_CALL(SB_VUART_PUT, siop->nvuart), data);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ void sio_lld_put(SIODriver *siop, uint_fast16_t data) {
|
|||
*/
|
||||
msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg) {
|
||||
|
||||
__syscall4r(97, SB_VUART_CTL, siop->nvuart, operation, arg);
|
||||
__syscall3r(97, VIO_CALL(SB_VUART_CTL, siop->nvuart), operation, arg);
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
return (msg_t)r0;
|
||||
|
@ -462,7 +462,7 @@ void sio_lld_serve_interrupt(SIODriver *siop) {
|
|||
sioevents_t events;
|
||||
|
||||
#if SIO_USE_SYNCHRONIZATION == TRUE
|
||||
__syscall2rr(97, SB_VUART_GEVT, siop->nvuart);
|
||||
__syscall1rr(97, VIO_CALL(SB_VUART_GEVT, siop->nvuart));
|
||||
osalDbgAssert(r0 != (uint32_t)-1, "unexpected failure");
|
||||
|
||||
/* Processing enabled events, if any.*/
|
||||
|
|
Loading…
Reference in New Issue