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