Permalink
Browse files

. 增强菜单项目脚本处理。(issues #165)

  比如可使用  goto :label
  • Loading branch information...
yaya
yaya committed Feb 20, 2018
1 parent 05379e7 commit 74f6c862c73a4d21e61832174f4ab2f1d7f8b12a
Showing with 70 additions and 15 deletions.
  1. +4 −0 ChangeLog_chenall.txt
  2. +4 −2 stage2/asm.S
  3. +14 −7 stage2/boot.c
  4. +4 −2 stage2/builtins.c
  5. +1 −0 stage2/shared.h
  6. +43 −4 stage2/stage2.c
@@ -1,4 +1,8 @@
更新说明:
2018-02-20(yaya)
增强菜单项目脚本处理。
比如可使用 goto :label

2017-12-05(yaya)
增强颜色赋值功能。修正color及echo帮助信息。
1. 按目标分配颜色,顺序不能乱(未选菜单 被选菜单 帮助 标题)。颜色可用占位符n替换。
@@ -14409,7 +14409,8 @@ VARIABLE(linux_data_real_addr)
.long 0

VARIABLE(linux_bzimage_tmp_addr)
.long SYSTEM_RESERVED_MEMORY
// .long SYSTEM_RESERVED_MEMORY
.long LINUX_TMP_MEMORY

ENTRY(linux_boot)

@@ -15748,7 +15749,8 @@ ENTRY(multi_boot)
* function must be at below 1M, together with real-mode functions.
*/

movl $(SYSTEM_RESERVED_MEMORY + 0x0100000), %esi
// movl $(SYSTEM_RESERVED_MEMORY + 0x0100000), %esi
movl $(LINUX_TMP_MEMORY + 0x0100000), %esi
movl $0x0100000, %edi /* 1M */
movl ABS(EXT_C(cur_addr)), %ecx
subl %esi, %ecx
@@ -645,7 +645,8 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
printf (", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);

/* we have to increase cur_addr for now... */
cur_addr += SYSTEM_RESERVED_MEMORY; /* cur_addr is above SYSTEM_RESERVED_MEMORY. */
// cur_addr += SYSTEM_RESERVED_MEMORY; /* cur_addr is above SYSTEM_RESERVED_MEMORY. */
cur_addr += LINUX_TMP_MEMORY; /* cur_addr is above LINUX_TMP_MEMORY. */

/* read text, then read data */
if (grub_read ((unsigned long long) RAW_ADDR (cur_addr), text_len, 0xedde0d90) != text_len)
@@ -686,7 +687,8 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
if (align_4k)
cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;

mbi.syms.a.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
// mbi.syms.a.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
mbi.syms.a.addr = cur_addr - LINUX_TMP_MEMORY;

*((int *) RAW_ADDR (cur_addr)) = pu.aout->a_syms;
cur_addr += sizeof (int);
@@ -786,7 +788,8 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
if (! memcheck (memaddr, memsiz))
goto failure_newline;

memaddr += SYSTEM_RESERVED_MEMORY;
// memaddr += SYSTEM_RESERVED_MEMORY;
memaddr += LINUX_TMP_MEMORY;

/* mark memory as used */
if (cur_addr < memaddr + memsiz)
@@ -819,7 +822,8 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
filepos = pu.elf->e_shoff;
if (grub_read ((unsigned long long) RAW_ADDR (cur_addr), tab_size, 0xedde0d90) == tab_size)
{
mbi.syms.e.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
// mbi.syms.e.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
mbi.syms.e.addr = cur_addr - LINUX_TMP_MEMORY;
shdr = (Elf32_Shdr *) mbi.syms.e.addr;
cur_addr += tab_size;

@@ -852,7 +856,8 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
break;
}

shdr[i].sh_addr = cur_addr - SYSTEM_RESERVED_MEMORY;
// shdr[i].sh_addr = cur_addr - SYSTEM_RESERVED_MEMORY;
shdr[i].sh_addr = cur_addr - LINUX_TMP_MEMORY;
cur_addr += sec_size;
}
}
@@ -939,9 +944,11 @@ load_module (char *module, char *arg)
mbi.mods_addr = 0x20000; /* yes, multi_boot() will move mll here. */

mll[mbi.mods_count].cmdline = (int) arg;
mll[mbi.mods_count].mod_start = cur_addr - SYSTEM_RESERVED_MEMORY;
// mll[mbi.mods_count].mod_start = cur_addr - SYSTEM_RESERVED_MEMORY;
mll[mbi.mods_count].mod_start = cur_addr - LINUX_TMP_MEMORY;
cur_addr += len;
mll[mbi.mods_count].mod_end = cur_addr - SYSTEM_RESERVED_MEMORY;
// mll[mbi.mods_count].mod_end = cur_addr - SYSTEM_RESERVED_MEMORY;
mll[mbi.mods_count].mod_end = cur_addr - LINUX_TMP_MEMORY;
mll[mbi.mods_count].pad = 0;

/* increment number of modules included */
@@ -4764,7 +4764,8 @@ fallback_func (char *arg, int flags)

fallback_entryno = (i == 0) ? -1 : 0;
if (go) return (errnum = MAX_ERR_NUM);
return 1;
// return 1;
return 0;
}

static struct builtin builtin_fallback =
@@ -17140,7 +17141,8 @@ static int goto_func(char *arg, int flags)
{
errorcheck_func ("on",0);
errnum = ERR_BAT_GOTO;
if (flags & BUILTIN_BAT_SCRIPT)//batch script return arg addr.
// if (flags & BUILTIN_BAT_SCRIPT)//batch script return arg addr.
if (*arg == ':')
{
return bat_find_label(arg);
}
@@ -48,6 +48,7 @@
*/

#define SYSTEM_RESERVED_MEMORY 0x2000000
#define LINUX_TMP_MEMORY 0x2600000

/* unifont start at 24M */
#define UNIFONT_START 0x1800000
@@ -590,9 +590,13 @@ extern int checkrange_func (char *arg1, int flags);
static int
run_script (char *script, char *heap)
{
char *old_entry = 0;
// char *old_entry = 0;
char *cur_entry = script;
struct builtin *builtin = 0;
char tmp[5] = {'!','B','A','T',0x0a};
char cmd_add[16];
char *menu_bat;
char *p;
// char *arg;
// grub_error_t errnum_old;//2010-12-16

@@ -607,6 +611,38 @@ run_script (char *script, char *heap)
errnum = 0;
errorcheck = 1; /* errorcheck on */

while (1)
{
while (*cur_entry++);
if (! *cur_entry)
break;
*(cur_entry - 1) = 0x0a;
}
menu_bat = (char *)grub_malloc(cur_entry - script + 10 + 512);
if (menu_bat == NULL)
return 0;
p = (char *)(((int)menu_bat + 511) & ~511);
grub_memmove (p, &tmp, 5);
grub_memmove (p + 5, script, cur_entry - script);
grub_sprintf (cmd_add, "(md)%d+%d", (int)p >> 9, ((cur_entry - script + 10 + 511) & ~511) >> 9);
command_func (cmd_add, 1);
grub_free(menu_bat);

if (errnum == MAX_ERR_NUM)
{
errnum=ERR_NONE;
return 0;
}
if (errnum && errorcheck)
goto ppp;

/* If any kernel is not loaded, just exit successfully. */
if (kernel_type == KERNEL_TYPE_NONE)
return 0; /* return to main menu. */
/* Otherwise, the command boot is run implicitly. */
grub_sprintf (cmd_add, "boot", 5);
run_line (cmd_add , BUILTIN_SCRIPT);
#if 0
while (1)
{
if (errnum == MAX_ERR_NUM)
@@ -671,7 +707,8 @@ run_script (char *script, char *heap)
if (! *old_entry) /* HEAP holds the implicit BOOT command */
break;
} /* while (1) */

#endif
ppp:
kernel_type = KERNEL_TYPE_NONE;

/* If a fallback entry is defined, don't prompt a user's intervention. */
@@ -2415,16 +2452,18 @@ cmain (void)

while (get_line_from_config ((char *) CMDLINE_BUF, NEW_HEAPSIZE, is_preset))
{
struct builtin *builtin;
struct builtin *builtin = 0;
char *cmdline = (char *) CMDLINE_BUF;

/* Get the pointer to the builtin structure. */
if (*cmdline == ':')
goto sss;
builtin = find_command (cmdline);
errnum = 0;
if (! builtin)
/* Unknown command. Just skip now. */
continue;

sss:
if ((int)builtin != -1 && builtin->flags == 0) /* title command */
{
if (builtin != &builtin_title)/*If title*/

0 comments on commit 74f6c86

Please sign in to comment.