Corrected some other warnings while at it.
}
#endif
- }\r
- else\r
+ }
+ else
{
- /* RAMLOG support */\r
- if(fd == FILE_RAMLOG) {\r
- for (int i = 0; i < nbytes; i++) {\r
- ramlog_chr (*(buf + i));\r
- }\r
+#if defined(USE_RAMLOG)
+ /* RAMLOG support */
+ if(fd == FILE_RAMLOG) {
+ for (int i = 0; i < nbytes; i++) {
+ ramlog_chr (*(buf + i));
+ }
}
- #endif\r
- }\r
- \r
- return (nbytes);\r
- }\r
- \r
- /* If we use malloc and it runs out of memory it calls sbrk()\r
- */\r
- #if 1\r
- \r
- extern char _end[];\r
- \r
- //static char *curbrk = _end;\r
-
- #ifndef HEAPSIZE\r
- #define HEAPSIZE 16000\r
+#endif
- unsigned char _heap[HEAPSIZE];\r
- \r
- caddr_t sbrk( int incr )\r
- {\r
- static unsigned char *heap_end;\r
- unsigned char *prev_heap_end;\r
- \r
- /* initialize */\r
- if( heap_end == 0 )\r
- heap_end = _heap;\r
- \r
- prev_heap_end = heap_end;\r
- \r
- if( heap_end + incr - _heap > HEAPSIZE ) {\r
- /* heap overflow - announce on stderr */\r
- write( 2, "Heap overflow!\n", 15 );\r
- abort();\r
- }\r
- \r
- heap_end += incr;\r
- \r
- return (caddr_t) prev_heap_end;\r
- }\r
- #else\r
- void *sbrk(int inc )\r
- {\r
- /* We use our own malloc */\r
- return (void *)(-1);\r
- }\r
- #endif\r
- \r
- int stat( const char *file, struct stat *st ) {\r
- //int stat(char *file, struct stat *st) {\r
- (void)file;\r
- st->st_mode = S_IFCHR;\r
- return 0;\r
- }\r
- \r
- \r
- int getpid() {\r
- return 1;\r
- }\r
- \r
- #include <errno.h>\r
- #undef errno\r
- extern int errno;\r
- int kill(int pid, int sig){\r
- (void)pid;\r
- (void)sig;\r
- errno=EINVAL;\r
- return(-1);\r
- }\r
- \r
- \r
- /* Should not really be here, but .. */\r
- \r
- void _fini( void )\r
- {\r
- \r
- }\r
- \r
- \r
- void __init( void )\r
- {\r
- \r
- }\r
- #if defined(CFG_ARM)\r
- void _exit( int status ) {\r
- while(1);\r
- }\r
- #endif\r
- \r
+ }
+
+ return (nbytes);
+ }
+
+ int arc_putchar(int c) {
+ char cc = c;
+ write( 1,&cc,1);
+
+ return 0;
+ }
+
+ /* If we use malloc and it runs out of memory it calls sbrk()
+ */
+ #if 1
+
+ extern char _end[];
+
+ //static char *curbrk = _end;
+
++#ifndef HEAPSIZE
+ #define HEAPSIZE 16000
++#endif
+ unsigned char _heap[HEAPSIZE];
+
+ caddr_t sbrk( int incr )
+ {
+ static unsigned char *heap_end;
+ unsigned char *prev_heap_end;
+
+ /* initialize */
+ if( heap_end == 0 )
+ heap_end = _heap;
+
+ prev_heap_end = heap_end;
+
+ if( heap_end + incr - _heap > HEAPSIZE ) {
+ /* heap overflow - announce on stderr */
+ write( 2, "Heap overflow!\n", 15 );
+ abort();
+ }
+
+ heap_end += incr;
+
+ return (caddr_t) prev_heap_end;
+ }
+ #else
+ void *sbrk(int inc )
+ {
+ /* We use our own malloc */
+ return (void *)(-1);
+ }
+ #endif
+
+ int stat( const char *file, struct stat *st ) {
+ //int stat(char *file, struct stat *st) {
+ (void)file;
+ st->st_mode = S_IFCHR;
+ return 0;
+ }
+
+
+ int getpid() {
+ return 1;
+ }
+
+ #include <errno.h>
+ #undef errno
+ extern int errno;
+ int kill(int pid, int sig){
+ (void)pid;
+ (void)sig;
+ errno=EINVAL;
+ return(-1);
+ }
+
+
+ /* Should not really be here, but .. */
+
+ void _fini( void )
+ {
+
+ }
+
+
+ void __init( void )
+ {
+
+ }
+ #if defined(CFG_ARM)
+ void _exit( int status ) {
+ while(1);
+ }
+ #endif
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
- \r
- #include <stdio.h>\r
+
-
-
+ #include <stdio.h>
#include <stdarg.h>
- #include "simple_printf.h"\r
- \r
++#include "simple_printf.h"
+
-extern int simple_sprintf(char *, const char *format, ...);
- #ifndef CFG_RAMLOG_SIZE\r
-#define CONFIG_RAMLOG_SIZE 2000
++#ifndef CFG_RAMLOG_SIZE
+#define CFG_RAMLOG_SIZE 2000
- #endif\r
- \r
- static unsigned char ramlog[CFG_RAMLOG_SIZE] __attribute__ ((section (".ramlog")));\r
- static unsigned ramlog_curr __attribute__ ((section (".ramlog")));\r
- static unsigned ramlog_session __attribute__ ((section (".ramlog")));\r
- \r
- static FILE *ramlogFile = 0;\r
- \r
- \r
- void ramlog_chr( char c ) {\r
- ramlog[ramlog_curr++] = c;\r
- if( ramlog_curr >= CFG_RAMLOG_SIZE ) {\r
- ramlog_curr = 0;\r
- }\r
- }\r
- \r
- void ramlog_puts( char *str ) {\r
- \r
- while(*str!=0) {\r
- ramlog_chr(*str++);\r
- }\r
- ramlog_chr('\n');\r
- }\r
- \r
- void ramlog_printf( const char *format, ... ) {\r
- \r
- // Fast and ugly ramlog support.\r
- volatile int rv;\r
- va_list args;\r
- va_start(args,format);\r
- \r
- rv = vfprintf(ramlogFile,format, args);\r
- va_end(args);\r
- }\r
- \r
- void ramlog_init()\r
- {\r
- char buf[32];\r
- if( ramlog_curr>CFG_RAMLOG_SIZE)\r
- {\r
- ramlog_curr = 0;\r
- ramlog_session = 0;\r
- }\r
- \r
- ramlogFile = fopen("ramlog","a");\r
- \r
- ramlog_session++;\r
- \r
- simple_sprintf(buf, "Session (%d)\n", ramlog_session);\r
- ramlog_puts(buf);\r
- }\r
++#endif
+
-static unsigned char ramlog[CONFIG_RAMLOG_SIZE] __attribute__ ((section (".ramlog")));
++static unsigned char ramlog[CFG_RAMLOG_SIZE] __attribute__ ((section (".ramlog")));
+ static unsigned ramlog_curr __attribute__ ((section (".ramlog")));
+ static unsigned ramlog_session __attribute__ ((section (".ramlog")));
+
+ static FILE *ramlogFile = 0;
+
+
+ void ramlog_chr( char c ) {
+ ramlog[ramlog_curr++] = c;
- if( ramlog_curr >= 2000 ) {
++ if( ramlog_curr >= CFG_RAMLOG_SIZE ) {
+ ramlog_curr = 0;
+ }
+ }
+
+ void ramlog_puts( char *str ) {
+
+ while(*str!=0) {
+ ramlog_chr(*str++);
+ }
+ ramlog_chr('\n');
+ }
+
+ void ramlog_printf( const char *format, ... ) {
+
+ // Fast and ugly ramlog support.
+ volatile int rv;
+ va_list args;
+ va_start(args,format);
+
+ rv = vfprintf(ramlogFile,format, args);
+ va_end(args);
+ }
+
+ void ramlog_init()
+ {
+ char buf[32];
- if( ramlog_curr>CONFIG_RAMLOG_SIZE)
++ if( ramlog_curr>CFG_RAMLOG_SIZE)
+ {
+ ramlog_curr = 0;
+ ramlog_session = 0;
+ }
+
+ ramlogFile = fopen("ramlog","a");
+
+ ramlog_session++;
+
+ simple_sprintf(buf, "Session (%d)\n", ramlog_session);
+ ramlog_puts(buf);
+ }
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
- \r
- #ifndef RAMLOG_H_\r
- #define RAMLOG_H_\r
- #include <stdint.h>\r
- #include "xtoa.h"\r
-
-
-/*
- * Ramlog.h
- *
- * Created on: 2009-apr-19
- * Author: mahi
- */
-
+ #ifndef RAMLOG_H_
+ #define RAMLOG_H_
- #if !defined(USE_RAMLOG)\r
++#include <stdint.h>
+ #include "xtoa.h"
+
++#if !defined(USE_RAMLOG)
+#define ramlog_str( _x)
+#define ramlog_dec( _x)
+#define ramlog_hex( _x)
+
+#else
+
- void ramlog_puts( char *str );\r
- \r
- /*\r
+ void ramlog_puts( char *str );
+ void ramlog_chr( char c );
+
+ /*
* Fast ramlog functions
- */\r
- static inline void ramlog_str( char *str ) {\r
- ramlog_puts(str);\r
- }\r
- \r
- static inline void ramlog_dec( int val ) {\r
- char str[10]; // include '-' and \0\r
- ultoa(val,str,10);\r
- ramlog_str(str);\r
- }\r
- \r
- static inline void ramlog_hex( uint32_t val ) {\r
- char str[10]; // include '-' and \0\r
- ultoa(val,str,16);\r
- ramlog_str(str);\r
- }\r
+ */
+ static inline void ramlog_str( char *str ) {
+ ramlog_puts(str);
+ }
+
+ static inline void ramlog_dec( int val ) {
+ char str[10]; // include '-' and \0
+ ultoa(val,str,10);
+ ramlog_str(str);
+ }
+
+ static inline void ramlog_hex( uint32_t val ) {
+ char str[10]; // include '-' and \0
+ ultoa(val,str,16);
+ ramlog_str(str);
+ }
+#endif
+
- \r
- /*\r
- * var args ramlog functions\r
+
+ /*
+ * var args ramlog functions
*/
- #if defined(USE_RAMLOG_PRINTF)\r
- int ramlog_printf(const char *format, ...);\r
++#if defined(USE_RAMLOG_PRINTF)
+ int ramlog_printf(const char *format, ...);
+#else
+#define ramlog_printf(format,...)
+#endif
- \r
+
#endif /* RAMLOG_H_ */
- \r
++
--- /dev/null
+\r
+#ifndef SIMPLE_PRINTF_H_\r
+#define SIMPLE_PRINTF_H_\r
+\r
+#if defined(USE_SIMPLE_PRINTF)\r
++int simple_sprintf(char *out, const char *format, ...);\r
++int simple_printf(const char *format, ...);\r
+#define simple_printf(format,...) simple_printf(format,## __VA_ARGS__ )\r
+#else\r
+#define simple_printf(format,...)\r
+#endif\r
+\r
+#endif /* SIMPLE_PRINTF_H_ */\r
\r
# Compile\r
%.o: %.c\r
-- @echo " >> CC $<"\r
- $(Q)$(CC) -c $(CFLAGS) -o $(abspath $@) $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $(realpath $<)\r
++ @echo " >> CC $(notdir $<)"\r
+ $(Q)$(CC) -c $(CFLAGS) -o $(goal) $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $(realpath $<)\r
\r
# Assembler\r
\r
%.o: %.s\r
-- @echo " >> AS $< $(ASFLAGS)"\r
- $(Q)$(AS) $(ASFLAGS) -o $@ $<\r
++ @echo " >> AS $(notdir $<) $(ASFLAGS)"\r
+ $(Q)$(AS) $(ASFLAGS) -o $(goal) $<\r
\r
-#$(Q)$(AS) -o /cygdrive/c/apa.o $<\r
-\r
-\r
# PP Assembler \r
-.SECONDARY %.s:\r
+#.SECONDARY %.s:\r
\r
%.s: %.S\r
-- @echo " >> CPP $<"\r
++ @echo " >> CPP $(notdir $<)"\r
$(Q)$(CPP) -o $@ $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $<\r
\r
- @echo " >> CPP $<"\r
+%.s: %.ps\r
++ @echo " >> CPP $(notdir $<)"\r
+ $(Q)$(CPP) -x assembler-with-cpp -o $@ $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $<\r
+\r
+\r
# @cat $@ \r
\r
.PHONY $(ROOTDIR)/libs:\r
$(ROOTDIR)/libs:\r
-- mkdir -p $@\r
++ $(Q)mkdir -p $@\r
\r
dep-y += $(ROOTDIR)/libs\r
\r
# lib \r
$(build-lib-y): $(dep-y) $(obj-y)\r
-- @echo " >> AR $(RELDIR)/$@" \r
++ @echo " >> AR $@" \r
$(Q)$(AR) -r -o $@ $(obj-y) 2> /dev/null\r
\r
# Could use readelf -S instead of parsing the *.map file.\r
$(build-exe-y): $(obj-y) $(sim-y) $(libitem-y) \r
@echo " >> LD $@"\r
-- $(LD) $(LDFLAGS) $(ldcmdfile-y) -o $@ $(libpath-y) --start-group $(obj-y) $(lib-y) $(libitem-y) --end-group $(LDMAPFILE)\r
++ $(Q)$(LD) $(LDFLAGS) $(ldcmdfile-y) -o $@ $(libpath-y) --start-group $(obj-y) $(lib-y) $(libitem-y) --end-group $(LDMAPFILE)\r
@echo "Image size: (decimal)"\r
@gawk --non-decimal-data '/^\.text/ { print " text:" $$3+0 " bytes"; rom+=$$3 };\\r
/^\.data/ { print " data:" $$3+0 " bytes"; rom+=$$3; ram+=$$3}; \\r
- \r
- #include "types.h"\r
- #include "Os.h"\r
- #include "assert.h"\r
- #include "sys.h"\r
- #include "stdlib.h"\r
- #include "kernel.h"\r
- #include "internal.h"\r
- #include "hooks.h"\r
- #include "task_i.h"\r
- #include "ext_config.h"\r
- \r
- \r
- #define valid_standard_id() (rid->nr < Oil_GetResourceCnt()) //&& !(rid->type == RESOURCE_TYPE_INTERNAL) )\r
- #define valid_internal_id() (rid->nr < Oil_GetResourceCnt()) //&& (rid->type == RESOURCE_TYPE_INTERNAL) )\r
- \r
- \r
- static StatusType GetResource_( resource_obj_t * );\r
- StatusType ReleaseResource_( resource_obj_t * );\r
- \r
- StatusType GetResource( ResourceType ResID ) {\r
- resource_obj_t *rid = Oil_GetResource(ResID);\r
- StatusType rv = GetResource_(rid);\r
- \r
- if (rv != E_OK)\r
- goto err;\r
- \r
- OS_STD_END_1(OSServiceId_GetResource,ResID);\r
- }\r
- \r
- #if 0\r
- StatusType GetResourceInternal( ResourceType ResID ) {\r
- return GetResource_(ResID,1);\r
- }\r
- #endif\r
- \r
- static StatusType GetResource_( resource_obj_t * rid ) {\r
- StatusType rv = E_OK;\r
- \r
- if( rid->nr == RES_SCHEDULER ) {\r
- // Lock the sheduler\r
- #warning Check this\r
- os_sys.scheduler_lock = 1;\r
- //simple_printf("RES_SCHEDULER, NOT supported yet\n");\r
- //while(1);\r
- }\r
- // Check if valid resource\r
- if( !valid_standard_id() ) {\r
- rv = E_OS_ID;\r
- goto err;\r
- }\r
- // Check that the resource does not belong to another application or task\r
- if( ( (os_task_nr_to_mask(get_curr_pid()) & rid->task_mask ) == 0 )\r
- || ( get_curr_application_id() != rid->application_owner_id)\r
- || ( rid->owner != (TaskType)(-1)))\r
- {\r
- rv = E_OS_ACCESS;\r
- goto err;\r
- }\r
- \r
- rid->owner = get_curr_pid();\r
- rid->old_task_prio = os_pcb_set_prio(os_get_curr_pcb() ,rid->ceiling_priority);\r
- goto ok;\r
- err:\r
- ERRORHOOK(rv);\r
- ok:\r
- return rv;\r
- }\r
- \r
- StatusType ReleaseResource( ResourceType ResID) {\r
- StatusType rv = E_OK;\r
- if( ResID == RES_SCHEDULER ) {\r
- #warning check this\r
- os_sys.scheduler_lock=0;\r
- } else {\r
- resource_obj_t *rid = Oil_GetResource(ResID);\r
- rv = ReleaseResource_(rid);\r
- }\r
- \r
- if (rv != E_OK)\r
- goto err;\r
- \r
- OS_STD_END_1(OSServiceId_ReleaseResource,ResID);\r
- }\r
- \r
- StatusType ReleaseResource_( resource_obj_t * rid ) {\r
- if (!valid_standard_id()) {\r
- return E_OS_ID;\r
- } else {\r
- \r
- // Release it...\r
- rid->owner = (TaskType) (-1);\r
- os_pcb_set_prio(os_get_curr_pcb(), rid->old_task_prio);\r
- \r
- return E_OK;\r
- }\r
- }\r
- \r
- // TODO: Remove this function later.. this is done in oil generator\r
- // instead.\r
- void os_resource_calc_attributes( void ) {\r
- // Calc ceiling\r
- // ResourceType *rsrc;\r
- for( int i=0;i<Oil_GetResourceCnt();i++) {\r
- // rsrc = Oil_GetResource();\r
- /* TODO: Do this when there's more time */\r
- // rsrc\r
- }\r
- }\r
- \r
- //\r
- void os_resource_get_internal( void ) {\r
- resource_obj_t *rt = os_get_resource_int_p();\r
- \r
- if( rt != NULL ) {\r
- //simple_printf("Get IR proc:%s prio:%d old_task_prio:%d\n",get_curr_pcb()->name, rt->ceiling_priority,rt->old_task_prio);\r
- GetResource_(rt);\r
- }\r
- //GetResourceInternal(os_get_curr_pcb()->resource_internal);\r
- }\r
- \r
- void os_resource_release_internal( void ) {\r
- resource_obj_t *rt = os_get_resource_int_p();\r
- \r
- if( rt != NULL ) {\r
- //simple_printf("Rel IR proc:%s prio:%d old_task_prio:%d\n",get_curr_pcb()->name,rt->ceiling_priority,rt->old_task_prio);\r
- ReleaseResource_(rt);\r
- }\r
- //ReleaseResource(os_get_curr_pcb()->resource_internal);\r
- }\r
- \r
- \r
- \r
+
+ #include "types.h"
+ #include "Os.h"
+ #include "assert.h"
+ #include "sys.h"
+ #include "stdlib.h"
+ #include "kernel.h"
+ #include "internal.h"
+ #include "hooks.h"
+ #include "task_i.h"
+ #include "ext_config.h"
+
+
+ #define valid_standard_id() (rid->nr < Oil_GetResourceCnt()) //&& !(rid->type == RESOURCE_TYPE_INTERNAL) )
+ #define valid_internal_id() (rid->nr < Oil_GetResourceCnt()) //&& (rid->type == RESOURCE_TYPE_INTERNAL) )
+
+
+ static StatusType GetResource_( resource_obj_t * );
+ StatusType ReleaseResource_( resource_obj_t * );
+
+ StatusType GetResource( ResourceType ResID ) {
+ resource_obj_t *rid = Oil_GetResource(ResID);
+ StatusType rv = GetResource_(rid);
+
+ if (rv != E_OK)
+ goto err;
+
+ OS_STD_END_1(OSServiceId_GetResource,ResID);
+ }
+
+ #if 0
+ StatusType GetResourceInternal( ResourceType ResID ) {
+ return GetResource_(ResID,1);
+ }
+ #endif
+
+ static StatusType GetResource_( resource_obj_t * rid ) {
+ StatusType rv = E_OK;
+
+ if( rid->nr == RES_SCHEDULER ) {
+ // Lock the sheduler
-#warning Check this
+ os_sys.scheduler_lock = 1;
+ //simple_printf("RES_SCHEDULER, NOT supported yet\n");
+ //while(1);
+ }
+ // Check if valid resource
+ if( !valid_standard_id() ) {
+ rv = E_OS_ID;
+ goto err;
+ }
+ // Check that the resource does not belong to another application or task
+ if( ( (os_task_nr_to_mask(get_curr_pid()) & rid->task_mask ) == 0 )
+ || ( get_curr_application_id() != rid->application_owner_id)
+ || ( rid->owner != (TaskType)(-1)))
+ {
+ rv = E_OS_ACCESS;
+ goto err;
+ }
+
+ rid->owner = get_curr_pid();
+ rid->old_task_prio = os_pcb_set_prio(os_get_curr_pcb() ,rid->ceiling_priority);
+ goto ok;
+ err:
+ ERRORHOOK(rv);
+ ok:
+ return rv;
+ }
+
+ StatusType ReleaseResource( ResourceType ResID) {
+ StatusType rv = E_OK;
+ if( ResID == RES_SCHEDULER ) {
- #warning check this
+ os_sys.scheduler_lock=0;
+ } else {
+ resource_obj_t *rid = Oil_GetResource(ResID);
+ rv = ReleaseResource_(rid);
+ }
+
+ if (rv != E_OK)
+ goto err;
+
+ OS_STD_END_1(OSServiceId_ReleaseResource,ResID);
+ }
+
+ StatusType ReleaseResource_( resource_obj_t * rid ) {
+ if (!valid_standard_id()) {
+ return E_OS_ID;
+ } else {
+
+ // Release it...
+ rid->owner = (TaskType) (-1);
+ os_pcb_set_prio(os_get_curr_pcb(), rid->old_task_prio);
+
+ return E_OK;
+ }
+ }
+
+ // TODO: Remove this function later.. this is done in oil generator
+ // instead.
+ void os_resource_calc_attributes( void ) {
+ // Calc ceiling
+ // ResourceType *rsrc;
+ for( int i=0;i<Oil_GetResourceCnt();i++) {
+ // rsrc = Oil_GetResource();
+ /* TODO: Do this when there's more time */
+ // rsrc
+ }
+ }
+
+ //
+ void os_resource_get_internal( void ) {
+ resource_obj_t *rt = os_get_resource_int_p();
+
+ if( rt != NULL ) {
+ //simple_printf("Get IR proc:%s prio:%d old_task_prio:%d\n",get_curr_pcb()->name, rt->ceiling_priority,rt->old_task_prio);
+ GetResource_(rt);
+ }
+ //GetResourceInternal(os_get_curr_pcb()->resource_internal);
+ }
+
+ void os_resource_release_internal( void ) {
+ resource_obj_t *rt = os_get_resource_int_p();
+
+ if( rt != NULL ) {
+ //simple_printf("Rel IR proc:%s prio:%d old_task_prio:%d\n",get_curr_pcb()->name,rt->ceiling_priority,rt->old_task_prio);
+ ReleaseResource_(rt);
+ }
+ //ReleaseResource(os_get_curr_pcb()->resource_internal);
+ }
+
+
+
\r
- MOD_USE+=KERNEL MCU T32_TERM SIMPLE_PRINTF RAMLOG\r
-MOD_USE+=KERNEL MCU T32_TERM\r
++MOD_USE+=KERNEL MCU T32_TERM SIMPLE_PRINTF RAMLOG SIMPLE_PRINTF\r