summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd/doscmd.h
blob: 8d5af631e5b5c2cbc5795722c346f3bf95bec026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
 * Copyright (c) 1992, 1993, 1996
 *	Berkeley Software Design, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Berkeley Software
 *	Design, Inc.
 *
 * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	BSDI doscmd.h,v 2.3 1996/04/08 19:32:32 bostic Exp
 *
 * $FreeBSD$
 */


#ifdef __NetBSD__
#define USE_VM86
#endif

#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>

#include <dirent.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <sys/signalvar.h>
#include <machine/sigframe.h>

#include <machine/frame.h>
#include <machine/psl.h>
#include <machine/npx.h>
#ifdef USE_VM86
#include <machine/vm86.h>
#endif

#include "register.h"
#include "dos.h"
#include "callback.h"
#include "cwd.h"

#define drlton(a)	((islower((a)) ? toupper((a)) : (a)) - 'A')
#define drntol(a)	((a) + 'A')

/* 
** assorted hardware/scope constants 
*/

#define	MAX_AVAIL_SEG	0xa000

#define MAXPORT		0x400

#define N_PARALS_MAX	3
#define N_COMS_MAX	4	/* DOS restriction (sigh) */

struct vconnect_area {
        int     int_state;
        int     magic;                  /* 0x4242 -> PRB format */
        u_long  passthru[256>>5];       /* bitmap of INTs to handle */
        u_long  magiciret[2];           /* Bounds of "magic" IRET */
};
extern struct vconnect_area vconnect_area;
#define IntState vconnect_area.int_state


/* debug.c */
extern int	vflag;
extern int	tmode;
extern FILE	*debugf;
extern int	debug_flags;

/* Lower 8 bits are int number */
#define D_ALWAYS 	0x0000100	/* always emit this message */
#define D_TRAPS 	0x0000200	/* trap-related activity */
#define D_FILE_OPS	0x0000400	/* file-related activity */
#define D_MEMORY	0x0000800	/* memory-related activity */
#define D_HALF		0x0001000 	/* for "half-implemented" system calls */
#define	D_FLOAT		0x0002000	/* ??? */
#define	D_DISK		0x0004000	/* disk (not file) operations */
#define	D_TRAPS2	0x0008000
#define	D_PORT		0x0010000	/* port accesses */
#define	D_EXEC		0x0020000
#define	D_ITRAPS	0x0040000
#define	D_REDIR		0x0080000	/* redirector functions */
#define	D_PRINTER	0x0100000
#define	D_TRAPS3	0x0200000
#define	D_DEBUGIN	0x0400000
#define D_DOSCALL	0x0800000	/* MS-DOS function results */
#define D_XMS		0x1000000	/* XMS calls */
#define D_EMS		0x2000000	/* EMS calls */

#define	TTYF_ECHO	0x00000001
#define	TTYF_ECHONL	0x00000003
#define	TTYF_CTRL	0x00000004
#define	TTYF_BLOCK	0x00000008
#define	TTYF_POLL	0x00000010
#define	TTYF_REDIRECT	0x00010000	/* Cannot have 0xffff bits set */

#define	TTYF_ALL	(TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT)
#define	TTYF_BLOCKALL	(TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT | TTYF_BLOCK)

extern void	unknown_int2(int, int, regcontext_t *REGS);
extern void	unknown_int3(int, int, int, regcontext_t *REGS);
extern void	unknown_int4(int, int, int, int, regcontext_t *REGS);
extern void	fatal (char *fmt, ...);
extern void	debug (int flags, char *fmt, ...);
extern void	dump_regs(regcontext_t *REGS);
extern void	debug_set(int x);
extern void	debug_unset(int x);
extern u_long	debug_isset(int x);

/* doscmd.c */
extern int		capture_fd;
extern int		dead;
extern int		xmode;
extern int		booting;
extern int		raw_kbd;
extern int		timer_disable;
extern char		cmdname[];
extern struct timeval	boot_time;
extern unsigned long	*ivec;

extern int		open_prog(char *name);
extern void		done(regcontext_t *REGS, int val);
extern void 		quit(int);
extern void		call_on_quit(void (*)(void *), void *);
extern void		iomap_port(int port, int count);
 
/* signal.c */
extern struct sigframe	*saved_sigframe;
extern regcontext_t	*saved_regcontext;
extern int		saved_valid;
extern void		setsignal(int s, void (*h)(struct sigframe *));

/* cmos.c */
extern time_t	delta_clock;

extern void	cmos_init(void);

/* config.c */
extern int	read_config(FILE *fp);

/* tty.c */
extern char	*xfont;

/* setver.c */
extern void	setver(char *, short);
extern short	getver(char *);

/* mem.c */
extern char	*dosmem;

extern void	mem_init(void);
extern int	mem_alloc(int size, int owner, int *biggestp);
extern int	mem_adjust(int addr, int size, int *availp);
extern void	mem_free_owner(int owner);
extern void	mem_change_owner(int addr, int owner);


/* intff.c */
extern int	int2f_11(regcontext_t *REGS);
extern void	intff(regcontext_t *REGS);

/* emuint.c */
extern void	emuint(regcontext_t *REGS);

/* trap.c */
extern void	fake_int(regcontext_t *REGS, int);
extern void	sigtrap(struct sigframe *sf);
extern void	sigtrace(struct sigframe *sf);
extern void	sigalrm(struct sigframe *sf);
extern void	sigill(struct sigframe *sf);
extern void	sigfpe(struct sigframe *sf);
extern void	breakpoint(struct sigframe *sf);
#ifdef USE_VM86
extern void	sigurg(struct sigframe *sf);
#else
extern void	sigbus(struct sigframe *sf);
#endif

/* int.c */
extern void	softint(int intnum);
extern void	hardint(int intnum);

extern void	delay_interrupt(int intnum, void (*func)(int));
extern void	resume_interrupt(void);


/* bios.c */
#define	BIOSDATA	((u_char *)0x400)
extern unsigned long	rom_config;
extern int nfloppies;
extern int ndisks;
extern int nserial;
extern int nparallel;

extern volatile int	poll_cnt;
extern void		wakeup_poll(void);
extern void		reset_poll(void);
extern void		sleep_poll(void);

/* int13.c */
extern int	init_hdisk(int drive, int cyl, int head, int tracksize,
			   char *file, char *boot_sector);
extern int	init_floppy(int drive, int type, char *file);
extern int	disk_fd(int drive);
extern void	make_readonly(int drive);
extern int	search_floppy(int i);
extern void	disk_bios_init(void);

/* int17.c */
extern void	lpt_poll(void);
extern void	printer_direct(int printer);
extern void	printer_spool(int printer, char *print_queue);
extern void	printer_timeout(int printer, char *time_out);

/* xms.c */
extern int	int2f_43(regcontext_t *REGS);
extern void	get_raw_extmemory_info(regcontext_t *REGS);
extern void	initHMA(void);
extern u_long	xms_maxsize;

/* ems.c */
extern int ems_init();
extern void ems_entry(regcontext_t *REGS);
extern u_long ems_frame_addr;

/****************************** dirty below here ******************************/

extern u_long	pending[];		/* pending interrupts */
extern int	n_pending;

u_char	*VREG;

extern int nmice;

extern int redirect0;
extern int redirect1; 
extern int redirect2;
extern int kbd_fd;
extern int jmp_okay;



void put_dosenv(char *value);


/* TTY subsystem   XXX rewrite! */
int tty_eread(REGISTERS, int, int);
void tty_write(int, int);
void tty_rwrite(int, int, int);
void tty_move(int, int);
void tty_report(int *, int *);
void tty_flush();
void tty_index();
void tty_pause();
int tty_peek(REGISTERS, int);
int tty_state();
void tty_scroll(int, int, int, int, int, int);
void tty_rscroll(int, int, int, int, int, int);
int tty_char(int, int);
void video_setborder(int);

void outb_traceport(int, unsigned char);
unsigned char inb_traceport(int);
void outb_port(int, unsigned char);
unsigned char inb_port(int);

OpenPOWER on IntegriCloud