Make manual page rendering easier.
[jimtcl/wkoszek.git] / jim-hwio.inoutblock.h
blob61f0098a4e261dc210eeb50f652d94b184e5f460
1 /* Jim - POSIX extension
2 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
3 * Copyright 2007 Uwe Klein Habertwedt <antirez@invece.org>
5 * $Id: jim-hwio.inoutblock.h,v 1.3 2008/02/11 17:09:39 macc Exp macc $
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * A copy of the license is also included in the source distribution
14 * of Jim, as a TXT file name called LICENSE.
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
23 static int INOUT_IN_CMDNAME(Jim_Interp *interp, int argc,
24 Jim_Obj *const *argv)
26 int idx ;
27 int addrval;
28 int *plast = NULL;
30 Jim_Obj *ret = Jim_NewListObj(interp, 0, 0);
33 for (idx=1;(idx < argc);idx++) {
34 if (HwIo_getIntsfromList(interp, argv[idx],INOUT_SIZE,plast,&addrval) != JIM_OK) {
35 Jim_WrongNumArgs(interp, 1, argv, "Format!");
36 return JIM_ERR;
38 inb(0x80);
39 Jim_ListAppendElement(interp,ret,Jim_NewIntObj(interp, INOUT_IN_OP(addrval)));
40 inb(0x80);
41 plast = &addrval;
43 Jim_SetResult(interp, ret);
44 return JIM_OK;
47 static int INOUT_OUT_CMDNAME(Jim_Interp *interp, int argc,
48 Jim_Obj *const *argv)
50 int idx ;
51 int addrval;
52 int *plast = NULL;
53 long outval;
54 int cnt = 0;
56 for (idx=1;(idx < argc);idx++) {
57 // fprintf(stderr,"argc %d idx %d\n",argc,idx);
58 if (HwIo_getIntsfromList(interp, argv[idx],INOUT_SIZE,plast,&addrval) != JIM_OK) {
59 Jim_WrongNumArgs(interp, 1, argv, "Format!");
60 return JIM_ERR;
62 plast = &addrval;
63 idx++;
64 if (idx == argc)
65 fprintf(stderr,"uneven number args @ %d\n",idx);
66 if (Jim_GetLong(interp, argv[idx], &outval) == JIM_OK) {
67 inb(0x80);
68 INOUT_OUT_OP(outval,addrval);
69 inb(0x80);
70 // fprintf(stderr,"outb:%ld @ %d\n",outval,addrval);
71 cnt++;
72 } else
73 return JIM_ERR;
74 // fprintf(stderr,"argc %d idx %d\n",argc,idx);
76 Jim_SetResult(interp, Jim_NewIntObj(interp, cnt));
77 return JIM_OK;
79 #undef INOUT_SIZE
80 #undef INOUT_IN_OP
81 #undef INOUT_OUT_OP
82 #undef INOUT_IN_CMDNAME
83 #undef INOUT_OUT_CMDNAME
84 //end