pc64: get rid of fixed 8MB INIMAP and dynamically map KZERO-end in l.s

traditionally, the pc kernel mapped the first 8MB of physical
address space. when the kernel size grows beyond that memory mapping,
it will crash on boot and theres no checking in the build process
making sure it fits.

with the pc64 kernel, it is not hard to always map the whole
kernel memory image from KZERO to end[], so that the kernel will
always fit into the initial mapping.
This commit is contained in:
cinap_lenrek 2014-11-15 11:43:05 +01:00
parent 4cd03abefe
commit 4e00cf6b17
3 changed files with 12 additions and 6 deletions

View file

@ -144,13 +144,20 @@ TEXT _warp64<>(SB), 1, $-4
MOVL $(PTESIZE|PTEGLOBAL|PTEWRITE|PTEVALID), DX
MOVL DX, PDO(0)(AX) /* PDE for double-map */
/*
* map from KZERO to end using 2MB pages
*/
ADDL $PDO(KZERO), AX
MOVL $end-KZERO(SB), CX
ADDL $(PGLSZ(1)-1), CX
ANDL $~(PGLSZ(1)-1), CX
MOVL CX, MemMin-KZERO(SB) /* see memory.c */
SHRL $(1*PTSHIFT+PGSHIFT), CX
memloop:
MOVL DX, 0(AX)
MOVL DX, (AX)
ADDL $PGLSZ(1), DX
ADDL $8, AX
CMPL DX, $INIMAP
JLT memloop
LOOP memloop
/*
* Enable and activate Long Mode. From the manual:

View file

@ -79,7 +79,6 @@
#define CPU0END (CPU0MACH+MACHSIZE)
#define MACHSIZE (2*KSTACK)
#define INIMAP (8*MiB) /* 4 pages; size of inital map in l.s */
/*
* known x86 segments (in GDT) and their selectors

View file

@ -12,6 +12,8 @@
#include "io.h"
#include "ureg.h"
u32int MemMin; /* set by l.s */
#define MEMDEBUG 0
enum {
@ -22,8 +24,6 @@ enum {
NMemType = 4,
KB = 1024,
MemMin = INIMAP,
};
typedef struct Map Map;