increasing usage of p<>, minor bugs fixed [code still broken]
[quarnos.git] / manes / manei.cpp
blob17c0086c078f4f09e383076e64711cf6e7366fff
1 /* Quarn OS / Manes
3 * Manes Initializer implementation
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.
23 #include "creator.h"
24 #include "manec.h"
25 #include "manei.h"
26 #include "type.h"
27 #include "services/server.h"
29 #include "services/tty_logger.h"
30 #include "services/early_logger.h"
31 #include "services/timer.h"
32 #include "services/unmangler.h"
33 #include "services/stats.h"
34 #include "services/interrupt_manager.h"
35 #include "services/kernel_state.h"
36 #include "services/asynch_tasks.h"
38 #include "resources/buffer.h"
39 #include "resources/isa.h"
40 #include "resources/pci.h"
41 #include "resources/keybscr.h"
42 #include "resources/fdc.h"
43 #include "resources/fat.h"
44 #include "resources/speaker.h"
45 #include "resources/foma.h"
46 #include "resources/uhci.h"
47 #include "resources/file.h"
48 #include "resources/unknown.h"
49 #include "resources/virtual_bus.h"
50 #include "resources/pio.h"
51 #include "resources/physmem.h"
52 #include "resources/ne2k.h"
53 #include "resources/usb.h"
54 #include "resources/rtl8139.h"
56 #include "modules/loader.h"
57 #include "modules/module.h"
59 #include "actors/roundrobin.h"
60 #include "actors/actor.h"
62 using namespace manes;
64 p<manei> manei::instance = p<manei>::invalid;
66 p<manei> manei::get() {
67 if (!instance.valid())
68 instance = new manei;
69 return instance;
72 void manei::launch_manes() {
73 main = new root();
74 types = new factory();
76 string str_factory("factory");
77 type_name factory_tname(str_factory, 0);
79 delegate<p<implementation> > create_deleg;
81 string str("none");
82 type_name bname(str,0);
84 p<type> factory_type = new type(type::factory, bname, factory_tname, create_deleg);
86 p<component> comp = new component((component*)this, factory_type, types.cast<implementation>());
88 comp->get<factory>()->initialize();
89 comp->get<factory>()->register_impl(factory_type);
91 main->initialize(comp);
95 void manei::register_creators() {
96 /* server */
97 services::server::register_type();
99 /* loader */
100 modules::loader::register_type();
102 /* director */
103 actors::roundrobin::register_type();
105 /* fat */
107 /* slob */
108 resources::foma::register_type();
110 /* physmem */
111 resources::physmem::register_type();
113 /* isa-bus */
114 resources::isa::register_type();
116 /* pci-bus */
117 resources::pci::register_type();
119 /* virtual_bus */
120 resources::virtual_bus::register_type();
123 void manei::register_builtin_types() {
124 /* ---- SERVICES ---- */
126 /* early logger */
127 services::early_logger::register_type();
129 /* tty logger */
130 services::tty_logger::register_type();
132 /* timer */
133 services::timer::register_type();
135 /* unmangler */
136 services::unmangler::register_type();
138 /* stats */
139 services::stats::register_type();
141 /* interrupt_manager */
142 services::interrupt_manager::register_type();
144 /* kernel_state */
145 services::kernel_state::register_type();
147 /* asynch_tasks */
148 services::asynch_tasks::register_type();
150 /* ---- DEVICES ---- */
152 /* keybscr */
153 resources::keybscr::register_type();
155 /* fdc */
156 resources::fdc::register_type();
158 /* speaker */
159 resources::speaker::register_type();
161 /* pio */
162 resources::pio::register_type();
164 /* ne2k */
165 resources::ne2k::register_type();
167 /* usb */
168 resources::usb::register_type();
170 /* uhci */
171 resources::uhci::register_type();
173 /* unknown */
174 resources::unknown::register_type();
176 /* rtl8139 */
177 resources::rtl8139::register_type();
179 /* ---- OBJECTS ---- */
180 resources::buffer::register_type();
182 /* ---- FILE SYSTEMS ---- */
183 resources::fat::register_type();
185 resources::file::register_type();
187 /* ---- ACTORS ---- */
188 actors::actor::register_type();
190 /* ---- MODULES ---- */
191 modules::module::register_type();
194 void manei::animate_creators() {
195 /* animate server */
196 main->new_component((type_name)"server")->get<creator>()->initialize();
198 kstate = main->new_component((type_name)"kernel_state")->get<services::kernel_state>();
200 main->new_component((type_name)"physmem")->get<creator>()->initialize();
202 /* animate slob */
203 /* state()->set_memory_allocator(*/main->new_component((type_name)"foma")->get<resources::memm>()->initialize();/*);*/
204 asm("cli\nhlt");
205 /* animate loader */
206 main->new_component((type_name)"loader")->get<creator>()->initialize();
208 /* animate isa - main bus */
209 main->new_component((type_name)"isa")->get<creator>()->initialize();
211 /* animate pci */
212 main->new_component((type_name)"pci")->get<creator>()->initialize();
214 /* animate virtual_bus */
215 main->new_component((type_name)"virtual_bus")->get<creator>()->initialize();
217 /* animate fat - main fs (temp) */
218 main->new_component((type_name)"fat")->get<creator>()->initialize();
220 /* animate director */
221 main->new_component((type_name)"director")->get<creator>()->initialize();
224 p<root> manei::get_root() {
225 return main;
228 p<services::kernel_state> manei::state() {
229 return kstate;