|
Message
From: cvs at opencores.org<cvs@o...>
Date: Thu Sep 14 07:05:05 CEST 2006
Subject: [cvs-checkins] MODIFIED: mlite ...
Date: 00/06/09 14:07:05 Modified: mlite/kernel rtos.h Log: Added optional qsort() and mktime() Revision Changes Path 1.5 mlite/kernel/rtos.h http://www.opencores.org/cvsweb.shtml/mlite/kernel/rtos.h.diff?r1=1.4&r2=1.5 (In the diff below, changes in quantity of whitespace are not shown.) Index: rtos.h =================================================================== RCS file: /cvsroot/rhoads/mlite/kernel/rtos.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- rtos.h 10 Sep 2006 01:10:07 -0000 1.4 +++ rtos.h 14 Sep 2006 05:05:04 -0000 1.5 @@ -12,14 +12,17 @@ #ifndef __RTOS_H__ #define __RTOS_H__ +// Symmetric Multi-Processing +#define OS_CPU_COUNT 1 + +// Standard C library calls #define printf UartPrintf //#define printf UartPrintfPoll #define scanf UartScanf #ifndef WIN32 -#define malloc(S) OS_HeapMalloc(NULL, S) -#define free(S) OS_HeapFree(S) + #define malloc(S) OS_HeapMalloc(NULL, S) + #define free(S) OS_HeapFree(S) #endif -#define OS_CPU_COUNT 1 //Symmetric Multi-Processing // Typedefs typedef unsigned int uint32; @@ -28,12 +31,12 @@ // Memory Access #ifdef WIN32 -uint32 MemoryRead(uint32 Address); -void MemoryWrite(uint32 Address, uint32 Value); -#define atoi atoi2 + uint32 MemoryRead(uint32 Address); + void MemoryWrite(uint32 Address, uint32 Value); + #define atoi atoi2 #else -#define MemoryRead(A) (*(volatile uint32*)(A)) -#define MemoryWrite(A,V) *(volatile uint32*)(A)=(V) + #define MemoryRead(A) (*(volatile uint32*)(A)) + #define MemoryWrite(A,V) *(volatile uint32*)(A)=(V) #endif /***************** LibC ******************/ @@ -72,13 +75,43 @@ long strtol(const char *s, const char **end, int base); int atoi(const char *s); char *itoa(int num, char *dst, int base); -void dump(const unsigned char *data, int length); #ifndef NO_ELLIPSIS -int sprintf(char *s, const char *format, ...); -int sscanf(char *s, const char *format, ...); + int sprintf(char *s, const char *format, ...); + int sscanf(char *s, const char *format, ...); #endif -#define _LIBC +#ifdef INCLUDE_DUMP + void dump(const unsigned char *data, int length); +#endif +#ifdef INCLUDE_QSORT +void qsort(void *base, + long n, + long size, + int (*cmp)(const void *,const void *)); +void *bsearch(const void *key, + const void *base, + long n, + long size, + int (*cmp)(const void *,const void *)); #endif +#ifdef INCLUDE_TIMELIB + #define difftime(time2,time1) (time2-time1) + typedef unsigned long time_t; //start at 1/1/80 + struct tm { + int tm_sec; //(0,59) + int tm_min; //(0,59) + int tm_hour; //(0,23) + int tm_mday; //(1,31) + int tm_mon; //(0,11) + int tm_year; //(0,n) from 1990 + int tm_wday; //(0,6) calculated + int tm_yday; //(0,365) calculated + int tm_isdst; // calculated + }; + time_t mktime(struct tm *tp); + void gmtime_r(const time_t *tp, struct tm *out);
+#endif
+#define _LIBC
+#endif //_LIBC
/***************** Assembly **************/
typedef uint32 jmp_buf[20];
@@ -103,27 +136,30 @@
/***************** Thread *****************/
#if OS_CPU_COUNT <= 1
-#define OS_CpuIndex() 0
-#define OS_CriticalBegin() OS_AsmInterruptEnable(0)
-#define OS_CriticalEnd(S) OS_AsmInterruptEnable(S)
-#define OS_SpinLock() 0
-#define OS_SpinUnlock(S)
-#define OS_SpinLockGet() 0
-#define OS_SpinLockSet(S)
+ // Single CPU
+ #define OS_CpuIndex() 0
+ #define OS_CriticalBegin() OS_AsmInterruptEnable(0)
+ #define OS_CriticalEnd(S) OS_AsmInterruptEnable(S)
+ #define OS_SpinLock() 0
+ #define OS_SpinUnlock(S)
+ #define OS_SpinLockGet() 0
+ #define OS_SpinLockSet(S)
#else
-uint32 OS_CpuIndex(void);
-#define OS_CriticalBegin() OS_SpinLock()
-#define OS_CriticalEnd(S) OS_SpinUnlock(S)
-uint32 OS_SpinLock(void);
-void OS_SpinUnlock(uint32 state);
-uint32 OS_SpinLockGet(void);
-void OS_SpinLockSet(uint32 count);
+ // Symmetric multiprocessing
+ uint32 OS_CpuIndex(void);
+ #define OS_CriticalBegin() OS_SpinLock()
+ #define OS_CriticalEnd(S) OS_SpinUnlock(S)
+ uint32 OS_SpinLock(void);
+ void OS_SpinUnlock(uint32 state);
+ uint32 OS_SpinLockGet(void);
+ void OS_SpinLockSet(uint32 count);
+ void OS_CpuInterrupt(uint32 cpuIndex, uint32 bitfield);
#endif
#ifdef WIN32
-#define STACK_SIZE_MINIMUM (1024*4)
+ #define STACK_SIZE_MINIMUM (1024*4)
#else
-#define STACK_SIZE_MINIMUM (1024*1)
+ #define STACK_SIZE_MINIMUM (1024*1)
#endif
#define STACK_SIZE_DEFAULT 1024*2
#define THREAD_PRIORITY_IDLE 0
|
 |