xref: /illumos-gate/usr/src/boot/i386/btx/lib/btxv86.h (revision 22028508)
1199767f8SToomas Soome /*
2199767f8SToomas Soome  * Copyright (c) 1998 Robert Nordier
3199767f8SToomas Soome  * All rights reserved.
4199767f8SToomas Soome  *
5199767f8SToomas Soome  * Redistribution and use in source and binary forms are freely
6199767f8SToomas Soome  * permitted provided that the above copyright notice and this
7199767f8SToomas Soome  * paragraph and the following disclaimer are duplicated in all
8199767f8SToomas Soome  * such forms.
9199767f8SToomas Soome  *
10199767f8SToomas Soome  * This software is provided "AS IS" and without any express or
11199767f8SToomas Soome  * implied warranties, including, without limitation, the implied
12199767f8SToomas Soome  * warranties of merchantability and fitness for a particular
13199767f8SToomas Soome  * purpose.
14199767f8SToomas Soome  */
15199767f8SToomas Soome 
16199767f8SToomas Soome #ifndef _BTXV86_H_
17199767f8SToomas Soome #define _BTXV86_H_
18199767f8SToomas Soome 
19199767f8SToomas Soome #include <sys/types.h>
20199767f8SToomas Soome #include <machine/psl.h>
21199767f8SToomas Soome 
22560b2482SToomas Soome /*
23560b2482SToomas Soome  * Real memory buffer space for real mode IO.
24560b2482SToomas Soome  * Just one page is not much, but the space is rather limited.
25560b2482SToomas Soome  * See ../btx/btx.S for details.
26560b2482SToomas Soome  */
27560b2482SToomas Soome #define	V86_IO_BUFFER		0x8000
28560b2482SToomas Soome #define	V86_IO_BUFFER_SIZE	0x1000
29560b2482SToomas Soome 
30199767f8SToomas Soome #define V86_ADDR   0x10000	/* Segment:offset address */
31199767f8SToomas Soome #define V86_CALLF  0x20000	/* Emulate far call */
32199767f8SToomas Soome #define V86_FLAGS  0x40000	/* Return flags */
33199767f8SToomas Soome 
34199767f8SToomas Soome struct __v86 {
35199767f8SToomas Soome     uint32_t ctl;		/* Control flags */
36199767f8SToomas Soome     uint32_t addr;		/* Interrupt number or address */
37199767f8SToomas Soome     uint32_t es;		/* V86 ES register */
38199767f8SToomas Soome     uint32_t ds;		/* V86 DS register */
39199767f8SToomas Soome     uint32_t fs;		/* V86 FS register */
40199767f8SToomas Soome     uint32_t gs;		/* V86 GS register */
41199767f8SToomas Soome     uint32_t eax;		/* V86 EAX register */
42199767f8SToomas Soome     uint32_t ecx;		/* V86 ECX register */
43199767f8SToomas Soome     uint32_t edx;		/* V86 EDX register */
44199767f8SToomas Soome     uint32_t ebx;		/* V86 EBX register */
45199767f8SToomas Soome     uint32_t efl;		/* V86 eflags register */
46199767f8SToomas Soome     uint32_t ebp;		/* V86 EBP register */
47199767f8SToomas Soome     uint32_t esi;		/* V86 ESI register */
48199767f8SToomas Soome     uint32_t edi;		/* V86 EDI register */
49199767f8SToomas Soome };
50199767f8SToomas Soome 
51199767f8SToomas Soome extern struct __v86 __v86;	/* V86 interface structure */
52199767f8SToomas Soome void __v86int(void);
53199767f8SToomas Soome 
54199767f8SToomas Soome #define v86	__v86
55199767f8SToomas Soome #define v86int	__v86int
56199767f8SToomas Soome 
57199767f8SToomas Soome extern u_int32_t	__base;
58199767f8SToomas Soome extern u_int32_t	__args;
59199767f8SToomas Soome 
60199767f8SToomas Soome #define	PTOV(pa)	((caddr_t)(pa) - __base)
61199767f8SToomas Soome #define	VTOP(va)	((vm_offset_t)(va) + __base)
62199767f8SToomas Soome #define	VTOPSEG(va)	(u_int16_t)(VTOP((caddr_t)va) >> 4)
63199767f8SToomas Soome #define	VTOPOFF(va)	(u_int16_t)(VTOP((caddr_t)va) & 0xf)
64199767f8SToomas Soome 
65199767f8SToomas Soome #define	V86_CY(x)	((x) & PSL_C)
66199767f8SToomas Soome #define	V86_ZR(x)	((x) & PSL_Z)
67199767f8SToomas Soome 
68199767f8SToomas Soome void __exit(int) __attribute__((__noreturn__));
69199767f8SToomas Soome void __exec(caddr_t, ...);
70199767f8SToomas Soome 
71199767f8SToomas Soome #endif /* !_BTXV86_H_ */