wok-6.x diff linld/stuff/src/LOAD.CPP @ rev 20634

linld: fix open()
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jan 08 17:51:51 2019 +0100 (2019-01-08)
parents ab907169f156
children 7f39f4ab7511
line diff
     1.1 --- a/linld/stuff/src/LOAD.CPP	Sat Jan 05 17:23:23 2019 +0100
     1.2 +++ b/linld/stuff/src/LOAD.CPP	Tue Jan 08 17:51:51 2019 +0100
     1.3 @@ -114,7 +114,6 @@
     1.4  u16 rm_size;
     1.5  static u8 pm_high;	// @ = @rm_size + 2, see JUMP.ASM
     1.6  static u8* rm_buf;	// @ = @rm_size + 3, see JUMP.ASM
     1.7 -u32 base_himem = _1m+_64k;
     1.8  struct image_himem imgs[2];
     1.9  
    1.10  // register value to launch the kernel real mode code
    1.11 @@ -125,15 +124,15 @@
    1.12  u32 csip=0x90200000;
    1.13  #define topseg() 0x9000
    1.14  #endif
    1.15 +u32 base_himem = _1m+_64k;
    1.16  
    1.17  static const char kernel_file_error[] = "Can't use kernel file";
    1.18  char* load_kernel() {
    1.19  
    1.20      struct	image_himem *m = &pm;
    1.21 -#define _base_himem	(((u32*)(m))[-1])
    1.22 -#define _rm_buf(m)	(((u8**)(m))[-3])
    1.23 -#define _pm_high	(((u8*)(m))[-7])
    1.24 -#define _rm_size	(*(u16*)((u8*)(m)-9))
    1.25 +#define _rm_buf(m)	(((u8**)(m))[-1])
    1.26 +#define _pm_high	(((u8*)(m))[-3])
    1.27 +#define _rm_size	(*(u16*)((u8*)(m)-5))
    1.28  #ifdef NO386
    1.29  #define _csip		(*(u32*)(m+2))
    1.30      *((u16 *)&csip+1)=topseg()+0x20;
    1.31 @@ -229,7 +228,7 @@
    1.32      struct image_himem *m = &pm;
    1.33      if((u16)(((m->fallback=(u32((u16(_CS)+0x1FFF)&0xF000)<<4))+m->size)>>4) >
    1.34  		 topseg() || _pm_high) {
    1.35 -        m->fallback = _base_himem;
    1.36 +        m->fallback = base_himem;
    1.37      }
    1.38  
    1.39      load_image(m);
    1.40 @@ -237,8 +236,22 @@
    1.41      return version_string;
    1.42  }
    1.43  
    1.44 +struct initrdparams_t {
    1.45 +    u32     header;         // 0202 Magic signature "HdrS"
    1.46 +    u16     version;        // 0206 Boot protocol version supported
    1.47 +    u16     realmode_switch_ofs; // 0208 Hook called just before rm->pm
    1.48 +    u16     realmode_switch_seg;
    1.49 +    u16     start_sys_seg;  // 020E
    1.50 +    u16     kernel_version; // 020C Points to kernel version string
    1.51 +    u8      type_of_loader; // 0210 Boot loader identifier
    1.52 +    u8      loadflags;      // 0211 Boot protocol option flags
    1.53 +    u16     setup_move_size;// 0212 Move to high memory size (used with hooks)
    1.54 +    u32     code32_start;   // 0214 Boot loader hook (see below)
    1.55 +    u32     initrd_buf;     // 0218 initrd load address (set by boot loader)
    1.56 +    u32     initrd_size;    // 021C initrd size (set by boot loader)
    1.57 +};
    1.58 +
    1.59  // Read initrd if needed
    1.60 -
    1.61  void load_initrd() {
    1.62      struct image_himem *m = &initrd;
    1.63      if (!initrd_name && !m->fd) return;
    1.64 @@ -259,9 +272,10 @@
    1.65      }
    1.66  
    1.67      load_image(m);
    1.68 -    struct kernelparams_t *kernelparams = &(((first1k_t*) _rm_buf(m-1))->params);
    1.69 -    if(kernelparams->header == HdrS) {
    1.70 -        kernelparams->initrd_buf  = m->fallback;
    1.71 -        kernelparams->initrd_size = m->size;
    1.72 +
    1.73 +    struct initrdparams_t *initrdparams = ((struct initrdparams_t *)&(((first1k_t*) _rm_buf(m-1))->params.header));
    1.74 +    if(initrdparams->header == HdrS) {
    1.75 +        initrdparams->initrd_buf  = m->fallback;
    1.76 +        initrdparams->initrd_size = m->size;
    1.77      }
    1.78  }