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

Subversion Repositories plasma

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

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
   (DllFunc)puts,
115
   (DllFunc)getch,
116
   (DllFunc)kbhit,
117
   (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
   ENUM_puts,
243
   ENUM_getch,
244
   ENUM_kbhit,
245
   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
#undef puts
289
#undef getch
290
#undef kbhit
291
 
292
#define strcpy DllF[ENUM_strcpy]
293
#define strncpy DllF[ENUM_strncpy]
294
#define strcat DllF[ENUM_strcat]
295
#define strncat DllF[ENUM_strncat]
296
#define strcmp (int)DllF[ENUM_strcmp]
297
#define strncmp (int)DllF[ENUM_strncmp]
298
#define strstr DllF[ENUM_strstr]
299
#define strlen (int)DllF[ENUM_strlen]
300
#define memcpy DllF[ENUM_memcpy]
301
#define memmove DllF[ENUM_memmove]
302
#define memcmp (int)DllF[ENUM_memcmp]
303
#define memset DllF[ENUM_memset]
304
#define abs (int)DllF[ENUM_abs]
305
#define rand (int)DllF[ENUM_rand]
306
#define srand DllF[ENUM_srand]
307
#define strtol (int)DllF[ENUM_strtol]
308
#define atoi (int)DllF[ENUM_atoi]
309
#define itoa DllF[ENUM_itoa]
310
#define sprintf DllF[ENUM_sprintf]
311
#define sscanf DllF[ENUM_sscanf]
312
#define dump DllF[ENUM_dump]
313
#define qsort DllF[ENUM_qsort]
314
#define bsearch DllF[ENUM_bsearch]
315
#define mktime DllF[ENUM_mktime]
316
#define gmtime_r DllF[ENUM_gmtime_r]
317
#define gmtimeDst DllF[ENUM_gmtimeDst]
318
#define gmtimeDstSet DllF[ENUM_gmtimeDstSet]
319
#define OS_AsmInterruptEnable (int)DllF[ENUM_OS_AsmInterruptEnable]
320
#define OS_HeapCreate DllF[ENUM_OS_HeapCreate]
321
#define OS_HeapDestroy DllF[ENUM_OS_HeapDestroy]
322
#define OS_HeapMalloc DllF[ENUM_OS_HeapMalloc]
323
#define OS_HeapFree DllF[ENUM_OS_HeapFree]
324
#define OS_HeapAlternate DllF[ENUM_OS_HeapAlternate]
325
#define OS_HeapRegister DllF[ENUM_OS_HeapRegister]
326
#define OS_ThreadCreate DllF[ENUM_OS_ThreadCreate]
327
#define OS_ThreadExit DllF[ENUM_OS_ThreadExit]
328
#define OS_ThreadSelf DllF[ENUM_OS_ThreadSelf]
329
#define OS_ThreadSleep DllF[ENUM_OS_ThreadSleep]
330
#define OS_ThreadTime DllF[ENUM_OS_ThreadTime]
331
#define OS_ThreadInfoSet DllF[ENUM_OS_ThreadInfoSet]
332
#define OS_ThreadInfoGet DllF[ENUM_OS_ThreadInfoGet]
333
#define OS_ThreadPriorityGet (int)DllF[ENUM_OS_ThreadPriorityGet]
334
#define OS_ThreadPrioritySet DllF[ENUM_OS_ThreadPrioritySet]
335
#define OS_ThreadProcessId DllF[ENUM_OS_ThreadProcessId]
336
#define OS_ThreadCpuLock DllF[ENUM_OS_ThreadCpuLock]
337
#define OS_SemaphoreCreate DllF[ENUM_OS_SemaphoreCreate]
338
#define OS_SemaphoreDelete DllF[ENUM_OS_SemaphoreDelete]
339
#define OS_SemaphorePend (int)DllF[ENUM_OS_SemaphorePend]
340
#define OS_SemaphorePost DllF[ENUM_OS_SemaphorePost]
341
#define OS_MutexCreate DllF[ENUM_OS_MutexCreate]
342
#define OS_MutexDelete DllF[ENUM_OS_MutexDelete]
343
#define OS_MutexPend (int)DllF[ENUM_OS_MutexPend]
344
#define OS_MutexPost DllF[ENUM_OS_MutexPost]
345
#define OS_MQueueCreate DllF[ENUM_OS_MQueueCreate]
346
#define OS_MQueueDelete DllF[ENUM_OS_MQueueDelete]
347
#define OS_MQueueSend DllF[ENUM_OS_MQueueSend]
348
#define OS_MQueueGet (int)DllF[ENUM_OS_MQueueGet]
349
#define OS_Job DllF[ENUM_OS_Job]
350
#define OS_TimerCreate DllF[ENUM_OS_TimerCreate]
351
#define OS_TimerDelete DllF[ENUM_OS_TimerDelete]
352
#define OS_TimerCallback DllF[ENUM_OS_TimerCallback]
353
#define OS_TimerStart DllF[ENUM_OS_TimerStart]
354
#define OS_TimerStop DllF[ENUM_OS_TimerStop]
355
#define OS_InterruptRegister DllF[ENUM_OS_InterruptRegister]
356
#define OS_InterruptStatus (int)DllF[ENUM_OS_InterruptStatus]
357
#define OS_InterruptMaskSet DllF[ENUM_OS_InterruptMaskSet]
358
#define OS_InterruptMaskClear DllF[ENUM_OS_InterruptMaskClear]
359
#define UartPrintf DllF[ENUM_UartPrintf]
360
#define UartPrintfPoll DllF[ENUM_UartPrintfPoll]
361
#define UartPrintfCritical DllF[ENUM_UartPrintfCritical]
362
#define UartScanf DllF[ENUM_UartScanf]
363
#define puts DllF[ENUM_puts]
364
#define getch (int)DllF[ENUM_getch]
365
#define kbhit (int)DllF[ENUM_kbhit]
366
#define Led DllF[ENUM_Led]
367
#define FP_Sqrt (float)(int)DllF[ENUM_FP_Sqrt]
368
#define FP_Cos (float)(int)DllF[ENUM_FP_Cos]
369
#define FP_Sin (float)(int)DllF[ENUM_FP_Sin]
370
#define FP_Atan (float)(int)DllF[ENUM_FP_Atan]
371
#define FP_Atan2 (float)(int)DllF[ENUM_FP_Atan2]
372
#define FP_Exp (float)(int)DllF[ENUM_FP_Exp]
373
#define FP_Log (float)(int)DllF[ENUM_FP_Log]
374
#define FP_Pow (float)(int)DllF[ENUM_FP_Pow]
375
#define OS_fopen DllF[ENUM_OS_fopen]
376
#define OS_fclose DllF[ENUM_OS_fclose]
377
#define OS_fread (int)DllF[ENUM_OS_fread]
378
#define OS_fwrite DllF[ENUM_OS_fwrite]
379
#define OS_fseek DllF[ENUM_OS_fseek]
380
#define OS_fmkdir DllF[ENUM_OS_fmkdir]
381
#define OS_fdir DllF[ENUM_OS_fdir]
382
#define OS_fdelete DllF[ENUM_OS_fdelete]
383
#define FlashRead DllF[ENUM_FlashRead]
384
#define FlashWrite DllF[ENUM_FlashWrite]
385
#define FlashErase DllF[ENUM_FlashErase]
386
#define IPOpen DllF[ENUM_IPOpen]
387
#define IPWriteFlush DllF[ENUM_IPWriteFlush]
388
#define IPWrite (int)DllF[ENUM_IPWrite]
389
#define IPRead (int)DllF[ENUM_IPRead]
390
#define IPClose DllF[ENUM_IPClose]
391
#define IPPrintf DllF[ENUM_IPPrintf]
392
#define IPResolve DllF[ENUM_IPResolve]
393
#define IPAddressSelf (int)DllF[ENUM_IPAddressSelf]
394
#define IPNameValue DllF[ENUM_IPNameValue]
395
 
396
#endif //DLL_CALL
397
 
398
 
399
#if defined(DLL_SETUP) && defined(DLL_CALL)
400
const DllFunc *DllF = DllFuncList;
401
#elif !defined(DLL_SETUP) && !defined(DLL_CALL) && !defined(DLL_ENTRY)
402
#define DLL_ENTRY 1
403
#endif //DLL_SETUP && DLL_CALL
404
 
405
 
406
// Included by DLL to initialize the DLL
407
#if defined(DLL_ENTRY) && !defined(NO_DLL_ENTRY)
408
const DllFunc *DllF;            //array of function pointers
409
extern void *__bss_start;
410
extern void *_end;
411
void Start(IPSocket *socket, char *argv[]);
412
 
413
//Must be first function in file
414
void *__start(DllFunc *DllFuncList)
415
{
416
   int *bss;
417
   if(DllFuncList == NULL)
418
      return (void*)__start;      //address where DLL should be loaded
419
   for(bss = (int*)&__bss_start; bss < (int*)&_end; ++bss)
420
      *bss = 0;
421
   DllF = DllFuncList;
422
   return (void*)Start;
423
}
424
#endif //DLL_ENTRY
425
 
426
 
427
#ifdef DLL_STRINGS
428
const char * const DllStrings[] = {
429
   "strcpy",
430
   "strncpy",
431
   "strcat",
432
   "strncat",
433
   "strcmp",
434
   "strncmp",
435
   "strstr",
436
   "strlen",
437
   "memcpy",
438
   "memmove",
439
   "memcmp",
440
   "memset",
441
   "abs",
442
   "rand",
443
   "srand",
444
   "strtol",
445
   "atoi",
446
   "itoa",
447
   "sprintf",
448
   "sscanf",
449
   "dump",
450
   "qsort",
451
   "bsearch",
452
   "mktime",
453
   "gmtime_r",
454
   "gmtimeDst",
455
   "gmtimeDstSet",
456
   "OS_AsmInterruptEnable",
457
   "OS_HeapCreate",
458
   "OS_HeapDestroy",
459
   "OS_HeapMalloc",
460
   "OS_HeapFree",
461
   "OS_HeapAlternate",
462
   "OS_HeapRegister",
463
   "OS_ThreadCreate",
464
   "OS_ThreadExit",
465
   "OS_ThreadSelf",
466
   "OS_ThreadSleep",
467
   "OS_ThreadTime",
468
   "OS_ThreadInfoSet",
469
   "OS_ThreadInfoGet",
470
   "OS_ThreadPriorityGet",
471
   "OS_ThreadPrioritySet",
472
   "OS_ThreadProcessId",
473
   "OS_ThreadCpuLock",
474
   "OS_SemaphoreCreate",
475
   "OS_SemaphoreDelete",
476
   "OS_SemaphorePend",
477
   "OS_SemaphorePost",
478
   "OS_MutexCreate",
479
   "OS_MutexDelete",
480
   "OS_MutexPend",
481
   "OS_MutexPost",
482
   "OS_MQueueCreate",
483
   "OS_MQueueDelete",
484
   "OS_MQueueSend",
485
   "OS_MQueueGet",
486
   "OS_Job",
487
   "OS_TimerCreate",
488
   "OS_TimerDelete",
489
   "OS_TimerCallback",
490
   "OS_TimerStart",
491
   "OS_TimerStop",
492
   "OS_InterruptRegister",
493
   "OS_InterruptStatus",
494
   "OS_InterruptMaskSet",
495
   "OS_InterruptMaskClear",
496
   "printf", //"UartPrintf",
497
   "UartPrintfPoll",
498
   "UartPrintfCritical",
499
   "scanf", //"UartScanf",
500
   "puts",
501
   "getch",
502
   "kbhit",
503
   "Led",
504
   "FP_Sqrt",
505
   "FP_Cos",
506
   "FP_Sin",
507
   "FP_Atan",
508
   "FP_Atan2",
509
   "FP_Exp",
510
   "FP_Log",
511
   "FP_Pow",
512
   "OS_fopen",
513
   "OS_fclose",
514
   "OS_fread",
515
   "OS_fwrite",
516
   "OS_fseek",
517
   "OS_fmkdir",
518
   "OS_fdir",
519
   "OS_fdelete",
520
   "FlashRead",
521
   "FlashWrite",
522
   "FlashErase",
523
   "IPOpen",
524
   "IPWriteFlush",
525
   "IPWrite",
526
   "IPRead",
527
   "IPClose",
528
   "IPPrintf",
529
   "IPResolve",
530
   "IPAddressSelf",
531
   "IPNameValue",
532
   NULL
533
};
534
#endif //DLL_STRINGS
535
 
536
#endif //__DLL_H__
537
 

powered by: WebSVN 2.1.0

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