]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/doscmd/emuint.c
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / usr.bin / doscmd / emuint.c
1 /*-
2  * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
3  * 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 immediately at the beginning of the file, witout modification,
10  *    this list of conditions, and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 #include <sys/param.h>
32 #include <ctype.h>
33 #include "doscmd.h"
34 #include "emuint.h"
35
36 /* The central entry point for the emulator interrupt. This is used by
37  * different special programs to call the emulator from VM86 space. 
38  * Look at emuint.h for definitions and a list of the currently defined
39  * subfunctions.
40  * To call emuint from VM86 space do:
41  *      push ax            Save original ax value (*must be done* !)
42  *      mov  ah, funcnum   Emuint function number to ah
43  *      mov  al, subfunc   Subfunction number, optional, depening on func
44  *      int  0xff               
45  *      ..
46  *      ..
47  * Emuint saves the function and subfunction numbers internally, then
48  * pops ax off the stack and calls the function handler with the original
49  * value in ax.
50  */
51 void
52 emuint(regcontext_t *REGS)
53 {
54     u_short func, subfunc;
55
56     /* Remove function number from stack */
57     func = R_AH;
58     subfunc = R_AL;
59
60     R_AX = POP(REGS);
61
62     /* Call the function handler, subfunction is ignored, if unused */
63     switch (func)
64     {
65         /* The redirector call */
66         case EMU_REDIR:
67             intff(REGS);
68             break;
69
70         /* EMS call, used by emsdriv.sys */
71         case EMU_EMS:
72         {
73             switch (subfunc) 
74             {
75                 case EMU_EMS_CTL:
76                     R_AX = (u_short)ems_init();
77                     break;
78
79                 case EMU_EMS_CALL:
80                     ems_entry(REGS);
81                     break;
82
83                 default:
84                     debug(D_ALWAYS, "Undefined subfunction for EMS call\n");
85                     break;
86             }
87             break;
88         }
89
90         default:
91             debug(D_ALWAYS, "Emulator interrupt called with undefined function %02x\n", func);
92
93             /* 
94              * XXX
95              * temporary backwards compatability with instbsdi.exe
96              * remove after a while.
97              */
98             fprintf(stderr, "***\n*** WARNING - unknown emuint function\n");
99             fprintf(stderr, "*** Continuing; assuming instbsdi redirector.\n");
100             fprintf(stderr, "*** Please install the new redirector");
101             fprintf(stderr, " `redir.com' as soon as possible.\n");
102             fprintf(stderr, "*** This compatability hack is not permanent.\n");
103             fprintf(stderr, "***\n");
104             PUSH(R_AX, REGS);
105             R_BX = R_ES;
106             R_DX = R_DI;
107             R_DI = R_DS;
108             intff(REGS);
109             break;
110     }
111 }