libpayload: Add PDCurses and ncurses' libform/libmenu
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / dos / pdcdos.h
1 /* Public Domain Curses */
2
3 /* $Id: pdcdos.h,v 1.30 2008/07/13 16:08:17 wmcbrine Exp $ */
4
5 #include <curspriv.h>
6 #include <string.h>
7
8 #if defined(_MSC_VER) || defined(_QC)
9 # define MSC 1
10 #endif
11
12 #if defined(__PACIFIC__) && !defined(__SMALL__)
13 # define __SMALL__
14 #endif
15
16 #if defined(__HIGHC__) || MSC
17 # include <bios.h>
18 #endif
19
20 /*----------------------------------------------------------------------
21  *  MEMORY MODEL SUPPORT:
22  *
23  *  MODELS
24  *    TINY    cs,ds,ss all in 1 segment (not enough memory!)
25  *    SMALL   cs:1 segment, ds:1 segment
26  *    MEDIUM  cs:many segments, ds:1 segment
27  *    COMPACT cs:1 segment, ds:many segments
28  *    LARGE   cs:many segments, ds:many segments
29  *    HUGE    cs:many segments, ds:segments > 64K
30  */
31
32 #ifdef __TINY__
33 # define SMALL 1
34 #endif
35 #ifdef __SMALL__
36 # define SMALL 1
37 #endif
38 #ifdef __MEDIUM__
39 # define MEDIUM 1
40 #endif
41 #ifdef __COMPACT__
42 # define COMPACT 1
43 #endif
44 #ifdef __LARGE__
45 # define LARGE 1
46 #endif
47 #ifdef __HUGE__
48 # define HUGE 1
49 #endif
50
51 #include <dos.h>
52
53 extern unsigned char *pdc_atrtab;
54 extern int pdc_adapter;
55 extern int pdc_scrnmode;
56 extern int pdc_font;
57 extern bool pdc_direct_video;
58 extern bool pdc_bogus_adapter;
59 extern unsigned pdc_video_seg;
60 extern unsigned pdc_video_ofs;
61
62 #ifdef __DJGPP__        /* Note: works only in plain DOS... */
63 # if DJGPP == 2
64 #  define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
65 # else
66 #  define _FAR_POINTER(s,o) (0xe0000000 + (((int)(s)) << 4) + ((int)(o)))
67 # endif
68 # define _FP_SEGMENT(p)     (unsigned short)((((long)p) >> 4) & 0xffff)
69 #else
70 # ifdef __TURBOC__
71 #  define _FAR_POINTER(s,o) MK_FP(s,o)
72 # else
73 #  if defined(__WATCOMC__) && defined(__FLAT__)
74 #   define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
75 #  else
76 #   define _FAR_POINTER(s,o) (((long)s << 16) | (long)o)
77 #  endif
78 # endif
79 # define _FP_SEGMENT(p)     (unsigned short)(((long)p) >> 4)
80 #endif
81 #define _FP_OFFSET(p)       ((unsigned short)p & 0x000f)
82
83 #ifdef __DJGPP__
84 # include <sys/movedata.h>
85 unsigned char getdosmembyte(int offs);
86 unsigned short getdosmemword(int offs);
87 unsigned long getdosmemdword(int offs);
88 void setdosmembyte(int offs, unsigned char b);
89 void setdosmemword(int offs, unsigned short w);
90 #else
91 # if SMALL || MEDIUM || MSC
92 #  define PDC_FAR far
93 # else
94 #  define PDC_FAR
95 # endif
96 # define getdosmembyte(offs) \
97     (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)))
98 # define getdosmemword(offs) \
99     (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)))
100 # define getdosmemdword(offs) \
101     (*((unsigned long PDC_FAR *) _FAR_POINTER(0,offs)))
102 # define setdosmembyte(offs,x) \
103     (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
104 # define setdosmemword(offs,x) \
105     (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
106 #endif
107
108 #if defined(__WATCOMC__) && defined(__386__)
109
110 typedef union
111 {
112     struct
113     {
114         unsigned long edi, esi, ebp, res, ebx, edx, ecx, eax;
115     } d;
116
117     struct
118     {
119         unsigned short di, di_hi, si, si_hi, bp, bp_hi, res, res_hi,
120                        bx, bx_hi, dx, dx_hi, cx, cx_hi, ax, ax_hi, 
121                        flags, es, ds, fs, gs, ip, cs, sp, ss;
122     } w;
123
124     struct
125     {
126         unsigned char edi[4], esi[4], ebp[4], res[4],
127                       bl, bh, ebx_b2, ebx_b3, dl, dh, edx_b2, edx_b3,
128                       cl, ch, ecx_b2, ecx_b3, al, ah, eax_b2, eax_b3;
129     } h;
130 } pdc_dpmi_regs;
131
132 void PDC_dpmi_int(int, pdc_dpmi_regs *);
133
134 #endif
135
136 #ifdef __DJGPP__
137 # include <dpmi.h>
138 # define PDCREGS __dpmi_regs
139 # define PDCINT(vector, regs) __dpmi_int(vector, &regs)
140 #else
141 # ifdef __WATCOMC__
142 #  ifdef __386__
143 #   define PDCREGS pdc_dpmi_regs
144 #   define PDCINT(vector, regs) PDC_dpmi_int(vector, &regs)
145 #  else
146 #   define PDCREGS union REGPACK
147 #   define PDCINT(vector, regs) intr(vector, &regs)
148 #  endif
149 # else
150 #  define PDCREGS union REGS
151 #  define PDCINT(vector, regs) int86(vector, &regs, &regs)
152 # endif
153 #endif
154
155 /* Wide registers in REGS: w or x? */
156
157 #ifdef __WATCOMC__
158 # define W w
159 #else
160 # define W x
161 #endif
162
163 /* Monitor (terminal) type information */
164
165 enum
166 {
167     _NONE, _MDA, _CGA,
168     _EGACOLOR = 0x04, _EGAMONO,
169     _VGACOLOR = 0x07, _VGAMONO,
170     _MCGACOLOR = 0x0a, _MCGAMONO,
171     _MDS_GENIUS = 0x30
172 };
173
174 /* Text-mode font size information */
175
176 enum
177 {
178     _FONT8 = 8,
179     _FONT14 = 14,
180     _FONT15,    /* GENIUS */
181     _FONT16
182 };
183
184 #ifdef __PACIFIC__
185 void movedata(unsigned, unsigned, unsigned, unsigned, unsigned);
186 #endif