mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added a global variable at the end of the kernel to detect its size.
This lets the kernel use any memory not directly used by it or the init ramdisk. Although, now we test whether the kernel fits into the identitymapped area. It can't really grow down there, unless it wants to collide with user-space. Instead, modules and the like (when they are invented), should be put in the upper memory. Or in their own user-space process, yay, microkernel!
This commit is contained in:
parent
0515111314
commit
ba9b715c59
3 changed files with 47 additions and 3 deletions
|
@ -87,6 +87,7 @@ fs/devfs.o \
|
|||
fs/initfs.o \
|
||||
fs/ramfs.o \
|
||||
../libmaxsi/libmaxsi-sortix.a \
|
||||
end.o # Must be last
|
||||
|
||||
JSOBJS:=$(subst .o,-js.o,$(OBJS))
|
||||
|
||||
|
|
33
sortix/end.cpp
Normal file
33
sortix/end.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
Sortix is free software: you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
end.cpp
|
||||
Places a symbol at the end of the kernel binary. This allows us to easily
|
||||
detect the size of the kernel. Be sure to put this one last in the linking
|
||||
command.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
namespace Sortix
|
||||
{
|
||||
size_t end; // Put in the bss, the last segment.
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ using namespace Maxsi;
|
|||
|
||||
namespace Sortix
|
||||
{
|
||||
const addr_t KERNELEND = 0x200000UL;
|
||||
extern size_t end;
|
||||
|
||||
namespace Page
|
||||
{
|
||||
|
@ -57,11 +57,21 @@ namespace Sortix
|
|||
|
||||
void Init(multiboot_info_t* bootinfo)
|
||||
{
|
||||
const size_t MAXKERNELEND = 0x400000UL; /* 4 MiB */
|
||||
addr_t kernelend = Page::AlignUp((addr_t) &end);
|
||||
if ( MAXKERNELEND < kernelend )
|
||||
{
|
||||
Log::PrintF("Warning: The kernel is too big! It ends at 0x%zx, "
|
||||
"but the highest ending address supported is 0x%zx. "
|
||||
"The system may not boot correctly.\n", kernelend,
|
||||
MAXKERNELEND);
|
||||
}
|
||||
|
||||
Page::pagesnotonstack = 0;
|
||||
Page::totalmem = 0;
|
||||
|
||||
// The first mebibytes are reserved for use by the kernel.
|
||||
Page::pagesallocated = KERNELEND >> 12UL;
|
||||
Page::pagesallocated = kernelend >> 12UL;
|
||||
|
||||
if ( !( bootinfo->flags & MULTIBOOT_INFO_MEM_MAP ) )
|
||||
{
|
||||
|
@ -109,7 +119,7 @@ namespace Sortix
|
|||
addr_t highest = regionend;
|
||||
|
||||
// Don't allocate the kernel.
|
||||
if ( lowest < KERNELEND ) { processed = KERNELEND; continue; }
|
||||
if ( lowest < kernelend ) { processed = kernelend; continue; }
|
||||
|
||||
// Don't give any of our modules to the physical page
|
||||
// allocator, we'll need them.
|
||||
|
|
Loading…
Reference in a new issue