OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [dll.h] - Blame information for rev 405

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 359 rhoads
/*--------------------------------------------------------------------
2
 * TITLE: Plasma Dynamic Link Library
3
 * AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
 * DATE CREATED: 4/4/08
5
 * FILENAME: dll.h
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
 *    Dynamic Link Library
11
 *--------------------------------------------------------------------*/
12
#ifndef __DLL_H__
13
#define __DLL_H__
14
 
15
#define INCLUDE_FILESYS
16
#include "rtos.h"
17
#include "tcpip.h"
18
 
19
typedef void *(*DllFunc)();
20
 
21
// Included by Plasma Kernel to create array of function pointers
22
#ifdef DLL_SETUP
23
 
24
void *DllDummy(void) { printf("Dummy"); return NULL; }
25
 
26
const DllFunc DllFuncList[] = {
27
   (DllFunc)strcpy,
28
   (DllFunc)strncpy,
29
   (DllFunc)strcat,
30
   (DllFunc)strncat,
31
   (DllFunc)strcmp,
32
   (DllFunc)strncmp,
33
   (DllFunc)strstr,
34
   (DllFunc)strlen,
35
   (DllFunc)memcpy,
36
   (DllFunc)memmove,
37
   (DllFunc)memcmp,
38
   (DllFunc)memset,
39
   (DllFunc)abs,
40
   (DllFunc)rand,
41
   (DllFunc)srand,
42
   (DllFunc)strtol,
43
   (DllFunc)atoi,
44
   (DllFunc)itoa,
45
   (DllFunc)sprintf,
46
   (DllFunc)sscanf,
47
#ifdef INCLUDE_DUMP
48
   (DllFunc)dump,
49
#else //INCLUDE_DUMP
50
   DllDummy,
51
#endif //INCLUDE_DUMP
52
#ifdef INCLUDE_QSORT
53
   (DllFunc)qsort,
54
   (DllFunc)bsearch,
55
#else //INCLUDE_QSORT
56
   DllDummy,
57
   DllDummy,
58
#endif //INCLUDE_QSORT
59
#ifdef INCLUDE_TIMELIB
60
   (DllFunc)mktime,
61
   (DllFunc)gmtime_r,
62
   (DllFunc)gmtimeDst,
63
   (DllFunc)gmtimeDstSet,
64
#else //INCLUDE_TIMELIB
65
   DllDummy,
66
   DllDummy,
67
   DllDummy,
68
   DllDummy,
69
#endif //INCLUDE_TIMELIB
70
   (DllFunc)OS_AsmInterruptEnable,
71
   (DllFunc)OS_HeapCreate,
72
   (DllFunc)OS_HeapDestroy,
73
   (DllFunc)OS_HeapMalloc,
74
   (DllFunc)OS_HeapFree,
75
   (DllFunc)OS_HeapAlternate,
76
   (DllFunc)OS_HeapRegister,
77
   (DllFunc)OS_ThreadCreate,
78
   (DllFunc)OS_ThreadExit,
79
   (DllFunc)OS_ThreadSelf,
80
   (DllFunc)OS_ThreadSleep,
81
   (DllFunc)OS_ThreadTime,
82
   (DllFunc)OS_ThreadInfoSet,
83
   (DllFunc)OS_ThreadInfoGet,
84
   (DllFunc)OS_ThreadPriorityGet,
85
   (DllFunc)OS_ThreadPrioritySet,
86
   (DllFunc)OS_ThreadProcessId,
87
   (DllFunc)OS_ThreadCpuLock,
88
   (DllFunc)OS_SemaphoreCreate,
89
   (DllFunc)OS_SemaphoreDelete,
90
   (DllFunc)OS_SemaphorePend,
91
   (DllFunc)OS_SemaphorePost,
92
   (DllFunc)OS_MutexCreate,
93
   (DllFunc)OS_MutexDelete,
94
   (DllFunc)OS_MutexPend,
95
   (DllFunc)OS_MutexPost,
96
   (DllFunc)OS_MQueueCreate,
97
   (DllFunc)OS_MQueueDelete,
98
   (DllFunc)OS_MQueueSend,
99
   (DllFunc)OS_MQueueGet,
100
   (DllFunc)OS_Job,
101
   (DllFunc)OS_TimerCreate,
102
   (DllFunc)OS_TimerDelete,
103
   (DllFunc)OS_TimerCallback,
104
   (DllFunc)OS_TimerStart,
105
   (DllFunc)OS_TimerStop,
106
   (DllFunc)OS_InterruptRegister,
107
   (DllFunc)OS_InterruptStatus,
108
   (DllFunc)OS_InterruptMaskSet,
109
   (DllFunc)OS_InterruptMaskClear,
110
   (DllFunc)UartPrintf,
111
   (DllFunc)UartPrintfPoll,
112
   (DllFunc)UartPrintfCritical,
113
   (DllFunc)UartScanf,
114 402 rhoads
   (DllFunc)OS_puts,
115
   (DllFunc)OS_getch,
116
   (DllFunc)OS_kbhit,
117 359 rhoads
   (DllFunc)Led,
118
   (DllFunc)FP_Sqrt,
119
   (DllFunc)FP_Cos,
120
   (DllFunc)FP_Sin,
121
   (DllFunc)FP_Atan,
122
   (DllFunc)FP_Atan2,
123
   (DllFunc)FP_Exp,
124
   (DllFunc)FP_Log,
125
   (DllFunc)FP_Pow,
126
#ifdef INCLUDE_FILESYS
127
   (DllFunc)OS_fopen,
128
   (DllFunc)OS_fclose,
129
   (DllFunc)OS_fread,
130
   (DllFunc)OS_fwrite,
131
   (DllFunc)OS_fseek,
132
   (DllFunc)OS_fmkdir,
133
   (DllFunc)OS_fdir,
134
   (DllFunc)OS_fdelete,
135
#else //INCLUDE_FILESYS
136
   DllDummy,
137
   DllDummy,
138
   DllDummy,
139
   DllDummy,
140
   DllDummy,
141
   DllDummy,
142
   DllDummy,
143
   DllDummy,
144
#endif //INCLUDE_FILESYS
145
#ifndef WIN32
146
   (DllFunc)FlashRead,
147
   (DllFunc)FlashWrite,
148
   (DllFunc)FlashErase,
149
#else //WIN32
150
   DllDummy,
151
   DllDummy,
152
   DllDummy,
153
#endif //WIN32
154
   (DllFunc)IPOpen,
155
   (DllFunc)IPWriteFlush,
156
   (DllFunc)IPWrite,
157
   (DllFunc)IPRead,
158
   (DllFunc)IPClose,
159
   (DllFunc)IPPrintf,
160
   (DllFunc)IPResolve,
161
   (DllFunc)IPAddressSelf,
162
   (DllFunc)IPNameValue
163
};
164
 
165
#endif //DLL_SETUP
166
 
167
// Included by DLL to call OS functions via array of function pointers
168
#if defined(DLL_CALL) || !defined(DLL_SETUP)
169
 
170
enum {
171
   ENUM_strcpy,
172
   ENUM_strncpy,
173
   ENUM_strcat,
174
   ENUM_strncat,
175
   ENUM_strcmp,
176
   ENUM_strncmp,
177
   ENUM_strstr,
178
   ENUM_strlen,
179
   ENUM_memcpy,
180
   ENUM_memmove,
181
   ENUM_memcmp,
182
   ENUM_memset,
183
   ENUM_abs,
184
   ENUM_rand,
185
   ENUM_srand,
186
   ENUM_strtol,
187
   ENUM_atoi,
188
   ENUM_itoa,
189
   ENUM_sprintf,
190
   ENUM_sscanf,
191
   ENUM_dump,
192
   ENUM_qsort,
193
   ENUM_bsearch,
194
   ENUM_mktime,
195
   ENUM_gmtime_r,
196
   ENUM_gmtimeDst,
197
   ENUM_gmtimeDstSet,
198
   ENUM_OS_AsmInterruptEnable,
199
   ENUM_OS_HeapCreate,
200
   ENUM_OS_HeapDestroy,
201
   ENUM_OS_HeapMalloc,
202
   ENUM_OS_HeapFree,
203
   ENUM_OS_HeapAlternate,
204
   ENUM_OS_HeapRegister,
205
   ENUM_OS_ThreadCreate,
206
   ENUM_OS_ThreadExit,
207
   ENUM_OS_ThreadSelf,
208
   ENUM_OS_ThreadSleep,
209
   ENUM_OS_ThreadTime,
210
   ENUM_OS_ThreadInfoSet,
211
   ENUM_OS_ThreadInfoGet,
212
   ENUM_OS_ThreadPriorityGet,
213
   ENUM_OS_ThreadPrioritySet,
214
   ENUM_OS_ThreadProcessId,
215
   ENUM_OS_ThreadCpuLock,
216
   ENUM_OS_SemaphoreCreate,
217
   ENUM_OS_SemaphoreDelete,
218
   ENUM_OS_SemaphorePend,
219
   ENUM_OS_SemaphorePost,
220
   ENUM_OS_MutexCreate,
221
   ENUM_OS_MutexDelete,
222
   ENUM_OS_MutexPend,
223
   ENUM_OS_MutexPost,
224
   ENUM_OS_MQueueCreate,
225
   ENUM_OS_MQueueDelete,
226
   ENUM_OS_MQueueSend,
227
   ENUM_OS_MQueueGet,
228
   ENUM_OS_Job,
229
   ENUM_OS_TimerCreate,
230
   ENUM_OS_TimerDelete,
231
   ENUM_OS_TimerCallback,
232
   ENUM_OS_TimerStart,
233
   ENUM_OS_TimerStop,
234
   ENUM_OS_InterruptRegister,
235
   ENUM_OS_InterruptStatus,
236
   ENUM_OS_InterruptMaskSet,
237
   ENUM_OS_InterruptMaskClear,
238
   ENUM_UartPrintf,
239
   ENUM_UartPrintfPoll,
240
   ENUM_UartPrintfCritical,
241
   ENUM_UartScanf,
242 402 rhoads
   ENUM_OS_puts,
243
   ENUM_OS_getch,
244
   ENUM_OS_kbhit,
245 359 rhoads
   ENUM_Led,
246
   ENUM_FP_Sqrt,
247
   ENUM_FP_Cos,
248
   ENUM_FP_Sin,
249
   ENUM_FP_Atan,
250
   ENUM_FP_Atan2,
251
   ENUM_FP_Exp,
252
   ENUM_FP_Log,
253
   ENUM_FP_Pow,
254
   ENUM_OS_fopen,
255
   ENUM_OS_fclose,
256
   ENUM_OS_fread,
257
   ENUM_OS_fwrite,
258
   ENUM_OS_fseek,
259
   ENUM_OS_fmkdir,
260
   ENUM_OS_fdir,
261
   ENUM_OS_fdelete,
262
   ENUM_FlashRead,
263
   ENUM_FlashWrite,
264
   ENUM_FlashErase,
265
   ENUM_IPOpen,
266
   ENUM_IPWriteFlush,
267
   ENUM_IPWrite,
268
   ENUM_IPRead,
269
   ENUM_IPClose,
270
   ENUM_IPPrintf,
271
   ENUM_IPResolve,
272
   ENUM_IPAddressSelf,
273
   ENUM_IPNameValue
274
};
275
 
276
extern const DllFunc *DllF;
277
 
278
#undef strcpy
279
#undef strcat
280
#undef strncat
281
#undef strcmp
282
#undef strlen
283
#undef memcpy
284
#undef memcmp
285
#undef memset
286
#undef abs
287
#undef atoi
288
 
289
#define strcpy DllF[ENUM_strcpy]
290
#define strncpy DllF[ENUM_strncpy]
291
#define strcat DllF[ENUM_strcat]
292
#define strncat DllF[ENUM_strncat]
293
#define strcmp (int)DllF[ENUM_strcmp]
294
#define strncmp (int)DllF[ENUM_strncmp]
295
#define strstr DllF[ENUM_strstr]
296
#define strlen (int)DllF[ENUM_strlen]
297
#define memcpy DllF[ENUM_memcpy]
298
#define memmove DllF[ENUM_memmove]
299
#define memcmp (int)DllF[ENUM_memcmp]
300
#define memset DllF[ENUM_memset]
301
#define abs (int)DllF[ENUM_abs]
302
#define rand (int)DllF[ENUM_rand]
303
#define srand DllF[ENUM_srand]
304
#define strtol (int)DllF[ENUM_strtol]
305
#define atoi (int)DllF[ENUM_atoi]
306
#define itoa DllF[ENUM_itoa]
307
#define sprintf DllF[ENUM_sprintf]
308
#define sscanf DllF[ENUM_sscanf]
309
#define dump DllF[ENUM_dump]
310
#define qsort DllF[ENUM_qsort]
311
#define bsearch DllF[ENUM_bsearch]
312
#define mktime DllF[ENUM_mktime]
313
#define gmtime_r DllF[ENUM_gmtime_r]
314
#define gmtimeDst DllF[ENUM_gmtimeDst]
315
#define gmtimeDstSet DllF[ENUM_gmtimeDstSet]
316
#define OS_AsmInterruptEnable (int)DllF[ENUM_OS_AsmInterruptEnable]
317
#define OS_HeapCreate DllF[ENUM_OS_HeapCreate]
318
#define OS_HeapDestroy DllF[ENUM_OS_HeapDestroy]
319
#define OS_HeapMalloc DllF[ENUM_OS_HeapMalloc]
320
#define OS_HeapFree DllF[ENUM_OS_HeapFree]
321
#define OS_HeapAlternate DllF[ENUM_OS_HeapAlternate]
322
#define OS_HeapRegister DllF[ENUM_OS_HeapRegister]
323
#define OS_ThreadCreate DllF[ENUM_OS_ThreadCreate]
324
#define OS_ThreadExit DllF[ENUM_OS_ThreadExit]
325
#define OS_ThreadSelf DllF[ENUM_OS_ThreadSelf]
326
#define OS_ThreadSleep DllF[ENUM_OS_ThreadSleep]
327
#define OS_ThreadTime DllF[ENUM_OS_ThreadTime]
328
#define OS_ThreadInfoSet DllF[ENUM_OS_ThreadInfoSet]
329
#define OS_ThreadInfoGet DllF[ENUM_OS_ThreadInfoGet]
330
#define OS_ThreadPriorityGet (int)DllF[ENUM_OS_ThreadPriorityGet]
331
#define OS_ThreadPrioritySet DllF[ENUM_OS_ThreadPrioritySet]
332
#define OS_ThreadProcessId DllF[ENUM_OS_ThreadProcessId]
333
#define OS_ThreadCpuLock DllF[ENUM_OS_ThreadCpuLock]
334
#define OS_SemaphoreCreate DllF[ENUM_OS_SemaphoreCreate]
335
#define OS_SemaphoreDelete DllF[ENUM_OS_SemaphoreDelete]
336
#define OS_SemaphorePend (int)DllF[ENUM_OS_SemaphorePend]
337
#define OS_SemaphorePost DllF[ENUM_OS_SemaphorePost]
338
#define OS_MutexCreate DllF[ENUM_OS_MutexCreate]
339
#define OS_MutexDelete DllF[ENUM_OS_MutexDelete]
340
#define OS_MutexPend (int)DllF[ENUM_OS_MutexPend]
341
#define OS_MutexPost DllF[ENUM_OS_MutexPost]
342
#define OS_MQueueCreate DllF[ENUM_OS_MQueueCreate]
343
#define OS_MQueueDelete DllF[ENUM_OS_MQueueDelete]
344
#define OS_MQueueSend DllF[ENUM_OS_MQueueSend]
345
#define OS_MQueueGet (int)DllF[ENUM_OS_MQueueGet]
346
#define OS_Job DllF[ENUM_OS_Job]
347
#define OS_TimerCreate DllF[ENUM_OS_TimerCreate]
348
#define OS_TimerDelete DllF[ENUM_OS_TimerDelete]
349
#define OS_TimerCallback DllF[ENUM_OS_TimerCallback]
350
#define OS_TimerStart DllF[ENUM_OS_TimerStart]
351
#define OS_TimerStop DllF[ENUM_OS_TimerStop]
352
#define OS_InterruptRegister DllF[ENUM_OS_InterruptRegister]
353
#define OS_InterruptStatus (int)DllF[ENUM_OS_InterruptStatus]
354
#define OS_InterruptMaskSet DllF[ENUM_OS_InterruptMaskSet]
355
#define OS_InterruptMaskClear DllF[ENUM_OS_InterruptMaskClear]
356
#define UartPrintf DllF[ENUM_UartPrintf]
357
#define UartPrintfPoll DllF[ENUM_UartPrintfPoll]
358
#define UartPrintfCritical DllF[ENUM_UartPrintfCritical]
359
#define UartScanf DllF[ENUM_UartScanf]
360 402 rhoads
#define OS_puts DllF[ENUM_OS_puts]
361
#define OS_getch (int)DllF[ENUM_OS_getch]
362
#define OS_kbhit (int)DllF[ENUM_OS_kbhit]
363 359 rhoads
#define Led DllF[ENUM_Led]
364
#define FP_Sqrt (float)(int)DllF[ENUM_FP_Sqrt]
365
#define FP_Cos (float)(int)DllF[ENUM_FP_Cos]
366
#define FP_Sin (float)(int)DllF[ENUM_FP_Sin]
367
#define FP_Atan (float)(int)DllF[ENUM_FP_Atan]
368
#define FP_Atan2 (float)(int)DllF[ENUM_FP_Atan2]
369
#define FP_Exp (float)(int)DllF[ENUM_FP_Exp]
370
#define FP_Log (float)(int)DllF[ENUM_FP_Log]
371
#define FP_Pow (float)(int)DllF[ENUM_FP_Pow]
372
#define OS_fopen DllF[ENUM_OS_fopen]
373
#define OS_fclose DllF[ENUM_OS_fclose]
374
#define OS_fread (int)DllF[ENUM_OS_fread]
375
#define OS_fwrite DllF[ENUM_OS_fwrite]
376
#define OS_fseek DllF[ENUM_OS_fseek]
377
#define OS_fmkdir DllF[ENUM_OS_fmkdir]
378
#define OS_fdir DllF[ENUM_OS_fdir]
379
#define OS_fdelete DllF[ENUM_OS_fdelete]
380
#define FlashRead DllF[ENUM_FlashRead]
381
#define FlashWrite DllF[ENUM_FlashWrite]
382
#define FlashErase DllF[ENUM_FlashErase]
383
#define IPOpen DllF[ENUM_IPOpen]
384
#define IPWriteFlush DllF[ENUM_IPWriteFlush]
385
#define IPWrite (int)DllF[ENUM_IPWrite]
386
#define IPRead (int)DllF[ENUM_IPRead]
387
#define IPClose DllF[ENUM_IPClose]
388
#define IPPrintf DllF[ENUM_IPPrintf]
389
#define IPResolve DllF[ENUM_IPResolve]
390
#define IPAddressSelf (int)DllF[ENUM_IPAddressSelf]
391
#define IPNameValue DllF[ENUM_IPNameValue]
392
 
393
#endif //DLL_CALL
394
 
395
 
396
#if defined(DLL_SETUP) && defined(DLL_CALL)
397
const DllFunc *DllF = DllFuncList;
398
#elif !defined(DLL_SETUP) && !defined(DLL_CALL) && !defined(DLL_ENTRY)
399
#define DLL_ENTRY 1
400
#endif //DLL_SETUP && DLL_CALL
401
 
402
 
403
// Included by DLL to initialize the DLL
404
#if defined(DLL_ENTRY) && !defined(NO_DLL_ENTRY)
405
const DllFunc *DllF;            //array of function pointers
406
extern void *__bss_start;
407
extern void *_end;
408
void Start(IPSocket *socket, char *argv[]);
409
 
410
//Must be first function in file
411
void *__start(DllFunc *DllFuncList)
412
{
413
   int *bss;
414
   if(DllFuncList == NULL)
415
      return (void*)__start;      //address where DLL should be loaded
416
   for(bss = (int*)&__bss_start; bss < (int*)&_end; ++bss)
417
      *bss = 0;
418
   DllF = DllFuncList;
419
   return (void*)Start;
420
}
421
#endif //DLL_ENTRY
422
 
423
 
424
#ifdef DLL_STRINGS
425
const char * const DllStrings[] = {
426
   "strcpy",
427
   "strncpy",
428
   "strcat",
429
   "strncat",
430
   "strcmp",
431
   "strncmp",
432
   "strstr",
433
   "strlen",
434
   "memcpy",
435
   "memmove",
436
   "memcmp",
437
   "memset",
438
   "abs",
439
   "rand",
440
   "srand",
441
   "strtol",
442
   "atoi",
443
   "itoa",
444
   "sprintf",
445
   "sscanf",
446
   "dump",
447
   "qsort",
448
   "bsearch",
449
   "mktime",
450
   "gmtime_r",
451
   "gmtimeDst",
452
   "gmtimeDstSet",
453
   "OS_AsmInterruptEnable",
454
   "OS_HeapCreate",
455
   "OS_HeapDestroy",
456
   "OS_HeapMalloc",
457
   "OS_HeapFree",
458
   "OS_HeapAlternate",
459
   "OS_HeapRegister",
460
   "OS_ThreadCreate",
461
   "OS_ThreadExit",
462
   "OS_ThreadSelf",
463
   "OS_ThreadSleep",
464
   "OS_ThreadTime",
465
   "OS_ThreadInfoSet",
466
   "OS_ThreadInfoGet",
467
   "OS_ThreadPriorityGet",
468
   "OS_ThreadPrioritySet",
469
   "OS_ThreadProcessId",
470
   "OS_ThreadCpuLock",
471
   "OS_SemaphoreCreate",
472
   "OS_SemaphoreDelete",
473
   "OS_SemaphorePend",
474
   "OS_SemaphorePost",
475
   "OS_MutexCreate",
476
   "OS_MutexDelete",
477
   "OS_MutexPend",
478
   "OS_MutexPost",
479
   "OS_MQueueCreate",
480
   "OS_MQueueDelete",
481
   "OS_MQueueSend",
482
   "OS_MQueueGet",
483
   "OS_Job",
484
   "OS_TimerCreate",
485
   "OS_TimerDelete",
486
   "OS_TimerCallback",
487
   "OS_TimerStart",
488
   "OS_TimerStop",
489
   "OS_InterruptRegister",
490
   "OS_InterruptStatus",
491
   "OS_InterruptMaskSet",
492
   "OS_InterruptMaskClear",
493
   "printf", //"UartPrintf",
494
   "UartPrintfPoll",
495
   "UartPrintfCritical",
496
   "scanf", //"UartScanf",
497 402 rhoads
   "OS_puts",
498
   "OS_getch",
499
   "OS_kbhit",
500 359 rhoads
   "Led",
501
   "FP_Sqrt",
502
   "FP_Cos",
503
   "FP_Sin",
504
   "FP_Atan",
505
   "FP_Atan2",
506
   "FP_Exp",
507
   "FP_Log",
508
   "FP_Pow",
509
   "OS_fopen",
510
   "OS_fclose",
511
   "OS_fread",
512
   "OS_fwrite",
513
   "OS_fseek",
514
   "OS_fmkdir",
515
   "OS_fdir",
516
   "OS_fdelete",
517
   "FlashRead",
518
   "FlashWrite",
519
   "FlashErase",
520
   "IPOpen",
521
   "IPWriteFlush",
522
   "IPWrite",
523
   "IPRead",
524
   "IPClose",
525
   "IPPrintf",
526
   "IPResolve",
527
   "IPAddressSelf",
528
   "IPNameValue",
529
   NULL
530
};
531
#endif //DLL_STRINGS
532
 
533
#endif //__DLL_H__
534
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.