boot e820 memory detection fixes
This commit is contained in:
parent
cb54d96eec
commit
1dfd43ac27
9 changed files with 60 additions and 48 deletions
17
boot/boot.h
17
boot/boot.h
|
@ -62,23 +62,6 @@ EXTERN u16_t cddevice; /* Drive that is CD if known. */
|
|||
|
||||
#define CDNAME "cd" /* Name of the CD device. */
|
||||
|
||||
typedef struct { /* One chunk of free memory. */
|
||||
u32_t base; /* Start byte. */
|
||||
u32_t size; /* Number of bytes. */
|
||||
} memory;
|
||||
|
||||
typedef struct { /* One chunk of free memory. */
|
||||
u32_t base_lo; /* Start byte. */
|
||||
u32_t base_hi;
|
||||
u32_t size_lo; /* Number of bytes. */
|
||||
u32_t size_hi; /* Number of bytes. */
|
||||
u32_t type;
|
||||
u32_t acpi_attrs;
|
||||
} e820_memory;
|
||||
|
||||
EXTERN memory mem[3]; /* List of available memory. */
|
||||
EXTERN e820_memory emem[16]; /* List of available memory. */
|
||||
EXTERN int mem_entries;
|
||||
EXTERN int mon_return; /* Monitor stays in memory? */
|
||||
EXTERN int cdbooted; /* Did we boot from CD? (Set by boothead.s.) */
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
.include <bsd.own.mk>
|
||||
|
||||
# XXX: Can only be built with ACK currently
|
||||
MINIXID= -sep
|
||||
.include "${.CURDIR}/../minix.ack16.mk"
|
||||
AFLAGS+= -Was-ncc
|
||||
#LDFLAGS+= -stack 12kb
|
||||
STRIPFLAG= -s
|
||||
LIBDIR?= /usr/lib/i86
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ char version[]= "2.20";
|
|||
#undef EXTERN
|
||||
#define EXTERN /* Empty */
|
||||
#include "boot.h"
|
||||
#include "emem.h"
|
||||
|
||||
#define arraysize(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define arraylimit(a) ((a) + arraysize(a))
|
||||
|
@ -548,14 +549,19 @@ static void initialize(void)
|
|||
u32_t dma64k;
|
||||
#endif
|
||||
|
||||
if (mem_entries) {
|
||||
if (emem_entries) {
|
||||
int i, j;
|
||||
j = 0;
|
||||
for(i = 0; i < mem_entries ; i++) {
|
||||
if (j < 3 && emem[i].type == 1 && !emem[i].base_hi) {
|
||||
mem[j].base = emem[i].base_lo;
|
||||
mem[j].size = emem[i].size_lo;
|
||||
j++;
|
||||
for(i = 0; i < emem_entries ; i++) {
|
||||
if (emem[i].type == 1 &&
|
||||
!emem[i].base_hi && !emem[i].size_hi) {
|
||||
if(j < MEM_ENTRIES) {
|
||||
mem[j].base = emem[i].base_lo;
|
||||
mem[j].size = emem[i].size_lo;
|
||||
j++;
|
||||
} else {
|
||||
printf("WARNING: boot skipping memory\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#
|
||||
! Boothead.s - BIOS support for boot.c Author: Kees J. Bot
|
||||
!
|
||||
!
|
||||
|
@ -32,12 +33,15 @@
|
|||
SS_SELECTOR = 5*8 ! Monitor stack
|
||||
CS_SELECTOR = 6*8 ! Kernel code
|
||||
MCS_SELECTOR= 7*8 ! Monitor code
|
||||
E820_MAGIC= 0x534D4150
|
||||
|
||||
ESC = 0x1B ! Escape character
|
||||
|
||||
MB_BOOT_MAGIC = 0x2BADB002 ! Multiboot BootLoader Magic
|
||||
MULTIBOOT_STRUCT_ADDR = 0x9500 ! Multiboot Struct's Location
|
||||
|
||||
#include "emem.h"
|
||||
|
||||
! Imported variables and functions:
|
||||
.extern _caddr, _daddr, _runsize, _edata, _end ! Runtime environment
|
||||
.extern _device ! BIOS device number
|
||||
|
@ -45,7 +49,7 @@
|
|||
.extern _k_flags ! Special kernel flags
|
||||
.extern _mem ! Free memory list
|
||||
.extern _emem ! Free memory list for E820
|
||||
.extern _mem_entries ! Free memory E820 list entries
|
||||
.extern _emem_entries ! Free memory E820 list entries
|
||||
.extern _cdbooted ! Whether we booted from CD
|
||||
.extern _cddevice ! Whether we booted from CD
|
||||
.extern _do_multiboot ! Whether we are multibooting
|
||||
|
@ -157,17 +161,17 @@ sepID:
|
|||
xor bx, bx ! zero EBX
|
||||
xor bp, bp !zero bp
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
mov dx, #E820_MAGIC
|
||||
.data1 o32
|
||||
mov cx, const_24 ! request 24 bytes
|
||||
mov cx, #EMEM_SIZE ! request 24 bytes
|
||||
|
||||
.data1 o32
|
||||
mov ax, const_0xe820
|
||||
mov ax, #0xE820
|
||||
int 0x15
|
||||
jc e820_failed
|
||||
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
mov dx, #E820_MAGIC
|
||||
.data1 o32
|
||||
cmp dx, ax
|
||||
jne e820_failed
|
||||
|
@ -179,30 +183,30 @@ sepID:
|
|||
|
||||
e820_next:
|
||||
.data1 o32
|
||||
mov ax, const_0xe820
|
||||
mov ax, #0xE820
|
||||
mov 20(di), #1 ! force a valid ACPI 3.X entry
|
||||
|
||||
.data1 o32
|
||||
mov cx, const_24 ! request 24 bytes
|
||||
mov cx, #EMEM_SIZE ! request 24 bytes
|
||||
int 0x15
|
||||
jc e820_done
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
mov dx, #E820_MAGIC
|
||||
|
||||
|
||||
e820_gotit:
|
||||
jcxz e820_skip
|
||||
cmp bp, #16
|
||||
je e820_done ! we have only space for 16 entries
|
||||
cmp bp, #EMEM_ENTRIES
|
||||
je e820_done ! we have EMEM_ENTRIES storage
|
||||
inc bp
|
||||
add di, #24
|
||||
add di, #EMEM_SIZE ! increase di for next entry
|
||||
e820_skip:
|
||||
.data1 o32
|
||||
test bx, bx
|
||||
jne e820_next
|
||||
|
||||
e820_done:
|
||||
mov _mem_entries, bp
|
||||
mov _emem_entries, bp
|
||||
jmp memory_detected
|
||||
|
||||
e820_failed:
|
||||
|
@ -251,7 +255,6 @@ no_ext:
|
|||
|
||||
memory_detected:
|
||||
|
||||
|
||||
! Time to switch to a higher level language (not much higher)
|
||||
call _boot
|
||||
|
||||
|
@ -1620,14 +1623,6 @@ p_mcs_desc:
|
|||
.data2 0xFFFF, UNSET
|
||||
.data1 UNSET, 0x9A, 0x00, 0x00
|
||||
|
||||
e820_magic:
|
||||
! .data1 0x53, 0x4D, 0x41, 0x50
|
||||
.data1 0x50, 0x41, 0x4D, 0x53
|
||||
const_24:
|
||||
.data1 0x18, 0x0, 0x0, 0x0
|
||||
const_0xe820:
|
||||
.data2 0xe820
|
||||
|
||||
|
||||
.bss
|
||||
.comm old_vid_mode, 2 ! Video mode at startup
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <machine/partition.h>
|
||||
#include "rawfs.h"
|
||||
#include "image.h"
|
||||
#include "emem.h"
|
||||
#include "boot.h"
|
||||
|
||||
#include <machine/multiboot.h>
|
||||
|
|
26
boot/boot/emem.h
Normal file
26
boot/boot/emem.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#define EMEM_ENTRIES 16
|
||||
#define EMEM_SIZE 24 /* size in bytes of e820_memory struct */
|
||||
#define MEM_ENTRIES 3
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
typedef struct { /* One chunk of free memory. */
|
||||
u32_t base; /* Start byte. */
|
||||
u32_t size; /* Number of bytes. */
|
||||
} memory;
|
||||
|
||||
EXTERN memory mem[MEM_ENTRIES]; /* List of available memory. */
|
||||
|
||||
typedef struct { /* One chunk of free memory. */
|
||||
u32_t base_lo; /* Start byte. */
|
||||
u32_t base_hi;
|
||||
u32_t size_lo; /* Number of bytes. */
|
||||
u32_t size_hi; /* Number of bytes. */
|
||||
u32_t type;
|
||||
u32_t acpi_attrs;
|
||||
} e820_memory;
|
||||
|
||||
EXTERN e820_memory emem[EMEM_ENTRIES]; /* List of available memory. */
|
||||
EXTERN int emem_entries;
|
||||
#endif
|
|
@ -8,4 +8,5 @@ COMPILER_TYPE=ack
|
|||
OBJECT_FMT=a.out
|
||||
CPPFLAGS+= -mi86
|
||||
AFLAGS+= -mi86
|
||||
LDFLAGS+= -mi86 -.o -com # no crtso, common I+D
|
||||
LDFLAGS+= -mi86 -.o $(MINIXID) # no crtso
|
||||
MINIXID?= -com # common I+D default
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
||||
* for DOS MINIX.
|
||||
*/
|
||||
#define NR_MEMS 8
|
||||
#define NR_MEMS 16
|
||||
|
||||
|
||||
/* Click to byte conversions (and vice versa). */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
/* VM behaviour */
|
||||
#define MEMPROTECT 0 /* Slab objects not mapped. Access with USE() */
|
||||
#define JUNKFREE 0 /* Fill freed pages with junk */
|
||||
#define JUNKFREE 1 /* Fill freed pages with junk */
|
||||
#define NONCONTIGUOUS 0 /* Make phys pages max. noncontiguous */
|
||||
|
||||
/* How noisy are we supposed to be? */
|
||||
|
|
Loading…
Reference in a new issue