5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 /* This file consist of functions that are called in order to run Manes. It
25 * includes initialization of hardware and internal kernel data structures.
26 * After this operation kernel can change to the standard way of working witch
27 * preemption, resources, actors and so on.
31 * @mainpage Quarn OS Documentation
32 * @image html http://quarnos.org/img/qoslogo.png
35 #error Quarn OS is needed to be compiled on GCC 4 or later.
39 #include "services/kernel_state.h"
42 #include "resources/stream.h"
43 #include "arch/low/general.h"
44 #include "resources/block.h"
46 #include "arch/low/launch.h"
47 #include "arch/low/console.h"
48 #include "resources/fs.h"
49 #include "services/logger.h"
50 #include "resources/bus.h"
51 #include "resources/ethernet.h"
52 #include "resources/fat.h"
53 #include "resources/pci.h"
54 #include "resources/isa.h"
55 #include "libs/delegate.h"
56 #include "libs/string.h"
57 #include "modules/loader.h"
58 #include "resources/file.h"
59 #include "services/unmangler.h"
60 #include "actors/actor.h"
61 #include "actors/director.h"
62 #include "modules/module.h"
63 #include "resources/pio.h"
64 #include "libs/setjmp.h"
65 #include "services/stats.h"
66 #include "libs/pointer.h"
68 #include "resources/ne2k.h"
69 #include "resources/ipv4.h"
70 #include "resources/arp.h"
71 #include "resources/icmp.h"
73 using namespace services
;
74 using namespace modules
;
75 using namespace resources
;
76 using namespace manes
;
78 using namespace actors
;
82 void *operator new(unsigned int, int);
84 extern char *comp_vtable
;
87 extern "C" void jump_v86();
88 #include "arch/low/pit.h"
89 #if USE_MULTIBOOT == CONF_YES
90 extern "C" void start() {
92 extern "C" void _start() {
94 delegate
<void,const char> del
;
96 /* Prepare to execute C++ code */
99 /* Launch Managed Execution System */
100 manei::get()->launch_manes();
102 manec::get()->connect_manes(manei::get()->get_root());
104 p
<manec
> main
= manec::get();
107 main
->register_abstract("storage", "noeene");
108 main
->register_abstract("console", "naaone");
109 main
->register_abstract("nic", "none");
111 /* Run low-level procedures */
114 /* Register creators */
115 manei::get()->register_creators();
117 /* Register built in types */
118 manei::get()->register_builtin_types();
121 manei::get()->animate_creators();
123 /* Initialize clock */
126 /* Manes is ready to use */
127 p
<logger
> log
= main
->get
<logger
>("/early_logger");
131 log
->print("OK.\nStarting Quarn OS...",logger::log_critical
);
139 tty = main->get<stream>("/keybscr");
143 log->print("cannot create tty", services::logger::log_info);
147 p
<stats
> stat
= main
->get
<stats
>("/stats");
149 p
<logger
> tlog
= main
->get
<logger
>("/tty_logger");
150 tlog
->print((string
)"EFC caught so far " + stat
->get_value(services::stats::efc_calls
) + " function calls.", services::logger::log_info
);
152 p
<bus
> mainbus
= main
->get
<bus
>("/isa");
153 tlog
->print((string
)"\nFound ISA devices: " + mainbus
->get_count(), services::logger::log_info
);
155 p
<bus
> pbus
= main
->get
<bus
>("/pci");
156 tlog
->print((string
)"\nFound PCI devices: " + pbus
->get_count(), services::logger::log_info
);
158 tlog
->print((string
)"\nAvailable memory: " + manec::get()->state()->get_memory_size() / 1024 / 1024 + " MB\n\n", services::logger::log_info
);
164 ip
.set_link_layer(ð
);
165 ip
.configure_ipv4(192 << 24 | 168 << 16 | 1 << 8 | 50, 255 << 24 | 255 << 16 | 255 << 8, 192 << 24 | 168 << 16 | 1 << 8 | 1);
169 // ping.ping(192 << 24 | 168 << 16 | 1 << 8 | 2);
171 // ping.ping(192 << 24 | 168 << 16 | 1 << 8 | 2);
173 p
<block
> floppy
= main
->get
<block
>("/fdc");
174 p
<fs
> fs_floppy
= main
->get
<fs
>("/fat");
176 type
*pcit
= main
->get
<type
>("/type,pci");
178 fs_floppy
->mount(floppy
);
179 p
<file
> temp
= main
->get
<file
>("/file,authors");
181 tlog
->print((string
)(const char*)((const string
)*temp
), services::logger::log_warning
);
183 p
<modules::module
> mod
= main
->get_component(component_name((type_name
)"loader",0))->get
<loader
>()->get_component(component_name((type_name
)"module","rs232.ko"))->get
<modules::module
>();
184 mod
->place(module::module_kernel_space
);
185 mod
->get_delegate()();
187 p
<unmangler
> unman
= main
->get
<unmangler
>("/unmangler");
189 stream
*serial
= main
->get
<stream
>("/console,1");
191 string name
= unman
->unmangle(typeid(*serial
).name());
192 serial
->write_bytes(name
, name
.length());
194 delegate
<void> del_next
;
195 del_next
.function(next
);
199 p
<director
> sched
= main
->get_component(component_name((type_name
)"director",0))->get
<director
>();
200 p
<actor
> proc
= sched
->new_component((type_name
)"actor")->get
<actor
>();
204 for (int i = 0; i < 10000; i++)
205 for (int j = 0; j < 1000; j++)
206 stat->get_value(stats::ks_timeticks);
208 tlog
->print((string
)"EFC caught so far " + stat
->get_value(services::stats::efc_calls
) + " function calls.\n", services::logger::log_info
);
209 string ss
= stat
->full_stats();
210 serial
->write_bytes(ss
, ss
.length());
211 //tlog->print(ss, services::logger::log_warning);
218 p
<manec
> main
= manec::get();
220 p
<modules::module
> mod
= main
->get
<modules::module
>("/module,shell.ko");
221 mod
->place(module::module_kernel_space
);
223 /* p<director> sched = main->get_component(component_name((type_name)"director",0))->get<director>();
224 p<actor> proc = sched->new_component((type_name)"actor")->get<actor>();
225 proc->set(mod->get_delegate());
226 sched->start(proc);*/
229 stream
*ttyS
= main
->get
<stream
>("/console,1");
231 pio
*str
= main
->get
<pio
>("/pio");
233 char buffer
[] = "\n\xdHello World!!!";
235 str
->send_packet(buffer
,strlen(buffer
));
238 str
->start(false, nul
);
240 while (1) __asm__("hlt");