Permalink
Browse files

. 修正 Windows XP 反馈 0K 错误。(issues #154)

  修正 int15/ax=e820 等函数。
  • Loading branch information...
yaya
yaya committed Aug 28, 2017
1 parent 172f98f commit a7d772bcd16e3f398757a537417a3b3c2b99018f
Showing with 55 additions and 126 deletions.
  1. +4 −0 ChangeLog_chenall.txt
  2. +26 −119 stage2/asm.S
  3. +22 −5 stage2/builtins.c
  4. +2 −2 stage2/common.c
  5. +1 −0 stage2/shared.h
View
@@ -1,4 +1,8 @@
更新说明:
2017-08-28(yaya)
修正 Windows XP 反馈 0K 错误。(issues #154)
修正 int15/ax=e820 等函数。
2017-06-21(yaya)
cat --hex 函数的文本字符,仅显示0x20-0x7e字符。(issues #150)
View
@@ -5559,7 +5559,7 @@ ENTRY(lba_cd_boot)
minimum_mem_lo_in_map:
.long 0 /* min ram drive base below 16M */
minimum_mem_hi_in_map:
ENTRY(minimum_mem_hi_in_map)
.long 0 /* min ram drive base above 16M */
#if 0
@@ -5750,6 +5750,16 @@ int15_e820_handler:
subl %es:(%di), %eax
sbbl %es:4(%di), %edx /* EDX:EAX=new length */
jb 5f /* start_address is below the base */
ja 7f
/* now EDX=0 */
testl %eax, %eax /* EAX also be zero? ZF holds it! */
jne 7f
/* Change memory address type from 1 (usable) to 2 (reserved). Note
* that original value is long integer of 1 (all higher 3 bytes = 0).
* So only the lowest byte needs to be incremented. */
incb %es:16(%di) /* memory address type */
jmp 5f
7:
subl %es:8(%di), %eax
sbbl %es:12(%di), %edx /* EDX:EAX=difference */
jnb 5f /* new length is too big */
@@ -5818,9 +5828,7 @@ int15_e820_handler:
/* find minimum mem ever used in the drive map slots */
movl $-1, %eax /* 0xffffffff, initialize to maximum value */
movl %eax, %cs:(minimum_mem_hi_in_map - int13_handler)
movl $0x1000000, %cs:(minimum_mem_lo_in_map - int13_handler)
movl %cs:(EXT_C(minimum_mem_hi_in_map) - int13_handler), %eax
/* set %si to the drive map */
#if MAP_NUM_16
movw $(EXT_C(hooked_drive_map_1) - int13_handler), %si
@@ -5849,32 +5857,20 @@ int15_e820_handler:
shll $9, %ebx /* convert to address in bytes */
cmpl $0x1000000, %ebx /* 16M */
jb 7f
/* hi mem */
cmpl %ebx, %cs:(minimum_mem_hi_in_map - int13_handler)
jbe 5f
movl %ebx, %cs:(minimum_mem_hi_in_map - int13_handler)
jmp 5f
7:
/* lo mem */
cmpl %ebx, %cs:(minimum_mem_lo_in_map - int13_handler)
cmpl %ebx, %eax
jbe 5f
movl %ebx, %cs:(minimum_mem_lo_in_map - int13_handler)
movl %ebx, %eax
5:
/* try next slot */
addw $DRIVE_MAP_SLOT_SIZE, %si
loop 6b
subl $0x100000, %eax
shrl $10, %eax
movl %eax, %cs:(minimum_mem_lo_in_map - int13_handler)
popal
cmpl $-1, %cs:(minimum_mem_hi_in_map - int13_handler)
jne 1f
cmpl $0x1000000, %cs:(minimum_mem_lo_in_map - int13_handler)
jne 1f
ljmp %cs:*(EXT_C(ROM_int15) - int13_handler)
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1:
cmpw $0xe801, %ax //cmpl $0x0000e801, %eax
@@ -5904,77 +5900,20 @@ int15_e820_handler:
* no Compaq machine was detected, or parameter /NOABOVE16 was given.
*/
//movw $0x3c00, %ax /* 1-16M mem in K (0x3c00KB = 15MB) */
//movw $0x0300, %bx /* mem above 16M in 64K blocks */
/* between 16M and 4G, we modify BX, DX */
4:
pushfw
xorw %cx, %cx
xorw %dx, %dx
//pushfw
//lcall %cs:*(EXT_C(ROM_int15) - int13_handler)
call safe_ROM_int15
jc 3f
pushl %eax
testw %cx, %cx
jnz 5f
testw %dx, %dx
jnz 5f
movw %ax, %cx
movl %cs:(minimum_mem_lo_in_map - int13_handler), %ebx
subl $0x3c00, %ebx /* 16M */
shrl $6, %ebx /* AX=mem above 16M in 64K blocks */
movw %bx, %dx
5:
/* between 16M and 4G, we modify BX, DX */
movl %cs:(minimum_mem_hi_in_map - int13_handler), %eax
cmpl $-1, %eax /* 4G - 1 */
je 5f
subl $0x1000000, %eax /* 16M */
shrl $16, %eax /* AX=mem above 16M in 64K blocks */
movw %ax, %bx
movw %ax, %dx
popl %eax
popfw
pushfw
pushl %eax
jnc 5f
movzwl %bx, %ebx
movzwl %dx, %edx
5:
popl %eax
pushl %eax
/* between 1M and 16M, we modify AX, CX */
movl %cs:(minimum_mem_lo_in_map - int13_handler), %eax
cmpl $0x1000000, %eax /* 16M */
je 5f
subl $0x0100000, %eax /* 1M */
shrl $10, %eax /* AX=1-16M mem in K */
movw $0x3c00, %ax
movw %ax, %cx
popl %eax
movw %cx, %ax
popfw
pushfw
pushl %eax
jnc 5f
popl %eax
movzwl %ax, %eax
pushl %eax
movzwl %cx, %ecx
5:
popl %eax
popfw
clc
lret $2
3:
popfw
stc
lret $2
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1:
@@ -6001,7 +5940,6 @@ int15_e820_handler:
//movl $0x3c00, %eax /* 1-16M mem in K (0x3c00 = 15MB) */
//movl $0x0300, %ebx /* mem above 16M in 64K blocks */
stc
jmp 4b
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1:
@@ -6028,12 +5966,6 @@ int15_e820_handler:
pushl %eax
movl %cs:(minimum_mem_lo_in_map - int13_handler), %eax
cmpl $0x1000000, %eax /* 16M */
jb 5f
movl %cs:(minimum_mem_hi_in_map - int13_handler), %eax
5:
subl $0x0100000, %eax
shrl $10, %eax /* EAX=extended mem in K */
xchgw %ax, %bx
shrl $16, %eax
movb %al, %cl
@@ -6151,21 +6083,9 @@ int15_e820_handler:
#;
#; jc 3f
pushl %eax
movl %cs:(minimum_mem_lo_in_map - int13_handler), %eax
cmpl $0x1000000, %eax /* 16M */
jb 5f
movl %cs:(minimum_mem_hi_in_map - int13_handler), %eax
5:
subl $0x0100000, %eax
shrl $10, %eax /* EAX=extended mem in K */
popw %dx
pushw %ax
shrl $16, %eax
xchgw %ax, %dx
popl %eax
movl %cs:(minimum_mem_lo_in_map - int13_handler), %edx
movw %dx, %ax
shrl $16, %edx
clc
lret $2
@@ -6196,24 +6116,11 @@ int15_e820_handler:
#;
#; jc 3f
pushl %eax
movl %cs:(minimum_mem_lo_in_map - int13_handler), %eax
cmpl $0x1000000, %eax /* 16M */
jb 5f
movl %cs:(minimum_mem_hi_in_map - int13_handler), %eax
5:
subl $0x0100000, %eax
shrl $10, %eax /* EAX=extended mem in K */
cmpl $0x10000, %eax
jb 5f
movw $0xFFFF, %ax
5:
addw $2, %sp
pushw %ax
popl %eax
clc
lret $2
#;3:
@@ -6222,7 +6129,7 @@ int15_e820_handler:
1:
ljmp %cs:*(EXT_C(ROM_int15) - int13_handler)
safe_ROM_int15:
pushw %ds
View
@@ -4561,6 +4561,12 @@ static int
displaymem_func (char *arg, int flags)
{
errnum = 0;
int sector = 0;
if (grub_memcmp (arg, "--s", 3) == 0)
sector = 1;
if (!sector)
{
if (get_eisamemsize () != -1)
grub_printf (" EISA Memory BIOS Interface is present\n");
if (get_mmap_entry ((void *) SCRATCHADDR, 0) != 0
@@ -4570,7 +4576,7 @@ displaymem_func (char *arg, int flags)
grub_printf (" Lower memory: %uK, "
"Upper memory (to first chipset hole): %uK\n",
(unsigned long)saved_mem_lower, (unsigned long)saved_mem_upper);
}
if (mbi.flags & MB_INFO_MEM_MAP)
{
struct AddrRangeDesc *map = (struct AddrRangeDesc *) saved_mmap_addr;
@@ -4585,12 +4591,23 @@ displaymem_func (char *arg, int flags)
if (map->Type == MB_ARD_MEMORY)
str = "Usable RAM";
else
str = "Reserved";
grub_printf (" %s: Base: 0x%lX, Length: 0x%lX\n",
str = "Reserved ";
if (!sector )
{
grub_printf (" %s: Base: 0x%8lX, Length: 0x%8lX\n",
str,
(unsigned long long)(map->BaseAddr),
(unsigned long long)(map->Length));
}
else if (map->Type == MB_ARD_MEMORY)
{
grub_printf (" Usable RAM(Hex): Base: %8lX, Length: %8lX, End: %8lX\n",
(unsigned long long)(map->BaseAddr) >> 9,
(unsigned long long)(map->Length) >> 9,
(unsigned long long)(map->BaseAddr + map->Length) >> 9);
}
map = ((struct AddrRangeDesc *) (((int) map) + 4 + map->size));
}
}
@@ -4603,7 +4620,7 @@ static struct builtin builtin_displaymem =
"displaymem",
displaymem_func,
BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_SCRIPT | BUILTIN_HELP_LIST,
"displaymem",
"displaymem [--s]",
"Display what GRUB thinks the system address space map of the"
" machine is, including all regions of physical RAM installed."
};
View
@@ -483,7 +483,7 @@ init_bios_info (void)
saved_mem_upper = memtmp;
if (!cont || (memtmp == 0x3c00))
if (cont != 0)
{
saved_mem_upper += (cont >> 10);
@@ -508,7 +508,7 @@ init_bios_info (void)
}
DEBUG_SLEEP
//printf("\r \r"); /* wipe out the messages */
minimum_mem_hi_in_map = (saved_mem_upper<<10)+0x100000;
mbi.mem_upper = saved_mem_upper;
mbi.mem_lower = saved_mem_lower;
mbi.mmap_addr = saved_mmap_addr;
View
@@ -1074,6 +1074,7 @@ extern unsigned long extended_memory;
extern unsigned long init_free_mem_start;
extern int config_len;
extern char menu_init_script_file[32];
extern unsigned long minimum_mem_hi_in_map;
/*
* Error variables.
*/

0 comments on commit a7d772b

Please sign in to comment.