[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v3 2/5] cdi: SCSI



+ cdi: Headerdatei und leere Implementierung fuer SCSI-Geraete
---
 src/modules/cdi/include/cdi.h      |    3 +-
 src/modules/cdi/include/cdi/scsi.h |  111 ++++++++++++++++++++++++++++++++++++
 src/modules/cdi/lib/scsi/driver.c  |   51 ++++++++++++++++
 3 files changed, 164 insertions(+), 1 deletions(-)
 create mode 100644 src/modules/cdi/include/cdi/scsi.h
 create mode 100644 src/modules/cdi/lib/scsi/driver.c

diff --git a/src/modules/cdi/include/cdi.h b/src/modules/cdi/include/cdi.h
index 42e4643..5fb7025 100644
--- a/src/modules/cdi/include/cdi.h
+++ b/src/modules/cdi/include/cdi.h
@@ -23,7 +23,8 @@
 typedef enum {
     CDI_UNKNOWN         = 0,
     CDI_NETWORK         = 1,
-    CDI_STORAGE         = 2
+    CDI_STORAGE         = 2,
+    CDI_SCSI            = 3,
 } cdi_device_type_t;
 
 struct cdi_driver;
diff --git a/src/modules/cdi/include/cdi/scsi.h b/src/modules/cdi/include/cdi/scsi.h
new file mode 100644
index 0000000..9f5b0e7
--- /dev/null
+++ b/src/modules/cdi/include/cdi/scsi.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2008 Janosch Graef
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+/**
+ * Treiber fuer SCSI-Geraete
+ * \defgroup scsi
+ */
+/*\@{*/
+
+#ifndef _CDI_SCSI_H_
+#define _CDI_SCSI_H_
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "cdi.h"
+
+/// SCSI-Paket
+struct cdi_scsi_packet {
+    /// Buffer zum Senden oder Empfangen von Daten
+    void *buffer;
+
+    /// Groesse des Buffers
+    size_t bufsize;
+
+    /// Ob gelesen oder geschrieben werden soll
+    enum {
+        CDI_SCSI_NODATA,
+        CDI_SCSI_READ,
+        CDI_SCSI_WRITE,
+    } direction;
+
+    /// SCSI-Befehl
+    uint8_t command[16];
+
+    /// Groesse des SCSI-Befehls
+    size_t cmdsize;
+};
+
+/// SCSI-Geraet
+struct cdi_scsi_device {
+
+    struct cdi_device dev;
+
+    /// Geraetetyp, der ueber SCSI angesteuert wird
+    cdi_device_type_t type;
+
+};
+
+/// SCSI-Treiber
+struct cdi_scsi_driver {
+
+    struct cdi_driver drv;
+
+    /**
+     * Sendet ein SCSI-Paket an das Geraet.
+     *
+     * @return SCSI-Fehlerstatus nach der Ausfuehrung des Befehls
+     */
+    int (*request)(struct cdi_scsi_device *device,
+        struct cdi_scsi_packet *packet);
+};
+
+/**
+ * Ein SCSI-Paket allozieren
+ *
+ * @param size Benoetigte Groesse
+ *
+ * @return Pointer auf das Paket oder NULL im Fehlerfall
+ */
+struct cdi_scsi_packet* cdi_scsi_packet_alloc(size_t size);
+
+/**
+ * Ein SCSI-Paket freigeben
+ *
+ * @param packet Pointer auf das Paket
+ */
+void cdi_scsi_packet_free(struct cdi_scsi_packet* packet);
+
+/**
+ * Initialisiert die Datenstrukturen fuer einen SCSI-Treiber
+ */
+void cdi_scsi_driver_init(struct cdi_scsi_driver* driver);
+
+/**
+ * Deinitialisiert die Datenstrukturen fuer einen SCSI-Treiber
+ */
+void cdi_scsi_driver_destroy(struct cdi_scsi_driver* driver);
+
+/**
+ * Registiert einen SCSI-Treiber
+ */
+void cdi_scsi_driver_register(struct cdi_scsi_driver* driver);
+
+/**
+ * Initialisiert ein neues SCSI-Geraet
+ *
+ * Der Typ der Geraetes muss bereits gesetzt sein
+ */
+void cdi_scsi_device_init(struct cdi_scsi_device* device);
+
+#endif
+
+/*\@}*/
diff --git a/src/modules/cdi/lib/scsi/driver.c b/src/modules/cdi/lib/scsi/driver.c
new file mode 100644
index 0000000..63e1e8c
--- /dev/null
+++ b/src/modules/cdi/lib/scsi/driver.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Kevin Wolf
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <lostio.h>
+
+#include "cdi/scsi.h"
+
+/**
+ * Initialisiert die Datenstrukturen fuer einen SCSI-Treiber
+ */
+void cdi_scsi_driver_init(struct cdi_scsi_driver* driver)
+{
+    driver->drv.type = CDI_SCSI;
+    cdi_driver_init((struct cdi_driver*) driver);
+}
+
+/**
+ * Deinitialisiert die Datenstrukturen fuer einen SCSI-Treiber
+ */
+void cdi_scsi_driver_destroy(struct cdi_scsi_driver* driver)
+{
+    cdi_driver_destroy((struct cdi_driver*) driver);
+}
+
+/**
+ * Initialisiert ein neues SCSI-Geraet
+ *
+ * Der Typ der Geraetes muss bereits gesetzt sein
+ */
+void cdi_scsi_device_init(struct cdi_scsi_device* device)
+{
+}
+
+/**
+ * Registiert den Treiber fuer SCSI-Geraete
+ */
+void cdi_scsi_driver_register(struct cdi_scsi_driver* driver)
+{
+    cdi_driver_register((struct cdi_driver*) driver);
+}
-- 
1.5.4.5