|
|
1.1 root 1: /*
2: * Copyright (c) 1995-1994 The University of Utah and
3: * the Computer Systems Laboratory at the University of Utah (CSL).
4: * All rights reserved.
5: *
6: * Permission to use, copy, modify and distribute this software is hereby
7: * granted provided that (1) source code retains these copyright, permission,
8: * and disclaimer notices, and (2) redistributions including binaries
9: * reproduce the notices in supporting documentation, and (3) all advertising
10: * materials mentioning features or use of this software display the following
11: * acknowledgement: ``This product includes software developed by the
12: * Computer Systems Laboratory at the University of Utah.''
13: *
14: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
15: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
16: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17: *
18: * CSL requests users of this software to return to [email protected] any
19: * improvements that they make and grant CSL redistribution rights.
20: *
21: * Author: Bryan Ford, University of Utah CSL
22: */
23: #ifndef _I16DOS_H_
24: #define _I16DOS_H_
25:
26: #include <mach/inline.h>
27: #include <mach/machine/far_ptr.h>
28:
29:
30: /* Returns 16-bit DOS version number:
31: major version number in high byte, minor in low byte. */
32: MACH_INLINE unsigned short i16_dos_version(void)
33: {
34: unsigned short dos_version_swapped;
35: asm volatile("int $0x21" : "=a" (dos_version_swapped) : "a" (0x3000));
36: return (dos_version_swapped >> 8) | (dos_version_swapped << 8);
37: }
38:
39: MACH_INLINE void i16_dos_putchar(int c)
40: {
41: asm volatile("int $0x21" : : "a" (0x0200), "d" (c));
42: }
43:
44: MACH_INLINE void i16_dos_exit(int rc)
45: {
46: asm volatile("int $0x21" : : "a" (0x4c00 | (rc & 0xff)));
47: }
48:
49: MACH_INLINE void i16_dos_get_int_vec(int vecnum, struct far_pointer_16 *out_vec)
50: {
51: asm volatile("
52: pushw %%es
53: int $0x21
54: movw %%es,%0
55: popw %%es
56: " : "=r" (out_vec->seg), "=b" (out_vec->ofs)
57: : "a" (0x3500 | vecnum));
58: }
59:
60: MACH_INLINE void i16_dos_set_int_vec(int vecnum, struct far_pointer_16 *new_vec)
61: {
62: asm volatile("
63: pushw %%ds
64: movw %1,%%ds
65: int $0x21
66: popw %%ds
67: " :
68: : "a" (0x2500 | vecnum),
69: "r" (new_vec->seg), "d" (new_vec->ofs));
70: }
71:
72: /* Open a DOS file and return the new file handle.
73: Returns -1 if an error occurs. */
74: MACH_INLINE int i16_dos_open(const char *filename, int access)
75: {
76: int fh;
77: asm volatile("
78: int $0x21
79: jnc 1f
80: movl $-1,%%eax
81: 1:
82: " : "=a" (fh) : "a" (0x3d00 | access), "d" (filename));
83: return fh;
84: }
85:
86: MACH_INLINE void i16_dos_close(int fh)
87: {
88: asm volatile("int $0x21" : : "a" (0x3e00), "b" (fh));
89: }
90:
91: MACH_INLINE int i16_dos_get_device_info(int fh)
92: {
93: int info_word;
94: asm volatile("
95: int $0x21
96: jnc 1f
97: movl $-1,%%edx
98: 1:
99: " : "=d" (info_word) : "a" (0x4400), "b" (fh), "d" (0));
100: return info_word;
101: }
102:
103: MACH_INLINE int i16_dos_get_output_status(int fh)
104: {
105: int status;
106: asm volatile("
107: int $0x21
108: movzbl %%al,%%eax
109: jnc 1f
110: movl $-1,%%eax
111: 1:
112: " : "=a" (status) : "a" (0x4407), "b" (fh));
113: return status;
114: }
115:
116: MACH_INLINE int i16_dos_alloc(unsigned short *inout_paras)
117: {
118: int seg;
119: asm volatile("
120: int $0x21
121: jnc 1f
122: movl $-1,%%eax
123: 1:
124: " : "=a" (seg), "=b" (*inout_paras)
125: : "a" (0x4800), "b" (*inout_paras));
126: return seg;
127: }
128:
129: MACH_INLINE int i16_dos_free(unsigned short seg)
130: {
131: asm volatile("
132: pushw %%es
133: movw %1,%%es
134: int $0x21
135: popw %%es
136: " : : "a" (0x4900), "r" (seg) : "eax");
137: }
138:
139: MACH_INLINE unsigned short i16_dos_get_psp_seg(void)
140: {
141: unsigned short psp_seg;
142: asm volatile("int $0x21" : "=b" (psp_seg) : "a" (0x6200));
143: return psp_seg;
144: }
145:
146: #endif _I16DOS_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.