FreeNOS
IntelBoot.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <String.h>
19#include <MemoryBlock.h>
20#include <CoreInfo.h>
21#include "IntelBoot.h"
22
24
26{
27 // Fill coreId and memory info
29 coreInfo.coreId = 0;
33
34 // Limit maximum supported memory to 1GiB minus 128MiB
35 // Unfortunately, libarch does not support RAM sizes of 1GiB and higher.
36 // The reason is that the kernel maps only 1GiB minus 128MiB of RAM,
37 // where the upper 128MiB is needed for the KernelPrivate section.
38 // Mapping more than that will not work with SplitAllocator::toVirtual().
39 // Therefore, use at maximum 1GiB minus 128MiB.
40 if (info->memUpper <= (1024 * (1024 - 128))) {
41 coreInfo.memory.size = (info->memUpper * 1024) + MegaByte(1);
42 } else {
43 coreInfo.memory.size = 1024 * 1024 * (1024 - 128);
44 }
45
46 // Fill the kernel command line
48
49 // Fill the bootimage address
50 for (Size n = 0; n < info->modsCount; n++)
51 {
53 mod += n;
54 String str((char *)(mod->string), false);
55
56 // Is this the BootImage?
57 if (str.match("*.img"))
58 {
61 break;
62 }
63 }
64}
Address __start
Address __end
Definition IntelBoot.cpp:23
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Abstraction of strings.
Definition String.h:42
bool match(const char *mask) const
Matches the String against a mask.
Definition String.cpp:267
void multibootToCoreInfo(MultibootInfo *info)
Convert multiboot info to a CoreInfo struct.
Definition IntelBoot.cpp:25
CoreInfo coreInfo
Local CoreInfo instance.
#define KERNEL_PATHLEN
Definition CoreInfo.h:29
unsigned long Address
A memory address.
Definition Types.h:131
#define MegaByte(v)
Convert megabytes to bytes.
Definition Macros.h:57
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Per-Core information structure.
Definition CoreInfo.h:61
Address bootImageSize
Boot image size in bytes.
Definition CoreInfo.h:84
Memory::Range kernel
Kernel memory range.
Definition CoreInfo.h:75
uint coreId
Core identifier.
Definition CoreInfo.h:66
Address bootImageAddress
Boot image physical memory address.
Definition CoreInfo.h:81
Memory::Range memory
Defines the physical memory available to the core.
Definition CoreInfo.h:69
char kernelCommand[KERNEL_PATHLEN]
Kernel command.
Definition CoreInfo.h:78
Size size
Size in number of bytes.
Definition Memory.h:59
Address phys
Physical address.
Definition Memory.h:58
The Multiboot information.
Definition IntelBoot.h:94
The module class.
Definition IntelBoot.h:117