-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathkmain.cpp
More file actions
executable file
·111 lines (87 loc) · 2.1 KB
/
Copy pathkmain.cpp
File metadata and controls
executable file
·111 lines (87 loc) · 2.1 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
107
108
109
110
111
// *******************************
// FILE: kmain.cpp
// AUTHOR: SharpCoder
// DATE: 2012-03-18
// ABOUT: This is the entry point for my C++ based
// raspberry pi kernel.
//
// LICENSE: Provided "AS IS". USE AT YOUR OWN RISK.
// *******************************
#include "irq.cpp"
#include "raspberrylib.cpp"
#include "gpu2d.cpp"
#include "console.cpp"
#include "keyboard.h"
// Include the meta data generate at compile time
#include "./libs/mem.h"
#include "./libs/math.h"
#include "./libs/string.h"
#include "meta.h"
using namespace RaspberryLib;
Console* console;
// Define any functions.
void print_header( Console* console );
void printf( const char* c);
void assert( const char* c);
extern "C" void enable_irq();
void run1() {
while(true) {
// NOTE: locking mechanism has issues...
lock();
// NOTE: printf() is not thread safe.
//printf("Hello from thread 1\n");
unlock();
Wait(1000);
}
}
void run2() {
while(true) {
// NOTE: locking mechanism has issues...
lock();
// NOTE: printf() is not thread safe.
//printf("Hello from thread 2\n");
unlock();
Wait(1000);
}
}
// Define the entry point for our application.
// Note: It must be marked as "extern" in order for the linker
// to see it properly.
extern "C" void kmain( void ) {
// Initialize the irq
irq_init();
// Initialize at zero.
sbrk(0);
// Create a canvas.
gpu2dCanvas canvas(false);
// Create a console.
console = new Console(&canvas);
// setup the IRQ console
irqConsole = console;
// Draw to the console.
print_header( console );
//UsbInitialise();
//assert("Keyboard Initialized");
// Queue up a few jobs.
fork(&run1);
fork(&run2);
// Setup IRQ
assert("IRQ Enabled");
enable_irq();
// Hang forever.
while(1) { }
return;
}
void assert(const char* val) {
console->kout(val);
}
void printf(const char* val) {
console->kprint(val);
}
void print_header( Console* console ) {
meta info = getBuildInfo();
console->kprint("Welcome to Mindflayer, a custom raspberry pi kernel written in C++\n");
console->kprint("Build: ");
console->kprint( info.VERSION );
console->kprint("\n\n\n");
}