improve some memory functions.
This commit is contained in:
parent
2d191cc4fb
commit
a87a341417
5 changed files with 118 additions and 57 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
||||||
|
2000-05-21 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
|
* stage2/asm.S (set_int13_handler): Don't use MBI to get the
|
||||||
|
lower memory size. Instead, decrease it in the BIOS memory
|
||||||
|
directly and set %eax to it, since MBI.MEM_LOWER may not be the
|
||||||
|
same as [0x413] any longer due to the previous change.
|
||||||
|
|
||||||
|
* grub/asmstub.c (CONVENTIONAL_MEMSIZE): Changed to 640 * 1024
|
||||||
|
from 640. You didn't like the inconsistency between
|
||||||
|
EXTENDED_MEMSIZE and CONVENTIONAL_MEMSIZE, did you?
|
||||||
|
(get_memsize): Return CONVENTIONAL_MEMSIZE >> 10 instead of
|
||||||
|
CONVENTIONAL_MEMSIZE, if TYPE is zero.
|
||||||
|
(get_eisamemsize): Return EXTENDED_MEMSIZE >> 10 instead of
|
||||||
|
EXTENDED_MEMSIZE / 1024. Just a cosmetic change.
|
||||||
|
(MMAR_DESC_LENGTH): New macro. Defined as 20.
|
||||||
|
(get_mmap_entry): Define a new variable DESC_TABLE statically,
|
||||||
|
and copy the CONTth entry to *DESC if CONT is a correct index.
|
||||||
|
|
||||||
|
2000-05-21 Chip Salzenberg <chip@valinux.com>
|
||||||
|
|
||||||
|
* stage2/common.c (mmap_avail_at): New function, abstracted out
|
||||||
|
of init_bios_info, to scan E820 memory map.
|
||||||
|
(init_bios_info): Use mmap_avail_at for _both_ MBI.MEM_UPPER and
|
||||||
|
MBI.MEM_LOWER.
|
||||||
|
|
||||||
2000-05-17 OKUJI Yoshinori <okuji@gnu.org>
|
2000-05-17 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
Update the network support to Etherboot-4.6.1.
|
Update the network support to Etherboot-4.6.1.
|
||||||
|
|
1
THANKS
1
THANKS
|
@ -11,6 +11,7 @@ Andrew Clausen <clausen@gnu.org>
|
||||||
Bradford Hovinen <hovinen@redrose.net>
|
Bradford Hovinen <hovinen@redrose.net>
|
||||||
Brian Brunswick <brian@skarpsey.demon.co.uk>
|
Brian Brunswick <brian@skarpsey.demon.co.uk>
|
||||||
Bryan Ford <baford@cs.utah.edu>
|
Bryan Ford <baford@cs.utah.edu>
|
||||||
|
Chip Salzenberg <chip@valinux.com>
|
||||||
Dan J. Walters <djw@cs.utexas.edu>
|
Dan J. Walters <djw@cs.utexas.edu>
|
||||||
Edmund GRIMLEY EVANS <edmundo@rano.demon.co.uk>
|
Edmund GRIMLEY EVANS <edmundo@rano.demon.co.uk>
|
||||||
Edward Killips <ekillips@triton.net>
|
Edward Killips <ekillips@triton.net>
|
||||||
|
|
|
@ -73,7 +73,7 @@ int grub_stage2 (void);
|
||||||
|
|
||||||
/* Simulated memory sizes. */
|
/* Simulated memory sizes. */
|
||||||
#define EXTENDED_MEMSIZE (3 * 1024 * 1024) /* 3MB */
|
#define EXTENDED_MEMSIZE (3 * 1024 * 1024) /* 3MB */
|
||||||
#define CONVENTIONAL_MEMSIZE (640) /* 640kB */
|
#define CONVENTIONAL_MEMSIZE (640 * 1024) /* 640kB */
|
||||||
|
|
||||||
/* Simulated disk sizes. */
|
/* Simulated disk sizes. */
|
||||||
#define DEFAULT_FD_CYLINDERS 80
|
#define DEFAULT_FD_CYLINDERS 80
|
||||||
|
@ -685,9 +685,9 @@ int
|
||||||
get_memsize (int type)
|
get_memsize (int type)
|
||||||
{
|
{
|
||||||
if (! type)
|
if (! type)
|
||||||
return CONVENTIONAL_MEMSIZE;
|
return CONVENTIONAL_MEMSIZE >> 10;
|
||||||
else
|
else
|
||||||
return EXTENDED_MEMSIZE;
|
return EXTENDED_MEMSIZE >> 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ get_memsize (int type)
|
||||||
int
|
int
|
||||||
get_eisamemsize (void)
|
get_eisamemsize (void)
|
||||||
{
|
{
|
||||||
return (EXTENDED_MEMSIZE / 1024);
|
return (EXTENDED_MEMSIZE >> 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -707,6 +707,8 @@ get_eisamemsize (void)
|
||||||
#define MMAR_DESC_TYPE_ACPI_RECLAIM 3 /* usable by OS after reading ACPI */
|
#define MMAR_DESC_TYPE_ACPI_RECLAIM 3 /* usable by OS after reading ACPI */
|
||||||
#define MMAR_DESC_TYPE_ACPI_NVS 4 /* required to save between NVS sessions */
|
#define MMAR_DESC_TYPE_ACPI_NVS 4 /* required to save between NVS sessions */
|
||||||
|
|
||||||
|
#define MMAR_DESC_LENGTH 20
|
||||||
|
|
||||||
/* Fetch the next entry in the memory map and return the continuation
|
/* Fetch the next entry in the memory map and return the continuation
|
||||||
value. DESC is a pointer to the descriptor buffer, and CONT is the
|
value. DESC is a pointer to the descriptor buffer, and CONT is the
|
||||||
previous continuation value (0 to get the first entry in the
|
previous continuation value (0 to get the first entry in the
|
||||||
|
@ -714,19 +716,49 @@ get_eisamemsize (void)
|
||||||
int
|
int
|
||||||
get_mmap_entry (struct mmar_desc *desc, int cont)
|
get_mmap_entry (struct mmar_desc *desc, int cont)
|
||||||
{
|
{
|
||||||
if (! cont)
|
/* Record the memory map statically. */
|
||||||
|
static struct mmar_desc desc_table[] =
|
||||||
{
|
{
|
||||||
/* First entry, located at 1MB. */
|
/* The conventional memory. */
|
||||||
desc->desc_len = sizeof (*desc) - sizeof (desc->desc_len);
|
{
|
||||||
desc->addr = 1024 * 1024;
|
MMAR_DESC_LENGTH,
|
||||||
desc->length = EXTENDED_MEMSIZE;
|
0,
|
||||||
desc->type = MMAR_DESC_TYPE_AVAILABLE;
|
CONVENTIONAL_MEMSIZE,
|
||||||
|
MMAR_DESC_TYPE_AVAILABLE
|
||||||
|
},
|
||||||
|
/* BIOS RAM and ROM (such as video memory). */
|
||||||
|
{
|
||||||
|
MMAR_DESC_LENGTH,
|
||||||
|
CONVENTIONAL_MEMSIZE,
|
||||||
|
0x100000 - CONVENTIONAL_MEMSIZE,
|
||||||
|
MMAR_DESC_TYPE_RESERVED
|
||||||
|
},
|
||||||
|
/* The extended memory. */
|
||||||
|
{
|
||||||
|
MMAR_DESC_LENGTH,
|
||||||
|
0x100000,
|
||||||
|
EXTENDED_MEMSIZE,
|
||||||
|
MMAR_DESC_TYPE_AVAILABLE
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int num = sizeof (desc_table) / sizeof (*desc_table);
|
||||||
|
|
||||||
|
if (cont < 0 || cont >= num)
|
||||||
|
{
|
||||||
|
/* Should not happen. */
|
||||||
|
desc->desc_len = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No more entries, so give an error. */
|
/* Copy the entry. */
|
||||||
desc->desc_len = 0;
|
*desc = desc_table[cont++];
|
||||||
|
|
||||||
|
/* If the next entry exists, return the index. */
|
||||||
|
if (cont < num)
|
||||||
|
return cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -564,13 +564,12 @@ ENTRY(set_int13_handler)
|
||||||
movw 2(%edi), %ax
|
movw 2(%edi), %ax
|
||||||
movw %ax, ABS(int13_segment)
|
movw %ax, ABS(int13_segment)
|
||||||
|
|
||||||
/* get the lower memory size */
|
|
||||||
movl $EXT_C(mbi), %edi
|
|
||||||
movl 4(%edi), %eax
|
|
||||||
/* decrease the lower memory size and set it to the BIOS memory */
|
/* decrease the lower memory size and set it to the BIOS memory */
|
||||||
decl %eax
|
|
||||||
movl $0x413, %edi
|
movl $0x413, %edi
|
||||||
movw %ax, (%edi)
|
decw (%edi)
|
||||||
|
xorl %eax, %eax
|
||||||
|
movw (%edi), %ax
|
||||||
|
|
||||||
/* compute the segment */
|
/* compute the segment */
|
||||||
shll $6, %eax
|
shll $6, %eax
|
||||||
|
|
||||||
|
|
|
@ -90,13 +90,42 @@ static struct AddrRangeDesc fakemap[3] =
|
||||||
{20, 0x100000, 0, 0, 0, MB_ARD_MEMORY},
|
{20, 0x100000, 0, 0, 0, MB_ARD_MEMORY},
|
||||||
{20, 0x1000000, 0, 0, 0, MB_ARD_MEMORY}
|
{20, 0x1000000, 0, 0, 0, MB_ARD_MEMORY}
|
||||||
};
|
};
|
||||||
#endif /* STAGE1_5 */
|
|
||||||
|
|
||||||
|
/* A big problem is that the memory areas aren't guaranteed to be:
|
||||||
|
(1) contiguous, (2) sorted in ascending order, or (3) non-overlapping.
|
||||||
|
Thus this kludge. */
|
||||||
|
static unsigned long
|
||||||
|
mmap_avail_at (unsigned long bottom)
|
||||||
|
{
|
||||||
|
unsigned long top, addr;
|
||||||
|
int cont;
|
||||||
|
|
||||||
/*
|
top = bottom;
|
||||||
* This queries for BIOS information.
|
do
|
||||||
*/
|
{
|
||||||
|
for (cont = 0, addr = mbi.mmap_addr;
|
||||||
|
addr < mbi.mmap_addr + mbi.mmap_length;
|
||||||
|
addr += *((unsigned long *) addr) + 4)
|
||||||
|
{
|
||||||
|
struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
|
||||||
|
|
||||||
|
if (desc->BaseAddrHigh == 0
|
||||||
|
&& desc->Type == MB_ARD_MEMORY
|
||||||
|
&& desc->BaseAddrLow <= top
|
||||||
|
&& desc->BaseAddrLow + desc->LengthLow > top)
|
||||||
|
{
|
||||||
|
top = desc->BaseAddrLow + desc->LengthLow;
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (cont);
|
||||||
|
|
||||||
|
return top - bottom;
|
||||||
|
}
|
||||||
|
#endif /* ! STAGE1_5 */
|
||||||
|
|
||||||
|
/* This queries for BIOS information. */
|
||||||
void
|
void
|
||||||
init_bios_info (void)
|
init_bios_info (void)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +169,7 @@ init_bios_info (void)
|
||||||
{
|
{
|
||||||
cont = get_mmap_entry ((void *) addr, cont);
|
cont = get_mmap_entry ((void *) addr, cont);
|
||||||
|
|
||||||
/* If the returned buffer's base is zero, quit. */
|
/* If the returned buffer's length is zero, quit. */
|
||||||
if (! *((unsigned long *) addr))
|
if (! *((unsigned long *) addr))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -152,41 +181,16 @@ init_bios_info (void)
|
||||||
if (mbi.mmap_length)
|
if (mbi.mmap_length)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This is to get the upper memory up to the first memory
|
* This is to get the lower memory, and upper memory (up to the
|
||||||
* hole into the "mbi.mem_upper" element, for OS's that
|
* first memory hole), into the "mbi.mem_{lower,upper}"
|
||||||
* don't care about the memory map, but might care about
|
* elements. This is for OS's that don't care about the memory
|
||||||
* RAM above 64MB.
|
* map, but might care about total RAM available.
|
||||||
*
|
|
||||||
* A big problem is that the memory areas aren't guaranteed
|
|
||||||
* to be: (1) contiguous, (2) sorted in ascending order, or
|
|
||||||
* (3) non-overlapping.
|
|
||||||
*/
|
*/
|
||||||
memtmp = 0x100000;
|
mbi.mem_lower = mmap_avail_at (0) >> 10;
|
||||||
|
mbi.mem_upper = mmap_avail_at (0x100000) >> 10;
|
||||||
do
|
|
||||||
{
|
|
||||||
for (cont = 0, addr = mbi.mmap_addr;
|
|
||||||
addr < mbi.mmap_addr + mbi.mmap_length;
|
|
||||||
addr += *((unsigned long *) addr) + 4)
|
|
||||||
{
|
|
||||||
if (((struct AddrRangeDesc *) addr)->BaseAddrHigh == 0
|
|
||||||
&& ((struct AddrRangeDesc *) addr)->Type == MB_ARD_MEMORY
|
|
||||||
&& ((struct AddrRangeDesc *) addr)->BaseAddrLow <= memtmp
|
|
||||||
&& (((struct AddrRangeDesc *) addr)->BaseAddrLow
|
|
||||||
+ ((struct AddrRangeDesc *) addr)->LengthLow) > memtmp)
|
|
||||||
{
|
|
||||||
memtmp = (((struct AddrRangeDesc *) addr)->BaseAddrLow
|
|
||||||
+ ((struct AddrRangeDesc *) addr)->LengthLow);
|
|
||||||
cont++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (cont);
|
|
||||||
|
|
||||||
mbi.mem_upper = (memtmp - 0x100000) >> 10;
|
|
||||||
|
|
||||||
/* Find the maximum available address. Ignore any memory holes. */
|
/* Find the maximum available address. Ignore any memory holes. */
|
||||||
for (addr = mbi.mmap_addr;
|
for (memtmp = 0, addr = mbi.mmap_addr;
|
||||||
addr < mbi.mmap_addr + mbi.mmap_length;
|
addr < mbi.mmap_addr + mbi.mmap_length;
|
||||||
addr += *((unsigned long *) addr) + 4)
|
addr += *((unsigned long *) addr) + 4)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue