wok-6.x view linld/stuff/src/COMMON.H @ rev 25035

Up libqcow (20210419)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 20 18:11:13 2022 +0000 (2022-05-20)
parents be9fc3c4c575
children
line source
1 //#define WITH_XMM_ALLOC add himem.sys driver
2 //#define INT15_E820 add int15/eax=E820 driver
3 //#define LARGE_ZIMAGE may load system in high memory temporarily
4 #define CLEAN_ISO9660 remove ';1' or '.' trailers for non rockridge name
5 #define BASIC_ISO9660 non rockridge support
6 #define ROCKRIDGE iso 9660 posix name support
7 #define ISO9660 iso= support
8 #define QUICK_BOOT /q bypass shutdown hack, /v keeps v86
9 #define ISOHOOK iso image dos boot helper
10 #define MOVE_SETUP spare few Kb in setup location for zImage system
11 #define NO386 8088 support
12 #define CPU64 /64 support
13 #define LONG_FILENAME look for Win95+ long file name too
14 #define SHUTDOWN disable int19 hooked drivers
15 #define VCPI v86 mode support with VCPI 4.0+
16 #define LINUX001 linux 0.01 support
17 #define ELKS elks support
18 #define IPXE ipxe support
19 #define CPUTYPE detect cpu family and model
20 #define MINRAM detect RAM size
21 /* End of the optional features */
23 #ifdef ISOHOOK
24 #ifndef ROCKRIDGE
25 #define ROCKRIDGE
26 #endif
27 #ifndef CPU64
28 #define CPU64
29 #endif
30 #endif
31 #if defined(ROCKRIDGE) || defined(BASIC_ISO9660) || defined(CLEAN_ISO9660)
32 #ifndef ISO9660
33 #define ISO9660
34 #endif
35 #endif
37 // This file is distributed under GPL
38 //
39 // Common defs not belonging to CRTL
41 #if defined(__BORLANDC__) && !defined(NO386)
42 #pragma option -3
43 asm{
44 .386p
45 }
46 #endif
48 #define NL "\n"
49 #define VERSION_STR "0.97"
51 #if 0 // DEBUG
52 #undef NDEBUG
53 #define DEBUG
54 #define static
55 #else // not DEBUG
56 #define NDEBUG
57 #undef DEBUG
58 #endif
60 typedef unsigned long u32; typedef signed long s32;
61 typedef unsigned short u16; typedef signed short s16;
62 typedef unsigned char u8; typedef signed char s8;
64 const u16 _16k = 16*1024u;
65 const u16 _32k = 32*1024u;
66 const u32 _64k = 64*1024ul;
67 const u32 _1m = 1024ul*1024ul;
68 const u32 _32m = 32*1024ul*1024ul;
69 const u32 _64m = 64*1024ul*1024ul;
71 const PAGE_BITS = 12;
72 const PAGE_SIZE = 1<<PAGE_BITS;
73 const PAGE_MASK = PAGE_SIZE-1;
75 // WARNING!
76 // BC 3.1 bug: seg() will generate incorrect code if inlined!
77 // replaced by _dirty_ hack for now
78 // u16 seg(const void far* p) { return FP_SEG(p); }
79 inline u16 seg(const void far*) { return _DS; }
81 inline u16 ofs(const void* p) { return FP_OFF(p); }
83 extern struct image_himem {
84 int fd;
85 u32 fallback;
86 u32 size;
87 u32 remaining;
88 u32 buf;
89 u32 *bufv;
90 u32 chunk_size;
91 u16 state;
92 u16 fd2close;
93 } imgs[2];
94 #define pm (imgs[0])
95 #define initrd (imgs[1])
96 #define pm2initrd(p) (p+1)
98 extern u8 pm_low;
100 extern u8 buf4k[4096];
102 extern u32 far *initrd_desc;
103 #ifdef ISO9660
104 #define CMDSTR_EXTRA "|iso"
105 #else
106 #define CMDSTR_EXTRA ""
107 #endif
108 #define cmdline (cmdstr[0])
109 #define kernel_name (cmdstr[1])
110 #define initrd_name (cmdstr[2])
111 #define isofile (cmdstr[3])
112 extern const char* cmdstr[4];
114 #define root_dev (cmdnum[0])
115 #define vid_mode (cmdnum[1]) // -3 = ask, -2 = Extended VGA, -1 = Normal VGA, n = as "n" was pressed
116 #define topmem (cmdnum[2])
117 #define base_himem (cmdnum[3])
118 #define CMDNUM 4
119 #define CMDNUM_EXTRA ""
120 extern u32 cmdnum[CMDNUM
121 #ifdef MINRAM
122 #define minram (cmdnum[CMDNUM])
123 #undef CMDNUM_EXTRA
124 #define CMDNUM_EXTRA "-r|"
125 #undef CMDNUM
126 #define CMDNUM 5
127 +1
128 #endif
129 #ifdef CPUTYPE
130 #define mincpu (* (short *) &cmdnum[CMDNUM])
131 #undef CMDNUM
132 #undef CMDNUM_EXTRA
133 # ifdef MINRAM
134 #define CMDNUM_EXTRA "-r|-c|"
135 #define CMDNUM 6
136 # else
137 #define CMDNUM_EXTRA "-c|"
138 #define CMDNUM 5
139 # endif
140 +1
141 #endif
142 #ifdef QUICK_BOOT
143 #undef CMDNUM
144 #undef CMDNUM_EXTRA
145 # ifdef MINRAM
146 # ifdef CPUTYPE
147 # ifdef VCPI
148 #define CMDNUM_EXTRA "-r|-c|-q~-v~"
149 #define CMDNUM 8
150 # else
151 #define CMDNUM_EXTRA "-r|-c|-q~"
152 #define CMDNUM 7
153 # endif
154 # else
155 # ifdef VCPI
156 #define CMDNUM_EXTRA "-r|-q~-v~"
157 #define CMDNUM 7
158 # else
159 #define CMDNUM_EXTRA "-r|-q~"
160 #define CMDNUM 6
161 # endif
162 # endif
163 # else
164 # ifdef CPUTYPE
165 # ifdef VCPI
166 #define CMDNUM_EXTRA "-c|-q~-v~"
167 #define CMDNUM 7
168 # else
169 #define CMDNUM_EXTRA "-c|-q~"
170 #define CMDNUM 6
171 # endif
172 # else
173 # ifdef VCPI
174 #define CMDNUM_EXTRA "-q~-v~"
175 #define CMDNUM 6
176 # else
177 #define CMDNUM_EXTRA "-q~"
178 #define CMDNUM 5
179 # endif
180 # endif
181 # endif
182 # ifdef VCPI
183 +2
184 # else
185 +1
186 # endif
187 #endif
188 #ifdef WITH_XMM_ALLOC
189 +1
190 #define skip_alloc (* (char *) &cmdnum[CMDNUM])
191 #endif
192 ];
193 #ifdef CPUTYPE
194 extern unsigned cputype;
195 #endif
197 extern _fastcall void memcpy_image_kernel();
198 extern _fastcall void memcpy_image_initrd();
199 extern _fastcall void storepage(u32 *dst);
200 extern _fastcall void reset_bufv(unsigned long *p);
201 extern "C" unsigned long* prev_bufv();
202 extern "C" unsigned long* next_bufv();
203 #define next(p) p = next_bufv()
204 #define prev(p) p = prev_bufv()
205 extern char vcpi;
206 extern char version_string[];
207 // External asm helpers
208 #ifdef WITH_XMM_ALLOC
209 extern _fastcall void xmm_alloc(struct image_himem *m);
210 #endif
211 extern "C" u32 topload();
212 extern "C" u32 memtop();
213 extern "C" void enable_a20_or_die();
214 extern "C" void far vm2rm();
215 extern "C" void hook_int15_88();
217 // C++ helpers
218 #ifdef DEBUG
219 extern "C" void hang();
220 #endif
222 void load_image(struct image_himem *m);
223 extern _fastcall void open_image(struct image_himem *m, const char *name);
224 extern _fastcall int read_image(struct image_himem *m);
225 void load_kernel();
226 void load_initrd();
227 extern "C" void boot_kernel();