wok view linld/stuff/src/COMMON.H @ rev 19571
linld: large image support with VCPI
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Dec 22 21:06:17 2016 +0100 (2016-12-22) |
parents | 7f92b23984dc |
children | 23fc786c04e8 |
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;
26 const PAGE_BITS = 12;
27 const PAGE_SIZE = 1<<PAGE_BITS;
28 const PAGE_MASK = PAGE_SIZE-1;
30 // WARNING!
31 // BC 3.1 bug: seg() will generate incorrect code if inlined!
32 // replaced by _dirty_ hack for now
33 // u16 seg(const void far* p) { return FP_SEG(p); }
34 inline u16 seg(const void far*) { return _DS; }
36 inline u16 ofs(const void* p) { return FP_OFF(p); }
38 extern struct image_himem {
39 int fd;
40 u32 fallback;
41 u32 size;
42 u32 remaining;
43 u32 buf;
44 u32 *bufv;
45 const char *errmsg;
46 u32 chunk_size;
47 void (*next_chunk)(struct image_himem *);
48 u16 state;
49 u16 fd2close;
50 } pm, initrd;
52 extern "C" void memcpy_image(struct image_himem *m);
53 extern "C" void storepage(u32 *dst, u16 src);
54 #ifdef LARGE_IMAGES
55 extern "C" void reset_bufv(unsigned long *p);
56 extern "C" unsigned long* prev_bufv();
57 extern "C" unsigned long* next_bufv();
58 #define next(p) p = next_bufv()
59 #define prev(p) p = prev_bufv()
60 #else
61 #define reset_bufv(p)
62 #define next(p) ++p
63 #define prev(p) --p
64 #endif
65 extern char vcpi;
66 extern const char* kernel_name;
67 extern const char* initrd_name;
68 extern const char* cmdline;
69 extern u16 root_dev;
70 extern u16 vid_mode;
71 // External asm helpers
72 extern "C" void memcpy32(u32, u16,u32, u32);
73 extern "C" void rmcpy();
74 extern "C" void set_sregs_jump_seg_ofs(u32 csip);
75 extern "C" void xmm_alloc(struct image_himem *m);
76 extern u32 topmem;
77 extern "C" u32 memtopz();
78 extern "C" u32 memtop();
79 extern "C" void enable_a20_or_die();
80 extern "C" int get_vcpi_interface();
81 extern "C" char* prepare_vcpi(void *pagebuf);
82 //extern "C" int call_pm_routine(void* f);
83 extern "C" void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs);
84 extern "C" void vm2rm();
85 extern "C" void hook_int15_88();
87 // C++ helpers
88 #ifdef DEBUG
89 extern "C" void hang();
90 #endif
92 void load_image(struct image_himem *m);
93 extern "C" void open_image(const char *name, struct image_himem *m);
94 extern "C" int read_image(struct image_himem *m, void* data, int sz);
95 char* load_kernel();
96 void load_initrd();
97 void boot_kernel();