wok view linld/stuff/src/COMMON.H @ rev 24067

linld: add cpu detection
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 05 15:05:16 2021 +0000 (2021-07-05)
parents 6b6d14c9f7e9
children ef1efd2c8811
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 /* End of the optional features */
22 #ifdef ISOHOOK
23 #ifndef ROCKRIDGE
24 #define ROCKRIDGE
25 #endif
26 #ifndef CPU64
27 #define CPU64
28 #endif
29 #endif
30 #if defined(ROCKRIDGE) || defined(BASIC_ISO9660) || defined(CLEAN_ISO9660)
31 #ifndef ISO9660
32 #define ISO9660
33 #endif
34 #endif
36 // This file is distributed under GPL
37 //
38 // Common defs not belonging to CRTL
40 #if defined(__BORLANDC__) && !defined(NO386)
41 #pragma option -3
42 asm{
43 .386p
44 }
45 #endif
47 #define NL "\n"
48 #define VERSION_STR "0.97"
50 #if 0 // DEBUG
51 #undef NDEBUG
52 #define DEBUG
53 #define static
54 #else // not DEBUG
55 #define NDEBUG
56 #undef DEBUG
57 #endif
59 typedef unsigned long u32; typedef signed long s32;
60 typedef unsigned short u16; typedef signed short s16;
61 typedef unsigned char u8; typedef signed char s8;
63 const u16 _16k = 16*1024u;
64 const u16 _32k = 32*1024u;
65 const u32 _64k = 64*1024ul;
66 const u32 _1m = 1024ul*1024ul;
67 const u32 _32m = 32*1024ul*1024ul;
68 const u32 _64m = 64*1024ul*1024ul;
70 const PAGE_BITS = 12;
71 const PAGE_SIZE = 1<<PAGE_BITS;
72 const PAGE_MASK = PAGE_SIZE-1;
74 // WARNING!
75 // BC 3.1 bug: seg() will generate incorrect code if inlined!
76 // replaced by _dirty_ hack for now
77 // u16 seg(const void far* p) { return FP_SEG(p); }
78 inline u16 seg(const void far*) { return _DS; }
80 inline u16 ofs(const void* p) { return FP_OFF(p); }
82 extern struct image_himem {
83 int fd;
84 u32 fallback;
85 u32 size;
86 u32 remaining;
87 u32 buf;
88 u32 *bufv;
89 u32 chunk_size;
90 u16 state;
91 u16 fd2close;
92 } imgs[2];
93 #define pm (imgs[0])
94 #define initrd (imgs[1])
95 #define pm2initrd(p) (p+1)
97 extern u8 pm_low;
99 extern u8 buf4k[4096];
101 extern u32 far *initrd_desc;
102 #define cmdline (cmdstr[0])
103 #define kernel_name (cmdstr[1])
104 #define initrd_name (cmdstr[2])
105 #define isofile (cmdstr[3])
106 extern const char* cmdstr[4];
108 #define root_dev (cmdnum[0])
109 #define vid_mode (cmdnum[1]) // -3 = ask, -2 = Extended VGA, -1 = Normal VGA, n = as "n" was pressed
110 #define topmem (cmdnum[2])
111 #define base_himem (cmdnum[3])
112 #ifdef CPUTYPE
113 #define skip_alloc (* (char *) &cmdnum[5])
114 #define mincpu (* (short *) &cmdnum[6])
115 extern unsigned cputype;
116 #else
117 #define skip_alloc (* (char *) &cmdnum[4])
118 #endif
119 extern u32 cmdnum[5
120 #ifdef CPUTYPE
121 +1
122 #endif
123 #ifdef QUICK_BOOT
124 +2
125 #endif
126 ];
128 extern _fastcall void memcpy_image_kernel();
129 extern _fastcall void memcpy_image_initrd();
130 extern _fastcall void storepage(u32 *dst);
131 extern _fastcall void reset_bufv(unsigned long *p);
132 extern "C" unsigned long* prev_bufv();
133 extern "C" unsigned long* next_bufv();
134 #define next(p) p = next_bufv()
135 #define prev(p) p = prev_bufv()
136 extern char vcpi;
137 extern char version_string[];
138 // External asm helpers
139 #ifdef WITH_XMM_ALLOC
140 extern _fastcall void xmm_alloc(struct image_himem *m);
141 #endif
142 extern "C" u32 memtop();
143 extern "C" void enable_a20_or_die();
144 extern "C" void far vm2rm();
145 extern "C" void hook_int15_88();
147 // C++ helpers
148 #ifdef DEBUG
149 extern "C" void hang();
150 #endif
152 void load_image(struct image_himem *m);
153 extern _fastcall void open_image(struct image_himem *m, const char *name);
154 extern _fastcall int read_image(struct image_himem *m);
155 void load_kernel();
156 void load_initrd();
157 extern "C" void boot_kernel();