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

linld: add quick boot switch
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 18 08:56:43 2021 +0000 (2021-02-18)
parents 5c1ce90eb1d6
children 61df94a0fa43
line source
1 // This file is distributed under GPL
2 //
3 // Common defs not belonging to CRTL
5 #define NL "\n"
6 #define VERSION_STR "0.97"
8 #if 0 // DEBUG
9 #undef NDEBUG
10 #define DEBUG
11 #define static
12 #else // not DEBUG
13 #define NDEBUG
14 #undef DEBUG
15 #endif
17 typedef unsigned long u32; typedef signed long s32;
18 typedef unsigned short u16; typedef signed short s16;
19 typedef unsigned char u8; typedef signed char s8;
21 const u16 _16k = 16*1024u;
22 const u16 _32k = 32*1024u;
23 const u32 _64k = 64*1024ul;
24 const u32 _1m = 1024ul*1024ul;
25 const u32 _32m = 32*1024ul*1024ul;
26 const u32 _64m = 64*1024ul*1024ul;
28 const PAGE_BITS = 12;
29 const PAGE_SIZE = 1<<PAGE_BITS;
30 const PAGE_MASK = PAGE_SIZE-1;
32 // WARNING!
33 // BC 3.1 bug: seg() will generate incorrect code if inlined!
34 // replaced by _dirty_ hack for now
35 // u16 seg(const void far* p) { return FP_SEG(p); }
36 inline u16 seg(const void far*) { return _DS; }
38 inline u16 ofs(const void* p) { return FP_OFF(p); }
40 extern struct image_himem {
41 int fd;
42 u32 fallback;
43 u32 size;
44 u32 remaining;
45 u32 buf;
46 u32 *bufv;
47 u32 chunk_size;
48 u16 state;
49 u16 fd2close;
50 } imgs[2];
51 #define pm (imgs[0])
52 #define initrd (imgs[1])
53 #define pm2initrd(p) (p+1)
55 extern u8 pm_low;
57 extern u32 far *initrd_desc;
58 #define cmdline (cmdstr[0])
59 #define kernel_name (cmdstr[1])
60 #define initrd_name (cmdstr[2])
61 #define isofile (cmdstr[3])
62 extern const char* cmdstr[4];
64 #define root_dev (cmdnum[0])
65 #define vid_mode (cmdnum[1]) // -3 = ask, -2 = Extended VGA, -1 = Normal VGA, n = as "n" was pressed
66 #define topmem (cmdnum[2])
67 #define base_himem (cmdnum[3])
68 #define skip_alloc (* (char *) &cmdnum[4])
69 #ifdef QUICK_BOOT
70 extern u32 cmdnum[7];
71 #else
72 extern u32 cmdnum[5];
73 #endif
75 extern _fastcall void memcpy_image_kernel();
76 extern _fastcall void memcpy_image_initrd();
77 extern _fastcall void storepage(u32 *dst);
78 extern _fastcall void reset_bufv(unsigned long *p);
79 extern "C" unsigned long* prev_bufv();
80 extern "C" unsigned long* next_bufv();
81 #define next(p) p = next_bufv()
82 #define prev(p) p = prev_bufv()
83 extern char vcpi;
84 extern char version_string[];
85 // External asm helpers
86 #ifdef WITH_XMM_ALLOC
87 extern _fastcall void xmm_alloc(struct image_himem *m);
88 #endif
89 extern "C" u32 memtop();
90 extern "C" void enable_a20_or_die();
91 extern "C" void far vm2rm();
92 extern "C" void hook_int15_88();
94 // C++ helpers
95 #ifdef DEBUG
96 extern "C" void hang();
97 #endif
99 void load_image(struct image_himem *m);
100 extern _fastcall void open_image(struct image_himem *m, const char *name);
101 extern _fastcall int read_image(struct image_himem *m);
102 void load_kernel();
103 void load_initrd();
104 extern "C" void boot_kernel();