Skip to content
Permalink
Browse files

fix initrd ERR_WONT_FIT

  • Loading branch information
chenall committed Jan 12, 2020
1 parent 2d7c4dd commit 26da0ad38b5dd6835f38406d427486abd67f2298
Showing with 19 additions and 9 deletions.
  1. +8 −4 stage2/boot.c
  2. +11 −5 stage2/builtins.c
@@ -979,18 +979,21 @@ load_initrd (char *initrd)
char *arg = initrd;
char *name = initrd;

linux_header = (struct linux_kernel_header *) (cur_addr - LINUX_SETUP_MOVE_SIZE);
//linux_header = (struct linux_kernel_header *) (cur_addr - LINUX_SETUP_MOVE_SIZE);
/*
tmp = ((linux_header->header == LINUX_MAGIC_SIGNATURE && linux_header->version >= 0x0203)
? linux_header->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);

*/
if (linux_mem_size)
moveto = linux_mem_size;
else
moveto = 0x100000000ULL;
/*
moveto = (saved_mem_upper + 0x400) << 10;
if (moveto > 0x100000000ULL)
moveto = 0x100000000ULL;

*/
top_addr = moveto;

/* XXX: Linux 2.3.xx has a bug in the memory range check, so avoid
@@ -999,9 +1002,10 @@ load_initrd (char *initrd)
worse than that of Linux 2.3.xx, so avoid the last 64kb. *sigh* */
moveto -= 0x10000;

/*
if (moveto > tmp)
moveto = tmp;

*/
moveto &= 0xfffff000;

if (debug > 2)
@@ -8045,7 +8045,7 @@ static struct builtin builtin_is64bit =
"return value bit0=PAE supported bit1=AMD64/Intel64 supported"
};


unsigned long long initrd_addr_max;
/* kernel */
static int
kernel_func (char *arg, int flags)
@@ -8125,6 +8125,9 @@ kernel_func (char *arg, int flags)

kernel_type = suggested_type;
mb_cmdline += len;
linux_header = (struct linux_kernel_header *) (cur_addr - LINUX_SETUP_MOVE_SIZE);
initrd_addr_max = (linux_header->header == LINUX_MAGIC_SIGNATURE && linux_header->version >= 0x0203)
? linux_header->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS;
return 1;
}

@@ -10851,7 +10854,10 @@ map_func (char *arg, int flags)
tmp_mem_max = 0x100000000ULL;
if (map_mem_min < 0x100000ULL)
map_mem_min = 0x100000ULL;

//fix initrd error by chenall 2020-01-04 http://bbs.wuyou.net/forum.php?mod=viewthread&tid=417786&extra=page%3D1&page=5
if (from == INITRD_DRIVE && to == 0xffff && tmp_mem_max > initrd_addr_max){ //INITRD_DRIVE
tmp_mem_max = initrd_addr_max;
}
if (mbi.flags & MB_INFO_MEM_MAP)
{
struct AddrRangeDesc *map = (struct AddrRangeDesc *) saved_mmap_addr;
@@ -11202,10 +11208,10 @@ map_func (char *arg, int flags)


// j_count(0) j_count(1) j_count(2) j_count(3)
// ©À©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©à©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©à©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©à©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©È
// ├──────────────┼───────────────────┼───────────────────┼───────────────────┤
// j_start(0) j_start(1) j_start(2) j_start(3)
// To_len
// ©«©©©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©¨©À©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©È
// ┇┅┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄├───────────────────────┤
// 0 To_statr

//Determine the start fragment
@@ -16415,7 +16421,7 @@ typedef struct _SETLOCAL {
unsigned long boot_drive;
unsigned long install_partition;
int debug;
char reserved[8];//预留位置,同时也是为了凑è¶?12字节ã€?
char reserved[8];//预留位置,同时也是为了凑足12字节
char var_str[MAX_USER_VARS<<9];//user vars only
char saved_dir[256];
char command_path[128];

0 comments on commit 26da0ad

Please sign in to comment.
You can’t perform that action at this time.