wok-current view linld/stuff/src/COMMON.H @ rev 19905
Up backup-manager (0.7.13)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Apr 10 09:25:19 2017 +0200 (2017-04-10) |
parents | 485b1db348fd |
children | a5b6457fb890 |
line source
1 // This file is distributed under GPL
2 //
3 // Common defs not belonging to CRTL
5 #define NL "\r\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 const char *errmsg;
48 u32 chunk_size;
49 void (*next_chunk)(struct image_himem *);
50 u16 state;
51 u16 fd2close;
52 } imgs[2];
53 #define pm (imgs[0])
54 #define initrd (imgs[1])
56 extern int skip_alloc;
57 extern u32 base_himem;
59 extern "C" void memcpy_image(struct image_himem *m);
60 extern "C" void storepage(u32 *dst, u16 src);
61 #ifdef LARGE_IMAGES
62 extern "C" void reset_bufv(unsigned long *p);
63 extern "C" unsigned long* prev_bufv();
64 extern "C" unsigned long* next_bufv();
65 #define next(p) p = next_bufv()
66 #define prev(p) p = prev_bufv()
67 #else
68 #define reset_bufv(p)
69 #define next(p) ++p
70 #define prev(p) --p
71 #endif
72 extern char vcpi;
73 extern const char* kernel_name;
74 extern const char* initrd_name;
75 extern const char* cmdline;
76 extern u16 root_dev;
77 extern u16 vid_mode;
78 // External asm helpers
79 extern "C" void memcpy32(u32, u16,u32, u32);
80 extern "C" void rmcpy();
81 extern "C" void xmm_alloc(struct image_himem *m);
82 extern u32 topmem;
83 extern "C" u32 memtopz();
84 extern "C" u32 memtop();
85 extern "C" void enable_a20_or_die();
86 extern "C" int get_vcpi_interface();
87 extern "C" char* prepare_vcpi(void *pagebuf);
88 //extern "C" int call_pm_routine(void* f);
89 extern "C" void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs);
90 extern "C" void vm2rm();
91 extern "C" void hook_int15_88();
93 // C++ helpers
94 #ifdef DEBUG
95 extern "C" void hang();
96 #endif
98 void load_image(struct image_himem *m);
99 extern "C" void open_image(const char *name, struct image_himem *m);
100 extern "C" int read_image(struct image_himem *m, void* data, int sz);
101 char* load_kernel();
102 void load_initrd();
103 extern "C" void boot_kernel();