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

[tyndur-devel] [PATCH 1/6] kernel2: Stubs für LIOv2-Clientsyscalls



+ kernel2: Stubs für die Clientsyscalls von LIOv2 eingefügt. Damit
  schlagen entsprechende Funktionsaufrufe zwar noch fehl, aber prinzipiell
  könnte jetzt ein für LIOv2 kompiliertes Programm auch auf master laufen.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/include/syscall_structs.h     |   79 ++++++++++++++++++++
 src/kernel2/include/syscall.h     |   60 +++++++++++++++
 src/kernel2/src/syscall.c         |   16 ++++
 src/kernel2/src/syscalls/lostio.c |  144 +++++++++++++++++++++++++++++++++++++
 4 files changed, 299 insertions(+), 0 deletions(-)
 create mode 100644 src/kernel2/src/syscalls/lostio.c

diff --git a/src/include/syscall_structs.h b/src/include/syscall_structs.h
index b15b612..c23d39e 100644
--- a/src/include/syscall_structs.h
+++ b/src/include/syscall_structs.h
@@ -74,4 +74,83 @@ typedef struct
     uint16_t es;
 } vm86_regs_t;
 
+// LIO2
+
+/** ID eines LostIO-Streams */
+typedef int64_t lio_usp_stream_t;
+
+/** ID einer LostIO-Ressource */
+typedef int64_t lio_usp_resource_t;
+
+/**
+ * Gibt an, realtiv zu welcher Position in der Datei das lio_seek-Offset
+ * zu interpretieren ist.
+ */
+enum lio_seek_whence {
+    /** Offset ist relativ zum Dateianfang */
+    LIO_SEEK_SET = 0,
+
+    /** Offset ist relativ zur aktuellen Position des Dateizeigers */
+    LIO_SEEK_CUR = 1,
+
+    /** Offset ist relativ zum Dateiende */
+    LIO_SEEK_END = 2,
+};
+
+/**
+ * Beschreibt als Bitmaske Fähgikeiten einer Ressource in
+ * struct lio_stat.flags
+ */
+enum lio_stat_flags {
+    /** Die Ressource ist lesbar */
+    LIO_FLAG_READABLE   = 1,
+
+    /** Die Ressource ist schreibbar */
+    LIO_FLAG_WRITABLE  = 2,
+
+    /** Die Ressource kann aufgelistet werden (ist ein Verzeichnis) */
+    LIO_FLAG_BROWSABLE  = 4,
+
+    /** Die Ressource verweist auf eine andere Ressource (Symlink) */
+    LIO_FLAG_RESOLVABLE = 8,
+
+    /** Das Verzeichnis ist schreibbar (Kindressourcen anlegen/löschen) */
+    LIO_FLAG_CHANGEABLE = 16,
+
+    /** Es kann geändert werden, auf welche Ressource verwiesen wird */
+    LIO_FLAG_RETARGETABLE = 32,
+
+    /** Dateizeiger von Streams auf die Ressource können geändert werden */
+    LIO_FLAG_SEEKABLE = 64,
+
+    /** Die Ressource ist eine (bidirektionale) Pipe */
+    LIO_FLAG_PIPE = 128,
+};
+
+/**
+ * Beschreibt eine Ressource
+ */
+struct lio_stat {
+    /** Größe der Ressource in Bytes */
+    uint64_t size;
+
+    /** Bitmaske aus enum lio_stat_flags */
+    uint32_t flags;
+} __attribute__((packed));
+
+/** Maximale Länge eines Dateinamens */
+#define LIO_MAX_FNLEN 255
+
+/** Beschreibt einen Verzeichniseintrag */
+struct lio_usp_dir_entry {
+    /** ID der Ressource (zur Benutzung mit lio_open) */
+    lio_usp_resource_t resource;
+
+    /** Dateiname der Ressource */
+    char               name[LIO_MAX_FNLEN + 1];
+
+    /** lio_stat-kompatible Beschreibung der Ressource */
+    struct lio_stat    stat;
+} __attribute__((packed));
+
 #endif
diff --git a/src/kernel2/include/syscall.h b/src/kernel2/include/syscall.h
index 54fc472..2eb93b0 100644
--- a/src/kernel2/include/syscall.h
+++ b/src/kernel2/include/syscall.h
@@ -38,6 +38,7 @@
 
 #include <types.h>
 #include <stdint.h>
+#include <syscall_structs.h>
 
 #include "cpu.h"
 
@@ -169,6 +170,65 @@ void syscall_fastrpc_ret(void);
 /// Interrupt registrieren
 void syscall_add_interrupt_handler(uint32_t intr);
 
+
+// LIO
+/// Ressource suchen
+void syscall_lio_resource(const char* path, size_t path_len, int flags,
+    lio_usp_resource_t* res_id);
+
+/// Informationen über eine Ressource abfragen
+int syscall_lio_stat(lio_usp_resource_t* resid, struct lio_stat* sbuf);
+
+/// Ressource öffnen
+void syscall_lio_open(lio_usp_resource_t* resid, int flags,
+    lio_usp_stream_t* stream_id);
+
+/// Stream schließen
+int syscall_lio_close(lio_usp_stream_t* stream_id);
+
+/// Aus Stream lesen
+void syscall_lio_read(lio_usp_stream_t* stream_id, uint64_t* offset,
+    size_t bytes, void* buffer, int updatepos, ssize_t* result);
+
+/// In Stream schreiben
+void syscall_lio_write(lio_usp_stream_t* stream_id, uint64_t* offset,
+    size_t bytes, const void* buffer, int updatepos, ssize_t* result);
+
+/// Cursorposition in der Datei ändern
+void syscall_lio_seek(lio_usp_stream_t* stream_id, int64_t* offset,
+    int whence, int64_t* result);
+
+/// Dateigröße ändern
+int syscall_lio_truncate(lio_usp_stream_t* stream_id, uint64_t* size);
+
+/// Veränderte Blocks schreiben
+int syscall_lio_sync(lio_usp_stream_t* stream_id);
+
+/// Verzeichnisinhalt auslesen
+void syscall_lio_read_dir(lio_usp_resource_t* res, size_t start, size_t num,
+    struct lio_usp_dir_entry* dent, ssize_t* result);
+
+/// Neue Datei anlegen
+void syscall_lio_mkfile(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, lio_usp_resource_t* result);
+
+/// Neues Verzeichnis anlegen
+void syscall_lio_mkdir(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, lio_usp_resource_t* result);
+
+/// Neuen Symlink anlegen
+void syscall_lio_mksymlink(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, const char* target, size_t target_len,
+    lio_usp_resource_t* result);
+
+/// Verzeichniseintrag löschen
+int syscall_lio_unlink(lio_usp_resource_t* parent, const char* name,
+    size_t name_len);
+
+/// Alle Blocks rausschreiben, die sich im Cache befinden
+int syscall_lio_sync_all(int soft);
+
+
 // Diverse
 /// Textausgabe ueber den Kernel
 void syscall_putsn(int char_count, char* source);
diff --git a/src/kernel2/src/syscall.c b/src/kernel2/src/syscall.c
index c605e62..1871739 100644
--- a/src/kernel2/src/syscall.c
+++ b/src/kernel2/src/syscall.c
@@ -100,6 +100,22 @@ void syscall_init()
     syscall_register(SYSCALL_VM86, &syscall_vm86_old, 2);
     syscall_register(SYSCALL_VM86_BIOS_INT, &syscall_vm86, 3);
 #endif
+
+    syscall_register(SYSCALL_LIO_RESOURCE, &syscall_lio_resource, 4);
+    syscall_register(SYSCALL_LIO_OPEN, &syscall_lio_open, 3);
+    syscall_register(SYSCALL_LIO_CLOSE, &syscall_lio_close, 1);
+    syscall_register(SYSCALL_LIO_READ, &syscall_lio_read, 6);
+    syscall_register(SYSCALL_LIO_WRITE, &syscall_lio_write, 6);
+    syscall_register(SYSCALL_LIO_SEEK, &syscall_lio_seek, 4);
+    syscall_register(SYSCALL_LIO_TRUNCATE, &syscall_lio_truncate, 2);
+    syscall_register(SYSCALL_LIO_SYNC, &syscall_lio_sync, 1);
+    syscall_register(SYSCALL_LIO_READ_DIR, &syscall_lio_read_dir, 5);
+    syscall_register(SYSCALL_LIO_MKFILE, &syscall_lio_mkfile, 4);
+    syscall_register(SYSCALL_LIO_MKDIR, &syscall_lio_mkdir, 4);
+    syscall_register(SYSCALL_LIO_MKSYMLINK, &syscall_lio_mksymlink, 6);
+    syscall_register(SYSCALL_LIO_STAT, &syscall_lio_stat, 2);
+    syscall_register(SYSCALL_LIO_UNLINK, &syscall_lio_unlink, 3);
+    syscall_register(SYSCALL_LIO_SYNC_ALL, &syscall_lio_sync_all, 0);
 }
 
 /**
diff --git a/src/kernel2/src/syscalls/lostio.c b/src/kernel2/src/syscalls/lostio.c
new file mode 100644
index 0000000..b7a3933
--- /dev/null
+++ b/src/kernel2/src/syscalls/lostio.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2009-2011 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Antoine Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the tyndur Project
+ *     and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "kprintf.h"
+#include "syscall.h"
+#include <syscall_structs.h>
+
+/// Ressource suchen
+void syscall_lio_resource(const char* path, size_t path_len, int flags,
+    lio_usp_resource_t* res_id)
+{
+    *res_id = -1;
+}
+
+/// Informationen über eine Ressource abfragen
+int syscall_lio_stat(lio_usp_resource_t* resid, struct lio_stat* sbuf)
+{
+    return -ENOSYS;
+}
+
+/// Ressource öffnen
+void syscall_lio_open(lio_usp_resource_t* resid, int flags,
+    lio_usp_stream_t* stream_id)
+{
+    *stream_id = -1;
+}
+
+/// Stream schließen
+int syscall_lio_close(lio_usp_stream_t* stream_id)
+{
+    return -ENOSYS;
+}
+
+/// Aus Stream lesen
+void syscall_lio_read(lio_usp_stream_t* stream_id, uint64_t* offset,
+    size_t bytes, void* buffer, int updatepos, ssize_t* result)
+{
+    *result = -1;
+}
+
+/// In Stream schreiben
+void syscall_lio_write(lio_usp_stream_t* stream_id, uint64_t* offset,
+    size_t bytes, const void* buffer, int updatepos, ssize_t* result)
+{
+    *result = -1;
+}
+
+/// Cursorposition in der Datei ändern
+void syscall_lio_seek(lio_usp_stream_t* stream_id, int64_t* offset,
+    int whence, int64_t* result)
+{
+    *result = -1;
+}
+
+/// Verzeichnisinhalt auslesen
+void syscall_lio_read_dir(lio_usp_resource_t* resid, size_t start, size_t num,
+    struct lio_usp_dir_entry* buf, ssize_t* result)
+{
+    *result = -1;
+}
+
+/// Neue Datei anlegen
+void syscall_lio_mkfile(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, lio_usp_resource_t* result)
+{
+    *result = -1;
+}
+
+/// Neues Verzeichnis anlegen
+void syscall_lio_mkdir(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, lio_usp_resource_t* result)
+{
+    *result = -1;
+}
+
+/// Neuen Symlink anlegen
+void syscall_lio_mksymlink(lio_usp_resource_t* parent, const char* name,
+    size_t name_len, const char* target, size_t target_len,
+    lio_usp_resource_t* result)
+{
+    *result = -1;
+}
+
+/// Veränderte Blocks schreiben
+int syscall_lio_sync(lio_usp_stream_t* stream_id)
+{
+    return -ENOSYS;
+}
+
+/// Dateigröße ändern
+int syscall_lio_truncate(lio_usp_stream_t* stream_id, uint64_t* size)
+{
+    return -ENOSYS;
+}
+
+/// Verzeichniseintrag löschen
+int syscall_lio_unlink(lio_usp_resource_t* parent, const char* name,
+    size_t name_len)
+{
+    return -ENOSYS;
+}
+
+/// Alle veränderten Blocks im Cache rausschreiben
+int syscall_lio_sync_all(int soft)
+{
+    return -ENOSYS;
+}
+
-- 
1.6.0.2