]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/doscmd/int2f.c
This commit was generated by cvs2svn to compensate for changes in r76259,
[FreeBSD/FreeBSD.git] / usr.bin / doscmd / int2f.c
1 /*
2  * Copyright (c) 1992, 1993, 1996
3  *      Berkeley Software Design, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Berkeley Software
16  *      Design, Inc.
17  *
18  * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      BSDI int2f.c,v 2.2 1996/04/08 19:32:53 bostic Exp
31  *
32  * $FreeBSD$
33  */
34
35 #include "doscmd.h"
36 #include "dispatch.h"
37
38 /*
39 ** Multiplex interrupt.
40 **
41 ** subfunctions 0-0x7f reserved for DOS, some are implemented here.
42 **
43 */
44
45 /*
46 ** 2f:00 2f:01 2f:02 2f:03
47 **
48 ** Various PRINT.COM functions
49 */
50 static int
51 int2f_printer(regcontext_t *REGS)
52 {
53     debug (D_FILE_OPS, "Called printer function 0x%02x", R_AH);
54     R_AL = FUNC_NUM_IVALID;
55 }
56
57 /*
58 ** 2f:12
59 **
60 ** DOS internal functions.  Only one we support is 0x2e, and then only to
61 ** complain about it.
62 */
63 static int
64 int2f_dosinternal(regcontext_t *REGS)
65 {
66     switch (R_AL) {
67     case 0x2e:          /* XXX - GET/SET ERROR TABLE ADDRESSES */
68         switch (R_DL) {
69         case 0x00:
70         case 0x02:
71         case 0x04:
72         case 0x06:
73             debug(D_ALWAYS,"DOS program attempted to get internal error table.\n");
74             break;
75             
76         case 0x01:
77         case 0x03:
78         case 0x05:
79         case 0x07:
80         case 0x09:
81             debug(D_ALWAYS,"DOS program attempted to set error table.\n");
82             break;
83         }       
84         
85     default:
86         unknown_int4(0x2f, 0x12, R_AL, R_DL, REGS);
87         break;
88     }
89     R_AL = FUNC_NUM_IVALID;
90     return(0);
91 }
92
93 /*
94 ** 2f:16
95 **
96 ** Windows Enhanced Mode functions.  Aigh!
97 */
98 static int
99 int2f_windows(regcontext_t *REGS)
100 {
101     switch (R_AL) {
102     case 0x00:
103         R_AL = 0x00;                    /* Neither Win 3.x nor 2.x running */
104         return(0);
105
106     case 0x80:                          /* installation check */
107         tty_pause();
108         R_AL = 0x00;
109         return(0);
110
111     default:
112         unknown_int3(0x2f, 0x16, R_AL, REGS);
113         break;
114     }
115     R_AL = FUNC_NUM_IVALID;
116     return(0);
117 }
118
119 /*
120 ** 2f:43
121 **
122 ** XMS interface
123 */
124 static int
125 int2f_xms(regcontext_t *REGS)
126 {
127     switch(R_AL) {
128     case 0:                     /* installation check */
129         return(0);              /* %al = 0 */
130     default:
131         R_AL = FUNC_NUM_IVALID;
132         return(0);
133     }
134 }
135         
136
137 static struct intfunc_table int2f_table[] = {
138
139     { 0x00,     IFT_NOSUBFUNC,  int2f_printer,          "printer"},
140     { 0x01,     IFT_NOSUBFUNC,  int2f_printer,          "printer"},
141     { 0x02,     IFT_NOSUBFUNC,  int2f_printer,          "printer"},
142     { 0x03,     IFT_NOSUBFUNC,  int2f_printer,          "printer"},
143     { 0x12,     IFT_NOSUBFUNC,  int2f_dosinternal,      "DOS internal function"},
144     { 0x16,     IFT_NOSUBFUNC,  int2f_windows,          "Windows detect"},
145     { 0x43,     IFT_NOSUBFUNC,  int2f_xms,              "XMS"},
146     { -1,       0,              NULL,                   NULL}
147 };
148
149 /*
150 ** int2f (multiplex) handler.
151 **
152 ** Note that due to the widely varied and inconsistent conventions, handlers
153 ** called from here are expected to manage their own return values.
154 */
155 void
156 int2f(regcontext_t *REGS)
157 {
158     int         index;
159    
160     /* look up the handler for the current function */
161     index = intfunc_search(int2f_table, R_AH, R_AL);
162
163     if (index >= 0) {           /* respond on multiplex chain */
164         int2f_table[index].handler(REGS);
165     } else {
166         unknown_int2(0x2f, R_AH, REGS);
167     }
168 }
169
170
171