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
28  MemoryBlock::set(&coreInfo, 0, sizeof(CoreInfo));
29  coreInfo.coreId = 0;
32  coreInfo.memory.phys = 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  {
60  coreInfo.bootImageSize = mod->modEnd - mod->modStart;
61  break;
62  }
63  }
64 }
MemoryBlock::copy
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Definition: MemoryBlock.cpp:36
MultibootInfo::modsCount
u32 modsCount
Definition: IntelBoot.h:100
CoreInfo::bootImageSize
Address bootImageSize
Boot image size in bytes.
Definition: CoreInfo.h:84
MemoryBlock::set
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
Definition: MemoryBlock.cpp:25
String
Abstraction of strings.
Definition: String.h:41
MultibootInfo::modsAddress
u32 modsAddress
Definition: IntelBoot.h:101
Address
unsigned long Address
A memory address.
Definition: Types.h:131
MultibootModule::modStart
u32 modStart
Definition: IntelBoot.h:118
CoreInfo::memory
Memory::Range memory
Defines the physical memory available to the core.
Definition: CoreInfo.h:69
MemoryBlock.h
CoreInfo::coreId
uint coreId
Core identifier.
Definition: CoreInfo.h:66
MegaByte
#define MegaByte(v)
Convert megabytes to bytes.
Definition: Macros.h:57
MultibootInfo
The Multiboot information.
Definition: IntelBoot.h:93
CoreInfo::kernelCommand
char kernelCommand[KERNEL_PATHLEN]
Kernel command.
Definition: CoreInfo.h:78
__end
Address __end
Definition: IntelBoot.cpp:23
Memory::Range::phys
Address phys
Physical address.
Definition: Memory.h:58
KERNEL_PATHLEN
#define KERNEL_PATHLEN
Definition: CoreInfo.h:29
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
MultibootInfo::cmdline
u32 cmdline
Definition: IntelBoot.h:99
CoreInfo::bootImageAddress
Address bootImageAddress
Boot image physical memory address.
Definition: CoreInfo.h:81
MultibootModule::modEnd
u32 modEnd
Definition: IntelBoot.h:119
CoreInfo
Per-Core information structure.
Definition: CoreInfo.h:60
coreInfo
CoreInfo coreInfo
Local CoreInfo instance.
IntelBoot.h
multibootToCoreInfo
void multibootToCoreInfo(MultibootInfo *info)
Convert multiboot info to a CoreInfo struct.
Definition: IntelBoot.cpp:25
CoreInfo::kernel
Memory::Range kernel
Kernel memory range.
Definition: CoreInfo.h:75
String.h
CoreInfo.h
MultibootModule
The module class.
Definition: IntelBoot.h:116
Memory::Range::size
Size size
Size in number of bytes.
Definition: Memory.h:59
__start
Address __start
MultibootModule::string
u32 string
Definition: IntelBoot.h:120
MultibootInfo::memUpper
u32 memUpper
Definition: IntelBoot.h:97