-
Notifications
You must be signed in to change notification settings - Fork 4
/
jim-hwio.c
669 lines (614 loc) · 17.8 KB
/
jim-hwio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
/* Jim - POSIX extension
* Copyright 2005 Salvatore Sanfilippo <[email protected]>
* Copyright 2007 Uwe Klein Habertwedt <[email protected]>
*
* $Id: jim-hwio.c,v 1.16 2008/03/10 21:49:29 macc Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* A copy of the license is also included in the source distribution
* of Jim, as a TXT file name called LICENSE.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/io.h>
#include <sys/mman.h>
#include <sched.h>
#define JIM_EXTENSION
#include "jim.h"
static void Jim_PosixSetError(Jim_Interp *interp)
{
Jim_SetResultString(interp, strerror(errno), -1);
}
static int Jim_HwIoTemplateCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
long longValue;
if (argc != 2) {
Jim_WrongNumArgs(interp, 1, argv, "?template?");
return JIM_ERR;
}
if (Jim_GetLong(interp, argv[1], &longValue) != JIM_OK)
return JIM_ERR;
// body
return JIM_OK;
}
#define AREAINFOLEN 10
typedef struct areainfo {
int len;
int base;
int flag;
char name[20];
} AREAINFO;
AREAINFO areainfo[AREAINFOLEN];
#define NEW 0
#define FOUND 1
#define NOTFOUND -1
int placearea(const char *name,int lbase, int len, int flag)
{
int i;
int state = NOTFOUND;
int firstempty = NOTFOUND;
int numbase = 0;
if (lbase==0) {
sscanf(name,"%i",&numbase);
// fprintf(stderr,"lb0 %s : %x \n",name,numbase);
}
for (i=0;(i<AREAINFOLEN);i++) {
if (lbase && (areainfo[i].base == lbase)) {
state = FOUND ; break;
}
if ((lbase==0) && areainfo[i].len && (strcmp(areainfo[i].name, name)==0)) {
//fprintf(stderr,"found an entry %s @ %x \n",areainfo[i].name,areainfo[i].base);
return areainfo[i].base;
}
if (numbase
&& (numbase >= areainfo[i].base)
&& (numbase < ( areainfo[i].base + areainfo[i].len))
)
return(numbase);
if (lbase && firstempty<0 && areainfo[i].flag == 0) {
firstempty = i;
//fprintf(stderr,"firstempty: %d\n",firstempty);
}
}
if ((state==NOTFOUND)&&(firstempty>=0)) {
i = firstempty;
state = NEW;
}
switch (state) {
case NEW: strcpy(areainfo[i].name,name);
//fprintf(stderr,"created an entry %s \n",areainfo[i].name);
case FOUND: areainfo[i].len = len;
areainfo[i].base = lbase;
areainfo[i].flag = flag;
//fprintf(stderr,"refreshed an entry %s @ %x \n",areainfo[i].name,areainfo[i].base);
break;
default:
//fprintf(stderr,"notfound : entry %s \n",name);
return lbase;
}
return areainfo[i].base;
}
int getbasefromID(const char *name)
{
return placearea(name,0,0,0);
}
static int Jim_HwIoAreaCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
const char *op ;
int strlen;
const char *name = NULL;
long offset = -1;
long len = -1;
long res;
switch (argc) {
case 5: if (Jim_GetLong(interp, argv[4], &len) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid len");
return JIM_ERR;
}
case 4: if (Jim_GetLong(interp, argv[3], &offset) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid offset");
return JIM_ERR;
}
case 3: if (name = Jim_GetString(argv[2], &strlen),strlen == 0) {
return JIM_ERR;
}
case 2: if (op = Jim_GetString(argv[1], &strlen),strlen == 0) {
return JIM_ERR;
}
break;
case 1: op = "list";
break;
default:
Jim_WrongNumArgs(interp, 1, argv, "invalid offset");
return JIM_ERR;
}
if (strcmp(op,"create") == 0 ) {
if ( ioperm( offset, len, 1) == 0 ) {
placearea(name,offset, len,1 );
Jim_SetResult(interp,argv[2]);
}
} else if (strcmp(op,"delete") == 0 ) {
res = ioperm( offset, len, 0);
placearea(name,offset, len, 0 );
Jim_SetResult(interp, Jim_NewIntObj(interp, res));
} else if (strcmp(op,"list") == 0 ) {
res = 0;
Jim_SetResult(interp, Jim_NewIntObj(interp, res));
} else {
Jim_WrongNumArgs(interp, 1, argv, "unknown op");
return JIM_ERR;
}
return JIM_OK;
}
static long base = 0x300;
static long bcast = 0x30a;
static int Jim_HwIoBaseCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
Jim_Obj *ret = NULL;
switch (argc) {
case 3: if (Jim_GetLong(interp, argv[2], &bcast) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid bcast");
return JIM_ERR;
}
case 2: if (Jim_GetLong(interp, argv[1], &base) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid base");
return JIM_ERR;
}
case 1:
break;
default:
Jim_WrongNumArgs(interp, 1, argv, "invalid offset");
return JIM_ERR;
}
ret = Jim_NewListObj(interp, 0, 0);
Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, base));
Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, bcast));
Jim_SetResult(interp, ret);
return JIM_OK;
}
// getIntsfromList retrieves a number of ints from a list (argv)
// first item must be a number consecutive elements can be numbers
// or '.' for repeat last number
// or '+' for increment last number by size
// or '-' for decrement last number by size
static int HwIo_getIntsfromList(Jim_Interp *interp,
Jim_Obj *arg, int size, int *lastval, int *pval)
{
long tmpval;
const char *strarg;
int strlen = 0;
if (Jim_GetLong(interp, arg, &tmpval) == JIM_OK) {
*pval = tmpval;
//fprintf(stderr,"int conversion OK\n");
return JIM_OK;
} else if (lastval == 0) {
//fprintf(stderr,"tmpval: %ld lastval %p \n",tmpval, lastval);
return JIM_ERR;
} else if (strarg = Jim_GetString(arg, &strlen),strlen>0) {
// fprintf(stderr,"lastval: %ld %p %s\n",tmpval, strarg,strarg);
do {
switch (*strarg) {
case '-': *pval = *lastval - size; break;
case '.': *pval = *lastval; break;
case '+': *pval = *lastval + size; break;
default:
//fprintf(stderr,"extra opt :%d %c %s\n",strlen,*strarg,strarg);
return JIM_ERR;
}
} while (strarg++,*strarg);
//fprintf(stderr,"pval: %d \n",*pval);
} else {
//fprintf(stderr,"else \n");
return JIM_ERR;
}
return JIM_OK;
}
#define MASK(width) ((1<<width)-1)
#define DATAOFFS 0
#define DATABITS 27
#define ADDROFFS DATABITS
#define ADDRBITS 5
#define DATAMASK MASK(DATABITS)
#define ADDRMASK MASK(ADDRBITS)
#define COMPOSE(addr,value) (((addr&ADDRMASK)<<ADDROFFS)|((value&DATAMASK)<<DATAOFFS))
#define STRIP(value) (value&DATAMASK)
#define ADDRREG 0x1f
static int Jim_HwIoRregCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
int idx ;
int lbase = base;
int addrval;
int *plast = NULL;
int outvalue;
Jim_Obj *ret = Jim_NewListObj(interp, 0, 0);
for (idx=1;(idx < argc);idx++) {
if (HwIo_getIntsfromList(interp, argv[idx],1,plast,&addrval) != JIM_OK) {
const char *board;
int strlen;
// fprintf(stderr,"going for ID\n");
if ((idx == 1) && (board = Jim_GetString(argv[idx], &strlen))) {
//fprintf(stderr,"cont for ID\n");
lbase = getbasefromID(board);
continue;
}
Jim_WrongNumArgs(interp, 1, argv, "Format!");
return JIM_ERR;
}
outvalue = COMPOSE(ADDRREG,addrval);
// fprintf(stderr,"rreg lbase: %x addrval: %x outvalue: %08x\n",lbase,addrval,outvalue);
inb(0x80);
outl(outvalue,lbase);
#ifdef USE_USLEEP
usleep(1000);
#else
inb(0x80);
inb(0x80);
inb(0x80);
inb(0x80);
inb(0x80);
#endif
Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, STRIP(inl(lbase))));
inb(0x80);
plast = &addrval;
}
Jim_SetResult(interp, ret);
return JIM_OK;
}
#define RETisUINT 0
#define RETisINT 1
#define MAXBOARD 4
static int Jim_HwIoRregBlkCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
long len = -1 ;
int bcnt = 0;
int lbase[MAXBOARD] = {base, 0, 0, 0 };
long addr;
long outvalue;
const char *board;
int strlen;
int rettype=RETisUINT;
int llength;
int i,j,k;
int swaplist[] = {0, 3, 2, 1};
char swaplen = (sizeof(swaplist)/sizeof(int));
long swapbuf[2*swaplen];
Jim_Obj *ret = NULL;
if ( argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "wrong num args!");
return JIM_ERR;
}
// check if the board spec is a list
if ((argc>=4) && (Jim_ListLength(interp,argv[1],&llength),llength > 1)) {
Jim_Obj* bobj;
// fprintf(stderr,"larg length:%d \n",llength);
for (i=0;(i<llength);i++) {
Jim_ListIndex(interp,argv[1],i,&bobj,JIM_NONE);
if ((board = Jim_GetString(bobj, &strlen))) {
// fprintf(stderr,"larg Board: %s base %x \n",board,getbasefromID(board));
lbase[bcnt++] = getbasefromID(board);
}
}
argv++; argc--;
}
while ((argc > 3) && (board = Jim_GetString(argv[1], &strlen))) {
if (strcmp("int",board)==0) {
rettype = RETisINT;
argv++; argc--;
continue;
}
if (strcmp("noswap",board)==0) {
swaplist[0] = 0;
swaplist[1] = 1;
swaplist[2] = 2;
swaplist[3] = 3;
argv++; argc--;
continue;
}
if (sscanf(board,"swap:%i,%i,%i,%i",
&swaplist[0],&swaplist[1],&swaplist[2],&swaplist[3]
)==4) {
argv++; argc--;
continue;
}
// fprintf(stderr,"marg Board: %s base %x \n",board,getbasefromID(board));
//fprintf(stderr,"cont for ID\n");
lbase[bcnt++] = getbasefromID(board);
argv++; argc--;
}
if (bcnt > MAXBOARD) {
Jim_WrongNumArgs(interp, 1, argv, "too many boards specified!");
return JIM_ERR;
}
if (!bcnt) bcnt = 1; // default base
// get start
if (Jim_GetLong(interp, argv[1], &addr) != JIM_OK) {
return JIM_ERR;
}
outvalue = COMPOSE(ADDRREG,addr);
// get len
if (Jim_GetLong(interp, argv[2], &len) != JIM_OK) {
return JIM_ERR;
}
len /= bcnt; // fix for bcnt items per len--
for (i=0;(i<bcnt);i++) {
// fprintf(stderr,"rregmult:%d lbase: %x addr: %lx outvalue %08lx (len: %lx )\n",bcnt,lbase[i],addr,outvalue,len);
inb(0x80);
outl(outvalue,lbase[i]);
}
#ifdef USE_USLEEP
usleep(1000);
#else
inb(0x80);
inb(0x80);
inb(0x80);
inb(0x80);
inb(0x80);
#endif
ret = Jim_NewListObj(interp, 0, 0);
switch (rettype) {
case RETisUINT:
j = 0;
while (len--) {
for (i=0;(i<bcnt);i++,j++) {
inb(0x80);
swapbuf[j] = inl(lbase[i]);
}
if (j>=swaplen) {
j -= swaplen;
for (k=0;(k<swaplen);k++) {
Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, swapbuf[j+swaplist[k]]));
}
}
}
inb(0x80);
break;
case RETisINT:
j = 0;
while (len--) {
for (i=0;(i<bcnt);i++,j++) {
inb(0x80);
swapbuf[j] = inl(lbase[i]);
}
if (j>=swaplen) {
j -= swaplen;
for (k=0;(k<swaplen);k++) {
Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, (int)swapbuf[j+swaplist[k]]));
}
}
}
inb(0x80);
}
Jim_SetResult(interp, ret);
return JIM_OK;
}
static int Jim_HwIoWregCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
int idx ;
int lbase = base;
int addr;
int *plast = NULL;
long val;
long outvalue;
int cnt = 0;
for (idx=1;(idx < argc);idx++) {
// fprintf(stderr,"argc %d idx %d\n",argc,idx);
if (HwIo_getIntsfromList(interp, argv[idx],1,plast,&addr) != JIM_OK) {
const char *board;
int strlen;
//fprintf(stderr,"going for ID\n");
if ((idx == 1) && (board = Jim_GetString(argv[idx], &strlen))) {
//fprintf(stderr,"cont for ID\n");
lbase = getbasefromID(board);
continue;
}
Jim_WrongNumArgs(interp, 1, argv, "Format!");
return JIM_ERR;
}
plast = &addr;
idx++;
if (idx == argc)
fprintf(stderr,"uneven number args @ %d\n",idx);
if (Jim_GetLong(interp, argv[idx], &val) == JIM_OK) {
outvalue = COMPOSE(addr,val);
// fprintf(stderr,"wreg: lbase: %x addr: %x outvalue %08lx\n",lbase,addr,outvalue);
inb(0x80);
outl(outvalue,lbase);
inb(0x80);
// fprintf(stderr,"outb:%ld @ %d\n",outval,addrval);
cnt++;
} else
return JIM_ERR;
//fprintf(stderr,"argc %d idx %d\n",argc,idx);
}
Jim_SetResult(interp, Jim_NewIntObj(interp, cnt));
return JIM_OK;
}
#undef INOUT_SIZE
#undef INOUT_IN_OP
#undef INOUT_OUT_OP
#undef INOUT_IN_CMDNAME
#undef INOUT_OUT_CMDNAME
//end
#define INOUT_SIZE 1
#define INOUT_IN_OP inb
#define INOUT_OUT_OP outb
#define INOUT_IN_CMDNAME Jim_HwIoInbCommand
#define INOUT_OUT_CMDNAME Jim_HwIoOutbCommand
#include "jim-hwio.inoutblock.h"
#define INOUT_SIZE 2
#define INOUT_IN_OP inw
#define INOUT_OUT_OP outw
#define INOUT_IN_CMDNAME Jim_HwIoInwCommand
#define INOUT_OUT_CMDNAME Jim_HwIoOutwCommand
#include "jim-hwio.inoutblock.h"
#define INOUT_SIZE 4
#define INOUT_IN_OP inl
#define INOUT_OUT_OP outl
#define INOUT_IN_CMDNAME Jim_HwIoInlCommand
#define INOUT_OUT_CMDNAME Jim_HwIoOutlCommand
#include "jim-hwio.inoutblock.h"
static int Jim_HwIoMLockCommand( Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
const char *options[] = {
"release", "current", "future", NULL
};
enum {RELEASE, CURRENT, FUTURE} ;
int option;
jim_wide start;
jim_wide len;
switch (argc) {
case 3: // Address Range
if (Jim_GetWide(interp, argv[1], &start) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid Start");
return JIM_ERR;
}
if (Jim_GetWide(interp, argv[2], &len) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid Len");
return JIM_ERR;
}
if (mlock((void*)(long)start,len))
goto tell_posix_error;
return JIM_OK;
case 2:
if (Jim_GetEnum(interp, argv[1], options, &option,
"mlock type", JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
switch (option) {
case RELEASE:
if (munlockall())
goto tell_posix_error;
return JIM_OK;
case CURRENT:
if (mlockall(MCL_CURRENT))
goto tell_posix_error;
return JIM_OK;
case FUTURE:
if (mlockall(MCL_FUTURE))
goto tell_posix_error;
return JIM_OK;
}
break;
case 1:
return JIM_OK;
default:
Jim_WrongNumArgs(interp, 1, argv, "?template?");
return JIM_ERR;
}
tell_posix_error:
Jim_PosixSetError(interp);
return JIM_ERR;
}
#define SELF 0
static int Jim_HwIoSchedPriorityCommand( Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
struct sched_param sched_param;
const char *policies[] = {
"other", "rr", "fifo", NULL
};
enum { OTHER, RR, FIFO };
int policy = -1;
int mypolicy;
int min, max;
jim_wide new;
int newprio = 0;
switch (argc) {
case 3: if (Jim_GetWide(interp, argv[2], &new) != JIM_OK) {
Jim_WrongNumArgs(interp, 1, argv, "invalid Priority");
return JIM_ERR;
}
newprio = 1;
case 2: if (Jim_GetEnum(interp, argv[1], policies, &policy,
"Sched Priority Policy", JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
switch (policy) {
case OTHER: policy = SCHED_OTHER ; break;
case RR: policy = SCHED_RR ; break;
case FIFO: policy = SCHED_FIFO ; break;
}
min = sched_get_priority_min(policy);
max = sched_get_priority_max(policy);
//fprintf(stderr,"mypolicy: %d min:%d max:%d new:%d newprio:%d :\n",mypolicy,min,max,(int)new,newprio);
if (( policy >= 0) && newprio && (new <0)) {
sched_param.sched_priority = max + new;
//fprintf(stderr,"priorel : %d \n",sched_param.sched_priority);
if (sched_setscheduler(SELF, policy, &sched_param))
goto tell_posix_error;
return JIM_OK;
}
if (( policy >= 0) && newprio && (new >min)) {
sched_param.sched_priority = new;
//fprintf(stderr,"prioabs: %d \n",sched_param.sched_priority);
if (sched_setscheduler(SELF, policy, &sched_param))
goto tell_posix_error;
return JIM_OK;
}
return JIM_ERR;
case 1: {
char buff[0x20];
mypolicy = sched_getscheduler(SELF);
switch (mypolicy) {
case SCHED_OTHER: mypolicy = OTHER ; break;
case SCHED_RR: mypolicy = RR ; break;
case SCHED_FIFO: mypolicy = FIFO ; break;
}
if (sched_getparam(SELF, &sched_param))
goto tell_posix_error;
sprintf(buff,"%s %d",policies[mypolicy],sched_param.sched_priority);
Jim_SetResultString(interp, buff, -1);
return JIM_OK;
}
default:
Jim_WrongNumArgs(interp, 1, argv, "?template?");
return JIM_ERR;
}
sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 10;
sched_setscheduler(0, SCHED_FIFO, &sched_param);
return JIM_OK;
tell_posix_error:
//fprintf(stderr,"telling posix error:");
Jim_PosixSetError(interp);
return JIM_ERR;
}
int Jim_OnLoad(Jim_Interp *interp)
{
Jim_InitExtension(interp);
if (Jim_PackageProvide(interp, "hwio", "0.5", JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
Jim_CreateCommand(interp, "hwio.area", Jim_HwIoAreaCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.base", Jim_HwIoBaseCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.inb" , Jim_HwIoInbCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.outb", Jim_HwIoOutbCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.inw" , Jim_HwIoInwCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.outw", Jim_HwIoOutwCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.inl" , Jim_HwIoInlCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.outl", Jim_HwIoOutlCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.wreg", Jim_HwIoWregCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.rreg", Jim_HwIoRregCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.rblk", Jim_HwIoRregBlkCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.mlock", Jim_HwIoMLockCommand, NULL, NULL);
Jim_CreateCommand(interp, "hwio.priority", Jim_HwIoSchedPriorityCommand, NULL, NULL);
// get the delay port
ioperm( 0x80, 1, 1);
return JIM_OK;
}