Linux-kernel mailing list archive 1998-10,: [patch] support for more than 1G RAM, 2.1.90-A

# [patch] support for more than 1G RAM, 2.1.90-A

MOLNAR Ingo (mingo@chiara.csoma.elte.hu)
Wed, 11 Mar 1998 18:56:35 +0100 (CET)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Dieter =?ISO-8859-1?Q?N=FCtzel: "2.1.8x sb sound module settings"
- Previous message: MOLNAR Ingo: "[patch] io-apic-2.1.90-B"

this is a cleaned up version of the CONFIG_MAX_MEMSIZE patch, it
implements the suggestions made by H. Peter Anvin, Michael Elizabeth
Chastain and Regis Duchesne:

- memory size configured in decimal, MBytes

- config.in issues cleaned up

- it actually compiles and works, unlike the previous version ;)

it was sanity booted on pre1-2.1.90.

-- mingo

--- linux/Documentation/Configure.help.orig Tue Mar 17 01:27:49 1998
+++ linux/Documentation/Configure.help Tue Mar 17 02:54:10 1998
@@ -103,6 +103,17 @@
you are not sure, say Y; apart from resulting in a 45kB bigger
kernel, it won't hurt.
+Max physical memory
+CONFIG_MAX_MEMSIZE
+ Linux/x86 can use up to 3.8 gigabytes of physical memory. Default
+ is max 1 gigabyte physical memory (1024 MB), this is enough for
+ most systems.
+ A system with 2G physical memory should use a value of ~2400, a
+ system with 3.8G memory should use something like 3900. A bit of
+ experimentation with the limit wont hurt, the kernel needs a ~128M
+ window for vmalloc() plus PCI space uses up some memory too, thus
+ addresses above FD000000 should rather be kept free.
+
Normal floppy disk support
CONFIG_BLK_DEV_FD
If you want to use your floppy disk drive(s) under Linux, say
--- linux/include/asm-i386/page.h.orig Tue Oct 15 08:14:53 1996
+++ linux/include/asm-i386/page.h Tue Mar 17 03:47:29 1998
@@ -7,6 +7,7 @@
#define PAGE_MASK (~(PAGE_SIZE-1))
#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
#define STRICT_MM_TYPECHECKS
@@ -52,12 +53,14 @@
#define __pgprot(x) (x)
#endif
+#endif /* !__ASSEMBLY__ */
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
/* This handles the memory map.. */
-#define PAGE_OFFSET 0xC0000000
+#define __PAGE_OFFSET ((0x1000-CONFIG_MAX_MEMSIZE)<<20)
+#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
#define MAP_NR(addr) (__pa(addr) >> PAGE_SHIFT)
--- linux/include/asm-i386/processor.h.orig Tue Jan 27 04:22:21 1998
+++ linux/include/asm-i386/processor.h Tue Mar 17 03:47:33 1998
@@ -10,6 +10,7 @@
#include <asm/vm86.h>
#include <asm/math_emu.h>
#include <asm/segment.h>
+#include <asm/page.h>
/*
* CPU type and hardware bug flags. Kept separately for each CPU.
@@ -71,10 +72,9 @@
extern unsigned int BIOS_revision;
/*
- * User space process size: 3GB. This is hardcoded into a few places,
- * so don't change it unless you know what you are doing.
+ * User space process size: 3GB (default).
*/
-#define TASK_SIZE (0xC0000000UL)
+#define TASK_SIZE (PAGE_OFFSET)
/* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
--- linux/include/asm-i386/pgtable.h.orig Wed Mar 4 15:15:57 1998
+++ linux/include/asm-i386/pgtable.h Tue Mar 17 03:51:41 1998
@@ -13,6 +13,7 @@
* the i386 page table tree.
*/
+#ifndef __ASSEMBLY__
/* Caches aren't brain-dead on the intel. */
#define flush_cache_all() do { } while (0)
#define flush_cache_mm(mm) do { } while (0)
@@ -155,6 +156,7 @@
}
#endif
+#endif /* !__ASSEMBLY__ */
/* Certain architectures need to do special things when pte's
@@ -181,6 +183,16 @@
#define PTRS_PER_PMD 1
#define PTRS_PER_PGD 1024
+/*
+ * pgd entries used up by user/kernel:
+ */
+
+#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
+#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
+#define __USER_PGD_PTRS (__PAGE_OFFSET >> PGDIR_SHIFT)
+#define __KERNEL_PGD_PTRS (PTRS_PER_PGD-__USER_PGD_PTRS)
+
+#ifndef __ASSEMBLY__
/* Just any arbitrary offset to the start of the vmalloc VM area: the
* current 8MB value just means that there will be a 8MB "hole" after the
* physical memory until the kernel virtual memory starts. That means that
@@ -496,5 +508,7 @@
#define module_map vmalloc
#define module_unmap vfree
+
+#endif /* !__ASSEMBLY__ */
#endif /* _I386_PAGE_H */
--- linux/include/asm-i386/uaccess.h.orig Sun Feb 1 01:17:54 1998
+++ linux/include/asm-i386/uaccess.h Tue Mar 17 03:48:01 1998
@@ -5,6 +5,7 @@
* User space memory access functions
*/
#include <linux/sched.h>
+#include <asm/page.h>
#define VERIFY_READ 0
#define VERIFY_WRITE 1
@@ -21,7 +22,7 @@
#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
-#define USER_DS MAKE_MM_SEG(0xC0000000)
+#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
#define get_ds() (KERNEL_DS)
#define get_fs() (current->addr_limit)
--- linux/drivers/char/apm_bios.c.orig Sat Mar 14 01:32:49 1998
+++ linux/drivers/char/apm_bios.c Tue Mar 17 01:34:29 1998
@@ -1203,17 +1203,17 @@
* even though they are called in protected mode.
*/
set_base(gdt[APM_40 >> 3],
- 0xc0000000 + ((unsigned long)0x40 << 4));
+ __va((unsigned long)0x40 << 4));
set_limit(gdt[APM_40 >> 3], 4096 - (0x40 << 4));
apm_bios_entry.offset = apm_bios_info.offset;
apm_bios_entry.segment = APM_CS;
set_base(gdt[APM_CS >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.cseg << 4));
+ __va((unsigned long)apm_bios_info.cseg << 4));
set_base(gdt[APM_CS_16 >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.cseg_16 << 4));
+ __va((unsigned long)apm_bios_info.cseg_16 << 4));
set_base(gdt[APM_DS >> 3],
- 0xc0000000 + ((unsigned long)apm_bios_info.dseg << 4));
+ __va((unsigned long)apm_bios_info.dseg << 4));
if (apm_bios_info.version == 0x100) {
set_limit(gdt[APM_CS >> 3], 64 * 1024);
set_limit(gdt[APM_CS_16 >> 3], 64 * 1024);
--- linux/arch/i386/mm/init.c.orig Tue Jan 20 02:25:22 1998
+++ linux/arch/i386/mm/init.c Tue Mar 17 01:34:30 1998
@@ -204,8 +204,8 @@
/* unmap the original low memory mappings */
pgd_val(pg_dir[0]) = 0;
- /* Map whole memory from 0xC0000000 */
- pg_dir += 768;
+ /* Map whole memory from PAGE_OFFSET */
+ pg_dir += USER_PGD_PTRS;
while (address < end_mem) {
/*
* If we're running on a Pentium CPU, we can use the 4MB
--- linux/arch/i386/kernel/head.S.orig Wed Mar 4 15:15:49 1998
+++ linux/arch/i386/kernel/head.S Tue Mar 17 03:49:09 1998
@@ -8,9 +8,13 @@
*/
.text
+#include <linux/config.h>
#include <linux/tasks.h>
#include <linux/linkage.h>
#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
#define CL_MAGIC_ADDR 0x90020
#define CL_MAGIC 0xA33F
@@ -54,9 +58,9 @@
* be using the global pages.
*
* NOTE! We have to correct for the fact that we're
- * not yet offset 0xC0000000..
+ * not yet offset PAGE_OFFSET..
*/
-#define cr4_bits mmu_cr4_features-0xC0000000
+#define cr4_bits mmu_cr4_features-__PAGE_OFFSET
movl %cr4,%eax # Turn on 4Mb pages
orl cr4_bits,%eax
movl %eax,%cr4
@@ -368,7 +372,7 @@
* sets up a idt with 256 entries pointing to
* ignore_int, interrupt gates. It doesn't actually load
* idt - that can be done only after paging has been enabled
- * and the kernel moved to 0xC0000000. Interrupts
+ * and the kernel moved to PAGE_OFFSET. Interrupts
* are enabled elsewhere, when we can be relatively
* sure everything is ok.
*/
@@ -444,14 +448,16 @@
/*
* This is initialized to create a identity-mapping at 0-4M (for bootup
* purposes) and another mapping of the 0-4M area at virtual address
- * 0xC0000000.
+ * PAGE_OFFSET.
*/
.org 0x1000
ENTRY(swapper_pg_dir)
.long 0x00102007
- .fill 767,4,0
+ .fill __USER_PGD_PTRS-1,4,0
+ /* default: 767 entries */
.long 0x00102007
- .fill 255,4,0
+ /* default: 255 entries */
+ .fill __KERNEL_PGD_PTRS-1,4,0
/*
* The page tables are initialized to only 4MB here - the final page
@@ -614,8 +620,8 @@
.fill 256,8,0 # idt is uninitialized
/*
- * This gdt setup gives the kernel a 1GB address space at virtual
- * address 0xC0000000 - space enough for expansion, I hope.
+ * This gdt setup gives the kernel a CONFIG_MAX_MEMSIZE sized address space at
+ * virtual address PAGE_OFFSET.
*
* This contains up to 8192 quadwords depending on NR_TASKS - 64kB of
* gdt entries. Ugh.
--- linux/arch/i386/kernel/process.c.orig Sat Jan 3 09:44:17 1998
+++ linux/arch/i386/kernel/process.c Tue Mar 17 01:34:30 1998
@@ -314,10 +314,10 @@
/* Remap the kernel at virtual address zero, as well as offset zero
from the kernel segment. This assumes the kernel segment starts at
- virtual address 0xc0000000. */
+ virtual address PAGE_OFFSET. */
- memcpy (swapper_pg_dir, swapper_pg_dir + 768,
- sizeof (swapper_pg_dir [0]) * 256);
+ memcpy (swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
+ sizeof (swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
/* Make sure the first page is mapped to the start of physical memory.
It is normally not mapped, to trap kernel NULL pointer dereferences. */
--- linux/arch/i386/kernel/trampoline.S.orig Mon Dec 1 19:34:10 1997
+++ linux/arch/i386/kernel/trampoline.S Tue Mar 17 03:46:53 1998
@@ -26,8 +26,10 @@
* entries except for the gdt one..
*/
+#include <linux/config.h>
#include <linux/linkage.h>
#include <asm/segment.h>
+#include <asm/page.h>
.data
@@ -62,7 +64,7 @@
gdt_48:
.word 0x0800 # gdt limit = 2048, 256 GDT entries
- .long gdt_table-0xc0000000 # gdt base = gdt (first SMP CPU)
+ .long gdt_table-__PAGE_OFFSET # gdt base = gdt (first SMP CPU)
.globl SYMBOL_NAME(trampoline_end)
SYMBOL_NAME_LABEL(trampoline_end)
--- linux/arch/i386/Makefile.orig Tue Feb 10 08:43:01 1998
+++ linux/arch/i386/Makefile Tue Mar 17 02:58:29 1998
@@ -58,6 +58,9 @@
DRIVERS := $(DRIVERS) arch/i386/math-emu/math.a
endif
+memsize: dummy
+ @echo "__kernel_offset__ = (0x1000-$(CONFIG_MAX_MEMSIZE))*1024*1024;" > arch/i386/.kernel_offset.lds
+
arch/i386/kernel: dummy
$(MAKE) linuxsubdirs SUBDIRS=arch/i386/kernel
@@ -66,27 +69,27 @@
MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
-zImage: vmlinux
+zImage: memsize vmlinux
@$(MAKEBOOT) zImage
-bzImage: vmlinux
+bzImage: memsize vmlinux
@$(MAKEBOOT) bzImage
compressed: zImage
-zlilo: vmlinux
+zlilo: memsize vmlinux
@$(MAKEBOOT) BOOTIMAGE=zImage zlilo
-bzlilo: vmlinux
+bzlilo: memsize vmlinux
@$(MAKEBOOT) BOOTIMAGE=bzImage zlilo
-zdisk: vmlinux
+zdisk: memsize vmlinux
@$(MAKEBOOT) BOOTIMAGE=zImage zdisk
-bzdisk: vmlinux
+bzdisk: memsize vmlinux
@$(MAKEBOOT) BOOTIMAGE=bzImage zdisk
-install: vmlinux
+install: memsize vmlinux
@$(MAKEBOOT) BOOTIMAGE=bzImage install
archclean:
--- linux/arch/i386/config.in.orig Tue Mar 17 01:27:49 1998
+++ linux/arch/i386/config.in Tue Mar 17 02:54:43 1998
@@ -17,6 +17,7 @@
Pentium/K5/5x86/6x86 CONFIG_M586 \
PPro/K6/6x86MX CONFIG_M686" Pentium
bool 'Math emulation' CONFIG_MATH_EMULATION
+int ' Max physical memory in MB' CONFIG_MAX_MEMSIZE 1024
endmenu
mainmenu_option next_comment
--- linux/arch/i386/vmlinux.lds.orig Wed May 14 07:41:01 1997
+++ linux/arch/i386/vmlinux.lds Tue Mar 17 04:11:12 1998
@@ -1,12 +1,13 @@
/* ld script to make i386 Linux kernel
* Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+INCLUDE arch/i386/.kernel_offset.lds
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
- . = 0xc0100000;
+ . = __kernel_offset__ + 0x100000;
_text = .; /* Text and read-only data */
.text : {
*(.text)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

- Next message: Dieter =?ISO-8859-1?Q?N=FCtzel: "2.1.8x sb sound module settings"
- Previous message: MOLNAR Ingo: "[patch] io-apic-2.1.90-B"