Silence -Wold-style-definition.
[dragonfly.git] / usr.bin / doscmd / emuint.c
blob266b5614e89eaf1cebba187aa209e069e0202ee5
1 /*-
2 * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
3 * All rights reserved.
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.
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.
28 * $FreeBSD: src/usr.bin/doscmd/emuint.c,v 1.3.2.2 2002/04/25 11:04:51 tg Exp $
29 * $DragonFly: src/usr.bin/doscmd/emuint.c,v 1.2 2003/06/17 04:29:26 dillon Exp $
32 #include <sys/param.h>
33 #include <ctype.h>
34 #include "doscmd.h"
35 #include "emuint.h"
37 /* The central entry point for the emulator interrupt. This is used by
38 * different special programs to call the emulator from VM86 space.
39 * Look at emuint.h for definitions and a list of the currently defined
40 * subfunctions.
41 * To call emuint from VM86 space do:
42 * push ax Save original ax value (*must be done* !)
43 * mov ah, funcnum Emuint function number to ah
44 * mov al, subfunc Subfunction number, optional, depening on func
45 * int 0xff
46 * ..
47 * ..
48 * Emuint saves the function and subfunction numbers internally, then
49 * pops ax off the stack and calls the function handler with the original
50 * value in ax.
52 void
53 emuint(regcontext_t *REGS)
55 u_short func, subfunc;
57 /* Remove function number from stack */
58 func = R_AH;
59 subfunc = R_AL;
61 R_AX = POP(REGS);
63 /* Call the function handler, subfunction is ignored, if unused */
64 switch (func)
66 /* The redirector call */
67 case EMU_REDIR:
68 intff(REGS);
69 break;
71 /* EMS call, used by emsdriv.sys */
72 case EMU_EMS:
74 switch (subfunc)
76 case EMU_EMS_CTL:
77 R_AX = (u_short)ems_init();
78 break;
80 case EMU_EMS_CALL:
81 ems_entry(REGS);
82 break;
84 default:
85 debug(D_ALWAYS, "Undefined subfunction for EMS call\n");
86 break;
88 break;
91 default:
92 debug(D_ALWAYS, "Emulator interrupt called with undefined function %02x\n", func);
94 /*
95 * XXX
96 * temporary backwards compatibility with instbsdi.exe
97 * remove after a while.
99 fprintf(stderr, "***\n*** WARNING - unknown emuint function\n");
100 fprintf(stderr, "*** Continuing; assuming instbsdi redirector.\n");
101 fprintf(stderr, "*** Please install the new redirector");
102 fprintf(stderr, " `redir.com' as soon as possible.\n");
103 fprintf(stderr, "*** This compatibility hack is not permanent.\n");
104 fprintf(stderr, "***\n");
105 PUSH(R_AX, REGS);
106 R_BX = R_ES;
107 R_DX = R_DI;
108 R_DI = R_DS;
109 intff(REGS);
110 break;