Permalink
Browse files

. 允许批处理文件加载 kernel、initrd,会产生错误。(issue #141)

  修正卷标显示。
  增加32位色转4色模块。
  • Loading branch information...
yaya
yaya committed May 15, 2017
1 parent b3f7aea commit 515e8f7c89df2a54efdc15ef6255afbae990f2e7
Showing with 77 additions and 30 deletions.
  1. +5 −0 ChangeLog_chenall.txt
  2. +3 −3 stage2/asm.S
  3. +7 −7 stage2/boot.c
  4. +15 −13 stage2/builtins.c
  5. +0 −6 stage2/char_io.c
  6. +47 −0 stage2/console.c
  7. +0 −1 stage2/shared.h
View
@@ -1,4 +1,9 @@
更新说明:
+2017-05-15(yaya)
+ 允许批处理文件加载 kernel、initrd,会产生错误。(issue #141)
+ 修正卷标显示。
+ 增加32位色转4色模块。
+
2017-05-12(yaya)
修正写映射设备有时失败有时成功的问题。
可以在FAT、NTFS文件系统创建卷标。
View
@@ -14455,7 +14455,7 @@ VARIABLE(linux_data_real_addr)
.long 0
VARIABLE(linux_bzimage_tmp_addr)
- .long LINUX_TMP_MEMORY
+ .long SYSTEM_RESERVED_MEMORY
ENTRY(linux_boot)
@@ -14473,7 +14473,7 @@ ENTRY(linux_boot)
movl EXT_C(linux_text_len), %ecx
addl $3, %ecx
shrl $2, %ecx
- movl EXT_C(linux_bzimage_tmp_addr), %esi # LINUX_TMP_MEMORY
+ movl EXT_C(linux_bzimage_tmp_addr), %esi # SYSTEM_RESERVED_MEMORY
movl $LINUX_ZIMAGE_ADDR, %edi # 0x10000
rep movsl
@@ -14494,7 +14494,7 @@ ENTRY(big_linux_boot)
movl EXT_C(linux_text_len), %ecx
addl $3, %ecx
shrl $2, %ecx
- movl EXT_C(linux_bzimage_tmp_addr), %esi # LINUX_TMP_MEMORY
+ movl EXT_C(linux_bzimage_tmp_addr), %esi # SYSTEM_RESERVED_MEMORY
movl $LINUX_BZIMAGE_ADDR, %edi # 0x100000
rep movsl
View
@@ -645,7 +645,7 @@ 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 += LINUX_TMP_MEMORY; /* cur_addr is above LINUX_TMP_MEMORY. */
+ cur_addr += SYSTEM_RESERVED_MEMORY; /* cur_addr is above SYSTEM_RESERVED_MEMORY. */
/* read text, then read data */
if (grub_read ((unsigned long long) RAW_ADDR (cur_addr), text_len, 0xedde0d90) != text_len)
@@ -686,7 +686,7 @@ 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 - LINUX_TMP_MEMORY;
+ mbi.syms.a.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
*((int *) RAW_ADDR (cur_addr)) = pu.aout->a_syms;
cur_addr += sizeof (int);
@@ -786,7 +786,7 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
if (! memcheck (memaddr, memsiz))
goto failure_newline;
- memaddr += LINUX_TMP_MEMORY;
+ memaddr += SYSTEM_RESERVED_MEMORY;
/* mark memory as used */
if (cur_addr < memaddr + memsiz)
@@ -819,7 +819,7 @@ 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 - LINUX_TMP_MEMORY;
+ mbi.syms.e.addr = cur_addr - SYSTEM_RESERVED_MEMORY;
shdr = (Elf32_Shdr *) mbi.syms.e.addr;
cur_addr += tab_size;
@@ -852,7 +852,7 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
break;
}
- shdr[i].sh_addr = cur_addr - LINUX_TMP_MEMORY;
+ shdr[i].sh_addr = cur_addr - SYSTEM_RESERVED_MEMORY;
cur_addr += sec_size;
}
}
@@ -939,9 +939,9 @@ 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 - LINUX_TMP_MEMORY;
+ mll[mbi.mods_count].mod_start = cur_addr - SYSTEM_RESERVED_MEMORY;
cur_addr += len;
- mll[mbi.mods_count].mod_end = cur_addr - LINUX_TMP_MEMORY;
+ mll[mbi.mods_count].mod_end = cur_addr - SYSTEM_RESERVED_MEMORY;
mll[mbi.mods_count].pad = 0;
/* increment number of modules included */
View
@@ -6577,39 +6577,41 @@ static struct builtin builtin_font =
static void get_uuid (char* uuid_found, int tag);
static void get_vol (char* vol_found, int tag);
static int
-uuid_func (char *arg, int flags)
+uuid_func (char *argument, int flags)
{
unsigned long drive;
unsigned long tmp_drive = saved_drive;
unsigned long tmp_partition = saved_partition;
char root_found[16] = "";
char uuid_found[256];
+ char tem[256];
char uuid_tag[5] = {'U','U','I','D',0};
char vol_tag[12] = {'V','o','l','u','m','e',' ','N','a','m','e',0};
char *p;
- int write = 0;
+ char *arg = tem;
+ int write = 0, i = 0, j = 0;
- if (grub_memcmp (arg, "--write", 7) == 0)
+ if (grub_memcmp (argument, "--write", 7) == 0)
{
write = 1;
- arg += 7;
- arg = skip_to (0, arg);
+ argument += 7;
+ argument = skip_to (0, argument);
}
if (flags)
p = uuid_tag;
else
p = vol_tag;
- if (!flags)
+
+ while (argument[i])
{
- int i=0, j=0;
- while (arg[i])
+ if (argument[i] == '"' || argument[i] == '\\' )
{
- if (arg[i] == '"' || arg[i] == '\\' )
- i++;
- arg[j++] = arg[i++];
+ i++;
+ continue;
}
- arg[j] = 0;
+ arg[j++] = argument[i++];
}
+ arg[j] = 0;
if (*arg == '(')
{
@@ -6681,7 +6683,7 @@ uuid_func (char *arg, int flags)
if (write)
return ! (errnum = ERR_BAD_ARGUMENT);
errnum = ERR_NONE;
- return ! substring ((char*)uuid_found, arg,0);
+ return ! substring ((char*)uuid_found, arg,1);
}
if (write)
return ! (errnum = ERR_BAD_ARGUMENT);
View
@@ -1167,12 +1167,6 @@ real_get_cmdline (void)
while (buf[i - 1] != '"')
i--;
}
- if (buf[i - 1] == '"')
- {
- i--;
- while (buf[i - 1] != '"')
- i--;
- }
if (buf[i - 1] == ' ' || buf[i - 1] == '=')
{
/* find backslashes immediately before the space */
View
@@ -72,6 +72,50 @@ console_setcolorstate (color_state state)
console_color_state = state;
}
+unsigned char color_64_to_8 (unsigned long long color64);
+unsigned char color_32_to_4 (unsigned long color32);
+unsigned char
+color_32_to_4 (unsigned long color32)
+{
+ unsigned char r, g, b, col32, col4=0;
+ r = color32 >> 16;
+ g = (color32 >> 8) & 0xff;
+ b = color32 & 0xff;
+
+ if (r >= g)
+ {
+ if (r >= b)
+ col32 = r;
+ else
+ col32 = b;
+ }
+ else
+ {
+ if (g >= b)
+ col32 = g;
+ else
+ col32 = b;
+ }
+
+ if (col32 >= 0xaa)
+ col4 |= 8;
+ if (r && r >= col32/2)
+ col4 |= 4;
+ if (g && g >= col32/2)
+ col4 |= 2;
+ if (b && b >= col32/2)
+ col4 |= 1;
+
+ return col4;
+}
+
+unsigned char
+color_64_to_8 (unsigned long long color64)
+{
+ return (color_32_to_4 (color64 >> 32) << 4) | color_32_to_4 (color64 & 0xffffff);
+}
+
+
unsigned long long
color_4_to_32 (unsigned char color4)
{
@@ -112,7 +156,10 @@ console_setcolor(unsigned long state,unsigned long long color[])
if (!(state & (1<<i)))
continue;
if (color[i] > 0xff)
+ {
+ console_color[i] = color_64_to_8(color[i]);
console_color_64bit[i] = color[i];
+ }
else
{
console_color[i] = color[i];
View
@@ -48,7 +48,6 @@
*/
#define SYSTEM_RESERVED_MEMORY 0x2000000
-#define LINUX_TMP_MEMORY 0x2800000
/* unifont start at 24M */
#define UNIFONT_START 0x1800000

0 comments on commit 515e8f7

Please sign in to comment.