Commit 9d840e8b authored by Kevin Wolf's avatar Kevin Wolf
Browse files

kernel2: Neuer Syscall lio_ioctl()


+ kernel2: Mit lio_ioctl() gibt es jetzt einen Syscall, um
  ressourcenspezifische Befehle auszuführen. Dieser Commit enthält nur
  die Infrastruktur und implementiert noch keinen solchen Befehl.
Signed-off-by: Kevin Wolf's avatarKevin Wolf <kevin@tyndur.org>
parent d6e56ca0
No related merge requests found
Showing with 77 additions and 0 deletions
+77 -0
......@@ -113,6 +113,7 @@
#define SYSCALL_LIO_DUP 102
#define SYSCALL_LIO_STREAM_ORIGIN 103
#define SYSCALL_LIO_PIPE 104
#define SYSCALL_LIO_IOCTL 105
#define SYSCALL_LIO_SRV_SERVICE_REGISTER 110
#define SYSCALL_LIO_SRV_TREE_SET_RING 111
......
......@@ -177,6 +177,16 @@ int lio_truncate(struct lio_stream* s, uint64_t size);
*/
int lio_close(struct lio_stream* s);
/**
* Führt einen ressourcenspezifischen Befehl auf einem Stream aus.
*
* @param s Stream, auf den sich der Befehl bezieht
* @param cmd Auszuführender Befehl (LIO_IOCTL_*-Konstanten)
*
* @return 0 bei Erfolg, negativ im Fehlerfall.
*/
int lio_ioctl(struct lio_stream* s, int cmd);
/**
* Inhalt eines Verzeichnisses auslesen
*/
......
......@@ -250,6 +250,9 @@ int syscall_lio_sync(lio_usp_stream_t* stream_id);
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);
/// Ressourcenspezifischen Befehl ausführen
int syscall_lio_ioctl(lio_usp_stream_t* stream_id, int cmd);
/// Neue Datei anlegen
void syscall_lio_mkfile(lio_usp_resource_t* parent, const char* name,
size_t name_len, lio_usp_resource_t* result);
......
......@@ -742,6 +742,19 @@ int lio_close(struct lio_stream* s)
return 0;
}
/**
* Führt einen ressourcenspezifischen Befehl auf einem Stream aus.
*
* @param s Stream, auf den sich der Befehl bezieht
* @param cmd Auszuführender Befehl (LIO_IOCTL_*-Konstanten)
*
* @return 0 bei Erfolg, negativ im Fehlerfall.
*/
int lio_ioctl(struct lio_stream* s, int cmd)
{
return -ENOTTY;
}
/**
* Inhalt eines Verzeichnisses auslesen
*/
......
......@@ -135,6 +135,7 @@ void syscall_init()
syscall_register(SYSCALL_LIO_PROBE_SERVICE, &syscall_lio_probe_service, 2);
syscall_register(SYSCALL_LIO_DUP, &syscall_lio_dup, 2);
syscall_register(SYSCALL_LIO_STREAM_ORIGIN, &syscall_lio_stream_origin, 1);
syscall_register(SYSCALL_LIO_IOCTL, &syscall_lio_ioctl, 2);
syscall_register(SYSCALL_LIO_SRV_SERVICE_REGISTER,
&syscall_lio_srv_service_register, 4);
......
......@@ -312,6 +312,20 @@ void syscall_lio_read_dir(lio_usp_resource_t* resid, size_t start, size_t num,
free(int_buf);
}
/// Ressourcenspezifischen Befehl ausführen
int syscall_lio_ioctl(lio_usp_stream_t* stream_id, int cmd)
{
struct lio_usp_stream* fd;
// TODO: Ein paar is_userspace
fd = lio_usp_get_stream(current_process, *stream_id);
if (fd == NULL) {
return -EBADF;
}
return lio_ioctl(fd->stream, cmd);
}
/// Neue Datei anlegen
void syscall_lio_mkfile(lio_usp_resource_t* parent, const char* name,
size_t name_len, lio_usp_resource_t* result)
......
......@@ -319,6 +319,16 @@ int64_t lio_seek(lio_stream_t s, uint64_t offset, int whence);
*/
int lio_truncate(lio_stream_t s, uint64_t size);
/**
* Führt einen ressourcenspezifischen Befehl auf einem Stream aus.
*
* @param s Stream, auf den sich der Befehl bezieht
* @param cmd Auszuführender Befehl (LIO_IOCTL_*-Konstanten)
*
* @return 0 bei Erfolg, negativ im Fehlerfall.
*/
int lio_ioctl(lio_stream_t s, int cmd);
/**
* Liest Einträge einer Verzeichnisressource aus.
*
......
......@@ -426,6 +426,31 @@ int lio_truncate(lio_stream_t s, uint64_t size)
return result;
}
/**
* Führt einen ressourcenspezifischen Befehl auf einem Stream aus.
*
* @param s Stream, auf den sich der Befehl bezieht
* @param cmd Auszuführender Befehl (LIO_IOCTL_*-Konstanten)
*
* @return 0 bei Erfolg, negativ im Fehlerfall.
*/
int lio_ioctl(lio_stream_t s, int cmd)
{
int result;
asm(
"pushl %3;"
"pushl %2;"
"mov %1, %%eax;"
"int $0x30;"
"add $0x10, %%esp;"
: "=a" (result)
: "i" (SYSCALL_LIO_IOCTL), "r" (&s), "r" (cmd)
: "memory");
return result;
}
/**
* Liest Einträge einer Verzeichnisressource aus.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment