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 "cds/creator.h"
28 #include "cds/driver.h"
29 #include "cds/factory.h"
30 #include "cds/abstract.h"
31 #include "services/kernel_state.h"
33 using namespace manes
;
34 using namespace manes::cds
;
36 p
<component
> manec::comp
= (component
*)0;
37 p
<manec
> manec::instance
= (manec
*)0;
39 manec::manec() : usermode(false) {}
41 void manec::connect_manes(p
<root
> root_mgr
) {
43 types
= main
->get_component(component_name::from_path("/factory"));
46 void manec::connect_manes() {
49 __asm__ ("int $0x32": "=a" (main
));
52 main
->usermode
= true;
55 p
<manec
> manec::get() {
56 if (!instance
.valid()) {
58 // p<type> tpe = new abstract(type::zero, type_name("nme",true), type_name("nme",true));
59 // comp = new component((component*)0, tpe, instance.cast<implementation>());
62 return instance
; //comp->get<manec>();
65 p
<services::kernel_state
> manec::state() {
67 kstate
= get
<services::kernel_state
>("/kernel_state");
71 bool manec::far_calls() {
75 p
<error
> manec::err_msg(const string
&x
) {
76 return state()->new_error(x
);
79 p
<component
> manec::get_component(const component_name
&obj
) {
80 return main
->get_component(obj
);
83 p
<component
> manec::get_component(const string cname
) {
84 return get_component(component_name::from_index(cname
,0));
87 p
<component
> manec::get_by_path(const string
&tpath
) {
88 return get_component(component_name::from_path(tpath
));
91 void manec::register_type(const string
&me
, const string
&parent
, delegate
<p
<component
> > deleg
) {
92 register_type(new type(component_name::from_path((string
)"/type," + me
), component_name::from_path((string
)"/type," + parent
), deleg
));
95 void manec::register_driver(const string
&me
,const string
&parent
, delegate
<p
<component
> > deleg
, delegate
<bool, p
<resources::did
> > check
) {
96 register_type(new driver(component_name::from_path((string
)"/type," + me
), component_name::from_path((string
)"/type," + parent
), deleg
, check
));
97 main
->type_added(component_name::from_path((string
)"/type," + me
));
100 void manec::register_abstract(const string
&me
, const string
&parent
) {
101 register_type(new abstract(component_name::from_path((string
)"/type," + me
), component_name::from_path((string
)"/type," + parent
)));
104 void manec::register_type(p
<type
> tpe
) {
106 throw new argument_null_exception();
108 types
->add_existing(tpe
);
111 p
<type
> manec::get_type(const component_name
&tpe
) {
112 return types
->get_component(tpe
).cast
<type
>();
115 p
<type
> manec::get_driver(p
<resources::did
> id
) {
116 for (int i
= 0; i
< types
->count(); i
++) {
117 p
<type
> drv
= types
->get_component(component_name::from_index("driver", i
)).cast
<type
>();
118 if (drv
.cast
<driver
>().valid() && drv
.cast
<driver
>()->check_device(id
))
122 // throw new driver_not_found_exception();
123 return p
<type
>::invalid
;
126 arch::irq_op
*manec::get_low() {
130 p
<root
> manec::get_root() {
135 p
<factory
> manec::get_factory() {