First try in keyboard driver
[incOS.git] / programs / ramdisk / main.c
blob89466310942348374b667d517db4653e93fa6c98
1 /*
2 * Copyright (c) 2008 The LOST Project. All rights reserved.
4 * This code is derived from software contributed to the LOST Project
5 * by Alexander Siol and Janosch Graef.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the LOST Project
18 * and its contributors.
19 * 4. Neither the name of the LOST Project nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <stdint.h>
37 #include <stdlib.h>
38 #include <stdio.h>
40 #include "cdi/fs.h"
41 #include "cdi/misc.h"
43 #include "ramdisk_cdi.h"
45 struct ramdisk_driver {
46 struct cdi_fs_driver fs;
49 static struct ramdisk_driver ramdisk_driver;
50 static const char* driver_name = "ramdisk";
52 static int ramdisk_driver_init(struct ramdisk_driver* driver);
53 static void ramdisk_driver_destroy(struct cdi_driver* driver);
55 #ifdef CDI_STANDALONE
56 int main(void)
57 #else
58 int init_ramdisk(void)
59 #endif
61 cdi_init();
63 if (ramdisk_driver_init(&ramdisk_driver) != 0) {
64 return -1;
66 cdi_fs_driver_register((struct cdi_fs_driver*) &ramdisk_driver);
68 #ifdef CDI_STANDALONE
69 cdi_run_drivers();
70 #endif
72 return 0;
75 /**
76 * Initialisiert die Datenstrukturen fuer den ramdisk-Treiber
78 static int ramdisk_driver_init(struct ramdisk_driver* driver)
80 // Konstruktor der Vaterklasse
81 cdi_fs_driver_init((struct cdi_fs_driver*) driver);
83 // Namen setzen
84 driver->fs.drv.name = driver_name;
85 driver->fs.fs_init = ramdisk_fs_init;
86 driver->fs.fs_destroy = ramdisk_fs_destroy;
88 driver->fs.drv.destroy = ramdisk_driver_destroy;
89 return 0;
92 /**
93 * Deinitialisiert die Datenstrukturen fuer den ramdisk-Treiber
95 static void ramdisk_driver_destroy(struct cdi_driver* driver)
97 cdi_fs_driver_destroy((struct cdi_fs_driver*) driver);