Adopted Posix-like error codes for the sandbox. Implemented stdin, stdout and stderr as separate streams.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12990 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
f7d500c20f
commit
3500272800
|
@ -54,7 +54,9 @@ static THD_FUNCTION(Unprivileged1, arg) {
|
|||
.r0_end = (uint32_t)&__flash7_end__,
|
||||
.r1_base = (uint32_t)&__ram7_start__,
|
||||
.r1_end = (uint32_t)&__ram7_end__,
|
||||
.stdio_stream = (SandboxStream *)&SD2
|
||||
.stdin_stream = (SandboxStream *)&SD2,
|
||||
.stdout_stream = (SandboxStream *)&SD2,
|
||||
.stderr_stream = (SandboxStream *)&SD2
|
||||
};
|
||||
sb_class_t sbx1;
|
||||
|
||||
|
|
|
@ -37,10 +37,13 @@
|
|||
* @{
|
||||
*/
|
||||
#define SB_ERR_NOERROR 0U
|
||||
#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_ENOENT ((uint32_t)(-2))
|
||||
#define SB_ERR_EFAULT ((uint32_t)(-14))
|
||||
#define SB_ERR_EBUSY ((uint32_t)(-16))
|
||||
#define SB_ERR_EINVAL ((uint32_t)(-22))
|
||||
#define SB_ERR_ESPIPE ((uint32_t)(-29))
|
||||
#define SB_ERR_EBADFD ((uint32_t)(-81))
|
||||
#define SB_ERR_ENOSYS ((uint32_t)(-88))
|
||||
|
||||
#define SB_ERR_ERRORMASK 0xFFFFFF00U
|
||||
#define SB_ERR_ISERROR(x) (((x) & SB_ERR_ERRORMASK) == SB_ERR_ERRORMASK)
|
||||
|
|
|
@ -915,7 +915,7 @@ const port_syscall_t sb_syscalls[256] = {
|
|||
|
||||
static void sb_undef_handler(struct port_extctx *ectxp) {
|
||||
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
ectxp->r0 = SB_ERR_ENOSYS;
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -927,28 +927,28 @@ 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);
|
||||
ectxp->r2);
|
||||
break;
|
||||
case SB_POSIX_CLOSE:
|
||||
ectxp->r0 = sb_posix_close((int)ectxp->r1);
|
||||
ectxp->r0 = sb_posix_close(ectxp->r1);
|
||||
break;
|
||||
case SB_POSIX_READ:
|
||||
ectxp->r0 = sb_posix_read((int)ectxp->r1,
|
||||
ectxp->r0 = sb_posix_read(ectxp->r1,
|
||||
(void *)ectxp->r2,
|
||||
(size_t)ectxp->r3);
|
||||
break;
|
||||
case SB_POSIX_WRITE:
|
||||
ectxp->r0 = sb_posix_write((int)ectxp->r1,
|
||||
ectxp->r0 = sb_posix_write(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);
|
||||
ectxp->r0 = sb_posix_lseek(ectxp->r1,
|
||||
ectxp->r2,
|
||||
ectxp->r3);
|
||||
break;
|
||||
default:
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
ectxp->r0 = SB_ERR_ENOSYS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -958,7 +958,7 @@ void sb_api_exit(struct port_extctx *ectxp) {
|
|||
chThdExit((msg_t )ectxp->r0);
|
||||
|
||||
/* Cannot get here.*/
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
ectxp->r0 = SB_ERR_ENOSYS;
|
||||
}
|
||||
|
||||
void sb_api_get_systime(struct port_extctx *ectxp) {
|
||||
|
@ -999,7 +999,7 @@ void sb_api_wait_message(struct port_extctx *ectxp) {
|
|||
else {
|
||||
chMsgRelease(sbcp->msg_tp, MSG_RESET);
|
||||
sbcp->msg_tp = NULL;
|
||||
ectxp->r0 = SB_ERR_API_USAGE;
|
||||
ectxp->r0 = SB_ERR_EBUSY;
|
||||
}
|
||||
#else
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
|
@ -1013,10 +1013,10 @@ void sb_api_reply_message(struct port_extctx *ectxp) {
|
|||
if (sbcp->msg_tp != NULL) {
|
||||
chMsgRelease(sbcp->msg_tp, (msg_t )ectxp->r0);
|
||||
sbcp->msg_tp = NULL;
|
||||
ectxp->r0 = SB_ERR_API_USAGE;
|
||||
ectxp->r0 = SB_ERR_NOERROR;
|
||||
}
|
||||
else {
|
||||
ectxp->r0 = SB_ERR_API_USAGE;
|
||||
ectxp->r0 = SB_ERR_EBUSY;
|
||||
}
|
||||
#else
|
||||
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -78,12 +78,26 @@ typedef struct {
|
|||
*/
|
||||
uint32_t r1_end;
|
||||
/**
|
||||
* @brief Sandbox stream.
|
||||
* @brief Sandbox STDIN 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;
|
||||
SandboxStream *stdin_stream;
|
||||
/**
|
||||
* @brief Sandbox STDOUT 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 *stdout_stream;
|
||||
/**
|
||||
* @brief Sandbox STDERR 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 *stderr_stream;
|
||||
} sb_config_t;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue