1 |
416 |
rhoads |
/*--------------------------------------------------------------------
|
2 |
|
|
* TITLE: OS stubs
|
3 |
|
|
* AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
4 |
|
|
* DATE CREATED: 2/18/08
|
5 |
|
|
* FILENAME: os_stubs.c
|
6 |
|
|
* PROJECT: Plasma CPU core
|
7 |
|
|
* COPYRIGHT: Software placed into the public domain by the author.
|
8 |
|
|
* Software 'as is' without warranty. Author liable for nothing.
|
9 |
|
|
* DESCRIPTION:
|
10 |
|
|
*--------------------------------------------------------------------*/
|
11 |
|
|
#include <stdlib.h>
|
12 |
|
|
#include "plasma.h"
|
13 |
|
|
#include "rtos.h"
|
14 |
|
|
|
15 |
|
|
static unsigned char *flash;
|
16 |
|
|
|
17 |
|
|
void FlashLock(void) {}
|
18 |
|
|
void FlashUnlock(void) {}
|
19 |
|
|
|
20 |
|
|
void FlashRead(uint16 *dst, uint32 byteOffset, int bytes)
|
21 |
|
|
{
|
22 |
|
|
if(flash == NULL)
|
23 |
|
|
{
|
24 |
|
|
flash = (unsigned char*)malloc(1024*1024*16);
|
25 |
|
|
memset(flash, 0xff, 1024*1024*16);
|
26 |
|
|
}
|
27 |
|
|
memcpy(dst, flash+byteOffset, bytes);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
void FlashWrite(uint16 *src, uint32 byteOffset, int bytes)
|
32 |
|
|
{
|
33 |
|
|
memcpy(flash+byteOffset, src, bytes);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
void FlashErase(uint32 byteOffset)
|
38 |
|
|
{
|
39 |
|
|
memset(flash+byteOffset, 0xff, 1024*128);
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
//Stub out RTOS functions
|
44 |
|
|
#undef malloc
|
45 |
|
|
#undef free
|
46 |
|
|
#undef printf
|
47 |
|
|
static void *infoValue;
|
48 |
407 |
rhoads |
void *OS_HeapMalloc(OS_Heap_t *heap, int bytes) {(void)heap; return malloc(bytes);}
|
49 |
|
|
void OS_HeapFree(void *block) {free(block);}
|
50 |
416 |
rhoads |
void UartPrintfCritical(const char *format,
|
51 |
|
|
int a, int b, int c, int d, int e, int f, int g, int h)
|
52 |
|
|
{printf(format,a,b,c,d,e,f,g,h);}
|
53 |
|
|
uint32 OS_AsmInterruptEnable(uint32 state) {(void)state; return 0;}
|
54 |
|
|
void OS_Assert(void)
|
55 |
|
|
{}
|
56 |
|
|
OS_Thread_t *OS_ThreadCreate(const char *name,
|
57 |
|
|
OS_FuncPtr_t funcPtr,
|
58 |
|
|
void *arg,
|
59 |
|
|
uint32 priority,
|
60 |
|
|
uint32 stackSize)
|
61 |
|
|
{(void)name;(void)funcPtr;(void)arg;(void)priority;(void)stackSize;return NULL;}
|
62 |
|
|
void OS_ThreadExit(void) {}
|
63 |
|
|
OS_Thread_t *OS_ThreadSelf(void) {return NULL;}
|
64 |
|
|
void OS_ThreadSleep(int ticks) {(void)ticks;}
|
65 |
|
|
uint32 OS_ThreadTime(void) {return 0;}
|
66 |
|
|
void *OS_ThreadInfoGet(OS_Thread_t *thread, uint32 index)
|
67 |
|
|
{(void)thread;(void)index;return infoValue;}
|
68 |
|
|
void OS_ThreadInfoSet(OS_Thread_t *thread, uint32 index, void *info)
|
69 |
|
|
{(void)thread;(void)index;infoValue=info;}
|
70 |
|
|
|
71 |
|
|
OS_Semaphore_t *OS_SemaphoreCreate(const char *name, uint32 count)
|
72 |
|
|
{(void)name;(void)count;return NULL;}
|
73 |
|
|
void OS_SemaphoreDelete(OS_Semaphore_t *semaphore) {(void)semaphore;}
|
74 |
|
|
int OS_SemaphorePend(OS_Semaphore_t *semaphore, int ticks)
|
75 |
|
|
{(void)semaphore; (void)ticks; return 0;}
|
76 |
|
|
void OS_SemaphorePost(OS_Semaphore_t *semaphore) {(void)semaphore;}
|
77 |
|
|
|
78 |
|
|
OS_Mutex_t *OS_MutexCreate(const char *name) {(void)name; return NULL;}
|
79 |
|
|
void OS_MutexDelete(OS_Mutex_t *semaphore) {(void)semaphore;}
|
80 |
|
|
void OS_MutexPend(OS_Mutex_t *semaphore) {(void)semaphore;}
|
81 |
|
|
void OS_MutexPost(OS_Mutex_t *semaphore) {(void)semaphore;}
|
82 |
|
|
#if OS_CPU_COUNT > 1
|
83 |
|
|
uint32 OS_SpinLock(void) {return 0;}
|
84 |
|
|
void OS_SpinUnlock(uint32 state) {(void)state;}
|
85 |
|
|
#endif
|
86 |
|
|
|
87 |
|
|
OS_MQueue_t *OS_MQueueCreate(const char *name,
|
88 |
|
|
int messageCount,
|
89 |
|
|
int messageBytes)
|
90 |
|
|
{(void)name;(void)messageCount;(void)messageBytes; return NULL;}
|
91 |
|
|
void OS_MQueueDelete(OS_MQueue_t *mQueue) {(void)mQueue;}
|
92 |
|
|
int OS_MQueueSend(OS_MQueue_t *mQueue, void *message)
|
93 |
|
|
{(void)mQueue;(void)message; return 0;}
|
94 |
|
|
int OS_MQueueGet(OS_MQueue_t *mQueue, void *message, int ticks)
|
95 |
|
|
{(void)mQueue;(void)message;(void)ticks; return 0;}
|
96 |
|
|
|
97 |
|
|
void OS_Job(JobFunc_t funcPtr, void *arg0, void *arg1, void *arg2)
|
98 |
|
|
{funcPtr(arg0, arg1, arg2);}
|
99 |
|
|
|
100 |
|
|
|