pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / mdb / ioctl.c
blob4cc1d88389f79a16b4f00bf63d3f1fd373296730
1 /*
2 * ioctl.c for mdb -- decode an IOCTL system call
3 */
4 #include "mdb.h"
5 #ifdef SYSCALLS_SUPPORT
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <fcntl.h>
10 #include <sys/stat.h>
11 #include <minix/type.h>
12 #include <minix/callnr.h>
13 #include <minix/com.h>
14 #include <sys/ioctl.h>
15 #include <sgtty.h>
16 #include "proto.h"
18 PRIVATE int get_request;
20 PRIVATE char *rnames[] = {
21 "TIOCGETP",
22 "TIOCSETP",
23 "TIOCGETC",
24 "TIOCSETC"
27 #define GETPNAME 0
28 #define SETPNAME 1
29 #define GETCNAME 2
30 #define SETCNAME 3
32 /*
33 * decode ioctl call
34 * send or receive = 'R' or 'S'
36 void decode_ioctl(sr, m)
37 int sr;
38 message *m;
40 int rq;
41 int request, device;
42 int high;
43 long spek, flags;
44 int ispeed, ospeed, speed, erase, kill;
45 int t_intrc, t_quitc, t_startc, t_stopc, t_brk, t_eof;
47 device = m->m2_i1;
48 request = m->m2_i3;
49 spek = m->m2_l1;
50 flags = m->m2_l2;
52 #ifdef DEBUG
53 if( debug )
54 Printf("%c device=%d request=%c|%d m2_l1=%lx m2_l2=%lx\n",
55 sr,device,
56 (request >> 8) & BYTE,
57 request & BYTE,
58 spek,flags);
59 #endif
61 if ( sr == 'R') request = get_request;
63 switch(request) {
64 case TIOCGETP:
65 case TIOCSETP:
66 rq = (request == TIOCGETP) ? GETPNAME : SETPNAME;
67 if (sr == 'S') {
68 get_request = request;
69 Printf( "Sending %s ",rnames[rq] );
70 if ( request == TIOCGETP ) break;
73 if ( (sr == 'R') && (request == TIOCSETP) ) break;
75 erase = (spek >> 8) & BYTE;
76 kill = spek & BYTE;
77 flags = flags & 0xFFFF;
78 speed = (spek >> 16) & 0xFFFFL;
79 ispeed = speed & BYTE;
80 ospeed = (speed >> 8) & BYTE;
81 Printf("%s erase=%d kill=%d speed=%d/%d flags=%lx ",
82 rnames[rq], erase, kill, ispeed, ospeed, flags);
83 break;
85 case TIOCGETC:
86 case TIOCSETC:
87 rq = (request == TIOCGETC) ? GETCNAME : SETCNAME;
88 if (sr == 'S') {
89 get_request = request;
90 Printf( "Sending %s ",rnames[rq] );
91 if ( request == TIOCGETC ) break;
94 if ( (sr == 'R') && (request == TIOCSETC) ) break;
96 t_intrc = (spek >> 24) & BYTE;
97 t_quitc = (spek >> 16) & BYTE;
98 t_startc = (spek >> 8) & BYTE;
99 t_stopc = (spek >> 0) & BYTE;
100 t_brk = flags & BYTE;
101 t_eof = (flags >> 8 ) & BYTE;
102 Printf("%s int %d quit %d start %d stop %d brk %d eof %d\n",
103 rnames[rq],
104 t_intrc, t_quitc, t_startc, t_stopc, t_brk, t_eof);
105 break;
107 default:
109 #ifdef __i86 /* 16 bit */
110 if ( sr == 'S' ) {
111 Printf("Sending ");
112 get_request = request;
114 else
115 Printf("Receiving ");
117 Printf("Other IOCTL device=%d request=%c|%d\n",
118 device, (request >> 8) & BYTE, request & BYTE );
120 break;
121 #endif
123 #ifdef __i386 /* 32 bit encoding */
124 if ( sr == 'S' ) {
125 Printf("Sending (%lx) ", request);
126 get_request = request;
128 else
129 Printf("Receiving (%lx) ", request);
131 high = ( request & 0xFFFF0000 ) >> 16 ;
132 request &= _IOCTYPE_MASK;
134 Printf("Other IOCTL device=%d request=%c|%d flags=%x size =%d\n",
135 device, (request >> 8) & BYTE, request & BYTE,
136 (high & ~_IOCPARM_MASK ),
137 (high & _IOCPARM_MASK )
139 break;
140 #endif
142 Printf("\n");
146 #endif /* SYSCALLS_SUPPORT */