#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.) */
.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
#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))
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");
+ }
}
}
}
+#
! Boothead.s - BIOS support for boot.c Author: Kees J. Bot
!
!
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
.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
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
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:
memory_detected:
-
! Time to switch to a higher level language (not much higher)
call _boot
.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
#include <machine/partition.h>
#include "rawfs.h"
#include "image.h"
+#include "emem.h"
#include "boot.h"
#include <machine/multiboot.h>
--- /dev/null
+
+#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
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
* 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). */
/* 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? */