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"
|
---|
17 |
|
---|
18 | PRIVATE int get_request;
|
---|
19 |
|
---|
20 | PRIVATE char *rnames[] = {
|
---|
21 | "TIOCGETP",
|
---|
22 | "TIOCSETP",
|
---|
23 | "TIOCGETC",
|
---|
24 | "TIOCSETC"
|
---|
25 | };
|
---|
26 |
|
---|
27 | #define GETPNAME 0
|
---|
28 | #define SETPNAME 1
|
---|
29 | #define GETCNAME 2
|
---|
30 | #define SETCNAME 3
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * decode ioctl call
|
---|
34 | * send or receive = 'R' or 'S'
|
---|
35 | */
|
---|
36 | void decode_ioctl(sr, m)
|
---|
37 | int sr;
|
---|
38 | message *m;
|
---|
39 | {
|
---|
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;
|
---|
46 |
|
---|
47 | device = m->m2_i1;
|
---|
48 | request = m->m2_i3;
|
---|
49 | spek = m->m2_l1;
|
---|
50 | flags = m->m2_l2;
|
---|
51 |
|
---|
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
|
---|
60 |
|
---|
61 | if ( sr == 'R') request = get_request;
|
---|
62 |
|
---|
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;
|
---|
71 | }
|
---|
72 |
|
---|
73 | if ( (sr == 'R') && (request == TIOCSETP) ) break;
|
---|
74 |
|
---|
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;
|
---|
84 |
|
---|
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;
|
---|
92 | }
|
---|
93 |
|
---|
94 | if ( (sr == 'R') && (request == TIOCSETC) ) break;
|
---|
95 |
|
---|
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;
|
---|
106 |
|
---|
107 | default:
|
---|
108 |
|
---|
109 | #ifdef __i86 /* 16 bit */
|
---|
110 | if ( sr == 'S' ) {
|
---|
111 | Printf("Sending ");
|
---|
112 | get_request = request;
|
---|
113 | }
|
---|
114 | else
|
---|
115 | Printf("Receiving ");
|
---|
116 |
|
---|
117 | Printf("Other IOCTL device=%d request=%c|%d\n",
|
---|
118 | device, (request >> 8) & BYTE, request & BYTE );
|
---|
119 |
|
---|
120 | break;
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | #ifdef __i386 /* 32 bit encoding */
|
---|
124 | if ( sr == 'S' ) {
|
---|
125 | Printf("Sending (%lx) ", request);
|
---|
126 | get_request = request;
|
---|
127 | }
|
---|
128 | else
|
---|
129 | Printf("Receiving (%lx) ", request);
|
---|
130 |
|
---|
131 | high = ( request & 0xFFFF0000 ) >> 16 ;
|
---|
132 | request &= _IOCTYPE_MASK;
|
---|
133 |
|
---|
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 )
|
---|
138 | );
|
---|
139 | break;
|
---|
140 | #endif
|
---|
141 | }
|
---|
142 | Printf("\n");
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | #endif /* SYSCALLS_SUPPORT */
|
---|