Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / doscmd / doscmd.h
CommitLineData
984263bc
MD
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 doscmd.h,v 2.3 1996/04/08 19:32:32 bostic Exp
31 *
32 * $FreeBSD: src/usr.bin/doscmd/doscmd.h,v 1.7.2.1 2002/04/25 11:04:51 tg Exp $
33 */
34
35
36#ifdef __NetBSD__
37#define USE_VM86
38#endif
39
40#include <sys/param.h>
41#include <sys/types.h>
42#include <sys/time.h>
43#include <sys/stat.h>
44
45#include <dirent.h>
46#include <fcntl.h>
47#include <signal.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <ucontext.h>
52#include <errno.h>
53
54#include <sys/signalvar.h>
55#include <machine/sigframe.h>
56
57#include <machine/frame.h>
58#include <machine/psl.h>
59#include <machine/npx.h>
60#ifdef USE_VM86
61#include <machine/vm86.h>
62#endif
63
64#include "register.h"
65#include "dos.h"
66#include "callback.h"
67
68#define drlton(a) ((islower((a)) ? toupper((a)) : (a)) - 'A')
69#define drntol(a) ((a) + 'A')
70
71/*
72** assorted hardware/scope constants
73*/
74
75#define MAX_AVAIL_SEG 0xa000
76
77#define MAXPORT 0x400
78
79#define N_PARALS_MAX 3
80#define N_COMS_MAX 4 /* DOS restriction (sigh) */
81
82struct vconnect_area {
83 int int_state;
84 int magic; /* 0x4242 -> PRB format */
85 u_long passthru[256>>5]; /* bitmap of INTs to handle */
86 u_long magiciret[2]; /* Bounds of "magic" IRET */
87};
88extern struct vconnect_area vconnect_area;
89#define IntState vconnect_area.int_state
90
91/* ParseBuffer.c */
92int ParseBuffer(char *, char **, int);
93
94/* bios.c */
95#define BIOSDATA ((u_char *)0x400)
96extern unsigned long rom_config;
97extern int nfloppies;
98extern int ndisks;
99extern int nserial;
100extern int nparallel;
101
102extern volatile int poll_cnt;
103void bios_init(void);
104void wakeup_poll(void);
105void reset_poll(void);
106void sleep_poll(void);
107
108/* cmos.c */
109extern time_t delta_clock;
110
111void cmos_init(void);
112
113/* config.c */
114int read_config(FILE *fp);
115
116/* cpu.c */
117void cpu_init(void);
118int emu_instr(regcontext_t *);
119void int00(regcontext_t *);
120void int01(regcontext_t *);
121void int03(regcontext_t *);
122void int0d(regcontext_t *);
123
124/* debug.c */
125extern int vflag;
126extern int tmode;
127extern FILE *debugf;
128extern int debug_flags;
129
130/* Lower 8 bits are int number */
131#define D_ALWAYS 0x0000100 /* always emit this message */
132#define D_TRAPS 0x0000200 /* trap-related activity */
133#define D_FILE_OPS 0x0000400 /* file-related activity */
134#define D_MEMORY 0x0000800 /* memory-related activity */
135#define D_HALF 0x0001000 /* "half-implemented" system calls */
136#define D_FLOAT 0x0002000 /* ??? */
137#define D_DISK 0x0004000 /* disk (not file) operations */
138#define D_TRAPS2 0x0008000
139#define D_PORT 0x0010000 /* port accesses */
140#define D_EXEC 0x0020000
141#define D_ITRAPS 0x0040000
142#define D_REDIR 0x0080000 /* redirector functions */
143#define D_PRINTER 0x0100000
144#define D_TRAPS3 0x0200000
145#define D_DEBUGIN 0x0400000
146#define D_DOSCALL 0x0800000 /* MS-DOS function results */
147#define D_XMS 0x1000000 /* XMS calls */
148#define D_EMS 0x2000000 /* EMS calls */
149#define D_VIDEO 0x4000000 /* video-related activity */
150
151#define TTYF_ECHO 0x00000001
152#define TTYF_ECHONL 0x00000003
153#define TTYF_CTRL 0x00000004
154#define TTYF_BLOCK 0x00000008
155#define TTYF_POLL 0x00000010
156#define TTYF_REDIRECT 0x00010000 /* Cannot have 0xffff bits set */
157
158#define TTYF_ALL (TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT)
159#define TTYF_BLOCKALL (TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT | TTYF_BLOCK)
160
161void unknown_int2(int, int, regcontext_t *);
162void unknown_int3(int, int, int, regcontext_t *);
163void unknown_int4(int, int, int, int, regcontext_t *);
164void fatal(const char *, ...) __printflike(1, 2);
165void debug(int, const char *, ...) __printflike(2, 3);
166void dump_regs(regcontext_t *);
167void debug_set(int);
168void debug_unset(int);
169u_long debug_isset(int);
170
171/* disktab.c */
172int map_type(int, int *, int *, int *);
173
174/* doscmd.c */
175extern int capture_fd;
176extern int dead;
177extern int xmode;
178extern int booting;
179extern int raw_kbd;
180extern int timer_disable;
181extern char cmdname[];
182extern struct timeval boot_time;
183extern unsigned long *ivec;
184
185int _prog(char *);
186void call_on_quit(void (*)(void *), void *);
187void done(regcontext_t *, int);
188void iomap_port(int, int);
189int open_prog(char *);
190void put_dosenv(const char *);
191void quit(int);
192int squirrel_fd(int);
193
194/* ems.c */
195int ems_init(void);
196void ems_entry(regcontext_t *);
197
198/* emuint.c */
199extern void emuint(regcontext_t *REGS);
200
201/* i386-pinsn.c */
202extern int i386dis(unsigned short, unsigned short,
203 unsigned char *, char *, int);
204
205/* int.c */
206void init_ints(void);
207int isinhardint(int);
208void softint(int);
209void hardint(int);
210void resume_interrupt(void);
211void unpend(int);
212void send_eoi(void);
213void set_eoir(int, void (*)(void *), void *);
214
215/* int10.c */
216extern void int10(regcontext_t *);
217
218/* int13.c */
219extern int init_hdisk(int drive, int cyl, int head, int tracksize,
220 char *file, char *boot_sector);
221extern int init_floppy(int drive, int type, char *file);
222extern int disk_fd(int drive);
223extern void make_readonly(int drive);
224extern int search_floppy(int i);
225extern void disk_bios_init(void);
226
227/* int16.c */
228void int16(regcontext_t *);
229
230/* int17.c */
231void int17(regcontext_t *);
232void lpt_poll(void);
233void printer_direct(int printer);
234void printer_spool(int printer, char *print_queue);
235void printer_timeout(int printer, char *time_out);
236
237/* int1a.c */
238void int1a(regcontext_t *);
239
240/* int2f.c */
241extern void int2f(regcontext_t *);
242
243/* intff.c */
244extern int int2f_11(regcontext_t *REGS);
245extern void intff(regcontext_t *REGS);
246
247/* mem.c */
248extern char *dosmem;
249
250extern void mem_init(void);
251extern int mem_alloc(int size, int owner, int *biggestp);
252extern int mem_adjust(int addr, int size, int *availp);
253extern void mem_free_owner(int owner);
254extern void mem_change_owner(int addr, int owner);
255
256/* mouse.c */
257void int33(regcontext_t *);
258void mouse_init(void);
259
260/* net.c */
261void net_init(void);
262
263/* port.c */
264void define_input_port_handler(int, unsigned char (*)(int));
265void define_output_port_handler(int, void (*)(int, unsigned char));
266void inb(regcontext_t *, int);
267unsigned char inb_port(int);
268unsigned char inb_speaker(int);
269unsigned char inb_traceport(int);
270void init_io_port_handlers(void);
271void insb(regcontext_t *, int);
272void insx(regcontext_t *, int);
273void inx(regcontext_t *, int);
274void outb(regcontext_t *, int);
275void outb_port(int, unsigned char);
276void outb_speaker(int, unsigned char);
277void outb_traceport(int, unsigned char);
278void outsb(regcontext_t *, int);
279void outsx(regcontext_t *, int);
280void outx(regcontext_t *, int);
281void speaker_init(void);
282
283/* setver.c */
284extern void setver(char *, short);
285extern short getver(char *);
286
287/* signal.c */
288extern struct sigframe *saved_sigframe;
289extern regcontext_t *saved_regcontext;
290extern int saved_valid;
291extern void setsignal(int s, void (*h)(struct sigframe *));
292
293/* timer.c */
294extern void timer_init(void);
295
296/* trace.c */
297extern int resettrace(regcontext_t *);
298extern void tracetrap(regcontext_t *);
299
300/* xms.c */
301extern void get_raw_extmemory_info(regcontext_t *REGS);
302extern int int2f_43(regcontext_t *REGS);
303extern void initHMA(void);
304extern void xms_init(void);
305extern u_long xms_maxsize;
306
307/****************************** dirty below here *****************************/extern int nmice;