wok-current annotate linld/stuff/src/COMMON.H @ rev 19900
linld/tazboot: memcpy32 bug workaround
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Apr 08 18:04:44 2017 +0200 (2017-04-08) |
parents | 9e8f9b54bd83 |
children | 485b1db348fd |
rev | line source |
---|---|
pascal@19515 | 1 // This file is distributed under GPL |
pascal@19515 | 2 // |
pascal@19515 | 3 // Common defs not belonging to CRTL |
pascal@19515 | 4 |
pascal@19515 | 5 #define NL "\r\n" |
pascal@19515 | 6 #define VERSION_STR "0.97" |
pascal@19515 | 7 |
pascal@19515 | 8 #if 0 // DEBUG |
pascal@19515 | 9 #undef NDEBUG |
pascal@19515 | 10 #define DEBUG |
pascal@19515 | 11 #define static |
pascal@19515 | 12 #else // not DEBUG |
pascal@19515 | 13 #define NDEBUG |
pascal@19515 | 14 #undef DEBUG |
pascal@19515 | 15 #endif |
pascal@19515 | 16 |
pascal@19515 | 17 typedef unsigned long u32; typedef signed long s32; |
pascal@19515 | 18 typedef unsigned short u16; typedef signed short s16; |
pascal@19515 | 19 typedef unsigned char u8; typedef signed char s8; |
pascal@19515 | 20 |
pascal@19515 | 21 const u16 _16k = 16*1024u; |
pascal@19515 | 22 const u16 _32k = 32*1024u; |
pascal@19515 | 23 const u32 _64k = 64*1024ul; |
pascal@19515 | 24 const u32 _1m = 1024ul*1024ul; |
pascal@19580 | 25 const u32 _32m = 32*1024ul*1024ul; |
pascal@19580 | 26 const u32 _64m = 64*1024ul*1024ul; |
pascal@19515 | 27 |
pascal@19515 | 28 const PAGE_BITS = 12; |
pascal@19515 | 29 const PAGE_SIZE = 1<<PAGE_BITS; |
pascal@19515 | 30 const PAGE_MASK = PAGE_SIZE-1; |
pascal@19515 | 31 |
pascal@19515 | 32 // WARNING! |
pascal@19515 | 33 // BC 3.1 bug: seg() will generate incorrect code if inlined! |
pascal@19515 | 34 // replaced by _dirty_ hack for now |
pascal@19515 | 35 // u16 seg(const void far* p) { return FP_SEG(p); } |
pascal@19515 | 36 inline u16 seg(const void far*) { return _DS; } |
pascal@19515 | 37 |
pascal@19515 | 38 inline u16 ofs(const void* p) { return FP_OFF(p); } |
pascal@19515 | 39 |
pascal@19515 | 40 extern struct image_himem { |
pascal@19515 | 41 int fd; |
pascal@19515 | 42 u32 fallback; |
pascal@19515 | 43 u32 size; |
pascal@19515 | 44 u32 remaining; |
pascal@19515 | 45 u32 buf; |
pascal@19515 | 46 u32 *bufv; |
pascal@19515 | 47 const char *errmsg; |
pascal@19515 | 48 u32 chunk_size; |
pascal@19515 | 49 void (*next_chunk)(struct image_himem *); |
pascal@19515 | 50 u16 state; |
pascal@19538 | 51 u16 fd2close; |
pascal@19899 | 52 } imgs[2]; |
pascal@19899 | 53 #define pm (imgs[0]) |
pascal@19899 | 54 #define initrd (imgs[1]) |
pascal@19515 | 55 |
pascal@19580 | 56 extern int skip_alloc; |
pascal@19580 | 57 extern u32 base_himem; |
pascal@19580 | 58 |
pascal@19571 | 59 extern "C" void memcpy_image(struct image_himem *m); |
pascal@19571 | 60 extern "C" void storepage(u32 *dst, u16 src); |
pascal@19571 | 61 #ifdef LARGE_IMAGES |
pascal@19571 | 62 extern "C" void reset_bufv(unsigned long *p); |
pascal@19571 | 63 extern "C" unsigned long* prev_bufv(); |
pascal@19571 | 64 extern "C" unsigned long* next_bufv(); |
pascal@19571 | 65 #define next(p) p = next_bufv() |
pascal@19571 | 66 #define prev(p) p = prev_bufv() |
pascal@19571 | 67 #else |
pascal@19571 | 68 #define reset_bufv(p) |
pascal@19571 | 69 #define next(p) ++p |
pascal@19571 | 70 #define prev(p) --p |
pascal@19571 | 71 #endif |
pascal@19515 | 72 extern char vcpi; |
pascal@19515 | 73 extern const char* kernel_name; |
pascal@19515 | 74 extern const char* initrd_name; |
pascal@19515 | 75 extern const char* cmdline; |
pascal@19515 | 76 extern u16 root_dev; |
pascal@19515 | 77 extern u16 vid_mode; |
pascal@19515 | 78 // External asm helpers |
pascal@19538 | 79 extern "C" void memcpy32(u32, u16,u32, u32); |
pascal@19571 | 80 extern "C" void rmcpy(); |
pascal@19900 | 81 extern "C" void set_sregs_jump_seg_ofs(); |
pascal@19538 | 82 extern "C" void xmm_alloc(struct image_himem *m); |
pascal@19515 | 83 extern u32 topmem; |
pascal@19515 | 84 extern "C" u32 memtopz(); |
pascal@19515 | 85 extern "C" u32 memtop(); |
pascal@19515 | 86 extern "C" void enable_a20_or_die(); |
pascal@19515 | 87 extern "C" int get_vcpi_interface(); |
pascal@19515 | 88 extern "C" char* prepare_vcpi(void *pagebuf); |
pascal@19515 | 89 //extern "C" int call_pm_routine(void* f); |
pascal@19538 | 90 extern "C" void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs); |
pascal@19515 | 91 extern "C" void vm2rm(); |
pascal@19515 | 92 extern "C" void hook_int15_88(); |
pascal@19515 | 93 |
pascal@19515 | 94 // C++ helpers |
pascal@19515 | 95 #ifdef DEBUG |
pascal@19515 | 96 extern "C" void hang(); |
pascal@19515 | 97 #endif |
pascal@19515 | 98 |
pascal@19515 | 99 void load_image(struct image_himem *m); |
pascal@19515 | 100 extern "C" void open_image(const char *name, struct image_himem *m); |
pascal@19515 | 101 extern "C" int read_image(struct image_himem *m, void* data, int sz); |
pascal@19515 | 102 char* load_kernel(); |
pascal@19515 | 103 void load_initrd(); |
pascal@19515 | 104 void boot_kernel(); |