diff --git a/apps/Makefile.k64f b/apps/Makefile.k64f index 44c4ceb..85bb767 100755 --- a/apps/Makefile.k64f +++ b/apps/Makefile.k64f @@ -113,18 +113,18 @@ BUILD_DIR = $(abspath $(CURDIR)/build) CRT0_ASM_SRC = $(STARTUP_DIR)/app_k64f_crt0.s # Memory management code. Bring in the UMM library if stdlib isnt being used. -ifeq (-nostdlib,$(findstring -nostdlib,$(LDFLAGS))) - UMM_C_SRC = $(UMM_DIR)/umm_malloc.c -else - UMM_C_SRC = -endif +#ifeq (-nostdlib,$(findstring -nostdlib,$(LDFLAGS))) +# UMM_C_SRC = $(UMM_DIR)/umm_malloc.c +#else +# UMM_C_SRC = +#endif # Teensy3 modules which may be needed. TEENSY3_C_SRC = #$(wildcard $(COREPATH)/*.c) TEENSY3_CPP_SRC= #$(wildcard $(COREPATH)/*.cpp) # Common modules needed for this app. -COMMON_SRC = +COMMON_SRC = #../common/sysutils.c #../common/sbrk.c # Application being built. MAIN_PRJ_APP = $(APP_NAME) @@ -136,10 +136,11 @@ OBJS := $(foreach src,$(SOURCES), $(BUILD_DIR)/$(src)) # CPPFLAGS = compiler options for C and C++ #CPPFLAGS = -Wall -g -Os -mthumb -ffunction-sections -fdata-sections -nostdlib -MMD $(OPTIONS) -DTEENSYDUINO=144 -DF_CPU=$(TEENSY_CORE_SPEED) -CPPFLAGS += -Wall -g -mthumb -nostdlib -MMD $(OPTIONS) -DTEENSYDUINO=144 -DF_CPU=$(TEENSY_CORE_SPEED) -CPPFLAGS += -I. -I$(COMMON_DIR) -I$(FATFS_DIR) -I$(OSDIR) -I$(INCLUDE_DIR) -I$(APP_INCLUDE_DIR) -I$(COREPATH) -I$(COREMARK_DIR) -I$(DHRY_DIR) -I$(UMM_DIR) # -I$(LIB_INCLUDE_DIR) +CPPFLAGS += -Wall -g -mthumb -MMD $(OPTIONS) -DTEENSYDUINO=144 -DF_CPU=$(TEENSY_CORE_SPEED) +CPPFLAGS += -I. -I$(COMMON_DIR) -I$(FATFS_DIR) -I$(OSDIR) -I$(INCLUDE_DIR) -I$(APP_INCLUDE_DIR) -I$(COREPATH) +CPPFLAGS += -I$(COREMARK_DIR) -I$(DHRY_DIR) -I$(UMM_DIR) #-I$(LIB_INCLUDE_DIR) CPPFLAGS += -D__K64F__ -D__APP__ -DDEBUG -D__SD_CARD__ -DOS_BASEADDR=$(OS_BASEADDR) -DOS_APPADDR=$(OS_APPADDR) -CPPFLAGS += -mlong-calls # WARNING! This is needed as a bug in the compiler creates veneer wrappers which switch to ARM mode and not Thumb. +CPPFLAGS += -fno-builtin -mlong-calls # WARNING! This is needed as a bug in the compiler creates veneer wrappers which switch to ARM mode and not Thumb. ifeq (-nostdlib,$(findstring -nostdlib,$(LDFLAGS))) CPPFLAGS += -DUMM_BEST_FIT -DUMM_INFO -DUMM_DBG_LOG_LEVEL=0 endif @@ -218,6 +219,18 @@ else $(error Invalid setting for TEENSY) endif +# Application specific library handling. +ifeq ($(APP_NAME),mbasic) + LIBS += -lnosys +else ifeq ($(APP_NAME),ed) + LIBS += -lc -lnosys +else ifeq ($(APP_NAME),kilo) + LIBS += -lc -lnosys +else + LIBS += -lc_s -lnosys +endif + + # set arduino define if given ifdef ARDUINO CPPFLAGS += -DARDUINO=$(ARDUINO) diff --git a/apps/Makefile.zpu b/apps/Makefile.zpu index 3996403..88a5f93 100755 --- a/apps/Makefile.zpu +++ b/apps/Makefile.zpu @@ -103,11 +103,11 @@ LINKMAPAPP = $(STARTUP_DIR)/app_zpu_${OS_BASEADDR}_${OS_APPADDR}.ld CRT0_ASM_SRC = $(STARTUP_DIR)/appcrt0.s # Memory management code. Bring in the UMM library if stdlib isnt being used. -ifeq (-nostdlib,$(findstring -nostdlib,$(LDFLAGS))) - UMM_C_SRC = $(UMM_DIR)/umm_malloc.c -else - UMM_C_SRC = -endif +#ifeq (-nostdlib,$(findstring -nostdlib,$(LDFLAGS))) +# UMM_C_SRC = $(UMM_DIR)/umm_malloc.c +#else +# UMM_C_SRC = +#endif # Common modules needed for this app. #COMMON_SRC = $(COMMON_DIR)/syscalls.c $(COMMON_DIR)/malloc.c $(COMMON_DIR)/tools.c #$(COMMON_DIR)/utils.c diff --git a/apps/bdump/bdump.c b/apps/bdump/bdump.c index bf1d3c3..912d1c1 100755 --- a/apps/bdump/bdump.c +++ b/apps/bdump/bdump.c @@ -39,29 +39,21 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +64,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "bdump.h" // Utility functions. @@ -98,7 +91,7 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &offset)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { memoryDump((uint32_t)&G->Buff[offset], 0x200, 16, offset, 32); diff --git a/apps/bdump/bdump.h b/apps/bdump/bdump.h index b5f007e..df37084 100755 --- a/apps/bdump/bdump.h +++ b/apps/bdump/bdump.h @@ -46,76 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. #define BUILTIN_BUFFER_DUMP 1 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/bedit/bedit.c b/apps/bedit/bedit.c index acf7154..b86d5b9 100755 --- a/apps/bedit/bedit.c +++ b/apps/bedit/bedit.c @@ -39,29 +39,21 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +64,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "bedit.h" // Utility functions. @@ -100,7 +93,7 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &addr)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { if (xatoi(&ptr, &data)) @@ -112,15 +105,15 @@ uint32_t app(uint32_t param1, uint32_t param2) { for (;;) { - xprintf("%04X %02X-", (WORD)addr, G->Buff[addr]); - xgets(line, sizeof line); + printf("%04X %02X-", (WORD)addr, G->Buff[addr]); + fgets(line, sizeof line, stdin); ptr = line; if (*ptr == '.') break; if (*ptr < ' ') { addr++; continue; } if (xatoi(&ptr, &data)) { G->Buff[addr++] = (BYTE)data; } else { - xputs("???\n"); + puts("???\n"); } } } diff --git a/apps/bedit/bedit.h b/apps/bedit/bedit.h index b3b2b3e..cffff77 100755 --- a/apps/bedit/bedit.h +++ b/apps/bedit/bedit.h @@ -46,76 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 #define BUILTIN_BUFFER_EDIT 1 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/bfill/Makefile b/apps/bfill/Makefile index 6735c5d..8fa937d 100755 --- a/apps/bfill/Makefile +++ b/apps/bfill/Makefile @@ -38,6 +38,13 @@ APP_NAME = bfill APP_DIR = .. BASEDIR = ../../.. + +ifeq ($(__K64F__),1) +LIBS = -lumansi-k64f +else +LIBS = +endif + ifeq ($(__K64F__),1) include $(APP_DIR)/Makefile.k64f else diff --git a/apps/bfill/bfill.c b/apps/bfill/bfill.c index e7d81ca..8b79b77 100755 --- a/apps/bfill/bfill.c +++ b/apps/bfill/bfill.c @@ -39,29 +39,21 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +64,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "bfill.h" // Utility functions. @@ -98,7 +91,7 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &value)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { memset(G->Buff, (BYTE)value, sizeof G->Buff); diff --git a/apps/bfill/bfill.h b/apps/bfill/bfill.h index a79c95b..5f3e45d 100755 --- a/apps/bfill/bfill.h +++ b/apps/bfill/bfill.h @@ -46,76 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 #define BUILTIN_BUFFER_FILL 1 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/blen/blen.c b/apps/blen/blen.c index ab6cdb2..ad0c02c 100755 --- a/apps/blen/blen.c +++ b/apps/blen/blen.c @@ -39,29 +39,21 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +64,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "blen.h" // Utility functions. @@ -99,11 +92,11 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &len)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { fr = fileSetBlockLen(len); - if(fr) { printFSCode(fr); } else { xprintf("R/W length = %u\n", len); retCode = 0; } + if(fr) { printFSCode(fr); } else { printf("R/W length = %lu\n", len); retCode = 0; } } return(retCode); diff --git a/apps/blen/blen.h b/apps/blen/blen.h index 6ab6e10..0ae6691 100755 --- a/apps/blen/blen.h +++ b/apps/blen/blen.h @@ -46,77 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 #define BUILTIN_BUFFER_LEN 1 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/bread/bread.c b/apps/bread/bread.c index 39d048d..9b2548a 100755 --- a/apps/bread/bread.c +++ b/apps/bread/bread.c @@ -39,29 +39,22 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ #include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +65,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "bread.h" // Utility functions. @@ -100,14 +94,14 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &drive)) { - xprintf("Illegal <#pd> value.\n"); + printf("Illegal <#pd> value.\n"); } else if(!xatoi(&ptr, §or)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { if(!xatoi(&ptr, &count)) count = 1; - xprintf("rc=%u\n", disk_read((BYTE)drive, G->Buff, sector, count)); + printf("rc=%u\n", disk_read((BYTE)drive, G->Buff, sector, count)); retCode = 0; } diff --git a/apps/bread/bread.h b/apps/bread/bread.h index 50fe624..bd2bcd4 100755 --- a/apps/bread/bread.h +++ b/apps/bread/bread.h @@ -46,77 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 #define BUILTIN_BUFFER_READ 1 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/bwrite/bwrite.c b/apps/bwrite/bwrite.c index 2f85b1b..3281b75 100755 --- a/apps/bwrite/bwrite.c +++ b/apps/bwrite/bwrite.c @@ -39,29 +39,22 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ #include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +65,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "bwrite.h" // Utility functions. @@ -100,14 +94,14 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &drive)) { - xprintf("Illegal <#pd> value.\n"); + printf("Illegal <#pd> value.\n"); } else if(!xatoi(&ptr, §or)) { - xprintf("Illegal value.\n"); + printf("Illegal value.\n"); } else { if(!xatoi(&ptr, &count)) count = 1; - xprintf("rc=%u\n", disk_write((BYTE)drive, G->Buff, sector, count)); + printf("rc=%u\n", disk_write((BYTE)drive, G->Buff, sector, count)); retCode = 0; } diff --git a/apps/bwrite/bwrite.h b/apps/bwrite/bwrite.h index 2869cfb..452ad72 100755 --- a/apps/bwrite/bwrite.h +++ b/apps/bwrite/bwrite.h @@ -46,77 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 // Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 #define BUILTIN_BUFFER_WRITE 1 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/common/sysutils.c b/apps/common/sysutils.c index 3e7ff05..515f7fc 100644 --- a/apps/common/sysutils.c +++ b/apps/common/sysutils.c @@ -236,7 +236,8 @@ char *strstr (const char *s1, const char *s2) __attribute__((weak)) int _read(int file, char *ptr, int len) { - return 0; + strcpy(ptr, "HEREHERE\n"); + return 9; } __attribute__((weak)) diff --git a/apps/coremark/Makefile b/apps/coremark/Makefile index 1ab1347..7684718 100755 --- a/apps/coremark/Makefile +++ b/apps/coremark/Makefile @@ -38,18 +38,39 @@ APP_NAME = coremark APP_DIR = .. BASEDIR = ../../.. -SWDIR = $(BASEDIR)/software +COMMON_DIR = $(CURDIR)../../common +COREMARK_DIR = $(COMMON_DIR)/CoreMark -# Coremark specific settings. -COREMARK_DIR = $(SWDIR)/common/CoreMark -COREMARK_SRC = $(COREMARK_DIR)/core_list_join.c $(COREMARK_DIR)/core_main_embedded.c $(COREMARK_DIR)/core_matrix.c $(COREMARK_DIR)/core_state.c $(COREMARK_DIR)/core_util.c $(COREMARK_DIR)/ee_printf.c $(COREMARK_DIR)/core_portme.c -COREMARK_OBJ = $(patsubst $(COREMARK_DIR)/%.c,$(BUILD_DIR)/%.o,$(COREMARK_SRC)) +# Override values given by parent make for this application as its memory usage differs from the standard app. +ifeq ($(__K64F__),1) + #override HEAPADDR = 0x2002f000 + #override HEAPSIZE = 0x00000000 + #override STACKADDR = 0x2002f000 + #override STACKSIZE = 0x00000000 -MAIN_OBJ = $(COREMARK_OBJ) + # Coremark specific settings. + COREMARK_SRC = $(COREMARK_DIR)/core_list_join.c $(COREMARK_DIR)/core_main_embedded.c $(COREMARK_DIR)/core_matrix.c $(COREMARK_DIR)/core_state.c $(COREMARK_DIR)/core_util.c $(COREMARK_DIR)/ee_printf.c $(COREMARK_DIR)/core_portme.c + COREMARK_OBJ = $(patsubst $(COREMARK_DIR)/%.c,$(BUILD_DIR)/%.o,$(COREMARK_SRC)) + MAIN_OBJ = $(COREMARK_OBJ) -CFLAGS += -I$(COREMARK_DIR) -# Enable CoreMark Test -OFLAGS += -DCOREMARK_TEST + CFLAGS += -I$(COREMARK_DIR) + # Enable CoreMark Test + OFLAGS += -DCOREMARK_TEST +else + #override HEAPADDR = 0x0000D000 + #override HEAPSIZE = 0x00002000 + #override STACKADDR = 0x0000F000 + #override STACKSIZE = 0x00000000 + + # Coremark specific settings. + COREMARK_SRC = $(COREMARK_DIR)/core_list_join.c $(COREMARK_DIR)/core_main_embedded.c $(COREMARK_DIR)/core_matrix.c $(COREMARK_DIR)/core_state.c $(COREMARK_DIR)/core_util.c $(COREMARK_DIR)/ee_printf.c $(COREMARK_DIR)/core_portme.c + COREMARK_OBJ = $(patsubst $(COREMARK_DIR)/%.c,$(BUILD_DIR)/%.o,$(COREMARK_SRC)) + MAIN_OBJ = $(COREMARK_OBJ) + + CFLAGS += -I$(COREMARK_DIR) + # Enable CoreMark Test + OFLAGS += -DCOREMARK_TEST +endif ifeq ($(__K64F__),1) include $(APP_DIR)/Makefile.k64f diff --git a/apps/coremark/coremark.c b/apps/coremark/coremark.c index 448d2e4..fdc01f8 100755 --- a/apps/coremark/coremark.c +++ b/apps/coremark/coremark.c @@ -38,30 +38,22 @@ #endif #if defined(__K64F__) + #include #include - #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -74,6 +66,7 @@ // #include "coremk.h" #include "coremark.h" +#include "app.h" // Utility functions. #include "tools.h" @@ -97,7 +90,7 @@ uint32_t app(uint32_t param1, uint32_t param2) uint32_t retCode = 0xffffffff; // Run a CoreMark test to evaluate CPU speed. - xputs("Running CoreMark test, please wait ...\n\n"); + puts("Running CoreMark test, please wait ...\n\n"); CoreMarkTest(); retCode = 0; diff --git a/apps/coremark/coremk.h b/apps/coremark/coremk.h index bdfbc5c..533a3ff 100755 --- a/apps/coremark/coremk.h +++ b/apps/coremark/coremk.h @@ -45,79 +45,7 @@ extern "C" { // Application execution constants. // - -// Components to be embedded in the program. -// -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 -// Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 #define BUILTIN_TST_COREMARK 1 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/ddump/ddump.c b/apps/ddump/ddump.c index ff71aa9..4ad8256 100755 --- a/apps/ddump/ddump.c +++ b/apps/ddump/ddump.c @@ -39,29 +39,22 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ #include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +65,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "ddump.h" // Utility functions. @@ -100,7 +94,7 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!xatoi(&ptr, &drive)) { - xprintf("Illegal <#pd> value.\n"); + printf("Illegal <#pd> value.\n"); } else { if (!xatoi(&ptr, §or)) sector = G->Sector; @@ -108,7 +102,7 @@ uint32_t app(uint32_t param1, uint32_t param2) if(!fr) { G->Sector = sector + 1; - xprintf("Sector:%lu\n", sector); + printf("Sector:%lu\n", sector); memoryDump((uint32_t)G->Buff, 0x200, 16, 0, 32); } } diff --git a/apps/ddump/ddump.h b/apps/ddump/ddump.h index 3144e88..6b90d8f 100755 --- a/apps/ddump/ddump.h +++ b/apps/ddump/ddump.h @@ -46,76 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 // Disk low level components to be embedded in the program. #define BUILTIN_DISK_DUMP 1 -#define BUILTIN_DISK_STATUS 0 -// Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/dhry/Makefile b/apps/dhry/Makefile index 044afac..b6d83c5 100755 --- a/apps/dhry/Makefile +++ b/apps/dhry/Makefile @@ -38,18 +38,55 @@ APP_NAME = dhry APP_DIR = .. BASEDIR = ../../.. -SWDIR = $(BASEDIR)/software +COMMON_DIR = $(CURDIR)/../../common +DHRY_DIR = $(COMMON_DIR)/Dhrystone + +# Override values given by parent make for this application as its memory usage differs from the standard app. +ifeq ($(__K64F__),1) + override HEAPADDR = 0x2002f000 + override HEAPSIZE = 0x00000000 + override STACKADDR = 0x2002f000 + override STACKSIZE = 0x00000000 + + # Modules making up Kilo. + APP_C_SRC = #$(APP_COMMON_DIR)/sysutils.c $(APP_COMMON_DIR)/ctypelocal.c + CFLAGS += -I$(DHRY_DIR) + # Enable Dhrystone Test + OFLAGS += -DDHRYSTONE_TEST + CPPFLAGS = -D__HEAPADDR__=$(HEAPADDR) -D__HEAPSIZE__=$(HEAPSIZE) + LDFLAGS = -nostdlib + LIBS = -lumansi-k64f -lumstdio-k64f + DHRY_SRC = $(DHRY_DIR)/dhry_1.c $(DHRY_DIR)/dhry_2.c + DHRY_OBJ = $(patsubst $(DHRY_DIR)/%.c,$(BUILD_DIR)/%.o,$(DHRY_SRC)) + MAIN_OBJ = $(DHRY_OBJ) +else + override HEAPADDR = 0x0000dc00 + override HEAPSIZE = 0x00001000 + override STACKADDR = 0x0000ec00 + override STACKSIZE = 0x00000000 + + # Modules making up Kilo. + # Modules making up Kilo. + APP_C_SRC = #$(APP_COMMON_DIR)/sysutils.c $(APP_COMMON_DIR)/ctypelocal.c + CFLAGS += -I$(DHRY_DIR) + # Enable Dhrystone Test + OFLAGS += -DDHRYSTONE_TEST + CPPFLAGS = -D__HEAPADDR__=$(HEAPADDR) -D__HEAPSIZE__=$(HEAPSIZE) + LDFLAGS = -nostdlib + LIBS = -lumansi-zpu -limath-zpu + DHRY_SRC = $(DHRY_DIR)/dhry_1.c $(DHRY_DIR)/dhry_2.c + DHRY_OBJ = $(patsubst $(DHRY_DIR)/%.c,$(BUILD_DIR)/%.o,$(DHRY_SRC)) + MAIN_OBJ = $(DHRY_OBJ) +endif + +# Filter out the standard HEAP address and size, replacing with the ones required for this application. +# Useful for sub-makes +FILTER1 = $(filter-out $(filter HEAPADDR=%,$(MAKEFLAGS)), $(MAKEFLAGS)) +FILTER2 = $(filter-out $(filter HEAPSIZE=%,$(FILTER1)), $(FILTER1)) +NEWMAKEFLAGS = $(FILTER2) HEAPADDR=$(HEADADDR) HEAPSIZE=$(HEAPSIZE) -# Dhrystone specific settings. -DHRY_DIR = $(SWDIR)/common/Dhrystone -DHRY_SRC = $(DHRY_DIR)/dhry_1.c $(DHRY_DIR)/dhry_2.c -DHRY_OBJ = $(patsubst $(DHRY_DIR)/%.c,$(BUILD_DIR)/%.o,$(DHRY_SRC)) -MAIN_OBJ = $(DHRY_OBJ) -CFLAGS += -I$(DHRY_DIR) -# Enable Dhrystone Test -OFLAGS += -DDHRYSTONE_TEST ifeq ($(__K64F__),1) include $(APP_DIR)/Makefile.k64f diff --git a/apps/dhry/dhry.c b/apps/dhry/dhry.c index 21d4c56..380b409 100755 --- a/apps/dhry/dhry.c +++ b/apps/dhry/dhry.c @@ -39,29 +39,21 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +64,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "dhrystone.h" // Utility functions. @@ -97,7 +90,7 @@ uint32_t app(uint32_t param1, uint32_t param2) //FRESULT fr = 1; // Run a Dhrystone test to evaluate CPU speed. - xputs("Running Dhrystone test, please wait ...\n"); + puts("Running Dhrystone test, please wait ...\n"); main_dhry(); retCode = 0; diff --git a/apps/dhry/dhrystone.h b/apps/dhry/dhrystone.h index 160b6a8..f8a0add 100755 --- a/apps/dhry/dhrystone.h +++ b/apps/dhry/dhrystone.h @@ -114,6 +114,7 @@ uint32_t app(uint32_t, uint32_t); // Global scope variables within the ZPUTA memory space. GLOBALS *G; SOC_CONFIG *cfgSoC; +struct __file *__iob[3]; // Global scope variables in the app memory space. volatile UINT Timer; /* Performance timer (100Hz increment) */ diff --git a/apps/dstat/dstat.c b/apps/dstat/dstat.c index fe7d060..fb2c9ac 100755 --- a/apps/dstat/dstat.c +++ b/apps/dstat/dstat.c @@ -39,29 +39,22 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ #include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -72,6 +65,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "dstat.h" // Utility functions. @@ -102,44 +96,44 @@ uint32_t app(uint32_t param1, uint32_t param2) { if (disk_ioctl((BYTE)drive, GET_SECTOR_COUNT, §or) == RES_OK) { - xprintf("Drive size: %lu sectors\n", sector); + printf("Drive size: %lu sectors\n", sector); } if (disk_ioctl((BYTE)drive, GET_BLOCK_SIZE, §or) == RES_OK) { - xprintf("Erase block: %lu sectors\n", sector); + printf("Erase block: %lu sectors\n", sector); } if (disk_ioctl((BYTE)drive, MMC_GET_TYPE, &cardType) == RES_OK) { - xprintf("Card type: %u\n", cardType); + printf("Card type: %u\n", cardType); } if (disk_ioctl((BYTE)drive, MMC_GET_CSD, G->Buff) == RES_OK) { - xputs("CSD:\n"); memoryDump((uint32_t)G->Buff, 16, 16, 0, 32); + puts("CSD:\n"); memoryDump((uint32_t)G->Buff, 16, 16, 0, 32); } if (disk_ioctl((BYTE)drive, MMC_GET_CID, G->Buff) == RES_OK) { - xputs("CID:\n"); memoryDump((uint32_t)G->Buff, 16, 16, 0, 32); + puts("CID:\n"); memoryDump((uint32_t)G->Buff, 16, 16, 0, 32); } if (disk_ioctl((BYTE)drive, MMC_GET_OCR, G->Buff) == RES_OK) { - xputs("OCR:\n"); memoryDump((uint32_t)G->Buff, 4, 16, 0, 32); + puts("OCR:\n"); memoryDump((uint32_t)G->Buff, 4, 16, 0, 32); } if (disk_ioctl((BYTE)drive, MMC_GET_SDSTAT, G->Buff) == RES_OK) { - xputs("SD Status:\n"); + puts("SD Status:\n"); memoryDump((uint32_t)G->Buff, 64, 16, 0, 32); } if (disk_ioctl((BYTE)drive, ATA_GET_MODEL, line) == RES_OK) { - line[40] = '\0'; xprintf("Model: %s\n", line); + line[40] = '\0'; printf("Model: %s\n", line); } if (disk_ioctl((BYTE)drive, ATA_GET_SN, line) == RES_OK) { - line[20] = '\0'; xprintf("S/N: %s\n", line); + line[20] = '\0'; printf("S/N: %s\n", line); } } else { - xprintf("Illegal <#pd> value.\n"); + printf("Illegal <#pd> value.\n"); } return(0); diff --git a/apps/dstat/dstat.h b/apps/dstat/dstat.h index df7df08..b36967b 100755 --- a/apps/dstat/dstat.h +++ b/apps/dstat/dstat.h @@ -46,76 +46,8 @@ // Components to be embedded in the program. // -#define BUILTIN_DEFAULT 1 // Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 #define BUILTIN_DISK_STATUS 1 -// Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 0 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ #ifdef __cplusplus } diff --git a/apps/ed/Makefile b/apps/ed/Makefile index 318b5b0..13decab 100755 --- a/apps/ed/Makefile +++ b/apps/ed/Makefile @@ -42,18 +42,23 @@ BASEDIR = ../../.. # Override values given by parent make for this application as its memory usage differs from the standard app. ifeq ($(__K64F__),1) - override HEAPADDR = 0x1FFF5000 - override HEAPSIZE = 0x00033000 - override STACKADDR = 0x20028000 - override STACKSIZE = 0x00000000 + #override HEAPADDR = 0x2002f000 + #override HEAPSIZE = 0x00000000 + #override STACKADDR = 0x2002f000 + #override STACKSIZE = 0x00000000 # Modules making up Kilo. APP_C_SRC = #$(APP_COMMON_DIR)/sysutils.c $(APP_COMMON_DIR)/ctypelocal.c CFLAGS = - CPPFLAGS = -D__HEAPADDR__=$(HEAPADDR) -D__HEAPSIZE__=$(HEAPSIZE) - LDFLAGS = -nostdlib - LIBS = -lumansi-k64f -lumstdio-k64f + CPPFLAGS = #-D__HEAPADDR__=$(HEAPADDR) -D__HEAPSIZE__=$(HEAPSIZE) + LDFLAGS = + LIBS = else + override HEAPADDR = 0x0000ED00 + override HEAPSIZE = 0x00000300 + override STACKADDR = 0x0000F000 + override STACKSIZE = 0x00000000 + # Modules making up Kilo. APP_C_SRC = #$(APP_COMMON_DIR)/sysutils.c $(APP_COMMON_DIR)/ctypelocal.c CFLAGS = diff --git a/apps/ed/ed.c b/apps/ed/ed.c index 4216c10..f76e9f6 100644 --- a/apps/ed/ed.c +++ b/apps/ed/ed.c @@ -48,30 +48,26 @@ #if defined(__K64F__) #include - #include + #include + #include #include #include #include #include #include "k64f_soc.h" - #include "../../libraries/include/ansi.h" - #include "../../libraries/include/ctype.h" + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" #include #include + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" -#include #include "utils.h" // #if defined __ZPUTA__ @@ -82,6 +78,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "ed.h" // Utility functions. @@ -296,15 +293,15 @@ int getCursorPosition(uint32_t *rows, uint32_t *cols) // Save cursor position. // - xprintf("%c%c", 0x1b, '7'); + printf("%c%c", 0x1b, '7'); // Cursor to maximum X/Y location, report cursor location // - xputs("\x1b[0;0H"); + fputs("\x1b[0;0H", stdout); syswait(10); - xputs("\x1b[999;999H"); + fputs("\x1b[999;999H", stdout); syswait(10); - xputs("\x1b[6n"); + fputs("\x1b[6n", stdout); // Read the response: ESC [ rows ; cols R // @@ -329,7 +326,7 @@ int getCursorPosition(uint32_t *rows, uint32_t *cols) // Restore cursor. // - xprintf("%c%c", 0x1b, '8'); + printf("%c%c", 0x1b, '8'); return 0; } @@ -363,8 +360,8 @@ int editorInsertRow(int at, char *s, size_t len) if (at > E.numrows) return 0; - E.row = realloc(E.row,sizeof(erow)*(E.numrows+1)); - if(E.row == NULL) { xprintf("editorInsertRow: Memory exhausted\n"); return 1; } + E.row = sys_realloc(E.row,sizeof(erow)*(E.numrows+1)); + if(E.row == NULL) { printf("editorInsertRow: Memory exhausted\n"); return 1; } if (at != E.numrows) { @@ -373,8 +370,8 @@ int editorInsertRow(int at, char *s, size_t len) } E.row[at].size = len; - E.row[at].chars = malloc(len+1); - if(E.row[at].chars == NULL) { xprintf("editorInsertRow: Memory exhausted\n"); return 1; } + E.row[at].chars = sys_malloc(len+1); + if(E.row[at].chars == NULL) { printf("editorInsertRow: Memory exhausted\n"); return 1; } memcpy(E.row[at].chars,s,len+1); E.row[at].idx = at; E.numrows++; @@ -387,7 +384,7 @@ void editorFreeRow(erow *row) { if(row->chars != NULL) { - free(row->chars); + sys_free(row->chars); row->chars = NULL; } } @@ -398,19 +395,21 @@ void editorCleanup(void) { int idx; - // Go through and free all row memory. - // - for(idx=0; idx < E.numrows; idx++) - { - if(E.row[idx].chars != NULL) - { - free(E.row[idx].chars); - } - } - // Free the editor config structure. if(E.row) - free(E.row); + { + // Go through and free all row memory. + // + for(idx=0; idx < E.numrows; idx++) + { + if(E.row[idx].chars != NULL) + { + sys_free(E.row[idx].chars); + } + } + + sys_free(E.row); + } // Reset necessary variables. E.cx = 0; @@ -452,8 +451,8 @@ int editorRowInsertChar(erow *row, int at, int c) /* In the next line +2 means: new char and null term. */ - row->chars = realloc(row->chars,row->size+padlen+2); - if(row->chars == NULL) { xprintf("editorRowInsertChar: Memory exhausted\n"); return 1; } + row->chars = sys_realloc(row->chars,row->size+padlen+2); + if(row->chars == NULL) { printf("editorRowInsertChar: Memory exhausted\n"); return 1; } memset(row->chars+row->size,' ',padlen); row->chars[row->size+padlen+1] = '\0'; row->size += padlen+1; @@ -461,8 +460,8 @@ int editorRowInsertChar(erow *row, int at, int c) /* If we are in the middle of the string just make space for 1 new * char plus the (already existing) null term. */ - row->chars = realloc(row->chars,row->size+2); - if(row->chars == NULL) { xprintf("editorRowInsertChar: Memory exhausted\n"); return 1; } + row->chars = sys_realloc(row->chars,row->size+2); + if(row->chars == NULL) { printf("editorRowInsertChar: Memory exhausted\n"); return 1; } memmove(row->chars+at+1,row->chars+at,row->size-at+1); row->size++; } @@ -475,8 +474,8 @@ int editorRowInsertChar(erow *row, int at, int c) /* Append the string 's' at the end of a row */ int editorRowAppendString(erow *row, char *s, size_t len) { - row->chars = realloc(row->chars,row->size+len+1); - if(row->chars == NULL) { xprintf("editorRowAppendString: Memory exhausted\n"); return 1; } + row->chars = sys_realloc(row->chars,row->size+len+1); + if(row->chars == NULL) { printf("editorRowAppendString: Memory exhausted\n"); return 1; } memcpy(row->chars+row->size,s,len); row->size += len; @@ -619,11 +618,10 @@ int editorOpen(char *filename) E.dirty = 0; E.filename = filename; - fr = f_open(&fp, filename, FA_OPEN_ALWAYS | FA_READ); if(fr) { - xprintf("Failed to open file:%s\n", filename); + printf("Failed to open file:%s\n", filename); return 2; } @@ -637,7 +635,7 @@ int editorOpen(char *filename) fr = f_lseek(&fp, 0); if(fr) { - xprintf("Failed to rewind file:%s\n", filename); + printf("Failed to rewind file:%s\n", filename); return 3; } @@ -647,8 +645,9 @@ int editorOpen(char *filename) { // Allocate memory for the row array. // - E.row = realloc(E.row,sizeof(erow)*(E.numrows)); - if(E.row == NULL) { xprintf("editorOpen: Memory exhausted\n"); return 1; } + E.row = sys_malloc(sizeof(erow)*(E.numrows)); + if(E.row == NULL) { printf("editorOpen: Memory exhausted\n"); return 1; } + memset(E.row, '\0', sizeof(erow)*(E.numrows)); // Now go through the file again and populate each row with the data. // @@ -660,14 +659,15 @@ int editorOpen(char *filename) buf[--linelen] = '\0'; E.row[rowNo].size = linelen; - E.row[rowNo].chars = malloc(linelen+1); - if(E.row[rowNo].chars == NULL) { xprintf("editorOpen: Memory exhausted\n"); return 1; } + E.row[rowNo].chars = sys_malloc(linelen+1); + if(E.row[rowNo].chars == NULL) { printf("editorOpen: Memory exhausted\n"); return 1; } memcpy(E.row[rowNo].chars, buf, linelen+1); E.row[rowNo].idx = rowNo; rowNo++; } } f_close(&fp); +printf("EXIT\n"); return 0; } @@ -686,7 +686,7 @@ int editorSave(char *newFileName) fr = f_open(&fp, (newFileName == NULL ? E.filename : newFileName), FA_OPEN_ALWAYS | FA_WRITE | FA_READ); if(fr) { - xsprintf(E.statusmsg, "Failed to open file:%s\n", (newFileName == NULL ? E.filename : newFileName)); + sprintf(E.statusmsg, "Failed to open file:%s\n", (newFileName == NULL ? E.filename : newFileName)); E.statusmsg_time = sysmillis(); return 1; } @@ -710,13 +710,13 @@ int editorSave(char *newFileName) f_close(&fp); E.dirty = 0; - xsprintf(E.statusmsg, "%d bytes written on disk", totlen); + sprintf(E.statusmsg, "%d bytes written on disk", totlen); E.statusmsg_time = sysmillis(); return 0; writeerr: f_close(&fp); - xsprintf(E.statusmsg, "Can't save! I/O error"); + sprintf(E.statusmsg, "Can't save! I/O error"); E.statusmsg_time = sysmillis(); return 1; } @@ -740,10 +740,10 @@ void abAppend(const char *s, int len, int flush) // First call, allocate memory for the buffer. if(ab == NULL) { - ab = malloc(sizeof(struct abuf)); - if(ab == NULL) { xprintf("abAppend: Memory exhausted\n"); return; } - ab->b = malloc(MAX_APPEND_BUFSIZE); - if(ab->b == NULL) { xprintf("abAppend: Memory exhausted\n"); return; } + ab = sys_malloc(sizeof(struct abuf)); + if(ab == NULL) { printf("abAppend: Memory exhausted\n"); return; } + ab->b = sys_malloc(MAX_APPEND_BUFSIZE); + if(ab->b == NULL) { printf("abAppend: Memory exhausted\n"); return; } ab->len = 0; } @@ -752,14 +752,14 @@ void abAppend(const char *s, int len, int flush) { const char *ptr = ab->b; for(ptr=ab->b; ptr < ab->b+ab->len; ptr++) - xputc(*ptr); + fputc(*ptr, stdout); // If we are flushing then write out the additional data passed in to the method. // if(flush) { for(ptr=s; ptr < s+len; ptr++) - xputc(*ptr); + fputc(*ptr, stdout); } ab->len = 0; @@ -775,8 +775,8 @@ void abAppend(const char *s, int len, int flush) { // On flush we free up the memory, extra cycles in alloc and free but keeps the heap balanced and no memory leaks when we exit. // - free(ab->b); - free(ab); + sys_free(ab->b); + sys_free(ab); ab = NULL; } } @@ -801,7 +801,7 @@ int editorRefreshScreen(void) if (E.numrows == 0 && y == E.screenrows/3) { char welcome[80]; - xsprintf(welcome, "Ed(itor) -- version %s\x1b[0K\r\n", ED_VERSION); + sprintf(welcome, "Ed(itor) -- version %s\x1b[0K\r\n", ED_VERSION); int welcomelen = strlen(welcome); int padding = (E.screencols-welcomelen)/2; if (padding) @@ -858,9 +858,9 @@ int editorRefreshScreen(void) abAppend("\x1b[0K",4, 0); abAppend("\x1b[7m",4, 0); char status[80], rstatus[80]; - xsprintf(status, "%-20s - %d lines %s", E.filename, E.numrows, E.dirty > 0 ? "(modified)" : ""); + sprintf(status, "%-20s - %d lines %s", E.filename, E.numrows, E.dirty > 0 ? "(modified)" : ""); int len = strlen(status); - xsprintf(rstatus, "%d/%d",E.rowoff+E.cy+1,E.numrows); + sprintf(rstatus, "%d/%d",E.rowoff+E.cy+1,E.numrows); int rlen = strlen(rstatus); if (len > E.screencols) len = E.screencols; abAppend(status,len, 0); @@ -897,7 +897,7 @@ int editorRefreshScreen(void) cx++; } } - xsprintf(buf,"\x1b[%d;%dH",E.cy+1,cx); + sprintf(buf,"\x1b[%d;%dH",E.cy+1,cx); abAppend(buf,strlen(buf), 0); /* Show cursor and Flush to complete. @@ -921,7 +921,7 @@ void editorFind(void) { while(1) { - xsprintf(E.statusmsg, "Search: %s (Use ESC/Arrows/Enter)", query); + sprintf(E.statusmsg, "Search: %s (Use ESC/Arrows/Enter)", query); E.statusmsg_time = sysmillis(); editorRefreshScreen(); @@ -934,7 +934,7 @@ void editorFind(void) { E.cx = saved_cx; E.cy = saved_cy; E.coloff = saved_coloff; E.rowoff = saved_rowoff; } - xsprintf(E.statusmsg, ""); + E.statusmsg[0] = '\0'; E.statusmsg_time = sysmillis(); return; } else if (c == ARROW_RIGHT || c == ARROW_DOWN) { @@ -1119,7 +1119,7 @@ uint32_t editorProcessKeypress(void) */ if (E.dirty > 0 && quit_times > 0) { - xsprintf(E.statusmsg, "WARNING!!! File has unsaved changes. Press Ctrl-Q %d more times to quit.", quit_times); + sprintf(E.statusmsg, "WARNING!!! File has unsaved changes. Press Ctrl-Q %d more times to quit.", quit_times); E.statusmsg_time = sysmillis(); quit_times--; } @@ -1129,8 +1129,8 @@ uint32_t editorProcessKeypress(void) cySave = E.cy; E.cy = E.screenrows-1; lastLine = editorRefreshScreen(); - xprintf("\x1b[%03d;%03dH", (lastLine == -1 ? E.screenrows-1 : lastLine+1), 1); - xputs("\x1b[0J"); + printf("\x1b[%03d;%03dH", (lastLine == -1 ? E.screenrows-1 : lastLine+1), 1); + fputs("\x1b[0J", stdout); // Restore the cursor so it opens in the same place when edit is restarted. E.cx = cxSave; @@ -1212,7 +1212,7 @@ uint32_t initEditor(void) E.syntax = NULL; if (getWindowSize(&E.screenrows,&E.screencols) == -1) { - xprintf("Unable to query the screen for size (columns / rows)"); + printf("Unable to query the screen for size (columns / rows)"); return(1); } E.screenrows -= 2; /* Get room for status bar. */ @@ -1238,14 +1238,14 @@ uint32_t app(uint32_t param1, uint32_t param2) pathName = getStrParam(&ptr); if(strlen(pathName) == 0) { - xprintf("Usage: ed \n"); + printf("Usage: ed \n"); } else { if((retCode = initEditor()) == 0) { if((retCode = editorOpen(pathName)) == 0) { - xsprintf(E.statusmsg, "HELP: Ctrl-S = save | Ctrl-Q = quit | Ctrl-F = find"); + sprintf(E.statusmsg, "HELP: Ctrl-S = save | Ctrl-Q = quit | Ctrl-F = find"); E.statusmsg_time = sysmillis(); while(retCode == 0) { @@ -1254,22 +1254,23 @@ uint32_t app(uint32_t param1, uint32_t param2) } // Clear screen on exit. - xputs("\x1b[2J"); + fputs("\x1b[2J", stdout); } else { // Memory exhausted? if(retCode == 1) { - // Force a dump of the memory block list to aid in evaluation - umm_info(NULL, 1); - - xprintf("Insufficient memory to process this file.\n", pathName); + printf("Insufficient memory to process this file.\n"); } else { - xprintf("Failed to create or open file:%s\n", pathName); + printf("Failed to create or open file:%s\n", pathName); } } } + + // Important to release all memory back to the heap otherwise future apps wont be able to allocate it. + // + editorCleanup(); } return(retCode); } diff --git a/apps/ed/ed.h b/apps/ed/ed.h index 48d60b1..74944fe 100755 --- a/apps/ed/ed.h +++ b/apps/ed/ed.h @@ -51,79 +51,6 @@ // Application execution constants. // -// Components to be embedded in the program. -// -#define BUILTIN_DEFAULT 1 -// Disk low level components to be embedded in the program. -#define BUILTIN_DISK_DUMP 0 -#define BUILTIN_DISK_STATUS 0 -// Disk buffer components to be embedded in the program. -#define BUILTIN_BUFFER_DUMP 0 -#define BUILTIN_BUFFER_EDIT 0 -#define BUILTIN_BUFFER_READ 0 -#define BUILTIN_BUFFER_WRITE 0 -#define BUILTIN_BUFFER_FILL 0 -#define BUILTIN_BUFFER_LEN 0 -// Memory components to be embedded in the program. -#define BUILTIN_MEM_CLEAR 0 -#define BUILTIN_MEM_COPY 0 -#define BUILTIN_MEM_DIFF 0 -#define BUILTIN_MEM_DUMP 0 -#define BUILTIN_MEM_PERF 0 -#define BUILTIN_MEM_SRCH 0 -#define BUILTIN_MEM_TEST 0 -#define BUILTIN_MEM_EDIT_BYTES 0 -#define BUILTIN_MEM_EDIT_HWORD 0 -#define BUILTIN_MEM_EDIT_WORD 0 -// Hardware components to be embedded in the program. -#define BUILTIN_HW_SHOW_REGISTER 0 -#define BUILTIN_HW_TEST_TIMERS 0 -// Filesystem components to be embedded in the program. -#define BUILTIN_FS_STATUS 0 -#define BUILTIN_FS_DIRLIST 1 -#define BUILTIN_FS_OPEN 0 -#define BUILTIN_FS_CLOSE 0 -#define BUILTIN_FS_SEEK 0 -#define BUILTIN_FS_READ 0 -#define BUILTIN_FS_CAT 0 -#define BUILTIN_FS_INSPECT 0 -#define BUILTIN_FS_WRITE 0 -#define BUILTIN_FS_TRUNC 0 -#define BUILTIN_FS_RENAME 0 -#define BUILTIN_FS_DELETE 0 -#define BUILTIN_FS_CREATEDIR 0 -#define BUILTIN_FS_ALLOCBLOCK 0 -#define BUILTIN_FS_CHANGEATTRIB 0 -#define BUILTIN_FS_CHANGETIME 0 -#define BUILTIN_FS_COPY 0 -#define BUILTIN_FS_CHANGEDIR 0 -#define BUILTIN_FS_CHANGEDRIVE 0 -#define BUILTIN_FS_SHOWDIR 0 -#define BUILTIN_FS_SETLABEL 0 -#define BUILTIN_FS_CREATEFS 0 -#define BUILTIN_FS_LOAD 0 -#define BUILTIN_FS_DUMP 0 -#define BUILTIN_FS_CONCAT 0 -#define BUILTIN_FS_XTRACT 0 -#define BUILTIN_FS_SAVE 0 -#define BUILTIN_FS_EXEC 0 -// Test components to be embedded in the program. -#define BUILTIN_TST_DHRYSTONE 0 -#define BUILTIN_TST_COREMARK 0 -// Miscellaneous components to be embedded in this program. -#define BUILTIN_MISC_HELP 0 -#define BUILTIN_MISC_SETTIME 0 - -// Prototypes. -uint32_t app(uint32_t, uint32_t); - -// Global scope variables within the ZPUTA memory space. -GLOBALS *G; -SOC_CONFIG *cfgSoC; - -// Global scope variables in the app memory space. -volatile UINT Timer; /* Performance timer (100Hz increment) */ - #ifdef __cplusplus } #endif diff --git a/apps/falloc/falloc.c b/apps/falloc/falloc.c index a1f46ee..65441ee 100755 --- a/apps/falloc/falloc.c +++ b/apps/falloc/falloc.c @@ -39,28 +39,20 @@ #if defined(__K64F__) #include - #include + #include #include #include "k64f_soc.h" - #define uint32_t __uint32_t - #define uint16_t __uint16_t - #define uint8_t __uint8_t - #define int32_t __int32_t - #define int16_t __int16_t - #define int8_t __int8_t + #include <../../libraries/include/stdmisc.h> #elif defined(__ZPU__) #include + #include #include "zpu_soc.h" + #include #else #error "Target CPU not defined, use __ZPU__ or __K64F__" #endif #include "interrupts.h" #include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" -#include -#include -#include -#include "xprintf.h" #include "utils.h" // #if defined __ZPUTA__ @@ -71,6 +63,7 @@ #error OS not defined, use __ZPUTA__ or __ZOS__ #endif // +#include "app.h" #include "falloc.h" // Utility functions. @@ -99,12 +92,12 @@ uint32_t app(uint32_t param1, uint32_t param2) if(G->fileInUse == 0) { - xputs("No file open, cannot allocate block.\n"); + puts("No file open, cannot allocate block.\n"); } else { if (!xatoi(&ptr, &size) || !xatoi(&ptr, &option)) { - xputs("Illegal or