-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.cpp
More file actions
106 lines (85 loc) · 3.35 KB
/
kernel.cpp
File metadata and controls
106 lines (85 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
* kernel.cpp
*
* Copyright 2008 Matthias v.d. Vlies
* matthias@mserver.nl
****************************************************************************/
/*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*! \file kernel.cpp
* \brief Kernel initialisation
*
* This file includes the initialisation methods for booting the kernel's features.
*/
#include <config.h>
#include <errors.h>
#include <core/video.h>
#include <grub/multiboot.h>
#include <core/staticallocator.h>
#include <core/kernelallocator.h>
#include <core/console.h>
#include <core/terminal.h>
#include <core/resource.h>
#include <grub/grub.h>
#include <core/architecture.h>
/*! High level code entrypoint
*
*\param magic GRUB magic number
*\param address Pointer to to the GRUB multiboot information structure
*\return The result of the initialization routines. Only on failure.
*/
extern "C" int kernel(unsigned long magic, unsigned long address) {
// create a new terminal
Core::Terminal* terminal = new Core::Terminal(Core::Video::getInstance());
// set new colors
terminal->setColor(MAKE_COLOR(TERMINAL_BLACK, TERMINAL_WHITE, FALSE));
Core::Console* console = Core::Console::getInstance();
// switch to it
console->switchTerminal(terminal);
// write welcome message
console->write("Titanium kernel version: ");
console->write(VERSION_STRING);
console->write("\nCopyright Matthias van der Vlies <matthias@eenweiland.nl> 2008-");
console->write(YEAR_STRING);
console->write("\nCompiled by ");
console->write(USER);
console->write("@");
console->write(HOST);
console->write(" on ");
console->write(__DATE__);
console->write(" ");
console->write(__TIME__);
console->write(" using GCC ");
console->write(__VERSION__);
console->write("\n");
// back to normal coloring scheme
terminal->setColor(MAKE_COLOR(TERMINAL_BLACK, TERMINAL_LIGHTGRAY, FALSE));
Core::ResourceManager* manager = Core::ResourceManager::getInstance();
// static resource initialisation
manager->registerResource(Core::KernelAllocator::getInstance());
manager->registerResource(Core::StaticAllocator::getInstance());
manager->registerResource(Core::Video::getInstance());
manager->registerResource(console);
manager->registerResource(terminal);
// check grub
Grub::GrubChecker* grubChecker = new Grub::GrubChecker(magic, address);
/*!\todo print memory size */
grubChecker->getMemorySize();
Core::Architecture::detectArchitecture();
// infinite loop
for(;;);
return E_SUCCESS;
}