wok view linld/stuff/src/HIMEM.CPP @ rev 19562

magicpoint: add magicpoint.desktop
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 17 18:42:47 2016 +0100 (2016-12-17)
parents 31c5cbbd9380
children d934532a1be1
line source
1 // This file is distributed under GPL
2 //
3 // High mem handling routines
4 // C++ part of VCPI madness is here
6 #include "crtl.h"
7 #include "common.h"
9 int skip_xmmalloc;
10 void load_image(struct image_himem *m) {
11 no_exit++; // die() won't return to DOS
12 m->remaining = m->size;
13 m->buf = m->fallback;
14 u32 buf;
15 u32* bufv= &buf;
16 if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ?
17 if(vcpi) {
18 bufv = malloc_bufv_or_die(m); // update m->bufv
19 }
20 else if (!skip_xmmalloc) {
21 xmm_alloc(m); // update m->buf
22 }
23 }
24 buf = m->buf;
25 do {
26 u8 xfer_buf[PAGE_SIZE];
27 u16 size = read_image(m, xfer_buf, PAGE_SIZE);
28 if(s16(size) <= 0) break;
29 memcpy32(*bufv, seg(xfer_buf), ofs(xfer_buf), PAGE_SIZE);
30 if (bufv != &buf) bufv++;
31 buf += size;
32 } while (*bufv);
33 if(m->remaining) die("Read error");
34 close(m->fd2close);
35 }