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
,
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!");
39 Jim_ListAppendElement(interp
,ret
,Jim_NewIntObj(interp
, INOUT_IN_OP(addrval
)));
43 Jim_SetResult(interp
, ret
);
47 static int INOUT_OUT_CMDNAME(Jim_Interp
*interp
, int argc
,
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!");
65 fprintf(stderr
,"uneven number args @ %d\n",idx
);
66 if (Jim_GetLong(interp
, argv
[idx
], &outval
) == JIM_OK
) {
68 INOUT_OUT_OP(outval
,addrval
);
70 // fprintf(stderr,"outb:%ld @ %d\n",outval,addrval);
74 // fprintf(stderr,"argc %d idx %d\n",argc,idx);
76 Jim_SetResult(interp
, Jim_NewIntObj(interp
, cnt
));
82 #undef INOUT_IN_CMDNAME
83 #undef INOUT_OUT_CMDNAME