summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--arch/Makefile1
-rw-r--r--arch/arm/lpc17xx/handlers.c3
-rw-r--r--demo.c8
-rw-r--r--os/Makefile4
-rw-r--r--os/src/close.c3
-rw-r--r--os/src/fclose.c3
-rw-r--r--os/src/fflush.c2
-rw-r--r--os/src/filesystem.c2
-rw-r--r--os/src/fio.c7
-rw-r--r--os/src/fopen.c2
-rw-r--r--os/src/fprintf.c4
-rw-r--r--os/src/fread.c2
-rw-r--r--os/src/free.c4
-rw-r--r--os/src/fstat.c2
-rw-r--r--os/src/fwrite.c2
-rw-r--r--os/src/isatty.c2
-rw-r--r--os/src/lseek.c2
-rw-r--r--os/src/malloc.c2
-rw-r--r--os/src/open.c2
-rw-r--r--os/src/printf.c1
-rw-r--r--os/src/read.c2
-rw-r--r--os/src/romfs.c2
-rw-r--r--os/src/sprintf.c2
-rw-r--r--os/src/write.c2
25 files changed, 58 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index ee7f336..203c0be 100644
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,7 @@ tools:
$(E) "[MAKE] Entering tools"
$(Q)$(MAKE) $(MAKE_OPTS) -C tools
-test-romfs.o: tools
+test-romfs.o: tools/mkromfs
$(E) "[ROMFS] Building test romfs"
$(Q) tools/mkromfs -d test-romfs test-romfs.bin
$(Q) $(TARGET_OBJCOPY_BIN) --prefix-sections '.romfs' test-romfs.bin test-romfs.o
diff --git a/arch/Makefile b/arch/Makefile
index 7dab0ab..a326af1 100644
--- a/arch/Makefile
+++ b/arch/Makefile
@@ -8,6 +8,7 @@ include $(ROOTDIR)/FreeRTOS/config.mk
include $(ROOTDIR)/os/config.mk
ifeq ($(CPU),arm)
+TARGET_SRCS += arm/src/angel.s
ifeq ($(CPU_FLAVOR),lpc1768)
TARGET_SRCS += arm/lpc17xx/Core/CM3/DeviceSupport/NXP/LPC17xx/system_LPC17xx.c arm/lpc17xx/Core/CM3/CoreSupport/core_cm3.c
TARGET_SRCS += $(addprefix arm/lpc17xx/Drivers/source/lpc17xx_, spi.c rit.c exti.c wdt.c uart.c dac.c rtc.c i2s.c pwm.c mcpwm.c pinsel.c nvic.c emac.c systick.c ssp.c can.c gpio.c libcfg_default.c i2c.c timer.c gpdma.c clkpwr.c qei.c adc.c)
diff --git a/arch/arm/lpc17xx/handlers.c b/arch/arm/lpc17xx/handlers.c
index a421aff..50b02e8 100644
--- a/arch/arm/lpc17xx/handlers.c
+++ b/arch/arm/lpc17xx/handlers.c
@@ -35,6 +35,9 @@ void general_C_handler(enum FaultType fault, struct fault_data_extra_t * fault_d
uint8_t MMFSR = SCB->CFSR & 0xff;
uint8_t BFSR = (SCB->CFSR >> 8) & 0xff;
uint16_t UFSR = (SCB->CFSR >> 16) & 0xffff;
+ (void) MMFSR;
+ (void) BFSR;
+ (void) UFSR;
struct fault_data_cpu_t * fault_data_cpu = (struct fault_data_cpu_t *) ((eflags & 4) ? (void *) __get_PSP() : (void *) (fault_data_extra + 1));
DBGOUT("***FAULT***\r\neflags = 0x0%x\r\nPSP = %p\r\nType: ", eflags, __get_PSP());
switch (fault) {
diff --git a/demo.c b/demo.c
index fbf2b26..d106f63 100644
--- a/demo.c
+++ b/demo.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <fio.h>
#include <romfs.h>
+#include <semifs.h>
#define LED1_wire 18
#define LED2_wire 20
@@ -66,10 +67,11 @@ static const char msg[] = "Hello world - from fwrite!\r\n";
extern uint8_t _binary_test_romfs_bin_start[];
int main() {
- FILE * f1, * f2;
+ FILE * f1, * f2, * f3;
char buf[32];
int c;
register_devfs();
+ register_semifs();
register_romfs("romfs", _binary_test_romfs_bin_start);
handle = xSemaphoreCreateMutex();
printf("Hello world - from stdio!\r\n");
@@ -79,9 +81,13 @@ int main() {
f2 = fopen("/romfs/test.txt", "r");
c = fread(buf, 1, 32, f2);
fwrite(buf, 1, c, f1);
+ f3 = fopen("/host/TEST.TXT", "r");
+ c = fread(buf, 1, 32, f3);
+ fwrite(buf, 1, c, f1);
fflush(f1);
fclose(f1);
fclose(f2);
+ fclose(f3);
setupLEDs();
litLED(1, 0);
litLED(2, 0);
diff --git a/os/Makefile b/os/Makefile
index cfc6e33..d7d0419 100644
--- a/os/Makefile
+++ b/os/Makefile
@@ -36,6 +36,10 @@ src/malloc.c \
src/printf.c \
src/sprintf.c \
+ifeq ($(CPU),arm)
+TARGET_SRCS += src/semifs.c
+endif
+
include $(ROOTDIR)/target-rules.mk
clean: clean-generic
diff --git a/os/src/close.c b/os/src/close.c
index 90b22ed..5da8b2c 100644
--- a/os/src/close.c
+++ b/os/src/close.c
@@ -1,9 +1,10 @@
#include <reent.h>
-#include <osdebug.h>
#include <errno.h>
#include "fio.h"
+#include "osdebug.h"
int _close_r(struct _reent * reent, int fd) {
+// DBGOUT("_close_r(%p, %i)\r\n", reent, fd);
if (!fio_is_open(fd)) {
reent->_errno = EBADF;
return -1;
diff --git a/os/src/fclose.c b/os/src/fclose.c
index 76cf51d..4c4c3fc 100644
--- a/os/src/fclose.c
+++ b/os/src/fclose.c
@@ -1,7 +1,8 @@
#include <stdio.h>
#include <reent.h>
-#include <osdebug.h>
+#include "osdebug.h"
int fclose(FILE * fp) {
+// DBGOUT("fclose(%p)\r\n", fp);
return _fclose_r(_impure_ptr, fp);
}
diff --git a/os/src/fflush.c b/os/src/fflush.c
index fc1bf63..84e2c67 100644
--- a/os/src/fflush.c
+++ b/os/src/fflush.c
@@ -1,5 +1,7 @@
#include <stdio.h>
+#include "osdebug.h"
int fflush(FILE * file) {
+// DBGOUT("fflush(%p)\r\n", file);
return _fflush_r(_impure_ptr, file);
}
diff --git a/os/src/filesystem.c b/os/src/filesystem.c
index 64d7e0d..dda47bd 100644
--- a/os/src/filesystem.c
+++ b/os/src/filesystem.c
@@ -22,6 +22,7 @@ __attribute__((constructor)) void fs_init() {
int register_fs(const char * mountpoint, fs_open_t callback, void * opaque) {
int i;
+ DBGOUT("register_fs(\"%s\", %p, %p)\r\n", mountpoint, callback, opaque);
for (i = 0; i < MAX_FS; i++) {
if (!fss[i].cb) {
@@ -39,6 +40,7 @@ int fs_open(const char * path, int flags, int mode) {
const char * slash;
uint32_t hash;
int i;
+// DBGOUT("fs_open(\"%s\", %i, %i)\r\n", path, flags, mode);
while (path[0] == '/')
path++;
diff --git a/os/src/fio.c b/os/src/fio.c
index 9fe5038..432f7e2 100644
--- a/os/src/fio.c
+++ b/os/src/fio.c
@@ -75,6 +75,7 @@ int fio_is_open(int fd) {
int fio_open(fdread_t fdread, fdwrite_t fdwrite, fdseek_t fdseek, fdclose_t fdclose, void * opaque) {
int fd;
+// DBGOUT("fio_open(%p, %p, %p, %p, %p)\r\n", fdread, fdwrite, fdseek, fdclose, opaque);
xSemaphoreTake(fio_sem, portMAX_DELAY);
fd = fio_findfd();
@@ -92,6 +93,7 @@ int fio_open(fdread_t fdread, fdwrite_t fdwrite, fdseek_t fdseek, fdclose_t fdcl
ssize_t fio_read(int fd, void * buf, size_t count) {
ssize_t r = 0;
+// DBGOUT("fio_read(%i, %p, %i)\r\n", fd, buf, count);
if (fio_is_open_int(fd)) {
if (fio_fds[fd].fdread) {
r = fio_fds[fd].fdread(fio_fds[fd].opaque, buf, count);
@@ -106,6 +108,7 @@ ssize_t fio_read(int fd, void * buf, size_t count) {
ssize_t fio_write(int fd, const void * buf, size_t count) {
ssize_t r = 0;
+// DBGOUT("fio_write(%i, %p, %i)\r\n", fd, buf, count);
if (fio_is_open_int(fd)) {
if (fio_fds[fd].fdwrite) {
r = fio_fds[fd].fdwrite(fio_fds[fd].opaque, buf, count);
@@ -120,6 +123,7 @@ ssize_t fio_write(int fd, const void * buf, size_t count) {
off_t fio_seek(int fd, off_t offset, int whence) {
off_t r = 0;
+// DBGOUT("fio_seek(%i, %i, %i)\r\n", fd, offset, whence);
if (fio_is_open_int(fd)) {
if (fio_fds[fd].fdseek) {
r = fio_fds[fd].fdseek(fio_fds[fd].opaque, offset, whence);
@@ -134,6 +138,7 @@ off_t fio_seek(int fd, off_t offset, int whence) {
int fio_close(int fd) {
int r = 0;
+// DBGOUT("fio_close(%i)\r\n", fd);
if (fio_is_open_int(fd)) {
if (fio_fds[fd].fdclose)
r = fio_fds[fd].fdclose(fio_fds[fd].opaque);
@@ -157,6 +162,7 @@ void fio_set_opaque(int fd, void * opaque) {
static int devfs_open(void * opaque, const char * path, int flags, int mode) {
uint32_t h = hash_djb2((const uint8_t *) path, -1);
+// DBGOUT("devfs_open(%p, \"%s\", %i, %i)\r\n", opaque, path, flags, mode);
switch (h) {
case stdin_hash:
if (flags & (O_WRONLY | O_RDWR))
@@ -178,5 +184,6 @@ static int devfs_open(void * opaque, const char * path, int flags, int mode) {
}
void register_devfs() {
+ DBGOUT("Registering devfs.\r\n");
register_fs("dev", devfs_open, NULL);
}
diff --git a/os/src/fopen.c b/os/src/fopen.c
index e8b4246..22ac269 100644
--- a/os/src/fopen.c
+++ b/os/src/fopen.c
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <reent.h>
+#include "osdebug.h"
FILE * fopen(const char * path, const char * mode) {
+// DBGOUT("fopen(\"%s\", \"%s\")\r\n", path, mode);
return _fopen_r(_impure_ptr, path, mode);
}
diff --git a/os/src/fprintf.c b/os/src/fprintf.c
index 10d34e7..a56ed33 100644
--- a/os/src/fprintf.c
+++ b/os/src/fprintf.c
@@ -1,12 +1,12 @@
#include <reent.h>
#include <stdio.h>
#include <stdarg.h>
-#include <osdebug.h>
+#include "osdebug.h"
int fprintf(FILE * file, const char * fmt, ...) {
int r;
va_list ap;
- DBGOUT("fprintf(%p, %p, ...)\r\n", file, fmt);
+// DBGOUT("fprintf(%p, %p, ...)\r\n", file, fmt);
va_start(ap, fmt);
r = _vfprintf_r(_impure_ptr, file, fmt, ap);
va_end(ap);
diff --git a/os/src/fread.c b/os/src/fread.c
index b003d33..3f39c1e 100644
--- a/os/src/fread.c
+++ b/os/src/fread.c
@@ -1,5 +1,7 @@
#include <stdio.h>
+#include "osdebug.h"
size_t fread(void * ptr, size_t size, size_t nmemb, FILE * file) {
+// DBGOUT("fread(%p, %i, %i, %p)\r\n", ptr, size, nmemb, file);
return _fread_r(_impure_ptr, ptr, size, nmemb, file);
}
diff --git a/os/src/free.c b/os/src/free.c
index 0091d56..a011077 100644
--- a/os/src/free.c
+++ b/os/src/free.c
@@ -1,8 +1,8 @@
#include <reent.h>
#include <malloc.h>
-#include <osdebug.h>
+#include "osdebug.h"
void free(void * ptr) {
- DBGOUT("free(%p)\r\n", ptr);
+// DBGOUT("free(%p)\r\n", ptr);
_free_r(_impure_ptr, ptr);
}
diff --git a/os/src/fstat.c b/os/src/fstat.c
index b10194c..a7c251f 100644
--- a/os/src/fstat.c
+++ b/os/src/fstat.c
@@ -3,9 +3,11 @@
#include <string.h>
#include <errno.h>
#include "fio.h"
+#include "osdebug.h"
int _fstat_r(struct _reent * reent, int fd, struct stat * buf) {
off_t c;
+// DBGOUT("_fstat_r(%p, %i, %p)\r\n", reent, fd, buf);
memset(buf, 0, sizeof(struct stat));
if (!fio_is_open(fd)) {
diff --git a/os/src/fwrite.c b/os/src/fwrite.c
index c6890dc..6a10db0 100644
--- a/os/src/fwrite.c
+++ b/os/src/fwrite.c
@@ -1,5 +1,7 @@
#include <stdio.h>
+#include "osdebug.h"
size_t fwrite(const void * ptr, size_t size, size_t nmemb, FILE * file) {
+// DBGOUT("fwrite(%p, %i, %i, %p)\r\n", ptr, size, nmemb, file);
return _fwrite_r(_impure_ptr, ptr, size, nmemb, file);
}
diff --git a/os/src/isatty.c b/os/src/isatty.c
index 051284f..b37a9dc 100644
--- a/os/src/isatty.c
+++ b/os/src/isatty.c
@@ -2,8 +2,10 @@
#include <reent.h>
#include <errno.h>
#include "fio.h"
+#include "osdebug.h"
int _isatty_r(struct _reent * reent, int fd) {
+// DBGOUT("_isatty_r(%p, %i)\r\n", reent, fd);
if (!fio_is_open(fd)) {
reent->_errno = EBADF;
return 0;
diff --git a/os/src/lseek.c b/os/src/lseek.c
index 1cb0234..1e904a5 100644
--- a/os/src/lseek.c
+++ b/os/src/lseek.c
@@ -2,9 +2,11 @@
#include <osdebug.h>
#include <errno.h>
#include "fio.h"
+#include "osdebug.h"
_off_t _lseek_r(struct _reent * reent, int fd, _off_t seek, int wheel) {
off_t r;
+// DBGOUT("_lseek_r(%p, %i, %i, %i)\r\n", reent, fd, seek, wheel);
if ((wheel != SEEK_SET) && (wheel != SEEK_CUR) && (wheel != SEEK_END)) {
reent->_errno = EINVAL;
diff --git a/os/src/malloc.c b/os/src/malloc.c
index 281a75b..3d867d0 100644
--- a/os/src/malloc.c
+++ b/os/src/malloc.c
@@ -2,6 +2,7 @@
#include <malloc.h>
#include <FreeRTOS.h>
#include <semphr.h>
+#include "osdebug.h"
static xSemaphoreHandle malloc_sem = NULL;
@@ -11,6 +12,7 @@ __attribute__((constructor)) static void malloc_init() {
void * malloc(size_t size) {
void * ptr;
+// DBGOUT("malloc(%i)\r\n", size);
if (malloc_sem)
xSemaphoreTake(malloc_sem, portMAX_DELAY);
diff --git a/os/src/open.c b/os/src/open.c
index 7a2c147..5298fd8 100644
--- a/os/src/open.c
+++ b/os/src/open.c
@@ -3,8 +3,10 @@
#include <errno.h>
#include "fio.h"
#include "filesystem.h"
+#include "osdebug.h"
int _open_r(struct _reent * reent, const char * path, int flags, int mode) {
+// DBGOUT("_open_r(%p, \"%s\", flags, mode)\r\n", reent, path, flags, mode);
int r = fs_open(path, flags, mode);
if (r >= 0)
diff --git a/os/src/printf.c b/os/src/printf.c
index 83f7539..80b6b94 100644
--- a/os/src/printf.c
+++ b/os/src/printf.c
@@ -6,6 +6,7 @@
int printf(const char * fmt, ...) {
int r;
va_list ap;
+// DBGOUT("printf(\"%p\", ...)\r\n", fmt);
va_start(ap, fmt);
r = _vprintf_r(_impure_ptr, fmt, ap);
va_end(ap);
diff --git a/os/src/read.c b/os/src/read.c
index f848812..845092b 100644
--- a/os/src/read.c
+++ b/os/src/read.c
@@ -6,6 +6,8 @@
_ssize_t _read_r(struct _reent * reent, int fd, void * buf, size_t size) {
_ssize_t r;
+// DBGOUT("_read_r(%p, %i, %p, %i)\r\n", reent, fd, buf, size);
+
if (!fio_is_open(fd)) {
reent->_errno = EBADF;
return -1;
diff --git a/os/src/romfs.c b/os/src/romfs.c
index 270fb54..2d11d96 100644
--- a/os/src/romfs.c
+++ b/os/src/romfs.c
@@ -90,6 +90,6 @@ static int romfs_open(void * opaque, const char * path, int flags, int mode) {
}
void register_romfs(const char * mountpoint, const uint8_t * romfs) {
- DBGOUT("Registering romfs `%s' @ %p\r\n", mountpoint, romfs);
+// DBGOUT("Registering romfs `%s' @ %p\r\n", mountpoint, romfs);
register_fs(mountpoint, romfs_open, (void *) romfs);
}
diff --git a/os/src/sprintf.c b/os/src/sprintf.c
index 9027623..755d780 100644
--- a/os/src/sprintf.c
+++ b/os/src/sprintf.c
@@ -6,7 +6,7 @@
int sprintf(char * str, const char * fmt, ...) {
int r;
va_list ap;
- DBGOUT("sprintf(%p, %p, ...)\r\n", str, fmt);
+// DBGOUT("sprintf(%p, %p, ...)\r\n", str, fmt);
va_start(ap, fmt);
r = _vsprintf_r(_impure_ptr, str, fmt, ap);
va_end(ap);
diff --git a/os/src/write.c b/os/src/write.c
index 14e26d6..c54e304 100644
--- a/os/src/write.c
+++ b/os/src/write.c
@@ -6,6 +6,8 @@
_ssize_t _write_r(struct _reent * reent, int fd, const void * buf, size_t size) {
_ssize_t r;
+// DBGOUT("_write_r(%p, %i, %p, %i)\r\n", reent, fd, buf, size);
+
if (!fio_is_open(fd)) {
reent->_errno = EBADF;
return -1;