wok annotate linld/stuff/src/HIMEM.CPP @ rev 20630
Up firefox-official (64.0), again
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jan 03 12:04:23 2019 +0100 (2019-01-03) |
parents | 65366955881f |
children | ab907169f156 |
rev | line source |
---|---|
pascal@19515 | 1 // This file is distributed under GPL |
pascal@19515 | 2 // |
pascal@19515 | 3 // High mem handling routines |
pascal@19515 | 4 // C++ part of VCPI madness is here |
pascal@19515 | 5 |
pascal@19515 | 6 #include "crtl.h" |
pascal@19515 | 7 #include "common.h" |
pascal@19515 | 8 |
pascal@19899 | 9 struct image_himem imgs[2]; |
pascal@19580 | 10 int skip_alloc; |
pascal@19571 | 11 |
pascal@19515 | 12 void load_image(struct image_himem *m) { |
pascal@19515 | 13 no_exit++; // die() won't return to DOS |
pascal@19515 | 14 m->remaining = m->size; |
pascal@19562 | 15 m->buf = m->fallback; |
pascal@19562 | 16 u32 buf; |
pascal@19538 | 17 u32* bufv= &buf; |
pascal@19580 | 18 if(((u16 *)&m->fallback)[1] >= 0x10 && !skip_alloc) { // >= _1m ? |
pascal@19538 | 19 if(vcpi) { |
pascal@20528 | 20 bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv |
pascal@19515 | 21 } |
pascal@19580 | 22 else { |
pascal@19562 | 23 xmm_alloc(m); // update m->buf |
pascal@19538 | 24 } |
pascal@19515 | 25 } |
pascal@19562 | 26 buf = m->buf; |
pascal@19538 | 27 do { |
pascal@19571 | 28 u16 size; |
pascal@20538 | 29 if(s16(size = read_image(m)) <= 0) break; |
pascal@20538 | 30 storepage(bufv); |
pascal@19571 | 31 if (bufv != &buf) next(bufv); |
pascal@19538 | 32 buf += size; |
pascal@19538 | 33 } while (*bufv); |
pascal@19515 | 34 if(m->remaining) die("Read error"); |
pascal@19538 | 35 close(m->fd2close); |
pascal@19515 | 36 } |
pascal@20538 | 37 |
pascal@20538 | 38 // Called just before rm->pm |
pascal@20538 | 39 void last_ditch() { |
pascal@20538 | 40 struct image_himem *m = ± |
pascal@20538 | 41 u32 *q; |
pascal@20538 | 42 vm2rm(); |
pascal@20538 | 43 if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ? |
pascal@20538 | 44 q = m->bufv; |
pascal@20538 | 45 if(q==0) { |
pascal@20538 | 46 // Move kernel |
pascal@20538 | 47 memcpy_image(m); |
pascal@20538 | 48 // Move initrd |
pascal@20538 | 49 memcpy_image(pm2initrd(m)); |
pascal@20538 | 50 } else { //vcpi |
pascal@20538 | 51 #if defined(__BORLANDC__) && defined(NO386) |
pascal@20538 | 52 #pragma option -3 |
pascal@20538 | 53 asm{ |
pascal@20538 | 54 .386p |
pascal@20538 | 55 } |
pascal@20538 | 56 #endif |
pascal@20538 | 57 // Move kernel |
pascal@20538 | 58 // 'Gathering' copy in chunks of PAGE_SIZE |
pascal@20538 | 59 // No risk of overlapping: kernel is copied from above to 1m mark |
pascal@20538 | 60 m->size = pm2initrd(m)->size = PAGE_SIZE; |
pascal@20543 | 61 #define ADD_PAGE(x) (*(unsigned long *)(((char *)&x)+1)+=PAGE_SIZE/256) |
pascal@20543 | 62 #define SUB_PAGE(x) (*(unsigned long *)(((char *)&x)+1)-=PAGE_SIZE/256) |
pascal@20538 | 63 reset_bufv(q); |
pascal@20538 | 64 do { |
pascal@20538 | 65 m->buf = *q; |
pascal@20538 | 66 memcpy_image(m); |
pascal@20543 | 67 next(q); ADD_PAGE(m->fallback); |
pascal@20538 | 68 } while(*q); |
pascal@20538 | 69 // Move initrd |
pascal@20538 | 70 m = pm2initrd(m); |
pascal@20538 | 71 if(((u16 *)&m->fallback)[1]) { |
pascal@20538 | 72 // This is tricky: copy initrd backwards to reduce |
pascal@20538 | 73 // risk of overlapping: use the fact that initrd is copied |
pascal@20538 | 74 // to the very top of ram |
pascal@20538 | 75 // (overlapping still can happen with more than 256mb ram) |
pascal@20538 | 76 // (generic solution for this overwrite problem, anyone?) |
pascal@20538 | 77 q=m->bufv; |
pascal@20538 | 78 reset_bufv(q); |
pascal@20538 | 79 do { |
pascal@20543 | 80 next(q); ADD_PAGE(m->fallback); |
pascal@20538 | 81 } while(*q); |
pascal@20538 | 82 do { |
pascal@20543 | 83 prev(q); SUB_PAGE(m->fallback); |
pascal@20538 | 84 m->buf = *q; |
pascal@20538 | 85 memcpy_image(m); |
pascal@20538 | 86 } while(q != m->bufv); |
pascal@20538 | 87 } |
pascal@20538 | 88 } |
pascal@20538 | 89 } |