For the cases when loading bzip2-compressed kernels enabled use last

3MB of physical memory for heap instead of range between 1MB and 4MB.
This makes this feature working with PAE and amd64 kernels, which are
loaded at 2MB. Teach i386_copyin() to avoid using range allocated by
heap in such case, so that it won't trash heap in the low memory
conditions.

This should make loading bzip2-compressed kernels/modules/mfs images
generally useable, so that re@ team is welcome to evaluate merits
of using this feature in the installation CDs.

Valuable suggestions by:	jhb
This commit is contained in:
Maxim Sobolev 2005-12-21 02:17:58 +00:00
parent d6209fadb2
commit e4f5866fd5
4 changed files with 10 additions and 6 deletions

View File

@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$");
#include "libi386.h"
#include "btxv86.h"
vm_offset_t memtop;
vm_offset_t memtop, memtop_copyin;
u_int32_t bios_basemem, bios_extmem;
#define SMAPSIG 0x534D4150
@ -101,7 +101,7 @@ bios_getmem(void)
}
/* Set memtop to actual top of memory */
memtop = 0x100000 + bios_extmem;
memtop = memtop_copyin = 0x100000 + bios_extmem;
}

View File

@ -66,7 +66,7 @@ ssize_t
i386_readin(const int fd, vm_offset_t dest, const size_t len)
{
if (dest + len >= memtop) {
if (dest + len >= memtop_copyin) {
errno = EFBIG;
return(-1);
}

View File

@ -91,7 +91,10 @@ void bios_getsmap(void);
void bios_getmem(void);
extern u_int32_t bios_basemem; /* base memory in bytes */
extern u_int32_t bios_extmem; /* extended memory in bytes */
extern vm_offset_t memtop;
extern vm_offset_t memtop; /* last address of physical memory + 1 */
extern vm_offset_t memtop_copyin; /* memtop less heap size for the cases */
/* when heap is at the top of extended memory */
/* for other cases - just the same as memtop */
int biospci_find_devclass(uint32_t class, int index);
int biospci_write_config(uint32_t locator, int offset, int width, int val);

View File

@ -92,8 +92,9 @@ main(void)
bios_getmem();
#ifdef LOADER_BZIP2_SUPPORT
heap_top = PTOV(0x400000);
heap_bottom = PTOV(0x100000);
heap_top = PTOV(memtop_copyin);
memtop_copyin -= 0x300000;
heap_bottom = PTOV(memtop_copyin);
#else
heap_top = (void *)bios_basemem;
heap_bottom = (void *)end;