git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15277 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
8df9b3d998
commit
8eca9d11d6
|
@ -177,7 +177,7 @@ static void InsertHandler(eventid_t id) {
|
|||
#endif
|
||||
|
||||
err = drvFatFSMount("0:", 1);
|
||||
if (CH_IS_ERROR(err)) {
|
||||
if (CH_RET_IS_ERROR(err)) {
|
||||
#if HAL_USE_SDC
|
||||
sdcDisconnect(&PORTAB_SDCD1);
|
||||
#else
|
||||
|
@ -288,13 +288,13 @@ int main(void) {
|
|||
msg = drvOverlayRegisterDriver(&root_overlay_driver,
|
||||
drvStreamsObjectInit(&dev_driver, &streams[0]),
|
||||
"dev");
|
||||
if (CH_IS_ERROR(msg)) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
chSysHalt("VFS");
|
||||
}
|
||||
|
||||
/* Opening a file for shell I/O.*/
|
||||
msg = vfsOpenFile("/dev/VSD1", VO_RDWR, &file);
|
||||
if (CH_IS_ERROR(msg)) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
chSysHalt("VFS");
|
||||
}
|
||||
shell_cfg1.sc_channel = vfsGetFileStream(file);
|
||||
|
|
|
@ -98,6 +98,8 @@ DEPDIR := ./.dep
|
|||
include $(CHIBIOS)/os/license/license.mk
|
||||
# Startup files.
|
||||
include $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk
|
||||
# Common files.
|
||||
include $(CHIBIOS)/os/common/utils/utils.mk
|
||||
# HAL-OSAL files (optional).
|
||||
#include $(CHIBIOS)/os/hal/hal.mk
|
||||
#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk
|
||||
|
|
|
@ -98,6 +98,8 @@ DEPDIR := ./.dep
|
|||
include $(CHIBIOS)/os/license/license.mk
|
||||
# Startup files.
|
||||
include $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk
|
||||
# Common files.
|
||||
include $(CHIBIOS)/os/common/utils/utils.mk
|
||||
# HAL-OSAL files (optional).
|
||||
#include $(CHIBIOS)/os/hal/hal.mk
|
||||
#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk
|
||||
|
|
|
@ -91,14 +91,14 @@
|
|||
#define CH_ERRORS_MASK (msg_t)0xFF
|
||||
#define CH_ENCODE_ERROR(posixerr) (~CH_ERRORS_MASK | (msg_t)(posixerr))
|
||||
#define CH_DECODE_ERROR(err) ((msg_t)(err) & CH_ERRORS_MASK)
|
||||
#define CH_IS_ERROR(x) (((msg_t)(x) & ~CH_ERRORS_MASK) == ~CH_ERRORS_MASK)
|
||||
#define CH_RET_IS_ERROR(x) (((msg_t)(x) & ~CH_ERRORS_MASK) == ~CH_ERRORS_MASK)
|
||||
|
||||
#define CH_BREAK_ON_ERROR(err) \
|
||||
if (CH_IS_ERROR(err)) break
|
||||
if (CH_RET_IS_ERROR(err)) break
|
||||
|
||||
#define CH_RETURN_ON_ERROR(err) do { \
|
||||
msg_t __ret = (err); \
|
||||
if (CH_IS_ERROR(__ret)) { \
|
||||
if (CH_RET_IS_ERROR(__ret)) { \
|
||||
return __ret; \
|
||||
} \
|
||||
} while (false)
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#ifndef SBUSER_H
|
||||
#define SBUSER_H
|
||||
|
||||
#include "sberr.h"
|
||||
#include "errcodes.h"
|
||||
#include "sbsysc.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module constants. */
|
||||
|
|
|
@ -32,7 +32,7 @@ int _close_r(struct _reent *r, int file) {
|
|||
uint32_t err;
|
||||
|
||||
err = sbFileClose((uint32_t)file);
|
||||
if (SB_ERR_ISERROR(err)) {
|
||||
if (CH_RET_IS_ERROR(err)) {
|
||||
__errno_r(r) = MAKERR(err);
|
||||
return -1;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ int _write_r(struct _reent *r, int file, char * ptr, int len) {
|
|||
uint32_t err;
|
||||
|
||||
err = sbFileWrite((uint32_t)file, (const uint8_t *)ptr, (size_t)len);
|
||||
if (SB_ERR_ISERROR(err)) {
|
||||
if (CH_RET_IS_ERROR(err)) {
|
||||
__errno_r(r) = MAKERR(err);
|
||||
return -1;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int _read_r(struct _reent *r, int file, char * ptr, int len) {
|
|||
uint32_t err;
|
||||
|
||||
err = sbFileRead((uint32_t)file, (uint8_t *)ptr, (size_t)len);
|
||||
if (SB_ERR_ISERROR(err)) {
|
||||
if (CH_RET_IS_ERROR(err)) {
|
||||
__errno_r(r) = MAKERR(err);
|
||||
return -1;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
|
|||
uint32_t err;
|
||||
|
||||
err = sbFileSeek((uint32_t)file, (uint32_t)ptr, (uint32_t)dir);
|
||||
if (SB_ERR_ISERROR(err)) {
|
||||
if (CH_RET_IS_ERROR(err)) {
|
||||
__errno_r(r) = MAKERR(err);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ static void cmd_cd(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
msg_t res;
|
||||
|
||||
res = vfsChangeCurrentDirectory(argv[0]);
|
||||
if (CH_IS_ERROR(res)) {
|
||||
if (CH_RET_IS_ERROR(res)) {
|
||||
chprintf(chp, "failed (%d)" SHELL_NEWLINE_STR, res);
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ static void cmd_ls(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
|
||||
/* Opening the (un)specified directory.*/
|
||||
res = vfsOpenDirectory(argc == 1 ? argv[0] : ".", &dirp);
|
||||
if (!CH_IS_ERROR(res)) {
|
||||
if (!CH_RET_IS_ERROR(res)) {
|
||||
|
||||
while (vfsReadDirectoryNext(dirp, dip) > (msg_t)0) {
|
||||
chprintf(chp, "%s" SHELL_NEWLINE_STR, dip->name);
|
||||
|
@ -413,7 +413,7 @@ static void cmd_pwd(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
res = vfsGetCurrentDirectory(buf, VFS_CFG_PATHLEN_MAX + 1);
|
||||
if (CH_IS_ERROR(res)) {
|
||||
if (CH_RET_IS_ERROR(res)) {
|
||||
chprintf(chp, "Failed (%d)" SHELL_NEWLINE_STR, res);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -456,7 +456,7 @@ static size_t file_stream_write(void *instance, const uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fffnp->vmt->file_write((void *)fffnp, bp, n);
|
||||
if (msg < CH_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ static size_t file_stream_read(void *instance, uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fffnp->vmt->file_read((void *)fffnp, bp, n);
|
||||
if (msg < CH_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ static msg_t file_stream_put(void *instance, uint8_t b) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fffnp->vmt->file_write((void *)fffnp, &b, (size_t)1);
|
||||
if (msg < CH_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ static msg_t file_stream_get(void *instance) {
|
|||
uint8_t b;
|
||||
|
||||
msg = fffnp->vmt->file_read((void *)fffnp, &b, (size_t)1);
|
||||
if (msg < CH_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ static msg_t open_absolute_dir(vfs_overlay_driver_c *drvp,
|
|||
|
||||
/* Searching for a match among registered overlays.*/
|
||||
err = match_driver(drvp, &scanpath, &dp);
|
||||
if (!CH_IS_ERROR(err)) {
|
||||
if (!CH_RET_IS_ERROR(err)) {
|
||||
/* Delegating node creation to a registered driver.*/
|
||||
err = dp->vmt->open_dir((void *)dp,
|
||||
scanpath,
|
||||
|
@ -272,7 +272,7 @@ static msg_t open_absolute_file(vfs_overlay_driver_c *drvp,
|
|||
|
||||
/* Searching for a match among registered overlays.*/
|
||||
err = match_driver(drvp, &scanpath, &dp);
|
||||
if (!CH_IS_ERROR(err)) {
|
||||
if (!CH_RET_IS_ERROR(err)) {
|
||||
/* Delegating node creation to a registered driver.*/
|
||||
err = dp->vmt->open_file((void *)dp, scanpath, oflag, vfnpp);
|
||||
}
|
||||
|
|
|
@ -142,10 +142,10 @@ static msg_t drv_set_cwd(void *instance, const char *path) {
|
|||
(void)instance;
|
||||
|
||||
if (strcmp(path, "/") != 0) {
|
||||
return VFS_RET_ENOENT;
|
||||
return CH_RET_ENOENT;
|
||||
}
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static msg_t drv_get_cwd(void *instance, char *buf, size_t size) {
|
||||
|
@ -153,19 +153,19 @@ static msg_t drv_get_cwd(void *instance, char *buf, size_t size) {
|
|||
(void)instance;
|
||||
|
||||
if (size < 2) {
|
||||
return VFS_RET_ERANGE;
|
||||
return CH_RET_ERANGE;
|
||||
}
|
||||
|
||||
buf[0] = '/';
|
||||
buf[1] = '\0';
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static msg_t drv_open_dir(void *instance,
|
||||
const char *path,
|
||||
vfs_directory_node_c **vdnpp) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_sfs_driver_c *drvp = (vfs_sfs_driver_c *)instance;
|
||||
|
@ -184,7 +184,7 @@ static msg_t drv_open_file(void *instance,
|
|||
const char *path,
|
||||
int flags,
|
||||
vfs_file_node_c **vfnpp) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_sfs_driver_c *drvp = (vfs_sfs_driver_c *)instance;
|
||||
|
@ -212,7 +212,7 @@ static void node_dir_release(void *instance) {
|
|||
|
||||
static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip) {
|
||||
vfs_sfs_dir_node_c *dnp = (vfs_sfs_dir_node_c *)instance;
|
||||
msg_t err = VFS_RET_SUCCESS;;
|
||||
msg_t err = CH_RET_SUCCESS;;
|
||||
|
||||
(void)dnp;
|
||||
|
||||
|
@ -223,7 +223,7 @@ static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip) {
|
|||
}
|
||||
|
||||
static msg_t node_dir_next(void *instance, vfs_direntry_info_t *dip) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_sfs_dir_node_c *dnp = (vfs_sfs_dir_node_c *)instance;
|
||||
|
@ -278,7 +278,7 @@ static msg_t node_file_setpos(void *instance, vfs_offset_t offset) {
|
|||
(void)fnp;
|
||||
(void)offset;
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static vfs_offset_t node_file_getpos(void *instance) {
|
||||
|
@ -294,7 +294,7 @@ static msg_t node_file_getstat(void *instance, vfs_file_stat_t *fsp) {
|
|||
(void)instance;
|
||||
(void)fsp;
|
||||
|
||||
return VFS_RET_ENOSYS;
|
||||
return CH_RET_ENOSYS;
|
||||
}
|
||||
|
||||
static size_t file_stream_write(void *instance, const uint8_t *bp, size_t n) {
|
||||
|
@ -303,7 +303,7 @@ static size_t file_stream_write(void *instance, const uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_write((void *)fnp, bp, n);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ static size_t file_stream_read(void *instance, uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_read((void *)fnp, bp, n);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ static msg_t file_stream_put(void *instance, uint8_t b) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_write((void *)fnp, &b, (size_t)1);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ static msg_t file_stream_get(void *instance) {
|
|||
uint8_t b;
|
||||
|
||||
msg = fnp->vmt->file_read((void *)fnp, &b, (size_t)1);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
|
|
@ -142,10 +142,10 @@ static msg_t drv_set_cwd(void *instance, const char *path) {
|
|||
(void)instance;
|
||||
|
||||
if (strcmp(path, "/") != 0) {
|
||||
return VFS_RET_ENOENT;
|
||||
return CH_RET_ENOENT;
|
||||
}
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static msg_t drv_get_cwd(void *instance, char *buf, size_t size) {
|
||||
|
@ -153,19 +153,19 @@ static msg_t drv_get_cwd(void *instance, char *buf, size_t size) {
|
|||
(void)instance;
|
||||
|
||||
if (size < 2) {
|
||||
return VFS_RET_ERANGE;
|
||||
return CH_RET_ERANGE;
|
||||
}
|
||||
|
||||
buf[0] = '/';
|
||||
buf[1] = '\0';
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static msg_t drv_open_dir(void *instance,
|
||||
const char *path,
|
||||
vfs_directory_node_c **vdnpp) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_template_driver_c *drvp = (vfs_template_driver_c *)instance;
|
||||
|
@ -184,14 +184,14 @@ static msg_t drv_open_file(void *instance,
|
|||
const char *path,
|
||||
int flags,
|
||||
vfs_file_node_c **vfnpp) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_template_driver_c *drvp = (vfs_template_driver_c *)instance;
|
||||
|
||||
(void)drvp;
|
||||
(void)path;
|
||||
(void)oflag;
|
||||
(void)flags;
|
||||
(void)vfnpp;
|
||||
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ static void node_dir_release(void *instance) {
|
|||
|
||||
static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip) {
|
||||
vfs_template_dir_node_c *dnp = (vfs_template_dir_node_c *)instance;
|
||||
msg_t err = VFS_RET_SUCCESS;;
|
||||
msg_t err = CH_RET_SUCCESS;;
|
||||
|
||||
(void)dnp;
|
||||
|
||||
|
@ -223,7 +223,7 @@ static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip) {
|
|||
}
|
||||
|
||||
static msg_t node_dir_next(void *instance, vfs_direntry_info_t *dip) {
|
||||
msg_t err = VFS_RET_SUCCESS;
|
||||
msg_t err = CH_RET_SUCCESS;
|
||||
|
||||
do {
|
||||
vfs_template_dir_node_c *dnp = (vfs_template_dir_node_c *)instance;
|
||||
|
@ -278,7 +278,7 @@ static msg_t node_file_setpos(void *instance, vfs_offset_t offset) {
|
|||
(void)fnp;
|
||||
(void)offset;
|
||||
|
||||
return VFS_RET_SUCCESS;
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static vfs_offset_t node_file_getpos(void *instance) {
|
||||
|
@ -294,7 +294,7 @@ static msg_t node_file_getstat(void *instance, vfs_file_stat_t *fsp) {
|
|||
(void)instance;
|
||||
(void)fsp;
|
||||
|
||||
return VFS_RET_ENOSYS;
|
||||
return CH_RET_ENOSYS;
|
||||
}
|
||||
|
||||
static size_t file_stream_write(void *instance, const uint8_t *bp, size_t n) {
|
||||
|
@ -303,7 +303,7 @@ static size_t file_stream_write(void *instance, const uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_write((void *)fnp, bp, n);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ static size_t file_stream_read(void *instance, uint8_t *bp, size_t n) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_read((void *)fnp, bp, n);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return (size_t)0;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ static msg_t file_stream_put(void *instance, uint8_t b) {
|
|||
msg_t msg;
|
||||
|
||||
msg = fnp->vmt->file_write((void *)fnp, &b, (size_t)1);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ static msg_t file_stream_get(void *instance) {
|
|||
uint8_t b;
|
||||
|
||||
msg = fnp->vmt->file_read((void *)fnp, &b, (size_t)1);
|
||||
if (msg < VFS_RET_SUCCESS) {
|
||||
if (CH_RET_IS_ERROR(msg)) {
|
||||
|
||||
return STM_TIMEOUT;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ int _read_r(struct _reent *r, int file, char *ptr, int len) {
|
|||
}
|
||||
|
||||
nr = vfsReadFile(fds[file], (uint8_t *)ptr, (size_t)len);
|
||||
if (CH_IS_ERROR(nr)) {
|
||||
if (CH_RET_IS_ERROR(nr)) {
|
||||
__errno_r(r) = CH_DECODE_ERROR(nr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ int _write_r(struct _reent *r, int file, const char *ptr, int len) {
|
|||
}
|
||||
|
||||
nw = vfsWriteFile(fds[file], (const uint8_t *)ptr, (size_t)len);
|
||||
if (CH_IS_ERROR(nw)) {
|
||||
if (CH_RET_IS_ERROR(nw)) {
|
||||
__errno_r(r) = CH_DECODE_ERROR(nw);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue