Last change
on this file since 694253c was f42ee6f, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago |
Add basic structures for sysman
Conflicts:
boot/Makefile.common
|
-
Property mode
set to
100644
|
File size:
804 bytes
|
Line | |
---|
1 | #include <adt/list.h>
|
---|
2 | #include <assert.h>
|
---|
3 | #include <errno.h>
|
---|
4 | #include <fibril_synch.h>
|
---|
5 |
|
---|
6 | #include "configuration.h"
|
---|
7 |
|
---|
8 | static list_t units;
|
---|
9 | static fibril_mutex_t units_mtx;
|
---|
10 |
|
---|
11 | void configuration_init(void)
|
---|
12 | {
|
---|
13 | list_initialize(&units);
|
---|
14 | fibril_mutex_initialize(&units_mtx);
|
---|
15 | }
|
---|
16 |
|
---|
17 | int configuration_add_unit(unit_t *unit)
|
---|
18 | {
|
---|
19 | assert(unit);
|
---|
20 | assert(unit->state == STATE_EMBRYO);
|
---|
21 |
|
---|
22 | fibril_mutex_lock(&units_mtx);
|
---|
23 | list_append(&unit->units, &units);
|
---|
24 |
|
---|
25 | // TODO check name uniqueness
|
---|
26 | fibril_mutex_unlock(&units_mtx);
|
---|
27 | return EOK;
|
---|
28 | }
|
---|
29 |
|
---|
30 | /** Marks newly added units as usable (via state change) */
|
---|
31 | int configuration_commit(void)
|
---|
32 | {
|
---|
33 | fibril_mutex_lock(&units_mtx);
|
---|
34 | list_foreach(units, units, unit_t, u) {
|
---|
35 | if (u->state == STATE_EMBRYO) {
|
---|
36 | u->state = STATE_STOPPED;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | fibril_mutex_unlock(&units_mtx);
|
---|
40 |
|
---|
41 | return EOK;
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.