2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <cdi/lists.h>
26 #include <cdi/storage.h>
37 cdi_debug("destroy\n");
38 struct cdi_driver
* driver
;
39 while ((driver
= cdi_list_pop(cdi_drivers
))) driver
->destroy(driver
);
48 cdi_drivers
= cdi_list_create();
49 cdi_filesystems
= cdi_list_create();
55 * Runs all CDI drivers
57 void cdi_run_drivers() {
58 cdi_debug("run drivers\n");
59 struct cdi_driver
* driver
;
60 struct cdi_device
* device
;
63 for (i
=0;(driver
= cdi_list_get(cdi_drivers
,i
));i
++) {
64 cdi_debug("init driver: %s\n",driver
->name
);
65 for (j
= 0;(device
= cdi_list_get(driver
->devices
,j
));j
++) {
66 device
->driver
= driver
;
67 if (driver
->init_device
!=NULL
) driver
->init_device(device
);
75 * Initializes a CDI driver
76 * @param driver Driver to initialize
78 void cdi_driver_init(struct cdi_driver
* driver
) {
79 cdi_debug("driver init\n");
80 driver
->devices
= cdi_list_create();
84 * Destroys a CDI driver
85 * @param driver Driver to destroy
87 void cdi_driver_destroy(struct cdi_driver
* driver
) {
88 cdi_debug("driver destroy: %s\n",driver
->name
);
89 cdi_list_destroy(driver
->devices
);
93 * Registers a CDI driver
94 * @param driver Driver to register
96 void cdi_driver_register(struct cdi_driver
* driver
) {
97 cdi_debug("driver register: %s\n",driver
->name
);
98 cdi_list_push(cdi_drivers
,driver
);
102 * Prints debug message
104 * @param ... Parameters
106 void cdi_debug(const char *fmt
,...) {
110 fprintf(CDI_DEBUG
,"cdi (%d): ",getpid());
111 vfprintf(CDI_DEBUG
,fmt
,args
);