git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15202 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2021-12-05 12:26:00 +00:00
parent cc7d41bbd6
commit fe6602f75f
8 changed files with 55 additions and 9 deletions

View File

@ -110,6 +110,7 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
# VFS files (optional). # VFS files (optional).
include $(CHIBIOS)/os/vfs/vfs.mk include $(CHIBIOS)/os/vfs/vfs.mk
include $(CHIBIOS)/os/vfs/vfs_syscalls.mk
# Auto-build files in ./source recursively. # Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional). # Other files (optional).

View File

@ -110,6 +110,7 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
# VFS files (optional). # VFS files (optional).
include $(CHIBIOS)/os/vfs/vfs.mk include $(CHIBIOS)/os/vfs/vfs.mk
include $(CHIBIOS)/os/vfs/vfs_syscalls.mk
# Auto-build files in ./source recursively. # Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional). # Other files (optional).

View File

@ -115,14 +115,13 @@ caddr_t _sbrk_r(struct _reent *r, int incr) {
} }
__attribute__((used)) __attribute__((used))
int _kill(struct _reent *r, int pid, int sig) { int _kill(int pid, int sig) {
(void) r;
(void) pid; (void) pid;
(void) sig; (void) sig;
chSysHalt("kill"); errno = EINVAL;
abort(); return -1;
} }
__attribute__((used)) __attribute__((used))

View File

@ -31,6 +31,7 @@
#include "chprintf.h" #include "chprintf.h"
#if (SHELL_CMD_FILES_ENABLED == TRUE) || defined(__DOXYGEN__) #if (SHELL_CMD_FILES_ENABLED == TRUE) || defined(__DOXYGEN__)
#include <fcntl.h>
#include "vfs.h" #include "vfs.h"
#endif #endif
@ -297,6 +298,42 @@ static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
chHeapFree((void *)nip); chHeapFree((void *)nip);
} }
} }
static void cmd_cat(BaseSequentialStream *chp, int argc, char *argv[]) {
char *buf = NULL;
if (argc != 1) {
chprintf(chp, "Usage: cat <filename>\r\n");
return;
}
do {
int fd, n;
buf= (char *)chHeapAlloc(NULL, 2048);
if (buf == NULL) {
chprintf(chp, "Out of memory\r\n");
break;
}
fd = open(argv[1], O_RDONLY);
if(fd == -1) {
chprintf(chp, "Cannot open file\r\n");
break;
}
while ((n = read(fd, buf, sizeof (buf))) > 0) {
chprintf(chp, "%s", buf);
}
(void) close(fd);
}
while (false);
if (buf != NULL) {
chHeapFree((void *)buf);
}
}
#endif #endif
/*===========================================================================*/ /*===========================================================================*/
@ -327,6 +364,7 @@ const ShellCommand shell_local_commands[] = {
#endif #endif
#if SHELL_CMD_FILES_ENABLED == TRUE #if SHELL_CMD_FILES_ENABLED == TRUE
{"tree", cmd_tree}, {"tree", cmd_tree},
{"cat", cmd_cat},
#endif #endif
#if SHELL_CMD_TEST_ENABLED == TRUE #if SHELL_CMD_TEST_ENABLED == TRUE
{"test", cmd_test}, {"test", cmd_test},

View File

@ -62,7 +62,7 @@
#endif #endif
#if !defined(SHELL_CMD_FILES_ENABLED) || defined(__DOXYGEN__) #if !defined(SHELL_CMD_FILES_ENABLED) || defined(__DOXYGEN__)
#define SHELL_CMD_FILES_ENABLED FALSE #define SHELL_CMD_FILES_ENABLED TRUE
#endif #endif
#if !defined(SHELL_CMD_TEST_WA_SIZE) || defined(__DOXYGEN__) #if !defined(SHELL_CMD_TEST_WA_SIZE) || defined(__DOXYGEN__)

View File

@ -196,9 +196,8 @@ void _exit(int status) {
/***************************************************************************/ /***************************************************************************/
__attribute__((used)) __attribute__((used))
int _kill(struct _reent *r, int pid, int sig) { int _kill(int pid, int sig) {
(void) r;
(void) pid; (void) pid;
(void) sig; (void) sig;

View File

@ -191,9 +191,8 @@ void _exit(int status) {
/***************************************************************************/ /***************************************************************************/
__attribute__((used)) __attribute__((used))
int _kill(struct _reent *r, int pid, int sig) { int _kill(int pid, int sig) {
(void) r;
(void) pid; (void) pid;
(void) sig; (void) sig;

9
os/vfs/vfs_syscalls.mk Normal file
View File

@ -0,0 +1,9 @@
# List of all the ChibiOS/VFS syscall files.
VFSSYSSRC := $(CHIBIOS)/os/vfs/various/syscalls.c \
# Required include directories
VFSSYSINC := $(CHIBIOS)/os/vfs/various
# Shared variables
ALLCSRC += $(VFSSYSSRC)
ALLINC += $(VFSSYSINC)