From kevin at tyndur.org Sat Dec 5 11:02:58 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 11:02:58 +0100 Subject: [tyndur-devel] [PATCH] ramoverlay hinzugefuegt Message-ID: <1260007378-12445-1-git-send-email-kevin@tyndur.org> + ramoverlay: Ein LostIO-Service, der ueber eine schreibgeschuetze Ressource (z.B. eine CD-ROM) einen COW-Ramdisk legt, um temporaere Schreibzugriffe zu erlauben Signed-off-by: Kevin Wolf --- src/modules/ramoverlay/Makefile.all | 6 + src/modules/ramoverlay/main.c | 282 +++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+), 0 deletions(-) create mode 100644 src/modules/ramoverlay/Makefile.all create mode 100644 src/modules/ramoverlay/main.c diff --git a/src/modules/ramoverlay/Makefile.all b/src/modules/ramoverlay/Makefile.all new file mode 100644 index 0000000..8eacb97 --- /dev/null +++ b/src/modules/ramoverlay/Makefile.all @@ -0,0 +1,6 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh + +echo "LD $1/modules/ramoverlay" +$LOST_TOOLS_LD -Ttext=0x40000000 -oramoverlay.mod *.o --start-group $2 --end-group +$LOST_TOOLS_STRIP -s ramoverlay.mod -o $1/modules/ramoverlay diff --git a/src/modules/ramoverlay/main.c b/src/modules/ramoverlay/main.c new file mode 100644 index 0000000..654c383 --- /dev/null +++ b/src/modules/ramoverlay/main.c @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2009 The tyndur Project. All rights reserved. + * + * This code is derived from software contributed to the tyndur Project + * by Kevin Wolf. + * + * 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 +#include +#include +#include +#include +#include + +#define BLOCK_SIZE (256 * 1024) + +void overlay_post_open(lostio_filehandle_t* fh); +size_t overlay_read(lostio_filehandle_t*,void*,size_t,size_t); +size_t overlay_write(lostio_filehandle_t*,size_t,size_t,void*); +int overlay_seek(lostio_filehandle_t* fh, uint64_t offset, int origin); +int overlay_close(lostio_filehandle_t*); + +#define TYPEHANDLE_OVERLAY 255 + +typehandle_t th_overlay = { + .id = TYPEHANDLE_OVERLAY, + .post_open = overlay_post_open, + .seek = overlay_seek, + .read = overlay_read, + .write = overlay_write, + .seek = overlay_seek, + .close = overlay_close, +}; + +typedef enum { + OVERLAY_READ_CACHE, + OVERLAY_COW, +} cache_t; + +struct overlay { + size_t backing_size; + void** blocks; + cache_t type; +}; + +int main(int argc, char* argv[]) +{ + lostio_init(); + lostio_type_directory_use(); + + lostio_register_typehandle(&th_overlay); + + vfstree_create_node("/cached", TYPEHANDLE_OVERLAY, 0, + (void*) OVERLAY_READ_CACHE, LOSTIO_FLAG_NOAUTOEOF); + vfstree_create_node("/cow", TYPEHANDLE_OVERLAY, 0, + (void*) OVERLAY_COW, LOSTIO_FLAG_NOAUTOEOF); + + init_service_register("ramoverlay"); + + while(1) { + wait_for_rpc(); + } +} + +void overlay_post_open(lostio_filehandle_t* fh) +{ + size_t backing_size; + struct overlay* overlay; + size_t num_blocks; + void** blocks; + + // Groesse der unterliegenden Datei + fseek(fh->source, 0, SEEK_END); + backing_size = ftell(fh->source); + fseek(fh->source, 0, SEEK_SET); + + // Blocktabelle anlegen + num_blocks = (backing_size + BLOCK_SIZE - 1) / BLOCK_SIZE; + blocks = calloc(sizeof(void*), num_blocks); + + // Overlay-Strukur anlegen + overlay = calloc(1, sizeof(*overlay)); + overlay->backing_size = backing_size; + overlay->blocks = blocks; + overlay->type = (cache_t) fh->node->data; + + fh->data = overlay; +} + +size_t overlay_read(lostio_filehandle_t* fh, void* buf, size_t bs, size_t nb) +{ + struct overlay* overlay = fh->data; + size_t blocknum; + void* block; + size_t size, max_size; + + // Blockpointer raussuchen + blocknum = fh->pos / BLOCK_SIZE; + block = overlay->blocks[blocknum]; + + // Die Requestgroesse darf keine Blockgrenzen ueberschreiten + size = bs * nb; + max_size = BLOCK_SIZE - (fh->pos % BLOCK_SIZE); + + if (size > max_size) { + size = max_size; + } + + if (fh->pos + size > overlay->backing_size) { + size = overlay->backing_size - fh->pos; + } + + // Wenn der Lesecache aktiviert ist, ganzen Block laden + if ((block == NULL) && (overlay->type == OVERLAY_READ_CACHE)) { + int ret; + block = overlay->blocks[blocknum] = malloc(BLOCK_SIZE); + fseek(fh->source, blocknum * BLOCK_SIZE, SEEK_SET); + ret = fread(block, 1, BLOCK_SIZE, fh->source); + if (ret != BLOCK_SIZE) { + return -1; + } + } + + // Daten lesen + if (block == NULL) { + fseek(fh->source, fh->pos, SEEK_SET); + size = fread(buf, 1, size, fh->source); + } else { + memcpy(buf, ((uint8_t*) block) + (fh->pos % BLOCK_SIZE), size); + + } + + if (size > 0) { + fh->pos += size; + } + + // EOF setzen, falls noetig + if (fh->pos >= overlay->backing_size) { + fh->flags |= LOSTIO_FLAG_EOF; + } + + return size; +} + +size_t overlay_write(lostio_filehandle_t* fh,size_t bs,size_t nb, void* buf) +{ + struct overlay* overlay = fh->data; + size_t blocknum; + void* block; + size_t size, max_size; + size_t ret; + + // Blockpointer raussuchen + blocknum = fh->pos / BLOCK_SIZE; + block = overlay->blocks[blocknum]; + + // Die Requestgroesse darf keine Blockgrenzen ueberschreiten + size = bs * nb; + max_size = BLOCK_SIZE - (fh->pos % BLOCK_SIZE); + + if (size > max_size) { + size = max_size; + } + + if (fh->pos + size > overlay->backing_size) { + size = overlay->backing_size - fh->pos; + } + + // Copy on Write + if (block == NULL) { + size_t offset; + + block = overlay->blocks[blocknum] = malloc(BLOCK_SIZE); + + offset = fh->pos % BLOCK_SIZE; + if (offset) { + fseek(fh->source, fh->pos, SEEK_SET); + ret = fread(block, 1, offset, fh->source); + if (ret != offset) { + return -1; + } + } + + offset = (fh->pos + size) % BLOCK_SIZE; + if (offset < BLOCK_SIZE) { + fseek(fh->source, fh->pos + offset, SEEK_SET); + ret = fread(((uint8_t*) block) + offset, 1, BLOCK_SIZE - offset, + fh->source); + if (ret != BLOCK_SIZE - offset) { + return -1; + } + } + } + + // Daten schreiben + memcpy(((uint8_t*) block) + (fh->pos % BLOCK_SIZE), buf, size); + + if (size > 0) { + fh->pos += size; + } + + return size; +} + +int overlay_seek(lostio_filehandle_t* fh, uint64_t offset, int origin) +{ + struct overlay* overlay = fh->data; + uint64_t new_pos = fh->pos; + uint64_t size = overlay->backing_size; + + switch (origin) { + case SEEK_SET: + new_pos = offset; + break; + + case SEEK_CUR: + new_pos += offset; + break; + + case SEEK_END: + new_pos = size; + break; + } + + // Position nur aktualisieren, wenn sie nicht ausserhalb des Datentraegers + // liegt. + if (new_pos > size) { + return -1; + } else if (new_pos == size) { + // Gegebenen Falles noch EOF setzen + fh->flags |= LOSTIO_FLAG_EOF; + } else { + // Sonst EOF loeschen + fh->flags &= ~LOSTIO_FLAG_EOF; + } + fh->pos = new_pos; + return 0; +} + +int overlay_close(lostio_filehandle_t* fh) +{ + struct overlay* overlay = fh->data; + size_t i; + + for (i = (overlay->backing_size - 1) / BLOCK_SIZE; i > 0; i--) + { + free(overlay->blocks[i]); + } + + free(overlay->blocks); + free(overlay); + + return 0; +} -- 1.6.0.2 From kevin at tyndur.org Sat Dec 5 11:42:59 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 11:42:59 +0100 Subject: [tyndur-devel] [PATCH v2] shell: Fixes fuer bincat Message-ID: <1260009779-11944-1-git-send-email-kevin@tyndur.org> ! shell: bincat soll die angegebene Laenge auch dann respektieren, wenn sie nicht auf 1024 Bytes ausgerichtet ist ! shell: Offsets in bincat waren um 8 Bytes verrutscht ! shell: An jedem Blockanfang wird rechts das Offset angezeigt. Das war bisher ebenfalls verrutscht und das erste ist auf einer eigenen Zeile gelandet. Signed-off-by: Kevin Wolf --- src/modules/c/shell/cmds/bincat.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/c/shell/cmds/bincat.c b/src/modules/c/shell/cmds/bincat.c index 825e81e..3efddb0 100644 --- a/src/modules/c/shell/cmds/bincat.c +++ b/src/modules/c/shell/cmds/bincat.c @@ -129,7 +129,7 @@ void bincat_display_usage(void); FILE* file = fopen(path, "r"); lio_seek(file, start, SEEK_SET); - m = start / 8; + m = start - 8; if (file == NULL) { printf("Konnte '%s' nicht zum lesen oeffnen!\n", path); @@ -143,15 +143,20 @@ void bincat_display_usage(void); total_read += size; - printf("0x%08x: ", m); + if (length && (total_read > length)) { + size -= total_read - length; + } for (n=0; n < size; n++) { if ((n % 8) == 0) { + if (n == 8) { + printf("0x%08x", m); + } m += 8; printf("\n"); printf("0x%08x: ", m); } - + printf("0x%02x ", ((dword) buffer[n]) & 0xFF); } } -- 1.6.0.2 From kevin at tyndur.org Sat Dec 5 14:36:30 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 14:36:30 +0100 Subject: [tyndur-devel] [PATCH 0/3] Mehr Internationalisierung Message-ID: <1260020193-16130-1-git-send-email-kevin@tyndur.org> Mit dieser Patchserie begruesst getterm den Benutzer mit einer englischen Meldung, wenn auf der Modulkommandozeile fuer init env.LANG=en angegeben wird. Die Umgebungsvariable wird auch nicht mehr von der start.lsh ueberschrieben. Kevin Wolf (3): shell: set -d start.lsh: LANG ueberschreibbar machen getterm lernt notduerftig englisch build/root-common/config/shell/start.lsh | 4 +- src/modules/c/getterm/lang.h | 62 ++++++++++++++++++++++++++++++ src/modules/c/getterm/main.c | 29 +++++++++++-- src/modules/c/shell/commmands.c | 21 +++++++++- src/modules/lib/envvars.c | 2 +- 5 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 src/modules/c/getterm/lang.h From kevin at tyndur.org Sat Dec 5 14:36:31 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 14:36:31 +0100 Subject: [tyndur-devel] [PATCH 1/3] shell: set -d In-Reply-To: <1260020193-16130-1-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> Message-ID: <1260020193-16130-2-git-send-email-kevin@tyndur.org> ! libc: setenv() beruecksichtigt den overwrite-Parameter jetzt + shell: set -d setzt einen Defaultwert fuer eine Umgebungsvariable. Wenn die Variable bereits gesetzt ist, bleibt sie unveraendert. Signed-off-by: Kevin Wolf --- src/modules/c/shell/commmands.c | 21 +++++++++++++++++++-- src/modules/lib/envvars.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/modules/c/shell/commmands.c b/src/modules/c/shell/commmands.c index 897c937..6c33478 100644 --- a/src/modules/c/shell/commmands.c +++ b/src/modules/c/shell/commmands.c @@ -287,6 +287,21 @@ void set_list_vars(void); int shell_command_set(int argc, char* argv[], const char* args) { + int overwrite = 1; + + while (argc > 1) { + if (!strcmp(argv[1], "-d")) { + overwrite = 0; + } else if (!strcmp(argv[1], "-h")) { + set_display_usage(); + return EXIT_SUCCESS; + } else { + break; + } + argc--; + argv++; + } + switch (argc) { case 1: set_list_vars(); @@ -297,7 +312,7 @@ int shell_command_set(int argc, char* argv[], const char* args) break; case 3: - setenv(argv[1], argv[2], 1); + setenv(argv[1], argv[2], overwrite); break; default: @@ -320,6 +335,8 @@ void set_list_vars() void set_display_usage() { - puts("\nAufruf: set [ []]\n"); + puts("\nAufruf: set [-d] [ []]"); + puts(" -d: Defaultwert setzen. Wenn die Variable schon gesetzt ist, wird " + "ihr Wert\n nicht geändert.\n"); } diff --git a/src/modules/lib/envvars.c b/src/modules/lib/envvars.c index 12ba4f6..323cd86 100644 --- a/src/modules/lib/envvars.c +++ b/src/modules/lib/envvars.c @@ -261,7 +261,7 @@ int setenv(const char* name, const char* value, int overwrite) //In die Liste einfuegen envvar_list = list_push(envvar_list, envvar); - } else { + } else if (overwrite) { char* new_value = malloc(strlen(value) + 1); memcpy(new_value, value, strlen(value) + 1); -- 1.6.0.2 From kevin at tyndur.org Sat Dec 5 14:36:32 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 14:36:32 +0100 Subject: [tyndur-devel] [PATCH 2/3] start.lsh: LANG ueberschreibbar machen In-Reply-To: <1260020193-16130-1-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> Message-ID: <1260020193-16130-3-git-send-email-kevin@tyndur.org> * start.lsh: Fuer LANG und LC_ALL werden nur noch Defaultwerte gesetzt, so dass sie z.B. per "init env.LANG=en" ueberschreiben werden koennen Signed-off-by: Kevin Wolf --- build/root-common/config/shell/start.lsh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/root-common/config/shell/start.lsh b/build/root-common/config/shell/start.lsh index 33e4f01..75ba24f 100644 --- a/build/root-common/config/shell/start.lsh +++ b/build/root-common/config/shell/start.lsh @@ -3,7 +3,7 @@ set PATH file:/apps;file:/system/lpt-bin set TERM tyndur -set LC_ALL de_DE.UTF-8 -set LANG de_DE.UTF-8 +set -d LC_ALL de_DE.UTF-8 +set -d LANG de_DE.UTF-8 cd file:/ -- 1.6.0.2 From kevin at tyndur.org Sat Dec 5 14:36:33 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 5 Dec 2009 14:36:33 +0100 Subject: [tyndur-devel] [PATCH 3/3] getterm lernt notduerftig englisch In-Reply-To: <1260020193-16130-1-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> Message-ID: <1260020193-16130-4-git-send-email-kevin@tyndur.org> + getterm: Meldungen auf englisch, wenn LANG=en gesetzt ist ! getterm: Rechtschreibfehler und Umlaute in Meldungen Signed-off-by: Kevin Wolf --- src/modules/c/getterm/lang.h | 62 ++++++++++++++++++++++++++++++++++++++++++ src/modules/c/getterm/main.c | 29 ++++++++++++++++--- 2 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/modules/c/getterm/lang.h diff --git a/src/modules/c/getterm/lang.h b/src/modules/c/getterm/lang.h new file mode 100644 index 0000000..299a8d5 --- /dev/null +++ b/src/modules/c/getterm/lang.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009 The tyndur Project. All rights reserved. + * + * This code is derived from software contributed to the tyndur Project + * by Kevin Wolf. + * + * 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. + */ + +#ifndef LANG_H +#define LANG_H + +struct messages { + const char* rsUsage; + const char* rsPressEnter; + const char* rsConsSetError; + const char* rsExecError; +}; + +static struct messages msg = { + .rsUsage = "Aufruf: getterm [--once] [--auto] " + " ", + .rsPressEnter = "\n\nEingabetaste drücken, um %s zu starten...\n", + .rsConsSetError = "Fehler beim Setzen des Pfades für die I/O-Handles.", + .rsExecError = "Fehler beim Ausführen von '%s'\n", +}; + +static struct messages msg_en = { + .rsUsage = "Usage: getterm [--once] [--auto] " + " ", + .rsPressEnter = "\n\nPress the enter key to start %s...\n", + .rsConsSetError = "Failed to set the path for I/O handles.", + .rsExecError = "Failed to execute '%s'\n", +}; + +#endif diff --git a/src/modules/c/getterm/main.c b/src/modules/c/getterm/main.c index aa210e6..e536177 100644 --- a/src/modules/c/getterm/main.c +++ b/src/modules/c/getterm/main.c @@ -42,6 +42,8 @@ #include #include +#include "lang.h" + // Aufruf an Console zum aendern der Terminal-Optionen typedef enum {STDIN, STDOUT, STDERR} console_handle_t; @@ -52,6 +54,22 @@ typedef struct { } __attribute__((packed)) console_ctrl_t; /** + * Sprache anhand der Umgebungsvariablen LANG setzen + */ +static void set_language(void) +{ + const char* lang = getenv("LANG"); + + if (!lang) { + return; + } + + if (!strcmp(lang, "en")) { + msg = msg_en; + } +} + +/** * Pfad fuer Terminal aendern */ static void console_set_handle(console_handle_t handle, const char* path) @@ -73,7 +91,7 @@ static void console_set_handle(console_handle_t handle, const char* path) dword result = rpc_get_dword(console_pid, "CONS_SET", size, (char*) buffer); if (result == 0) { - printf("Fehler beim setzen des Pfades fuer die I/O-Handles."); + puts(msg.rsConsSetError); exit(-1); } } @@ -87,6 +105,8 @@ int main(int argc, char* argv[]) int respawn = 1; int wait_for_key = 1; + set_language(); + // Mit --once wird das Programm nicht neugestartet // Mit --auto wird nicht auf einen Tastendruck gewartet while (argc > 2) { @@ -103,8 +123,7 @@ int main(int argc, char* argv[]) // Wenn die Anzahl der Argumente nicht stimmt wird abgebrochen if (argc != 5) { - puts("Aufruf: getterm [--once] [--auto] " - " "); + puts(msg.rsUsage); return -1; } program = argv[4]; @@ -120,7 +139,7 @@ int main(int argc, char* argv[]) do { if (wait_for_key) { char input = 0; - printf("\n\nEingabetaste druecken um %s zu starten...\n", program); + printf(msg.rsPressEnter, program); // Auf Druecken der Eingabetaste warten while((fread(&input, 1, 1, stdin) != 1) || (input != '\n')) { yield(); @@ -131,7 +150,7 @@ int main(int argc, char* argv[]) // Fehler ist aufgetreten if (pid == 0) { - printf("Fehler beim ausfuehren von '%s'\n", program); + printf(msg.rsExecError, program); return -1; } -- 1.6.0.2 From toni at tyndur.org Sat Dec 5 19:51:37 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 5 Dec 2009 19:51:37 +0100 Subject: [tyndur-devel] [PATCH 3/4] setup: Konfigurationsprogramm In-Reply-To: <1258205309-11452-4-git-send-email-kevin@tyndur.org> References: <1258205309-11452-1-git-send-email-kevin@tyndur.org> <1258205309-11452-4-git-send-email-kevin@tyndur.org> Message-ID: <20091205185137.GA14993@neo.geekcave.lan> On Sat, Nov 14 14:28, Kevin Wolf wrote: > + setup: Ein tolles Konfigurationsprogramm, das im Moment so gut wie > gar nichts kann > > Signed-off-by: Kevin Wolf > --- > src/modules/pas/setup/Makefile.all | 4 + > src/modules/pas/setup/menu.pas | 96 ++++++++++++++++++++ > src/modules/pas/setup/setup.pas | 52 +++++++++++ > src/modules/pas/setup/setup_keyboard.pas | 146 ++++++++++++++++++++++++++++++ > src/modules/pas/setup/setup_lpt.pas | 136 ++++++++++++++++++++++++++++ > 5 files changed, 434 insertions(+), 0 deletions(-) > create mode 100644 src/modules/pas/setup/Makefile.all > create mode 100644 src/modules/pas/setup/menu.pas > create mode 100644 src/modules/pas/setup/setup.pas > create mode 100644 src/modules/pas/setup/setup_keyboard.pas > create mode 100644 src/modules/pas/setup/setup_lpt.pas > > diff --git a/src/modules/pas/setup/Makefile.all b/src/modules/pas/setup/Makefile.all > new file mode 100644 > index 0000000..febfb1e > --- /dev/null > +++ b/src/modules/pas/setup/Makefile.all > @@ -0,0 +1,4 @@ > +shopt -s extglob > +echo "LD $1/setup" > +"$COMPILER_PREFIX"ld -m elf_i386 -osetup -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` > +strip -s setup -o $1/apps/setup > diff --git a/src/modules/pas/setup/menu.pas b/src/modules/pas/setup/menu.pas > new file mode 100644 > index 0000000..89b537d > --- /dev/null > +++ b/src/modules/pas/setup/menu.pas > @@ -0,0 +1,96 @@ > +unit menu; > + > +interface > +uses tui; > + > +procedure MainMenu(screen: TUIObject; frame: TUIFrame); > +function StartModule(module: String; back: boolean): boolean; > + > +implementation > + > +uses tyndur, crt, setup_keyboard, setup_lpt; > + > +function StartModule(module: String; back: boolean): boolean; > +begin > + if module = 'keyboard' then begin > + SetupKeyboard(back); > + end else if module = 'lpt' then begin > + SetupLPT(back); > + end else begin > + exit(false); > + end; > + > + exit(true); > +end; > + > +procedure MainMenu(screen: TUIObject; frame: TUIFrame); > +var > + mainw: TUIRowContainer; > + > + a: TUIMenu; > + b: TUILabel; > + > + buttons: TUIColContainer; > + btnOk: TUIButton; > + btnCancel: TUIButton; > +begin > + mainw := TUIRowContainer.create(2); > + mainw.spacer := true; > + frame.obj := mainw; > + > + a := TUIMenu.create(4); > + with a do begin > + bgcolor := 0; > + color := 14; > + > + AddItem('Tastaturbelegung', nil); > + AddItem('lpt-Quellen', nil); > + AddItem('', nil); > + AddItem('Beenden', nil); > + end; > + mainw[1] := a; > + mainw.fixed[1] := 4; > + > + b := TUILabel.create; > + b.content := Utf8Decode('Bitte w??hle aus dem Men?? das gew??nschte Konfigurationsprogramm aus.'); > + mainw[0] := b; > + mainw.prop[0] := 30; > + > + a.selected := 0; > + repeat > + // Zeichnen > + screen.align(80, 24); > + screen.draw(1, 1); > + > + case readkey of > + #27: > + case ReadEscapeSequence of > + SK_UP: > + begin > + a.selected := (a.selected + 4 - 1) mod 4; > + if a.selected = 2 then begin > + a.selected := 1; > + end; > + end; > + SK_DOWN: > + begin > + a.selected := (a.selected + 1) mod 4; > + if a.selected = 2 then begin > + a.selected := 3; > + end; > + end; > + end; > + #10: > + case a.selected of > + 0: StartModule('keyboard', true); > + 1: StartModule('lpt', true); > + 3: break; > + end; > + end; > + until false; > + > + frame.obj := nil; > + mainw.free; > +end; > + > +end. > diff --git a/src/modules/pas/setup/setup.pas b/src/modules/pas/setup/setup.pas > new file mode 100644 > index 0000000..e50a90a > --- /dev/null > +++ b/src/modules/pas/setup/setup.pas > @@ -0,0 +1,52 @@ > +program setup; > +{$MODE ObjFPC} > +{$H+} > + > +uses > + crt, tui, > + menu; > + > +var > + screen: TUIRowContainer; > + title: TUILabel; > + f: TUIFrame; > + s: string; > + show_menu: boolean; > + i: integer; > +begin > + s := ''; > + WriteLn(HexStr(dword(@s), 8)); Was soll denn das genau? ;-) > + > + screen := TUIRowContainer.create(2); > + screen.bgcolor := 2; > + screen.color := 1; > + > + title := TUILabel.create; > + title.content := 'tyndur-Konfiguration'; > + title.bgcolor := 1; > + title.color := 15; > + screen[0] := title; > + screen.fixed[0] := 1; > + > + f := TUIFrame.create(nil, 60, 12); > + screen[1] := f; > + screen.prop[1] := 1; > + > + show_menu := true; > + for i := 1 to system.ParamCount do begin > + if not StartModule(system.ParamStr(i), false) then begin > + show_menu := false; > + break; > + end; > + end; > + > + if show_menu then begin > + MainMenu(screen, f); > + end; > + > + screen.free; > + > + TextBackground(0); > + TextColor(7); > + ClrScr; > +end. > diff --git a/src/modules/pas/setup/setup_keyboard.pas b/src/modules/pas/setup/setup_keyboard.pas > new file mode 100644 > index 0000000..879ca88 > --- /dev/null > +++ b/src/modules/pas/setup/setup_keyboard.pas > @@ -0,0 +1,146 @@ > +unit setup_keyboard; > + > +interface > + > +procedure SetupKeyboard(back: boolean); > + > +implementation > + > +uses sysutils, tyndur, crt, tui; > + > +procedure SetLayout(layout: String); > +var > + f: File of byte; > + buf: Array [1..2048] of byte; > + path: String; > + > + cfg: text; > +begin > + path := 'file:/system/keymaps/' + layout + '.kbd'; > + > + if not FileExists(path) then begin > + exit; > + end; > + > + Assign(f, path); > + Reset(f, 2048); > + BlockRead(f, buf, 1); > + Close(f); > + > + Assign(f, 'vterm:/keymap'); > + Rewrite(f, 2048); > + BlockWrite(f, buf, 1); > + Close(f); > +end; > + > +procedure SetupKeyboard(back: boolean); > +var > + mainw: TUIRowContainer; > + > + a: TUIMenu; > + b: TUILabel; > + > + buttons: TUIColContainer; > + btnOk: TUIButton; > + btnCancel: TUIButton; > + screen: TUIRowContainer; > + title: TUILabel; > + f: TUIFrame; > + s: string; > + num_items: integer; > +begin > + s := ''; > + WriteLn(HexStr(dword(@s), 8)); Nochmal... ;-) > + > + screen := TUIRowContainer.create(2); > + screen.bgcolor := 2; > + screen.color := 1; > + > + title := TUILabel.create; > + title.content := 'tyndur-Konfiguration: Tastaturbelegung'; > + title.bgcolor := 1; > + title.color := 15; > + screen[0] := title; > + screen.fixed[0] := 1; > + > + f := TUIFrame.create(nil, 60, 12); > + screen[1] := f; > + screen.prop[1] := 1; > + > + mainw := TUIRowContainer.create(2); > + mainw.spacer := true; > + f.obj := mainw; > + > + if back then begin > + num_items := 4; > + end else begin > + num_items := 2; > + end; > + > + a := TUIMenu.create(num_items); > + with a do begin > + bgcolor := 0; > + color := 14; > + > + AddItem('Deutsch', nil); > + AddItem('US-Amerikanisch', nil); > + if back then begin > + AddItem('', nil); > + AddItem(Utf8Decode('Zur??ck'), nil); > + end; > + end; > + mainw[1] := a; > + mainw.fixed[1] := num_items; > + > + b := TUILabel.create; > + b.content := Utf8Decode('Bitte w??hle aus dem Men?? die richtige Tastaturbelegung aus.'); Vielleicht eher "gewünschte Tastaturbelegung"? (Man merkt nicht dass ich nichts zu kommentieren habe, oder? ;-)) > + mainw[0] := b; > + mainw.prop[0] := 30; > + > + a.selected := 0; > + repeat > + // Zeichnen > + screen.align(80, 24); > + screen.draw(1, 1); > + > + case readkey of > + #27: > + case ReadEscapeSequence of > + SK_UP: > + begin > + a.selected := (a.selected + num_items - 1) mod num_items; > + if a.selected = 2 then begin > + a.selected := 1; > + end; > + end; > + SK_DOWN: > + begin > + a.selected := (a.selected + 1) mod num_items; > + if a.selected = 2 then begin > + a.selected := 3; > + end; > + end; > + end; > + #10: > + case a.selected of > + 0: > + begin > + SetLayout('de'); > + break; > + end; > + 1: > + begin > + SetLayout('us'); > + break; > + end; > + 3: break; > + end; > + end; > + until false; > + > + f.obj := nil; > + mainw.free; > + screen.free; > +end; > + > +end. > diff --git a/src/modules/pas/setup/setup_lpt.pas b/src/modules/pas/setup/setup_lpt.pas > new file mode 100644 > index 0000000..e4207ab > --- /dev/null > +++ b/src/modules/pas/setup/setup_lpt.pas > @@ -0,0 +1,136 @@ > +unit setup_lpt; > + > +interface > + > +procedure SetupLPT(back: boolean); > + > +implementation > + > +uses sysutils, dos, tyndur, crt, tui; > + > +procedure SetRepo(repo: String); > +var > + cfg: text; > +begin > + Assign(cfg, 'file:/config/lpt/pkgsrc'); > + Rewrite(cfg); > + WriteLn(cfg, 'lpt ', repo); > + Close(cfg); > + > + TextBackground(0); > + TextColor(7); > + ClrScr; > + Exec('lpt', 'scan'); > + > + WriteLn; > + WriteLn('Bitte eine beliebige Taste dr??cken'); > + readkey; > +end; > + > +procedure SetupLPT(back: boolean); > +var > + mainw: TUIRowContainer; > + > + a: TUIMenu; > + b: TUILabel; > + > + buttons: TUIColContainer; > + btnOk: TUIButton; > + btnCancel: TUIButton; > + screen: TUIRowContainer; > + title: TUILabel; > + f: TUIFrame; > + num_items: integer; > +begin > + screen := TUIRowContainer.create(2); > + screen.bgcolor := 2; > + screen.color := 1; > + > + title := TUILabel.create; > + title.content := Utf8Decode('tyndur-Konfiguration: Quelle f??r lpt'); > + title.bgcolor := 1; > + title.color := 15; > + screen[0] := title; > + screen.fixed[0] := 1; > + > + f := TUIFrame.create(nil, 60, 12); > + screen[1] := f; > + screen.prop[1] := 1; > + > + mainw := TUIRowContainer.create(2); > + mainw.spacer := true; > + f.obj := mainw; > + > + if back then begin > + num_items := 4; > + end else begin > + num_items := 2; > + end; > + > + a := TUIMenu.create(num_items); > + with a do begin > + bgcolor := 0; > + color := 14; > + > + AddItem('Stabile Version (gothmog)', nil); > + AddItem('Entwicklerversion (current)', nil); > + if back then begin > + AddItem('', nil); > + AddItem(Utf8Decode('Zur??ck'), nil); > + end; > + end; > + mainw[1] := a; > + mainw.fixed[1] := num_items; > + > + b := TUILabel.create; > + b.content := Utf8Decode('Bitte w??hle aus dem Men?? die Quelle f??r lpt aus.'); > + mainw[0] := b; > + mainw.prop[0] := 30; > + > + a.selected := 0; > + repeat > + // Zeichnen > + screen.align(80, 24); > + screen.draw(1, 1); > + > + case readkey of > + #27: > + case ReadEscapeSequence of > + SK_UP: > + begin > + a.selected := (a.selected + num_items - 1) mod num_items; > + if a.selected = 2 then begin > + a.selected := 1; > + end; > + end; > + SK_DOWN: > + begin > + a.selected := (a.selected + 1) mod num_items; > + if a.selected = 2 then begin > + a.selected := 3; > + end; > + end; > + end; > + #10: > + case a.selected of > + 0: > + begin > + SetRepo('http://lpt.tyndur.org/gothmog/'); > + break; > + end; > + 1: > + begin > + SetRepo('http://lpt.tyndur.org/current/'); > + break; > + end; > + 3: break; > + end; > + end; > + until false; > + > + f.obj := nil; > + mainw.free; > + screen.free; > +end; > + > +end. Hm viel habe ich ja jetzt nicht gefunden. Das ganze sieht halt noch nach etwas viel Code-Duplikation aus, da könnte man wohl noch einiges vom UI-Code herausnehmen, aber jo, pack das von mir aus mal so rein, wenn es denn tut. ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sat Dec 5 19:57:20 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 5 Dec 2009 19:57:20 +0100 Subject: [tyndur-devel] [PATCH 4/4] Tastaturbelegung beim ersten Start abfragen In-Reply-To: <1258205309-11452-5-git-send-email-kevin@tyndur.org> References: <1258205309-11452-1-git-send-email-kevin@tyndur.org> <1258205309-11452-5-git-send-email-kevin@tyndur.org> Message-ID: <20091205185719.GB14993@neo.geekcave.lan> On Sat, Nov 14 14:28, Kevin Wolf wrote: > + setup: Beim Auswaehler der Tastaturbelegung die Wahl in Ist das da etwa KRITIKEL und sollte "Auswaehlen" heissen? ;-) > config/keyboard.lsh abspeichern (als Skript, das die Belegung > aktiviert) > + root-common: keyboard.lsh vor getterm1 starten > + keyboard.lsh: Konfiguration der Tastaturbelegung aufrufen, wodurch > sich das Skript selbst ueberschreibt und beim naechsten Mal die > richtige Tastaturbelegung laedt. > > Signed-off-by: Kevin Wolf > --- > build/root-common/config/servmgr/config/cmd | 1 + > build/root-common/config/servmgr/config/conf | 1 + > build/root-common/config/servmgr/config/deps | 2 ++ > build/root-common/config/servmgr/config/workdir | 1 + > build/root-common/config/servmgr/getterm1/deps | 1 + > build/root-floppy/config/keyboard.lsh | 3 +++ > build/root-hd/config/keyboard.lsh | 3 +++ > src/modules/pas/setup/setup_keyboard.pas | 7 +++++++ > 8 files changed, 19 insertions(+), 0 deletions(-) > create mode 100644 build/root-common/config/servmgr/config/cmd > create mode 100644 build/root-common/config/servmgr/config/conf > create mode 100644 build/root-common/config/servmgr/config/deps > create mode 100644 build/root-common/config/servmgr/config/workdir > create mode 100644 build/root-floppy/config/keyboard.lsh > create mode 100644 build/root-hd/config/keyboard.lsh > > diff --git a/build/root-common/config/servmgr/config/cmd b/build/root-common/config/servmgr/config/cmd > new file mode 100644 > index 0000000..410e9da > --- /dev/null > +++ b/build/root-common/config/servmgr/config/cmd > @@ -0,0 +1 @@ > +/apps/getterm --once --auto vterm:/vterm0/in vterm:/vterm0/out vterm:/vterm0/out /config/keyboard.lsh > diff --git a/build/root-common/config/servmgr/config/conf b/build/root-common/config/servmgr/config/conf > new file mode 100644 > index 0000000..319afcd > --- /dev/null > +++ b/build/root-common/config/servmgr/config/conf > @@ -0,0 +1 @@ > +waitterminate > diff --git a/build/root-common/config/servmgr/config/deps b/build/root-common/config/servmgr/config/deps > new file mode 100644 > index 0000000..5d3c62c > --- /dev/null > +++ b/build/root-common/config/servmgr/config/deps > @@ -0,0 +1,2 @@ > +vterm > +mount > diff --git a/build/root-common/config/servmgr/config/workdir b/build/root-common/config/servmgr/config/workdir > new file mode 100644 > index 0000000..db5802b > --- /dev/null > +++ b/build/root-common/config/servmgr/config/workdir > @@ -0,0 +1 @@ > +file:/ > diff --git a/build/root-common/config/servmgr/getterm1/deps b/build/root-common/config/servmgr/getterm1/deps > index 884bf14..4b6e1dd 100644 > --- a/build/root-common/config/servmgr/getterm1/deps > +++ b/build/root-common/config/servmgr/getterm1/deps > @@ -1,3 +1,4 @@ > vterm > cmos > mount > +config > diff --git a/build/root-floppy/config/keyboard.lsh b/build/root-floppy/config/keyboard.lsh > new file mode 100644 > index 0000000..22eaf78 > --- /dev/null > +++ b/build/root-floppy/config/keyboard.lsh > @@ -0,0 +1,3 @@ > +#!file:/apps/sh > + > +setup keyboard quit > diff --git a/build/root-hd/config/keyboard.lsh b/build/root-hd/config/keyboard.lsh > new file mode 100644 > index 0000000..22eaf78 > --- /dev/null > +++ b/build/root-hd/config/keyboard.lsh > @@ -0,0 +1,3 @@ > +#!file:/apps/sh > + > +setup keyboard quit > diff --git a/src/modules/pas/setup/setup_keyboard.pas b/src/modules/pas/setup/setup_keyboard.pas > index 879ca88..1dedf06 100644 > --- a/src/modules/pas/setup/setup_keyboard.pas > +++ b/src/modules/pas/setup/setup_keyboard.pas > @@ -31,6 +31,13 @@ begin > Rewrite(f, 2048); > BlockWrite(f, buf, 1); > Close(f); > + > + Assign(cfg, 'file:/config/keyboard.lsh'); > + Rewrite(cfg); > + WriteLn(cfg, '#!file:/apps/sh'); > + WriteLn(cfg); > + WriteLn(cfg, 'cp ', path, ' vterm:/keymap'); > + Close(cfg); > end; > > procedure SetupKeyboard(back: boolean); Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sat Dec 5 20:05:28 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 5 Dec 2009 20:05:28 +0100 Subject: [tyndur-devel] [PATCH 1/3] shell: set -d In-Reply-To: <1260020193-16130-2-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> <1260020193-16130-2-git-send-email-kevin@tyndur.org> Message-ID: <20091205190528.GC14993@neo.geekcave.lan> On Sat, Dec 05 14:36, Kevin Wolf wrote: > ! libc: setenv() beruecksichtigt den overwrite-Parameter jetzt > + shell: set -d setzt einen Defaultwert fuer eine Umgebungsvariable. > Wenn die Variable bereits gesetzt ist, bleibt sie unveraendert. > > Signed-off-by: Kevin Wolf > --- > src/modules/c/shell/commmands.c | 21 +++++++++++++++++++-- > src/modules/lib/envvars.c | 2 +- > 2 files changed, 20 insertions(+), 3 deletions(-) > > diff --git a/src/modules/c/shell/commmands.c b/src/modules/c/shell/commmands.c > index 897c937..6c33478 100644 > --- a/src/modules/c/shell/commmands.c > +++ b/src/modules/c/shell/commmands.c > @@ -287,6 +287,21 @@ void set_list_vars(void); > > int shell_command_set(int argc, char* argv[], const char* args) > { > + int overwrite = 1; > + > + while (argc > 1) { > + if (!strcmp(argv[1], "-d")) { > + overwrite = 0; > + } else if (!strcmp(argv[1], "-h")) { > + set_display_usage(); > + return EXIT_SUCCESS; > + } else { > + break; > + } > + argc--; > + argv++; > + } > + > switch (argc) { > case 1: > set_list_vars(); > @@ -297,7 +312,7 @@ int shell_command_set(int argc, char* argv[], const char* args) > break; > > case 3: > - setenv(argv[1], argv[2], 1); > + setenv(argv[1], argv[2], overwrite); > break; > > default: > @@ -320,6 +335,8 @@ void set_list_vars() > > void set_display_usage() > { > - puts("\nAufruf: set [ []]\n"); > + puts("\nAufruf: set [-d] [ []]"); > + puts(" -d: Defaultwert setzen. Wenn die Variable schon gesetzt ist, wird " > + "ihr Wert\n nicht ge??ndert.\n"); > } > > diff --git a/src/modules/lib/envvars.c b/src/modules/lib/envvars.c > index 12ba4f6..323cd86 100644 > --- a/src/modules/lib/envvars.c > +++ b/src/modules/lib/envvars.c > @@ -261,7 +261,7 @@ int setenv(const char* name, const char* value, int overwrite) > > //In die Liste einfuegen > envvar_list = list_push(envvar_list, envvar); > - } else { > + } else if (overwrite) { > char* new_value = malloc(strlen(value) + 1); > memcpy(new_value, value, strlen(value) + 1); > > -- > 1.6.0.2 > Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sat Dec 5 20:06:30 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 5 Dec 2009 20:06:30 +0100 Subject: [tyndur-devel] [PATCH 2/3] start.lsh: LANG ueberschreibbar machen In-Reply-To: <1260020193-16130-3-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> <1260020193-16130-3-git-send-email-kevin@tyndur.org> Message-ID: <20091205190630.GD14993@neo.geekcave.lan> On Sat, Dec 05 14:36, Kevin Wolf wrote: > * start.lsh: Fuer LANG und LC_ALL werden nur noch Defaultwerte gesetzt, > so dass sie z.B. per "init env.LANG=en" ueberschreiben werden koennen > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sat Dec 5 20:13:33 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 5 Dec 2009 20:13:33 +0100 Subject: [tyndur-devel] [PATCH 3/3] getterm lernt notduerftig englisch In-Reply-To: <1260020193-16130-4-git-send-email-kevin@tyndur.org> References: <1260020193-16130-1-git-send-email-kevin@tyndur.org> <1260020193-16130-4-git-send-email-kevin@tyndur.org> Message-ID: <20091205191333.GE14993@neo.geekcave.lan> On Sat, Dec 05 14:36, Kevin Wolf wrote: > + getterm: Meldungen auf englisch, wenn LANG=en gesetzt ist > ! getterm: Rechtschreibfehler und Umlaute in Meldungen > > Signed-off-by: Kevin Wolf > --- > src/modules/c/getterm/lang.h | 62 ++++++++++++++++++++++++++++++++++++++++++ > src/modules/c/getterm/main.c | 29 ++++++++++++++++--- > 2 files changed, 86 insertions(+), 5 deletions(-) > create mode 100644 src/modules/c/getterm/lang.h > > diff --git a/src/modules/c/getterm/lang.h b/src/modules/c/getterm/lang.h > new file mode 100644 > index 0000000..299a8d5 > --- /dev/null > +++ b/src/modules/c/getterm/lang.h > @@ -0,0 +1,62 @@ > +/* > + * Copyright (c) 2009 The tyndur Project. All rights reserved. > + * > + * This code is derived from software contributed to the tyndur Project > + * by Kevin Wolf. > + * > + * 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. > + */ > + > +#ifndef LANG_H > +#define LANG_H > + > +struct messages { > + const char* rsUsage; > + const char* rsPressEnter; > + const char* rsConsSetError; > + const char* rsExecError; > +}; > + > +static struct messages msg = { > + .rsUsage = "Aufruf: getterm [--once] [--auto] " > + " ", > + .rsPressEnter = "\n\nEingabetaste dr??cken, um %s zu starten...\n", > + .rsConsSetError = "Fehler beim Setzen des Pfades f??r die I/O-Handles.", > + .rsExecError = "Fehler beim Ausf??hren von '%s'\n", > +}; > + > +static struct messages msg_en = { > + .rsUsage = "Usage: getterm [--once] [--auto] " > + " ", > + .rsPressEnter = "\n\nPress the enter key to start %s...\n", > + .rsConsSetError = "Failed to set the path for I/O handles.", > + .rsExecError = "Failed to execute '%s'\n", > +}; > + > +#endif > diff --git a/src/modules/c/getterm/main.c b/src/modules/c/getterm/main.c > index aa210e6..e536177 100644 > --- a/src/modules/c/getterm/main.c > +++ b/src/modules/c/getterm/main.c > @@ -42,6 +42,8 @@ > #include > #include > > +#include "lang.h" > + > > // Aufruf an Console zum aendern der Terminal-Optionen > typedef enum {STDIN, STDOUT, STDERR} console_handle_t; > @@ -52,6 +54,22 @@ typedef struct { > } __attribute__((packed)) console_ctrl_t; > > /** > + * Sprache anhand der Umgebungsvariablen LANG setzen > + */ > +static void set_language(void) > +{ > + const char* lang = getenv("LANG"); > + > + if (!lang) { > + return; > + } > + > + if (!strcmp(lang, "en")) { > + msg = msg_en; > + } > +} > + > +/** > * Pfad fuer Terminal aendern > */ > static void console_set_handle(console_handle_t handle, const char* path) > @@ -73,7 +91,7 @@ static void console_set_handle(console_handle_t handle, const char* path) > dword result = rpc_get_dword(console_pid, "CONS_SET", > size, (char*) buffer); > if (result == 0) { > - printf("Fehler beim setzen des Pfades fuer die I/O-Handles."); > + puts(msg.rsConsSetError); > exit(-1); > } > } > @@ -87,6 +105,8 @@ int main(int argc, char* argv[]) > int respawn = 1; > int wait_for_key = 1; > > + set_language(); > + > // Mit --once wird das Programm nicht neugestartet > // Mit --auto wird nicht auf einen Tastendruck gewartet > while (argc > 2) { > @@ -103,8 +123,7 @@ int main(int argc, char* argv[]) > > // Wenn die Anzahl der Argumente nicht stimmt wird abgebrochen > if (argc != 5) { > - puts("Aufruf: getterm [--once] [--auto] " > - " "); > + puts(msg.rsUsage); > return -1; > } > program = argv[4]; > @@ -120,7 +139,7 @@ int main(int argc, char* argv[]) > do { > if (wait_for_key) { > char input = 0; > - printf("\n\nEingabetaste druecken um %s zu starten...\n", program); > + printf(msg.rsPressEnter, program); > // Auf Druecken der Eingabetaste warten > while((fread(&input, 1, 1, stdin) != 1) || (input != '\n')) { > yield(); > @@ -131,7 +150,7 @@ int main(int argc, char* argv[]) > > // Fehler ist aufgetreten > if (pid == 0) { > - printf("Fehler beim ausfuehren von '%s'\n", program); > + printf(msg.rsExecError, program); > return -1; > } > > -- > 1.6.0.2 Etwas unschön, aber saubere i18n wäre wohl etwas zu aufwändig für kurz vor Weihnachten... ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 6 15:48:09 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 6 Dec 2009 15:48:09 +0100 Subject: [tyndur-devel] [PATCH] ramoverlay hinzugefuegt In-Reply-To: <1260007378-12445-1-git-send-email-kevin@tyndur.org> References: <1260007378-12445-1-git-send-email-kevin@tyndur.org> Message-ID: <20091206144809.GA16200@thales.kaufmann.lan> On Sat, Dec 05 11:02, Kevin Wolf wrote: > + ramoverlay: Ein LostIO-Service, der ueber eine schreibgeschuetze > Ressource (z.B. eine CD-ROM) einen COW-Ramdisk legt, um temporaere > Schreibzugriffe zu erlauben > > Signed-off-by: Kevin Wolf > --- > src/modules/ramoverlay/Makefile.all | 6 + > src/modules/ramoverlay/main.c | 282 +++++++++++++++++++++++++++++++++++ > 2 files changed, 288 insertions(+), 0 deletions(-) > create mode 100644 src/modules/ramoverlay/Makefile.all > create mode 100644 src/modules/ramoverlay/main.c > > diff --git a/src/modules/ramoverlay/Makefile.all b/src/modules/ramoverlay/Makefile.all > new file mode 100644 > index 0000000..8eacb97 > --- /dev/null > +++ b/src/modules/ramoverlay/Makefile.all > @@ -0,0 +1,6 @@ > +shopt -s extglob > +source $LOST_BUILDMK_ROOT/config.sh > + > +echo "LD $1/modules/ramoverlay" > +$LOST_TOOLS_LD -Ttext=0x40000000 -oramoverlay.mod *.o --start-group $2 --end-group > +$LOST_TOOLS_STRIP -s ramoverlay.mod -o $1/modules/ramoverlay > diff --git a/src/modules/ramoverlay/main.c b/src/modules/ramoverlay/main.c > new file mode 100644 > index 0000000..654c383 > --- /dev/null > +++ b/src/modules/ramoverlay/main.c > @@ -0,0 +1,282 @@ > +/* > + * Copyright (c) 2009 The tyndur Project. All rights reserved. > + * > + * This code is derived from software contributed to the tyndur Project > + * by Kevin Wolf. > + * > + * 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 > +#include > +#include > +#include > +#include > +#include > + > +#define BLOCK_SIZE (256 * 1024) > + > +void overlay_post_open(lostio_filehandle_t* fh); > +size_t overlay_read(lostio_filehandle_t*,void*,size_t,size_t); > +size_t overlay_write(lostio_filehandle_t*,size_t,size_t,void*); > +int overlay_seek(lostio_filehandle_t* fh, uint64_t offset, int origin); > +int overlay_close(lostio_filehandle_t*); > + > +#define TYPEHANDLE_OVERLAY 255 > + > +typehandle_t th_overlay = { > + .id = TYPEHANDLE_OVERLAY, > + .post_open = overlay_post_open, > + .seek = overlay_seek, > + .read = overlay_read, > + .write = overlay_write, > + .seek = overlay_seek, > + .close = overlay_close, > +}; > + > +typedef enum { > + OVERLAY_READ_CACHE, > + OVERLAY_COW, > +} cache_t; > + > +struct overlay { > + size_t backing_size; > + void** blocks; > + cache_t type; > +}; > + > +int main(int argc, char* argv[]) > +{ > + lostio_init(); > + lostio_type_directory_use(); > + > + lostio_register_typehandle(&th_overlay); > + > + vfstree_create_node("/cached", TYPEHANDLE_OVERLAY, 0, > + (void*) OVERLAY_READ_CACHE, LOSTIO_FLAG_NOAUTOEOF); > + vfstree_create_node("/cow", TYPEHANDLE_OVERLAY, 0, > + (void*) OVERLAY_COW, LOSTIO_FLAG_NOAUTOEOF); > + > + init_service_register("ramoverlay"); > + > + while(1) { > + wait_for_rpc(); > + } > +} > + > +void overlay_post_open(lostio_filehandle_t* fh) > +{ > + size_t backing_size; > + struct overlay* overlay; > + size_t num_blocks; > + void** blocks; > + > + // Groesse der unterliegenden Datei > + fseek(fh->source, 0, SEEK_END); > + backing_size = ftell(fh->source); > + fseek(fh->source, 0, SEEK_SET); > + > + // Blocktabelle anlegen > + num_blocks = (backing_size + BLOCK_SIZE - 1) / BLOCK_SIZE; > + blocks = calloc(sizeof(void*), num_blocks); > + > + // Overlay-Strukur anlegen > + overlay = calloc(1, sizeof(*overlay)); > + overlay->backing_size = backing_size; > + overlay->blocks = blocks; > + overlay->type = (cache_t) fh->node->data; > + > + fh->data = overlay; > +} > + > +size_t overlay_read(lostio_filehandle_t* fh, void* buf, size_t bs, size_t nb) > +{ > + struct overlay* overlay = fh->data; > + size_t blocknum; > + void* block; > + size_t size, max_size; > + > + // Blockpointer raussuchen > + blocknum = fh->pos / BLOCK_SIZE; > + block = overlay->blocks[blocknum]; Hm ist das nicht unter Umständen ein overflow? Also ich denke jetzt an den Fall wenn fh->pos == overlay->backing_size... > + > + // Die Requestgroesse darf keine Blockgrenzen ueberschreiten Hat das einen tieferen Grund, oder war das nur faulheit und du wollest unten keine schleife machen? ;-) Ah ich sehe grad dass die Blokgroesse recht grosszügig gewählt wurde, da funktioniert wohl das Argument mit den gesparten RPCs nur bedingt... ;-) > + size = bs * nb; > + max_size = BLOCK_SIZE - (fh->pos % BLOCK_SIZE); > + > + if (size > max_size) { > + size = max_size; > + } > + > + if (fh->pos + size > overlay->backing_size) { > + size = overlay->backing_size - fh->pos; > + } > + > + // Wenn der Lesecache aktiviert ist, ganzen Block laden > + if ((block == NULL) && (overlay->type == OVERLAY_READ_CACHE)) { > + int ret; > + block = overlay->blocks[blocknum] = malloc(BLOCK_SIZE); > + fseek(fh->source, blocknum * BLOCK_SIZE, SEEK_SET); > + ret = fread(block, 1, BLOCK_SIZE, fh->source); > + if (ret != BLOCK_SIZE) { > + return -1; Hm ob das gut kommt mit der -1 als size_t? Ich bin mir nicht ganz sicher was dabei rauskommen müsste, aber ich tippe auf einen OOM, zumindest wenn kein SHM benutzt wird zum lesen, und er dann ((size_t) -1) Bytes zuruecksenden moechte. Da wäre wohl 0 die richtige Wahl (plus natürlich das imaginäre Flag für ferror() *hust*). > + } > + } > + > + // Daten lesen > + if (block == NULL) { > + fseek(fh->source, fh->pos, SEEK_SET); > + size = fread(buf, 1, size, fh->source); > + } else { > + memcpy(buf, ((uint8_t*) block) + (fh->pos % BLOCK_SIZE), size); > + Oha, wichtige Leerzeile ;-) > + } > + > + if (size > 0) { Hm, das if ist doch nur bedingt sinnvoll, size ist unsigned, also geht doch nur noch die alternative size == 0, und das dürfte ja fh->pos nicht speziell beeindrucken... > + fh->pos += size; > + } > + > + // EOF setzen, falls noetig > + if (fh->pos >= overlay->backing_size) { > + fh->flags |= LOSTIO_FLAG_EOF; > + } > + > + return size; > +} > + > +size_t overlay_write(lostio_filehandle_t* fh,size_t bs,size_t nb, void* buf) > +{ > + struct overlay* overlay = fh->data; > + size_t blocknum; > + void* block; > + size_t size, max_size; > + size_t ret; > + > + // Blockpointer raussuchen > + blocknum = fh->pos / BLOCK_SIZE; > + block = overlay->blocks[blocknum]; > + > + // Die Requestgroesse darf keine Blockgrenzen ueberschreiten > + size = bs * nb; > + max_size = BLOCK_SIZE - (fh->pos % BLOCK_SIZE); > + > + if (size > max_size) { > + size = max_size; > + } > + > + if (fh->pos + size > overlay->backing_size) { > + size = overlay->backing_size - fh->pos; > + } > + > + // Copy on Write > + if (block == NULL) { > + size_t offset; > + > + block = overlay->blocks[blocknum] = malloc(BLOCK_SIZE); > + > + offset = fh->pos % BLOCK_SIZE; > + if (offset) { > + fseek(fh->source, fh->pos, SEEK_SET); > + ret = fread(block, 1, offset, fh->source); > + if (ret != offset) { > + return -1; Auch hier wieder eine -1, die dürfte aber diesmal nur die Aufrufer verwirren, wenn der Rueckgabewert von fwrite groesser ist als erwartet. > + } > + } > + > + offset = (fh->pos + size) % BLOCK_SIZE; > + if (offset < BLOCK_SIZE) { > + fseek(fh->source, fh->pos + offset, SEEK_SET); > + ret = fread(((uint8_t*) block) + offset, 1, BLOCK_SIZE - offset, > + fh->source); > + if (ret != BLOCK_SIZE - offset) { > + return -1; Und nochmal. > + } > + } > + } > + > + // Daten schreiben > + memcpy(((uint8_t*) block) + (fh->pos % BLOCK_SIZE), buf, size); > + > + if (size > 0) { Hier wärs wohl nochmal das selbe wie in read oben. > + fh->pos += size; > + } > + > + return size; > +} > + > +int overlay_seek(lostio_filehandle_t* fh, uint64_t offset, int origin) > +{ > + struct overlay* overlay = fh->data; > + uint64_t new_pos = fh->pos; > + uint64_t size = overlay->backing_size; > + > + switch (origin) { > + case SEEK_SET: > + new_pos = offset; > + break; > + > + case SEEK_CUR: > + new_pos += offset; > + break; > + > + case SEEK_END: > + new_pos = size; > + break; > + } > + > + // Position nur aktualisieren, wenn sie nicht ausserhalb des Datentraegers > + // liegt. > + if (new_pos > size) { > + return -1; > + } else if (new_pos == size) { > + // Gegebenen Falles noch EOF setzen > + fh->flags |= LOSTIO_FLAG_EOF; > + } else { > + // Sonst EOF loeschen > + fh->flags &= ~LOSTIO_FLAG_EOF; > + } > + fh->pos = new_pos; > + return 0; > +} > + > +int overlay_close(lostio_filehandle_t* fh) > +{ > + struct overlay* overlay = fh->data; > + size_t i; > + > + for (i = (overlay->backing_size - 1) / BLOCK_SIZE; i > 0; i--) Hm erwischst du da den ersten block auch? Und gibts da einen Grund, warum das rückwärts sein muss? ;-) > + { > + free(overlay->blocks[i]); > + } > + > + free(overlay->blocks); > + free(overlay); > + > + return 0; > +} Sonst sieht das vernünftig aus, glaube ich... ;-) -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Sun Dec 6 23:15:31 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 6 Dec 2009 23:15:31 +0100 Subject: [tyndur-devel] [PATCH] build: Live-CD Message-ID: <1260137731-23999-1-git-send-email-kevin@tyndur.org> * build: Die Skripte fuer die Erstellung von CD-ROMs umgestellt, so dass jetzt ein Festplattenimage auf die CD kopiert wird, das per ramoverlay auch temporaer beschreibbar ist. Signed-off-by: Kevin Wolf --- build/config/grub_cdrom.cfg | 4 +++- build/config/image_cdrom.sh | 1 + build/root-hd/config/servmgr/mount/cmd | 2 +- build/scripts/image_cdrom | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/build/config/grub_cdrom.cfg b/build/config/grub_cdrom.cfg index fc71ef7..008c828 100644 --- a/build/config/grub_cdrom.cfg +++ b/build/config/grub_cdrom.cfg @@ -3,6 +3,8 @@ kernel /tyndur debug=s module /init boot=file:/ module /ata module /iso9660 +module /ramoverlay +module /ext2 module /console servmgr:/term servmgr:/term -module /servmgr ata:/atapi10|iso9660:/ vterm:/vterm8/out ata iso9660 console +module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 boot diff --git a/build/config/image_cdrom.sh b/build/config/image_cdrom.sh index 3e3e67f..faffc5e 100644 --- a/build/config/image_cdrom.sh +++ b/build/config/image_cdrom.sh @@ -1,2 +1,3 @@ IMAGE_PATH="build/images/cdrom.img" FLOPPY_IMAGE_PATH="build/images/cdrom_floppy.img" +HD_IMAGE_PATH="build/images/hd.img" diff --git a/build/root-hd/config/servmgr/mount/cmd b/build/root-hd/config/servmgr/mount/cmd index 2d53391..0c9cb8a 100644 --- a/build/root-hd/config/servmgr/mount/cmd +++ b/build/root-hd/config/servmgr/mount/cmd @@ -1 +1 @@ -/modules/file mount file:/ ata:/ata00_p0|ext2:/ +/modules/file mount file:/ $ROOT diff --git a/build/scripts/image_cdrom b/build/scripts/image_cdrom index d569b4e..3cfe5c8 100755 --- a/build/scripts/image_cdrom +++ b/build/scripts/image_cdrom @@ -49,6 +49,21 @@ source config.sh export MTOOLSRC=lostmtools.conf +# Festplattenpartition kopieren +if [ ! -f $HD_IMAGE_PATH ]; then + echo "Benoetige ein Festplattenimage" + exit 1 +fi + + +PARTITIONS="`build/scripts/get_partition $HD_IMAGE_PATH`" +PART_START=`echo $PARTITIONS | awk '{print $1}'` + +dd if=$HD_IMAGE_PATH of=$ROOT_CDROM/hd.img skip=$PART_START + + +# CD bauen + if [ -f $STAGE2_ELTORITO ]; then # Eltorito mkdir -p $ROOT/boot/grub @@ -106,6 +121,7 @@ mcopy -D o build/config/grub_cdrom.cfg l:/boot/grub/menu.lst # Die noetigsten Treiber auf das Floppy-Image packen mcopy -D o $ROOT/boot/tyndur $ROOT/modules/init $ROOT/modules/console l:/ mcopy -D o $ROOT/modules/ata $ROOT/modules/iso9660 $ROOT/modules/servmgr l:/ +mcopy -D o $ROOT/modules/ext2 $ROOT/modules/ramoverlay l:/ # Konfigurationsdatei fuer mtools wieder loeschen rm -f $MTOOLSRC -- 1.6.0.2 From hartmut at tyndur.org Mon Dec 7 16:21:46 2009 From: hartmut at tyndur.org (Alexander H. Kluth) Date: Mon, 07 Dec 2009 16:21:46 +0100 Subject: [tyndur-devel] ps: Ausgabe besser formatiert Message-ID: <20091207162146.13121zne4teq2cga@mail.famkaufmann.info> ! ps.c: Die Pfade vor dem Prozess wurden nun gestrippt ! ps.c: EIP wird nicht mehr ausgegeben, nur auf Wunsch via --with-eip Signed-off-by: Alexander Hartmut Kluth --- src/modules/c/shell/cmds/ps.c | 57 ++++++++++++++++++++++++++++++++++------ 1 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/modules/c/shell/cmds/ps.c b/src/modules/c/shell/cmds/ps.c index e6ffe3b..e000f4e 100644 --- a/src/modules/c/shell/cmds/ps.c +++ b/src/modules/c/shell/cmds/ps.c @@ -36,6 +36,7 @@ #include "types.h" #include "stdlib.h" #include "stdio.h" +#include "string.h" #include "syscall.h" #include "unistd.h" #include @@ -48,21 +49,59 @@ void ps_display_usage(void); int main(int argc, char* argv[]) #endif { - if (argc > 1) { + if (argc > 2) { ps_display_usage(); return -1; } + + bool with_eip; + char *temp, *process; + char copied_cmdline[255]; + + if (argc > 1) { + if (strcmp(argv[1], "--with-eip") == 0) { + with_eip = TRUE; + } else { + with_eip = FALSE; + } + } else { + with_eip = FALSE; + } task_info_t* task_info = enumerate_tasks(); dword i; - puts(" PID PPID Status eip Speicher CMD"); - for (i = 0; i < task_info->task_count; i++) { - printf("%4d %4d %1d %08x %08x %s\n", task_info->tasks[i].pid, - task_info->tasks[i].parent_pid, task_info->tasks[i].status, - task_info->tasks[i].eip, - task_info->tasks[i].memory_used, - task_info->tasks[i].cmdline); + if (with_eip) { + puts(" PID PPID Status eip Speicher CMD"); + } else { + puts(" PID PPID Status Speicher CMD"); + } + + for (i = 0; i < task_info->task_count; i++) { + strncpy(copied_cmdline, task_info->tasks[i].cmdline, 255); + + process = strtok((char*)task_info->tasks[i].cmdline, " "); + process = strrchr(process, '/'); + + if ((temp = strchr(copied_cmdline, ' '))) { + strcat(process, temp); + } + + if (with_eip) { + printf("%4d %4d %1d %08x %ik %s\n", task_info->tasks[i].pid, + task_info->tasks[i].parent_pid, task_info->tasks[i].status, + task_info->tasks[i].eip, + (task_info->tasks[i].memory_used / 1000), + ++process); + } else { + printf("%4d %4d %1d %ik %s\n", task_info->tasks[i].pid, + task_info->tasks[i].parent_pid, task_info->tasks[i].status, + (task_info->tasks[i].memory_used / 1000), + ++process); + } + + process = NULL; + temp = NULL; } return EXIT_SUCCESS; @@ -70,6 +109,6 @@ void ps_display_usage(void); void ps_display_usage() { - puts("\nAufruf: ps"); + puts("\nAufruf: ps [--with-eip]"); } -- 1.6.5.1.1367.gcd48 From kevin at tyndur.org Tue Dec 8 20:34:47 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Tue, 8 Dec 2009 20:34:47 +0100 Subject: [tyndur-devel] [PATCH] lpt list kompakter machen Message-ID: <1260300887-16080-1-git-send-email-kevin@tyndur.org> * lpt: Die Paketliste ist im Moment als Baum nur sehr bedingt sinnvoll, weil es sowieso keine Knoten mit mehr als einem Kind gibt. Machen wir lieber eine schoene Liste draus und packen die Paketbeschreibung noch rein. Signed-off-by: Kevin Wolf --- src/modules/pas/lpt/lpt.pas | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas index d4d1630..348900b 100644 --- a/src/modules/pas/lpt/lpt.pas +++ b/src/modules/pas/lpt/lpt.pas @@ -263,22 +263,28 @@ begin for i := 0 to pkgset.packages.count - 1 do begin pkg := TPackage(pkgset.packages.items[i]); - WriteLn('+ ' + pkg.name); for j := 0 to pkg.sections.count - 1 do begin sect := TPackageSection(pkg.sections.items[j]); - WriteLn('| + ' + sect.section); for k := 0 to sect.versions.count - 1 do begin ver := TPackageVersion(sect.versions.items[k]); - WriteLn('| | + ' + ver.version); + + Write(pkg.name, StringOfChar(' ', 12 - Length(pkg.name))); + Write(' | ', sect.section, StringOfChar(' ', 5 - Length(sect.section))); + Write(' | ', ver.version : 10); + if Length(pkg.desc) > 43 then begin + WriteLn(' | ' + Copy(pkg.desc, 1, 40), '...'); + end else begin + WriteLn(' | ' + pkg.desc); + end; for l := 0 to ver.preinstDependencies.count - 1 do begin dep := TDependency(ver.preinstDependencies.items[l]); - WriteLn('| | | [i] ' + dep.pkgname + ' (' + dep.section + ')'); + WriteLn('' : 36, 'Installation hängt ab von: ' + dep.pkgname + ' (' + dep.section + ')'); end; for l := 0 to ver.runDependencies.count - 1 do begin dep := TDependency(ver.runDependencies.items[l]); - WriteLn('| | | [r] ' + dep.pkgname + ' (' + dep.section + ')'); + WriteLn('' : 36, 'Hängt ab von: ' + dep.pkgname + ' (' + dep.section + ')'); end; end; -- 1.6.0.2 From toni at tyndur.org Tue Dec 8 20:42:18 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 8 Dec 2009 20:42:18 +0100 Subject: [tyndur-devel] [PATCH] lpt list kompakter machen In-Reply-To: <1260300887-16080-1-git-send-email-kevin@tyndur.org> References: <1260300887-16080-1-git-send-email-kevin@tyndur.org> Message-ID: <20091208194218.GA17883@thales.kaufmann.lan> On Tue, Dec 08 20:34, Kevin Wolf wrote: > * lpt: Die Paketliste ist im Moment als Baum nur sehr bedingt sinnvoll, > weil es sowieso keine Knoten mit mehr als einem Kind gibt. Machen wir > lieber eine schoene Liste draus und packen die Paketbeschreibung noch > rein. > > Signed-off-by: Kevin Wolf > --- > src/modules/pas/lpt/lpt.pas | 16 +++++++++++----- > 1 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas > index d4d1630..348900b 100644 > --- a/src/modules/pas/lpt/lpt.pas > +++ b/src/modules/pas/lpt/lpt.pas > @@ -263,22 +263,28 @@ begin > > for i := 0 to pkgset.packages.count - 1 do begin > pkg := TPackage(pkgset.packages.items[i]); > - WriteLn('+ ' + pkg.name); > for j := 0 to pkg.sections.count - 1 do begin > sect := TPackageSection(pkg.sections.items[j]); > - WriteLn('| + ' + sect.section); > for k := 0 to sect.versions.count - 1 do begin > ver := TPackageVersion(sect.versions.items[k]); > - WriteLn('| | + ' + ver.version); > + > + Write(pkg.name, StringOfChar(' ', 12 - Length(pkg.name))); > + Write(' | ', sect.section, StringOfChar(' ', 5 - Length(sect.section))); > + Write(' | ', ver.version : 10); > + if Length(pkg.desc) > 43 then begin > + WriteLn(' | ' + Copy(pkg.desc, 1, 40), '...'); > + end else begin > + WriteLn(' | ' + pkg.desc); > + end; > > for l := 0 to ver.preinstDependencies.count - 1 do begin > dep := TDependency(ver.preinstDependencies.items[l]); > - WriteLn('| | | [i] ' + dep.pkgname + ' (' + dep.section + ')'); > + WriteLn('' : 36, 'Installation h??ngt ab von: ' + dep.pkgname + ' (' + dep.section + ')'); Öhm kein english here? ;-) > end; > > for l := 0 to ver.runDependencies.count - 1 do begin > dep := TDependency(ver.runDependencies.items[l]); > - WriteLn('| | | [r] ' + dep.pkgname + ' (' + dep.section + ')'); > + WriteLn('' : 36, 'H??ngt ab von: ' + dep.pkgname + ' (' + dep.section + ')'); Und hier auch nicht? > end; > > end; Sonst sieht das gut aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Wed Dec 9 19:52:07 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 9 Dec 2009 19:52:07 +0100 Subject: [tyndur-devel] [PATCH] LostIO: Fix fuer Race-Condition beim Anlegen von neuen Knoten Message-ID: <1260384727-3547-1-git-send-email-toni@tyndur.org> ! LostIO: Fix fuer Race-Condition beim Anlegen von neuen Knoten. Dabei wurde der Knoten erst nach dem Eintragen beim Vater-Knoten als Kind fertig initialisiert. Weiter hat da auch ein p/v() gefehlt. Signed-off-by: Antoine Kaufmann --- src/modules/lib/lostio/vfstree.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/lib/lostio/vfstree.c b/src/modules/lib/lostio/vfstree.c index 9463847..96f09bf 100644 --- a/src/modules/lib/lostio/vfstree.c +++ b/src/modules/lib/lostio/vfstree.c @@ -217,8 +217,6 @@ bool vfstree_create_child(vfstree_node_t* parent, char* name, typeid_t type, siz { vfstree_node_t* new_file = malloc(sizeof(vfstree_node_t)); - parent->children = list_push((list_t*)parent->children, (void*) new_file); - parent->size++; new_file->type = type; new_file->name = malloc(strlen(name) + 1); @@ -228,9 +226,15 @@ bool vfstree_create_child(vfstree_node_t* parent, char* name, typeid_t type, siz new_file->data = data; new_file->flags = flags; - new_file->resid = next_resid++; new_file->children = list_create(); new_file->parent = parent; + + p(); + new_file->resid = next_resid++; + parent->children = list_push((list_t*)parent->children, (void*) new_file); + parent->size++; + v(); + return TRUE; } -- 1.6.3.3 From toni at tyndur.org Wed Dec 9 19:52:41 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 9 Dec 2009 19:52:41 +0100 Subject: [tyndur-devel] [PATCH] Libc: p()/v() in Makros umgewandelt, die noch eine Barrier beinhalten Message-ID: <1260384761-3730-1-git-send-email-toni@tyndur.org> * Libc: p()/v() in Makros umgewandelt, die noch eine Barrier beinhalten, die eigentlichen Funktionen wurden in syscall_p/v umbenannt. Signed-off-by: Antoine Kaufmann --- src/kernel/src/init.c | 4 ++-- src/kernel2/src/pv.c | 4 ++-- src/lib/stdlibc/liballoc.c | 8 ++++---- src/modules/include/syscall.h | 8 ++++++-- src/modules/lib/syscalls/pv.c | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/kernel/src/init.c b/src/kernel/src/init.c index 58309ca..f8fd58d 100644 --- a/src/kernel/src/init.c +++ b/src/kernel/src/init.c @@ -176,5 +176,5 @@ __attribute__((noreturn)) void panic(char * message, ...) } } -void p(void) {} -void v(void) {} +void syscall_p(void) {} +void syscall_v(void) {} diff --git a/src/kernel2/src/pv.c b/src/kernel2/src/pv.c index fe79fe1..780c352 100644 --- a/src/kernel2/src/pv.c +++ b/src/kernel2/src/pv.c @@ -1,4 +1,4 @@ // Das hier ist ein gemeiner Hack, damit es in den Locking-Funktionen von // liballoc keine nicht-aufgelösten Symbole gibt. -void __attribute__((weak)) p(void) {} -void __attribute__((weak)) v(void) {} +void __attribute__((weak)) syscall_p(void) {} +void __attribute__((weak)) syscall_v(void) {} diff --git a/src/lib/stdlibc/liballoc.c b/src/lib/stdlibc/liballoc.c index c02892f..da125b3 100644 --- a/src/lib/stdlibc/liballoc.c +++ b/src/lib/stdlibc/liballoc.c @@ -8,8 +8,8 @@ #define PREFIX(func) func extern void* mem_allocate(dword size, dword flags); -extern void p(void); -extern void v(void); +extern void syscall_p(void); +extern void syscall_v(void); extern void mem_free(void* address, dword size); /** Durand's Amazing Super Duper Memory functions. */ @@ -114,14 +114,14 @@ static lock_t la_lock = 0; static int liballoc_lock(void) { //lock(&la_lock); - p(); + syscall_p(); return 0; } static int liballoc_unlock(void) { //unlock(&la_lock); - v(); + syscall_v(); return 0; } diff --git a/src/modules/include/syscall.h b/src/modules/include/syscall.h index 6bb3593..325e11c 100644 --- a/src/modules/include/syscall.h +++ b/src/modules/include/syscall.h @@ -65,8 +65,12 @@ bool release_ports(dword port, dword length); void yield(void); void wait_for_rpc(void); -void p(void); -void v(void); +void syscall_p(void); +void syscall_v(void); + +#define p() do { asm volatile (""); syscall_p(); } while (0) +#define v() do { asm volatile (""); syscall_v(); } while (0) + void set_rpc_handler(void (*rpc_handler)(void)); void add_intr_handler(dword intr); diff --git a/src/modules/lib/syscalls/pv.c b/src/modules/lib/syscalls/pv.c index 98ab630..e8c425b 100644 --- a/src/modules/lib/syscalls/pv.c +++ b/src/modules/lib/syscalls/pv.c @@ -1,6 +1,6 @@ #include "syscall.h" -void p() +void syscall_p() { asm( "mov %0, %%eax;" @@ -8,7 +8,7 @@ void p() : : "i" (SYSCALL_PM_P) : "eax"); } -void v() +void syscall_v() { asm( "mov %0, %%eax;" -- 1.6.3.3 From toni at tyndur.org Wed Dec 9 19:53:22 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 9 Dec 2009 19:53:22 +0100 Subject: [tyndur-devel] [PATCH] vterm: Schweizerdeutsches Tastaturlayout Message-ID: <1260384802-3947-1-git-send-email-toni@tyndur.org> + vterm: Schweizerdeutsches Tastaturlayout Signed-off-by: Antoine Kaufmann --- src/modules/vterm/keymaps/Makefile.all | 2 +- src/modules/vterm/keymaps/de_ch.c | 167 ++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletions(-) create mode 100644 src/modules/vterm/keymaps/de_ch.c diff --git a/src/modules/vterm/keymaps/Makefile.all b/src/modules/vterm/keymaps/Makefile.all index b0efe9a..7e47059 100644 --- a/src/modules/vterm/keymaps/Makefile.all +++ b/src/modules/vterm/keymaps/Makefile.all @@ -3,7 +3,7 @@ source $LOST_BUILDMK_ROOT/config.sh mkdir -p $1/system/keymaps -for lang in de us; do +for lang in de us de_ch; do echo "KMAP $lang" $LOST_TOOLS_LD --oformat binary $lang.o -e 0 -o $1/system/keymaps/$lang.kbd chmod a-x $1/system/keymaps/$lang.kbd diff --git a/src/modules/vterm/keymaps/de_ch.c b/src/modules/vterm/keymaps/de_ch.c new file mode 100644 index 0000000..0e81cb7 --- /dev/null +++ b/src/modules/vterm/keymaps/de_ch.c @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2008 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 "keymap.h" + +keymap_entry_t keymap[128] = { + { 0, 0, 0, 0 }, // 0 + { '\033', '\033', '\033', '\033' }, + { '1', '+', '|', 0 }, + { '2', '"', '@', 0 }, + { '3', '*', '#', 0 }, + { '4', L'ç', 0, 0 }, + { '5', '%', 0, 0 }, + { '6', '&', L'¬', 0 }, + { '7', '/', '|', 0 }, + { '8', '(', L'¢', 0 }, + { '9', ')', 0, 0 }, // 10 + { '0', '=', 0, 0 }, + { '\'', '?', '\'', 0 }, + { '^', '`', '~', 0 }, + { '\b', 0, 0, 0 }, + { '\t', 0, 0, 0 }, + { 'q', 'Q', 0, 17 }, + { 'w', 'W', 0, 23 }, + { 'e', 'E', L'€', 5 }, + { 'r', 'R', 0, 18 }, + { 't', 'T', 0, 20 }, // 20 + { 'z', 'Z', 0, 26 }, + { 'u', 'U', 0, 21 }, + { 'i', 'I', 0, 9 }, + { 'o', 'O', 0, 15 }, + { 'p', 'P', 0, 16 }, + {L'ü', L'è', '[', 0 }, + { 0, '!', ']', 0 }, + { '\n', 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 'a', 'A', 0, 1 }, // 30 + { 's', 'S', 0, 19 }, + { 'd', 'D', 0, 4 }, + { 'f', 'F', 0, 6 }, + { 'g', 'G', 0, 7 }, + { 'h', 'H', 0, 8 }, + { 'j', 'J', 0, 10 }, + { 'k', 'K', 0, 11 }, + { 'l', 'L', 0, 12 }, + {L'ö', L'é', 0, 0 }, + {L'ä', L'à', L'{', 0 }, // 40 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { '$', L'£', '}', 0 }, + { 'y', 'Y', 0, 25 }, + { 'x', 'X', 0, 24 }, + { 'c', 'C', 0, 3 }, + { 'v', 'V', 0, 22 }, + { 'b', 'B', 0, 2 }, + { 'n', 'N', 0, 14 }, + { 'm', 'M', 0, 13 }, // 50 + { ',', ';', 0, 0 }, + { '.', ':', 0, 0 }, + { '-', '_', 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { ' ', ' ', ' ', 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 60 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 70 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 80 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { '<', '>', '\\', 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 90 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 100 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 110 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, // 120 + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, +}; -- 1.6.3.3 From toni at tyndur.org Wed Dec 9 19:54:26 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 9 Dec 2009 19:54:26 +0100 Subject: [tyndur-devel] [PATCH] Pascal-RTL: DeleteFile() implementiert Message-ID: <1260384866-4240-1-git-send-email-toni@tyndur.org> + Pascal-RTL: DeleteFile() implementiert Signed-off-by: Antoine Kaufmann --- src/modules/pas/lib/rtl/sysutils.pp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/modules/pas/lib/rtl/sysutils.pp b/src/modules/pas/lib/rtl/sysutils.pp index 7eef839..8009993 100644 --- a/src/modules/pas/lib/rtl/sysutils.pp +++ b/src/modules/pas/lib/rtl/sysutils.pp @@ -54,6 +54,8 @@ function c_feof(f: longint): boolean; cdecl; external name 'feof'; function c_init_execute(cmd: PChar): dword; cdecl; external name 'init_execute'; function c_waitpid(pid: integer; status: Pointer; flags: integer): integer; cdecl; external name 'waitpid'; +function c_remove(filename: PChar): longint; cdecl; external name 'remove'; + type DirEntry = record name: array [1..32] of char; @@ -310,8 +312,11 @@ begin end; function DeleteFile(const filename: AnsiString):Boolean; +var + c_filename: String; begin - Result := true; // FIXME + c_filename := filename + #0; + Result := (c_remove(@c_filename[1]) = 0); end; function RenameFile(const oldname: AnsiString;const newname: AnsiString):Boolean; -- 1.6.3.3 From kevin at tyndur.org Wed Dec 9 20:09:41 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 9 Dec 2009 20:09:41 +0100 Subject: [tyndur-devel] [PATCH] Pascal-RTL: DeleteFile() implementiert In-Reply-To: <1260384866-4240-1-git-send-email-toni@tyndur.org> References: <1260384866-4240-1-git-send-email-toni@tyndur.org> Message-ID: <20091209190940.GA26856@silvanus> On Wed, Dec 09, 2009 at 07:54:26PM +0100, Antoine Kaufmann wrote: > + Pascal-RTL: DeleteFile() implementiert > > Signed-off-by: Antoine Kaufmann Acked-by: Kevin Wolf From kevin at tyndur.org Wed Dec 9 20:12:50 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 9 Dec 2009 20:12:50 +0100 Subject: [tyndur-devel] [PATCH] vterm: Schweizerdeutsches Tastaturlayout In-Reply-To: <1260384802-3947-1-git-send-email-toni@tyndur.org> References: <1260384802-3947-1-git-send-email-toni@tyndur.org> Message-ID: <20091209191249.GB26856@silvanus> On Wed, Dec 09, 2009 at 07:53:22PM +0100, Antoine Kaufmann wrote: > + vterm: Schweizerdeutsches Tastaturlayout > > Signed-off-by: Antoine Kaufmann Ich gehe mal davon aus, dass du weißt, wie das aussehen muss und dass du es auch getestet hast. Mit weiteren Aussagen bezüglich der Korrektheit würde ich mich vermutlich zu weit aus dem Fenster lehnen. ;-) Schieb's einfach rein. From kevin at tyndur.org Wed Dec 9 20:35:08 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 9 Dec 2009 20:35:08 +0100 Subject: [tyndur-devel] [PATCH] Libc: p()/v() in Makros umgewandelt, die noch eine Barrier beinhalten In-Reply-To: <1260384761-3730-1-git-send-email-toni@tyndur.org> References: <1260384761-3730-1-git-send-email-toni@tyndur.org> Message-ID: <20091209193504.GC26856@silvanus> On Wed, Dec 09, 2009 at 07:52:41PM +0100, Antoine Kaufmann wrote: > * Libc: p()/v() in Makros umgewandelt, die noch eine Barrier beinhalten, > die eigentlichen Funktionen wurden in syscall_p/v umbenannt. > > Signed-off-by: Antoine Kaufmann > --- > src/kernel/src/init.c | 4 ++-- > src/kernel2/src/pv.c | 4 ++-- > src/lib/stdlibc/liballoc.c | 8 ++++---- > src/modules/include/syscall.h | 8 ++++++-- > src/modules/lib/syscalls/pv.c | 4 ++-- > 5 files changed, 16 insertions(+), 12 deletions(-) > > diff --git a/src/kernel/src/init.c b/src/kernel/src/init.c > index 58309ca..f8fd58d 100644 > --- a/src/kernel/src/init.c > +++ b/src/kernel/src/init.c > @@ -176,5 +176,5 @@ __attribute__((noreturn)) void panic(char * message, ...) > } > } > > -void p(void) {} > -void v(void) {} > +void syscall_p(void) {} > +void syscall_v(void) {} > diff --git a/src/kernel2/src/pv.c b/src/kernel2/src/pv.c > index fe79fe1..780c352 100644 > --- a/src/kernel2/src/pv.c > +++ b/src/kernel2/src/pv.c > @@ -1,4 +1,4 @@ > // Das hier ist ein gemeiner Hack, damit es in den Locking-Funktionen von > // liballoc keine nicht-aufgel?sten Symbole gibt. > -void __attribute__((weak)) p(void) {} > -void __attribute__((weak)) v(void) {} > +void __attribute__((weak)) syscall_p(void) {} > +void __attribute__((weak)) syscall_v(void) {} > diff --git a/src/lib/stdlibc/liballoc.c b/src/lib/stdlibc/liballoc.c > index c02892f..da125b3 100644 > --- a/src/lib/stdlibc/liballoc.c > +++ b/src/lib/stdlibc/liballoc.c > @@ -8,8 +8,8 @@ > #define PREFIX(func) func > > extern void* mem_allocate(dword size, dword flags); > -extern void p(void); > -extern void v(void); > +extern void syscall_p(void); > +extern void syscall_v(void); > extern void mem_free(void* address, dword size); > > /** Durand's Amazing Super Duper Memory functions. */ > @@ -114,14 +114,14 @@ static lock_t la_lock = 0; > static int liballoc_lock(void) > { > //lock(&la_lock); > - p(); > + syscall_p(); > return 0; > } > > static int liballoc_unlock(void) > { > //unlock(&la_lock); > - v(); > + syscall_v(); > return 0; > } > > diff --git a/src/modules/include/syscall.h b/src/modules/include/syscall.h > index 6bb3593..325e11c 100644 > --- a/src/modules/include/syscall.h > +++ b/src/modules/include/syscall.h > @@ -65,8 +65,12 @@ bool release_ports(dword port, dword length); > > void yield(void); > void wait_for_rpc(void); > -void p(void); > -void v(void); > +void syscall_p(void); > +void syscall_v(void); > + > +#define p() do { asm volatile (""); syscall_p(); } while (0) > +#define v() do { asm volatile (""); syscall_v(); } while (0) Ich würde ein __sync_synchronize() bevorzugen, wenn gcc schon solche Builtins hat. Ansonsten wäre wohl zumindest ein asm("" ::: "memory") angebracht, damit es auch wirklich wirkt. From kevin at tyndur.org Wed Dec 9 20:40:38 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 9 Dec 2009 20:40:38 +0100 Subject: [tyndur-devel] [PATCH] LostIO: Fix fuer Race-Condition beim Anlegen von neuen Knoten In-Reply-To: <1260384727-3547-1-git-send-email-toni@tyndur.org> References: <1260384727-3547-1-git-send-email-toni@tyndur.org> Message-ID: <20091209194038.GD26856@silvanus> On Wed, Dec 09, 2009 at 07:52:07PM +0100, Antoine Kaufmann wrote: > ! LostIO: Fix fuer Race-Condition beim Anlegen von neuen Knoten. Dabei > wurde der Knoten erst nach dem Eintragen beim Vater-Knoten als > Kind fertig initialisiert. Weiter hat da auch ein p/v() > gefehlt. In derselben Datei fehlt zumindest in vfstree_get_node_by_name und vfstree_clear_node noch jeweils ein p/v bei Listenzugriffen. Aber der Teil, der da ist, sieht vernünftig aus. > > Signed-off-by: Antoine Kaufmann > --- > src/modules/lib/lostio/vfstree.c | 10 +++++++--- > 1 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/src/modules/lib/lostio/vfstree.c b/src/modules/lib/lostio/vfstree.c > index 9463847..96f09bf 100644 > --- a/src/modules/lib/lostio/vfstree.c > +++ b/src/modules/lib/lostio/vfstree.c > @@ -217,8 +217,6 @@ bool vfstree_create_child(vfstree_node_t* parent, char* name, typeid_t type, siz > { > vfstree_node_t* new_file = malloc(sizeof(vfstree_node_t)); > > - parent->children = list_push((list_t*)parent->children, (void*) new_file); > - parent->size++; > new_file->type = type; > > new_file->name = malloc(strlen(name) + 1); > @@ -228,9 +226,15 @@ bool vfstree_create_child(vfstree_node_t* parent, char* name, typeid_t type, siz > new_file->data = data; > new_file->flags = flags; > > - new_file->resid = next_resid++; > new_file->children = list_create(); > new_file->parent = parent; > + > + p(); > + new_file->resid = next_resid++; > + parent->children = list_push((list_t*)parent->children, (void*) new_file); > + parent->size++; > + v(); > + > return TRUE; > } > > -- > 1.6.3.3 > > _______________________________________________ > tyndur-devel mailing list > tyndur-devel at tyndur.org > http://list.tyndur.org/mailman/listinfo/tyndur-devel From hartmut at tyndur.org Thu Dec 10 07:52:28 2009 From: hartmut at tyndur.org (Alexander H. Kluth) Date: Thu, 10 Dec 2009 07:52:28 +0100 Subject: [tyndur-devel] kirc: Input-Parsing Message-ID: <20091210075228.57022rswhdewptpo@mail.famkaufmann.info> + kirc.pas: Befehle werden nun geparsed + kirc.pas: Kürzel wie /cs oder /voice implementiert + kirc.pas: Direkte Befehle können nur noch via /irc geschickt werden ! kirc.pas: Server auf irc.euirc.net geändert + kirc.pas: Channel-Frage hinzugefügt (#lost als Standardchannel) + kirc.pas: Bei Ende des MOTD wird der gewollte Channel gejoint Signed-off-by: Alexander H. Kluth --- src/modules/pas/kirc/kirc.pas | 65 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/modules/pas/kirc/kirc.pas b/src/modules/pas/kirc/kirc.pas index 7b6ad9b..a44a228 100644 --- a/src/modules/pas/kirc/kirc.pas +++ b/src/modules/pas/kirc/kirc.pas @@ -74,6 +74,12 @@ begin ReadLn(nick); until NickIsValid(nick); + Write('Channel :'); + ReadLn(channel); + if channel = '' then begin + channel := '#lost'; + end; + conn := FileOpen('tcpip:/'+server+':'+port, fmOpenReadWrite); if conn = -1 then begin @@ -213,6 +219,11 @@ begin + msg, 7); end; end + + // 376 leutet das Ende des MOTD ein + else if command = '376' then begin + WriteConn(conn, 'JOIN ' + channel); + end else if command = 'ERROR' then begin theIRCWindow.Incoming(line, 12); end @@ -238,12 +249,56 @@ begin theIRCWindow.Incoming('Ungueltiger Befehl: ' + line, 12); end; end else begin - if line[1] = '/' then begin - WriteConn(conn, Copy(line, 2, length(line)) + #10); + // Wir brauchen so etwas wie TStringList in der RTL + // Höhö, das kennen wir doch aus kedit: Wir prüfen + // per LeftStr, ob es ein (uns bekanntest) Kommando ist + if LeftStr(line, 3) = '/ns' then begin + command := 'PRIVMSG NickServ :' + Copy(line, 5, length(line)) + + #10; + end else if LeftStr(line, 3) = '/cs' then begin + command := 'PRIVMSG ChanServ :' + Copy(line, 5, length(line)) + + #10; + end else if LeftStr(line, 6) = '/voice' then begin + // mit Copy(line, 7...) spare ich mir ein zusätzliches + " " + + command := 'MODE ' + channel + ' +v ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 8) = '/devoice' then begin + command := 'MODE ' + channel + ' -v ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 3) = '/op' then begin + command := 'MODE ' + channel + ' +o ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 5) = '/deop' then begin + command := 'MODE ' + channel + ' -o ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 6) = '/admin' then begin + command := 'MODE ' + channel + ' +a ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 8) = '/deadmin' then begin + command := 'MODE ' + channel + ' -a ' + Copy(line, 8, + length(line)) + #10; + end else if LeftStr(line, 5) = '/kick' then begin + space := Pos(' ', Copy(line, 7, length(line))); + + command := 'KICK ' + channel + ' ' + Copy(line, 7, space-1) + + ' :' + Copy(line, space+1, length(line)) + #10; + end else if LeftStr(line, 4) = '/ban' then begin + command := 'MODE ' + channel + ' +b ' + Copy(line, 6, + length(line)) + '!*@*' + #10; + end else if LeftStr(line, 6) = '/unban' then begin + command := 'MODE ' + channel + ' -b ' + Copy(line, 8, + length(line)) + '!*@*' + #10; + end else if LeftStr(line, 6) = '/42' then begin + theIRCWindow.title := 'The Answer to Life, the Universe, and Everything is ... 42'; + end else if LeftStr(line, 4) = '/irc' then begin + command := Copy(line, 6, length(line)); end else begin - theIRCWindow.Incoming('<' + nick + '> ' + line+#10, 7); - WriteConn(conn, 'PRIVMSG '+channel+' :'+line+#10); + space := Pos(' ', line); + + theIRCWindow.Incoming('Unbekannter Befehl ' + Copy(line, 0, space), 12); end; + + WriteConn(conn, command); end; end; @@ -260,8 +315,6 @@ begin theIRCWindow.commandHandler := @EvaluateIRCCommand; theIRCWindow.Draw(false); - channel := ''; - inBuffer := ''; outBuffer := ''; while not FileEof(conn) do begin -- 1.6.5.1.1367.gcd48 From hartmut at tyndur.org Thu Dec 10 10:05:06 2009 From: hartmut at tyndur.org (Alexander H. Kluth) Date: Thu, 10 Dec 2009 10:05:06 +0100 Subject: [tyndur-devel] pstree: Pfadnamen gestrippt Message-ID: <20091210100506.15346sevq4vkogjm@mail.famkaufmann.info> From 224a2985477fae77a98995973c653e21f74de182 Mon Sep 17 00:00:00 2001 From: Alexander H. Kluth Date: Wed, 9 Dec 2009 10:02:51 +0100 Subject: [PATCH] pstree: Pfade gestrippt + pstree.c: Analog zu ps.c die Pfade vor den Prozessen gestriptt Signed-off-by: Alexander H. Kluth --- src/modules/c/shell/cmds/pstree.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/src/modules/c/shell/cmds/pstree.c b/src/modules/c/shell/cmds/pstree.c index d6f63dd..6200d26 100644 --- a/src/modules/c/shell/cmds/pstree.c +++ b/src/modules/c/shell/cmds/pstree.c @@ -35,6 +35,7 @@ #include "stdlib.h" #include "stdio.h" +#include "string.h" #include "syscall.h" #include "unistd.h" #include @@ -68,16 +69,30 @@ void pstree_display_usage() void pstree_show_children(pid_t pid, byte depth) { dword i, j; + char *temp, *process; + char copied_cmdline[255]; for (i = 0; i < task_info->task_count; i++) { + strncpy(copied_cmdline, task_info->tasks[i].cmdline, 255); + + process = strtok((char*)task_info->tasks[i].cmdline, " "); + process = strrchr(process, '/'); + + if ((temp = strchr(copied_cmdline, ' '))) { + strcat(process, temp); + } + if (task_info->tasks[i].parent_pid == pid) { for (j = 0; j < depth; j++) { printf(" "); } - printf("%s\n", task_info->tasks[i].cmdline); + printf("- %s\n", ++process); pstree_show_children(task_info->tasks[i].pid, depth + 1); } + + process = NULL; + temp = NULL; } } -- 1.6.5.1.1367.gcd48 From kevin at tyndur.org Fri Dec 11 23:47:21 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Fri, 11 Dec 2009 23:47:21 +0100 Subject: [tyndur-devel] kirc: Input-Parsing In-Reply-To: <20091210075228.57022rswhdewptpo@mail.famkaufmann.info> References: <20091210075228.57022rswhdewptpo@mail.famkaufmann.info> Message-ID: <20091211224720.GA2618@silvanus> On Thu, Dec 10, 2009 at 07:52:28AM +0100, Alexander H. Kluth wrote: > + kirc.pas: Befehle werden nun geparsed > + kirc.pas: Kürzel wie /cs oder /voice implementiert > + kirc.pas: Direkte Befehle können nur noch via /irc geschickt werden > ! kirc.pas: Server auf irc.euirc.net geändert > + kirc.pas: Channel-Frage hinzugefügt (#lost als Standardchannel) > + kirc.pas: Bei Ende des MOTD wird der gewollte Channel gejoint > > Signed-off-by: Alexander H. Kluth Der Patch ist nicht anwendbar. Hab ich lokal gefixt. Er enthält einen Haufen Tabs statt Leerzeichen. Hab ich auch gefixt. Kompilierbar ist er leider auch nicht. Ebenfalls gefixt. Anschließend war kirc total kaputt. Ich glaube, der Patch braucht nochmal eine neue Version. > --- > src/modules/pas/kirc/kirc.pas | 65 > +++++++++++++++++++++++++++++++++++++---- > 1 files changed, 59 insertions(+), 6 deletions(-) > > diff --git a/src/modules/pas/kirc/kirc.pas b/src/modules/pas/kirc/kirc.pas > index 7b6ad9b..a44a228 100644 > --- a/src/modules/pas/kirc/kirc.pas > +++ b/src/modules/pas/kirc/kirc.pas > @@ -74,6 +74,12 @@ begin > ReadLn(nick); > until NickIsValid(nick); > > + Write('Channel :'); Konsistent wäre hier 'Channel [#lost]:' > + ReadLn(channel); > + if channel = '' then begin > + channel := '#lost'; > + end; > + > conn := FileOpen('tcpip:/'+server+':'+port, fmOpenReadWrite); > > if conn = -1 then begin > @@ -213,6 +219,11 @@ begin > + msg, 7); > end; > end > + > + // 376 leutet das Ende des MOTD ein > + else if command = '376' then begin > + WriteConn(conn, 'JOIN ' + channel); > + end In meinem Test ist er nie auf die Idee gekommen, auch wirklich zu joinen > else if command = 'ERROR' then begin > theIRCWindow.Incoming(line, 12); > end > @@ -238,12 +249,56 @@ begin > theIRCWindow.Incoming('Ungueltiger Befehl: ' + line, 12); > end; > end else begin > - if line[1] = '/' then begin > - WriteConn(conn, Copy(line, 2, length(line)) + #10); > + // Wir brauchen so etwas wie TStringList in der RTL > + // Höhö, das kennen wir doch aus kedit: Wir prüfen > + // per LeftStr, ob es ein (uns bekanntest) Kommando ist > + if LeftStr(line, 3) = '/ns' then begin > + command := 'PRIVMSG NickServ :' + Copy(line, 5, length(line)) command ist nicht deklariert > + + #10; > + end else if LeftStr(line, 3) = '/cs' then begin > + command := 'PRIVMSG ChanServ :' + Copy(line, 5, length(line)) + > + #10; > + end else if LeftStr(line, 6) = '/voice' then begin > + // mit Copy(line, 7...) spare ich mir ein zusätzliches + " " + > + command := 'MODE ' + channel + ' +v ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 8) = '/devoice' then begin > + command := 'MODE ' + channel + ' -v ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 3) = '/op' then begin > + command := 'MODE ' + channel + ' +o ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 5) = '/deop' then begin > + command := 'MODE ' + channel + ' -o ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 6) = '/admin' then begin > + command := 'MODE ' + channel + ' +a ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 8) = '/deadmin' then begin > + command := 'MODE ' + channel + ' -a ' + Copy(line, 8, > + length(line)) + #10; > + end else if LeftStr(line, 5) = '/kick' then begin > + space := Pos(' ', Copy(line, 7, length(line))); > + > + command := 'KICK ' + channel + ' ' + Copy(line, 7, space-1) + > + ' :' + Copy(line, space+1, length(line)) + #10; > + end else if LeftStr(line, 4) = '/ban' then begin > + command := 'MODE ' + channel + ' +b ' + Copy(line, 6, > + length(line)) + '!*@*' + #10; > + end else if LeftStr(line, 6) = '/unban' then begin > + command := 'MODE ' + channel + ' -b ' + Copy(line, 8, > + length(line)) + '!*@*' + #10; > + end else if LeftStr(line, 6) = '/42' then begin > + theIRCWindow.title := 'The Answer to Life, the > Universe, and Everything is ... 42'; > + end else if LeftStr(line, 4) = '/irc' then begin > + command := Copy(line, 6, length(line)); > end else begin > - theIRCWindow.Incoming('<' + nick + '> ' + line+#10, 7); > - WriteConn(conn, 'PRIVMSG '+channel+' :'+line+#10); > + space := Pos(' ', line); > + > + theIRCWindow.Incoming('Unbekannter Befehl ' + > Copy(line, 0, space), 12); > end; Öhm, das macht nicht nur "/foo" zu einem Fehler, sondern auch "Moin", oder übersehe ich was? Das Copy geht außerdem schief, wenn der Befehl keinen Parameter hat, weil space dann 0 ist. Hast du den Patch selber überhaupt getestet? From kevin at tyndur.org Sat Dec 12 14:27:15 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 12 Dec 2009 14:27:15 +0100 Subject: [tyndur-devel] [PATCH] kbc: Nicht auf erfolgreichen Selbsttest bestehen Message-ID: <1260624435-26564-1-git-send-email-kevin@tyndur.org> ! kbc: In bochs ist das Statusbit fuer erfolgreichen nicht gesetzt und laesst sich auch nicht so einfach setzen. Pruefen wir eben nicht mehr darauf. Signed-off-by: Kevin Wolf --- src/modules/kbc/keyboard.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/modules/kbc/keyboard.c b/src/modules/kbc/keyboard.c index 2303228..26b65d3 100644 --- a/src/modules/kbc/keyboard.c +++ b/src/modules/kbc/keyboard.c @@ -82,7 +82,9 @@ static void send_key_event(uint8_t keycode, bool release); */ static void send_kbd_command(uint8_t command) { - while ((inb(0x64) & 0x6) != 0x4) yield(); + while (inb(0x64) & 0x2) { + yield(); + } outb(0x60, command); } -- 1.6.0.2 From toni at tyndur.org Sat Dec 12 14:34:11 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 12 Dec 2009 14:34:11 +0100 Subject: [tyndur-devel] [PATCH] kbc: Nicht auf erfolgreichen Selbsttest bestehen In-Reply-To: <1260624435-26564-1-git-send-email-kevin@tyndur.org> References: <1260624435-26564-1-git-send-email-kevin@tyndur.org> Message-ID: <20091212133411.GA5864@thales.kaufmann.lan> On Sat, Dec 12 14:27, Kevin Wolf wrote: > ! kbc: In bochs ist das Statusbit fuer erfolgreichen nicht gesetzt und ^^^ KRITIKEL! > laesst sich auch nicht so einfach setzen. Pruefen wir eben nicht mehr > darauf. > > Signed-off-by: Kevin Wolf > --- > src/modules/kbc/keyboard.c | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/src/modules/kbc/keyboard.c b/src/modules/kbc/keyboard.c > index 2303228..26b65d3 100644 > --- a/src/modules/kbc/keyboard.c > +++ b/src/modules/kbc/keyboard.c > @@ -82,7 +82,9 @@ static void send_key_event(uint8_t keycode, bool release); > */ > static void send_kbd_command(uint8_t command) > { > - while ((inb(0x64) & 0x6) != 0x4) yield(); > + while (inb(0x64) & 0x2) { > + yield(); > + } > outb(0x60, command); > } Ansonsten sieht das vernünftig aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Sat Dec 12 14:51:17 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sat, 12 Dec 2009 14:51:17 +0100 Subject: [tyndur-devel] [PATCH] config: Bootmenueeintrag fuer Englisch Message-ID: <1260625877-22511-1-git-send-email-kevin@tyndur.org> + config/grub_cdrom.cfg: Bootmenueeintrag fuer Englisch Signed-off-by: Kevin Wolf --- build/config/grub_cdrom.cfg | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/build/config/grub_cdrom.cfg b/build/config/grub_cdrom.cfg index 008c828..8949215 100644 --- a/build/config/grub_cdrom.cfg +++ b/build/config/grub_cdrom.cfg @@ -1,4 +1,4 @@ -title tyndur +title tyndur (Deutsch) kernel /tyndur debug=s module /init boot=file:/ module /ata @@ -8,3 +8,14 @@ module /ext2 module /console servmgr:/term servmgr:/term module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 boot + +title tyndur (English) +kernel /tyndur debug=s +module /init boot=file:/ env.LANG=en +module /ata +module /iso9660 +module /ramoverlay +module /ext2 +module /console servmgr:/term servmgr:/term +module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 +boot -- 1.6.0.2 From toni at tyndur.org Sat Dec 12 23:10:24 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 12 Dec 2009 23:10:24 +0100 Subject: [tyndur-devel] [PATCH] config: Bootmenueeintrag fuer Englisch In-Reply-To: <1260625877-22511-1-git-send-email-kevin@tyndur.org> References: <1260625877-22511-1-git-send-email-kevin@tyndur.org> Message-ID: <20091212221024.GA7548@thales.kaufmann.lan> On Sat, Dec 12 14:51, Kevin Wolf wrote: > + config/grub_cdrom.cfg: Bootmenueeintrag fuer Englisch > > Signed-off-by: Kevin Wolf > --- > build/config/grub_cdrom.cfg | 13 ++++++++++++- > 1 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/build/config/grub_cdrom.cfg b/build/config/grub_cdrom.cfg > index 008c828..8949215 100644 > --- a/build/config/grub_cdrom.cfg > +++ b/build/config/grub_cdrom.cfg > @@ -1,4 +1,4 @@ > -title tyndur > +title tyndur (Deutsch) > kernel /tyndur debug=s > module /init boot=file:/ > module /ata > @@ -8,3 +8,14 @@ module /ext2 > module /console servmgr:/term servmgr:/term > module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 > boot > + > +title tyndur (English) > +kernel /tyndur debug=s > +module /init boot=file:/ env.LANG=en > +module /ata > +module /iso9660 > +module /ramoverlay > +module /ext2 > +module /console servmgr:/term servmgr:/term > +module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 > +boot Wenn du das in hd und floppy auch noch reinpackst (stört ja dort auch nicht), ist das so in Ordnung. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sat Dec 12 23:38:51 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sat, 12 Dec 2009 23:38:51 +0100 Subject: [tyndur-devel] [PATCH] build: Live-CD In-Reply-To: <1260137731-23999-1-git-send-email-kevin@tyndur.org> References: <1260137731-23999-1-git-send-email-kevin@tyndur.org> Message-ID: <20091212223851.GB7548@thales.kaufmann.lan> On Sun, Dec 06 23:15, Kevin Wolf wrote: > * build: Die Skripte fuer die Erstellung von CD-ROMs umgestellt, so dass > jetzt ein Festplattenimage auf die CD kopiert wird, das per ramoverlay > auch temporaer beschreibbar ist. > > Signed-off-by: Kevin Wolf Sieht vernünftig aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Sun Dec 13 15:48:50 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 15:48:50 +0100 Subject: [tyndur-devel] [PATCH] Versionsstrings aktualisieren Message-ID: <1260715730-21519-1-git-send-email-kevin@tyndur.org> * config.h: TYNDUR_VERSION auf 0.2.2 erhoehen ! init, shell: $Rev$ durch die tyndur-Versionsnummer ersetzen Signed-off-by: Kevin Wolf --- src/include/lost/config.h | 2 +- src/modules/c/shell/commmands.c | 5 +++-- src/modules/init/init.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/include/lost/config.h b/src/include/lost/config.h index 2975fc6..a4582b4 100644 --- a/src/include/lost/config.h +++ b/src/include/lost/config.h @@ -74,7 +74,7 @@ #define CONFIG_LIBC_NO_STUBS -#define TYNDUR_VERSION "0.2.1" +#define TYNDUR_VERSION "0.2.2" #define TYNDUR_RELEASE "Gothmog" #if CONFIG_ARCH == ARCH_I386 diff --git a/src/modules/c/shell/commmands.c b/src/modules/c/shell/commmands.c index 6c33478..2d0fd7c 100644 --- a/src/modules/c/shell/commmands.c +++ b/src/modules/c/shell/commmands.c @@ -47,6 +47,8 @@ #include #include +#include + //Hier koennen die Debug-Nachrichten aktiviert werden #define DEBUG 0 @@ -217,8 +219,7 @@ int shell_command_help(int argc, char* argv[], const char* args) */ int shell_command_version(int argc, char* argv[], const char* args) { - puts("tyndur Shell v0.2"); - puts("$Rev$"); + puts("tyndur Shell " TYNDUR_VERSION); return 0; } diff --git a/src/modules/init/init.c b/src/modules/init/init.c index 89dafa5..3849701 100644 --- a/src/modules/init/init.c +++ b/src/modules/init/init.c @@ -147,7 +147,7 @@ static void parse_cmdline(void) void _start(dword modules) { - puts("\n\033[1;33mtyndur-Init $Rev$ \033[0;37m\n"); + puts("\n\033[1;33mtyndur-Init " TYNDUR_VERSION " \033[0;37m\n"); init_messaging(); init_memory_manager(); -- 1.6.0.2 From kevin at tyndur.org Sun Dec 13 16:17:03 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 16:17:03 +0100 Subject: [tyndur-devel] [PATCH] Live-CD: Mit geladenem pci bootet es sich schneller Message-ID: <1260717423-12535-1-git-send-email-kevin@tyndur.org> ! Live-CD: pci muss auch noch auf das Floppyimage und beim Booten geladen werden, ansonsten wartet ata auf einen Timeout ! grub_hd.cfg: pci sollte als Startup-Service deklariert sein Signed-off-by: Kevin Wolf --- build/config/grub_cdrom.cfg | 6 ++++-- build/config/grub_hd.cfg | 4 ++-- build/scripts/image_cdrom | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build/config/grub_cdrom.cfg b/build/config/grub_cdrom.cfg index 8949215..e0de5e3 100644 --- a/build/config/grub_cdrom.cfg +++ b/build/config/grub_cdrom.cfg @@ -1,21 +1,23 @@ title tyndur (Deutsch) kernel /tyndur debug=s module /init boot=file:/ +module /pci module /ata module /iso9660 module /ramoverlay module /ext2 module /console servmgr:/term servmgr:/term -module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 +module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci boot title tyndur (English) kernel /tyndur debug=s module /init boot=file:/ env.LANG=en +module /pci module /ata module /iso9660 module /ramoverlay module /ext2 module /console servmgr:/term servmgr:/term -module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 +module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci boot diff --git a/build/config/grub_hd.cfg b/build/config/grub_hd.cfg index 97e88c3..74c2133 100644 --- a/build/config/grub_hd.cfg +++ b/build/config/grub_hd.cfg @@ -5,7 +5,7 @@ module /modules/pci module /modules/ata module /modules/ext2 module /modules/console servmgr:/term servmgr:/term -module /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console +module /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console pci boot title tyndur (English) @@ -15,5 +15,5 @@ module /modules/pci module /modules/ata module /modules/ext2 module /modules/console servmgr:/term servmgr:/term -module /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console +module /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console pci boot diff --git a/build/scripts/image_cdrom b/build/scripts/image_cdrom index 3cfe5c8..23c78f8 100755 --- a/build/scripts/image_cdrom +++ b/build/scripts/image_cdrom @@ -121,7 +121,7 @@ mcopy -D o build/config/grub_cdrom.cfg l:/boot/grub/menu.lst # Die noetigsten Treiber auf das Floppy-Image packen mcopy -D o $ROOT/boot/tyndur $ROOT/modules/init $ROOT/modules/console l:/ mcopy -D o $ROOT/modules/ata $ROOT/modules/iso9660 $ROOT/modules/servmgr l:/ -mcopy -D o $ROOT/modules/ext2 $ROOT/modules/ramoverlay l:/ +mcopy -D o $ROOT/modules/ext2 $ROOT/modules/ramoverlay $ROOT/modules/pci l:/ # Konfigurationsdatei fuer mtools wieder loeschen rm -f $MTOOLSRC -- 1.6.0.2 From toni at tyndur.org Sun Dec 13 18:31:35 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:35 +0100 Subject: [tyndur-devel] Updates und Entfernen fuer lpt Message-ID: <1260725504-9035-1-git-send-email-toni@tyndur.org> Das Aktualisieren und Entfernen von Paketen mit lpt ermöglichen. Dafür wird beim Installieren notiert welche Dateien erstellt wurden, und in den Paketen werden die vollstaendigen Paketinformationen im pkglist- Format gespeichert. From toni at tyndur.org Sun Dec 13 18:31:36 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:36 +0100 Subject: [tyndur-devel] [PATCH 1/9] lpt: Aktuellste und nicht erste Version installieren In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-2-git-send-email-toni@tyndur.org> * lpt: Aktuellste und nicht erste Version im Repo installieren Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/packages.pas | 115 +++++++++++++++++++++++++++++++++++++- 1 files changed, 113 insertions(+), 2 deletions(-) diff --git a/src/modules/pas/lpt/packages.pas b/src/modules/pas/lpt/packages.pas index d5a0218..7cab104 100644 --- a/src/modules/pas/lpt/packages.pas +++ b/src/modules/pas/lpt/packages.pas @@ -60,6 +60,9 @@ type function add(number: String): TPackageVersion; + (** Neuste Version dieser Section suchen. *) + function getCurrentVersion(): TPackageVersion; + public section: String; versions: TCollection; @@ -76,6 +79,20 @@ type procedure addDependency(typ: char; dep: String); procedure copyDependencies(from: TPackageVersion); + (** + * n-ten Teil der Versionsnummer auslesen. Teile, die nicht gesetzt + * sind, werden einfach als -1 zurueckgegeben. + *) + function getVersionPart(n: Integer): Integer; + + (** + * Diese Version mit der angegebenen vergleichen. Ist die angegebene + * neuer wird ein Wert kleiner 0 zurueckgegeben, ist sie aelter, + * wird ein Wert groesser 0 zurueckgegeben. Falls die beiden + * Versionen geleich sind, wird 0 zurueckgegeben. + **) + function compareTo(other: TPackageVersion): integer; + property preinstDependencies: TCollection read instDep; property runDependencies: TCollection read runDep; @@ -124,8 +141,7 @@ begin if pkg.name = pkgname then begin sect := pkg.section[sectname]; if (sect <> nil) and (sect.versions.count > 0) then begin - // TODO Aktuellste Version nehmen - exit(TPackageVersion(sect.versions.items[0])); + exit(sect.getCurrentVersion); end; end; end; @@ -293,6 +309,26 @@ begin exit(version); end; +(** Neuste Version dieser Section suchen. *) +function TPackageSection.getCurrentVersion(): TPackageVersion; +var + cur, other: TPackageVersion; + curVer, i: Integer; +begin + (* Mit erstbester Version anfangen und immer wenn wir eine neuere finden + die als Aktuelle hernehmen. *) + cur := TPackageVersion(versions.items[0]); + for i := 1 to versions.count - 1 do begin + other := TPackageVersion(versions.items[i]); + if cur.compareTo(other) < 0 then begin + cur := other; + end; + end; + + Exit(cur); +end; + + constructor TPackageVersion.create(parent: TCollection); begin inherited; @@ -350,4 +386,79 @@ begin end; end; +(** + * n-ten Teil der Versionsnummer auslesen. Teile, die nicht gesetzt + * sind, werden einfach als -1 zurueckgegeben. + *) +function TPackageVersion.getVersionPart(n: Integer): Integer; +var + part, ver: String; + i, dotpos, num: Integer; +begin + ver := version; + dotpos := 1; + + (* Wir spalten den String Stueck fuer Stueck bei . und - auf und fuellen + ihn in ein Array *) + for i := 1 to n do begin + dotpos := Pos('.', ver); + if dotpos <= 0 then begin + dotpos := Pos('-', ver); + end; + + (* Kein . oder - mehr gefunden, wenn noch ein Stueck uebrig ist, nehmen + wir das noch, sonst sind wir fertig. *) + if (Length(ver) = 0) then begin + Exit(-1); + end else if dotpos <= 0 then begin + dotpos := Length(ver) + 1; + end; + + part := Copy(ver, 1, dotpos - 1); + ver := Copy(ver, dotpos + 1, Length(ver)); + num := StrToInt(part); + end; + + Exit(num); +end; + +(** + * Diese Version mit der angegebenen vergleichen. Ist die angegebene + * neuer wird ein Wert kleiner 0 zurueckgegeben, ist sie aelter, + * wird ein Wert groesser 0 zurueckgegeben. Falls die beiden + * Versionen geleich sind, wird 0 zurueckgegeben. + **) +function TPackageVersion.compareTo(other: TPackageVersion): integer; +var + partA, partB, n: Integer; + aInv, bInv: Boolean; +begin + n := 1; + aInv := false; + bInv := false; + repeat begin + partA := getVersionPart(n); + partB := other.getVersionPart(n); + + (* Wenn eine Versionsnummer kuerzer ist als die andere, hat eine -1 und + die andere noch eine vernuenftige Zahl. Ist diese Zufaelligerweise 0, + muss der Vergleich trotzdem passen, da 0.2 = 0.2.0 *) + if partA = -1 then begin + aInv := true; + partA := 0; + end; + if partB = -1 then begin + bInv := true; + partB := 0; + end; + + if (partA - partB) <> 0 then begin + Exit(partA - partB); + end; + + Inc(n); + end; until aInv and bInv; + Exit(0); +end; + end. -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:37 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:37 +0100 Subject: [tyndur-devel] [PATCH 2/9] lpt: ScanFile in Klasse ausgelagert In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-3-git-send-email-toni@tyndur.org> * lpt: ScanFile in Klasse ausgelagert, damit die Parserfunktion spaeter auch fuer die Paketinformationen benutzt werden kann. Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/helpers.pas | 87 +-------------------- src/modules/pas/lpt/pkglist.pas | 161 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 82 deletions(-) create mode 100644 src/modules/pas/lpt/pkglist.pas diff --git a/src/modules/pas/lpt/helpers.pas b/src/modules/pas/lpt/helpers.pas index b26ff4b..67b02ed 100644 --- a/src/modules/pas/lpt/helpers.pas +++ b/src/modules/pas/lpt/helpers.pas @@ -2,7 +2,8 @@ unit helpers; {$MODE ObjFPC} interface -uses crt, sysutils, dos, classes, tar, packages, tcpip, http, multilang; +uses crt, sysutils, dos, classes, tar, packages, tcpip, http, multilang, + pkglist; procedure ScanFile(pkgset: TPackageSet; filename, repository: String); procedure DrawProgress(http: HTTPRequest); @@ -127,88 +128,10 @@ end; procedure ScanFile(pkgset: TPackageSet; filename, repository: String); var - f: Text; - line: String; - status: integer; - - pkg: TPackage; - section: TPackageSection; - version: TPackageVersion; + plp: TPkglistParser; begin - Assign(f, filename); - Reset(f); - status := 0; - pkg := nil; - try - while not eof(f) do begin - ReadLn(f, line); - - if line = '' then begin - continue; - end; - - case line[1] of - 'P': - begin - status := 1; - pkg := pkgset.add(Copy(line, 3, length(line))); - end; - 'D': - if status = 1 then begin - pkg.desc := Copy(line, 3, length(line)); - end else begin - raise EPackageFileFormat.create( - 'D in status ' + IntToStr(status)); - end; - 'S': - if status >= 1 then begin - status := 2; - section := pkg.add(Copy(line, 3, length(line))); - end else begin - raise EPackageFileFormat.create( - 'S in status ' + IntToStr(status)); - end; - 'V': - if status >= 2 then begin - status := 3; - version := section.add(Copy(line, 3, length(line))); - version.pkg := pkg; - version.section := section; - version.repository := repository; - end else begin - raise EPackageFileFormat.create( - 'V in status ' + IntToStr(status)); - end; - 's': - if status >= 3 then begin - version.size := StrToInt(Copy(line, 3, length(line))); - end else begin - raise EPackageFileFormat.create( - 's in status ' + IntToStr(status)); - end; - 'd': - if status >= 3 then begin - if length(line) < 2 then begin - raise EPackageFileFormat.create( - 'Einsames d'); - end; - - version.addDependency(line[2], Copy(line, 4, length(line))); - - end else begin - raise EPackageFileFormat.create( - 'd in status ' + IntToStr(status)); - end; - else - begin - raise EPackageFileFormat.create( - 'Unbekannter Schluessel: ' + line[1]); - end; - end; - end; - finally - Close(f); - end; + plp := TPkglistParser.create(pkgset); + plp.ProcessFile(filename, repository); end; procedure Untar(tar: TTarArchive; targetpath: String = 'file:/'); diff --git a/src/modules/pas/lpt/pkglist.pas b/src/modules/pas/lpt/pkglist.pas new file mode 100644 index 0000000..996bd9d --- /dev/null +++ b/src/modules/pas/lpt/pkglist.pas @@ -0,0 +1,161 @@ +unit pkglist; +{$MODE ObjFPC} + +interface +uses classes, sysutils, packages; + +type + TPkglistParser = class + private + status: Integer; + package: TPackage; + section: TPackageSection; + version: TPackageVersion; + pkgset: TPackageSet; + + public + (** + * Konstruktor. + * + * @param ps PakageSet in dem die angegebenen Pakete erfasst werden + * sollen. + *) + constructor Create(ps: TPackageSet); + + (** + * Einzelne Zeile der pkglist verarbeiten. + * + * @param line Zeile + * @param repo Repository-Url, die in den Paketen eingetragen werden + * soll. + *) + procedure ProcessLine(line, repo: String); + + (** + * pkglist-Datei verarbeiten + * + * @param path Pfad zur Datei + * @param repo Repository-Url, die in den Paketen eingetragen werden + * soll. + *) + procedure ProcessFile(path, repo: String); + end; + +implementation + +(** + * Konstruktor. + * + * @param ps PakageSet in dem die angegebenen Pakete erfasst werden + * sollen. + *) +constructor TPkglistParser.Create(ps: TPackageSet); +begin + status := 0; + package := nil; + section := nil; + version := nil; + pkgset := ps; +end; + +(** + * Einzelne Zeile der pkglist verarbeiten. + * + * @param line Zeile + * @param repo Repository-Url, die in den Paketen eingetragen werden + * soll. + *) +procedure TPkglistParser.ProcessLine(line, repo: String); +begin + if line = '' then begin + Exit; + end; + + case line[1] of + 'P': + begin + status := 1; + package := pkgset.add(Copy(line, 3, length(line))); + end; + 'D': + if status = 1 then begin + package.desc := Copy(line, 3, length(line)); + end else begin + raise EPackageFileFormat.create( + 'D in status ' + IntToStr(status)); + end; + 'S': + if status >= 1 then begin + status := 2; + section := package.add(Copy(line, 3, length(line))); + end else begin + raise EPackageFileFormat.create( + 'S in status ' + IntToStr(status)); + end; + 'V': + if status >= 2 then begin + status := 3; + version := section.add(Copy(line, 3, length(line))); + version.pkg := package; + version.section := section; + version.repository := repo; + end else begin + raise EPackageFileFormat.create( + 'V in status ' + IntToStr(status)); + end; + 's': + if status >= 3 then begin + version.size := StrToInt(Copy(line, 3, length(line))); + end else begin + raise EPackageFileFormat.create( + 's in status ' + IntToStr(status)); + end; + 'd': + if status >= 3 then begin + if length(line) < 2 then begin + raise EPackageFileFormat.create( + 'Einsames d'); + end; + + version.addDependency(line[2], Copy(line, 4, length(line))); + + end else begin + raise EPackageFileFormat.create( + 'd in status ' + IntToStr(status)); + end; + else + begin + raise EPackageFileFormat.create( + 'Unbekannter Schluessel: ' + line[1]); + end; + end; +end; + + +(** + * pkglist-Datei verarbeiten + * + * @param path Pfad zur Datei + * @param repo Repository-Url, die in den Paketen eingetragen werden + * soll. + *) +procedure TPkglistParser.ProcessFile(path, repo: String); +var + f: Text; + l: String; +begin + Assign(f, path); + Reset(f); + + try + while not Eof(f) do begin + ReadLn(f, l); + ProcessLine(l, repo); + end; + finally + Close(f); + end; +end; + +begin +end. -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:38 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:38 +0100 Subject: [tyndur-devel] [PATCH 3/9] lpt: pkglist-Format fuer Paketinformationen verwenden In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-4-git-send-email-toni@tyndur.org> * lpt: pkglist-Format fuer Paketinformationen verwenden Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/lang/lang_en.c | 4 -- src/modules/pas/lpt/lang/resstr.h | 1 - src/modules/pas/lpt/repository_single.pas | 52 +++++++--------------------- 3 files changed, 13 insertions(+), 44 deletions(-) diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c index 177089f..74d7c1d 100644 --- a/src/modules/pas/lpt/lang/lang_en.c +++ b/src/modules/pas/lpt/lang/lang_en.c @@ -132,10 +132,6 @@ static const struct tms_strings dict[] = { &RESSTR_REPOSITORY_HTTP_RSDOWNLOADINGPKGLIST, "Downloading package list %s from %s", - // Keine (lokale Datei) - &RESSTR_REPOSITORY_SINGLE_RSLOCALPKGDESC, - "None (local file)", - 0, 0, }; diff --git a/src/modules/pas/lpt/lang/resstr.h b/src/modules/pas/lpt/lang/resstr.h index 3ddace7..7b9b3ca 100644 --- a/src/modules/pas/lpt/lang/resstr.h +++ b/src/modules/pas/lpt/lang/resstr.h @@ -52,6 +52,5 @@ extern void* RESSTR_REPOSITORIES_RSUNKNOWNREPOTYPE; extern void* RESSTR_REPOSITORIES_RSINVALIDPKGSRC; extern void* RESSTR_REPOSITORY_BASE_RSNOPACKAGELIST; extern void* RESSTR_REPOSITORY_HTTP_RSDOWNLOADINGPKGLIST; -extern void* RESSTR_REPOSITORY_SINGLE_RSLOCALPKGDESC; #endif diff --git a/src/modules/pas/lpt/repository_single.pas b/src/modules/pas/lpt/repository_single.pas index 8ab1e2b..d1f100c 100644 --- a/src/modules/pas/lpt/repository_single.pas +++ b/src/modules/pas/lpt/repository_single.pas @@ -2,7 +2,7 @@ unit repository_single; {$MODE ObjFPC} interface -uses sysutils, classes, tar, packages, helpers, repository_base; +uses sysutils, classes, tar, packages, helpers, repository_base, pkglist; type TSFRepository = class(TRepository) @@ -16,9 +16,6 @@ type implementation -resourcestring - rsLocalPkgDesc = 'Keine (lokale Datei)'; - constructor TSFRepository.create(parent : TCollection); begin inherited; @@ -49,56 +46,33 @@ var package: TTarArchive; line: String; i: integer; - size: integer; package_file_string: String; - pkg_name, pkg_version, pkg_section, pkg_arch: String; + plp: TPkglistParser; pkg: TPackage; section: TPackageSection; version: TPackageVersion; begin + plp := TPkglistParser.create(pkgset); package := TTarArchive.create(self.url); while package.hasNext do begin line := package.nextFilename; - size := package.nextSize; i := Pos('packageinfo', line); - if i > 0 then begin + if (i > 0) then begin (* Metadaten laden *) package_file_string := package.ExtractString(); - (* Newline-getrennte Infos auslesen. *) - (* In Reihenfolge: Name, Version, Sektion, Architektur *) - i := Pos(#10, package_file_string); - pkg_name := Copy(package_file_string, 1, i - 1); - package_file_string := - Copy(package_file_string, i + 1, Length(package_file_string)); - - i := Pos(#10, package_file_string); - pkg_version := Copy(package_file_string, 1, i - 1); - package_file_string := - Copy(package_file_string, i + 1, Length(package_file_string)); - - i := Pos(#10, package_file_string); - pkg_section := Copy(package_file_string, 1, i - 1); - package_file_string := - Copy(package_file_string, i + 1, Length(package_file_string)); - - i := Pos(#10, package_file_string); - pkg_arch := Copy(package_file_string, 1, i - 1); - package_file_string := - Copy(package_file_string, i + 1, Length(package_file_string)); + while Length(package_file_string) > 0 do begin + i := Pos(#10, package_file_string); + if i <= 0 then begin + i := Length(package_file_string); + end; - (* Prüfen ob Metadaten zu Paket passen *) - if (line = 'packages/'+pkg_name+'/'+pkg_version+'/packageinfo-'+pkg_section) then begin - pkg := pkgset.add(pkg_name); - pkg.desc := rsLocalPkgDesc; - section := pkg.add(pkg_section); - version := section.add(pkg_version); - version.pkg := pkg; - version.section := section; - version.repository := self.name; - break; + line := Copy(package_file_string, 1, i - 1); + plp.ProcessLine(line, self.name); + package_file_string := Copy(package_file_string, i + 1, + Length(package_file_string)); end; end else begin package.skipFile(); -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:39 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:39 +0100 Subject: [tyndur-devel] [PATCH 4/9] lpt: In pkglist-Klasse beim Parsen A-Feld fuer Architektur ignorieren In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-5-git-send-email-toni@tyndur.org> * lpt: In pkglist-Klasse beim Parsen A-Feld fuer Architektur ignorieren und keine Fehlermeldung mehr generieren. Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/pkglist.pas | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/modules/pas/lpt/pkglist.pas b/src/modules/pas/lpt/pkglist.pas index 996bd9d..3bd4188 100644 --- a/src/modules/pas/lpt/pkglist.pas +++ b/src/modules/pas/lpt/pkglist.pas @@ -123,6 +123,9 @@ begin raise EPackageFileFormat.create( 'd in status ' + IntToStr(status)); end; + + 'A': + (* Architektur - ignorieren wir im Moment mal fleissig ;-) *) else begin raise EPackageFileFormat.create( -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:40 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:40 +0100 Subject: [tyndur-devel] [PATCH 5/9] lpt: Hilfsfunktion FindInstalledPackages In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-6-git-send-email-toni@tyndur.org> + lpt: Hilfsfunktion FindInstalledPackages die alle momentan installierten Pakete zusammensucht. Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/helpers.pas | 43 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/src/modules/pas/lpt/helpers.pas b/src/modules/pas/lpt/helpers.pas index 67b02ed..b8b4cee 100644 --- a/src/modules/pas/lpt/helpers.pas +++ b/src/modules/pas/lpt/helpers.pas @@ -16,6 +16,13 @@ procedure Untar(tar: TTarArchive; targetpath: String = 'file:/'); function getArch: String; procedure mkpath(path: string); +(** + * Installierte Pakete im Paketset pkgset eintragen + * + * @param pkgset Set in dem die installierten Pakete eingetragen werden + *) +procedure FindInstalledPackages(pkgset: TPackageSet); + implementation resourcestring @@ -166,5 +173,41 @@ begin Untar(tar, targetpath); end; +(** + * Installierte Pakete im Paketset pkgset eintragen + * + * @param pkgset Set in dem die installierten Pakete eingetragen werden + *) +procedure FindInstalledPackages(pkgset: TPackageSet); +var + prec, vrec, irec: Searchrec; + path, pname, pver, pinfo: String; +begin + DosError := 0; + dos.FindFirst('file:/packages/*', Directory, prec); + while DosError = 0 do begin + pname := 'file:/packages/' + prec.name; + + dos.FindFirst(pname + '/*', Directory, vrec); + while DosError = 0 do begin + pver := pname + '/' + vrec.name; + + dos.FindFirst(pver + '/packageinfo*', Directory, irec); + while DosError = 0 do begin + pinfo := pver + '/' + irec.name; + ScanFile(pkgset, pinfo, ''); + dos.FindNext(irec); + end; + dos.FindClose(irec); + DosError := 0; + dos.FindNext(vrec); + end; + dos.FindClose(vrec); + DosError := 0; + dos.FindNext(prec); + end; + dos.FindClose(prec); +end; + begin end. -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:41 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:41 +0100 Subject: [tyndur-devel] [PATCH 6/9] lpt: Liste mit installierten Dateien anlegen fuer jedes Paket In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-7-git-send-email-toni@tyndur.org> * lpt: Untar so modifiziert, dass es eine Liste als Parameter nimmt, in der es die Pfade zu entpackten Dateien eintraegt. + lpt: Liste mit installierten Dateien anlegen fuer jedes Paket Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/helpers.pas | 55 ++++++++++++++++++++++++++++++++++----- src/modules/pas/lpt/lpt.pas | 28 +++++++++++++++++++- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/modules/pas/lpt/helpers.pas b/src/modules/pas/lpt/helpers.pas index b8b4cee..e58a3a0 100644 --- a/src/modules/pas/lpt/helpers.pas +++ b/src/modules/pas/lpt/helpers.pas @@ -11,8 +11,26 @@ function StartDownload(url: String): HTTPRequest; function DownloadToFile(url, filename: String): boolean; function DownloadToTarArchive(url: String): TTarArchive; function getConfigRoot: String; -procedure Untar(tarfile: String; targetpath: String = 'file:/'); -procedure Untar(tar: TTarArchive; targetpath: String = 'file:/'); + +(** + * Tar-Archiv entpacken. + * + * @param tar Das zu entpackende Archiv + * @param filelist Liste in die die Pfade der erstellten Dateien und + * Verzeichnisse eingetragen werden sollen, wenn nicht nil. + * @param targetpath Pfad wohin das Archiv entpackt werden soll. + *) +procedure Untar(tar: TTarArchive; filelist: TStrings = nil; + targetpath: String = 'file:/'); + +(** + * Tar-Archiv entpacken. + * + * @see Untar + *) +procedure Untar(tarfile: String; filelist: TStrings = nil; + targetpath: String = 'file:/'); + function getArch: String; procedure mkpath(path: string); @@ -83,6 +101,7 @@ var httpc: HTTPRequest; begin httpc := HTTPRequest.create(url); + httpc.setRequestHeader('Pragma', 'no-cache'); httpc.setRequestHeader('Cache-Control', 'no-cache'); WriteLn(Format(rsDownloading, [url])); @@ -141,36 +160,58 @@ begin plp.ProcessFile(filename, repository); end; -procedure Untar(tar: TTarArchive; targetpath: String = 'file:/'); +(** + * Tar-Archiv entpacken. + * + * @param tar Das zu entpackende Archiv + * @param filelist Liste in die die Pfade der erstellten Dateien und + * Verzeichnisse eingetragen werden sollen, wenn nicht nil. + * @param targetpath Pfad wohin das Archiv entpackt werden soll. + *) +procedure Untar(tar: TTarArchive; filelist: TStrings = nil; + targetpath: String = 'file:/'); var path: String; dir, filename, ext: String; + target: String; f: file; begin while tar.hasNext do begin path := tar.NextFilename; - dos.FSplit(path, dir, filename, ext); + target := targetpath + '/' + path; + dos.FSplit(path, dir, filename, ext); mkpath(targetpath + '/' + dir); if tar.NextFiletype = TAR_TYPE_FILE then begin - Assign(f, targetpath + '/' + path); + Assign(f, target); Rewrite(f, 1); tar.ExtractFile(f); Close(f); + + (* In Dateiliste eingtragen falls gewuenscht *) + if filelist <> nil then begin + filelist.add(target); + end; end else begin tar.SkipFile; end; end; end; -procedure Untar(tarfile: String; targetpath: String = 'file:/'); +(** + * Tar-Archiv entpacken. + * + * @see Untar + *) +procedure Untar(tarfile: String; filelist: TStrings = nil; + targetpath: String = 'file:/'); var tar: TTarArchive; begin tar := TTarArchive.create(tarfile); - Untar(tar, targetpath); + Untar(tar, filelist, targetpath); end; (** diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas index d4d1630..5fda323 100644 --- a/src/modules/pas/lpt/lpt.pas +++ b/src/modules/pas/lpt/lpt.pas @@ -110,13 +110,37 @@ begin end; procedure Get(pkgname: String; reinstall: boolean); + (** + * Liste mit beim Installieren des Pakets angelegten Dateien speichern, + * sodass das Paket spaeter einfach wieder weggeworfen werden kann. + * + * @param version Version, die installiert wurde + * @param filenames Liste mit den erstellten Dateien und Verzeichnissen + *) + procedure saveFilelist(version: TPackageVersion; filenames: TStrings); + var + filename: String; + f: Text; + i: Integer; + begin + filename := 'file:/packages/' + version.pkg.name + '/' + + version.version + '/pkgcontent-' + version.section.section; + Assign(f, filename); + Rewrite(f); + for i := 0 to filenames.count - 1 do begin + WriteLn(f, filenames[i]); + end; + + Close(f); + end; function Install(version: TPackageVersion; reinstall: boolean): boolean; var filename: String; repos: TRepository; installarchive: TTarArchive; + filenames: TStringList; begin Install := false; @@ -142,7 +166,9 @@ procedure Get(pkgname: String; reinstall: boolean); TextColor(7); installarchive := repos.Download(version); if installarchive <> nil then begin - Untar(installarchive); + filenames := TStringList.create; + Untar(installarchive, filenames); + saveFilelist(version, filenames); end; filename := 'file:/packages/' + version.pkg.name + '/' + -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:42 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:42 +0100 Subject: [tyndur-devel] [PATCH 7/9] lpt: Pakete deinstallieren In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-8-git-send-email-toni@tyndur.org> + lpt: Pakete deinstallieren Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/lang/lang_en.c | 15 ++++- src/modules/pas/lpt/lang/resstr.h | 3 + src/modules/pas/lpt/lpt.pas | 151 +++++++++++++++++++++++++++++++++++- 3 files changed, 167 insertions(+), 2 deletions(-) diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c index 74d7c1d..dd3b228 100644 --- a/src/modules/pas/lpt/lang/lang_en.c +++ b/src/modules/pas/lpt/lang/lang_en.c @@ -62,7 +62,8 @@ static const struct tms_strings dict[] = { " list: List all available packages\n" " get: Install a package\n" " install: Install a package from a local file\n" - " (speficy file name as last parameter)", + " (speficy file name as last parameter)\n" + " remove: Remove a package", // Herunterladen und Entpacken von %s &RESSTR_P$LPT_RSDOWNLOADANDEXTRACT, @@ -76,6 +77,10 @@ static const struct tms_strings dict[] = { &RESSTR_P$LPT_RSCONFIGURING, "Configuring %s", + // Entferne %s + &RESSTR_P$LPT_RSREMOVING, + "Removing %s", + // Fehler: &RESSTR_P$LPT_RSERROR, "Error:", @@ -92,6 +97,10 @@ static const struct tms_strings dict[] = { &RESSTR_P$LPT_RSALREADYINSTALLED, "Package is already installed:", + // Paket ist nicht installiert + &RESSTR_P$LPT_RSNOTINSTALLED, + "Package is not installed", + // Kann die Paketlisten nicht einlesen: &RESSTR_P$LPT_RSCANNOTREADPKGLISTS, "Cannot read package lists:", @@ -112,6 +121,10 @@ static const struct tms_strings dict[] = { &RESSTR_P$LPT_RSINVALIDACTION, "Invalid action:", + // Kann Paket nicht deinstallieren, da die pkgcontent-Datei fehlt. + &RESSTR_P$LPT_RSNOPKGCONTENTFILE, + "Could not remove package, pkgcontent file is missing.", + // Paket %s fehlt &RESSTR_PACKAGES_RSPACKAGEMISSING, "Package %s is not available", diff --git a/src/modules/pas/lpt/lang/resstr.h b/src/modules/pas/lpt/lang/resstr.h index 7b9b3ca..10f95e7 100644 --- a/src/modules/pas/lpt/lang/resstr.h +++ b/src/modules/pas/lpt/lang/resstr.h @@ -38,15 +38,18 @@ extern void* RESSTR_P$LPT_RSUSAGE; extern void* RESSTR_P$LPT_RSDOWNLOADANDEXTRACT; extern void* RESSTR_P$LPT_RSSEARCHING; extern void* RESSTR_P$LPT_RSCONFIGURING; +extern void* RESSTR_P$LPT_RSREMOVING; extern void* RESSTR_P$LPT_RSERROR; extern void* RESSTR_P$LPT_RSCANTLOADREPOLIST; extern void* RESSTR_P$LPT_RSFAILDOWNLOADREPOLIST; extern void* RESSTR_P$LPT_RSALREADYINSTALLED; +extern void* RESSTR_P$LPT_RSNOTINSTALLED; extern void* RESSTR_P$LPT_RSCANNOTREADPKGLISTS; extern void* RESSTR_P$LPT_RSCANNOTFINDPACKAGE; extern void* RESSTR_P$LPT_RSCANNOTRESOLVEDEP; extern void* RESSTR_P$LPT_RSWRONGPARAMCOUNT; extern void* RESSTR_P$LPT_RSINVALIDACTION; +extern void* RESSTR_P$LPT_RSNOPKGCONTENTFILE; extern void* RESSTR_PACKAGES_RSPACKAGEMISSING; extern void* RESSTR_REPOSITORIES_RSUNKNOWNREPOTYPE; extern void* RESSTR_REPOSITORIES_RSINVALIDPKGSRC; diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas index 5fda323..cef2d56 100644 --- a/src/modules/pas/lpt/lpt.pas +++ b/src/modules/pas/lpt/lpt.pas @@ -12,21 +12,27 @@ resourcestring ' list: Zeigt alle verfügbaren Pakete an'#10 + ' get: Installiert das angegebene Paket'#10 + ' install: Installiert das angegebene Paket aus lokaler Datei'#10 + - ' Achtung, Datei als letzten Parameter angeben!'; + ' Achtung, Datei als letzten Parameter angeben!'#10 + + ' remove: Paket deinstallieren'; + rsDownloadAndExtract = 'Herunterladen und Entpacken von %s'; rsSearching = 'Suche %s'; rsConfiguring = 'Richte %s ein'; + rsRemoving = 'Entferne %s'; rsError = 'Fehler:'; rsCantLoadRepoList = 'Kann Repository-Liste nicht laden:'; rsFailDownloadRepoList = 'Download der Paketliste für %s fehlgeschlagen:'; rsAlreadyInstalled = 'Paket ist bereits installiert:'; + rsNotInstalled = 'Paket ist nicht installiert'; rsCannotReadPkglists = 'Kann die Paketlisten nicht einlesen:'; rsCannotFindPackage = 'Konnte keine Version von %s finden'; rsCannotResolveDep = 'Konnte die Abhängigkeiten des Pakets nicht auflösen:'; rsWrongParamCount = 'Falsche Parameterzahl'; rsInvalidAction = 'Ungütige Aktion:'; + rsNoPkgcontentFile = 'Kann Paket nicht deinstallieren, da die pkgcontent-' + + 'Datei fehlt.'; procedure PrintUsage; @@ -312,6 +318,142 @@ begin end; end; +(** + * Bestimmte Version eines Pakets deinstallieren + * + * @param version Zu deinstalliernde Version + * + * @return True bei Erfolg, False sonst + *) +function RemoveVersion(version: TPackageVersion): Boolean; + + (** + * Pre-Remove-Skript der angegebenen Version ausfuehren ausfuehren + *) + procedure ExecutePreremoveScript(version: TPackageVersion); + var + filename: String; + begin + filename := 'file:/packages/' + version.pkg.name + '/' + + version.version + '/preremove-' + version.section.section; + + WriteLn(Format(rsSearching, [filename])); + if FileExists(filename) then begin + exec(filename, ''); + end; + end; + + (** + * Die angegebene Datei/das angegebene Verzeichnis loeschen, und falls das + * Elternverzeichnis dadurch leer wird, dieses auch entfernen. + * + * @param path Zu loeschender Pfad + * + * @result True wenn die Datei erfolgreich geloescht wurde, false sonst. + *) + function RemoveWithParent(path: String): Boolean; + var + f: Text; + dir, fn, ext: String; + rec: Searchrec; + begin + if not DeleteFile(path) then begin + Exit(False); + end; + + (* Wenn das Verzeichnis leer ist, machen wir rekursiv weiter *) + dos.FSplit(path, dir, fn, ext); + DosError := 0; + dos.FindFirst(dir + '/*', 0, rec); + while DosError = 0 do begin + if (rec.name <> '.') and (rec.name <> '..') then begin + dos.FindClose(rec); + Exit(True); + end; + dos.FindNext(rec); + end; + dos.FindClose(rec); + + RemoveWithParent(Copy(dir, 1, Length(dir) - 1)); + Exit(True); + end; + + (** + * Alle installierten Dateien dieser Version entfernen + * + * @param version Zu entfernende Version + *) + procedure RemoveVersionFiles(version: TPackageVersion); + var + filename: String; + contents: Text; + path: String; + begin + filename := 'file:/packages/' + version.pkg.name + '/' + version.version + + '/pkgcontent-' + version.section.section; + + Assign(contents, filename); + Reset(contents); + if IOResult <> 0 then begin + WriteLn(rsNoPkgcontentFile); + Exit; + end; + + repeat + ReadLn(contents, path); + RemoveWithParent(path); + until Eof(contents); + + Close(contents); + + (* Die Paketliste koennen wir erst loeschen wenn sie geschlossen ist *) + RemoveWithParent(filename); + end; + +begin + WriteLn(Format(rsRemoving, [version.pkg.name + '-' + version.version + '/' + + version.section.section])); + + ExecutePreremoveScript(version); + RemoveVersionFiles(version); + Exit(True); +end; + +(** + * Paket entfernen + * + * @param pkgname Name des zu entfernenden Pakets + *) +procedure Remove(pkgname: String); +var + installed: TPackageSet; + version: TPackageVersion; + section: String; + i: Integer; +begin + installed := TPackageSet.create; + FindInstalledPackages(installed); + + // Parameter hat die Form Paketname/Section. Wenn keine Section angegeben + // ist, wird bin als Default benutzt. + // FIXME: Hier will man wohl auch die Version angeben koennen + i := Pos('/', pkgname); + if i > 0 then begin + section := Copy(pkgname, i + 1, Length(pkgname)); + pkgname := Copy(pkgname, 1, i - 1); + end else begin + section := 'bin'; + end; + + version := installed.GetCurrentVersion(pkgname, section); + if version = nil then begin + WriteLn(rsNotInstalled); + Exit; + end; + + RemoveVersion(version); +end; + function c_lostio_create_link(target, link: PChar; hard: boolean): integer; cdecl; external name 'io_create_link'; procedure CfgAddbin(path, pubname: String); @@ -404,6 +546,13 @@ begin WriteLn(rsWrongParamCount); PrintUsage; end; + end else if system.ParamStr(1) = 'remove' then begin + if system.ParamCount = 2 then begin + Remove(system.ParamStr(2)); + end else begin + WriteLn(rsWrongParamCount); + PrintUsage; + end; end else if system.ParamStr(1) = 'cfg-addbin' then begin if system.ParamCount = 3 then begin CfgAddbin(system.ParamStr(2), system.ParamStr(3)); -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:43 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:43 +0100 Subject: [tyndur-devel] [PATCH 8/9] lpt: Alle Pakete Updaten (lpt upgrade-all) In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-9-git-send-email-toni@tyndur.org> + lpt: Alle Pakete Updaten (lpt upgrade-all) Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/lang/lang_en.c | 15 ++++++- src/modules/pas/lpt/lang/resstr.h | 3 + src/modules/pas/lpt/lpt.pas | 90 +++++++++++++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 3 deletions(-) diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c index dd3b228..3c45acf 100644 --- a/src/modules/pas/lpt/lang/lang_en.c +++ b/src/modules/pas/lpt/lang/lang_en.c @@ -63,7 +63,8 @@ static const struct tms_strings dict[] = { " get: Install a package\n" " install: Install a package from a local file\n" " (speficy file name as last parameter)\n" - " remove: Remove a package", + " remove: Remove a package\n" + " upgrade-all: Upgrade all installed packages", // Herunterladen und Entpacken von %s &RESSTR_P$LPT_RSDOWNLOADANDEXTRACT, @@ -81,6 +82,14 @@ static const struct tms_strings dict[] = { &RESSTR_P$LPT_RSREMOVING, "Removing %s", + // Folgende Pakete werden aktualisiert: + &RESSTR_P$LPT_RSPACKAGESTOUPGRADE, + "The following packages will be upgraded:", + + // Aenderungen uebernehmen? (j/N) + &RESSTR_P$LPT_RSAPPLYCHANGESYESNO, + "Apply changes? (y/N)", + // Fehler: &RESSTR_P$LPT_RSERROR, "Error:", @@ -125,6 +134,10 @@ static const struct tms_strings dict[] = { &RESSTR_P$LPT_RSNOPKGCONTENTFILE, "Could not remove package, pkgcontent file is missing.", + // Keine Aktualisierungen verfuegbar + &RESSTR_P$LPT_RSNOUPDATESAVAILABLE, + "No updates available", + // Paket %s fehlt &RESSTR_PACKAGES_RSPACKAGEMISSING, "Package %s is not available", diff --git a/src/modules/pas/lpt/lang/resstr.h b/src/modules/pas/lpt/lang/resstr.h index 10f95e7..296a381 100644 --- a/src/modules/pas/lpt/lang/resstr.h +++ b/src/modules/pas/lpt/lang/resstr.h @@ -39,6 +39,8 @@ extern void* RESSTR_P$LPT_RSDOWNLOADANDEXTRACT; extern void* RESSTR_P$LPT_RSSEARCHING; extern void* RESSTR_P$LPT_RSCONFIGURING; extern void* RESSTR_P$LPT_RSREMOVING; +extern void* RESSTR_P$LPT_RSPACKAGESTOUPGRADE; +extern void* RESSTR_P$LPT_RSAPPLYCHANGESYESNO; extern void* RESSTR_P$LPT_RSERROR; extern void* RESSTR_P$LPT_RSCANTLOADREPOLIST; extern void* RESSTR_P$LPT_RSFAILDOWNLOADREPOLIST; @@ -50,6 +52,7 @@ extern void* RESSTR_P$LPT_RSCANNOTRESOLVEDEP; extern void* RESSTR_P$LPT_RSWRONGPARAMCOUNT; extern void* RESSTR_P$LPT_RSINVALIDACTION; extern void* RESSTR_P$LPT_RSNOPKGCONTENTFILE; +extern void* RESSTR_P$LPT_RSNOUPDATESAVAILABLE; extern void* RESSTR_PACKAGES_RSPACKAGEMISSING; extern void* RESSTR_REPOSITORIES_RSUNKNOWNREPOTYPE; extern void* RESSTR_REPOSITORIES_RSINVALIDPKGSRC; diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas index cef2d56..97da589 100644 --- a/src/modules/pas/lpt/lpt.pas +++ b/src/modules/pas/lpt/lpt.pas @@ -13,13 +13,15 @@ resourcestring ' get: Installiert das angegebene Paket'#10 + ' install: Installiert das angegebene Paket aus lokaler Datei'#10 + ' Achtung, Datei als letzten Parameter angeben!'#10 + - ' remove: Paket deinstallieren'; - + ' remove: Paket deinstallieren'#10 + + ' upgrade-all: Alle installierten Pakete aktualisieren'; rsDownloadAndExtract = 'Herunterladen und Entpacken von %s'; rsSearching = 'Suche %s'; rsConfiguring = 'Richte %s ein'; rsRemoving = 'Entferne %s'; + rsPackagesToUpgrade = 'Folgende Pakete werden aktualisiert:'; + rsApplyChangesYesNo = 'Änderungen übernehmen? (j/N)'; rsError = 'Fehler:'; rsCantLoadRepoList = 'Kann Repository-Liste nicht laden:'; @@ -33,6 +35,7 @@ resourcestring rsInvalidAction = 'Ungütige Aktion:'; rsNoPkgcontentFile = 'Kann Paket nicht deinstallieren, da die pkgcontent-' + 'Datei fehlt.'; + rsNoUpdatesAvailable = 'Keine Aktualisierungen verfügbar'; procedure PrintUsage; @@ -454,6 +457,82 @@ begin RemoveVersion(version); end; +(** + * Alle installierten Pakete aktualisieren + *) +procedure UpgradeAll; +var + pkgset, installed, toInstall, toRemove: TPackageSet; + pkg: TPackage; + sect: TPackageSection; + verInst, verRepo: TPackageVersion; + + i, j: Integer; + answer: Char; +begin + pkgset := TPackageSet.create; + installed := TPackageSet.create; + toInstall := TPackageSet.create; + toRemove := TPackageSet.create; + + FindInstalledPackages(installed); + ReadPkgsrc(getConfigRoot + 'pkgsrc'); + ReadPkglists(pkgset); + + + (* Pakete zum Aktualisieren finden *) + WriteLn(rsPackagesToUpgrade); + for i := 0 to installed.packages.count - 1 do begin + pkg := TPackage(installed.packages.items[i]); + for j := 0 to pkg.sections.count - 1 do begin + sect := TPackageSection(pkg.sections.items[j]); + verInst := installed.GetCurrentVersion(pkg.name, sect.section); + verRepo := pkgset.GetCurrentVersion(pkg.name, sect.section); + + (* Das Paket ist nicht im Repo oder nicht installiert *) + if (verInst = nil) or (verRepo = nil) then begin + continue; + end; + + (* Wenn die Version im Repo neuer ist als unsere Lokale koennen wir + updaten *) + if verInst.compareTo(verRepo) < 0 then begin + WriteLn(' ' + pkg.name + ': ' + verInst.version + '=>' + + verRepo.version); + toInstall.addVersion(verRepo); + toRemove.addVersion(verInst); + end; + end; + end; + + if toInstall.packages.count < 1 then begin + WriteLn(' ', rsNoUpdatesAvailable); + Exit; + end; + + WriteLn(rsApplyChangesYesNo); + Read(answer); + if (answer <> 'j') and (answer <> 'J') and (answer <> 'y') and + (answer <> 'Y') then + begin + Exit; + end; + + (* Alte Versionen deinstallieren *) + for i := 0 to toRemove.packages.count - 1 do begin + pkg := TPackage(toRemove.packages.items[i]); + sect := TPackageSection(pkg.sections.items[0]); + verInst := TPackageVersion(sect.versions.items[0]); + RemoveVersion(verInst); + end; + + (* Neue Versionen installieren *) + for i := 0 to toInstall.packages.count - 1 do begin + pkg := TPackage(toInstall.packages.items[i]); + Get(pkg.name, false); + end; +end; + function c_lostio_create_link(target, link: PChar; hard: boolean): integer; cdecl; external name 'io_create_link'; procedure CfgAddbin(path, pubname: String); @@ -553,6 +632,13 @@ begin WriteLn(rsWrongParamCount); PrintUsage; end; + end else if system.ParamStr(1) = 'upgrade-all' then begin + if system.ParamCount = 1 then begin + UpgradeAll; + end else begin + WriteLn('Falsche Parameterzahl'); + PrintUsage; + end; end else if system.ParamStr(1) = 'cfg-addbin' then begin if system.ParamCount = 3 then begin CfgAddbin(system.ParamStr(2), system.ParamStr(3)); -- 1.6.3.3 From toni at tyndur.org Sun Dec 13 18:31:44 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 18:31:44 +0100 Subject: [tyndur-devel] [PATCH 9/9] lpt: upgrade um ein einzelnes Paket zu aktualisieren In-Reply-To: <1260725504-9035-1-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> Message-ID: <1260725504-9035-10-git-send-email-toni@tyndur.org> + lpt: upgrade um ein einzelnes Paket zu aktualisieren Signed-off-by: Antoine Kaufmann --- src/modules/pas/lpt/lang/lang_en.c | 1 + src/modules/pas/lpt/lpt.pas | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 0 deletions(-) diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c index 3c45acf..684aa87 100644 --- a/src/modules/pas/lpt/lang/lang_en.c +++ b/src/modules/pas/lpt/lang/lang_en.c @@ -64,6 +64,7 @@ static const struct tms_strings dict[] = { " install: Install a package from a local file\n" " (speficy file name as last parameter)\n" " remove: Remove a package\n" + " upgrade: Upgrade the specified package\n" " upgrade-all: Upgrade all installed packages", // Herunterladen und Entpacken von %s diff --git a/src/modules/pas/lpt/lpt.pas b/src/modules/pas/lpt/lpt.pas index 97da589..43cfe19 100644 --- a/src/modules/pas/lpt/lpt.pas +++ b/src/modules/pas/lpt/lpt.pas @@ -14,6 +14,7 @@ resourcestring ' install: Installiert das angegebene Paket aus lokaler Datei'#10 + ' Achtung, Datei als letzten Parameter angeben!'#10 + ' remove: Paket deinstallieren'#10 + + ' upgrade: Das angegebene Paket aktualisieren'#10 + ' upgrade-all: Alle installierten Pakete aktualisieren'; rsDownloadAndExtract = 'Herunterladen und Entpacken von %s'; @@ -458,6 +459,55 @@ begin end; (** + * Paket aktualisieren (nur neuste Version) + * + * @param name Paketname + *) +procedure Upgrade(name: String); +var + pkgset, installed: TPackageSet; + pkg: TPackage; + ver: TPackageVersion; + verRepo: TPackageVersion; + i: Integer; + sectname: String; + +begin + pkgset := TPackageSet.create; + installed := TPackageSet.create; + + FindInstalledPackages(installed); + ReadPkgsrc(getConfigRoot + 'pkgsrc'); + ReadPkglists(pkgset); + + (* Section aus dem Paketnamen extrahieren, falls angegeben *) + sectname := 'bin'; + i := Pos(name, '/'); + if i > 0 then begin + sectname := Copy(name, i + 1, Length(name)); + sectname := Copy(name, 1, i - 1); + end; + + ver := installed.GetCurrentVersion(name, sectname); + if ver = nil then begin + WriteLn(rsNotInstalled); + Exit; + end; + + verRepo := pkgset.GetCurrentVersion(name, sectname); + + (* Wenn die Version im Repo aelter oder gleich alt wie unsere ist, brauchen + wir nichts zu tun. *) + if (ver = nil) or (ver.compareTo(verRepo) >= 0) then begin + WriteLn(rsNoUpdatesAvailable); + Exit; + end; + + RemoveVersion(ver); + Get(name, false); +end; + +(** * Alle installierten Pakete aktualisieren *) procedure UpgradeAll; @@ -632,6 +682,13 @@ begin WriteLn(rsWrongParamCount); PrintUsage; end; + end else if system.ParamStr(1) = 'upgrade' then begin + if system.ParamCount = 2 then begin + Upgrade(system.ParamStr(2)); + end else begin + WriteLn(rsWrongParamCount); + PrintUsage; + end; end else if system.ParamStr(1) = 'upgrade-all' then begin if system.ParamCount = 1 then begin UpgradeAll; -- 1.6.3.3 From kevin at tyndur.org Sun Dec 13 20:07:23 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:23 +0100 Subject: [PATCH 0/5] Unser Boot wird schöner Message-ID: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Mit dieser Serie werden Meldungen von Service auch nach dem Laden von servmgr noch angezeigt. Dabei fallen ein paar unschoene Kleinigkeiten auf, die gleich auch noch behoben werden. Kevin Wolf (5): kbc: Antwort der Tastatur auslesen init: stdout zeilenpuffern file: Neue Ausgabe bei Mounts ext2: Debugmeldung entfernen servmgr/vterm: Mehr Bootmeldungen anzeigen src/modules/cdi/ext2/init.c | 1 - src/modules/file/server.c | 6 ++---- src/modules/init/init.c | 1 + src/modules/kbc/keyboard.c | 1 + src/modules/servmgr/rpcif.c | 11 +++++++++++ src/modules/servmgr/servio.c | 40 ++++++++++++++++++++++++---------------- src/modules/servmgr/servmgr.h | 11 +++++++++++ src/modules/vterm/vterm.c | 25 ++++++++++++++++++++++--- 8 files changed, 72 insertions(+), 24 deletions(-) From kevin at tyndur.org Sun Dec 13 20:07:24 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:24 +0100 Subject: [tyndur-devel] [PATCH 1/5] kbc: Antwort der Tastatur auslesen In-Reply-To: <1260731248-16477-1-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Message-ID: <1260731248-16477-2-git-send-email-kevin@tyndur.org> ! kbc: Nachdem man einen Befehl gesendet hat, muss man auch die Antwort der Tastatur auslesen (normal 0xfa fuer Ack). Ansonsten wundert sich der Treiber spaeter ueber komische Scancodes. Signed-off-by: Kevin Wolf --- src/modules/kbc/keyboard.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/modules/kbc/keyboard.c b/src/modules/kbc/keyboard.c index 26b65d3..71cb82b 100644 --- a/src/modules/kbc/keyboard.c +++ b/src/modules/kbc/keyboard.c @@ -86,6 +86,7 @@ static void send_kbd_command(uint8_t command) yield(); } outb(0x60, command); + while (inb(0x60) != 0xfa); } -- 1.6.0.2 From kevin at tyndur.org Sun Dec 13 20:07:25 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:25 +0100 Subject: [tyndur-devel] [PATCH 2/5] init: stdout zeilenpuffern In-Reply-To: <1260731248-16477-1-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Message-ID: <1260731248-16477-3-git-send-email-kevin@tyndur.org> ! init: Wenn stdout neu geoeffnet wird, um die Meldungen an servmgr zu schicken, ist es erst einmal blockgepuffert. Deswegen bleiben Meldungen immer mal wieder stecken und kommen nie auf vterm8 an. Zeilenpuffern hilft. Signed-off-by: Kevin Wolf --- src/modules/init/init.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/modules/init/init.c b/src/modules/init/init.c index 3849701..475d602 100644 --- a/src/modules/init/init.c +++ b/src/modules/init/init.c @@ -341,6 +341,7 @@ void rpc_reopen_stdio(pid_t pid, dword cid, size_t size, void* data) } stdout = fopen("servmgr:/term", "w"); + setlinebuf(stdout); } -- 1.6.0.2 From kevin at tyndur.org Sun Dec 13 20:07:26 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:26 +0100 Subject: [tyndur-devel] [PATCH 3/5] file: Neue Ausgabe bei Mounts In-Reply-To: <1260731248-16477-1-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Message-ID: <1260731248-16477-4-git-send-email-kevin@tyndur.org> * file: Anstatt alle aktiven Mounts zu dumpen, wenn einer dazu kommt, eine schoener formatierte Nachricht nur fuer den neu dazugekommenen Mount ausgeben. Signed-off-by: Kevin Wolf --- src/modules/file/server.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/file/server.c b/src/modules/file/server.c index 2b1e728..01da1a3 100644 --- a/src/modules/file/server.c +++ b/src/modules/file/server.c @@ -141,9 +141,7 @@ static void rpc_mount(pid_t pid, dword cid, size_t data_size, void* data) src += 5; src_size -= 5; -#ifdef DEBUG - printf("file: MOUNT %s => %s\n", src, dst); -#endif + printf("[ FILE ] file:%s => %s\n", src, dst); struct mount* mount = malloc(sizeof(*mount)); mount->src_len = src_size; @@ -165,10 +163,10 @@ static void rpc_mount(pid_t pid, dword cid, size_t data_size, void* data) #ifdef DEBUG printf("Dump mounts:\n"); -#endif for (i = 0; (item = list_get_element_at(mounts, i)); i++) { printf("%s => %s\n", item->src, item->dst); } +#endif } int server(void) -- 1.6.0.2 From kevin at tyndur.org Sun Dec 13 20:07:27 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:27 +0100 Subject: [tyndur-devel] [PATCH 4/5] ext2: Debugmeldung entfernen In-Reply-To: <1260731248-16477-1-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Message-ID: <1260731248-16477-5-git-send-email-kevin@tyndur.org> - ext2: "mounted"-Meldung entfernt Signed-off-by: Kevin Wolf --- src/modules/cdi/ext2/init.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/src/modules/cdi/ext2/init.c b/src/modules/cdi/ext2/init.c index aadb497..d20f647 100644 --- a/src/modules/cdi/ext2/init.c +++ b/src/modules/cdi/ext2/init.c @@ -86,7 +86,6 @@ int ext2_fs_init(struct cdi_fs_filesystem* cdi_fs) root_res->res.dir = &ext2_fs_dir; cdi_fs->root_res = (struct cdi_fs_res*) root_res; - puts("mounted"); return 1; } -- 1.6.0.2 From kevin at tyndur.org Sun Dec 13 20:07:28 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 20:07:28 +0100 Subject: [tyndur-devel] [PATCH 5/5] servmgr/vterm: Mehr Bootmeldungen anzeigen In-Reply-To: <1260731248-16477-1-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> Message-ID: <1260731248-16477-6-git-send-email-kevin@tyndur.org> + vterm: RPC an servmgr schicken, sobald vterm geladen ist * servmgr: Solange vterm noch nicht da ist, werden Meldungen auch auf der Kernelkonsole ausgegeben Signed-off-by: Kevin Wolf --- src/modules/servmgr/rpcif.c | 11 +++++++++++ src/modules/servmgr/servio.c | 40 ++++++++++++++++++++++++---------------- src/modules/servmgr/servmgr.h | 11 +++++++++++ src/modules/vterm/vterm.c | 25 ++++++++++++++++++++++--- 4 files changed, 68 insertions(+), 19 deletions(-) diff --git a/src/modules/servmgr/rpcif.c b/src/modules/servmgr/rpcif.c index fae72cd..013eabd 100644 --- a/src/modules/servmgr/rpcif.c +++ b/src/modules/servmgr/rpcif.c @@ -40,11 +40,13 @@ #include "servmgr.h" static void rpc_needserv(pid_t pid, dword cid, size_t data_size, void* data); +static void rpc_vterm(pid_t pid, dword cid, size_t data_size, void* data); void rpcif_init() { register_message_handler("NEEDSERV", rpc_needserv); + register_message_handler("VTERM ", rpc_vterm); init_service_register("servmgr"); } @@ -74,3 +76,12 @@ static void rpc_needserv(pid_t pid, dword cid, size_t data_size, void* data) rpc_send_dword_response(pid, cid, result); } +/** + * RPC um mitzuteilen, dass vterm jetzt da ist + */ +static void rpc_vterm(pid_t pid, dword cid, size_t data_size, void* data) +{ + service_io_stop_kputsn(); + rpc_send_dword_response(pid, cid, 0); + service_io_flush(); +} diff --git a/src/modules/servmgr/servio.c b/src/modules/servmgr/servio.c index 27156ec..5537002 100644 --- a/src/modules/servmgr/servio.c +++ b/src/modules/servmgr/servio.c @@ -41,7 +41,7 @@ #include "servmgr.h" -#define FLUSH_DELAY 5 +#define FLUSH_DELAY 1 /// Pfad zum Ausgabeterminal @@ -56,11 +56,8 @@ static char* out_buffer = NULL; /// Anzahl der Zeichen im Ausgabepuffer static size_t out_buffer_pos = 0; - -/** - * IO-Puffer flushen - */ -static void service_io_flush(void); +/// Ausgaben auf Kernelkonsole kopieren? +static int use_kputsn = 1; /** @@ -68,7 +65,6 @@ static void service_io_flush(void); */ void service_io_init(void) { - timer_register(service_io_flush, 1000000 * FLUSH_DELAY); send_message(1, RPC_MESSAGE, 0, 8, "UP_STDIO"); } @@ -90,6 +86,12 @@ void service_io_write(const char* buf, size_t size) out_buffer = realloc(out_buffer, out_buffer_pos + size); memcpy(out_buffer + out_buffer_pos, buf, size); out_buffer_pos += size; + + // Solange vterm noch nicht da ist, geben wir es auch noch ueber den + // Kernel aus + if (use_kputsn) { + syscall_putsn(size, buf); + } } else { fwrite(buf, 1, size, servterm); fflush(servterm); @@ -101,30 +103,36 @@ void service_io_write(const char* buf, size_t size) /** * IO-Puffer flushen */ -static void service_io_flush(void) +void service_io_flush(void) { + FILE* f = servterm; - p(); // Terminal oeffnen falls es noch nicht geoeffnet ist - if (!out_buffer || (!servterm && - !(servterm = fopen(service_terminal, "w")))) - { + if (!f && !(f = fopen(service_terminal, "w"))) { timer_register(service_io_flush, 1000000 * FLUSH_DELAY); goto out; } // Pufferinhalt in das Terminal schreiben - if (!fwrite(out_buffer, 1, out_buffer_pos, servterm)) { + p(); + if (!out_buffer || !fwrite(out_buffer, 1, out_buffer_pos, f)) { goto out; } - fflush(servterm); + fflush(f); free(out_buffer); out_buffer = NULL; out_buffer_pos = 0; + v(); out: - v(); + servterm = f; } - +/** + * Aufhoeren, Ausgaben auch auf die Kernelkonsole weiterzuleiten + */ +void service_io_stop_kputsn(void) +{ + use_kputsn = 0; +} diff --git a/src/modules/servmgr/servmgr.h b/src/modules/servmgr/servmgr.h index 065f524..ff98ab8 100644 --- a/src/modules/servmgr/servmgr.h +++ b/src/modules/servmgr/servmgr.h @@ -112,6 +112,17 @@ void service_io_init(void); */ void service_io_write(const char* buf, size_t size); +/** + * IO-Puffer flushen + */ +void service_io_flush(void); + + +/** + * Aufhoeren, Ausgaben auch auf die Kernelkonsole weiterzuleiten + */ +void service_io_stop_kputsn(void); + /** * Konfiguration der Services einlesen diff --git a/src/modules/vterm/vterm.c b/src/modules/vterm/vterm.c index d27fbc6..91055a3 100644 --- a/src/modules/vterm/vterm.c +++ b/src/modules/vterm/vterm.c @@ -49,15 +49,34 @@ FILE* input = NULL; int main(int argc, char* argv[]) { + pid_t servmgr_pid; + // Schnittstelle fuer die anderen Prozesse einrichten init_lostio_interface(); + // Service registrieren + // + // HACK: Wenn wir uns fast gleichzeitig bei init und servmgr anmelden, + // treiben wir sie direkt in einen Deadlock (servmgr brauch init, um + // vterm:/vterm8/out zu oeffnen und init will "service_register" auf stdout + // schreiben, das beim servmgr liegt). Also warten wir, bis init fertig + // ist. + p(); + init_service_register("vterm"); + while(!init_service_get("vterm")) { + yield(); + } + + // servmgr kann aufhoeren, syscall_putsn zu benutzen + servmgr_pid = init_service_get("servmgr"); + if (servmgr_pid != 0) { + rpc_get_dword(servmgr_pid, "VTERM ", 0, NULL); + } + // Virtuelle Terminal initialisieren init_output(); init_vterminals(10); - - // Service registrieren - init_service_register("vterm"); + v(); // Eingabe initialisieren // Dies registriert einen RPC-Callbackhandler bei kbc. Der Aufruf -- 1.6.0.2 From toni at tyndur.org Sun Dec 13 20:27:36 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:27:36 +0100 Subject: [tyndur-devel] [PATCH] Live-CD: Mit geladenem pci bootet es sich schneller In-Reply-To: <1260717423-12535-1-git-send-email-kevin@tyndur.org> References: <1260717423-12535-1-git-send-email-kevin@tyndur.org> Message-ID: <20091213192735.GA9533@neo.geekcave.lan> On Sun, Dec 13 16:17, Kevin Wolf wrote: > ! Live-CD: pci muss auch noch auf das Floppyimage und beim Booten > geladen werden, ansonsten wartet ata auf einen Timeout > ! grub_hd.cfg: pci sollte als Startup-Service deklariert sein > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 20:36:35 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:36:35 +0100 Subject: [tyndur-devel] [PATCH] Versionsstrings aktualisieren In-Reply-To: <1260715730-21519-1-git-send-email-kevin@tyndur.org> References: <1260715730-21519-1-git-send-email-kevin@tyndur.org> Message-ID: <20091213193634.GB9533@neo.geekcave.lan> On Sun, Dec 13 15:48, Kevin Wolf wrote: > * config.h: TYNDUR_VERSION auf 0.2.2 erhoehen > ! init, shell: $Rev$ durch die tyndur-Versionsnummer ersetzen > > Signed-off-by: Kevin Wolf Hm in der lpt-Konfiguration dürfte auch noch so eine Nummer sein, aber sonst: Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 20:55:48 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:55:48 +0100 Subject: [tyndur-devel] [PATCH 1/5] kbc: Antwort der Tastatur auslesen In-Reply-To: <1260731248-16477-2-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> <1260731248-16477-2-git-send-email-kevin@tyndur.org> Message-ID: <20091213195547.GC9533@neo.geekcave.lan> On Sun, Dec 13 20:07, Kevin Wolf wrote: > ! kbc: Nachdem man einen Befehl gesendet hat, muss man auch die Antwort > der Tastatur auslesen (normal 0xfa fuer Ack). Ansonsten wundert sich > der Treiber spaeter ueber komische Scancodes. > > Signed-off-by: Kevin Wolf Ah das erklärt die Meldungen, lesen sollte man können... ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 20:56:22 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:56:22 +0100 Subject: [tyndur-devel] [PATCH 2/5] init: stdout zeilenpuffern In-Reply-To: <1260731248-16477-3-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> <1260731248-16477-3-git-send-email-kevin@tyndur.org> Message-ID: <20091213195622.GD9533@neo.geekcave.lan> On Sun, Dec 13 20:07, Kevin Wolf wrote: > ! init: Wenn stdout neu geoeffnet wird, um die Meldungen an servmgr zu > schicken, ist es erst einmal blockgepuffert. Deswegen bleiben > Meldungen immer mal wieder stecken und kommen nie auf vterm8 an. > Zeilenpuffern hilft. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 20:57:10 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:57:10 +0100 Subject: [tyndur-devel] [PATCH 3/5] file: Neue Ausgabe bei Mounts In-Reply-To: <1260731248-16477-4-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> <1260731248-16477-4-git-send-email-kevin@tyndur.org> Message-ID: <20091213195710.GE9533@neo.geekcave.lan> On Sun, Dec 13 20:07, Kevin Wolf wrote: > * file: Anstatt alle aktiven Mounts zu dumpen, wenn einer dazu kommt, > eine schoener formatierte Nachricht nur fuer den neu dazugekommenen > Mount ausgeben. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 20:57:39 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 20:57:39 +0100 Subject: [tyndur-devel] [PATCH 4/5] ext2: Debugmeldung entfernen In-Reply-To: <1260731248-16477-5-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> <1260731248-16477-5-git-send-email-kevin@tyndur.org> Message-ID: <20091213195738.GF9533@neo.geekcave.lan> On Sun, Dec 13 20:07, Kevin Wolf wrote: > - ext2: "mounted"-Meldung entfernt > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Sun Dec 13 21:06:38 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 21:06:38 +0100 Subject: [tyndur-devel] [PATCH v2] shell: Fixes fuer bincat In-Reply-To: <1260009779-11944-1-git-send-email-kevin@tyndur.org> References: <1260009779-11944-1-git-send-email-kevin@tyndur.org> Message-ID: <20091213200638.GG9533@neo.geekcave.lan> On Sat, Dec 05 11:42, Kevin Wolf wrote: > ! shell: bincat soll die angegebene Laenge auch dann respektieren, wenn > sie nicht auf 1024 Bytes ausgerichtet ist > ! shell: Offsets in bincat waren um 8 Bytes verrutscht > ! shell: An jedem Blockanfang wird rechts das Offset angezeigt. Das war > bisher ebenfalls verrutscht und das erste ist auf einer eigenen Zeile > gelandet. > > Signed-off-by: Kevin Wolf Ich glaube das könnte hinkommen... ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Sun Dec 13 22:38:58 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 22:38:58 +0100 Subject: [tyndur-devel] [PATCH 1/9] lpt: Aktuellste und nicht erste Version installieren In-Reply-To: <1260725504-9035-2-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> <1260725504-9035-2-git-send-email-toni@tyndur.org> Message-ID: <20091213213857.GA22707@silvanus> On Sun, Dec 13, 2009 at 06:31:36PM +0100, Antoine Kaufmann wrote: > * lpt: Aktuellste und nicht erste Version im Repo installieren > > Signed-off-by: Antoine Kaufmann > --- > src/modules/pas/lpt/packages.pas | 115 +++++++++++++++++++++++++++++++++++++- > 1 files changed, 113 insertions(+), 2 deletions(-) > > diff --git a/src/modules/pas/lpt/packages.pas b/src/modules/pas/lpt/packages.pas > index d5a0218..7cab104 100644 > --- a/src/modules/pas/lpt/packages.pas > +++ b/src/modules/pas/lpt/packages.pas > @@ -60,6 +60,9 @@ type > > function add(number: String): TPackageVersion; > > + (** Neuste Version dieser Section suchen. *) > + function getCurrentVersion(): TPackageVersion; > + > public > section: String; > versions: TCollection; > @@ -76,6 +79,20 @@ type > procedure addDependency(typ: char; dep: String); > procedure copyDependencies(from: TPackageVersion); > > + (** > + * n-ten Teil der Versionsnummer auslesen. Teile, die nicht gesetzt > + * sind, werden einfach als -1 zurueckgegeben. > + *) > + function getVersionPart(n: Integer): Integer; Hm, muss das wirklich public sein? > + > + (** > + * Diese Version mit der angegebenen vergleichen. Ist die angegebene > + * neuer wird ein Wert kleiner 0 zurueckgegeben, ist sie aelter, > + * wird ein Wert groesser 0 zurueckgegeben. Falls die beiden > + * Versionen geleich sind, wird 0 zurueckgegeben. > + **) > + function compareTo(other: TPackageVersion): integer; > + > property preinstDependencies: TCollection read instDep; > property runDependencies: TCollection read runDep; > > @@ -124,8 +141,7 @@ begin > if pkg.name = pkgname then begin > sect := pkg.section[sectname]; > if (sect <> nil) and (sect.versions.count > 0) then begin > - // TODO Aktuellste Version nehmen > - exit(TPackageVersion(sect.versions.items[0])); > + exit(sect.getCurrentVersion); > end; > end; > end; > @@ -293,6 +309,26 @@ begin > exit(version); > end; > > +(** Neuste Version dieser Section suchen. *) > +function TPackageSection.getCurrentVersion(): TPackageVersion; > +var > + cur, other: TPackageVersion; > + curVer, i: Integer; > +begin > + (* Mit erstbester Version anfangen und immer wenn wir eine neuere finden > + die als Aktuelle hernehmen. *) > + cur := TPackageVersion(versions.items[0]); > + for i := 1 to versions.count - 1 do begin > + other := TPackageVersion(versions.items[i]); > + if cur.compareTo(other) < 0 then begin > + cur := other; > + end; > + end; > + > + Exit(cur); > +end; > + > + > constructor TPackageVersion.create(parent: TCollection); > begin > inherited; > @@ -350,4 +386,79 @@ begin > end; > end; > > +(** > + * n-ten Teil der Versionsnummer auslesen. Teile, die nicht gesetzt > + * sind, werden einfach als -1 zurueckgegeben. > + *) > +function TPackageVersion.getVersionPart(n: Integer): Integer; > +var > + part, ver: String; > + i, dotpos, num: Integer; > +begin > + ver := version; > + dotpos := 1; Überflüssig? > + > + (* Wir spalten den String Stueck fuer Stueck bei . und - auf und fuellen > + ihn in ein Array *) > + for i := 1 to n do begin > + dotpos := Pos('.', ver); > + if dotpos <= 0 then begin > + dotpos := Pos('-', ver); > + end; - darf also nur nach allen Punkten kommen? > + > + (* Kein . oder - mehr gefunden, wenn noch ein Stueck uebrig ist, nehmen > + wir das noch, sonst sind wir fertig. *) > + if (Length(ver) = 0) then begin > + Exit(-1); > + end else if dotpos <= 0 then begin > + dotpos := Length(ver) + 1; > + end; > + > + part := Copy(ver, 1, dotpos - 1); > + ver := Copy(ver, dotpos + 1, Length(ver)); > + num := StrToInt(part); Vielleicht hier die Exception fangen falls einer Buchstaben reinmischt und dann auch -1 zurückgeben? > + end; > + > + Exit(num); > +end; > + > +(** > + * Diese Version mit der angegebenen vergleichen. Ist die angegebene > + * neuer wird ein Wert kleiner 0 zurueckgegeben, ist sie aelter, > + * wird ein Wert groesser 0 zurueckgegeben. Falls die beiden > + * Versionen geleich sind, wird 0 zurueckgegeben. > + **) > +function TPackageVersion.compareTo(other: TPackageVersion): integer; > +var > + partA, partB, n: Integer; > + aInv, bInv: Boolean; > +begin > + n := 1; > + aInv := false; > + bInv := false; > + repeat begin Gibt es irgendeinen Grund für repeat begin ... end until statt einfach nur repeat ... until? ;-) > + partA := getVersionPart(n); > + partB := other.getVersionPart(n); > + > + (* Wenn eine Versionsnummer kuerzer ist als die andere, hat eine -1 und > + die andere noch eine vernuenftige Zahl. Ist diese Zufaelligerweise 0, > + muss der Vergleich trotzdem passen, da 0.2 = 0.2.0 *) > + if partA = -1 then begin > + aInv := true; > + partA := 0; > + end; > + if partB = -1 then begin > + bInv := true; > + partB := 0; > + end; > + > + if (partA - partB) <> 0 then begin > + Exit(partA - partB); > + end; > + > + Inc(n); > + end; until aInv and bInv; > + Exit(0); > +end; > + > end. Sieht ansonsten glaubwürdig aus. From toni at tyndur.org Sun Dec 13 23:04:23 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 23:04:23 +0100 Subject: [tyndur-devel] [PATCH 5/5] servmgr/vterm: Mehr Bootmeldungen anzeigen In-Reply-To: <1260731248-16477-6-git-send-email-kevin@tyndur.org> References: <1260731248-16477-1-git-send-email-kevin@tyndur.org> <1260731248-16477-6-git-send-email-kevin@tyndur.org> Message-ID: <20091213220423.GH9533@neo.geekcave.lan> On Sun, Dec 13 20:07, Kevin Wolf wrote: > + vterm: RPC an servmgr schicken, sobald vterm geladen ist > * servmgr: Solange vterm noch nicht da ist, werden Meldungen auch auf > der Kernelkonsole ausgegeben > > Signed-off-by: Kevin Wolf Hm jo so langsam aber sicher glaube ich dir, dass das funktionieren könnte. ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Sun Dec 13 23:31:31 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 13 Dec 2009 23:31:31 +0100 Subject: [tyndur-devel] [PATCH] cdi: Hack fuer allgemeine cdrom-Ressource Message-ID: <1260743491-10716-1-git-send-email-kevin@tyndur.org> + cdi/storage: Fuer das erste gefundene CD-ROM-Laufwerk wird gleich noch ein Alias cdrom angelegt, damit man nicht wissen muss, an welchem Kanal es genau haengt. * grub_cdrom.cfg: ata:/cdrom statt ata:/atapi10 benutzen Signed-off-by: Kevin Wolf --- build/config/grub_cdrom.cfg | 4 ++-- src/modules/cdi/lib/storage.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build/config/grub_cdrom.cfg b/build/config/grub_cdrom.cfg index e0de5e3..263f9f4 100644 --- a/build/config/grub_cdrom.cfg +++ b/build/config/grub_cdrom.cfg @@ -7,7 +7,7 @@ module /iso9660 module /ramoverlay module /ext2 module /console servmgr:/term servmgr:/term -module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci +module /servmgr ata:/cdrom|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci boot title tyndur (English) @@ -19,5 +19,5 @@ module /iso9660 module /ramoverlay module /ext2 module /console servmgr:/term servmgr:/term -module /servmgr ata:/atapi10|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci +module /servmgr ata:/cdrom|iso9660:/hd.img|ramoverlay:/cached|ext2:/ vterm:/vterm8/out ata iso9660 console ramoverlay ext2 pci boot diff --git a/src/modules/cdi/lib/storage.c b/src/modules/cdi/lib/storage.c index 992ae00..5cf16ea 100644 --- a/src/modules/cdi/lib/storage.c +++ b/src/modules/cdi/lib/storage.c @@ -212,6 +212,8 @@ static void lostio_mst_if_init() */ int lostio_mst_if_newdev(struct cdi_storage_device* device) { + static int has_cdrom = 0; + // Slash vor Pfad angaengen char path[strlen(device->dev.name) + 2]; strcpy(path + 1, device->dev.name); @@ -222,6 +224,13 @@ int lostio_mst_if_newdev(struct cdi_storage_device* device) { return -1; } + + if (!has_cdrom && !strncmp(device->dev.name, "atapi", strlen("atapi"))) { + has_cdrom = 1; + vfstree_create_node("/cdrom", CDI_LOSTIO_TYPE_MST, device->block_size * + device->block_count, (void*) device, 0); + } + return 0; } -- 1.6.0.2 From toni at tyndur.org Sun Dec 13 23:35:59 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Sun, 13 Dec 2009 23:35:59 +0100 Subject: [tyndur-devel] [PATCH] cdi: Hack fuer allgemeine cdrom-Ressource In-Reply-To: <1260743491-10716-1-git-send-email-kevin@tyndur.org> References: <1260743491-10716-1-git-send-email-kevin@tyndur.org> Message-ID: <20091213223559.GI9533@neo.geekcave.lan> On Sun, Dec 13 23:31, Kevin Wolf wrote: > + cdi/storage: Fuer das erste gefundene CD-ROM-Laufwerk wird gleich noch > ein Alias cdrom angelegt, damit man nicht wissen muss, an welchem > Kanal es genau haengt. > * grub_cdrom.cfg: ata:/cdrom statt ata:/atapi10 benutzen > > Signed-off-by: Kevin Wolf Also halt ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From max at tyndur.org Mon Dec 14 15:37:31 2009 From: max at tyndur.org (max at tyndur.org) Date: Mon, 14 Dec 2009 15:37:31 +0100 Subject: [tyndur-devel] [PATCH] buffer_position Message-ID: <1260801451-25174-1-git-send-email-max@tyndur.org> From: Max Reitz - buffer_position() aus output.c entfernt und das extern inline in vterm.h in ein static inline umgewandelt Signed-off-by: Max Reitz --- src/modules/vterm/output.c | 18 ------------------ src/modules/vterm/vterm.h | 13 +++++++++++-- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/modules/vterm/output.c b/src/modules/vterm/output.c index 98b22b9..5264470 100644 --- a/src/modules/vterm/output.c +++ b/src/modules/vterm/output.c @@ -412,24 +412,6 @@ static void screen_adjust(vterm_output_t* out, position_t pos) /** - * Diese Funktion ist das Gegenstueck zu screen_position. Sie errechnet anhand - * einer gegebenen Bildschirm-Position die Position im Puffer. Im Gegensatz zu - * screen_position kann diese Funktion aber nicht fehlschlagen, da der - * Bildschirm immer irgendwo innerhalb des Puffers sein muss. - * - * @param screen_pos Position auf dem Bildschirm - * @param dest_pos Pointer auf die Positionsstruktur, in der das Ergebnis - * abgelegt werden soll. - */ -inline void buffer_position(vterm_output_t* out, position_t screen_pos, - position_t* dest_pos) -{ - dest_pos->line = out->screen_topline + screen_pos.line; - dest_pos->line %= out->buffer_lines; - dest_pos->column = screen_pos.column; -} - -/** * Ein einzelnes Zeichen in einem Buffer setzen * * @param buffer Puffer in den das Zeichen gesetzt werden soll diff --git a/src/modules/vterm/vterm.h b/src/modules/vterm/vterm.h index 0871db9..45a3a0a 100644 --- a/src/modules/vterm/vterm.h +++ b/src/modules/vterm/vterm.h @@ -217,8 +217,17 @@ void screen_user_scroll(vterm_output_t* out, int lines); bool screen_position(vterm_output_t* out, position_t buffer_pos, position_t* position); -/// Das Gegenstueck zu screen_position -extern inline void buffer_position(vterm_output_t* out, position_t screen_pos, +/** + * Diese Funktion ist das Gegenstueck zu screen_position. Sie errechnet anhand + * einer gegebenen Bildschirm-Position die Position im Puffer. Im Gegensatz zu + * screen_position kann diese Funktion aber nicht fehlschlagen, da der + * Bildschirm immer irgendwo innerhalb des Puffers sein muss. + * + * @param screen_pos Position auf dem Bildschirm + * @param dest_pos Pointer auf die Positionsstruktur, in der das Ergebnis + * abgelegt werden soll. + */ +static inline void buffer_position(vterm_output_t* out, position_t screen_pos, position_t* dest_pos) { dest_pos->line = out->screen_topline + screen_pos.line; -- 1.6.4.2 From max at tyndur.org Mon Dec 14 19:24:23 2009 From: max at tyndur.org (max at tyndur.org) Date: Mon, 14 Dec 2009 19:24:23 +0100 Subject: [tyndur-devel] [PATCH 1/3] CDI.usb, CDI.usb-hcd, mempool Message-ID: <1260815065-30874-1-git-send-email-max@tyndur.org> From: Max Reitz + CDI.usb-Lib (nur tauglich, wenn alle die Lib nutzenden Treiber in einer Binary sind) + CDI.usb-hcd-Lib (ebenso) + Mempool-Lib für CDI-Treiber Signed-off-by: Max Reitz --- src/modules/cdi/include/cdi/mempool.h | 35 ++ src/modules/cdi/include/cdi/usb-hcd.h | 184 +++++++ src/modules/cdi/include/cdi/usb.h | 880 +++++++++++++++++++++++++++++++++ src/modules/cdi/lib/cdi.c | 5 + src/modules/cdi/lib/mempool.c | 109 ++++ src/modules/cdi/lib/usb-hcd.c | 55 ++ src/modules/cdi/lib/usb.c | 425 ++++++++++++++++ 7 files changed, 1693 insertions(+), 0 deletions(-) create mode 100644 src/modules/cdi/include/cdi/mempool.h create mode 100644 src/modules/cdi/include/cdi/usb-hcd.h create mode 100644 src/modules/cdi/include/cdi/usb.h create mode 100644 src/modules/cdi/lib/mempool.c create mode 100644 src/modules/cdi/lib/usb-hcd.c create mode 100644 src/modules/cdi/lib/usb.c diff --git a/src/modules/cdi/include/cdi/mempool.h b/src/modules/cdi/include/cdi/mempool.h new file mode 100644 index 0000000..83d2ab2 --- /dev/null +++ b/src/modules/cdi/include/cdi/mempool.h @@ -0,0 +1,35 @@ +/****************************************************************************** +* Copyright (c) 2009 Kevin Wolf * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef MEMPOOL_H +#define MEMPOOL_H + +#include +#include + +struct mempool; + +struct mempool* mempool_create(size_t pool_size, size_t object_size); +int mempool_get(struct mempool* pool, void** obj, uintptr_t* phys_obj); +int mempool_put(struct mempool* pool, void* obj); + +#endif diff --git a/src/modules/cdi/include/cdi/usb-hcd.h b/src/modules/cdi/include/cdi/usb-hcd.h new file mode 100644 index 0000000..246bda4 --- /dev/null +++ b/src/modules/cdi/include/cdi/usb-hcd.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2009 Max Reitz + * + * 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. + */ + +/** + * \if german + * USB-Hostcontrollertreiber + * \elseif english + * USB host controller drivers + * \endif + * \defgroup USBHCD + */ +/*\@{*/ + +#ifndef _CDI_USB_HCD_H_ +#define _CDI_USB_HCD_H_ + +#include "cdi/misc.h" +#include "cdi/usb.h" +#include "sys/types.h" + +struct cdi_usb_hc { + struct cdi_device dev; + + /** + * \if german + * USB-Geschwindigkeit + * \elseif english + * USB speed + * \endif + */ + cdi_usb_speed_t speed; +}; + +struct cdi_usb_hcd { + struct cdi_driver drv; + + /** + * \if german + * + * Listet alle Geraete auf, die an den Rootports haengen und ruft ggf. + * cdi_usb_device_init auf + * + * @param device Der Hostcontroller + * + * \elseif english + * + * Lists all devices hanging at the root ports and calls (if necessary) + * cdi_usb_device_init + * + * @param device The host controller + * + * \endif + */ + void (*find_devices)(struct cdi_usb_hc* device); + + /** + * \if german + * + * Aktiviert den zum angegebenen Geraet gehoerigen Rootport + * + * @param usb_device Das USB-Geraet (muss an einem Rootport haengen) + * + * \elseif english + * + * Activates the root port corresponding to the device + * + * @param usb_device The USB device (must be located at a root port) + * + * \endif + */ + void (*activate_device)(struct cdi_usb_device* usb_device); + + /** + * \if german + * + * Verarbeitet USB-Pakete + * + * @param packets Array zu sendender Pakete + * @param num_packets Anzahl der Pakete + * + * @return Gibt den Status an (z. B. USB_NO_ERROR fuer keinen Fehler) + * + * \elseif english + * + * Sends USB packets + * + * @param packets Array of packages to be sent + * @param num_packages Number of packages + * + * \endif + */ + cdi_usb_status_t (*send_packets)(struct cdi_usb_packet* packets, + size_t num_packets); + + /** + * \if german + * + * Erstellt eine neue Pipe + * + * @param pipe Die Pipe + * + * \elseif english + * + * Creates a new pipe + * + * @param pipe The pipe + * + * \endif + */ + void (*add_pipe)(struct cdi_usb_pipe* pipe); + + /* + // tyndurspezifisch + pid_t pid; + uintptr_t real_add_pipe;*/ +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \if german + * + * Initialisiert einen HCD + * + * @param driver Der HCD + * + * \elseif english + * + * Initializes an HCD + * + * @param driver The HCD + * + * \endif + */ +void cdi_usb_hcd_init(struct cdi_usb_hcd* driver); + +/** + * \if german + * + * Gibt einen HCD frei + * + * @param driver Freizugebender HCD + * + * \elseif english + * + * Removes an HCD + * + * @param driver HCD to be removed + * + * \endif + */ +void cdi_usb_hcd_destroy(struct cdi_usb_hcd* driver); + +/** + * \if german + * + * Registriert einen HCD + * + * @param driver Zu registrierender HCD + * + * \elseif english + * + * Registers an HCD + * + * @param driver HCD to be registered + * + * \endif + */ +//void cdi_usb_hcd_register(struct cdi_usb_hcd* driver); + +#ifdef __cplusplus +} //extern "C" +#endif + +#endif diff --git a/src/modules/cdi/include/cdi/usb.h b/src/modules/cdi/include/cdi/usb.h new file mode 100644 index 0000000..ccfe6c1 --- /dev/null +++ b/src/modules/cdi/include/cdi/usb.h @@ -0,0 +1,880 @@ +/* + * Copyright (c) 2009 Max Reitz + * + * 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. + */ + +/** + * \if german + * USB-Bustreiber + * \elseif english + * USB bus drivers + * \endif + * \defgroup USB + */ +/*\@{*/ + +#ifndef _CDI_USB_H_ +#define _CDI_USB_H_ + +#include "stddef.h" +#include "stdint.h" +#include "sys/types.h" + +typedef enum { + /// Low-Speed (1,5 Mbit/s) + CDI_USB_LOW_SPEED = 0x01, + /// Full-Speed (12 Mbit/s) + CDI_USB_FULL_SPEED = 0x02, + /// High-Speed (480 Mbit/s) + CDI_USB_HIGH_SPEED = 0x04, + /// SuperSpeed (5 Gbit/s) + CDI_USB_SUPER_SPEED = 0x08, +} cdi_usb_speed_t; + +typedef enum { + /** + * \if german + * SETUP-Paket + * \elseif english + * SETUP packet + * \endif + */ + CDI_USB_PACKET_SETUP = 0x2D, + + /** + * \if german + * Daten vom Geraet zum Host + * \elseif english + * Data from the device to the host + * \endif + */ + CDI_USB_PACKET_IN = 0x69, + + /** + * \if german + * Daten vom Host zum Geraet + * \elseif english + * Data from the host to the device + * \endif + */ + CDI_USB_PACKET_OUT = 0xE1, +} cdi_usb_packet_type_t; + +typedef enum { + /** + * \if german + * Kein Fehler + * \elseif english + * No error + * \endif + */ + CDI_USB_NO_ERROR = 0x0000, + + /// Stalled + CDI_USB_STALLED = 0x0001, + + /** + * \if german + * Bufferfehler (Overflow, underrun, ...) + * \elseif english + * Buffer error (overflow, underrun, ...) + * \endif + */ + CDI_USB_BUFFER_ERROR = 0x0002, + + /** + * \if german + * Babble (Geraet hat zu viele Daten gesendet) + * \elseif english + * Babble (device has sent more data than expected) + * \endif + */ + CDI_USB_BABBLE = 0x0004, + + /** + * \if german + * NAK (Daten sind erneut zu senden) + * \elseif english + * NAK (data has to be sent again) + * \endif + */ + CDI_USB_NAK = 0x0008, + + /** + * \if german + * CRC-Fehler + * \elseif english + * CRC error + * \endif + */ + CDI_USB_CRC = 0x0010, + + /// Timeout + CDI_USB_TIMEOUT = 0x0020, + + /** + * \if german + * Bitstuff/-destuff-Fehler + * \elseif english + * bitstuff/-destuff error + * \endif + */ + CDI_USB_BITSTUFF = 0x0040, + + /** + * \if german + * Reservieren von Speicher fehlgeschlagen, ... + * \elseif english + * Allocating of memory failed, ... + * \endif + */ + CDI_USB_TRIVIAL_ERROR = 0x0080, +} cdi_usb_status_t; + +struct cdi_usb_hc; +struct cdi_usb_pipe; +struct cdi_usb_interface; +struct cdi_usb_driver; + +struct cdi_usb_device { + /** + * \if german + * Der USB-Bustreiber + * \elseif english + * The USB bus driver + * \endif + */ + struct cdi_usb_driver* drv; + + /** + * \if german + * Der Hostcontroller, an dem das Geraet im Endeffekt haengt + * \elseif english + * The host controller where the device is eventually located + * \endif + */ + struct cdi_usb_hc* hc; + + /** + * \if german + * Haengt das Geraet an einem Hub, dann ist dieses Feld ein Pointer auf + * das entsprechende USB-Geraet, haengt es an einem Rootport, dann ist + * dieses Feld NULL. + * \elseif english + * If the device is located at a hub, then this field contains a pointer to + * the corresponding USB device, if it's located at a root port, then this + * field is set to NULL. + * \endif + */ + struct cdi_usb_device* hub; + + /** + * \if german + * Geschwindigkeit(-en) dieses Geraets + * \elseif english + * Speed(-s) supported by this device + * \endif + */ + cdi_usb_speed_t speed; + + /// ID + int id; + + /** + * \if german + * Entweder der Rootport oder der Port des Hubs, an dem das Geraet haengt + * \elseif english + * Either the root port or the port hub's port where the device is located + * \endif + */ + int port; + + /** + * \if german + * Hier darf der Geraetetreiber seine Daten unterbringen + * \elseif english + * The device driver may store its data here + * \endif + */ + void* driver_data; + + /** + * \if german + * Felder, die so auch bei PCI existieren: Vendor-, Device-, Class-, + * Subclass- und Protocol-ID + * \elseif english + * Fields existing at PCI, too: vendor, device, class, subclass and + * protocol ID. + * \endif + */ + int vendor_id; + int device_id; + int class_id; + int subclass_id; + int protocol_id; + + /** + * \if german + * + * Setzt das USB-Geraet zurueck (kann sowohl vom HCD als auch vom Hub + * driver ausgefuehrt werden) + * + * @param usb_device Das Geraet + * + * \elseif english + * + * Resets the USB device (may be executed either by the HCD or the hub + * driver) + * + * @param usb_device The device + * + * \endif + */ + void (*reset)(struct cdi_usb_device* usb_device); + + /** + * \if german + * Ziemlich lowlevelig. Gehoert das hier wirklich rein? + * \elseif english + * Very low level. Does it really fit in here? + * \endif + */ + + /** + * \if german + * Im einzelnen sind das: Pipe fuer Endpoint 0 + * \elseif english + * In particular these things are: Pipe for endpoint 0 + * \endif + */ + struct cdi_usb_pipe* ep0; + + /// Device descriptor + void* device_desc; + + /// Configuration descriptor + void* config_desc; + + /// Interface descriptor + struct cdi_usb_interface* interface_desc; + + /// Class descriptor + void* class_desc; + + /* + // tyndurspezifisch + uintptr_t real_reset; + pid_t ppid;*/ +}; + +enum cdi_usb_toggle { + /** + * \if german + * Das Toggle nehmen, das jetzt dran ist + * \elseif english + * Use the toggle to be used right now + * \endif + */ + TOGGLE_UNSPECIFIC = 0, + + /** + * \if german + * Geloeschtes Togglebit erzwingen + * \elseif english + * Force unset toggle bit + * \endif + */ + TOGGLE_0 = 1, + + /** + * \if german + * Gesetztes Togglebit erzwingen + * \elseif english + * Force set toggle bit + * \endif + */ + TOGGLE_1 = 2 +}; + +struct cdi_usb_endpoint { + /// sizeof(struct cdi_usb_endpoint) + uint8_t length; + + /// 5 + uint8_t descriptor_type; + + /** + * \if german + * Nummer des Endpoints + * \elseif english + * Endpoint's number + * \endif + */ + uint8_t endpoint_address; + + /** + * \if german + * Eigenschaften (IN/OUT, Bulk/Interrupt/..., ...) + * \elseif english + * Attributes (IN/OUT, bulk/interrupt/..., ...) + * \endif + */ + uint8_t attributes; + + /** + * \if german + * Maximale Paketgroesse in Bytes + * \elseif english + * Maximum packet size in bytes + * \endif + */ + uint16_t max_packet_size; + + /// ??? + uint8_t interval; +} __attribute__((packed)); + +struct cdi_usb_interface { + /// sizeof(struct cdi_usb_interface) + uint8_t length; + + /// 4 + uint8_t descriptor_type; + + /** + * \if german + * Nummer des Interface + * \elseif english + * Interface's number + * \endif + */ + uint8_t interface_number; + + /// ??? + uint8_t alternate_setting; + + /** + * \if german + * Anzahl der Endpoints fuer dieses Interface + * \elseif english + * Number of endpoints for this interface + * \endif + */ + uint8_t num_endpoints; + + /** + * \if german + * Class-ID (bei Composite Devices) + * \elseif english + * Class ID (used with composite devices) + * \endif + */ + uint8_t interface_class; + + /// Subclass-ID + uint8_t interface_subclass; + + /// Protocol-ID + uint8_t interface_protocol; + + /** + * \if german + * String-Index, der das Interface beschreibt + * \elseif english + * String index describing the interface + * \endif + */ + uint8_t iInterface; +} __attribute__((packed)); + +/** + * \if german + * Beschreibt eine Pipe + * \elseif english + * Describes a pipe + * \endif + */ +struct cdi_usb_pipe { + /** + * \if german + * Ziel + * \elseif english + * Destination + * \endif + */ + struct cdi_usb_device* device; + + /** + * \if german + * Ein Pointer auf eine den Endpoint beschreibende Struktur + * TODO Das ist eigentlich auch sehr lowlevelig. + * \elseif english + * A pointer to a structure describing the endpoint + * TODO This is on a very low level, too. + */ + struct cdi_usb_endpoint* endpoint; + + /// Data-Toggle + int data_toggle; +}; + +/** + * \if german + * Beschreibt ein USB-Paket + * \elseif english + * Describes a USB packet + * \endif + */ +struct cdi_usb_packet { + /** + * \if german + * Die gewuenschte Pipe + * \elseif english + * The desired pipe + * \endif + */ + struct cdi_usb_pipe* pipe; + + /** + * \if german + * Der Typ des Pakets (PACKET_IN, PACKET_OUT, PACKET_SETUP) + * \elseif english + * Type of packet (PACKET_IN, PACKET_OUT, PACKET_SETUP) + * \endif + */ + cdi_usb_packet_type_t type; + + /** + * \if german + * Zeiger auf den Datenpuffer + * \elseif english + * Pointer to the data buffer + * \endif + */ + void* data; + + /** + * \if german + * Die Laenge des Puffers + * \elseif english + * The buffer's length + * \endif + */ + size_t length; + + /** + * \if german + * Fehlertyp (oder CDI_USB_NO_ERROR) + * \elseif english + * Error type (or CDI_USB_NO_ERROR) + * \endif + */ + cdi_usb_status_t condition; + + /** + * \if german + * Bestimmtes Data-Toggle benuten + * \elseif english + * Use specific data toggle + * \endif + */ + enum cdi_usb_toggle use_toggle; +}; + +typedef enum { + /** + * \if german + * Host -> Geraet + * \elseif english + * Host -> device + * \endif + */ + CDI_USB_CONTROL_OUT = 0x00, + + /** + * \if german + * Geraet -> Host + * \elseif english + * Device -> host + * \endif + */ + CDI_USB_CONTROL_IN = 0x80 +} cdi_usb_control_direction_t; + +typedef enum { + /** + * \if german + * Standard-Request + * \elseif english + * Standard request + * \endif + */ + CDI_USB_CONTROL_RQ_STANDARD = 0x00, + + /** + * \if german + * Klassenspezifischer Request + * \elseif english + * Class specific request + * \endif + */ + CDI_USB_CONTROL_RQ_CLASS = 0x20, + + /** + * \if german + * Herstellerspezifischer Request + * \elseif english + * Vendor specific request + * \endif + */ + CDI_USB_CONTROL_RQ_VENDOR = 0x40 +} cdi_usb_control_request_type_t; + +typedef enum { + /** + * \if german + * Empfaenger: Geraet + * \elseif english + * Recipient: device + * \endif + */ + CDI_USB_CONTROL_REC_DEVICE = 0x00, + + /** + * \if german + * Empfaenger: Interface + * \elseif english + * Recipient: interface + * \endif + */ + CDI_USB_CONTROL_REC_INTERFACE = 0x01, + + /** + * \if german + * Empfaenger: Endpoint + * \elseif english + * Recipient: endpoint + * \endif + */ + CDI_USB_CONTROL_REC_ENDPOINT = 0x02, + + /** + * \if german + * Empfaenger ist jemand anderes + * \elseif english + * Recipient is another one + * \endif + */ + CDI_USB_CONTROL_REC_OTHER = 0x03 +} cdi_usb_control_recipient_t; + +struct cdi_usb_control_transfer { + /** + * \if german + * Wenn Daten zum Geraet gesendet werden sollen, dann ist hier der + * Speicherbereich anzugeben + * \elseif english + * If data has to be sent to the device, then the memory buffer has to be + * given here + * \endif + */ + void* buffer; + + /** + * \if german + * Laenge der erwarteten bzw. zu sendenden Daten + * \elseif english + * Length of the expected data respectively the data to be sent + * \endif + */ + size_t length; + + /** + * \if german + * Richtung + * \elseif english + * Direction + * \endif + */ + cdi_usb_control_direction_t direction; + + /** + * \if german + * Art des Requests (Standardrequest, klassenspezifisch, + * herstellerspezifisch) + * \elseif english + * Request type (standard request, class specific, vendor specific) + * \endif + */ + cdi_usb_control_request_type_t rtype; + + /** + * \if german + * Ziel (Device, Interface, Endpoint, anderes) + * \elseif english + * Recipient (device, interface, endpoint, other) + * \endif + */ + cdi_usb_control_recipient_t recipient; + + /** + * \if german + * Requestcode (Je nach rtype und recipient) + * \elseif english + * Request code (specific to rtype and recipient) + * \endif + */ + int request; + + /** + * \if german + * Ein zu sendender Wert + * \elseif english + * A value to be sent + * \endif + */ + int value; + + /** + * \if german + * Ein zu sendender Index + * \elseif english + * An index to be sent + * \endif + */ + int index; +}; + +#include "cdi/usb-hcd.h" + +struct cdi_usb_driver { + struct cdi_driver drv; + + /** + * \if german + * Unterstuetzte Geschwindigkeiten + * \elseif english + * Supported speeds + * \endif + */ + cdi_usb_speed_t speeds; + + /** + * \if german + * + * Enumeriert ein USB-Geraet + * + * @param device Das zu enumerierende Geraet + * + * \elseif english + * + * Enumerates a USB device + * + * @param device The device to be enumerated + * + * \endif + */ + void (*enumerate_device)(struct cdi_usb_device* device); + + /** + * \if german + * + * Sendet USB-Pakete + * + * @param packets Array zu sendender Pakete + * @param num_packets Anzahl der Pakete + * + * @return Gibt den Status an (z. B. USB_NO_ERROR fuer keinen Fehler) + * + * \elseif english + * + * Sends USB packets + * + * @param packets Array of packets to be sent + * @param num_packets Number of packets + * + * @return Returns the status (i. e. USB_NO_ERROR to indicate no error) + * + * \endif + */ + cdi_usb_status_t (*send_packets)(struct cdi_usb_packet* packets, + size_t num_packets); + + /** + * \if german + * + * Fuehrt einen Control-Transfer durch + * + * @param device Das Zielgeraet + * @param transfer Eine den Transfer beschreibende Struktur + * + * @return Gibt einen Puffer zurueck, der die ausgetauschen Daten enthaelt, + * im Fehlerfall hingegen NULL, gab es keine Daten, dann + * (void *)0xFFFFFFFF. + * + * \elseif english + * + * Performs a control transfer + * + * @param device The destination device + * @param transfer A structure describing this transfer + * + * @return Returns a buffer containing the transferred data, in case of an + * error the value is NULL and if there was no data, it returns + * (void *)0xFFFFFFFF. + * + * \endif + */ + void* (*do_control)(struct cdi_usb_device* device, + struct cdi_usb_control_transfer* transfer); + + /* + // tyndurspezifisch + uintptr_t pointer_base; + uintptr_t real_enum_device; + pid_t pid;*/ +}; + +/** + * \if german + * Ein USB-Geraetetreiber uebergibt dem Betriebssystem eine solche Struktur, + * damit ein bestimmter Handler beim Auffinden solcher Geraete aufgerufen wird. + * Jedes Feld enthaelt entweder eine Zahl, die mit der des Geraetes + * uebereinstimmen muss oder -1, dann wird dieses Feld ignoriert. + * \elseif english + * A USB device driver passes this structure to the OS so that a specific + * handler is called upon the detection of such a device. Each field either + * contains a number that has to be equal to that of the driver or -1, so that + * the field will be ignored. + * \endif + */ +struct cdi_usb_device_pattern { + int vendor_id; + int device_id; + int class_id; + int subclass_id; + int protocol_id; + + /** + * \if german + * + * Ueberprueft das angegebene USB-Geraet + * + * @param device Das Geraet + * + * @return 0, wenn dieses Geraet nicht vom Treiber verarbeitet werden kann, + * sonst 1 + * + * \elseif english + * + * Checks the given USB device + * + * @param device The device + * + * @return 0 if the driver is unable to handle this device, else 1 + * + * \endif + */ + int (*take_usb_device)(struct cdi_usb_device* device); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \if german + * + * Entfernt einen USB-Bustreiber + * + * @param driver Der Treiber + * + * \elseif english + * + * Removes a USB bus driver + * + * @param driver The driver + * + * \endif + */ +void cdi_usb_driver_destroy(struct cdi_usb_driver* driver); + +/** + * \if german + * + * Initialisiert einen USB-Bustreiber + * + * @param driver Der Treiber + * + * \elseif english + * + * Initializes a USB bus driver + * + * @param driver The driver + * + * \endif + */ +void cdi_usb_driver_init(struct cdi_usb_driver* driver); + +/** + * \if german + * + * Registriert einen USB-Bustreiber beim System + * + * @param driver Der Treiber + * + * \elseif english + * + * Registers a USB bus driver at the OS + * + * @param driver The driver + * + * \endif + */ +void cdi_usb_driver_register(struct cdi_usb_driver* driver); + +/** + * \if german + * + * Registriert ein gefundenes USB-Geraet beim Betriebssystem - diese Funktion + * wird z. B. vom Host-Controller-Treiber nach einem Aufruf von find_devices + * fuer jedes gefundene Geraet aufgerufen + * + * @param device Das zu registrierende Geraet + * + * \elseif english + * + * Registers a detected USB device at the OS - this function is called i. e. by + * the host controller driver after a find_devices call for every device found + * + * @param device The device to be registered + */ +void cdi_usb_device_init(struct cdi_usb_device* device); + +/** + * \if german + * + * Registriert ein Geraetemuster + * + * @param pattern Das Muster + * + * \elseif english + * + * Registers a device pattern + * + * @param pattern The pattern + * + * \endif + */ +void cdi_usb_register_device_pattern(struct cdi_usb_device_pattern* pattern); + +#ifdef __cplusplus +} //extern "C" +#endif + +#endif diff --git a/src/modules/cdi/lib/cdi.c b/src/modules/cdi/lib/cdi.c index b650a79..e3b10cc 100644 --- a/src/modules/cdi/lib/cdi.c +++ b/src/modules/cdi/lib/cdi.c @@ -21,6 +21,7 @@ static list_t* drivers = NULL; static void cdi_destroy(void); +void _init_usb_hcd(struct cdi_driver* drv); /** * Caches Synchronisieren @@ -98,6 +99,10 @@ void cdi_run_drivers(void) } } + if (driver->type == CDI_USB_HCD) { + _init_usb_hcd(driver); + } + if (driver->type != CDI_NETWORK) { init_service_register((char*) driver->name); } diff --git a/src/modules/cdi/lib/mempool.c b/src/modules/cdi/lib/mempool.c new file mode 100644 index 0000000..8a165db --- /dev/null +++ b/src/modules/cdi/lib/mempool.c @@ -0,0 +1,109 @@ +/****************************************************************************** +* Copyright (c) 2009 Kevin Wolf * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include "cdi/mempool.h" +#include "cdi/misc.h" + +struct free_object { + struct free_object* next; +}; + +struct mempool { + size_t pool_size; + size_t object_size; + size_t num_objects; + + void* objects; + void* phys_objects; + + struct free_object* first_free; +}; + +struct mempool* mempool_create(size_t pool_size, size_t object_size) +{ + struct mempool* pool = malloc(sizeof(*pool)); + uintptr_t cur; + int i; + struct free_object** p; + + pool->pool_size = pool_size; + pool->object_size = object_size; + pool->num_objects = pool_size / object_size; + + // Wir brauchen auf jeden Fall Platz fuer die Freispeicherliste + if (object_size < sizeof(struct free_object)) { + goto fail; + } + + + // Speicher reservieren + // FIXME Das ist alles zusammenhaengend + if (cdi_alloc_phys_mem(pool_size, &pool->objects, &pool->phys_objects)) { + goto fail; + } + + // Freie Objekte eintragen + cur = (uintptr_t) pool->objects; + p = &pool->first_free; + for (i = 0; i < (int)pool->num_objects; i++) { + *p = (struct free_object*) cur; + p = &((struct free_object*) cur)->next; + cur += object_size; + } + *p = NULL; + + return pool; + +fail: + free(pool); + return NULL; +} + +int mempool_get(struct mempool* pool, void** obj, uintptr_t* phys_obj) +{ + struct free_object* free = pool->first_free; + + if (free == NULL) { + return -1; + } + + pool->first_free = free->next; + + *obj = free; + *phys_obj = (uintptr_t) pool->phys_objects + + (uintptr_t) free - (uintptr_t) pool->objects; + + return 0; +} + +int mempool_put(struct mempool* pool, void* obj) +{ + struct free_object* free = obj; + + free->next = pool->first_free; + pool->first_free = free; + + return 0; +} diff --git a/src/modules/cdi/lib/usb-hcd.c b/src/modules/cdi/lib/usb-hcd.c new file mode 100644 index 0000000..cb8c5a6 --- /dev/null +++ b/src/modules/cdi/lib/usb-hcd.c @@ -0,0 +1,55 @@ +//#include "rpc.h" +#include "stdio.h" +//#include "unistd.h" + +#include "cdi/lists.h" +#include "cdi/misc.h" +#include "cdi/usb-hcd.h" + +//static int has_handler = 0; + +void register_usb_devices(cdi_list_t devices); + +void cdi_usb_hcd_init(struct cdi_usb_hcd* driver) +{ + driver->drv.type = CDI_USB_HCD; + cdi_driver_init((struct cdi_driver*) driver); +} + +void cdi_usb_hcd_destroy(struct cdi_usb_hcd* driver) +{ + cdi_driver_destroy((struct cdi_driver*) driver); +} + +/*static void rpc_pipe(pid_t pid, dword correlation_id, size_t data_size, + void* data) +{ + struct { + void (*call_address)(struct cdi_usb_device*); + struct cdi_usb_device dev_data; + struct cdi_usb_hc hc_data; + struct cdi_usb_endpoint ep0; + }* drv_dev = data; + struct cdi_usb_pipe ep0_pipe = { + .device = &drv_dev->dev_data, + .endpoint = &drv_dev->ep0, + .data_toggle = 0 + }; + + drv_dev->dev_data.hc = &drv_dev->hc_data; + drv_dev->dev_data.ep0 = &ep0_pipe; + drv_dev->call_address(&drv_dev->dev_data); + + rpc_send_dword_response(pid, correlation_id, 0); +}*/ + +void _init_usb_hcd(struct cdi_driver* drv) +{ + struct cdi_usb_hcd* driver = (struct cdi_usb_hcd*) drv; + struct cdi_usb_hc* hc; + int i; + + for (i = 0; (hc = cdi_list_get(drv->devices, i)) != NULL; i++) { + driver->find_devices(hc); + } +} diff --git a/src/modules/cdi/lib/usb.c b/src/modules/cdi/lib/usb.c new file mode 100644 index 0000000..a9f42e0 --- /dev/null +++ b/src/modules/cdi/lib/usb.c @@ -0,0 +1,425 @@ +//#include "init.h" +//#include "rpc.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +//#include "syscall.h" +//#include "unistd.h" + +#include "cdi/lists.h" +#include "cdi/usb.h" + +static cdi_list_t queued_usb_devices = NULL; +static cdi_list_t possible_usb_drivers = NULL; +static cdi_list_t usb_bus_drivers = NULL; +/*static struct cdi_usb_driver* bus_drivers = NULL; + +static pid_t service_usb = (pid_t)-1; +static dword bus_drivers_shm_id = 0; +static int has_handler = 0; +static int has_parent_handler = 0;*/ + +static char *class_name[] = +{ + "TSNH", //"This should never happen" - Von Composite Devices sollte einer + //der Interface-Class-Codes geliefert werden + "Audiogeraet", + "Kommunikationsgeraet", + "HID", + "???", //Hm, ja. Undefiniert. + "PID", + "Bildgeraet", + "Drucker", + "Massenspeicher", + "Hub", + "CDC-Datengeraet", + "Chipkarte", + "Sicherheitsgeraet", + "Videogeraet", + "Healthcare-Geraet" +}; + +/*static void dev_reset(struct cdi_usb_device* device) +{ + struct { + void (*call_address)(struct cdi_usb_device*); + struct cdi_usb_device dev_data; + int driver_index; + } drv_dev; + + drv_dev.call_address = (void*) device->real_reset; + memcpy(&drv_dev.dev_data, device, sizeof(*device)); + drv_dev.driver_index = ((uintptr_t)device->drv - (uintptr_t)bus_drivers) / + sizeof(struct cdi_usb_driver); + + rpc_get_dword(device->ppid, "RESET", sizeof(drv_dev), + (char*) &drv_dev); +} + +static void _add_pipe(struct cdi_usb_pipe* pipe) +{ + struct cdi_usb_hcd* hcd; + struct { + void (*call_address)(struct cdi_usb_device*); + struct cdi_usb_device dev_data; + struct cdi_usb_hc hc_data; + struct cdi_usb_endpoint ep0; + } drv_dev; + + hcd = (struct cdi_usb_hcd*) pipe->device->hc->dev.driver; + drv_dev.call_address = (void*) hcd->real_add_pipe; + memcpy(&drv_dev.dev_data, pipe->device, sizeof(drv_dev.dev_data)); + memcpy(&drv_dev.hc_data, pipe->device->hc, sizeof(drv_dev.hc_data)); + memcpy(&drv_dev.ep0, pipe->endpoint, sizeof(drv_dev.ep0)); + + rpc_get_dword(hcd->pid, "ADD_PIPE", sizeof(drv_dev), + (char*) &drv_dev); +} + +static void rpc_reset(pid_t pid, dword correlation_id, size_t data_size, + void* data) +{ + struct { + void (*call_address)(struct cdi_usb_device*); + struct cdi_usb_device dev_data; + int driver_index; + }* drv_dev = data; + + drv_dev->dev_data.drv = &bus_drivers[drv_dev->driver_index]; + + drv_dev->call_address(&drv_dev->dev_data); + + rpc_send_dword_response(pid, correlation_id, 0); +} + +static void rpc_enum(pid_t pid, dword correlation_id, size_t data_size, + void* data) +{ + struct { + void (*call_address)(struct cdi_usb_device*); + struct cdi_usb_device dev_data; + struct cdi_usb_hc hc_data; + int driver_index; + }* drv_dev = data; + + drv_dev->dev_data.drv = &bus_drivers[drv_dev->driver_index]; + drv_dev->dev_data.hc = &drv_dev->hc_data; + drv_dev->dev_data.real_reset = (uintptr_t)drv_dev->dev_data.reset; + drv_dev->dev_data.reset = &dev_reset; + + drv_dev->call_address(&drv_dev->dev_data); + + rpc_send_dword_response(pid, correlation_id, 0); +}*/ + +void cdi_usb_driver_destroy(struct cdi_usb_driver* driver) +{ + cdi_driver_destroy((struct cdi_driver*) driver); +} + +void cdi_usb_driver_init(struct cdi_usb_driver* driver) +{ + if (driver == NULL) { + return; + } + + driver->drv.type = CDI_USB; + cdi_driver_init((struct cdi_driver*) driver); +} + +void cdi_usb_driver_register(struct cdi_usb_driver* driver) +{ + /*int len = strlen(driver->drv.name) + 1, i; + int* heap, off; + + if (service_usb == (pid_t)-1) { + service_usb = init_service_get("usb"); + } + + driver->pid = getpid(); + if (!has_handler) { + register_message_handler("ENUM", &rpc_enum); + has_handler = 1; + } + + if (!bus_drivers_shm_id) { + bus_drivers_shm_id = rpc_get_dword(service_usb, "USB_BUS_DRIVERS", 0, + NULL); + bus_drivers = open_shared_memory(bus_drivers_shm_id); + } + + heap = (int*) ((uintptr_t)bus_drivers + 32768); + off = *heap; + *heap += len; + memcpy((void*) ((uintptr_t)bus_drivers + 32772 + off), driver->drv.name, + len); + driver->drv.name = (const char*) ((uintptr_t)bus_drivers + 32772 + off); + driver->pointer_base = (uintptr_t)bus_drivers; + + for (i = 0; bus_drivers[i].drv.type; i++); + + memcpy(&bus_drivers[i], driver, sizeof(*driver));*/ + + if (usb_bus_drivers == NULL) { + usb_bus_drivers = cdi_list_create(); + } + cdi_list_push(usb_bus_drivers, driver); + + cdi_driver_register((struct cdi_driver*) driver); +} + +/*static void _enumerate(struct cdi_usb_device* device) +{ + struct { + uintptr_t call_address; + struct cdi_usb_device dev_data; + struct cdi_usb_hc hc_data; + int driver_index; + } drv_dev; + + drv_dev.call_address = device->drv->real_enum_device; + drv_dev.driver_index = ((uintptr_t)device->drv - (uintptr_t)bus_drivers) / + sizeof(struct cdi_usb_driver); + memcpy(&drv_dev.dev_data, device, sizeof(*device)); + memcpy(&drv_dev.hc_data, device->hc, sizeof(*device->hc)); + rpc_get_dword(device->drv->pid, "ENUM", sizeof(drv_dev), + (char *)&drv_dev); +}*/ + +void cdi_usb_device_init(struct cdi_usb_device* device) +{ + size_t i; + struct cdi_usb_driver* drv; + struct cdi_usb_device_pattern* pos_drv; + struct cdi_usb_device_pattern* best_drv = NULL; + enum { + MATCH_NOTHING = 0, + MATCH_CLASS = 1, + MATCH_CLASS_VENDOR = 2, + MATCH_CLASS_SUBCLASS = 3, + MATCH_CLASS_SUBCLASS_VENDOR = 4, + MATCH_CLASS_SUBCLASS_PROTOCOL = 5, + MATCH_CLASS_SUBCLASS_PROTOCOL_VENDOR = 6, + MATCH_VENDOR_DEVICE = 7 + } best_match; + + if (queued_usb_devices == NULL) { + queued_usb_devices = cdi_list_create(); + } + + /*if (!has_parent_handler) { + register_message_handler("RESET", &rpc_reset); + has_parent_handler = 1; + }*/ + + printf("[cdi.usb] "); + switch (device->speed) { + case CDI_USB_LOW_SPEED: + printf("Low"); + break; + case CDI_USB_FULL_SPEED: + printf("Full"); + break; + case CDI_USB_HIGH_SPEED: + printf("High"); + break; + case CDI_USB_SUPER_SPEED: + printf("Super"); + break; + } +// device->ppid = getpid(); + printf("-Speed-Geraet am Port %i (", device->port); + if (device->hub != NULL) { + printf("Hub %i) ", device->hub->id); + } else { + printf("HC %s) ", device->hc->dev.name); + } + + /* + //if (service_usb == (pid_t)-1) { + service_usb = init_service_get("usb"); + //} + + if (!bus_drivers_shm_id) { + bus_drivers_shm_id = rpc_get_dword(service_usb, "USB_BUS_DRIVERS", 0, + NULL); + bus_drivers = open_shared_memory(bus_drivers_shm_id); + } + */ + + //for (i = 0; (drv = &bus_drivers[i])->drv.type; i++) { + for (i = 0; (drv = cdi_list_get(usb_bus_drivers, i)) != NULL; i++) { +/* drv->real_enum_device = (uintptr_t)drv->enumerate_device; + drv->enumerate_device = &_enumerate;*/ + + if (drv->speeds & device->speed) { + device->drv = drv; + /*printf("-> %s\n", (char*) ((uintptr_t)bus_drivers + + (uintptr_t)drv->drv.name - drv->pointer_base));*/ + printf("-> %s\n", drv->drv.name); + + drv->enumerate_device(device); + + printf("[cdi.usb] "); + if (device->class_id < 0x10) { + printf("%s", class_name[device->class_id]); + } else { + switch (device->class_id) { + case 0xDC: + printf("Diagnosegeraet"); + break; + case 0xE0: + printf("Drahtloscontroller"); + break; + case 0xEF: + printf("Unbestimmtes Geraet"); + break; + case 0xFE: + printf("Softwarespezifisch"); + break; + case 0xFF: + printf("Herstellerspezifisch"); + break; + default: + printf("Unbekanntes Geraet"); + } + } + + printf(" %i@", device->id); + if (device->hub != NULL) + printf("%i", device->hub->id); + else + printf("%s:", device->hc->dev.name); + printf("/%i (%04X:%04X) - %02X/%02X/%02X\n", device->port, + device->vendor_id, device->device_id, device->class_id, + device->subclass_id, device->protocol_id); + + best_match = MATCH_NOTHING; + if (possible_usb_drivers != NULL) { + for (i = 0; (pos_drv = cdi_list_get(possible_usb_drivers, i)) + != NULL; i++) + { + if (pos_drv->vendor_id == device->vendor_id) { + if (pos_drv->device_id == device->device_id) { + best_match = MATCH_VENDOR_DEVICE; + best_drv = pos_drv; + break; + } else if (pos_drv->device_id != -1) { + continue; + } else if (pos_drv->class_id == device->class_id) { + if (pos_drv->subclass_id == device->subclass_id) { + if (pos_drv->protocol_id == + device->protocol_id) + { + best_match = + MATCH_CLASS_SUBCLASS_PROTOCOL_VENDOR; + best_drv = pos_drv; + continue; + } else if (pos_drv->protocol_id != -1) { + continue; + } + if (best_match < MATCH_CLASS_SUBCLASS_VENDOR) { + best_match = MATCH_CLASS_SUBCLASS_VENDOR; + best_drv = pos_drv; + } + continue; + } else if (pos_drv->subclass_id != -1) { + continue; + } + if (best_match < MATCH_CLASS_VENDOR) { + best_match = MATCH_CLASS_VENDOR; + best_drv = pos_drv; + } + continue; + } + } else if (pos_drv->vendor_id != -1) { + continue; + } + if (pos_drv->class_id == device->class_id) { + if (pos_drv->subclass_id == device->subclass_id) { + if (pos_drv->protocol_id == device->protocol_id) { + if (best_match < MATCH_CLASS_SUBCLASS_PROTOCOL) + { + best_match = MATCH_CLASS_SUBCLASS_PROTOCOL; + best_drv = pos_drv; + } + continue; + } else if (pos_drv->protocol_id != -1) { + continue; + } + if (best_match < MATCH_CLASS_SUBCLASS) { + best_match = MATCH_CLASS_SUBCLASS; + best_drv = pos_drv; + } + continue; + } else if (pos_drv->subclass_id != -1) { + continue; + } + if (best_match < MATCH_CLASS) { + best_match = MATCH_CLASS; + best_drv = pos_drv; + } + continue; + } + } + } + + if ((best_match == MATCH_NOTHING) || + !best_drv->take_usb_device(device)) + { + printf("[cdi.usb] Derzeit kein passender USB-Geraetetreiber" + "vorhanden...\n"); + cdi_list_push(queued_usb_devices, device); + } + + return; + } + } + + printf("-> kein passender USB-Bustreiber.\n"); +} + +void cdi_usb_register_device_pattern(struct cdi_usb_device_pattern* pattern) +{ + struct cdi_usb_device* dev; + int i; + + if (pattern == NULL) { + return; + } + + if (possible_usb_drivers == NULL) { + possible_usb_drivers = cdi_list_create(); + } + + cdi_list_push(possible_usb_drivers, pattern); + + for (i = 0; (dev = cdi_list_get(queued_usb_devices, i)) != NULL; i++) { + if ((pattern->vendor_id != dev->vendor_id) && + (pattern->vendor_id != -1)) + { + continue; + } + if ((pattern->device_id != dev->device_id) && + (pattern->device_id != -1)) + { + continue; + } + if ((pattern->class_id != dev->class_id) && (pattern->class_id != -1)) { + continue; + } + if ((pattern->subclass_id != dev->subclass_id) && + (pattern->subclass_id != -1)) + { + continue; + } + if ((pattern->protocol_id != dev->protocol_id) && + (pattern->protocol_id != -1)) + { + continue; + } + if (pattern->take_usb_device(dev)) { + cdi_list_remove(queued_usb_devices, i); + } + } +} -- 1.6.4.2 From max at tyndur.org Mon Dec 14 19:24:24 2009 From: max at tyndur.org (max at tyndur.org) Date: Mon, 14 Dec 2009 19:24:24 +0100 Subject: [tyndur-devel] [PATCH 2/3] GNU99 In-Reply-To: <1260815065-30874-1-git-send-email-max@tyndur.org> References: <1260815065-30874-1-git-send-email-max@tyndur.org> Message-ID: <1260815065-30874-2-git-send-email-max@tyndur.org> From: Max Reitz * Wenn CDI -std=gnu99 benutzt, dann muss týndur das auch, um diese Treiber nutzen zu können Signed-off-by: Max Reitz --- config.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/config.sh b/config.sh index 0ae1246..b6dede6 100644 --- a/config.sh +++ b/config.sh @@ -33,7 +33,7 @@ else LOST_TOOLS_AR=$COMPILER_PREFIX"ar" LOST_TOOLS_AS=$COMPILER_PREFIX"as -32" LOST_TOOLS_LD=$COMPILER_PREFIX"ld -m elf_i386" - LOST_TOOLS_GCC=$COMPILER_PREFIX"gcc -m32 -g -c -fno-stack-protector -nostdinc -fno-leading-underscore -fno-omit-frame-pointer -Wall -Werror -Wstrict-prototypes -fno-strict-aliasing -O2 -fno-builtin -I ." + LOST_TOOLS_GCC=$COMPILER_PREFIX"gcc -m32 -g -c -fno-stack-protector -nostdinc -fno-leading-underscore -fno-omit-frame-pointer -Wall -Werror -std=gnu99 -Wstrict-prototypes -fno-strict-aliasing -O2 -fno-builtin -I ." LOST_TOOLS_GPP=$COMPILER_PREFIX"g++ -m32 -g -c -fno-stack-protector -fno-leading-underscore -fno-omit-frame-pointer -Wall -fno-strict-aliasing -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-use-cxa-atexit -O0" LOST_TOOLS_OBJCOPY=$COMPILER_PREFIX"objcopy -B i386:i386" LOST_TOOLS_STRIP=$COMPILER_PREFIX"strip -F elf32-i386" -- 1.6.4.2 From max at tyndur.org Mon Dec 14 19:24:25 2009 From: max at tyndur.org (max at tyndur.org) Date: Mon, 14 Dec 2009 19:24:25 +0100 Subject: [tyndur-devel] [PATCH 3/3] OHCI, UHCI, USB 1.1, USB-MSD In-Reply-To: <1260815065-30874-1-git-send-email-max@tyndur.org> References: <1260815065-30874-1-git-send-email-max@tyndur.org> Message-ID: <1260815065-30874-3-git-send-email-max@tyndur.org> From: Max Reitz + OHCI-Treiber + UHCI-Treiber + USB-1.1-Treiber + USB-Massenspeichertreiber + Gemeinsame Makefile.all für alle, damit sie in einer Binary landen (wie von der aktuellen CDI.usb- bzw. CDI.usb-hcd-Lib gefordert) Signed-off-by: Max Reitz --- src/modules/cdi/Makefile.all | 6 + src/modules/cdi/ohci/Makefile.all | 2 + src/modules/cdi/ohci/hcd.c | 335 ++++++++++++++++ src/modules/cdi/ohci/include/ohci-hcd.h | 39 ++ src/modules/cdi/ohci/include/ohci-init.h | 31 ++ src/modules/cdi/ohci/include/ohci-transfer.h | 30 ++ src/modules/cdi/ohci/include/ohci.h | 283 +++++++++++++ src/modules/cdi/ohci/init.c | 249 ++++++++++++ src/modules/cdi/ohci/main.c | 32 ++ src/modules/cdi/ohci/transfer.c | 85 ++++ src/modules/cdi/uhci/Makefile.all | 2 + src/modules/cdi/uhci/hcd.c | 215 ++++++++++ src/modules/cdi/uhci/include/uhci-hcd.h | 39 ++ src/modules/cdi/uhci/include/uhci-init.h | 31 ++ src/modules/cdi/uhci/include/uhci-transfer.h | 30 ++ src/modules/cdi/uhci/include/uhci.h | 138 +++++++ src/modules/cdi/uhci/init.c | 257 ++++++++++++ src/modules/cdi/uhci/main.c | 32 ++ src/modules/cdi/uhci/transfer.c | 91 +++++ src/modules/cdi/usb-msd/Makefile.all | 2 + src/modules/cdi/usb-msd/include/msd.h | 121 ++++++ src/modules/cdi/usb-msd/main.c | 74 ++++ src/modules/cdi/usb-msd/msd.c | 555 ++++++++++++++++++++++++++ src/modules/cdi/usb11/Makefile.all | 2 + src/modules/cdi/usb11/control.c | 252 ++++++++++++ src/modules/cdi/usb11/include/control.h | 31 ++ src/modules/cdi/usb11/include/transfer.h | 38 ++ src/modules/cdi/usb11/include/usb-structs.h | 184 +++++++++ src/modules/cdi/usb11/include/usb11.h | 41 ++ src/modules/cdi/usb11/main.c | 82 ++++ src/modules/cdi/usb11/transfer.c | 223 +++++++++++ 31 files changed, 3532 insertions(+), 0 deletions(-) create mode 100644 src/modules/cdi/Makefile.all create mode 100644 src/modules/cdi/ohci/Makefile.all create mode 100644 src/modules/cdi/ohci/hcd.c create mode 100644 src/modules/cdi/ohci/include/ohci-hcd.h create mode 100644 src/modules/cdi/ohci/include/ohci-init.h create mode 100644 src/modules/cdi/ohci/include/ohci-transfer.h create mode 100644 src/modules/cdi/ohci/include/ohci.h create mode 100644 src/modules/cdi/ohci/init.c create mode 100644 src/modules/cdi/ohci/main.c create mode 100644 src/modules/cdi/ohci/transfer.c create mode 100644 src/modules/cdi/uhci/Makefile.all create mode 100644 src/modules/cdi/uhci/hcd.c create mode 100644 src/modules/cdi/uhci/include/uhci-hcd.h create mode 100644 src/modules/cdi/uhci/include/uhci-init.h create mode 100644 src/modules/cdi/uhci/include/uhci-transfer.h create mode 100644 src/modules/cdi/uhci/include/uhci.h create mode 100644 src/modules/cdi/uhci/init.c create mode 100644 src/modules/cdi/uhci/main.c create mode 100644 src/modules/cdi/uhci/transfer.c create mode 100644 src/modules/cdi/usb-msd/Makefile.all create mode 100644 src/modules/cdi/usb-msd/include/msd.h create mode 100644 src/modules/cdi/usb-msd/main.c create mode 100644 src/modules/cdi/usb-msd/msd.c create mode 100644 src/modules/cdi/usb11/Makefile.all create mode 100644 src/modules/cdi/usb11/control.c create mode 100644 src/modules/cdi/usb11/include/control.h create mode 100644 src/modules/cdi/usb11/include/transfer.h create mode 100644 src/modules/cdi/usb11/include/usb-structs.h create mode 100644 src/modules/cdi/usb11/include/usb11.h create mode 100644 src/modules/cdi/usb11/main.c create mode 100644 src/modules/cdi/usb11/transfer.c diff --git a/src/modules/cdi/Makefile.all b/src/modules/cdi/Makefile.all new file mode 100644 index 0000000..19a4827 --- /dev/null +++ b/src/modules/cdi/Makefile.all @@ -0,0 +1,6 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh + +echo "LD $1/modules/usb" +$LOST_TOOLS_LD -Ttext=0x40000000 -ousb.mod usb11/*.o ohci/*.o uhci/*.o usb-msd/*.o --start-group $2 --end-group +$LOST_TOOLS_STRIP -s usb.mod -o $1/modules/usb diff --git a/src/modules/cdi/ohci/Makefile.all b/src/modules/cdi/ohci/Makefile.all new file mode 100644 index 0000000..e027b50 --- /dev/null +++ b/src/modules/cdi/ohci/Makefile.all @@ -0,0 +1,2 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh diff --git a/src/modules/cdi/ohci/hcd.c b/src/modules/cdi/ohci/hcd.c new file mode 100644 index 0000000..5cf8630 --- /dev/null +++ b/src/modules/cdi/ohci/hcd.c @@ -0,0 +1,335 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "ohci.h" +#include "ohci-hcd.h" + +static void reset_device(struct cdi_usb_device *device); + +static void find_devices(struct cdi_usb_hc *device) +{ + struct ohci *ohci = (struct ohci *)device; + struct cdi_usb_device *dev; + int i; + + d0printf("Scanning root ports\n"); + for (i = 0; i < ohci->root_ports; i++) { + if (!(ohci->memory->hc_rh_port_status[i] & OHC_RP_CCS)) { + continue; + } + dev = calloc(1, sizeof(struct cdi_usb_device)); + dev->hc = device; + dev->id = 0; + dev->port = i; + dev->speed = (ohci->memory->hc_rh_port_status[i] & OHC_RP_LSDA) ? + CDI_USB_LOW_SPEED : CDI_USB_FULL_SPEED; + dev->reset = &reset_device; + cdi_usb_device_init(dev); + } +} + +static void activate_device(struct cdi_usb_device *device) +{ + struct ohci *ohci = (struct ohci *)device->hc; + + if (device->hub != NULL) { + return; + } + + d1printf("Activating device on port %i.\n", device->port); + ohci->memory->hc_rh_port_status[device->port] |= OHC_RP_PES; + cdi_sleep_ms(20); +} + +static void reset_device(struct cdi_usb_device *device) +{ + struct ohci *ohci = (struct ohci *)device->hc; + + if (device->hub != NULL) { + return; + } + + d1printf("Resetting device on port %i.\n", device->port); + ohci->memory->hc_rh_port_status[device->port] |= OHC_RP_PRS; + cdi_sleep_ms(20); +} + +static void add_pipe(struct cdi_usb_pipe *pipe) +{ + struct ohci *ohci = (struct ohci *)pipe->device->hc; + struct ohci_ed *ved; + uintptr_t ped; + struct ohci_ed_desc *dsc; + //TODO Mehr als Control und Bulk + int iscontrol = 0; + + if (mempool_get(ohci->ed_pool, (void **)&ved, &ped) == -1) { + return; + } + ved->function = pipe->device->id; + ved->endpoint = pipe->endpoint->endpoint_address; + if (ved->endpoint == 0) { + //EP0 + ved->direction = OHC_ED_DIR_TD; + iscontrol = 1; + } else if (pipe->endpoint->endpoint_address & 0x80) { + ved->direction = OHC_ED_DIR_IN; + } else { + ved->direction = OHC_ED_DIR_OUT; + } + ved->low_speed = !!(pipe->device->speed == CDI_USB_LOW_SPEED); + ved->skip = 0; + ved->format = 0; + ved->mps = pipe->endpoint->max_packet_size; + ved->td_queue_tail = 0; + ved->td_queue_head = 0; + dsc = cdi_list_get(ohci->ed_list, 0); + if (dsc == NULL) { + ved->next_ed = 0; + } else { + ved->next_ed = dsc->phys; + } + dsc = malloc(sizeof(*dsc)); + if (dsc == NULL) { + mempool_put(ohci->ed_pool, ved); + return; + } + dsc->virt = ved; + dsc->phys = ped; + dsc->function = pipe->device->id; + dsc->endpoint = pipe->endpoint->endpoint_address; + dsc->type = iscontrol ? USB_CONTROL : USB_BULK; + dsc->transfers = cdi_list_create(); + cdi_list_push(ohci->ed_list, dsc); + + if (iscontrol) { + ohci->memory->hc_control_head_ed = ped; + } else { + ohci->memory->hc_bulk_head_ed = ped; + } +} + +static inline int _tsl(volatile int *variable) +{ + int rval; + rval = *variable; + *variable = 1; + return rval; +} + +static volatile int locked = 0; + +static cdi_usb_status_t do_some_packets(struct cdi_usb_packet *packets, + size_t num_packets) +{ + struct ohci_ed_desc *edsc; + struct ohci_td_desc *tdsc, *otdsc; + int i, j, cond, toggle, done_packets; + struct ohci *ohci = (struct ohci *)packets[0].pipe->device->hc; + struct ohci_td *vtd[num_packets]; + uintptr_t ptd[num_packets]; + + for (i = 0; (edsc = cdi_list_get(ohci->ed_list, i)) != NULL; i++) { + if ((edsc->function == packets[0].pipe->device->id) && + (edsc->endpoint == packets[0].pipe->endpoint->endpoint_address)) + { + break; + } + } + if (edsc == NULL) { + return CDI_USB_TIMEOUT; //Genau das würde passieren + } + + toggle = packets[0].pipe->data_toggle; + for (i = 0; i < (int)num_packets; i++) { + if (mempool_get(ohci->transfer_pool, (void **)&vtd[i], &ptd[i]) == -1) + { + return CDI_USB_TRIVIAL_ERROR; + } + if ((packets[i].data != NULL) && + (packets[i].type != CDI_USB_PACKET_IN)) + { + memcpy((void *)((uintptr_t)vtd[i] + sizeof(struct ohci_td)), + packets[i].data, packets[i].length); + } + vtd[i]->rounding = 1; //Warum nicht + switch (packets[i].type) { + case CDI_USB_PACKET_SETUP: + vtd[i]->direction = OHC_TD_DIR_SETUP; + break; + case CDI_USB_PACKET_IN: + vtd[i]->direction = OHC_TD_DIR_IN; + break; + case CDI_USB_PACKET_OUT: + vtd[i]->direction = OHC_TD_DIR_OUT; + break; + default: //Hm, passt nicht ganz + for (j = 0; j <= i; j++) { + mempool_put(ohci->transfer_pool, vtd[j]); + } + return CDI_USB_TRIVIAL_ERROR; + } + vtd[i]->di = 0; + if (packets[i].use_toggle == TOGGLE_0) { + toggle = 0; + } else if (packets[i].use_toggle == TOGGLE_1) { + toggle = 1; + } + vtd[i]->toggle = 0x2 | toggle; + toggle ^= 1; + vtd[i]->error = 0; + vtd[i]->condition = 15; + if ((packets[i].data == NULL) || !packets[i].length) { + vtd[i]->current_buffer_pointer = 0; + vtd[i]->buffer_end = 0; + } else { + vtd[i]->current_buffer_pointer = ptd[i] + sizeof(struct ohci_td); + vtd[i]->buffer_end = ptd[i] + + sizeof(struct ohci_td) + packets[i].length - 1; + } + vtd[i]->next_td = 0; + tdsc = malloc(sizeof(*tdsc)); + if (tdsc == NULL) { + for (j = 0; j <= i; j++) { + mempool_put(ohci->transfer_pool, vtd[j]); + } + return CDI_USB_TRIVIAL_ERROR; + } + tdsc->virt = vtd[i]; + tdsc->phys = ptd[i]; + tdsc->endpoint = edsc; + + if (cdi_list_size(edsc->transfers)) { + otdsc = cdi_list_get(edsc->transfers, 0); + otdsc->virt->next_td = ptd[i]; + } + if (!edsc->virt->td_queue_head) { + edsc->virt->td_queue_head = ptd[i]; + } + + cdi_list_push(edsc->transfers, tdsc); + } + packets[0].pipe->data_toggle = toggle; + if (edsc->type == USB_CONTROL) { + ohci->memory->hc_command_status |= OHC_CMST_CLF; + } else if (edsc->type == USB_BULK) { + ohci->memory->hc_command_status |= OHC_CMST_BLF; + } + done_packets = 0; + cond = CDI_USB_NO_ERROR; + while (done_packets < (int)num_packets) { + cdi_sleep_ms(1); + for (i = 0; i < (int)num_packets; i++) { + if (vtd[i]->condition != 15) { + done_packets++; + switch (vtd[i]->condition) { + case 0x00: + packets[i].condition = CDI_USB_NO_ERROR; + break; + case 0x02: + packets[i].condition = CDI_USB_BITSTUFF; + break; + case 0x04: + packets[i].condition = CDI_USB_STALLED; + for (j = 0; j < (int)num_packets; j++) { + //Allet, was nicht fertig ist, ist STALLed + vtd[j]->condition = 0x04; + } + break; + case 0x05: + packets[i].condition = CDI_USB_TIMEOUT; + break; + case 0x08: + packets[i].condition = CDI_USB_BABBLE; + break; + case 0x0C: + case 0x0D: + packets[i].condition = CDI_USB_BUFFER_ERROR; + break; + default: + packets[i].condition = CDI_USB_CRC; + break; + } + cond |= packets[i].condition; + vtd[i]->condition = 15; //Nicht nochmal überprüfen + } + } + } + for (i = 0; i < (int)num_packets; i++) { + if ((packets[i].data != NULL) && + (packets[i].type == CDI_USB_PACKET_IN)) + { + memcpy(packets[i].data, (void *)((uintptr_t)vtd[i] + + sizeof(struct ohci_td)), packets[i].length); + } + if (vtd[i]->next_td == 0) { + edsc->virt->td_queue_head = 0; + } + mempool_put(ohci->transfer_pool, vtd[i]); + } + if (cond & CDI_USB_STALLED) { + //Transferliste für diesen Endpoint leeren + edsc->virt->td_queue_head = 0; + while ((tdsc = cdi_list_pop(edsc->transfers)) != NULL) { + free(tdsc); + } + edsc->virt->td_queue_tail = 0; //Weitermachen + } + return cond; +} + +static cdi_usb_status_t do_packets(struct cdi_usb_packet *packets, + size_t num_packets) +{ + int i; + cdi_usb_status_t error; + + for (i = 0; i < (int)num_packets; i += 48) { + error = do_some_packets(&packets[i], + (num_packets - i > 48) ? 48 : (num_packets - i)); + if (error != CDI_USB_NO_ERROR) { + break; + } + } + + for (; i < (int)num_packets; i++) { + packets[i].condition = CDI_USB_NAK; + } + + return error; +} + +const struct ohci_functions ohci_functions = { + .find_devices = &find_devices, + .activate_device = &activate_device, + .send_packets = &do_packets, + .add_pipe = &add_pipe +}; diff --git a/src/modules/cdi/ohci/include/ohci-hcd.h b/src/modules/cdi/ohci/include/ohci-hcd.h new file mode 100644 index 0000000..ccb6345 --- /dev/null +++ b/src/modules/cdi/ohci/include/ohci-hcd.h @@ -0,0 +1,39 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef UHCI_HCD_H +#define UHCI_HCD_H + +#include +#include + +struct ohci_functions { + void (*find_devices)(struct cdi_usb_hc *device); + void (*activate_device)(struct cdi_usb_device *device); + cdi_usb_status_t (*send_packets)(struct cdi_usb_packet *packets, + size_t num_packets); + void (*add_pipe)(struct cdi_usb_pipe *pipe); +}; + +cdi_list_t ohci_find_devices(struct cdi_usb_hc *device); + +#endif diff --git a/src/modules/cdi/ohci/include/ohci-init.h b/src/modules/cdi/ohci/include/ohci-init.h new file mode 100644 index 0000000..2f19d2c --- /dev/null +++ b/src/modules/cdi/ohci/include/ohci-init.h @@ -0,0 +1,31 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef OHCI_INIT_H +#define OHCI_INIT_H + +#include "ohci.h" + +void find_and_init_ohcis(void); +void ohci_init(struct cdi_device *dev); + +#endif diff --git a/src/modules/cdi/ohci/include/ohci-transfer.h b/src/modules/cdi/ohci/include/ohci-transfer.h new file mode 100644 index 0000000..a6dc6be --- /dev/null +++ b/src/modules/cdi/ohci/include/ohci-transfer.h @@ -0,0 +1,30 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef OHCI_TRANSFER_H +#define OHCI_TRANSFER_H + +#include + +void ohci_handler(struct cdi_device *cdi_hci); + +#endif diff --git a/src/modules/cdi/ohci/include/ohci.h b/src/modules/cdi/ohci/include/ohci.h new file mode 100644 index 0000000..b06a280 --- /dev/null +++ b/src/modules/cdi/ohci/include/ohci.h @@ -0,0 +1,283 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef OHCI_H +#define OHCI_H + +#include +#include + +#include +#include +#include + +#include "ohci.h" + + +//#define DEBUG + +#ifdef DEBUG +#define d1printf(...) printf("[ohci] " __VA_ARGS__) +#define _d1printf(...) printf(__VA_ARGS__) +#else +#define d1printf(...) +#define _d1printf(...) +#endif + +#define d0printf(...) printf("[ohci] " __VA_ARGS__) +#define _d0printf(...) printf(__VA_ARGS__) + + +#define OHC_USB_RESET 0x00000000 +#define OHC_USB_RESUME 0x00000040 +#define OHC_USB_OPERATIONAL 0x00000080 +#define OHC_USB_SUSPEND 0x000000C0 + +#define OHC_CTRL_CBSR 0x00000003 //Verhältnis zwischen Control und Bulk + //(cbsr+1 zu 1) +#define OHC_CTRL_PLE 0x00000004 //Periodische Transfers aktivieren +#define OHC_CTRL_IE 0x00000008 //Isochronous-Transfers aktivieren +#define OHC_CTRL_CLE 0x00000010 //Control-Transfers aktivieren +#define OHC_CTRL_BLE 0x00000020 //Bulk-Transfers aktivieren +#define OHC_CTRL_HCFS 0x000000C0 //Status des HCs +#define OHC_CTRL_IR 0x00000100 //Wenn gesetzt, dann werden IRQs zum SMB + //geleitet +#define OHC_CTRL_RWC 0x00000200 //Remote wakeup untersetützt +#define OHC_CTRL_RW 0x00000400 //Remote wakeup aktivieren + +#define OHC_CMST_RESET 0x00000001 //Reset +#define OHC_CMST_CLF 0x00000002 //Control list filled (muss gesetzt werden, + //wenn ein Eintrag zur Controlliste + //hinzugefügt wird) +#define OHC_CMST_BLF 0x00000004 //Bulk list filled (muss gesetzt werden, wenn + //ein Eintrag zur Bulkliste hinzugefügt wird) +#define OHC_CMST_OCR 0x00000008 //Ownership change request +#define OHC_CMST_SOC 0x00030000 //Scheduling overrun count + +#define OHC_INT_SO 0x00000001 //Scheduling overrun +#define OHC_INT_WDH 0x00000002 //Write back done head +#define OHC_INT_SF 0x00000004 //Start of frame (wird bei SOF gesetzt) +#define OHC_INT_RD 0x00000008 //Resume detected (wird bei einem von einem + //Gerät gesendeten Resume gesetzt) +#define OHC_INT_UE 0x00000010 //Unrecoverable error (wird bei einem HC- + //Fehler gesetzt, der nichts mit USB zu tun + //hat) +#define OHC_INT_FNO 0x00000020 //Frame number overflow (wird gesetzt, wenn + //die Framenummer größer als 32767 und + //umgebrochen wird) +#define OHC_INT_RHSC 0x00000040 //Root hub status change (wird gesetzt, wenn + //sich irgendwas am Roothub geändert hat) +#define OHC_INT_OC 0x40000000 //Ownership change +#define OHC_INT_MIE 0x80000000 //(De-)Aktiviert Interrupts + +#define OHC_RHA_NDP 0x000000FF //Anzahl an Rootports (1 bis 15) +#define OHC_RHA_PSM 0x00000100 //Gesetzt, wenn man die Stromzufuhr zu + //einzelnen Ports unabhängig setzen kann +#define OHC_RHA_NPS 0x00000200 //Gelöscht, wenn man die Stromzufuhr zu + //einzelnen Ports unabhängig setzen kann +#define OHC_RHA_DT 0x00000400 //Immer 0, zeigt so an, dass der Roothub kein + //Compound device ist. +#define OHC_RHA_OCPM 0x00000800 //Gesetzt, wenn Überspannungen für jeden Port + //einzeln gemeldet werden +#define OHC_RHA_NOCP 0x00001000 //Gesetzt, wenn keine Überspannungen erkannt + //bzw. verhindert werden können +#define OHC_RHA_POTPGT 0xFF000000 //Power on to power good time (potpgt * 2) + +#define OHC_RHS_LPS 0x00000001 //R: 0 + //W: Strom abdrehen +#define OHC_RHS_OCI 0x00000002 //R: Unspezifische Überspannung +#define OHC_RHS_DRWE 0x00008000 //R: Irgendwas mit Remote Wakeup Enable + //W: Das aktivieren +#define OHC_RHS_LPSC 0x00010000 //R: 0 + //W: Strom andrehen +#define OHC_RHS_OCIC 0x00020000 //R: Bei Änderungen von OCI gesetzt + //W: Feld löschen +#define OHC_RHS_CRWE 0x80000000 //W: Remote Wakeup Enable deaktivieren + +#define OHC_RP_CCS 0x00000001 //R: Gerät angeschlossen + //W: Deaktiviert den Port +#define OHC_RP_PES 0x00000002 //R: Port aktiviert + //W: Aktiviert den Port +#define OHC_RP_PSS 0x00000004 //R: Port schläft + //W: Schläfert den Port ein +#define OHC_RP_POCI 0x00000008 //R: Überspannung + //W: Port aufwecken +#define OHC_RP_PRS 0x00000010 //R: Reset läuft + //W: Reset treiben +#define OHC_RP_PPS 0x00000100 //R: Strom an + //W: Strom andrehen +#define OHC_RP_LSDA 0x00000200 //R: Low-Speed-Gerät + //W: Strom abdrehen +#define OHC_RP_CSC 0x00010000 //R: Gerät an- oder abgezogen + //W: Bit löschen +#define OHC_RP_PESC 0x00020000 //R: Port (de-)aktiviert + //W: Bit löschen +#define OHC_RP_PSSC 0x00040000 //R: Port wurde geweckt + //W: Bit löschen +#define OHC_RP_OCIC 0x00080000 //R: Überspannungsbit verändert + //W: Bit löschen +#define OHC_RP_PRSC 0x00100000 //R: Reset beendet + //W: Bit löschen + +struct ohci_registers +{ + uint32_t hc_revision; //Revision + volatile uint32_t hc_control; + volatile uint32_t hc_command_status; + volatile uint32_t hc_interrupt_status; + volatile uint32_t hc_interrupt_enable; + volatile uint32_t hc_interrupt_disable; + uint32_t hc_hcca; //Adresse des HCCA + volatile uint32_t hc_period_current_ed; //Adresse des aktuellen + //Endpointdescriptors der + //periodischen Transfers + uint32_t hc_control_head_ed; //Adresse des ersten Endpointdescriptors der + //Control-Transfers + volatile uint32_t hc_control_current_ed; //Adresse des aktuellen + //Endpointdescriptors der Control- + //Transfers + uint32_t hc_bulk_head_ed; //Adresse des ersten Endpointdescriptors der + //Bulk-Transfers + volatile uint32_t hc_bulk_current_ed; //Adresse des aktuellen + //Endpointdescriptors der Bulk- + //Transfers + volatile uint32_t hc_done_head; //Adresse des zuletzt abgearbeiteten + //Transferdeskriptors, der der Done-Liste + //hinzugefügt wurde + uint32_t hc_fm_interval; //Gibt die Länge eines Frames und die maximale + //Paketgröße an + volatile uint32_t hc_fm_remaining; //Verbleibende Takte des aktuellen + //Frames + volatile uint32_t hc_fm_number; //Nummer des aktuellen Frames + uint32_t hc_periodic_start; //10% von HcFmInterval, wenn HcFmInterval + //diesen Wert erreicht, dann haben periodische + //Transfers Vorrang + uint32_t hc_ls_threshold; //Besser nicht ändern + uint32_t hc_rh_descriptor_a; + uint32_t hc_rh_descriptor_b; + volatile uint32_t hc_rh_status; + volatile uint32_t hc_rh_port_status[]; +} __attribute__((packed)); + +struct ohci_legsup +{ + uint32_t hce_control; + uint32_t hce_input; + uint32_t hce_output; + uint32_t hce_status; +} __attribute__((packed)); + +struct ohci_hcca +{ + uint32_t interrupt_table[32]; //Zeiger zu Interrupt-EDs + uint16_t frame_number; //Die Nummer des aktuellen Frames + uint16_t pad; //Wird auf 0 gesetzt, wenn frame_number neu geschrieben wird + //(Ausrichten an DWord-Grenzen vermutlich) + uint32_t done_head; + uint8_t rsvd[116]; +} __attribute__((packed)); + +struct ohci +{ + struct cdi_usb_hc cdidev; + struct cdi_pci_device *pcidev; + + struct ohci_registers *memory; + struct ohci_legsup *legsup; + int root_ports; + struct ohci_hcca *hcca; + + struct mempool *ed_pool; + struct mempool *transfer_pool; + + cdi_list_t ed_list; +}; + +#define OHC_ED_DIR_TD 0 //Richtung im TD definiert +#define OHC_ED_DIR_OUT 1 +#define OHC_ED_DIR_IN 2 + +struct ohci_ed +{ + unsigned function : 7; //USB-Adresse des Geräts + unsigned endpoint : 4; //Nummer des Endpoints + unsigned direction : 2; //Richtung des Transfers + unsigned low_speed : 1; + unsigned skip : 1; + unsigned format : 1; //Bei Isochronous gesetzt + unsigned mps : 11; //Maximale Paketgröße + unsigned user : 5; //Für uns frei verfügbar + uint32_t td_queue_tail; //Letzter TD in der Warteschlange + volatile uint32_t td_queue_head; //Nächster TD in der Warteschlange + uint32_t next_ed; //Nächster ED +} __attribute__((packed)); + +struct ohci_ed_desc +{ + struct ohci_ed *virt; + uintptr_t phys; + int function; + int endpoint; + cdi_list_t transfers; + enum + { + USB_CONTROL, + USB_BULK + } type; +} __attribute__((packed)); + +#define OHC_TD_DIR_SETUP 0 +#define OHC_TD_DIR_OUT 1 +#define OHC_TD_DIR_IN 2 + +struct ohci_td +{ + unsigned user : 18; //Für uns frei verfügbar + unsigned rounding : 1; //Wenn gesetzt, dann sind zu kleine Pakete nicht so + //schlimm + unsigned direction : 2; //Richtung/Typ des Transfers (nur gültig, wenn das + //"direction"-Feld im ED 00b oder 11b ist) + unsigned di : 3; //Gibt an, wie viele Frames der HC vor Auslösen eines IRQs + //warten soll + unsigned toggle : 2; //Datatoggle (00b oder 01b - Wert muss aus dem ED + //ermittelt werden, 10b = DATA0, 11b = DATA1) + volatile unsigned error : 2; //Anzahl der aufgetretenen Fehler - bei 11b + //wird der Status im "condition"-Feld + //gespeichert. + volatile unsigned condition : 4; //Status + volatile uint32_t current_buffer_pointer; //Pointer zu den Daten (bei 0 + //wurden alle Daten übertragen) + uint32_t next_td; //Nächster TD + uint32_t buffer_end; //Letztes Datenbyte des Puffers +} __attribute__((packed)); + +struct ohci_td_desc +{ + struct ohci_td *virt; + uintptr_t phys; + struct ohci_ed_desc *endpoint; +} __attribute__((packed)); + +struct cdi_driver *init_ohcd(void); +void ohci_init(struct cdi_device *cdi_hci); + +#endif diff --git a/src/modules/cdi/ohci/init.c b/src/modules/cdi/ohci/init.c new file mode 100644 index 0000000..f2c9670 --- /dev/null +++ b/src/modules/cdi/ohci/init.c @@ -0,0 +1,249 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ohci.h" +#include "ohci-hcd.h" +#include "ohci-init.h" +#include "ohci-transfer.h" + +extern const struct ohci_functions ohci_functions; +extern int init_ohci(void); + +#define DRIVER_NAME "ohcd" + +static struct cdi_usb_hcd driver = { + .drv = { + .type = CDI_USB_HCD, + .name = DRIVER_NAME, + .devices = NULL, + .init_device = &ohci_init, + .remove_device = NULL, +#ifdef CDI_DRIVER + .init = &init_ohci, +#endif + .destroy = NULL + } +}; + +#ifdef CDI_DRIVER +CDI_DRIVER(DRIVER_NAME, driver) +#endif + +void find_and_init_ohcis(void) +{ + struct ohci *hci; + char *name; + int ohci_counter = 0; + struct cdi_pci_device *dev; + + cdi_usb_hcd_init(&driver); + + cdi_list_t pci_devices = cdi_list_create(); + cdi_pci_get_all_devices(pci_devices); + for (int i = 0; (dev = cdi_list_get(pci_devices, i)) != NULL; i++) { + if ((dev->class_id != 0x0C) || (dev->subclass_id != 0x03) + || (dev->interface_id != 0x10)) + { + cdi_pci_device_destroy(dev); + } else { + hci = malloc(sizeof(struct ohci)); + hci->cdidev.dev.type = CDI_USB_HCD; + name = malloc(7); + sprintf(name, "ohci%i", ohci_counter++); + hci->cdidev.dev.name = (const char *)name; + hci->cdidev.speed = CDI_USB_LOW_SPEED | CDI_USB_FULL_SPEED; + hci->pcidev = dev; + cdi_list_push(driver.drv.devices, hci); + } + } + + cdi_list_destroy(pci_devices); + + driver.find_devices = ohci_functions.find_devices; + driver.activate_device = ohci_functions.activate_device; + driver.send_packets = ohci_functions.send_packets; + driver.add_pipe = ohci_functions.add_pipe; + +#ifndef CDI_DRIVER + cdi_driver_register((struct cdi_driver*) &driver); +#endif +} + +void ohci_init(struct cdi_device *dev) +{ + struct ohci *ohci = (struct ohci *)dev; + struct cdi_pci_resource *res; + int i; + uintptr_t phys_hcca; + + ohci->memory = NULL; + for (i = 0; (res = cdi_list_get(ohci->pcidev->resources, i)) != NULL; + i++) + { + if (res->type == CDI_PCI_MEMORY) { + ohci->memory = cdi_alloc_phys_addr(res->length, res->start); + if (ohci->memory == NULL) { + d0printf("Wasn't able to allocate memory.\n"); + return; + } + ohci->legsup = (void *)((uintptr_t)ohci->memory + 0x100); + break; + } + } + if (ohci->memory == NULL) { + d1printf("Memory not found!\n"); + return; + } + d1printf("Memory @ 0x%08X\n", (uintptr_t)ohci->memory); + if ((ohci->memory->hc_revision & 0xFF) != 0x10) { + d0printf("This OHCI might be incompatible with this driver" + "(HCI %i.%i, HCD 1.0)\n", (ohci->memory->hc_revision & 0xF0) >> 4, + ohci->memory->hc_revision & 0xF); + } + if (cdi_alloc_phys_mem(sizeof(*ohci->hcca), (void **)&ohci->hcca, + (void **)&phys_hcca) == -1) + { + d0printf("Wasn't able to allocate HCCA.\n"); + return; + } + memset(ohci->hcca, 0, sizeof(*ohci->hcca)); + + d1printf("IRQ: %i\n", ohci->pcidev->irq); + cdi_register_irq(ohci->pcidev->irq, &ohci_handler, dev); + + ohci->ed_pool = mempool_create(64 * sizeof(struct ohci_ed), + sizeof(struct ohci_ed)); + if (ohci->ed_pool == NULL) { + d0printf("Wasn't able to create ED memory pool!\n"); + return; + } + + ohci->transfer_pool = mempool_create(48 * (1024 + sizeof(struct ohci_td)), + 1024 + sizeof(struct ohci_td)); + if (ohci->transfer_pool == NULL) { + d0printf("Wasn't able to create transfer memory pool!\n"); + return; + } + + ohci->memory->hc_interrupt_disable = OHC_INT_MIE; + + if (ohci->memory->hc_control & OHC_CTRL_IR) { + d1printf("Kicking out SMM... "); + //Änderung des "Besitzers" beantragen + ohci->memory->hc_command_status |= OHC_CMST_OCR; + for (i = 0; (ohci->memory->hc_control & OHC_CTRL_IR) && (i < 1000); + i++) + { + cdi_sleep_ms(1); + } + if (i < 100) { + _d1printf("Went fine.\n"); + } else { + _d1printf("Idiot.\n"); + ohci->memory->hc_control &= ~OHC_CTRL_IR; + } + } else if ((ohci->memory->hc_control & OHC_CTRL_CBSR) != OHC_USB_RESET) { + d1printf("BIOS active\n"); + if ((ohci->memory->hc_control & OHC_CTRL_CBSR) != OHC_USB_OPERATIONAL) + { + d1printf("Activating RESUME...\n"); + ohci->memory->hc_control = + (ohci->memory->hc_control & ~OHC_CTRL_CBSR) | OHC_USB_RESUME; + cdi_sleep_ms(10); + } + } else { + //Nix, weder BIOS noch SMM + cdi_sleep_ms(10); //Reset abwarten + } + + if (ohci->legsup->hce_control & 1) { + d1printf("USB legacy support activated, but that won't last for" + "long...\n"); + } + //Harhar, that's mine now! + ohci->legsup->hce_control = 0; + + ohci->memory->hc_command_status |= OHC_CMST_RESET; + //Normalerweise sollte man den Wert von hc_fm_interval von vor dem Reset + //wiederherstellen, aber ich finde das Schwachsinn. Die Werte sind so in + //Ordnung, wie sie jetzt sind. + + cdi_sleep_ms(3); //10 µs für den Reset und 2 ms für Resume + if ((ohci->memory->hc_control & OHC_CTRL_CBSR) == OHC_USB_SUSPEND) { + //Boah... + d1printf("Reset not finished yet...\n"); + ohci->memory->hc_control = + (ohci->memory->hc_control & ~OHC_CTRL_CBSR) | OHC_USB_RESUME; + cdi_sleep_ms(10); + } + + ohci->memory->hc_interrupt_disable = OHC_INT_MIE; + + ohci->memory->hc_hcca = phys_hcca; + ohci->memory->hc_interrupt_status = 0xFFFFFFFF; + ohci->memory->hc_interrupt_enable = + OHC_INT_SO | //Scheduling overrun + OHC_INT_WDH | //Write back done head + OHC_INT_RD | //Resume detected + OHC_INT_UE | //Schwerer Fehler + OHC_INT_RHSC | //Root hub status change + OHC_INT_MIE; + //Eigentlich sollte man alle Transfers aktivieren. Aber wir wollen ja noch + //gar keine periodischen Transfers... + //Periodisches Zeug deaktivieren + ohci->memory->hc_control &= ~(OHC_CTRL_PLE | OHC_CTRL_IE); + //Control und Bulk aktivieren + ohci->memory->hc_control |= OHC_CTRL_CLE | OHC_CTRL_BLE; + //Merkwürdigerweise soll das jetzt nicht auf 10 %, sondern auf 90 % gesetzt + //werden. Aber das klingt total bescheuert, weil nicht erklärt wird, wann + //man es denn auf 10 % setzen soll. Deshalb machen wir das gleich. + ohci->memory->hc_periodic_start = 0x4B0; + + d1printf("Activating HC.\n"); + + //DO IT, FAGGOT! + ohci->memory->hc_control = + (ohci->memory->hc_control & ~OHC_CTRL_CBSR) | OHC_USB_OPERATIONAL; + + ohci->memory->hc_rh_status |= OHC_RHS_LPSC; //Strom andrehen + ohci->root_ports = ohci->memory->hc_rh_descriptor_a & OHC_RHA_NDP; + cdi_sleep_ms((ohci->memory->hc_rh_descriptor_a & OHC_RHA_POTPGT) >> 23); + + d0printf("Found %i root ports.\n", ohci->root_ports); + + for (i = 0; i < ohci->root_ports; i++) { + ohci->memory->hc_rh_port_status[i] |= OHC_RP_CCS; //Deaktivieren + } + + ohci->ed_list = cdi_list_create(); +} diff --git a/src/modules/cdi/ohci/main.c b/src/modules/cdi/ohci/main.c new file mode 100644 index 0000000..323960a --- /dev/null +++ b/src/modules/cdi/ohci/main.c @@ -0,0 +1,32 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include + +#include "ohci-init.h" + +int init_ohci(void) +{ + find_and_init_ohcis(); + + return 0; +} diff --git a/src/modules/cdi/ohci/transfer.c b/src/modules/cdi/ohci/transfer.c new file mode 100644 index 0000000..24f7c67 --- /dev/null +++ b/src/modules/cdi/ohci/transfer.c @@ -0,0 +1,85 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include +#include +#include + +#include "ohci.h" + +void ohci_handler(struct cdi_device *cdi_hci) +{ + struct ohci *ohci = (struct ohci *)cdi_hci; + struct ohci_ed_desc *edsc; + struct ohci_td_desc *tdsc; + uint32_t status, done = 0; + int i, j; + uintptr_t phys; + + status = ohci->memory->hc_interrupt_status; + if (!status) { + return; //Wohl nicht für uns + } + + if (status & OHC_INT_RHSC) { + done |= OHC_INT_RHSC; + } + if (status & OHC_INT_UE) { + d0printf("Fatal HC error.\n"); + ohci->memory->hc_command_status |= OHC_CMST_RESET; + done |= OHC_INT_UE; + } + if (status & OHC_INT_SF) { + //Öhm... Na ja. Manchmal fragt man sich, ob sich der HC so einsam + //fühlt, dass er IRQs feuert, obwohl sie deaktiviert sind. + done |= OHC_INT_SF; + } + if (status & OHC_INT_WDH) { + //Paket gesendet + done |= OHC_INT_WDH; + phys = ohci->hcca->done_head; + for (i = 0; (edsc = cdi_list_get(ohci->ed_list, i)) != NULL; i++) { + for (j = 0; (tdsc = cdi_list_get(edsc->transfers, j)) != NULL; j++) + { + if (tdsc->phys == phys) { + //Das ist der fertige Transfer + cdi_list_remove(edsc->transfers, j); + free(tdsc); + break; + } + } + if (tdsc != NULL) { + //Gefunden + break; + } + } + } + + if (status & ~done) { + d1printf("Non-handled interrupt: 0x%08X\n", status & ~done); + } + + ohci->memory->hc_interrupt_status = status; +} diff --git a/src/modules/cdi/uhci/Makefile.all b/src/modules/cdi/uhci/Makefile.all new file mode 100644 index 0000000..e027b50 --- /dev/null +++ b/src/modules/cdi/uhci/Makefile.all @@ -0,0 +1,2 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh diff --git a/src/modules/cdi/uhci/hcd.c b/src/modules/cdi/uhci/hcd.c new file mode 100644 index 0000000..79f7481 --- /dev/null +++ b/src/modules/cdi/uhci/hcd.c @@ -0,0 +1,215 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "uhci.h" +#include "uhci-hcd.h" + +extern cdi_list_t uhci_active_transfers; + +static void reset_device(struct cdi_usb_device *device); + +static void find_devices(struct cdi_usb_hc *device) +{ + struct uhci *uhci = (struct uhci *)device; + struct cdi_usb_device *dev; + int i; + + d0printf("Scanning root ports\n"); + cdi_outw(uhci->pbase + UHCI_USBCMD, USB_RUN); + for (i = 0; i < uhci->root_ports; i++) { + if (!(cdi_inw(uhci->pbase + UHCI_RPORTS + 2 * i) & RPORT_DEVICE)) { + continue; + } + dev = calloc(1, sizeof(struct cdi_usb_device)); + dev->hc = device; + dev->id = 0; + dev->port = i; + dev->speed = (cdi_inw(uhci->pbase + UHCI_RPORTS + 2 * i) & + RPORT_LOSPD) ? CDI_USB_LOW_SPEED : CDI_USB_FULL_SPEED; + dev->hub = NULL; + dev->reset = &reset_device; + cdi_usb_device_init(dev); + } +} + +static void activate_device(struct cdi_usb_device *device) +{ + struct uhci *uhci = (struct uhci *)device->hc; + + if (device->hub != NULL) { + return; + } + + d1printf("Activating device on port %i.\n", device->port); + cdi_outw(uhci->pbase + UHCI_RPORTS + 2 * device->port, + RPORT_ENABLE | RPORT_CSC); + cdi_sleep_ms(20); +} + +static void reset_device(struct cdi_usb_device *device) +{ + struct uhci *uhci = (struct uhci *)device->hc; + + if (device->hub != NULL) { + return; + } + + d1printf("Resetting device on port %i.\n", device->port); + cdi_outw(uhci->pbase + UHCI_RPORTS + 2 * device->port, + RPORT_ENABLE | RPORT_RESET | RPORT_CSC); + cdi_sleep_ms(20); +} + +static void add_pipe(struct cdi_usb_pipe *pipe) +{ + //Macht nix, weil das bei UHCI nicht nötig ist + pipe = NULL; //Aber GCC können wir trotzdem glücklich machen +} + +static inline int _tsl(volatile int *variable) +{ + int rval; + rval = *variable; + *variable = 1; + return rval; +} + +static volatile int locked = 0; + +static cdi_usb_status_t do_packet(struct cdi_usb_packet *packet) +{ + struct cdi_usb_device *usbdev = packet->pipe->device; + struct uhci *uhci = (struct uhci *)usbdev->hc; + struct uhci_td td; + struct transfer addr; + int timeout, frame; + + void *buf; + uintptr_t pbuf; + + memset(&td, 0, sizeof(td)); + td.next = 1; //Invalid + td.active = 1; + td.ioc = 1; + if (packet->use_toggle == TOGGLE_0) { + packet->pipe->data_toggle = 0; + } else if (packet->use_toggle == TOGGLE_1) { + packet->pipe->data_toggle = 1; + } + td.data_toggle = packet->pipe->data_toggle; + packet->pipe->data_toggle ^= 1; + td.low_speed = !!(usbdev->speed == CDI_USB_LOW_SPEED); + td.errors = 1; + td.pid = packet->type; + td.device = usbdev->id; + td.endpoint = packet->pipe->endpoint->endpoint_address & 0x07; + td.maxlen = packet->length ? packet->length - 1 : 0x7FF; + while (_tsl(&locked)); + frame = (cdi_inw(uhci->pbase + UHCI_FRNUM) + 5) & 0x3FF; + while (!(uhci->queue_heads[frame].transfer & 1)) { + frame++; + frame &= 0x3FF; + } + + if (mempool_get(uhci->buffers, &buf, &pbuf) < 0) { + return CDI_USB_TRIVIAL_ERROR; + } + + addr.virt = buf; + addr.phys = pbuf; + addr.error = 0xFFFF; + + buf = (void *)((uintptr_t)buf + sizeof(td)); + pbuf += sizeof(td); + + if (!packet->length) { + td.buffer = 0; + } else { + td.buffer = pbuf; + if (packet->type != CDI_USB_PACKET_IN) { + memcpy(buf, packet->data, packet->length); + } + } + + memcpy(addr.virt, &td, sizeof(td)); + + + if (uhci_active_transfers == NULL) { + uhci_active_transfers = cdi_list_create(); + } + uhci->queue_heads[frame].transfer = addr.phys; + cdi_list_push(uhci_active_transfers, &addr); + + locked = 0; + for (timeout = 0; !(uhci->queue_heads[frame].transfer & 1) && + (timeout < 1000); timeout++) + { + cdi_sleep_ms(1); + } + while ((timeout < 1000) && (addr.error == 0xFFFF)) { +#ifndef CDI_STANDALONE + __asm__ __volatile__ ("hlt"); +#endif + } + if (packet->type == CDI_USB_PACKET_IN) { + memcpy(packet->data, buf, packet->length); + } + if (addr.error == 0xFFFF) { + addr.error = CDI_USB_TIMEOUT; + } + + mempool_put(uhci->buffers, addr.virt); + + return addr.error; +} + +static cdi_usb_status_t do_packets(struct cdi_usb_packet *packets, + size_t num_packets) +{ + size_t i; + cdi_usb_status_t cond = CDI_USB_NO_ERROR; + + //TODO + for (i = 0; (i < num_packets) && !cond; i++) { + packets[i].condition = do_packet(&packets[i]); + cond |= packets[i].condition; + } + + return cond; +} + + +const struct uhci_functions uhci_functions = { + .find_devices = &find_devices, + .activate_device = &activate_device, + .send_packets = &do_packets, + .add_pipe = &add_pipe +}; diff --git a/src/modules/cdi/uhci/include/uhci-hcd.h b/src/modules/cdi/uhci/include/uhci-hcd.h new file mode 100644 index 0000000..46e4093 --- /dev/null +++ b/src/modules/cdi/uhci/include/uhci-hcd.h @@ -0,0 +1,39 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef UHCI_HCD_H +#define UHCI_HCD_H + +#include +#include + +struct uhci_functions { + void (*find_devices)(struct cdi_usb_hc *device); + void (*activate_device)(struct cdi_usb_device *device); + cdi_usb_status_t (*send_packets)(struct cdi_usb_packet *packets, + size_t num_packets); + void (*add_pipe)(struct cdi_usb_pipe *pipe); +}; + +cdi_list_t uhci_find_devices(struct cdi_usb_hc *device); + +#endif diff --git a/src/modules/cdi/uhci/include/uhci-init.h b/src/modules/cdi/uhci/include/uhci-init.h new file mode 100644 index 0000000..7b357bc --- /dev/null +++ b/src/modules/cdi/uhci/include/uhci-init.h @@ -0,0 +1,31 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef UHCI_INIT_H +#define UHCI_INIT_H + +#include "uhci.h" + +void find_and_init_uhcis(void); +void uhci_init(struct cdi_device *dev); + +#endif diff --git a/src/modules/cdi/uhci/include/uhci-transfer.h b/src/modules/cdi/uhci/include/uhci-transfer.h new file mode 100644 index 0000000..53b46b0 --- /dev/null +++ b/src/modules/cdi/uhci/include/uhci-transfer.h @@ -0,0 +1,30 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef UHCI_TRANSFER_H +#define UHCI_TRANSFER_H + +#include + +void uhci_handler(struct cdi_device *cdi_hci); + +#endif diff --git a/src/modules/cdi/uhci/include/uhci.h b/src/modules/cdi/uhci/include/uhci.h new file mode 100644 index 0000000..678b2a1 --- /dev/null +++ b/src/modules/cdi/uhci/include/uhci.h @@ -0,0 +1,138 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef UHCI_H +#define UHCI_H + +#include +#include + +#include +#include +#include +#include + + +//#define DEBUG + +#ifdef DEBUG +#define d1printf(...) printf("[uhci] " __VA_ARGS__) +#define _d1printf(...) printf(__VA_ARGS__) +#else +#define d1printf(...) +#define _d1printf(...) +#endif + +#define d0printf(...) printf("[uhci] " __VA_ARGS__) +#define _d0printf(...) printf(__VA_ARGS__) + + +#define UHCI_USBCMD 0x00 //w +#define UHCI_USBSTS 0x02 //w +#define UHCI_USBINTR 0x04 //w +#define UHCI_FRNUM 0x06 //w +#define UHCI_FRBASEADD 0x08 //l +#define UHCI_SOFMOD 0x0C //b +#define UHCI_RPORTS 0x10 +#define UHCI_PORTSC1 0x10 //w +#define UHCI_PORTSC2 0x12 //w + +#define MAXP 0x0080 +#define CONFIGURE 0x0040 +#define GLOB_SUSP_MODE 0x0008 +#define GRESET 0x0004 +#define HCRESET 0x0002 +#define USB_RUN 0x0001 + +#define RPORT_RESET 0x0200 +#define RPORT_LOSPD 0x0100 //Low speed device attached +#define RPORT_ENABLE 0x0004 +#define RPORT_CSC 0x0002 //Connect status change +#define RPORT_DEVICE 0x0001 + +//Legacy support +#define UHCI_PCI_LEGSUP 0xC0 //w + +#define UHCI_LEGSUP_STATUS 0x8F00 //Statusbits, die mittels schreiben einer 1 + //gelöscht werden +#define UHCI_LEGSUP_NO_CHG 0x5040 //Bits, die nicht verändert werden können + //(RO bzw. reserviert) +#define UHCI_LEGSUP_PIRQ 0x2000 //Interrupt wird als PCI-IRQ ausgeführt + + +struct uhci_qh { + volatile uint32_t next; + volatile uint32_t transfer; + uint32_t align[2]; //Fürs korrekte Alignment (an 16 Bytes) +} __attribute__((packed)); + +struct uhci_td { + volatile uint32_t next; + + unsigned trans_len : 11; + unsigned rsvd0 : 6; + unsigned bitstuff_err : 1; + unsigned crc_time_err : 1; + unsigned nak : 1; + unsigned babble : 1; + unsigned buf_err : 1; + unsigned stalled_err : 1; + unsigned active : 1; + unsigned ioc : 1; + unsigned isochronous : 1; + unsigned low_speed : 1; + unsigned errors : 2; + unsigned spd : 1; + unsigned rsvd1 : 2; + + unsigned pid : 8; + unsigned device : 7; + unsigned endpoint : 4; + unsigned data_toggle : 1; + unsigned rsvd2 : 1; + unsigned maxlen : 11; + + uint32_t buffer; + + uint32_t user[4]; +} __attribute__((packed)); + +struct transfer { + void *virt; + uintptr_t phys; + volatile int error; +}; + +struct uhci { + struct cdi_usb_hc cdidev; + struct cdi_pci_device *pcidev; + int pbase; + uintptr_t phys_frame_list; + uint32_t *frame_list; + int root_ports; + struct uhci_qh *queue_heads; + struct uhci_qh *phys_queue_heads; + + struct mempool *buffers; +}; + +#endif diff --git a/src/modules/cdi/uhci/init.c b/src/modules/cdi/uhci/init.c new file mode 100644 index 0000000..e9f9569 --- /dev/null +++ b/src/modules/cdi/uhci/init.c @@ -0,0 +1,257 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "uhci.h" +#include "uhci-hcd.h" +#include "uhci-init.h" +#include "uhci-transfer.h" + +extern const struct uhci_functions uhci_functions; +extern int init_uhci(void); + +#define DRIVER_NAME "uhcd" + +static struct cdi_usb_hcd driver = { + .drv = { + .type = CDI_USB_HCD, + .name = DRIVER_NAME, + .devices = NULL, + .init_device = &uhci_init, + .remove_device = NULL, +#ifdef CDI_DRIVER + .init = &init_uhci, +#endif + .destroy = NULL + } +}; + +#ifdef CDI_DRIVER +CDI_DRIVER(DRIVER_NAME, driver) +#endif + +void find_and_init_uhcis(void) +{ + struct uhci *hci; + char *name; + int uhci_counter = 0; + struct cdi_pci_device *dev; + + cdi_usb_hcd_init(&driver); + + cdi_list_t pci_devices = cdi_list_create(); + cdi_pci_get_all_devices(pci_devices); + for (int i = 0; (dev = cdi_list_get(pci_devices, i)) != NULL; i++) { + if ((dev->class_id != 0x0C) || (dev->subclass_id != 0x03) + || (dev->interface_id != 0x00)) + { + cdi_pci_device_destroy(dev); + } else { + hci = malloc(sizeof(struct uhci)); + hci->cdidev.dev.type = CDI_USB_HCD; + name = malloc(7); + sprintf(name, "uhci%i", uhci_counter++); + hci->cdidev.dev.name = (const char *)name; + hci->cdidev.speed = CDI_USB_LOW_SPEED | CDI_USB_FULL_SPEED; + hci->pcidev = dev; + cdi_list_push(driver.drv.devices, hci); + } + } + + cdi_list_destroy(pci_devices); + + driver.find_devices = uhci_functions.find_devices; + driver.activate_device = uhci_functions.activate_device; + driver.send_packets = uhci_functions.send_packets; + driver.add_pipe = uhci_functions.add_pipe; + +#ifndef CDI_DRIVER + cdi_driver_register((struct cdi_driver*) &driver); +#endif +} + +void uhci_init(struct cdi_device *dev) +{ + struct uhci *uhci = (struct uhci *)dev; + struct cdi_pci_resource *res; + int size = 0, request_size, cmd, intr, i; +#ifdef CDI_PCI_DIRECT_ACCESS + int legsup; +#endif + + d0printf("Trying to init %s at %02x:%02x.%02x...\n", uhci->cdidev.dev.name, + uhci->pcidev->bus, uhci->pcidev->dev, uhci->pcidev->function); + + uhci->pbase = 0; + for (i = 0; (res = cdi_list_get(uhci->pcidev->resources, i)) != NULL; i++) + { + if (res->type == CDI_PCI_IOPORTS) { + size = res->length ? res->length : 0x14; + if (cdi_ioports_alloc(res->start, size) == -1) { + d0printf("Cannot allocate I/O ports.\n"); + return; + } + uhci->pbase = res->start; + break; + } + } + if (!uhci->pbase) { + d0printf("No I/O space found.\n"); + return; + } + request_size = + // Maximale Paketlänge (Full Speed) ist 1023, Alignment außerdem + 1024 + + // Transferdeskriptor + sizeof(struct uhci_td); + + uhci->buffers = mempool_create(8192, request_size); + if (uhci->buffers == NULL) { + d0printf("Cannot create mempool.\n"); + return; + } + + if (cdi_alloc_phys_mem(sizeof(*uhci->queue_heads) * 1024, + (void **)&uhci->queue_heads, (void **)&uhci->phys_queue_heads) == -1) + { + d0printf("Cannot allocate QH memory.\n"); + return; + } + + if (cdi_alloc_phys_mem(4096, (void **)&uhci->frame_list, + (void **)&uhci->phys_frame_list) == -1) + { + d0printf("Cannot allocate frame list.\n"); + return; + } + +#ifdef CDI_PCI_DIRECT_ACCESS + cdi_pci_config_outw(uhci->pcidev, 4, 0x05); +#endif + + cdi_register_irq(uhci->pcidev->irq, &uhci_handler, dev); + uhci->root_ports = (size - 0x10) >> 1; + //Erstmal testen, wie viele wir genau haben... + for (i = 2; i < uhci->root_ports; i++) { + if (!(cdi_inw(uhci->pbase + UHCI_RPORTS + i * 2) & 0x0080) || + (cdi_inw(uhci->pbase + UHCI_RPORTS + i * 2) == 0xFFFF)) + { + uhci->root_ports = i; + break; + } + } + //Mehr als sieben Rootports, klingt lustig + if (uhci->root_ports > 7) { + uhci->root_ports = 2; + } + + d1printf("I/O 0x%04X (%i ports), IRQ %i\n", uhci->pbase, uhci->root_ports, + uhci->pcidev->irq); + +#ifdef CDI_PCI_DIRECT_ACCESS + legsup = cdi_pci_config_inw(uhci->pcidev, UHCI_PCI_LEGSUP); +#endif + cmd = cdi_inw(uhci->pbase + UHCI_USBCMD); + intr = cdi_inw(uhci->pbase + UHCI_USBINTR); + +#ifdef CDI_PCI_DIRECT_ACCESS + //Wenn der HC läuft, das Configurebit gesetzt ist, der nicht runtergefahren + //ist oder dieses Interrupt-enable-Bit gesetzt ist, dann war wohl schon + //jemand dran. + //(oder wenn der Legacy Support aktiviert ist, das heißt, wenn in LEGSUP + //irgendein Bit gesetzt ist, dass nicht RO/reserviert oder ein Statusbit + //ist) + if ((legsup & ~(UHCI_LEGSUP_STATUS | UHCI_LEGSUP_NO_CHG)) || + (cmd & USB_RUN) || !(cmd & CONFIGURE) || !(cmd & GLOB_SUSP_MODE) || + (intr & 0x0002)) + { + //Na, wer hat denn da am HC rumgefummelt. Bööööses BIOS. Oder SMM. Oder + //wer auch immer. + //Alle LEGSUP-Statusbits löschen + cdi_pci_config_outw(uhci->pcidev, UHCI_PCI_LEGSUP, + UHCI_LEGSUP_STATUS); +#endif + //Resetten + cdi_outw(uhci->pbase + UHCI_USBCMD, HCRESET); + //Warten, bis der Reset beendet ist + for (i = 0; (cdi_inw(uhci->pbase + UHCI_USBCMD) & HCRESET) && + (i < 50); i++) + { + cdi_sleep_ms(10); + } + if (i == 50) { + d1printf("Reset not finished...\n"); + } + + //Interrupts erstmal deaktivieren + cdi_outw(uhci->pbase + UHCI_USBINTR, 0); + //Den gesamten HC ebenso + cdi_outw(uhci->pbase + UHCI_USBCMD, 0); + + //Alle Ports "runterfahren" + for (int port = 0; port < uhci->root_ports; port++) { + cdi_outw(uhci->pbase + UHCI_RPORTS + (port * 2), 0); + } +#ifdef CDI_PCI_DIRECT_ACCESS + } +#endif + + for (i = 0; i < 1024; i++) { + uhci->queue_heads[i].next = 1; //Invalid + uhci->queue_heads[i].transfer = 1; //Invalid + } + for (i = 0; i < 1024; i++) { + uhci->frame_list[i] = (uintptr_t)&uhci->phys_queue_heads[i] | 2; + } + + //Standardwert, jede Millisekunde ein Frame + cdi_outb(uhci->pbase + UHCI_SOFMOD, 0x40); + //Unsere Frameliste eintragen + cdi_outl(uhci->pbase + UHCI_FRBASEADD, uhci->phys_frame_list); + //Frame zurücksetzen + cdi_outw(uhci->pbase + UHCI_FRNUM, 0); +#ifdef CDI_PCI_DIRECT_ACCESS + //Hier setzen wir das PIRQ-Bit und deaktivieren sämtlichen Legacy Support. + cdi_pci_config_outw(uhci->pcidev, UHCI_PCI_LEGSUP, UHCI_LEGSUP_PIRQ); +#else + d0printf("Failed to deactivate USB legacy support.\n"); +#endif + + //HC starten + cdi_outw(uhci->pbase + UHCI_USBCMD, USB_RUN | CONFIGURE | MAXP); + //Alle Interrupts aktivieren + cdi_outw(uhci->pbase + UHCI_USBINTR, 0xF); + + //Connect status change löschen + for (i = 0; i < uhci->root_ports; i++) { + cdi_outw(uhci->pbase + UHCI_RPORTS + i * 2, RPORT_CSC); + } +} diff --git a/src/modules/cdi/uhci/main.c b/src/modules/cdi/uhci/main.c new file mode 100644 index 0000000..7047be9 --- /dev/null +++ b/src/modules/cdi/uhci/main.c @@ -0,0 +1,32 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include + +#include "uhci-init.h" + +int init_uhci(void) +{ + find_and_init_uhcis(); + + return 0; +} diff --git a/src/modules/cdi/uhci/transfer.c b/src/modules/cdi/uhci/transfer.c new file mode 100644 index 0000000..33c60bf --- /dev/null +++ b/src/modules/cdi/uhci/transfer.c @@ -0,0 +1,91 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include + +#include +#include +#include + +#include "uhci.h" + +cdi_list_t uhci_active_transfers = NULL; + +void uhci_handler(struct cdi_device *cdi_hci) +{ + struct uhci *uhci = (struct uhci *)cdi_hci; + int status = cdi_inw(uhci->pbase + UHCI_USBSTS), i; + struct transfer *addr; + struct uhci_td *td; + + if (!status) { + //Also, von hier kommt der IRQ nicht. + return; + } + //Ist Bit 0 gesetzt, dann ist das ein normaler IOC (Interrupt on + //completion), bei Bit 1 ist ein Fehler aufgetreten, aber das werden wir ja + //unten sehen. + if (status & ~0x0003) { + d1printf("Unerwarteter IRQ 0x%04X von %s\n", status, cdi_hci->name); + } + if (status & 0x10) { + d0printf("SCHWERWIEGENDER FEHLER - HC WIRD ANGEHALTEN\n"); + cdi_outw(uhci->pbase + UHCI_USBCMD, MAXP | HCRESET); //FU! + } else { + for (i = 0; (addr = cdi_list_get(uhci_active_transfers, i)) != NULL; + i++) + { + td = addr->virt; + if (td->active) { + continue; + } + addr->error = CDI_USB_NO_ERROR; + cdi_list_remove(uhci_active_transfers, i--); + if (td->stalled_err) { + d0printf("ENDPOINT STALLED\n"); + addr->error |= CDI_USB_STALLED; + } + if (td->buf_err) { + d1printf("Pufferüberlauf oder Underrun\n"); + addr->error |= CDI_USB_BUFFER_ERROR; + } + if (td->babble) { + d1printf("Da war ein Gerät wohl sehr gesprächig: Babble.\n"); + addr->error |= CDI_USB_BABBLE; + } + if (td->nak) { + d1printf("NAK empfangen\n"); + addr->error |= CDI_USB_NAK; + } + if (td->crc_time_err) { + d1printf("CRC-Fehler oder Timeout\n"); + addr->error |= CDI_USB_CRC | CDI_USB_TIMEOUT; + } + if (td->bitstuff_err) { + d1printf("Bitstufffehler\n"); + addr->error |= CDI_USB_BITSTUFF; + } + //TODO: free(td) - dazu wäre eine CDI-Funktion nützlich + } + } + cdi_outw(uhci->pbase + UHCI_USBSTS, status); +} diff --git a/src/modules/cdi/usb-msd/Makefile.all b/src/modules/cdi/usb-msd/Makefile.all new file mode 100644 index 0000000..e027b50 --- /dev/null +++ b/src/modules/cdi/usb-msd/Makefile.all @@ -0,0 +1,2 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh diff --git a/src/modules/cdi/usb-msd/include/msd.h b/src/modules/cdi/usb-msd/include/msd.h new file mode 100644 index 0000000..bb6cf51 --- /dev/null +++ b/src/modules/cdi/usb-msd/include/msd.h @@ -0,0 +1,121 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef MSD_H +#define MSD_H + +#include +#include + +//#define DEBUG + +#ifdef DEBUG +#define d1printf(...) printf("[usb-msd] " __VA_ARGS__) +#define _d1printf(...) printf(__VA_ARGS__) +#else +#define d1printf(...) +#define _d1printf(...) +#endif + +#define d0printf(...) printf("[usb-msd] " __VA_ARGS__) +#define _d0printf(...) printf(__VA_ARGS__) + +//"USBC" +#define CBW_SIGNATURE 0x43425355 +struct command_block_wrapper +{ + uint32_t cbw_signature; + uint32_t cbw_tag; + uint32_t cbw_data_transfer_length; + uint8_t cbw_flags; + uint8_t cbw_lun; + uint8_t cbw_cb_length; + uint8_t cbw_cb[16]; +} __attribute__((packed)); + +//"USBS" +#define CSW_SIGNATURE 0x53425355 +struct command_status_wrapper +{ + uint32_t csw_signature; + uint32_t csw_tag; + uint32_t csw_data_residue; + uint8_t csw_status; +} __attribute__((packed)); + +struct msc_sense +{ + unsigned error : 7; + unsigned valid : 1; + uint8_t rsvd0; + unsigned sense_key : 4; + unsigned rsvd1 : 4; + uint32_t information; + uint8_t additional_length; + uint32_t rsvd2; + uint8_t additional_code; + uint8_t additional_code_qualifier; + uint32_t rsvd; +} __attribute__((packed)); + +struct msd_capacity +{ + uint32_t last_lba; + uint32_t block_length; +} __attribute__((packed)); + +struct cdi_msd +{ + struct cdi_storage_device cdi_device; + struct cdi_usb_device *usb_device; + struct cdi_usb_pipe *bulk_in; + struct cdi_usb_pipe *bulk_out; + uint32_t offset; //Für Partitionen +}; + +struct part_table_entry +{ + uint8_t active; + uint8_t begin_chs[3]; + uint8_t type; + uint8_t end_chs[3]; + uint32_t start; + uint32_t size; +} __attribute__((packed)); + + +#define MSC_CMD_REZERO 0x01 +#define MSC_CMD_SENSE 0x03 +#define MSC_CMD_CAPACITY 0x25 +#define MSC_CMD_READ10 0x28 +#define MSC_CMD_WRITE10 0x2A +#define MSC_CMD_SEEK 0x2B +#define MSC_CMD_READ12 0xA8 +#define MSC_CMD_WRITE12 0xAA + +int check_msd(struct cdi_usb_device *device); +int msd_read_blocks(struct cdi_storage_device *device, uint64_t start, + uint64_t count, void *buffer); +int msd_write_blocks(struct cdi_storage_device *device, uint64_t start, + uint64_t count, void *buffer); + +#endif diff --git a/src/modules/cdi/usb-msd/main.c b/src/modules/cdi/usb-msd/main.c new file mode 100644 index 0000000..e414e80 --- /dev/null +++ b/src/modules/cdi/usb-msd/main.c @@ -0,0 +1,74 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include +#include + +#include "msd.h" + +#define DRIVER_NAME "usb-msd" + +int init_usbmsd(void); + +struct cdi_storage_driver msc_driver = { + .drv = { + .type = CDI_STORAGE, + .name = DRIVER_NAME, + .devices = NULL, + .init_device = NULL, + .remove_device = NULL, +#ifdef CDI_DRIVER + .init = &init_usbmsd, +#endif + .destroy = NULL + }, + .read_blocks = &msd_read_blocks, + .write_blocks = &msd_write_blocks +}; + +#ifdef CDI_DRIVER +CDI_DRIVER(DRIVER_NAME, msc_driver) +#endif + +static struct cdi_usb_device_pattern msd_pattern = { + .vendor_id = -1, + .device_id = -1, + .class_id = 8, + .subclass_id = -1, + .protocol_id = -1, + + .take_usb_device = &check_msd +}; + +int init_usbmsd() +{ + cdi_storage_driver_init(&msc_driver); + +#ifndef CDI_DRIVER + cdi_storage_driver_register(&msc_driver); +#endif + + cdi_usb_register_device_pattern(&msd_pattern); + + return 0; +} diff --git a/src/modules/cdi/usb-msd/msd.c b/src/modules/cdi/usb-msd/msd.c new file mode 100644 index 0000000..a53d41f --- /dev/null +++ b/src/modules/cdi/usb-msd/msd.c @@ -0,0 +1,555 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include + +#include "msd.h" + +//TODO: CDI-Funktion wäre hier sicher nützlich... +#define CPU_IS_LITTLE_ENDIAN + +#define change_endianess_32(_) ((((_) & \ + 0xFF000000) >> \ + 24) | \ + (((_) & \ + 0xFF0000) >> \ + 8) | \ + (((_) & 0xFF00) << 8) | (((_) & 0xFF) << 24)) +#ifdef CPU_IS_LITTLE_ENDIAN +#define CPU2BE(_) change_endianess_32(_) +#define CPU2LE(_) (_) +#define BE2CPU(_) change_endianess_32(_) +#define LE2CPU(_) (_) +#else +#define CPU2BE(_) (_) +#define CPU2LE(_) change_endianess_32(_) +#define BE2CPU(_) (_) +#define LE2CPU(_) change_endianess_32(_) +#endif + +extern struct cdi_storage_driver msc_driver; +static uint32_t cbw_tag = 1; +static volatile int i_am_locked = 0; + +static int msd_cdi_read(struct cdi_storage_device *strgdev, uint64_t start, + uint64_t count, void *buffer); +static int msd_cdi_write(struct cdi_storage_device *strgdev, uint64_t start, + uint64_t count, void *buffer); +static void get_partitions(struct cdi_storage_device *cdistrg); + +int msd_read_blocks(struct cdi_storage_device *device, uint64_t start, + uint64_t count, void *buffer) +{ + return msd_cdi_read(device, start, count, buffer); +} + +int msd_write_blocks(struct cdi_storage_device *device, uint64_t start, + uint64_t count, void *buffer) +{ + return msd_cdi_write(device, start, count, buffer); +} + +static int msd_get_capacity(struct cdi_usb_device *usbdev, + uint32_t *block_size, uint32_t *block_count); + +int check_msd(struct cdi_usb_device *device) +{ + struct cdi_storage_device *strgdev; + struct cdi_usb_endpoint *ep_desc; + struct cdi_msd *cdimsd; + struct cdi_usb_hcd *hcd; + void *address; + int i; + uint32_t bs, bc; + uint64_t size; + static int msdnum = 0; + + //Nur Bulk-Only + if (device->protocol_id != 0x50) { + return 0; + } + + d0printf("MSD detected.\n"); + + cdimsd = malloc(sizeof(struct cdi_msd)); + if (cdimsd == NULL) { + return 0; + } + cdimsd->usb_device = device; + cdimsd->offset = 0; + strgdev = (struct cdi_storage_device *)cdimsd; + strgdev->dev.type = CDI_STORAGE; + strgdev->dev.name = malloc(10); + if (strgdev->dev.name == NULL) { + free(strgdev); + return 0; + } + sprintf((char *)strgdev->dev.name, "usb-msd%i", msdnum++); + strgdev->dev.driver = (struct cdi_driver *)&msc_driver; + device->driver_data = cdimsd; + cdimsd->bulk_in = malloc(sizeof(*cdimsd->bulk_in)); + cdimsd->bulk_in->device = device; + cdimsd->bulk_in->endpoint = NULL; + cdimsd->bulk_in->data_toggle = 0; + cdimsd->bulk_out = malloc(sizeof(*cdimsd->bulk_out)); + cdimsd->bulk_out->device = device; + cdimsd->bulk_out->endpoint = NULL; + cdimsd->bulk_out->data_toggle = 0; + address = (void *)((uintptr_t)device->interface_desc + + sizeof(struct cdi_usb_interface)); + for (i = 0; i < device->interface_desc->num_endpoints; i++) { + ep_desc = address; + if ((ep_desc->endpoint_address & 0x80) && + (ep_desc->attributes == 0x02) && + (cdimsd->bulk_in->endpoint == NULL)) + { + //BULK-IN + cdimsd->bulk_in->endpoint = ep_desc; + } + else if (!(ep_desc->endpoint_address & 0x80) && + (ep_desc->attributes == 0x02) && + (cdimsd->bulk_out->endpoint == NULL)) + { + //BULK-OUT + cdimsd->bulk_out->endpoint = ep_desc; + } + address = (void *)((uintptr_t)address + + sizeof(struct cdi_usb_endpoint)); + } + if ((cdimsd->bulk_in->endpoint == NULL) || + (cdimsd->bulk_out->endpoint == NULL)) + { + d0printf("Not enough endpoints found.\n"); + return 0; + } + hcd = (struct cdi_usb_hcd *)device->hc->dev.driver; + hcd->add_pipe(cdimsd->bulk_in); + hcd->add_pipe(cdimsd->bulk_out); + if (!msd_get_capacity(device, &bs, &bc)) { + strgdev->block_size = 0; + strgdev->block_count = 0; + d1printf("Wasn't able to determine size of %s.\n", strgdev->dev.name); + } else { + strgdev->block_size = bs; + strgdev->block_count = bc; + size = bs; + size *= bc; + d1printf("%s: %i * %i B (about %d MB).\n", strgdev->dev.name, bc, bs, + (int)(size >> 20)); + } + cdi_storage_device_init(strgdev); + cdi_list_push(msc_driver.drv.devices, strgdev); + + get_partitions(strgdev); + + return 1; +} + +static int write_cmd(struct cdi_usb_device *usbdev, void *src) +{ + struct cdi_msd *cdimsd = usbdev->driver_data; + struct cdi_usb_packet cmd_packet = { + .pipe = cdimsd->bulk_out, + .type = CDI_USB_PACKET_OUT, + .data = src, + .length = 0x1F, + .use_toggle = TOGGLE_UNSPECIFIC + }; + + return usbdev->drv->send_packets(&cmd_packet, 1); +} + +/** + * Liest den Status von einem MSD + * + * @param usbdev Das bewusste Gerät + * @param expected_tag Das erwartete Tag + * + * @return Wenn der Status OK ist USB_NO_ERROR, sonst entsprechender Fehler + */ + +static int read_status(struct cdi_usb_device *usbdev, uint32_t expected_tag) +{ + struct cdi_msd *msc = usbdev->driver_data; + struct command_status_wrapper _csw; + struct command_status_wrapper *csw = &_csw; + cdi_usb_status_t error; + + struct cdi_usb_packet status_packet = { + .pipe = msc->bulk_in, + .type = CDI_USB_PACKET_IN, + .data = csw, + .length = 0x0D, + .use_toggle = TOGGLE_UNSPECIFIC + }; + + error = usbdev->drv->send_packets(&status_packet, 1); + if (error != CDI_USB_NO_ERROR) { + return error; + } + if ((csw->csw_signature != CSW_SIGNATURE) || + (csw->csw_tag != expected_tag) || csw->csw_status) + { + d1printf("0x%08X %i==%i 0x%08X\n", csw->csw_signature, csw->csw_tag, + expected_tag, csw->csw_status); + return CDI_USB_TRIVIAL_ERROR; + } + + return CDI_USB_NO_ERROR; +} + +static int msd_get_capacity(struct cdi_usb_device *usbdev, + uint32_t *block_size, uint32_t *block_count) +{ + struct cdi_msd *msc; + struct command_block_wrapper _cbw; + struct command_block_wrapper *cbw = &_cbw; + struct msd_capacity _cap; + struct msd_capacity *cap = &_cap; + uint32_t expected_tag; + + if ((usbdev == NULL) || (block_size == NULL) || (block_count == NULL)) { + return 0; + } + + msc = usbdev->driver_data; + memset(cbw, 0, 0x1F); + cbw->cbw_signature = CBW_SIGNATURE; + cbw->cbw_tag = (expected_tag = cbw_tag++); + cbw->cbw_data_transfer_length = sizeof(struct msd_capacity); + cbw->cbw_flags = 0x80; //IN + cbw->cbw_lun = 0; //Was weiß ich, wie viele LUNs datt Dingens hat? + cbw->cbw_cb_length = 12; + cbw->cbw_cb[0] = MSC_CMD_CAPACITY; + cbw->cbw_cb[1] = 0; //LUN: 0 + + if (write_cmd(usbdev, cbw) != CDI_USB_NO_ERROR) { + return 0; + } + + struct cdi_usb_packet in_packet = { + .pipe = msc->bulk_in, + .type = CDI_USB_PACKET_IN, + .data = cap, + .length = sizeof(*cap), + .use_toggle = TOGGLE_UNSPECIFIC + }; + + if (usbdev->drv->send_packets(&in_packet, 1) != CDI_USB_NO_ERROR) { + return 0; + } + + if (read_status(usbdev, expected_tag) != CDI_USB_NO_ERROR) { + return 0; + } + + *block_size = BE2CPU(cap->block_length); + *block_count = BE2CPU(cap->last_lba) + 1; + + return 1; +} + +#ifdef WAIT_FOR_MSD_READY +static int msd_ready(struct cdi_usb_device *usbdev) +{ + struct msclass_data *msc; + struct command_block_wrapper _cbw; + struct command_block_wrapper *cbw = &_cbw; + uint32_t expected_tag; + + msc = (struct msclass_data *)usbdev->driver_data; + memset(cbw, 0, 0x1F); + cbw->cbw_signature = CBW_SIGNATURE; + cbw->cbw_tag = (expected_tag = cbw_tag++); + cbw->cbw_data_transfer_length = 0; + cbw->cbw_flags = 0x80; //IN + cbw->cbw_lun = 0; //Was weiß ich, wie viele LUNs datt Dingens hat? + cbw->cbw_cb_length = 12; //Alles null, also "Test unit ready" + + if (write_cmd(usbdev, cbw) != USB_NO_ERROR) { + return 0; + } + + if (read_status(usbdev, expected_tag) != USB_NO_ERROR) { + return 0; + } + + return 1; +} +#endif + +static inline int _tsl(volatile int *variable) +{ + int rval; + rval = *variable; + *variable = 1; + return rval; +} + +#define MAX_ACCESS_BLOCKS 32 + +static uint32_t msd_read(struct cdi_usb_device *usbdev, uint32_t lba, + uint16_t sectors, void *buffer, size_t length); + +static int msd_cdi_read(struct cdi_storage_device *strgdev, uint64_t start, + uint64_t count, void *buffer) +{ + int bs = strgdev->block_size, error; +#ifdef WAIT_FOR_MSD_READY + int i; +#endif + struct cdi_usb_device *usbdev = ((struct cdi_msd *)strgdev)->usb_device; + int j, bbs; + + while (_tsl(&i_am_locked)); + + d1printf("read(%i, %i)\n", (int)start, (int)count); + start += ((struct cdi_msd *)strgdev)->offset; + + if (!count) { + d1printf("Empty read request.\n"); + i_am_locked = 0; + return 0; + } + for (j = 0; j < (int)count; j += MAX_ACCESS_BLOCKS) { +#ifdef WAIT_FOR_MSD_READY + for (i = 0; !msd_ready(usbdev) && (i < 10); i++) { + cdi_sleep_ms(20); + } +#endif + bbs = (count - j > MAX_ACCESS_BLOCKS) ? MAX_ACCESS_BLOCKS : count - j; + error = msd_read(usbdev, start + j, bbs, + (void *)((uintptr_t)buffer + j * bs), bbs * bs); + if (error != CDI_USB_NO_ERROR) { + d0printf("Read error 0x%X at block %lld.\n", error, start + j); + i_am_locked = 0; + return -1; + } + } + i_am_locked = 0; + return 0; +} + +static uint32_t msd_read(struct cdi_usb_device *usbdev, uint32_t lba, + uint16_t sectors, void *buffer, size_t length) +{ + struct cdi_msd *msc; + struct command_block_wrapper _cbw; + struct command_block_wrapper *cbw = &_cbw; + uint32_t expected_tag; + int error; + + if ((buffer == NULL) || !length) { + return CDI_USB_TRIVIAL_ERROR; + } + msc = usbdev->driver_data; + memset(cbw, 0, 0x1F); + cbw->cbw_signature = CBW_SIGNATURE; + cbw->cbw_tag = (expected_tag = cbw_tag++); + cbw->cbw_data_transfer_length = length; + cbw->cbw_flags = 0x80; //IN + cbw->cbw_lun = 0; //Was weiß ich, wie viele LUNs datt Dingens hat? + cbw->cbw_cb_length = 12; + cbw->cbw_cb[0] = MSC_CMD_READ10; + cbw->cbw_cb[1] = 0; //LUN: 0 + cbw->cbw_cb[2] = (lba & 0xFF000000) >> 24; + cbw->cbw_cb[3] = (lba & 0x00FF0000) >> 16; + cbw->cbw_cb[4] = (lba & 0x0000FF00) >> 8; + cbw->cbw_cb[5] = lba & 0x000000FF; + cbw->cbw_cb[7] = (sectors & 0x0000FF00) >> 8; + cbw->cbw_cb[8] = sectors & 0x000000FF; + + error = write_cmd(usbdev, cbw); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + struct cdi_usb_packet in_packet = { + .pipe = msc->bulk_in, + .type = CDI_USB_PACKET_IN, + .data = buffer, + .length = length, + .use_toggle = TOGGLE_UNSPECIFIC + }; + + error = usbdev->drv->send_packets(&in_packet, 1); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + error = read_status(usbdev, expected_tag); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + return CDI_USB_NO_ERROR; +} + +static uint32_t msd_write(struct cdi_usb_device *usbdev, uint32_t lba, + uint16_t sectors, void *buffer, size_t length); + +static int msd_cdi_write(struct cdi_storage_device *strgdev, uint64_t start, + uint64_t count, void *buffer) +{ + int bs = strgdev->block_size, error; +#ifdef WAIT_FOR_MSD_READY + int i; +#endif + struct cdi_usb_device *usbdev = ((struct cdi_msd *)strgdev)->usb_device; + int j, bbs; + + while (_tsl(&i_am_locked)); + + d1printf("write(%i, %i)\n", (int)start, (int)count); + start += ((struct cdi_msd *)strgdev)->offset; + + if (!count) { + d1printf("Empty write request.\n"); + i_am_locked = 0; + return 0; + } + for (j = 0; j < (int)count; j += MAX_ACCESS_BLOCKS) { +#ifdef WAIT_FOR_MSD_READY + for (i = 0; !msd_ready(usbdev) && (i < 10); i++) + cdi_sleep_ms(20); +#endif + bbs = (count - j > MAX_ACCESS_BLOCKS) ? MAX_ACCESS_BLOCKS : count - j; + error = msd_write(usbdev, start + j, bbs, + (void *)((uintptr_t)buffer + j * bs), bbs * bs); + if (error != CDI_USB_NO_ERROR) { + d0printf("Write error 0x%X at block %lld.\n", error, start + j); + i_am_locked = 0; + return -1; + } + } + i_am_locked = 0; + return 0; +} + +static uint32_t msd_write(struct cdi_usb_device *usbdev, uint32_t lba, + uint16_t sectors, void *buffer, size_t length) +{ + struct cdi_msd *msc; + struct command_block_wrapper _cbw; + struct command_block_wrapper* cbw = &_cbw; + uint32_t expected_tag; + int error; + + if ((buffer == NULL) || !length) { + return CDI_USB_TRIVIAL_ERROR; + } + msc = usbdev->driver_data; + memset(cbw, 0, 0x1F); + cbw->cbw_signature = CBW_SIGNATURE; + cbw->cbw_tag = (expected_tag = cbw_tag++); + cbw->cbw_data_transfer_length = length; + cbw->cbw_flags = 0x00; //OUT + cbw->cbw_lun = 0; //Was weiß ich, wie viele LUNs datt Dingens hat? + cbw->cbw_cb_length = 12; + cbw->cbw_cb[0] = MSC_CMD_WRITE10; + cbw->cbw_cb[1] = 0; //LUN: 0 + cbw->cbw_cb[2] = (lba & 0xFF000000) >> 24; + cbw->cbw_cb[3] = (lba & 0x00FF0000) >> 16; + cbw->cbw_cb[4] = (lba & 0x0000FF00) >> 8; + cbw->cbw_cb[5] = lba & 0x000000FF; + cbw->cbw_cb[7] = (sectors & 0x0000FF00) >> 8; + cbw->cbw_cb[8] = sectors & 0x000000FF; + + error = write_cmd(usbdev, cbw); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + struct cdi_usb_packet out_packet = { + .pipe = msc->bulk_out, + .type = CDI_USB_PACKET_OUT, + .data = buffer, + .length = length, + .use_toggle = TOGGLE_UNSPECIFIC + }; + + error = usbdev->drv->send_packets(&out_packet, 1); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + error = read_status(usbdev, expected_tag); + if (error != CDI_USB_NO_ERROR) { + return error; + } + + return CDI_USB_NO_ERROR; +} + +static void get_partitions(struct cdi_storage_device *cdistrg) +{ + void *mbr; + struct part_table_entry *partition; + struct cdi_msd *cdimsd, *base_cdimsd = (struct cdi_msd *)cdistrg; + int i, j = 0; + + mbr = malloc(512); + if (msd_cdi_read(cdistrg, 0, 1, mbr) != CDI_USB_NO_ERROR) + { + d1printf("Couldn't read MBR.\n"); + return; + } + if (((uint16_t *)mbr)[255] != 0xAA55) + return; + partition = (void *)((uintptr_t)mbr + 0x1BE); + d1printf("Partitions on %s:", cdistrg->dev.name); + for (i = 0; i < 4; i++) + { + if (partition[i].type && partition[i].size && + (partition[i].start + partition[i].size <= cdistrg->block_count)) + { + cdimsd = calloc(1, sizeof(struct cdi_msd)); + if (cdimsd == NULL) { + break; + } + cdimsd->offset = partition[i].start; + cdimsd->usb_device = base_cdimsd->usb_device; + cdimsd->cdi_device.dev.type = CDI_STORAGE; + cdimsd->cdi_device.dev.driver = (struct cdi_driver *)&msc_driver; + cdimsd->cdi_device.dev.name = malloc(14); + if (cdimsd->cdi_device.dev.name == NULL) { + free(cdimsd); + break; + } + sprintf((char *)cdimsd->cdi_device.dev.name, "%sp%i", + cdistrg->dev.name, j++); + cdimsd->cdi_device.block_size = base_cdimsd->cdi_device.block_size; + cdimsd->cdi_device.block_count = partition[i].size; + _d1printf(" %s", cdimsd->cdi_device.dev.name); + cdi_storage_device_init((struct cdi_storage_device *)cdimsd); + cdi_list_push(msc_driver.drv.devices, cdimsd); + } + } + _d1printf("\n"); +} diff --git a/src/modules/cdi/usb11/Makefile.all b/src/modules/cdi/usb11/Makefile.all new file mode 100644 index 0000000..e027b50 --- /dev/null +++ b/src/modules/cdi/usb11/Makefile.all @@ -0,0 +1,2 @@ +shopt -s extglob +source $LOST_BUILDMK_ROOT/config.sh diff --git a/src/modules/cdi/usb11/control.c b/src/modules/cdi/usb11/control.c new file mode 100644 index 0000000..170341d --- /dev/null +++ b/src/modules/cdi/usb11/control.c @@ -0,0 +1,252 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include + +#include +#include +#include + +#include "usb11.h" +#include "usb-structs.h" +#include "transfer.h" + +static int usb_dev_ids = 1; + +static void enumerate_hub(struct cdi_usb_device *usbdev); + +static int usb11_real_enumerate(struct cdi_usb_device *device) +{ + struct endpoint_desc *ep0; + struct device_desc *dev_desc; + struct cdi_usb_hcd *hcd; + int id; + char *name; + void *position; + struct config_desc *conf_desc; + struct interface_desc *if_desc, *best_if; + + hcd = (struct cdi_usb_hcd *)device->hc->dev.driver; + + //EP0 initialisieren + device->ep0 = malloc(sizeof(*device->ep0)); + device->ep0->endpoint = malloc(sizeof(struct endpoint_desc)); + ep0 = (struct endpoint_desc *)device->ep0->endpoint; + ep0->length = sizeof(struct endpoint_desc); + ep0->descriptor_type = DESC_ENDPOINT; + ep0->endpoint_address = 0; + ep0->attributes = 0; + ep0->max_packet_size = 8; + ep0->interval = 0; + device->ep0->device = device; + device->ep0->data_toggle = 0; + + //Zurücksetzen + device->reset(device); + + //Pipe erzeugen + hcd->add_pipe(device->ep0); + + //Erste acht Bytes des Device-Descriptors abrufen und die maximale + //Paketgröße von EP0 feststellen + dev_desc = usb11_do_control(device, DEV_TO_HOST, NULL, 8, STD_REQUEST, + REC_DEVICE, GET_DESCRIPTOR, DESC_DEVICE << 8, 0); + if (dev_desc == NULL) { + return 0; + } + ep0->max_packet_size = dev_desc->max_packet_size0; + + //Nochmals zurücksetzen + device->reset(device); + + //USB-Adresse zuweisen + usb11_do_control(device, HOST_TO_DEV | NO_DATA, NULL, 0, STD_REQUEST, + REC_DEVICE, SET_ADDRESS, (id = usb_dev_ids++), 0); + device->id = id; + if (usb_dev_ids >= 128) { + d0printf("Warning: USB device ID overflow.\n"); + usb_dev_ids = 1; + } + + //So, jetzt haben wir eine Adresse, da gibts auch eine neue Pipe + hcd->add_pipe(device->ep0); + + //Den ganzen Device-Descriptor einlesen + dev_desc = usb11_do_control(device, DEV_TO_HOST, NULL, sizeof(*dev_desc), + STD_REQUEST, REC_DEVICE, GET_DESCRIPTOR, DESC_DEVICE << 8, 0); + device->device_desc = dev_desc; + device->vendor_id = dev_desc->vendor_id; + device->device_id = dev_desc->device_id; + + if (dev_desc->iManufacturer) { + name = usb11_do_control(device, DEV_TO_HOST, NULL, 64, STD_REQUEST, + REC_DEVICE, GET_DESCRIPTOR, + (DESC_STRING << 8) | dev_desc->iManufacturer, 0); + if (name == NULL) { + return 0; + } + d1printf(" -> Manufacturer: "); + for (int i = 2; i < name[0]; i += 2) { + _d1printf("%c", name[i]); + } + _d1printf("\n"); + } + if (dev_desc->iProduct) { + name = usb11_do_control(device, DEV_TO_HOST, NULL, 64, STD_REQUEST, + REC_DEVICE, GET_DESCRIPTOR, + (DESC_STRING << 8) | dev_desc->iProduct, 0); + if (name == NULL) { + return 0; + } + d1printf(" -> Product: "); + for (int i = 2; i < name[0]; i += 2) { + _d1printf("%c", name[i]); + } + _d1printf("\n"); + } + //TODO: Man kann doch nicht immer den ersten nehmen... + conf_desc = usb11_do_control(device, DEV_TO_HOST, NULL, + sizeof(struct config_desc), STD_REQUEST, REC_DEVICE, GET_DESCRIPTOR, + DESC_CONFIGURATION << 8, 0); + if (conf_desc == NULL) { + return 0; + } + conf_desc = usb11_do_control(device, DEV_TO_HOST, NULL, + conf_desc->total_length, STD_REQUEST, REC_DEVICE, GET_DESCRIPTOR, + DESC_CONFIGURATION << 8, 0); + if (conf_desc == NULL) { + return 0; + } + device->config_desc = conf_desc; + usb11_do_control(device, HOST_TO_DEV, NULL, 0, STD_REQUEST, REC_DEVICE, + SET_CONFIGURATION, conf_desc->config_value, 0); + if (conf_desc->iConfiguration) { + name = usb11_do_control(device, DEV_TO_HOST, NULL, 64, STD_REQUEST, + REC_DEVICE, GET_DESCRIPTOR, + (DESC_STRING << 8) | conf_desc->iConfiguration, 0); + if (name == NULL) { + return 0; + } + d1printf("Using configuration "); + for (int i = 2; i < name[0]; i += 2) { + _d1printf("%c", name[i]); + } + _d1printf(".\n"); + } + position = conf_desc; + position = (void *)((uintptr_t)position + sizeof(struct config_desc)); + best_if = position; //Standard-IF + for (int i = 0; i < conf_desc->num_interfaces; i++) { + if_desc = position; + //TODO MSD ist zwar hübsch. Aber andere auch ;-) + if (if_desc->interface_class == 8) { + best_if = if_desc; + break; + } + position = (void *)((uintptr_t)position + + sizeof(struct interface_desc) + + if_desc->num_endpoints * sizeof(struct endpoint_desc)); + } + usb11_do_control(device, HOST_TO_DEV, NULL, 0, STD_REQUEST, REC_DEVICE, + SET_INTERFACE, best_if->interface_number, 0); + device->interface_desc = (void *)best_if; + if (best_if->iInterface) { + name = usb11_do_control(device, DEV_TO_HOST, NULL, 64, STD_REQUEST, + REC_DEVICE, GET_DESCRIPTOR, + (DESC_STRING << 8) | best_if->iInterface, 0); + if (name == NULL) { + return 0; + } + d1printf("Using interface "); + for (int i = 2; i < name[0]; i += 2) { + _d1printf("%c", name[i]); + } + _d1printf(".\n"); + } + d1printf("Configuration: %i:%i (%i)\n", conf_desc->config_value, + best_if->interface_number, best_if->interface_class); + + if (!dev_desc->class_id) { //Composite Device + device->class_id = best_if->interface_class; + device->subclass_id = best_if->interface_subclass; + device->protocol_id = best_if->interface_protocol; + } else { + device->class_id = dev_desc->class_id; + device->subclass_id = dev_desc->subclass_id; + device->protocol_id = dev_desc->protocol_id; + } + + if (best_if->interface_class == USBDC_HUB) { + enumerate_hub(device); + } + + return 1; +} + +void usb11_enumerate(struct cdi_usb_device *device) +{ + if (!usb11_real_enumerate(device)) { + free(device->ep0->endpoint); + free(device->ep0); + } +} + +static void reset_hub_device(struct cdi_usb_device *usbdev) +{ + usb11_do_control(usbdev->hub, HOST_TO_DEV, NULL, 0, CLS_REQUEST, REC_OTHER, + SET_FEATURE, PORTF_RESET, usbdev->port + 1); + cdi_sleep_ms(20); +} + +static void enumerate_hub(struct cdi_usb_device *usbdev) +{ + struct hub_desc *hub_desc; + struct cdi_usb_device *down; + uint16_t *port_status; + int i; + + //Mehr als 8 Ports sollte es nicht geben, die Größe des Deskriptors wird + //daher wohl nicht größer als sizeof()+16 werden + hub_desc = usb11_do_control(usbdev, DEV_TO_HOST, NULL, + sizeof(*hub_desc) + 16, CLS_REQUEST, REC_DEVICE, GET_DESCRIPTOR, + DESC_DEVICE << 8, 0); + for (i = 0; i < hub_desc->nbr_ports; i++) { + port_status = usb11_do_control(usbdev, DEV_TO_HOST, NULL, 4, + CLS_REQUEST,REC_OTHER, GET_STATUS, 0, i + 1); + if (!(port_status[0] & PORT_DEVICE)) { + continue; + } + //Strom an + usb11_do_control(usbdev, HOST_TO_DEV, NULL, 0, CLS_REQUEST, REC_OTHER, + SET_FEATURE, PORTF_POWER, i + 1); + cdi_sleep_ms(hub_desc->pwron2pwrgood * 2); + down = malloc(sizeof(struct cdi_usb_device)); + down->hc = usbdev->hc; + down->hub = usbdev; + down->id = 0; + down->port = i; + down->speed = (port_status[0] & PORT_LOWSPEED) ? + CDI_USB_LOW_SPEED : CDI_USB_FULL_SPEED; + down->reset = &reset_hub_device; + cdi_usb_device_init(down); + } +} diff --git a/src/modules/cdi/usb11/include/control.h b/src/modules/cdi/usb11/include/control.h new file mode 100644 index 0000000..97edefc --- /dev/null +++ b/src/modules/cdi/usb11/include/control.h @@ -0,0 +1,31 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef CONTROL_H +#define CONTROL_H + +#include +#include + +void usb11_enumerate(struct cdi_usb_device *device); + +#endif diff --git a/src/modules/cdi/usb11/include/transfer.h b/src/modules/cdi/usb11/include/transfer.h new file mode 100644 index 0000000..3b0f086 --- /dev/null +++ b/src/modules/cdi/usb11/include/transfer.h @@ -0,0 +1,38 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef TRANSFER_H +#define TRANSFER_H + +#include + +#include + +void *usb11_do_control(struct cdi_usb_device *device, int direction, + void *buffer, int length, int rtype, int recipient, int request, int value, + int index); +void *usb11_export_control(struct cdi_usb_device *device, + struct cdi_usb_control_transfer *transfer); +cdi_usb_status_t usb11_send_packets(struct cdi_usb_packet *packets, + size_t num_packets); + +#endif diff --git a/src/modules/cdi/usb11/include/usb-structs.h b/src/modules/cdi/usb11/include/usb-structs.h new file mode 100644 index 0000000..427d0e5 --- /dev/null +++ b/src/modules/cdi/usb11/include/usb-structs.h @@ -0,0 +1,184 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef USB_STRUCTS_H +#define USB_STRUCTS_H + +#include + + +#define NO_DATA 0x01 +#define DEV_TO_HOST 0x80 +#define HOST_TO_DEV 0x00 +#define STD_REQUEST 0x00 +#define CLS_REQUEST 0x20 +#define VEN_REQUEST 0x40 +#define REC_DEVICE 0x00 +#define REC_INTERFACE 0x01 +#define REC_ENDPOINT 0x02 +#define REC_OTHER 0x03 + +#define GET_STATUS 0 +#define CLEAR_FEATURE 1 +#define SET_FEATURE 3 +#define SET_ADDRESS 5 +#define GET_DESCRIPTOR 6 +#define SET_DESCRIPTOR 7 +#define GET_CONFIGURATION 8 +#define SET_CONFIGURATION 9 +#define GET_INTERFACE 10 +#define SET_INTERFACE 11 +#define SYNC_FRAME 12 + +#define PORT_DEVICE 0x0001 +#define PORT_ENABLED 0x0002 +#define PORT_SUSPENDED 0x0004 +#define PORT_OVERCURRENT 0x0008 +#define PORT_RESET 0x0010 +#define PORT_POWER 0x0100 +#define PORT_LOWSPEED 0x0200 +#define PORT_HIGHSPEED 0x0400 +#define PORT_TEST 0x0800 +#define PORT_INDICATOR 0x1000 + +#define PORTF_CONNECTION 0 +#define PORTF_ENABLE 1 +#define PORTF_SUSPEND 2 +#define PORTF_OVERCURRENT 3 +#define PORTF_RESET 4 +#define PORTF_POWER 8 +#define PORTF_LOWSPEED 9 +#define PORTF_HIGHSPEED 10 +#define PORTF_C_CONNECTION 16 +#define PORTF_C_ENABLE 17 +#define PORTF_C_SUSPEND 18 +#define PORTF_C_OVERCURRENT 19 +#define PORTF_C_RESET 20 +#define PORTF_TEST 21 +#define PORTF_INDICATOR 22 + +#define DESC_DEVICE 1 +#define DESC_CONFIGURATION 2 +#define DESC_STRING 3 +#define DESC_INTERFACE 4 +#define DESC_ENDPOINT 5 +#define DESC_DEVICE_QUALIFIER 6 +#define DESC_OTHER_SPEED_CONFIGURATION 7 +#define DESC_INTERFACE_POWER 8 + + +struct setup_packet +{ + uint8_t request_type; + uint8_t request; + uint16_t value; + uint16_t index; + uint16_t length; +} __attribute__((packed)); + +struct device_desc +{ + uint8_t length; + uint8_t descriptor_type; + uint16_t bcdUSB; + uint8_t class_id; + uint8_t subclass_id; + uint8_t protocol_id; + uint8_t max_packet_size0; + uint16_t vendor_id; + uint16_t device_id; + uint16_t bcdDevice; + uint8_t iManufacturer; + uint8_t iProduct; + uint8_t iSerialNumber; + uint8_t num_configurations; +} __attribute__((packed)); + +struct config_desc +{ + uint8_t length; + uint8_t descriptor_type; + uint16_t total_length; + uint8_t num_interfaces; + uint8_t config_value; + uint8_t iConfiguration; + uint8_t attributes; + uint8_t max_power; +} __attribute__((packed)); + +struct interface_desc +{ + uint8_t length; + uint8_t descriptor_type; + uint8_t interface_number; + uint8_t alternate_setting; + uint8_t num_endpoints; + uint8_t interface_class; + uint8_t interface_subclass; + uint8_t interface_protocol; + uint8_t iInterface; +} __attribute__((packed)); + +struct endpoint_desc +{ + uint8_t length; + uint8_t descriptor_type; + uint8_t endpoint_address; + uint8_t attributes; + uint16_t max_packet_size; + uint8_t interval; +} __attribute__((packed)); + +struct hub_desc +{ + uint8_t length; + uint8_t descriptor_type; + uint8_t nbr_ports; + uint16_t hub_characteristics; + uint8_t pwron2pwrgood; + uint8_t hub_contr_current; +} __attribute__((packed)); + +typedef enum +{ + USBDC_COMPOSITE = 0x00, + USBDC_AUDIO = 0x01, + USBDC_COMM_CDC = 0x02, + USBDC_HID = 0x03, + USBDC_PID = 0x05, + USBDC_IMAGE = 0x06, + USBDC_PRINTER = 0x07, + USBDC_MSC = 0x08, + USBDC_HUB = 0x09, + USBDC_CDC_DATA = 0x0A, + USBDC_CHIP = 0x0B, + USBDC_SECURITY = 0x0D, + USBDC_VIDEO = 0x0E, + USBDC_HEALTH = 0x0F, + USBDC_DIAGNOSIS = 0xDC, + USBDC_WIRELESS = 0xE0, + USBDC_MISC = 0xEF, + USBDC_SOFT_SPEC = 0xFE, + USBDC_VENDOR_SPEC = 0xFF +} usb_class_t; + +#endif diff --git a/src/modules/cdi/usb11/include/usb11.h b/src/modules/cdi/usb11/include/usb11.h new file mode 100644 index 0000000..77634e9 --- /dev/null +++ b/src/modules/cdi/usb11/include/usb11.h @@ -0,0 +1,41 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#ifndef USB11_H +#define USB11_H + +#include + +//#define DEBUG + +#ifdef DEBUG +#define d1printf(...) printf("[usb 1.1] " __VA_ARGS__) +#define _d1printf(...) printf(__VA_ARGS__) +#else +#define d1printf(...) +#define _d1printf(...) +#endif + +#define d0printf(...) printf("[usb 1.1] " __VA_ARGS__) +#define _d0printf(...) printf(__VA_ARGS__) + +#endif diff --git a/src/modules/cdi/usb11/main.c b/src/modules/cdi/usb11/main.c new file mode 100644 index 0000000..5594209 --- /dev/null +++ b/src/modules/cdi/usb11/main.c @@ -0,0 +1,82 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include "control.h" +#include "transfer.h" + +#define DRIVER_NAME "USB 1.1" + +int init_usb11(void); + +static struct cdi_usb_driver driver = { + .drv = { + .type = CDI_USB, + .name = DRIVER_NAME, + .devices = NULL, + .init_device = NULL, + .remove_device = NULL, +#ifdef CDI_DRIVER + .init = &init_usb11, +#endif + .destroy = NULL + }, + .speeds = CDI_USB_LOW_SPEED | CDI_USB_FULL_SPEED, + .enumerate_device = &usb11_enumerate, + .send_packets = &usb11_send_packets, + .do_control = &usb11_export_control +}; + +#ifdef CDI_DRIVER +CDI_DRIVER(DRIVER_NAME, driver) +#else +extern int init_ohci(void); +extern int init_uhci(void); +extern int init_usbmsd(void); +#endif + +#if defined CDI_STANDALONE && !defined CDI_DRIVER +int main(void) +#else +int init_usb11() +#endif +{ +#ifndef CDI_DRIVER + cdi_init(); +#endif + + cdi_usb_driver_init(&driver); + +#if defined CDI_STANDALONE && !defined CDI_DRIVER + init_uhci(); + init_ohci(); + init_usbmsd(); + + cdi_usb_driver_register(&driver); + + cdi_run_drivers(); +#endif + + return 0; +} diff --git a/src/modules/cdi/usb11/transfer.c b/src/modules/cdi/usb11/transfer.c new file mode 100644 index 0000000..1ea8dff --- /dev/null +++ b/src/modules/cdi/usb11/transfer.c @@ -0,0 +1,223 @@ +/***************************************************************************** +* Copyright (c) 2009 Max Reitz * +* * +* Permission is hereby granted, free of charge, to any person obtaining a * +* copy of this software and associated documentation files (the "Software"), * +* to deal in the Software without restriction, including without limitation * +* the rights to use, copy, modify, merge, publish, distribute, sublicense, * +* and/or sell copies of the Software, and to permit persons to whom the * +* Software is furnished to do so, subject to the following conditions: * +* * +* The above copyright notice and this permission notice shall be included in * +* all copies or substantial portions of the Software. * +* * +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * +* DEALINGS IN THE SOFTWARE. * +*****************************************************************************/ + +#include +#include + +#include + +#include "transfer.h" +#include "usb11.h" +#include "usb-structs.h" + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +/** + * Verarbeitet USB-Pakete. + * + * @param packet Die Paketliste + * @param num_packets Anzahl der Pakete + * + * @return Status + */ + +cdi_usb_status_t usb11_send_packets(struct cdi_usb_packet *packets, + size_t num_packets) +{ + cdi_usb_status_t error = CDI_USB_NAK; + int i = 0, mps; + int num_out_packets; + struct cdi_usb_pipe *pipe; + struct cdi_usb_device *device; + struct cdi_usb_packet *out_packets; + struct endpoint_desc *ep; + struct cdi_usb_hcd *hcd; + + if (num_packets < 1) { + return CDI_USB_TRIVIAL_ERROR; + } + + // Alle Pakete muessen dieselbe Pipe benutzen + pipe = packets[0].pipe; + for (i = 1; i < (int)num_packets; i++) { + if (packets[i].pipe != pipe) { + return CDI_USB_TRIVIAL_ERROR; + } + } + + device = pipe->device; + hcd = (struct cdi_usb_hcd *)device->hc->dev.driver; + ep = (struct endpoint_desc *)pipe->endpoint; + + // Pruefen, wie viele Pakete wir draus machen muessen + mps = ep->max_packet_size; + num_out_packets = 0; + for (i = 0; i < (int)num_packets; i++) { + int num = (packets[i].length + mps - 1) / mps; + if (num > 0) { + num_out_packets += num; + } else { + // Pakete ohne Daten wollen auch gesendet werden + num_out_packets++; + } + } + + // Ggf. Pakete kopieren und splitten + if (num_out_packets == (int)num_packets) { + out_packets = packets; + } else { + int j; + int cur = 0; + + out_packets = calloc(num_out_packets, sizeof(*out_packets)); + for (i = 0; i < (int)num_packets; i++) { + int num = (packets[i].length + mps - 1) / mps; + if (num == 0) { + num = 1; + } + + for (j = 0; j < num; j++) { + out_packets[cur].pipe = pipe; + out_packets[cur].type = packets[i].type; + out_packets[cur].data = packets[i].data; + out_packets[cur].length = MIN((int)packets[i].length, mps); + out_packets[cur].condition = CDI_USB_NAK; + + packets[i].data = (void *)((uintptr_t)packets[i].data + + out_packets[cur].length); + packets[i].length -= out_packets[cur].length; + cur++; + } + } + } + + error = hcd->send_packets(out_packets, num_out_packets); + if (error & CDI_USB_STALLED) { + d0printf("ENDPOINT 0x%02X OF DEVICE %i STALLED!\n", + ep->endpoint_address, device->id); + usb11_do_control(device, HOST_TO_DEV | NO_DATA, NULL, 0, STD_REQUEST, + REC_ENDPOINT, CLEAR_FEATURE, 0, ep->endpoint_address); + } else if (error & CDI_USB_NAK) { + // Nicht angenommene Pakete (FIXME: einzeln) senden + for (i = 0; i < num_out_packets; i++) { + if (!(out_packets[i].condition & CDI_USB_NAK)) { + continue; + } + error = CDI_USB_NAK; + while (error & CDI_USB_NAK) { + error = hcd->send_packets(&out_packets[i], 1); + if (error & CDI_USB_NAK) { + cdi_sleep_ms(5); + } + } + } + } + + if (out_packets != packets) { + free(out_packets); + } + + return error; +} + +void *usb11_do_control(struct cdi_usb_device *device, int direction, + void *buffer, int length, int rtype, int recipient, int request, int value, + int index) +{ + int no_data, alloced_here = 0; + cdi_usb_status_t rval; + struct setup_packet _setup; + struct setup_packet *setup = &_setup; + + no_data = direction & NO_DATA; + direction &= 0x80; + + setup->request_type = direction | (rtype & 0x60) | (recipient & 0x1F); + setup->request = request; + setup->value = value; + setup->index = index; + setup->length = length; + + struct cdi_usb_packet setup_packet = { + .pipe = device->ep0, + .type = CDI_USB_PACKET_SETUP, + .data = setup, + .length = sizeof(*setup), + .use_toggle = TOGGLE_UNSPECIFIC + }; + + if (usb11_send_packets(&setup_packet, 1)) { + return NULL; + } + + if (no_data) { + rval = CDI_USB_NO_ERROR; + buffer = (void *)0xFFFFFFFF; //Kein Fehler, aber auch keine Daten + } else { + if ((direction != HOST_TO_DEV) || (length && (buffer == NULL))) { + buffer = malloc(length); + alloced_here = 1; + } + + struct cdi_usb_packet data_packet = { + .pipe = device->ep0, + .type = (direction == DEV_TO_HOST ? + CDI_USB_PACKET_IN : CDI_USB_PACKET_OUT), + .data = buffer, + .length = length, + .use_toggle = TOGGLE_UNSPECIFIC + }; + + rval = usb11_send_packets(&data_packet, 1); + } + + if (rval == CDI_USB_NO_ERROR) { + struct cdi_usb_packet ack_packet = { + .pipe = device->ep0, + .data = NULL, + .length = 0, + .use_toggle = TOGGLE_1 + }; + + if (no_data || (direction == HOST_TO_DEV)) { + ack_packet.type = CDI_USB_PACKET_IN; + } else { + ack_packet.type = CDI_USB_PACKET_OUT; + } + + rval = usb11_send_packets(&ack_packet, 1); + } + + if ((rval != CDI_USB_NO_ERROR) && alloced_here) { + free(buffer); + } + + return (rval == CDI_USB_NO_ERROR) ? buffer : NULL; +} + +void *usb11_export_control(struct cdi_usb_device *device, + struct cdi_usb_control_transfer *transfer) +{ + return usb11_do_control(device, transfer->direction, transfer->buffer, + transfer->length, transfer->rtype, transfer->recipient, + transfer->request, transfer->value, transfer->index); +} -- 1.6.4.2 From kevin at tyndur.org Mon Dec 14 23:20:30 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 14 Dec 2009 23:20:30 +0100 Subject: [tyndur-devel] [PATCH 0/4] Kernelfixes fuer Prozessende Message-ID: <1260829234-19909-1-git-send-email-kevin@tyndur.org> Wenn man ordentlich aufräumt, kann man rtl8139 so oft beenden und wieder neu starten wie man will. Und danach sogar noch ohne Rot benutzen. Kevin Wolf (4): kernel: Portfreigabe beim Prozessende gefixt kernel: Timer beim Prozessende immer loeschen kernel: Kindprozesse in destroy_task umhaengen kernel: Beim Prozessende Interrupthandler austragen src/kernel/include/intr.h | 1 + src/kernel/src/intr.c | 14 ++++++++++++++ src/kernel/src/io.c | 2 +- src/kernel/src/task.c | 14 +++++++++++--- 4 files changed, 27 insertions(+), 4 deletions(-) From kevin at tyndur.org Mon Dec 14 23:20:31 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 14 Dec 2009 23:20:31 +0100 Subject: [tyndur-devel] [PATCH 1/4] kernel: Portfreigabe beim Prozessende gefixt In-Reply-To: <1260829234-19909-1-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> Message-ID: <1260829234-19909-2-git-send-email-kevin@tyndur.org> ! kernel: Fuer der Bedeutung eines Bits in der IO-Bitmap gibt es genau zwei Moeglichkeiten, und da waehlt man natuerlich erstmal die falsche. Signed-off-by: Kevin Wolf --- src/kernel/src/io.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/kernel/src/io.c b/src/kernel/src/io.c index c46bfef..04facca 100644 --- a/src/kernel/src/io.c +++ b/src/kernel/src/io.c @@ -200,7 +200,7 @@ void io_ports_release_all(struct task* task) for (i = 0; i < IO_BITMAP_LENGTH / 8; i++) { - if (io_bitmap[i]) { + if (io_bitmap[i] != (byte) -1) { io_ports_release(task, 8*i, 8); } } -- 1.6.0.2 From kevin at tyndur.org Mon Dec 14 23:20:32 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 14 Dec 2009 23:20:32 +0100 Subject: [tyndur-devel] [PATCH 2/4] kernel: Timer beim Prozessende immer loeschen In-Reply-To: <1260829234-19909-1-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> Message-ID: <1260829234-19909-3-git-send-email-kevin@tyndur.org> ! kernel: Ob ein Prozess zu loeschende Timer hat, hat eigentlich nichts damit zu tun, ob er IO-Ports reserviert hat. Signed-off-by: Kevin Wolf --- src/kernel/src/task.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c index fce02cd..9f314eb 100644 --- a/src/kernel/src/task.c +++ b/src/kernel/src/task.c @@ -288,9 +288,7 @@ void destroy_task(struct task* task_ptr) fastrpc(get_task(1), 0, 0, strlen(rpc_init), rpc_init); // Timer freigeben - if (task_ptr->io_bitmap) { - timer_cancel_all(task_ptr); - } + timer_cancel_all(task_ptr); // Alle Ports und die IO-Bitmap des Tasks freigeben if (task_ptr->io_bitmap) { -- 1.6.0.2 From kevin at tyndur.org Mon Dec 14 23:20:33 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 14 Dec 2009 23:20:33 +0100 Subject: [tyndur-devel] [PATCH 3/4] kernel: Kindprozesse in destroy_task umhaengen In-Reply-To: <1260829234-19909-1-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> Message-ID: <1260829234-19909-4-git-send-email-kevin@tyndur.org> ! kernel: Kindprozesse duerfen einen geloeschten Task nicht weiter referenzieren, deswegen werden sie jetzt an init vererbt. Signed-off-by: Kevin Wolf --- src/kernel/src/task.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c index 9f314eb..1a5b47a 100644 --- a/src/kernel/src/task.c +++ b/src/kernel/src/task.c @@ -278,6 +278,13 @@ void destroy_task(struct task* task_ptr) } previous_task->next_task = task_ptr->next_task; } + + // Alle Kindprozesse an init weitervererben + for (next_task = first_task; next_task; next_task = next_task->next_task) { + if (next_task->parent_task == task_ptr) { + next_task->parent_task = get_task(1); + } + } // Melde das Beenden des Tasks per RPC an init -- 1.6.0.2 From kevin at tyndur.org Mon Dec 14 23:20:34 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 14 Dec 2009 23:20:34 +0100 Subject: [tyndur-devel] [PATCH 4/4] kernel: Beim Prozessende Interrupthandler austragen In-Reply-To: <1260829234-19909-1-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> Message-ID: <1260829234-19909-5-git-send-email-kevin@tyndur.org> ! kernel: Interrupts an geloeschte Prozessen zu schicken ist keine besonders gute Idee Signed-off-by: Kevin Wolf --- src/kernel/include/intr.h | 1 + src/kernel/src/intr.c | 14 ++++++++++++++ src/kernel/src/task.c | 3 +++ 3 files changed, 18 insertions(+), 0 deletions(-) diff --git a/src/kernel/include/intr.h b/src/kernel/include/intr.h index f07bf61..a9e558b 100644 --- a/src/kernel/include/intr.h +++ b/src/kernel/include/intr.h @@ -17,6 +17,7 @@ void init_idt(void); void set_intr(int intr, word selector, void* handler, int dpl, int type); void set_intr_handling_task(byte intr, struct task * task); +void remove_intr_handling_task(struct task* task); typedef void(*pfIrqHandler)(int, dword*); diff --git a/src/kernel/src/intr.c b/src/kernel/src/intr.c index 42f64fb..f7c6854 100644 --- a/src/kernel/src/intr.c +++ b/src/kernel/src/intr.c @@ -434,6 +434,20 @@ void set_intr_handling_task(byte intr, struct task * task) } } +void remove_intr_handling_task(struct task* task) +{ + int i, intr; + + for (intr = IRQ_BASE; intr < IRQ_BASE + 0x10; intr++) { + for (i = 0; i < MAX_INTERRUPTS; i++) { + if (intr_handling_task[intr][i] == task) { + intr_handling_task[intr][i] = NULL; + break; + } + } + } +} + void handle_exception(dword* esp) { struct int_stack_frame * isf = *((struct int_stack_frame **)esp); diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c index 1a5b47a..59c05df 100644 --- a/src/kernel/src/task.c +++ b/src/kernel/src/task.c @@ -285,6 +285,9 @@ void destroy_task(struct task* task_ptr) next_task->parent_task = get_task(1); } } + + // Interrupthandler ausschalten + remove_intr_handling_task(task_ptr); // Melde das Beenden des Tasks per RPC an init -- 1.6.0.2 From toni at tyndur.org Tue Dec 15 22:36:57 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 15 Dec 2009 22:36:57 +0100 Subject: [tyndur-devel] [PATCH 1/4] kernel: Portfreigabe beim Prozessende gefixt In-Reply-To: <1260829234-19909-2-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> <1260829234-19909-2-git-send-email-kevin@tyndur.org> Message-ID: <20091215213656.GA23309@neo.geekcave.lan> On Mon, Dec 14 23:20, Kevin Wolf wrote: > ! kernel: Fuer der Bedeutung eines Bits in der IO-Bitmap gibt es genau > zwei Moeglichkeiten, und da waehlt man natuerlich erstmal die falsche. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Tue Dec 15 22:40:02 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 15 Dec 2009 22:40:02 +0100 Subject: [tyndur-devel] [PATCH 2/4] kernel: Timer beim Prozessende immer loeschen In-Reply-To: <1260829234-19909-3-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> <1260829234-19909-3-git-send-email-kevin@tyndur.org> Message-ID: <20091215214002.GB23309@neo.geekcave.lan> On Mon, Dec 14 23:20, Kevin Wolf wrote: > ! kernel: Ob ein Prozess zu loeschende Timer hat, hat eigentlich nichts > damit zu tun, ob er IO-Ports reserviert hat. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Tue Dec 15 22:42:37 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 15 Dec 2009 22:42:37 +0100 Subject: [tyndur-devel] [PATCH 3/4] kernel: Kindprozesse in destroy_task umhaengen In-Reply-To: <1260829234-19909-4-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> <1260829234-19909-4-git-send-email-kevin@tyndur.org> Message-ID: <20091215214236.GC23309@neo.geekcave.lan> On Mon, Dec 14 23:20, Kevin Wolf wrote: > ! kernel: Kindprozesse duerfen einen geloeschten Task nicht weiter > referenzieren, deswegen werden sie jetzt an init vererbt. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Tue Dec 15 22:48:33 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 15 Dec 2009 22:48:33 +0100 Subject: [tyndur-devel] [PATCH 4/4] kernel: Beim Prozessende Interrupthandler austragen In-Reply-To: <1260829234-19909-5-git-send-email-kevin@tyndur.org> References: <1260829234-19909-1-git-send-email-kevin@tyndur.org> <1260829234-19909-5-git-send-email-kevin@tyndur.org> Message-ID: <20091215214832.GD23309@neo.geekcave.lan> On Mon, Dec 14 23:20, Kevin Wolf wrote: > ! kernel: Interrupts an geloeschte Prozessen zu schicken ist keine > besonders gute Idee > > Signed-off-by: Kevin Wolf > --- > src/kernel/include/intr.h | 1 + > src/kernel/src/intr.c | 14 ++++++++++++++ > src/kernel/src/task.c | 3 +++ > 3 files changed, 18 insertions(+), 0 deletions(-) > > diff --git a/src/kernel/include/intr.h b/src/kernel/include/intr.h > index f07bf61..a9e558b 100644 > --- a/src/kernel/include/intr.h > +++ b/src/kernel/include/intr.h > @@ -17,6 +17,7 @@ > void init_idt(void); > void set_intr(int intr, word selector, void* handler, int dpl, int type); > void set_intr_handling_task(byte intr, struct task * task); > +void remove_intr_handling_task(struct task* task); > > typedef void(*pfIrqHandler)(int, dword*); > > diff --git a/src/kernel/src/intr.c b/src/kernel/src/intr.c > index 42f64fb..f7c6854 100644 > --- a/src/kernel/src/intr.c > +++ b/src/kernel/src/intr.c > @@ -434,6 +434,20 @@ void set_intr_handling_task(byte intr, struct task * task) > } > } > > +void remove_intr_handling_task(struct task* task) > +{ > + int i, intr; > + > + for (intr = IRQ_BASE; intr < IRQ_BASE + 0x10; intr++) { Hm also intr_handling_task hat ja 256 Einträge, und set_irq_handling_task scheint da auch keine einschränkung zu machen was man da registrieren darf (nebenbei macht es auch noch einen schönen Buffer overflow, wenn man einen nicht-IRQ registrieren möchte, wenn das mal nichts ist.... ;-)) Vielleicht also besser von 0 bis 256? > + for (i = 0; i < MAX_INTERRUPTS; i++) { > + if (intr_handling_task[intr][i] == task) { > + intr_handling_task[intr][i] = NULL; > + break; > + } > + } > + } > +} > + > void handle_exception(dword* esp) > { > struct int_stack_frame * isf = *((struct int_stack_frame **)esp); > diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c > index 1a5b47a..59c05df 100644 > --- a/src/kernel/src/task.c > +++ b/src/kernel/src/task.c > @@ -285,6 +285,9 @@ void destroy_task(struct task* task_ptr) > next_task->parent_task = get_task(1); > } > } > + > + // Interrupthandler ausschalten > + remove_intr_handling_task(task_ptr); > > > // Melde das Beenden des Tasks per RPC an init -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Tue Dec 15 23:49:40 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Tue, 15 Dec 2009 23:49:40 +0100 Subject: [tyndur-devel] [PATCH v2 4/4] kernel: Beim Prozessende Interrupthandler austragen In-Reply-To: <20091215214832.GD23309@neo.geekcave.lan> References: <20091215214832.GD23309@neo.geekcave.lan> Message-ID: <1260917380-24305-1-git-send-email-kevin@tyndur.org> ! kernel: Interrupts an geloeschte Prozessen zu schicken ist keine besonders gute Idee ! kernel: Buffer Overflow beim Registrieren eines Nicht-IRQ-Interrupts fuer Userspaceprozesse gefixt Signed-off-by: Kevin Wolf --- src/kernel/include/intr.h | 1 + src/kernel/src/intr.c | 17 ++++++++++++++++- src/kernel/src/task.c | 3 +++ 3 files changed, 20 insertions(+), 1 deletions(-) diff --git a/src/kernel/include/intr.h b/src/kernel/include/intr.h index f07bf61..a9e558b 100644 --- a/src/kernel/include/intr.h +++ b/src/kernel/include/intr.h @@ -17,6 +17,7 @@ void init_idt(void); void set_intr(int intr, word selector, void* handler, int dpl, int type); void set_intr_handling_task(byte intr, struct task * task); +void remove_intr_handling_task(struct task* task); typedef void(*pfIrqHandler)(int, dword*); diff --git a/src/kernel/src/intr.c b/src/kernel/src/intr.c index 42f64fb..a317235 100644 --- a/src/kernel/src/intr.c +++ b/src/kernel/src/intr.c @@ -428,12 +428,27 @@ void set_intr_handling_task(byte intr, struct task * task) (i == MAX_INTERRUPTS - 1)) { intr_handling_task[intr][i] = task; - irqs_to_send[intr - IRQ_BASE][i] = 0; + if (intr >= IRQ_BASE && intr < IRQ_BASE + 16) { + irqs_to_send[intr - IRQ_BASE][i] = 0; + } break; } } } +void remove_intr_handling_task(struct task* task) +{ + int i, intr; + + for (intr = 0; intr < 256; intr++) { + for (i = 0; i < MAX_INTERRUPTS; i++) { + if (intr_handling_task[intr][i] == task) { + intr_handling_task[intr][i] = NULL; + } + } + } +} + void handle_exception(dword* esp) { struct int_stack_frame * isf = *((struct int_stack_frame **)esp); diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c index 1a5b47a..59c05df 100644 --- a/src/kernel/src/task.c +++ b/src/kernel/src/task.c @@ -285,6 +285,9 @@ void destroy_task(struct task* task_ptr) next_task->parent_task = get_task(1); } } + + // Interrupthandler ausschalten + remove_intr_handling_task(task_ptr); // Melde das Beenden des Tasks per RPC an init -- 1.6.0.2 From kevin at tyndur.org Tue Dec 15 23:56:35 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Tue, 15 Dec 2009 23:56:35 +0100 Subject: [tyndur-devel] [PATCH] setup: Schweizerdeutsche Tastaturbelegung Message-ID: <1260917795-30037-1-git-send-email-kevin@tyndur.org> + setup: Schweizerdeutsche Tastaturbelegung zur Auswahl stellen Signed-off-by: Kevin Wolf --- src/modules/pas/setup/lang/lang_en.c | 4 ++++ src/modules/pas/setup/lang/resstr.h | 1 + src/modules/pas/setup/setup_keyboard.pas | 25 ++++++++++++++++--------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/modules/pas/setup/lang/lang_en.c b/src/modules/pas/setup/lang/lang_en.c index ed799ed..246a1fc 100644 --- a/src/modules/pas/setup/lang/lang_en.c +++ b/src/modules/pas/setup/lang/lang_en.c @@ -66,6 +66,10 @@ static const struct tms_strings dict[] = { &RESSTR_SETUP_KEYBOARD_RSGERMAN, "German (de)", + // Schweizerdeutsch + &RESSTR_SETUP_KEYBOARD_RSSWISSGERMAN, + "Swiss German (de_ch)", + // US-Amerikanisch &RESSTR_SETUP_KEYBOARD_RSUSAMERICAN, "US American (us)", diff --git a/src/modules/pas/setup/lang/resstr.h b/src/modules/pas/setup/lang/resstr.h index 9fb1e07..ca7098f 100644 --- a/src/modules/pas/setup/lang/resstr.h +++ b/src/modules/pas/setup/lang/resstr.h @@ -38,6 +38,7 @@ extern void* RESSTR_MENU_RSQUIT; extern void* RESSTR_SETUP_KEYBOARD_RSTITLE; extern void* RESSTR_SETUP_KEYBOARD_RSGERMAN; +extern void* RESSTR_SETUP_KEYBOARD_RSSWISSGERMAN; extern void* RESSTR_SETUP_KEYBOARD_RSUSAMERICAN; extern void* RESSTR_SETUP_KEYBOARD_RSBACK; extern void* RESSTR_SETUP_KEYBOARD_RSCHOOSELAYOUT; diff --git a/src/modules/pas/setup/setup_keyboard.pas b/src/modules/pas/setup/setup_keyboard.pas index 1e69ca2..ad9622d 100644 --- a/src/modules/pas/setup/setup_keyboard.pas +++ b/src/modules/pas/setup/setup_keyboard.pas @@ -11,8 +11,9 @@ uses sysutils, tyndur, crt, tui; resourcestring rsTitle = 'tyndur-Konfiguration: Tastaturbelegung'; - rsGerman = 'Deutsch'; - rsUSAmerican = 'US-Amerikanisch'; + rsGerman = 'Deutsch (de)'; + rsSwissGerman = 'Scheizerdeutsch (de_ch)'; + rsUSAmerican = 'US-Amerikanisch (us)'; rsBack = 'Zurück'; rsChooseLayout = 'Bitte wähle aus dem Menü Deine Tastaturbelegung aus.'; @@ -84,9 +85,9 @@ begin f.obj := mainw; if back then begin - num_items := 4; + num_items := 5; end else begin - num_items := 2; + num_items := 3; end; a := TUIMenu.create(num_items); @@ -95,6 +96,7 @@ begin color := 14; AddItem(rsGerman, nil); + AddItem(rsSwissGerman, nil); AddItem(rsUSAmerican, nil); if back then begin AddItem('', nil); @@ -121,15 +123,15 @@ begin SK_UP: begin a.selected := (a.selected + num_items - 1) mod num_items; - if a.selected = 2 then begin - a.selected := 1; + if a.selected = 3 then begin + a.selected := 2; end; end; SK_DOWN: begin a.selected := (a.selected + 1) mod num_items; - if a.selected = 2 then begin - a.selected := 3; + if a.selected = 3 then begin + a.selected := 4; end; end; end; @@ -142,10 +144,15 @@ begin end; 1: begin + SetLayout('de_ch'); + break; + end; + 2: + begin SetLayout('us'); break; end; - 3: break; + 4: break; end; end; until false; -- 1.6.0.2 From toni at tyndur.org Wed Dec 16 00:18:58 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 16 Dec 2009 00:18:58 +0100 Subject: [tyndur-devel] [PATCH v2 4/4] kernel: Beim Prozessende Interrupthandler austragen In-Reply-To: <1260917380-24305-1-git-send-email-kevin@tyndur.org> References: <20091215214832.GD23309@neo.geekcave.lan> <1260917380-24305-1-git-send-email-kevin@tyndur.org> Message-ID: <20091215231858.GE23309@neo.geekcave.lan> On Tue, Dec 15 23:49, Kevin Wolf wrote: > ! kernel: Interrupts an geloeschte Prozessen zu schicken ist keine > besonders gute Idee > ! kernel: Buffer Overflow beim Registrieren eines Nicht-IRQ-Interrupts > fuer Userspaceprozesse gefixt > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Wed Dec 16 00:20:12 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Wed, 16 Dec 2009 00:20:12 +0100 Subject: [tyndur-devel] [PATCH] setup: Schweizerdeutsche Tastaturbelegung In-Reply-To: <1260917795-30037-1-git-send-email-kevin@tyndur.org> References: <1260917795-30037-1-git-send-email-kevin@tyndur.org> Message-ID: <20091215232012.GF23309@neo.geekcave.lan> On Tue, Dec 15 23:56, Kevin Wolf wrote: > + setup: Schweizerdeutsche Tastaturbelegung zur Auswahl stellen > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Fri Dec 18 23:14:16 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Fri, 18 Dec 2009 23:14:16 +0100 Subject: [tyndur-devel] [PATCH 2/9] lpt: ScanFile in Klasse ausgelagert In-Reply-To: <1260725504-9035-3-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> <1260725504-9035-3-git-send-email-toni@tyndur.org> Message-ID: <20091218221415.GA2463@silvanus> On Sun, Dec 13, 2009 at 06:31:37PM +0100, Antoine Kaufmann wrote: > * lpt: ScanFile in Klasse ausgelagert, damit die Parserfunktion spaeter > auch fuer die Paketinformationen benutzt werden kann. > > Signed-off-by: Antoine Kaufmann > --- > src/modules/pas/lpt/helpers.pas | 87 +-------------------- > src/modules/pas/lpt/pkglist.pas | 161 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 166 insertions(+), 82 deletions(-) > create mode 100644 src/modules/pas/lpt/pkglist.pas > > diff --git a/src/modules/pas/lpt/helpers.pas b/src/modules/pas/lpt/helpers.pas > index b26ff4b..67b02ed 100644 > --- a/src/modules/pas/lpt/helpers.pas > +++ b/src/modules/pas/lpt/helpers.pas > @@ -2,7 +2,8 @@ unit helpers; > {$MODE ObjFPC} > > interface > -uses crt, sysutils, dos, classes, tar, packages, tcpip, http, multilang; > +uses crt, sysutils, dos, classes, tar, packages, tcpip, http, multilang, > + pkglist; > > procedure ScanFile(pkgset: TPackageSet; filename, repository: String); > procedure DrawProgress(http: HTTPRequest); > @@ -127,88 +128,10 @@ end; > > procedure ScanFile(pkgset: TPackageSet; filename, repository: String); > var > - f: Text; > - line: String; > - status: integer; > - > - pkg: TPackage; > - section: TPackageSection; > - version: TPackageVersion; > + plp: TPkglistParser; > begin > - Assign(f, filename); > - Reset(f); > - status := 0; > - pkg := nil; > - try > - while not eof(f) do begin > - ReadLn(f, line); > - > - if line = '' then begin > - continue; > - end; > - > - case line[1] of > - 'P': > - begin > - status := 1; > - pkg := pkgset.add(Copy(line, 3, length(line))); > - end; > - 'D': > - if status = 1 then begin > - pkg.desc := Copy(line, 3, length(line)); > - end else begin > - raise EPackageFileFormat.create( > - 'D in status ' + IntToStr(status)); > - end; > - 'S': > - if status >= 1 then begin > - status := 2; > - section := pkg.add(Copy(line, 3, length(line))); > - end else begin > - raise EPackageFileFormat.create( > - 'S in status ' + IntToStr(status)); > - end; > - 'V': > - if status >= 2 then begin > - status := 3; > - version := section.add(Copy(line, 3, length(line))); > - version.pkg := pkg; > - version.section := section; > - version.repository := repository; > - end else begin > - raise EPackageFileFormat.create( > - 'V in status ' + IntToStr(status)); > - end; > - 's': > - if status >= 3 then begin > - version.size := StrToInt(Copy(line, 3, length(line))); > - end else begin > - raise EPackageFileFormat.create( > - 's in status ' + IntToStr(status)); > - end; > - 'd': > - if status >= 3 then begin > - if length(line) < 2 then begin > - raise EPackageFileFormat.create( > - 'Einsames d'); > - end; > - > - version.addDependency(line[2], Copy(line, 4, length(line))); > - > - end else begin > - raise EPackageFileFormat.create( > - 'd in status ' + IntToStr(status)); > - end; > - else > - begin > - raise EPackageFileFormat.create( > - 'Unbekannter Schluessel: ' + line[1]); > - end; > - end; > - end; > - finally > - Close(f); > - end; > + plp := TPkglistParser.create(pkgset); > + plp.ProcessFile(filename, repository); Wird plp hier geleakt? > end; > > procedure Untar(tar: TTarArchive; targetpath: String = 'file:/'); > diff --git a/src/modules/pas/lpt/pkglist.pas b/src/modules/pas/lpt/pkglist.pas > new file mode 100644 > index 0000000..996bd9d > --- /dev/null > +++ b/src/modules/pas/lpt/pkglist.pas > @@ -0,0 +1,161 @@ > +unit pkglist; > +{$MODE ObjFPC} > + > +interface > +uses classes, sysutils, packages; > + > +type > + TPkglistParser = class > + private > + status: Integer; > + package: TPackage; > + section: TPackageSection; > + version: TPackageVersion; > + pkgset: TPackageSet; > + > + public > + (** > + * Konstruktor. > + * > + * @param ps PakageSet in dem die angegebenen Pakete erfasst werden > + * sollen. > + *) > + constructor Create(ps: TPackageSet); > + > + (** > + * Einzelne Zeile der pkglist verarbeiten. > + * > + * @param line Zeile > + * @param repo Repository-Url, die in den Paketen eingetragen werden > + * soll. > + *) > + procedure ProcessLine(line, repo: String); > + > + (** > + * pkglist-Datei verarbeiten > + * > + * @param path Pfad zur Datei > + * @param repo Repository-Url, die in den Paketen eingetragen werden > + * soll. > + *) > + procedure ProcessFile(path, repo: String); > + end; > + > +implementation > + > +(** > + * Konstruktor. > + * > + * @param ps PakageSet in dem die angegebenen Pakete erfasst werden > + * sollen. > + *) > +constructor TPkglistParser.Create(ps: TPackageSet); > +begin > + status := 0; > + package := nil; > + section := nil; > + version := nil; > + pkgset := ps; > +end; > + > +(** > + * Einzelne Zeile der pkglist verarbeiten. > + * > + * @param line Zeile > + * @param repo Repository-Url, die in den Paketen eingetragen werden > + * soll. > + *) > +procedure TPkglistParser.ProcessLine(line, repo: String); > +begin > + if line = '' then begin > + Exit; > + end; > + > + case line[1] of > + 'P': > + begin > + status := 1; > + package := pkgset.add(Copy(line, 3, length(line))); > + end; > + 'D': > + if status = 1 then begin > + package.desc := Copy(line, 3, length(line)); > + end else begin > + raise EPackageFileFormat.create( > + 'D in status ' + IntToStr(status)); > + end; > + 'S': > + if status >= 1 then begin > + status := 2; > + section := package.add(Copy(line, 3, length(line))); > + end else begin > + raise EPackageFileFormat.create( > + 'S in status ' + IntToStr(status)); > + end; > + 'V': > + if status >= 2 then begin > + status := 3; > + version := section.add(Copy(line, 3, length(line))); > + version.pkg := package; > + version.section := section; > + version.repository := repo; > + end else begin > + raise EPackageFileFormat.create( > + 'V in status ' + IntToStr(status)); > + end; > + 's': > + if status >= 3 then begin > + version.size := StrToInt(Copy(line, 3, length(line))); > + end else begin > + raise EPackageFileFormat.create( > + 's in status ' + IntToStr(status)); > + end; > + 'd': > + if status >= 3 then begin > + if length(line) < 2 then begin > + raise EPackageFileFormat.create( > + 'Einsames d'); > + end; > + > + version.addDependency(line[2], Copy(line, 4, length(line))); > + > + end else begin > + raise EPackageFileFormat.create( > + 'd in status ' + IntToStr(status)); > + end; > + else > + begin > + raise EPackageFileFormat.create( > + 'Unbekannter Schluessel: ' + line[1]); > + end; > + end; > +end; > + > + > +(** > + * pkglist-Datei verarbeiten > + * > + * @param path Pfad zur Datei > + * @param repo Repository-Url, die in den Paketen eingetragen werden > + * soll. > + *) > +procedure TPkglistParser.ProcessFile(path, repo: String); > +var > + f: Text; > + l: String; > +begin > + Assign(f, path); > + Reset(f); > + > + try > + while not Eof(f) do begin > + ReadLn(f, l); > + ProcessLine(l, repo); > + end; > + finally > + Close(f); > + end; > +end; > + > +begin Wenn da nichts drin steht ist das begin überflüssig. > +end. > -- > 1.6.3.3 Ansonsten dürfte das so hinkommen. From kevin at tyndur.org Fri Dec 18 23:21:19 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Fri, 18 Dec 2009 23:21:19 +0100 Subject: [tyndur-devel] [PATCH 3/9] lpt: pkglist-Format fuer Paketinformationen verwenden In-Reply-To: <1260725504-9035-4-git-send-email-toni@tyndur.org> References: <1260725504-9035-1-git-send-email-toni@tyndur.org> <1260725504-9035-4-git-send-email-toni@tyndur.org> Message-ID: <20091218222119.GB2463@silvanus> On Sun, Dec 13, 2009 at 06:31:38PM +0100, Antoine Kaufmann wrote: > * lpt: pkglist-Format fuer Paketinformationen verwenden > > Signed-off-by: Antoine Kaufmann > --- > src/modules/pas/lpt/lang/lang_en.c | 4 -- > src/modules/pas/lpt/lang/resstr.h | 1 - > src/modules/pas/lpt/repository_single.pas | 52 +++++++--------------------- > 3 files changed, 13 insertions(+), 44 deletions(-) > > diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c > index 177089f..74d7c1d 100644 > --- a/src/modules/pas/lpt/lang/lang_en.c > +++ b/src/modules/pas/lpt/lang/lang_en.c > @@ -132,10 +132,6 @@ static const struct tms_strings dict[] = { > &RESSTR_REPOSITORY_HTTP_RSDOWNLOADINGPKGLIST, > "Downloading package list %s from %s", > > - // Keine (lokale Datei) > - &RESSTR_REPOSITORY_SINGLE_RSLOCALPKGDESC, > - "None (local file)", > - > 0, > 0, > }; > diff --git a/src/modules/pas/lpt/lang/resstr.h b/src/modules/pas/lpt/lang/resstr.h > index 3ddace7..7b9b3ca 100644 > --- a/src/modules/pas/lpt/lang/resstr.h > +++ b/src/modules/pas/lpt/lang/resstr.h > @@ -52,6 +52,5 @@ extern void* RESSTR_REPOSITORIES_RSUNKNOWNREPOTYPE; > extern void* RESSTR_REPOSITORIES_RSINVALIDPKGSRC; > extern void* RESSTR_REPOSITORY_BASE_RSNOPACKAGELIST; > extern void* RESSTR_REPOSITORY_HTTP_RSDOWNLOADINGPKGLIST; > -extern void* RESSTR_REPOSITORY_SINGLE_RSLOCALPKGDESC; > > #endif > diff --git a/src/modules/pas/lpt/repository_single.pas b/src/modules/pas/lpt/repository_single.pas > index 8ab1e2b..d1f100c 100644 > --- a/src/modules/pas/lpt/repository_single.pas > +++ b/src/modules/pas/lpt/repository_single.pas > @@ -2,7 +2,7 @@ unit repository_single; > {$MODE ObjFPC} > > interface > -uses sysutils, classes, tar, packages, helpers, repository_base; > +uses sysutils, classes, tar, packages, helpers, repository_base, pkglist; > > type > TSFRepository = class(TRepository) > @@ -16,9 +16,6 @@ type > > implementation > > -resourcestring > - rsLocalPkgDesc = 'Keine (lokale Datei)'; > - > constructor TSFRepository.create(parent : TCollection); > begin > inherited; > @@ -49,56 +46,33 @@ var > package: TTarArchive; > line: String; > i: integer; > - size: integer; > > package_file_string: String; > - pkg_name, pkg_version, pkg_section, pkg_arch: String; > > + plp: TPkglistParser; > pkg: TPackage; > section: TPackageSection; > version: TPackageVersion; > begin > + plp := TPkglistParser.create(pkgset); Ich glaube, das wird schon wieder geleakt > package := TTarArchive.create(self.url); > while package.hasNext do begin > line := package.nextFilename; > - size := package.nextSize; > i := Pos('packageinfo', line); > - if i > 0 then begin > + if (i > 0) then begin Ich bin von der Notwendigkeit dieser Änderung nicht hundertprozentig überzeugt. ;-) > (* Metadaten laden *) > package_file_string := package.ExtractString(); > > - (* Newline-getrennte Infos auslesen. *) > - (* In Reihenfolge: Name, Version, Sektion, Architektur *) > - i := Pos(#10, package_file_string); > - pkg_name := Copy(package_file_string, 1, i - 1); > - package_file_string := > - Copy(package_file_string, i + 1, Length(package_file_string)); > - > - i := Pos(#10, package_file_string); > - pkg_version := Copy(package_file_string, 1, i - 1); > - package_file_string := > - Copy(package_file_string, i + 1, Length(package_file_string)); > - > - i := Pos(#10, package_file_string); > - pkg_section := Copy(package_file_string, 1, i - 1); > - package_file_string := > - Copy(package_file_string, i + 1, Length(package_file_string)); > - > - i := Pos(#10, package_file_string); > - pkg_arch := Copy(package_file_string, 1, i - 1); > - package_file_string := > - Copy(package_file_string, i + 1, Length(package_file_string)); > + while Length(package_file_string) > 0 do begin > + i := Pos(#10, package_file_string); > + if i <= 0 then begin > + i := Length(package_file_string); > + end; Wenn die Datei mal nicht mit einem Zeilenumbruch aufhören würde, schneiden wir mit i := length unten das letzte Zeichen ab, oder? > > - (* Pr??fen ob Metadaten zu Paket passen *) > - if (line = 'packages/'+pkg_name+'/'+pkg_version+'/packageinfo-'+pkg_section) then begin > - pkg := pkgset.add(pkg_name); > - pkg.desc := rsLocalPkgDesc; > - section := pkg.add(pkg_section); > - version := section.add(pkg_version); > - version.pkg := pkg; > - version.section := section; > - version.repository := self.name; > - break; > + line := Copy(package_file_string, 1, i - 1); > + plp.ProcessLine(line, self.name); > + package_file_string := Copy(package_file_string, i + 1, > + Length(package_file_string)); > end; > end else begin > package.skipFile(); > -- > 1.6.3.3 > > _______________________________________________ > tyndur-devel mailing list > tyndur-devel at tyndur.org > http://list.tyndur.org/mailman/listinfo/tyndur-devel From kevin at tyndur.org Sun Dec 20 11:52:45 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 20 Dec 2009 11:52:45 +0100 Subject: [tyndur-devel] [PATCH] ata: Fix fuer Fehlerbehandlung in ATAPI Message-ID: <1261306365-31807-1-git-send-email-kevin@tyndur.org> ! ata: Das Fehlerregister ist nur gueltig, wenn ERR im Statusregister gesetzt ist. Signed-off-by: Kevin Wolf --- src/modules/cdi/ata/atapi.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/cdi/ata/atapi.c b/src/modules/cdi/ata/atapi.c index 28b823a..77b1074 100644 --- a/src/modules/cdi/ata/atapi.c +++ b/src/modules/cdi/ata/atapi.c @@ -119,6 +119,7 @@ int atapi_request(struct cdi_scsi_device* scsi,struct cdi_scsi_packet* packet) if (ata_request(&request)) { + int status; struct ata_request rw_request = { .dev = dev, .flags = { @@ -138,8 +139,13 @@ int atapi_request(struct cdi_scsi_device* scsi,struct cdi_scsi_packet* packet) if (packet->direction==CDI_SCSI_READ) ata_protocol_pio_in(&rw_request); else if (packet->direction==CDI_SCSI_WRITE) ata_protocol_pio_in(&rw_request); - // Sense Key zurueck - return (ata_reg_inb(dev->controller,REG_ERROR)>>4); + // Bei Fehler den Sense Key zurueckgeben + status = ata_reg_inb(dev->controller, REG_STATUS); + if (status & STATUS_ERR) { + return (ata_reg_inb(dev->controller, REG_ERROR) >> 4); + } else { + return 0; + } } return 0xB; -- 1.6.0.2 From kevin at tyndur.org Sun Dec 20 11:52:57 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 20 Dec 2009 11:52:57 +0100 Subject: [tyndur-devel] [PATCH] build: FPC-Aufruf fuer natives Bauen angepasst Message-ID: <1261306377-31998-1-git-send-email-kevin@tyndur.org> * build: Der FPC-Aufruf war bisher fuer Bauen unter Linux geeignet. Wenn wir nativ bauen, wollen wir die RTL aber schon dabeihaben. Signed-off-by: Kevin Wolf --- src/modules/c/build/build.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/modules/c/build/build.c b/src/modules/c/build/build.c index 4c899c8..9c340f0 100644 --- a/src/modules/c/build/build.c +++ b/src/modules/c/build/build.c @@ -45,12 +45,13 @@ static const char* cflags = "-m32 -g -O0 -Wall -fno-stack-protector -nostdinc" " -fno-leading-underscore -fno-omit-frame-pointer -fno-strict-aliasing" " -fno-builtin -c"; +static const char* fpcflags = "-n -Cn -CX -Ttyndur"; #else //static const char* cflags = "-c -combine"; static const char* cflags = "-c"; +static const char* fpcflags = "-Cn -CX -Ttyndur"; #endif -static const char* fpcflags = "-n -Cn -CX -Tlost"; static const char* nasmflags = "-felf"; static const char* gasflags = "-m32 -c"; -- 1.6.0.2 From kevin at tyndur.org Sun Dec 20 13:18:02 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Sun, 20 Dec 2009 13:18:02 +0100 Subject: [tyndur-devel] [PATCH] kedit: Mehrsprachige Strings Message-ID: <1261311482-14162-1-git-send-email-kevin@tyndur.org> + kedit: Englischsprachige Strings * kedit: Versionsnummer aus der Menueleiste unten entfernt, dafuer Hinweis auf Syntaxhighlighting mit F8 eingefuegt. Signed-off-by: Kevin Wolf --- src/modules/pas/kedit/Makefile.all | 2 +- src/modules/pas/kedit/kedit.pas | 17 ++++++- src/modules/pas/kedit/kedit_input.pas | 8 ++- src/modules/pas/kedit/kedit_main.pas | 28 +++++++--- src/modules/pas/kedit/kedit_tui.pas | 8 ++- src/modules/pas/kedit/lang/Makefile.conf | 1 + src/modules/pas/kedit/lang/lang_en.c | 79 ++++++++++++++++++++++++++++++ src/modules/pas/kedit/lang/resstr.h | 40 +++++++++++++++ 8 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 src/modules/pas/kedit/lang/Makefile.conf create mode 100644 src/modules/pas/kedit/lang/lang_en.c create mode 100644 src/modules/pas/kedit/lang/resstr.h diff --git a/src/modules/pas/kedit/Makefile.all b/src/modules/pas/kedit/Makefile.all index f3697e4..7f4d2d0 100644 --- a/src/modules/pas/kedit/Makefile.all +++ b/src/modules/pas/kedit/Makefile.all @@ -1,4 +1,4 @@ shopt -s extglob echo "LD $1/kedit" -"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` +"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` strip -s kedit -o $1/apps/kedit diff --git a/src/modules/pas/kedit/kedit.pas b/src/modules/pas/kedit/kedit.pas index 54ea9d8..992bd0e 100644 --- a/src/modules/pas/kedit/kedit.pas +++ b/src/modules/pas/kedit/kedit.pas @@ -2,7 +2,7 @@ program KEdit; {$H+} uses - crt, sysutils, tyndur, + dos, crt, sysutils, tyndur, multilang, kedit_tui, kedit_buf, kedit_input, kedit_main; type @@ -227,10 +227,25 @@ begin until exitEditor; end; +procedure SetLang; +var + name: String; + lang: TLanguage; +begin + name := GetEnv('LANG'); + if name <> '' then begin + lang := GetLanguage(name); + if lang <> nil then begin + SetLanguage(lang); + end; + end; +end; + var i: integer; begin DisableFlushing(output); + SetLang; New(state.text); for i:=1 to ParamCount do begin diff --git a/src/modules/pas/kedit/kedit_input.pas b/src/modules/pas/kedit/kedit_input.pas index 493d6b8..2d4f33a 100644 --- a/src/modules/pas/kedit/kedit_input.pas +++ b/src/modules/pas/kedit/kedit_input.pas @@ -17,6 +17,10 @@ implementation uses sysutils, crt, kedit_buf; +resourcestring + rsFileNotSaved = 'Die Datei ist noch nicht gespeichert. Speichern?'; + + procedure uih_save_file(state: pkedit_state); begin if state^.readonly then begin @@ -30,7 +34,7 @@ end; procedure uih_load_file(state: pkedit_state); begin - if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of + if changed then case YesNoCancel(rsFileNotSaved, true) of OPT_YES: SaveFile(state); OPT_NO: changed := false; OPT_CANCEL: {do nothing}; @@ -52,7 +56,7 @@ end; procedure uih_quit(state: pkedit_state); begin - if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of + if changed then case YesNoCancel(rsFileNotSaved, true) of OPT_YES: SaveFile(state); OPT_NO: changed := false; OPT_CANCEL: {do nothing}; diff --git a/src/modules/pas/kedit/kedit_main.pas b/src/modules/pas/kedit/kedit_main.pas index a62f794..a2714e0 100644 --- a/src/modules/pas/kedit/kedit_main.pas +++ b/src/modules/pas/kedit/kedit_main.pas @@ -45,6 +45,12 @@ implementation uses crt, dos, sysutils, strutils, kedit_tui; +resourcestring + rsFilename = 'Dateiname'; + rsFileIsReadOnly = 'Die Datei %s existiert und ist schreibgeschützt. [ENTER]'; + rsOverwriteExistingFile = 'Die Datei %s gibt''s schon. Überschreiben?'; + rsFileNotFound = 'Datei %s nicht gefunden.'; + function RTrim(stext: string):string; begin @@ -93,16 +99,15 @@ begin TextBackground(1); // Dateinamen abfragen + GotoXY(1,1); + Write(space(79)); if filename='(unbenannt)' then begin GotoXY(1,1); - Write('Dateiname:'+Space(69)); - GotoXY(12,1); + Write(rsFilename, ': '); ReadLn(savename); end else begin GotoXY(1,1); - Write(space(79)); - GotoXY(1,1); - Write('Dateiname [',filename,']: '); + Write(rsFilename, ' [',filename,']: '); ReadLn(savename); if savename='' then begin savename := filename; @@ -122,12 +127,12 @@ begin GotoXY(1,1); if attr and dos.ReadOnly = dos.Readonly then begin - Write('Die Datei ',savename,' existiert und ist schreibgeschützt. [ENTER]'); + Write(Format(rsFileIsReadOnly, [savename])); Textbackground(0); readkey; exit; end else begin - case YesNoCancel('Die Datei ' + savename + ' gibt''s schon. Überschreiben?', false) of + case YesNoCancel(Format(rsOverwriteExistingFile, [savename]), false) of OPT_YES: {Do nothing}; OPT_NO: exit; end; @@ -173,7 +178,7 @@ begin if loadname = '' then begin Textbackground(1); gotoxy(1,1); Write(space(79)); - gotoxy(1,1); Write('Zu ladende Datei: '); ReadLn(loadname); + gotoxy(1,1); Write(rsFilename, ': '); ReadLn(loadname); Textbackground(0); end; @@ -190,8 +195,13 @@ begin exit; end else begin gotoxy(1,1); Write(space(79)); - gotoxy(1,1); Textbackground(4); Write('Datei ', loadname, ' nicht gefunden.'); Textbackground(0); + + gotoxy(1,1); + Textbackground(4); + Write(Format(rsFileNotFound, [loadname])); + Textbackground(0); readkey; + gotoxy(1,1); Write(space(79)); exit; end; diff --git a/src/modules/pas/kedit/kedit_tui.pas b/src/modules/pas/kedit/kedit_tui.pas index 5b767ba..14a56b4 100644 --- a/src/modules/pas/kedit/kedit_tui.pas +++ b/src/modules/pas/kedit/kedit_tui.pas @@ -35,6 +35,10 @@ uses crt, strutils, sysutils, syntax, syntax_c, syntax_pas, syntax_intel, syntax_atandt; +resourcestring + rsMenuBar = 'F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einfügen/Ersetzen'; + rsMenuBarReadOnly = 'F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einfügen/Ersetzen'; + var highlighter: TSyntax; @@ -266,9 +270,9 @@ begin TextBackground(1); TextColor(7); if state^.readonly then begin - Write('F2: R/W laden, F3: Laden, F10: Beenden, EINFG: Einfügen/Ersetzen ['+Version+']'#27'[K'); + Write(rsMenuBarReadOnly, #27'[K'); end else begin - Write('F2: Speichern, F3: Laden, F10: Beenden, EINFG: Einfügen/Ersetzen ['+Version+']'#27'[K'); + Write(rsMenuBar, #27'[K'); end; // Cursor richtig in den Text setzen diff --git a/src/modules/pas/kedit/lang/Makefile.conf b/src/modules/pas/kedit/lang/Makefile.conf new file mode 100644 index 0000000..594ef2a --- /dev/null +++ b/src/modules/pas/kedit/lang/Makefile.conf @@ -0,0 +1 @@ +CC_FLAGS_APPEND="-Wno-missing-braces" diff --git a/src/modules/pas/kedit/lang/lang_en.c b/src/modules/pas/kedit/lang/lang_en.c new file mode 100644 index 0000000..9712ec8 --- /dev/null +++ b/src/modules/pas/kedit/lang/lang_en.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2009 The tyndur Project. All rights reserved. + * + * This code is derived from software contributed to the tyndur Project + * by Kevin Wolf. + * + * 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. + * + * 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 +#include "resstr.h" + +static int get_number(int n) +{ + return (n == 1 ? 0 : 1); +} + +static const struct tms_strings dict[] = { + // Die Datei ist noch nicht gespeichert. Speichern? + &RESSTR_KEDIT_INPUT_RSFILENOTSAVED, + "The file has not been saved yet. Save it now?", + + // Dateiname + &RESSTR_KEDIT_MAIN_RSFILENAME, + "File name", + + // Die Datei %s existiert und ist schreibgeschützt + &RESSTR_KEDIT_MAIN_RSFILEISREADONLY, + "The file %s exists already and is write protected", + + // Die Datei %s gibt's schon. Überschreiben? + &RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE, + "The file %s exists already. Overwrite it?", + + // Datei %s nicht gefunden. + &RESSTR_KEDIT_MAIN_RSFILENOTFOUND, + "File %s could not be found.", + + // F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden, + // EINFG: Einfügen/Ersetzen + &RESSTR_KEDIT_TUI_RSMENUBAR, + "F2: Save, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace", + + // F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden, + // EINFG: Einf'#195#188'gen/Ersetzen + &RESSTR_KEDIT_TUI_RSMENUBARREADONLY, + "F2: Open R/W, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace", + + 0, + 0, +}; + +static const struct tms_lang lang = { + .lang = "en", + .numbers = 2, + .get_number = get_number, + .strings = dict, +}; + +LANGUAGE(&lang) diff --git a/src/modules/pas/kedit/lang/resstr.h b/src/modules/pas/kedit/lang/resstr.h new file mode 100644 index 0000000..1c0c61b --- /dev/null +++ b/src/modules/pas/kedit/lang/resstr.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2009 The tyndur Project. All rights reserved. + * + * This code is derived from software contributed to the tyndur Project + * by Kevin Wolf. + * + * 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. + * + * 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. + */ + +#ifndef RESSTR_H +#define RESSTR_H + +extern void* RESSTR_KEDIT_INPUT_RSFILENOTSAVED; +extern void* RESSTR_KEDIT_MAIN_RSFILENAME; +extern void* RESSTR_KEDIT_MAIN_RSFILEISREADONLY; +extern void* RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE; +extern void* RESSTR_KEDIT_MAIN_RSFILENOTFOUND; +extern void* RESSTR_KEDIT_TUI_RSMENUBAR; +extern void* RESSTR_KEDIT_TUI_RSMENUBARREADONLY; + +#endif -- 1.6.0.2 From toni at tyndur.org Mon Dec 21 16:33:58 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 16:33:58 +0100 Subject: [tyndur-devel] [PATCH] build: FPC-Aufruf fuer natives Bauen angepasst In-Reply-To: <1261306377-31998-1-git-send-email-kevin@tyndur.org> References: <1261306377-31998-1-git-send-email-kevin@tyndur.org> Message-ID: <20091221153357.GA7894@neo.geekcave.lan> On Sun, Dec 20 11:52, Kevin Wolf wrote: > * build: Der FPC-Aufruf war bisher fuer Bauen unter Linux geeignet. Wenn > wir nativ bauen, wollen wir die RTL aber schon dabeihaben. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Mon Dec 21 16:54:07 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 16:54:07 +0100 Subject: [tyndur-devel] [PATCH 0/3] setup: Netzwerkkonfiguration Message-ID: <1261410850-29673-1-git-send-email-kevin@tyndur.org> TUI für die Netzwerkkonfiguration in setup Kevin Wolf (3): config/servmgr: Mehr Netzwerkkarten setup: Netzwerkkonfiguration config: Netzwerkkonfiguration beim ersten Start starten build/root-common/config/servmgr/default/deps | 2 +- build/root-common/config/servmgr/e1000/cmd | 1 + build/root-common/config/servmgr/e1000/deps | 2 + build/root-common/config/servmgr/ne2k/cmd | 1 + build/root-common/config/servmgr/ne2k/deps | 2 + build/root-common/config/servmgr/nic/cmd | 1 + build/root-common/config/servmgr/nic/conf | 1 + build/root-common/config/servmgr/nic/deps | 1 + build/root-common/config/servmgr/pcnet/cmd | 1 + build/root-common/config/servmgr/pcnet/deps | 2 + build/root-common/config/servmgr/sis900/cmd | 1 + build/root-common/config/servmgr/sis900/deps | 2 + build/root-floppy/config/keyboard.lsh | 2 +- build/root-hd/config/keyboard.lsh | 2 +- src/modules/pas/setup/lang/lang_en.c | 32 +++ src/modules/pas/setup/lang/resstr.h | 9 + src/modules/pas/setup/menu.pas | 27 ++- src/modules/pas/setup/setup_network.pas | 341 +++++++++++++++++++++++++ 18 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 build/root-common/config/servmgr/e1000/cmd create mode 100644 build/root-common/config/servmgr/e1000/deps create mode 100644 build/root-common/config/servmgr/ne2k/cmd create mode 100644 build/root-common/config/servmgr/ne2k/deps create mode 100644 build/root-common/config/servmgr/nic/cmd create mode 100644 build/root-common/config/servmgr/nic/conf create mode 100644 build/root-common/config/servmgr/nic/deps create mode 100644 build/root-common/config/servmgr/pcnet/cmd create mode 100644 build/root-common/config/servmgr/pcnet/deps create mode 100644 build/root-common/config/servmgr/sis900/cmd create mode 100644 build/root-common/config/servmgr/sis900/deps create mode 100644 src/modules/pas/setup/setup_network.pas From kevin at tyndur.org Mon Dec 21 16:54:08 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 16:54:08 +0100 Subject: [tyndur-devel] [PATCH 1/3] config/servmgr: Mehr Netzwerkkarten In-Reply-To: <1261410850-29673-1-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> Message-ID: <1261410850-29673-2-git-send-email-kevin@tyndur.org> + config/servmgr: Services fuer alle Netzwerktreiber definiert * config/servmgr: Anstatt rtl8139 direkt in default zu laden, wird jetzt nic geladen, das eine Abhaengigkeit auf die aktuell eingestellte Netzwerkkarte hat Signed-off-by: Kevin Wolf --- build/root-common/config/servmgr/default/deps | 2 +- build/root-common/config/servmgr/e1000/cmd | 1 + build/root-common/config/servmgr/e1000/deps | 2 ++ build/root-common/config/servmgr/ne2k/cmd | 1 + build/root-common/config/servmgr/ne2k/deps | 2 ++ build/root-common/config/servmgr/nic/cmd | 1 + build/root-common/config/servmgr/nic/conf | 1 + build/root-common/config/servmgr/nic/deps | 1 + build/root-common/config/servmgr/pcnet/cmd | 1 + build/root-common/config/servmgr/pcnet/deps | 2 ++ build/root-common/config/servmgr/sis900/cmd | 1 + build/root-common/config/servmgr/sis900/deps | 2 ++ 12 files changed, 16 insertions(+), 1 deletions(-) create mode 100644 build/root-common/config/servmgr/e1000/cmd create mode 100644 build/root-common/config/servmgr/e1000/deps create mode 100644 build/root-common/config/servmgr/ne2k/cmd create mode 100644 build/root-common/config/servmgr/ne2k/deps create mode 100644 build/root-common/config/servmgr/nic/cmd create mode 100644 build/root-common/config/servmgr/nic/conf create mode 100644 build/root-common/config/servmgr/nic/deps create mode 100644 build/root-common/config/servmgr/pcnet/cmd create mode 100644 build/root-common/config/servmgr/pcnet/deps create mode 100644 build/root-common/config/servmgr/sis900/cmd create mode 100644 build/root-common/config/servmgr/sis900/deps diff --git a/build/root-common/config/servmgr/default/deps b/build/root-common/config/servmgr/default/deps index e9898e5..ebdafbb 100644 --- a/build/root-common/config/servmgr/default/deps +++ b/build/root-common/config/servmgr/default/deps @@ -2,5 +2,5 @@ getterm1 getterm2 getterm3 getterm4 -rtl8139 +nic mount diff --git a/build/root-common/config/servmgr/e1000/cmd b/build/root-common/config/servmgr/e1000/cmd new file mode 100644 index 0000000..60952c6 --- /dev/null +++ b/build/root-common/config/servmgr/e1000/cmd @@ -0,0 +1 @@ +/modules/e1000 diff --git a/build/root-common/config/servmgr/e1000/deps b/build/root-common/config/servmgr/e1000/deps new file mode 100644 index 0000000..7f5df2b --- /dev/null +++ b/build/root-common/config/servmgr/e1000/deps @@ -0,0 +1,2 @@ +pci +tcpip diff --git a/build/root-common/config/servmgr/ne2k/cmd b/build/root-common/config/servmgr/ne2k/cmd new file mode 100644 index 0000000..f4e866f --- /dev/null +++ b/build/root-common/config/servmgr/ne2k/cmd @@ -0,0 +1 @@ +/modules/ne2k diff --git a/build/root-common/config/servmgr/ne2k/deps b/build/root-common/config/servmgr/ne2k/deps new file mode 100644 index 0000000..7f5df2b --- /dev/null +++ b/build/root-common/config/servmgr/ne2k/deps @@ -0,0 +1,2 @@ +pci +tcpip diff --git a/build/root-common/config/servmgr/nic/cmd b/build/root-common/config/servmgr/nic/cmd new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/build/root-common/config/servmgr/nic/cmd @@ -0,0 +1 @@ + diff --git a/build/root-common/config/servmgr/nic/conf b/build/root-common/config/servmgr/nic/conf new file mode 100644 index 0000000..2140a3b --- /dev/null +++ b/build/root-common/config/servmgr/nic/conf @@ -0,0 +1 @@ +nowait diff --git a/build/root-common/config/servmgr/nic/deps b/build/root-common/config/servmgr/nic/deps new file mode 100644 index 0000000..27d043c --- /dev/null +++ b/build/root-common/config/servmgr/nic/deps @@ -0,0 +1 @@ +rtl8139 diff --git a/build/root-common/config/servmgr/pcnet/cmd b/build/root-common/config/servmgr/pcnet/cmd new file mode 100644 index 0000000..254da69 --- /dev/null +++ b/build/root-common/config/servmgr/pcnet/cmd @@ -0,0 +1 @@ +/modules/pcnet diff --git a/build/root-common/config/servmgr/pcnet/deps b/build/root-common/config/servmgr/pcnet/deps new file mode 100644 index 0000000..7f5df2b --- /dev/null +++ b/build/root-common/config/servmgr/pcnet/deps @@ -0,0 +1,2 @@ +pci +tcpip diff --git a/build/root-common/config/servmgr/sis900/cmd b/build/root-common/config/servmgr/sis900/cmd new file mode 100644 index 0000000..b123fe0 --- /dev/null +++ b/build/root-common/config/servmgr/sis900/cmd @@ -0,0 +1 @@ +/modules/sis900 diff --git a/build/root-common/config/servmgr/sis900/deps b/build/root-common/config/servmgr/sis900/deps new file mode 100644 index 0000000..7f5df2b --- /dev/null +++ b/build/root-common/config/servmgr/sis900/deps @@ -0,0 +1,2 @@ +pci +tcpip -- 1.6.0.2 From kevin at tyndur.org Mon Dec 21 16:54:09 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 16:54:09 +0100 Subject: [tyndur-devel] [PATCH 2/3] setup: Netzwerkkonfiguration In-Reply-To: <1261410850-29673-1-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> Message-ID: <1261410850-29673-3-git-send-email-kevin@tyndur.org> + setup: Modul fuer die Netzwerkkonfiguration Signed-off-by: Kevin Wolf --- src/modules/pas/setup/lang/lang_en.c | 32 +++ src/modules/pas/setup/lang/resstr.h | 9 + src/modules/pas/setup/menu.pas | 27 ++- src/modules/pas/setup/setup_network.pas | 341 +++++++++++++++++++++++++++++++ 4 files changed, 399 insertions(+), 10 deletions(-) create mode 100644 src/modules/pas/setup/setup_network.pas diff --git a/src/modules/pas/setup/lang/lang_en.c b/src/modules/pas/setup/lang/lang_en.c index 246a1fc..bc9fcba 100644 --- a/src/modules/pas/setup/lang/lang_en.c +++ b/src/modules/pas/setup/lang/lang_en.c @@ -53,6 +53,10 @@ static const struct tms_strings dict[] = { &RESSTR_MENU_RSMODLPT, "lpt repositories", + // Netzwerk + &RESSTR_MENU_RSMODNETWORK, + "Network", + // Beenden &RESSTR_MENU_RSQUIT, "Quit", @@ -108,6 +112,34 @@ static const struct tms_strings dict[] = { "Back", + //tyndur-Konfiguration: Netzwerk + &RESSTR_SETUP_NETWORK_RSTITLE, + "tyndur Configuration: Network", + + // Bitte in folgende Felder die Netzwerkeinstellungen eintragen: + &RESSTR_SETUP_NETWORK_RSCONFIGURENETWORK, + "Please enter your network configuration below:", + + // Treiber + &RESSTR_SETUP_NETWORK_RSDRIVER, + "Driver", + + // IP-Adresse + &RESSTR_SETUP_NETWORK_RSIPADDRESS, + "IP address", + + // Gateway + &RESSTR_SETUP_NETWORK_RSGATEWAY, + "Gateway", + + // OK + &RESSTR_SETUP_NETWORK_RSOK, + "OK", + + // Abbrechen + &RESSTR_SETUP_NETWORK_RSCANCEL, + "Cancel", + 0, 0, }; diff --git a/src/modules/pas/setup/lang/resstr.h b/src/modules/pas/setup/lang/resstr.h index ca7098f..9fb95ef 100644 --- a/src/modules/pas/setup/lang/resstr.h +++ b/src/modules/pas/setup/lang/resstr.h @@ -34,6 +34,7 @@ extern void* RESSTR_P$SETUP_RSTITLE; extern void* RESSTR_MENU_RSCHOOSEMODULE; extern void* RESSTR_MENU_RSMODKEYBOARD; extern void* RESSTR_MENU_RSMODLPT; +extern void* RESSTR_MENU_RSMODNETWORK; extern void* RESSTR_MENU_RSQUIT; extern void* RESSTR_SETUP_KEYBOARD_RSTITLE; @@ -50,4 +51,12 @@ extern void* RESSTR_SETUP_LPT_RSSTABLE; extern void* RESSTR_SETUP_LPT_RSCURRENT; extern void* RESSTR_SETUP_LPT_RSBACK; +extern void* RESSTR_SETUP_NETWORK_RSTITLE; +extern void* RESSTR_SETUP_NETWORK_RSCONFIGURENETWORK; +extern void* RESSTR_SETUP_NETWORK_RSDRIVER; +extern void* RESSTR_SETUP_NETWORK_RSIPADDRESS; +extern void* RESSTR_SETUP_NETWORK_RSGATEWAY; +extern void* RESSTR_SETUP_NETWORK_RSOK; +extern void* RESSTR_SETUP_NETWORK_RSCANCEL; + #endif diff --git a/src/modules/pas/setup/menu.pas b/src/modules/pas/setup/menu.pas index f2f49b3..da4b4a5 100644 --- a/src/modules/pas/setup/menu.pas +++ b/src/modules/pas/setup/menu.pas @@ -8,13 +8,14 @@ function StartModule(module: String; back: boolean): boolean; implementation -uses tyndur, crt, setup_keyboard, setup_lpt; +uses tyndur, crt, setup_keyboard, setup_lpt, setup_network; resourcestring rsChooseModule = 'Bitte wähle aus dem Menü das gewünschte Konfigurationsprogramm aus.'; rsModKeyboard = 'Tastaturbelegung'; rsModLpt = 'lpt-Quellen'; + rsModNetwork = 'Netzwerk'; rsQuit = 'Beenden'; function StartModule(module: String; back: boolean): boolean; @@ -23,6 +24,10 @@ begin SetupKeyboard(back); end else if module = 'lpt' then begin SetupLPT(back); + end else if module = 'network' then begin + SetupNetwork(back, false); + end else if module = 'network-detect' then begin + SetupNetwork(back, true); end else begin exit(false); end; @@ -45,18 +50,19 @@ begin mainw.spacer := true; frame.obj := mainw; - a := TUIMenu.create(4); + a := TUIMenu.create(5); with a do begin bgcolor := 0; color := 14; AddItem(rsModKeyboard, nil); AddItem(rsModLpt, nil); + AddItem(rsModNetwork, nil); AddItem('', nil); AddItem(rsQuit, nil); end; mainw[1] := a; - mainw.fixed[1] := 4; + mainw.fixed[1] := 5; b := TUILabel.create; b.content := Utf8Decode(rsChooseModule); @@ -74,16 +80,16 @@ begin case ReadEscapeSequence of SK_UP: begin - a.selected := (a.selected + 4 - 1) mod 4; - if a.selected = 2 then begin - a.selected := 1; + a.selected := (a.selected + 5 - 1) mod 5; + if a.selected = 3 then begin + a.selected := 2; end; end; SK_DOWN: begin - a.selected := (a.selected + 1) mod 4; - if a.selected = 2 then begin - a.selected := 3; + a.selected := (a.selected + 1) mod 5; + if a.selected = 3 then begin + a.selected := 4; end; end; end; @@ -91,7 +97,8 @@ begin case a.selected of 0: StartModule('keyboard', true); 1: StartModule('lpt', true); - 3: break; + 2: StartModule('network', true); + 4: break; end; end; until false; diff --git a/src/modules/pas/setup/setup_network.pas b/src/modules/pas/setup/setup_network.pas new file mode 100644 index 0000000..941f2f3 --- /dev/null +++ b/src/modules/pas/setup/setup_network.pas @@ -0,0 +1,341 @@ +unit setup_network; +{$MODE ObjFPC} + +interface + +procedure SetupNetwork(back, autodetect: boolean); + +implementation + +uses dos, sysutils, tyndur, crt, tui; + +resourcestring + rsTitle = 'tyndur-Konfiguration: Netzwerk'; + rsConfigureNetwork = 'Bitte in folgende Felder die Netzwerkeinstellungen eintragen:'; + + rsDriver = 'Treiber'; + rsIPAddress = 'IP-Adresse'; + rsGateway = 'Gateway'; + + rsOK = 'OK'; + rsCancel = 'Abbrechen'; + +function c_servmgr_need(service_name: PChar): boolean; cdecl; external name 'servmgr_need'; + +procedure SetNetworkConfig(driver, ip, gateway: AnsiString); +var + path: String; + f: text; +begin + // Treiber laden + c_servmgr_need(@driver[1]); + + // IP/Gateway setzen + path := 'tcpip:/' + driver + '/0/ip'; + Assign(f, path); +{$i-} + Rewrite(f); +{$i+} + if IOResult = 0 then begin + WriteLn(f, ip); + Close(f); + end; + + path := 'tcpip:/route'; + Assign(f, path); + Rewrite(f); + WriteLn(f, '0.0.0.0 ', gateway, ' 0.0.0.0'); + Close(f); + + // Dauerhaft speichern + path := 'file:/config/servmgr/tcpip/cmd'; + Assign(f, path); + Rewrite(f); + WriteLn(f, '/modules/tcpip ip=', ip, ' gw=', gateway); + Close(f); + + path := 'file:/config/servmgr/nic/deps'; + Assign(f, path); + Rewrite(f); + WriteLn(f, driver); + Close(f); +end; + +procedure GetNetworkConfig(var driver, ip, gateway: AnsiString); +var + path: String; + f: text; + s: String; + space: integer; +begin + ip := '10.0.2.14'; + gateway := '10.0.2.2'; + + // IP und Gateway aus dem tcpip-Aufruf rauspfriemeln + path := 'file:/config/servmgr/tcpip/cmd'; + Assign(f, path); + Reset(f); + ReadLn(f, s); + Close(f); + + repeat + space := Pos(' ' , s); + if space <= 0 then begin + space := Length(s) + 1; + end; + + if Copy(s, 1, 3) = 'ip=' then begin + ip := Copy(s, 4, space - 4); + end else if Copy(s, 1, 3) = 'gw=' then begin + gateway := Copy(s, 4, space - 4); + end; + + s := Copy(s, space + 1, Length(s)); + until s = ''; + + // Der Treiber steht in den Abhaengigkeiten von nic + path := 'file:/config/servmgr/nic/deps'; + Assign(f, path); + Reset(f); + ReadLn(f, driver); + Close(f); +end; + +procedure DetectNetworkConfig(var driver, ip, gateway: AnsiString); +var + srec: SearchRec; +begin + GetNetworkConfig(driver, ip, gateway); + driver := ''; + + dos.FindFirst('pci:/devices/*', 0, srec); + while (driver = '') and (DosError = 0) do begin + if srec.name = '10ec:8139' then begin + driver := 'rtl8139'; + end else if srec.name = '10ec:8029' then begin + driver := 'ne2k'; + end else if srec.name = '1039:0900' then begin + driver := 'sis900'; + end else if srec.name = '8086:100e' then begin + driver := 'e1000'; + end else if srec.name = '1022:2000' then begin + driver := 'pcnet'; + end; + dos.FindNext(srec); + end; + dos.FindClose(srec); +end; + +procedure SetupNetwork(back, autodetect: boolean); +var + mainw: TUIRowContainer; + + b: TUILabel; + + cntDriver: TUIColContainer; + txtDriver: TUILabel; + txtDriverValue: TUILabel; + + cntIP: TUIColContainer; + txtIP: TUILabel; + txtIPValue: TUILabel; + + cntGateway: TUIColContainer; + txtGateway: TUILabel; + txtGatewayValue: TUILabel; + + buttons: TUIColContainer; + btnOk: TUIButton; + btnCancel: TUIButton; + + screen: TUIRowContainer; + title: TUILabel; + f: TUIFrame; + + +const + num_items = 5; +var + items: Array[0..num_items - 1] of TUILabel; + cur_item: integer; + i: integer; + + driver, ip, gateway: AnsiString; + + c: char; +begin + screen := TUIRowContainer.create(2); + screen.bgcolor := 2; + screen.color := 1; + + title := TUILabel.create; + title.content := rsTitle; + title.bgcolor := 1; + title.color := 15; + screen[0] := title; + screen.fixed[0] := 1; + + f := TUIFrame.create(nil, 60, 12); + screen[1] := f; + screen.prop[1] := 1; + + mainw := TUIRowContainer.create(6); + f.obj := mainw; + + b := TUILabel.create; + b.content := Utf8Decode(rsConfigureNetwork); + mainw[0] := b; + mainw.prop[0] := 30; + + // Treiberauswahl + txtDriver := TUILabel.create; + txtDriver.content := rsDriver + ':'; + + txtDriverValue := TUILabel.create; + txtDriverValue.bgcolor := 1; + txtDriverValue.color := 14; + + cntDriver := TUIColContainer.create(2); + cntDriver.prop[0] := 1; + cntDriver.prop[1] := 1; + cntDriver[0] := txtDriver; + cntDriver[1] := txtDriverValue; + + mainw[1] := cntDriver; + mainw.fixed[1] := 1; + + // IP-Adresse + txtIP := TUILabel.create; + txtIP.content := rsIPAddress + ':'; + + txtIPValue := TUILabel.create; + txtIPValue.color := 14; + + cntIP := TUIColContainer.create(2); + cntIP.prop[0] := 1; + cntIP.prop[1] := 1; + cntIP[0] := txtIP; + cntIP[1] := txtIPValue; + + mainw[2] := cntIP; + mainw.fixed[2] := 1; + + // Gateway + txtGateway := TUILabel.create; + txtGateway.content := rsGateway + ':'; + + txtGatewayValue := TUILabel.create; + txtGatewayValue.color := 14; + + cntGateway := TUIColContainer.create(2); + cntGateway.prop[0] := 1; + cntGateway.prop[1] := 1; + cntGateway[0] := txtGateway; + cntGateway[1] := txtGatewayValue; + + mainw[3] := cntGateway; + mainw.fixed[3] := 1; + + // OK / Abbrechen + btnOK := TUIButton.create; + btnOK.content := rsOK; + btnOK.color := 15; + + btnCancel := TUIButton.create; + btnCancel.content := rsCancel; + btnCancel.color := 15; + + buttons := TUIColContainer.create(5); + + buttons[0] := TUIObject.create; + buttons[2] := TUIObject.create; + buttons[4] := TUIObject.create; + + buttons.prop[0] := 1; + buttons.prop[2] := 1; + buttons.prop[4] := 1; + + buttons[1] := btnOK; + buttons[3] := btnCancel; + + buttons.fixed[1] := 15; + buttons.fixed[3] := 15; + + mainw[4] := TUIObject.create; + mainw[5] := buttons; + mainw.prop[4] := 10; + mainw.fixed[5] := 1; + + + // Reihenfolge der Felder + cur_item := 3; + items[0] := txtDriverValue; + items[1] := txtIPValue; + items[2] := txtGatewayValue; + items[3] := btnOK; + items[4] := btnCancel; + + // Standardwerte setzen + if autodetect then begin + DetectNetworkConfig(driver, ip, gateway); + end else begin + GetNetworkConfig(driver, ip, gateway); + end; + + txtDriverValue.content := driver; + txtIPValue.content := ip; + txtGatewayValue.content := gateway; + + repeat + // Ausgewaehltes Widget markieren + for i := 0 to num_items - 1 do begin + if i = cur_item then begin + items[i].bgcolor := 1; + end else begin + items[i].bgcolor := 0; + end; + end; + + // Zeichnen + screen.align(80, 24); + screen.draw(1, 1); + + // Eingabe verarbeiten + c := readkey; + case c of + #27: + case ReadEscapeSequence of + SK_UP: cur_item := (cur_item + num_items - 1) + mod num_items; + SK_DOWN: cur_item := (cur_item + 1) mod num_items; + end; + #9: + cur_item := (cur_item + 1) mod num_items; + #10: + case cur_item of + 3: + begin + SetNetworkConfig(txtDriverValue.content, + txtIPValue.content, txtGatewayValue.content); + break; + end; + 4: break; + end; + 'A'..'Z', 'a'..'z', '0'..'9', '.': + if not (items[cur_item] is TUIButton) then begin + items[cur_item].content := items[cur_item].content + c; + end; + #8: + if not (items[cur_item] is TUIButton) then begin + items[cur_item].content := Copy(items[cur_item].content, 1, + Length(items[cur_item].content) - 1); + end; + end; + until false; + + f.obj := nil; + mainw.free; + screen.free; +end; + +end. -- 1.6.0.2 From kevin at tyndur.org Mon Dec 21 16:54:10 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 16:54:10 +0100 Subject: [tyndur-devel] [PATCH 3/3] config: Netzwerkkonfiguration beim ersten Start starten In-Reply-To: <1261410850-29673-1-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> Message-ID: <1261410850-29673-4-git-send-email-kevin@tyndur.org> + config: Nachdem der Benutzer beim ersten Start seine Tastaturbelegung ausgewaehlt hat, darf er dann gleich auch noch das Netzwerk erledigen Signed-off-by: Kevin Wolf --- build/root-floppy/config/keyboard.lsh | 2 +- build/root-hd/config/keyboard.lsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/root-floppy/config/keyboard.lsh b/build/root-floppy/config/keyboard.lsh index 22eaf78..1a9525f 100644 --- a/build/root-floppy/config/keyboard.lsh +++ b/build/root-floppy/config/keyboard.lsh @@ -1,3 +1,3 @@ #!file:/apps/sh -setup keyboard quit +setup keyboard network-detect quit diff --git a/build/root-hd/config/keyboard.lsh b/build/root-hd/config/keyboard.lsh index 22eaf78..1a9525f 100644 --- a/build/root-hd/config/keyboard.lsh +++ b/build/root-hd/config/keyboard.lsh @@ -1,3 +1,3 @@ #!file:/apps/sh -setup keyboard quit +setup keyboard network-detect quit -- 1.6.0.2 From kevin at tyndur.org Mon Dec 21 16:54:42 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 16:54:42 +0100 Subject: [tyndur-devel] [PATCH] tcpip: Pagefault beim Hinzufuegen neuer Routen Message-ID: <1261410882-30173-1-git-send-email-kevin@tyndur.org> ! tcpip: Wenn eine neue Route angegeben wird, muss sie auch erstmal angelegt werden, sonst ist sie ziemlich NULL Signed-off-by: Kevin Wolf --- src/modules/tcpip/lostio_if.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/modules/tcpip/lostio_if.c b/src/modules/tcpip/lostio_if.c index e4ebe57..32fdf44 100644 --- a/src/modules/tcpip/lostio_if.c +++ b/src/modules/tcpip/lostio_if.c @@ -501,6 +501,12 @@ int lostio_route_close(lostio_filehandle_t *handle) if (failed == FALSE) { struct routing_entry *entry = enum_routing_entry(0); + + if (entry == NULL) { + entry = calloc(1, sizeof(*entry)); + add_routing_entry(entry); + } + entry->target = ips[0]; entry->gateway = ips[1]; entry->subnet = ips[2]; -- 1.6.0.2 From toni at tyndur.org Mon Dec 21 21:36:16 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 21:36:16 +0100 Subject: [tyndur-devel] [PATCH] ata: Fix fuer Fehlerbehandlung in ATAPI In-Reply-To: <1261306365-31807-1-git-send-email-kevin@tyndur.org> References: <1261306365-31807-1-git-send-email-kevin@tyndur.org> Message-ID: <20091221203616.GB7894@neo.geekcave.lan> On Sun, Dec 20 11:52, Kevin Wolf wrote: > ! ata: Das Fehlerregister ist nur gueltig, wenn ERR im Statusregister > gesetzt ist. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Mon Dec 21 22:51:53 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 22:51:53 +0100 Subject: [tyndur-devel] [PATCH] iso9660: Fehlerbehandlung beim Lesen Message-ID: <1261432313-23554-1-git-send-email-kevin@tyndur.org> ! iso9660: Wenn beim Lesen vom Dateisystem etwas schiefgeht, liefert der Cache NULL zurueck, was man dann auch pruefen sollte Signed-off-by: Kevin Wolf --- src/modules/cdi/iso9660/sector.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/cdi/iso9660/sector.c b/src/modules/cdi/iso9660/sector.c index 645fb10..5e765ea 100644 --- a/src/modules/cdi/iso9660/sector.c +++ b/src/modules/cdi/iso9660/sector.c @@ -26,6 +26,8 @@ #include "iso9660_cdi.h" +#define MIN(a,b) ((a) > (b) ? (b) : (a)) + /** * Reads data from device for cache * @param cache CDI cache @@ -56,15 +58,25 @@ size_t iso9660_read(struct iso9660_fs_res *res,size_t pos,size_t size,void *buff while (rem_size>0) { //debug("Block: 0x%x\n",res->data_sector+block++); - struct cdi_cache_block *cache_block = cdi_cache_block_get(res->cache,res->data_sector+block++,0); - size_t cur_size = rem_size>res->voldesc->sector_size?res->voldesc->sector_size:rem_size; + struct cdi_cache_block* cache_block; + size_t cur_size; + + cache_block = cdi_cache_block_get(res->cache, res->data_sector + block, 0); + if (cache_block == NULL) { + break; + } + + cur_size = MIN(rem_size, res->voldesc->sector_size); + memcpy(buffer,cache_block->data+offset,cur_size); cdi_cache_block_release(res->cache,cache_block); + + block++; buffer += cur_size; rem_size -= cur_size; offset = 0; } - return size; + return size - rem_size; } -- 1.6.0.2 From toni at tyndur.org Mon Dec 21 23:23:04 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 23:23:04 +0100 Subject: [tyndur-devel] [PATCH] kedit: Mehrsprachige Strings In-Reply-To: <1261311482-14162-1-git-send-email-kevin@tyndur.org> References: <1261311482-14162-1-git-send-email-kevin@tyndur.org> Message-ID: <20091221222304.GC7894@neo.geekcave.lan> On Sun, Dec 20 13:18, Kevin Wolf wrote: > + kedit: Englischsprachige Strings > * kedit: Versionsnummer aus der Menueleiste unten entfernt, dafuer > Hinweis auf Syntaxhighlighting mit F8 eingefuegt. > > Signed-off-by: Kevin Wolf > --- > src/modules/pas/kedit/Makefile.all | 2 +- > src/modules/pas/kedit/kedit.pas | 17 ++++++- > src/modules/pas/kedit/kedit_input.pas | 8 ++- > src/modules/pas/kedit/kedit_main.pas | 28 +++++++--- > src/modules/pas/kedit/kedit_tui.pas | 8 ++- > src/modules/pas/kedit/lang/Makefile.conf | 1 + > src/modules/pas/kedit/lang/lang_en.c | 79 ++++++++++++++++++++++++++++++ > src/modules/pas/kedit/lang/resstr.h | 40 +++++++++++++++ > 8 files changed, 168 insertions(+), 15 deletions(-) > create mode 100644 src/modules/pas/kedit/lang/Makefile.conf > create mode 100644 src/modules/pas/kedit/lang/lang_en.c > create mode 100644 src/modules/pas/kedit/lang/resstr.h > > diff --git a/src/modules/pas/kedit/Makefile.all b/src/modules/pas/kedit/Makefile.all > index f3697e4..7f4d2d0 100644 > --- a/src/modules/pas/kedit/Makefile.all > +++ b/src/modules/pas/kedit/Makefile.all > @@ -1,4 +1,4 @@ > shopt -s extglob > echo "LD $1/kedit" > -"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` > +"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` > strip -s kedit -o $1/apps/kedit > diff --git a/src/modules/pas/kedit/kedit.pas b/src/modules/pas/kedit/kedit.pas > index 54ea9d8..992bd0e 100644 > --- a/src/modules/pas/kedit/kedit.pas > +++ b/src/modules/pas/kedit/kedit.pas > @@ -2,7 +2,7 @@ program KEdit; > {$H+} > > uses > - crt, sysutils, tyndur, > + dos, crt, sysutils, tyndur, multilang, > kedit_tui, kedit_buf, kedit_input, kedit_main; > > type > @@ -227,10 +227,25 @@ begin > until exitEditor; > end; > > +procedure SetLang; > +var > + name: String; > + lang: TLanguage; > +begin > + name := GetEnv('LANG'); > + if name <> '' then begin > + lang := GetLanguage(name); > + if lang <> nil then begin > + SetLanguage(lang); > + end; > + end; > +end; > + > var > i: integer; > begin > DisableFlushing(output); > + SetLang; > > New(state.text); > for i:=1 to ParamCount do begin > diff --git a/src/modules/pas/kedit/kedit_input.pas b/src/modules/pas/kedit/kedit_input.pas > index 493d6b8..2d4f33a 100644 > --- a/src/modules/pas/kedit/kedit_input.pas > +++ b/src/modules/pas/kedit/kedit_input.pas > @@ -17,6 +17,10 @@ implementation > > uses sysutils, crt, kedit_buf; > > +resourcestring > + rsFileNotSaved = 'Die Datei ist noch nicht gespeichert. Speichern?'; > + > + > procedure uih_save_file(state: pkedit_state); > begin > if state^.readonly then begin > @@ -30,7 +34,7 @@ end; > > procedure uih_load_file(state: pkedit_state); > begin > - if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of > + if changed then case YesNoCancel(rsFileNotSaved, true) of > OPT_YES: SaveFile(state); > OPT_NO: changed := false; > OPT_CANCEL: {do nothing}; > @@ -52,7 +56,7 @@ end; > > procedure uih_quit(state: pkedit_state); > begin > - if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of > + if changed then case YesNoCancel(rsFileNotSaved, true) of > OPT_YES: SaveFile(state); > OPT_NO: changed := false; > OPT_CANCEL: {do nothing}; > diff --git a/src/modules/pas/kedit/kedit_main.pas b/src/modules/pas/kedit/kedit_main.pas > index a62f794..a2714e0 100644 > --- a/src/modules/pas/kedit/kedit_main.pas > +++ b/src/modules/pas/kedit/kedit_main.pas > @@ -45,6 +45,12 @@ implementation > uses crt, dos, sysutils, strutils, kedit_tui; > > > +resourcestring > + rsFilename = 'Dateiname'; > + rsFileIsReadOnly = 'Die Datei %s existiert und ist schreibgesch??tzt. [ENTER]'; > + rsOverwriteExistingFile = 'Die Datei %s gibt''s schon. ??berschreiben?'; > + rsFileNotFound = 'Datei %s nicht gefunden.'; > + > > function RTrim(stext: string):string; > begin > @@ -93,16 +99,15 @@ begin > TextBackground(1); > > // Dateinamen abfragen > + GotoXY(1,1); > + Write(space(79)); > if filename='(unbenannt)' then begin > GotoXY(1,1); > - Write('Dateiname:'+Space(69)); > - GotoXY(12,1); > + Write(rsFilename, ': '); > ReadLn(savename); > end else begin > GotoXY(1,1); > - Write(space(79)); > - GotoXY(1,1); > - Write('Dateiname [',filename,']: '); > + Write(rsFilename, ' [',filename,']: '); > ReadLn(savename); > if savename='' then begin > savename := filename; > @@ -122,12 +127,12 @@ begin > GotoXY(1,1); > > if attr and dos.ReadOnly = dos.Readonly then begin > - Write('Die Datei ',savename,' existiert und ist schreibgesch??tzt. [ENTER]'); > + Write(Format(rsFileIsReadOnly, [savename])); > Textbackground(0); > readkey; > exit; > end else begin > - case YesNoCancel('Die Datei ' + savename + ' gibt''s schon. ??berschreiben?', false) of > + case YesNoCancel(Format(rsOverwriteExistingFile, [savename]), false) of > OPT_YES: {Do nothing}; > OPT_NO: exit; > end; > @@ -173,7 +178,7 @@ begin > if loadname = '' then begin > Textbackground(1); > gotoxy(1,1); Write(space(79)); > - gotoxy(1,1); Write('Zu ladende Datei: '); ReadLn(loadname); > + gotoxy(1,1); Write(rsFilename, ': '); ReadLn(loadname); > Textbackground(0); > end; > > @@ -190,8 +195,13 @@ begin > exit; > end else begin > gotoxy(1,1); Write(space(79)); > - gotoxy(1,1); Textbackground(4); Write('Datei ', loadname, ' nicht gefunden.'); Textbackground(0); > + > + gotoxy(1,1); > + Textbackground(4); > + Write(Format(rsFileNotFound, [loadname])); > + Textbackground(0); > readkey; > + > gotoxy(1,1); Write(space(79)); > exit; > end; > diff --git a/src/modules/pas/kedit/kedit_tui.pas b/src/modules/pas/kedit/kedit_tui.pas > index 5b767ba..14a56b4 100644 > --- a/src/modules/pas/kedit/kedit_tui.pas > +++ b/src/modules/pas/kedit/kedit_tui.pas > @@ -35,6 +35,10 @@ uses > crt, strutils, sysutils, > syntax, syntax_c, syntax_pas, syntax_intel, syntax_atandt; > > +resourcestring > + rsMenuBar = 'F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einf??gen/Ersetzen'; > + rsMenuBarReadOnly = 'F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einf??gen/Ersetzen'; > + > var > highlighter: TSyntax; > > @@ -266,9 +270,9 @@ begin > TextBackground(1); > TextColor(7); > if state^.readonly then begin > - Write('F2: R/W laden, F3: Laden, F10: Beenden, EINFG: Einf??gen/Ersetzen ['+Version+']'#27'[K'); > + Write(rsMenuBarReadOnly, #27'[K'); > end else begin > - Write('F2: Speichern, F3: Laden, F10: Beenden, EINFG: Einf??gen/Ersetzen ['+Version+']'#27'[K'); > + Write(rsMenuBar, #27'[K'); > end; > > // Cursor richtig in den Text setzen > diff --git a/src/modules/pas/kedit/lang/Makefile.conf b/src/modules/pas/kedit/lang/Makefile.conf > new file mode 100644 > index 0000000..594ef2a > --- /dev/null > +++ b/src/modules/pas/kedit/lang/Makefile.conf > @@ -0,0 +1 @@ > +CC_FLAGS_APPEND="-Wno-missing-braces" > diff --git a/src/modules/pas/kedit/lang/lang_en.c b/src/modules/pas/kedit/lang/lang_en.c > new file mode 100644 > index 0000000..9712ec8 > --- /dev/null > +++ b/src/modules/pas/kedit/lang/lang_en.c > @@ -0,0 +1,79 @@ > +/* > + * Copyright (c) 2009 The tyndur Project. All rights reserved. > + * > + * This code is derived from software contributed to the tyndur Project > + * by Kevin Wolf. > + * > + * 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. Hat es einen speziellen Grund, dass hier nur 2 Klauseln stehen? > + * > + * 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 > +#include "resstr.h" > + > +static int get_number(int n) > +{ > + return (n == 1 ? 0 : 1); > +} > + > +static const struct tms_strings dict[] = { > + // Die Datei ist noch nicht gespeichert. Speichern? > + &RESSTR_KEDIT_INPUT_RSFILENOTSAVED, > + "The file has not been saved yet. Save it now?", > + > + // Dateiname > + &RESSTR_KEDIT_MAIN_RSFILENAME, > + "File name", > + > + // Die Datei %s existiert und ist schreibgesch??tzt > + &RESSTR_KEDIT_MAIN_RSFILEISREADONLY, > + "The file %s exists already and is write protected", > + > + // Die Datei %s gibt's schon. ??berschreiben? > + &RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE, > + "The file %s exists already. Overwrite it?", > + > + // Datei %s nicht gefunden. > + &RESSTR_KEDIT_MAIN_RSFILENOTFOUND, > + "File %s could not be found.", > + > + // F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden, > + // EINFG: Einf??gen/Ersetzen > + &RESSTR_KEDIT_TUI_RSMENUBAR, > + "F2: Save, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace", > + > + // F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden, > + // EINFG: Einf'#195#188'gen/Ersetzen > + &RESSTR_KEDIT_TUI_RSMENUBARREADONLY, > + "F2: Open R/W, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace", > + > + 0, > + 0, > +}; > + > +static const struct tms_lang lang = { > + .lang = "en", > + .numbers = 2, > + .get_number = get_number, > + .strings = dict, > +}; > + > +LANGUAGE(&lang) > diff --git a/src/modules/pas/kedit/lang/resstr.h b/src/modules/pas/kedit/lang/resstr.h > new file mode 100644 > index 0000000..1c0c61b > --- /dev/null > +++ b/src/modules/pas/kedit/lang/resstr.h > @@ -0,0 +1,40 @@ > +/* > + * Copyright (c) 2009 The tyndur Project. All rights reserved. > + * > + * This code is derived from software contributed to the tyndur Project > + * by Kevin Wolf. > + * > + * 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. > + * > + * 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. > + */ > + > +#ifndef RESSTR_H > +#define RESSTR_H > + > +extern void* RESSTR_KEDIT_INPUT_RSFILENOTSAVED; > +extern void* RESSTR_KEDIT_MAIN_RSFILENAME; > +extern void* RESSTR_KEDIT_MAIN_RSFILEISREADONLY; > +extern void* RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE; > +extern void* RESSTR_KEDIT_MAIN_RSFILENOTFOUND; > +extern void* RESSTR_KEDIT_TUI_RSMENUBAR; > +extern void* RESSTR_KEDIT_TUI_RSMENUBARREADONLY; > + > +#endif Ansonsten: Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Mon Dec 21 23:26:36 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 23:26:36 +0100 Subject: [tyndur-devel] [PATCH 1/3] config/servmgr: Mehr Netzwerkkarten In-Reply-To: <1261410850-29673-2-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> <1261410850-29673-2-git-send-email-kevin@tyndur.org> Message-ID: <20091221222636.GD7894@neo.geekcave.lan> On Mon, Dec 21 16:54, Kevin Wolf wrote: > + config/servmgr: Services fuer alle Netzwerktreiber definiert > * config/servmgr: Anstatt rtl8139 direkt in default zu laden, wird jetzt > nic geladen, das eine Abhaengigkeit auf die aktuell eingestellte > Netzwerkkarte hat > > Signed-off-by: Kevin Wolf > --- > build/root-common/config/servmgr/default/deps | 2 +- > build/root-common/config/servmgr/e1000/cmd | 1 + > build/root-common/config/servmgr/e1000/deps | 2 ++ > build/root-common/config/servmgr/ne2k/cmd | 1 + > build/root-common/config/servmgr/ne2k/deps | 2 ++ > build/root-common/config/servmgr/nic/cmd | 1 + > build/root-common/config/servmgr/nic/conf | 1 + > build/root-common/config/servmgr/nic/deps | 1 + > build/root-common/config/servmgr/pcnet/cmd | 1 + > build/root-common/config/servmgr/pcnet/deps | 2 ++ > build/root-common/config/servmgr/sis900/cmd | 1 + > build/root-common/config/servmgr/sis900/deps | 2 ++ > 12 files changed, 16 insertions(+), 1 deletions(-) > create mode 100644 build/root-common/config/servmgr/e1000/cmd > create mode 100644 build/root-common/config/servmgr/e1000/deps > create mode 100644 build/root-common/config/servmgr/ne2k/cmd > create mode 100644 build/root-common/config/servmgr/ne2k/deps > create mode 100644 build/root-common/config/servmgr/nic/cmd > create mode 100644 build/root-common/config/servmgr/nic/conf > create mode 100644 build/root-common/config/servmgr/nic/deps > create mode 100644 build/root-common/config/servmgr/pcnet/cmd > create mode 100644 build/root-common/config/servmgr/pcnet/deps > create mode 100644 build/root-common/config/servmgr/sis900/cmd > create mode 100644 build/root-common/config/servmgr/sis900/deps > > diff --git a/build/root-common/config/servmgr/default/deps b/build/root-common/config/servmgr/default/deps > index e9898e5..ebdafbb 100644 > --- a/build/root-common/config/servmgr/default/deps > +++ b/build/root-common/config/servmgr/default/deps > @@ -2,5 +2,5 @@ getterm1 > getterm2 > getterm3 > getterm4 > -rtl8139 > +nic > mount > diff --git a/build/root-common/config/servmgr/e1000/cmd b/build/root-common/config/servmgr/e1000/cmd > new file mode 100644 > index 0000000..60952c6 > --- /dev/null > +++ b/build/root-common/config/servmgr/e1000/cmd > @@ -0,0 +1 @@ > +/modules/e1000 > diff --git a/build/root-common/config/servmgr/e1000/deps b/build/root-common/config/servmgr/e1000/deps > new file mode 100644 > index 0000000..7f5df2b > --- /dev/null > +++ b/build/root-common/config/servmgr/e1000/deps > @@ -0,0 +1,2 @@ > +pci > +tcpip > diff --git a/build/root-common/config/servmgr/ne2k/cmd b/build/root-common/config/servmgr/ne2k/cmd > new file mode 100644 > index 0000000..f4e866f > --- /dev/null > +++ b/build/root-common/config/servmgr/ne2k/cmd > @@ -0,0 +1 @@ > +/modules/ne2k > diff --git a/build/root-common/config/servmgr/ne2k/deps b/build/root-common/config/servmgr/ne2k/deps > new file mode 100644 > index 0000000..7f5df2b > --- /dev/null > +++ b/build/root-common/config/servmgr/ne2k/deps > @@ -0,0 +1,2 @@ > +pci > +tcpip > diff --git a/build/root-common/config/servmgr/nic/cmd b/build/root-common/config/servmgr/nic/cmd > new file mode 100644 > index 0000000..8b13789 > --- /dev/null > +++ b/build/root-common/config/servmgr/nic/cmd > @@ -0,0 +1 @@ > + Hm brauchst du hier wirklich eine leere Datei? Tuts nicht einfach auch keine? > diff --git a/build/root-common/config/servmgr/nic/conf b/build/root-common/config/servmgr/nic/conf > new file mode 100644 > index 0000000..2140a3b > --- /dev/null > +++ b/build/root-common/config/servmgr/nic/conf > @@ -0,0 +1 @@ > +nowait > diff --git a/build/root-common/config/servmgr/nic/deps b/build/root-common/config/servmgr/nic/deps > new file mode 100644 > index 0000000..27d043c > --- /dev/null > +++ b/build/root-common/config/servmgr/nic/deps > @@ -0,0 +1 @@ > +rtl8139 > diff --git a/build/root-common/config/servmgr/pcnet/cmd b/build/root-common/config/servmgr/pcnet/cmd > new file mode 100644 > index 0000000..254da69 > --- /dev/null > +++ b/build/root-common/config/servmgr/pcnet/cmd > @@ -0,0 +1 @@ > +/modules/pcnet > diff --git a/build/root-common/config/servmgr/pcnet/deps b/build/root-common/config/servmgr/pcnet/deps > new file mode 100644 > index 0000000..7f5df2b > --- /dev/null > +++ b/build/root-common/config/servmgr/pcnet/deps > @@ -0,0 +1,2 @@ > +pci > +tcpip > diff --git a/build/root-common/config/servmgr/sis900/cmd b/build/root-common/config/servmgr/sis900/cmd > new file mode 100644 > index 0000000..b123fe0 > --- /dev/null > +++ b/build/root-common/config/servmgr/sis900/cmd > @@ -0,0 +1 @@ > +/modules/sis900 > diff --git a/build/root-common/config/servmgr/sis900/deps b/build/root-common/config/servmgr/sis900/deps > new file mode 100644 > index 0000000..7f5df2b > --- /dev/null > +++ b/build/root-common/config/servmgr/sis900/deps > @@ -0,0 +1,2 @@ > +pci > +tcpip Sonst sieht das vernünftig aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Mon Dec 21 23:32:40 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 23:32:40 +0100 Subject: [tyndur-devel] [PATCH 2/3] setup: Netzwerkkonfiguration In-Reply-To: <1261410850-29673-3-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> <1261410850-29673-3-git-send-email-kevin@tyndur.org> Message-ID: <20091221223240.GE7894@neo.geekcave.lan> On Mon, Dec 21 16:54, Kevin Wolf wrote: > + setup: Modul fuer die Netzwerkkonfiguration > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Mon Dec 21 23:33:43 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 23:33:43 +0100 Subject: [tyndur-devel] [PATCH 3/3] config: Netzwerkkonfiguration beim ersten Start starten In-Reply-To: <1261410850-29673-4-git-send-email-kevin@tyndur.org> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> <1261410850-29673-4-git-send-email-kevin@tyndur.org> Message-ID: <20091221223343.GF7894@neo.geekcave.lan> On Mon, Dec 21 16:54, Kevin Wolf wrote: > + config: Nachdem der Benutzer beim ersten Start seine Tastaturbelegung > ausgewaehlt hat, darf er dann gleich auch noch das Netzwerk erledigen > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Mon Dec 21 23:36:45 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Mon, 21 Dec 2009 23:36:45 +0100 Subject: [tyndur-devel] [PATCH] tcpip: Pagefault beim Hinzufuegen neuer Routen In-Reply-To: <1261410882-30173-1-git-send-email-kevin@tyndur.org> References: <1261410882-30173-1-git-send-email-kevin@tyndur.org> Message-ID: <20091221223645.GG7894@neo.geekcave.lan> On Mon, Dec 21 16:54, Kevin Wolf wrote: > ! tcpip: Wenn eine neue Route angegeben wird, muss sie auch erstmal > angelegt werden, sonst ist sie ziemlich NULL > > Signed-off-by: Kevin Wolf Sieht überzeugend aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Mon Dec 21 23:48:42 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Mon, 21 Dec 2009 23:48:42 +0100 Subject: [tyndur-devel] [PATCH 1/3] config/servmgr: Mehr Netzwerkkarten In-Reply-To: <20091221222636.GD7894@neo.geekcave.lan> References: <1261410850-29673-1-git-send-email-kevin@tyndur.org> <1261410850-29673-2-git-send-email-kevin@tyndur.org> <20091221222636.GD7894@neo.geekcave.lan> Message-ID: <20091221224841.GA15776@silvanus> On Mon, Dec 21, 2009 at 11:26:36PM +0100, Antoine Kaufmann wrote: > On Mon, Dec 21 16:54, Kevin Wolf wrote: > > + config/servmgr: Services fuer alle Netzwerktreiber definiert > > * config/servmgr: Anstatt rtl8139 direkt in default zu laden, wird jetzt > > nic geladen, das eine Abhaengigkeit auf die aktuell eingestellte > > Netzwerkkarte hat > > > > Signed-off-by: Kevin Wolf > > --- > > build/root-common/config/servmgr/default/deps | 2 +- > > build/root-common/config/servmgr/e1000/cmd | 1 + > > build/root-common/config/servmgr/e1000/deps | 2 ++ > > build/root-common/config/servmgr/ne2k/cmd | 1 + > > build/root-common/config/servmgr/ne2k/deps | 2 ++ > > build/root-common/config/servmgr/nic/cmd | 1 + > > build/root-common/config/servmgr/nic/conf | 1 + > > build/root-common/config/servmgr/nic/deps | 1 + > > build/root-common/config/servmgr/pcnet/cmd | 1 + > > build/root-common/config/servmgr/pcnet/deps | 2 ++ > > build/root-common/config/servmgr/sis900/cmd | 1 + > > build/root-common/config/servmgr/sis900/deps | 2 ++ > > 12 files changed, 16 insertions(+), 1 deletions(-) > > create mode 100644 build/root-common/config/servmgr/e1000/cmd > > create mode 100644 build/root-common/config/servmgr/e1000/deps > > create mode 100644 build/root-common/config/servmgr/ne2k/cmd > > create mode 100644 build/root-common/config/servmgr/ne2k/deps > > create mode 100644 build/root-common/config/servmgr/nic/cmd > > create mode 100644 build/root-common/config/servmgr/nic/conf > > create mode 100644 build/root-common/config/servmgr/nic/deps > > create mode 100644 build/root-common/config/servmgr/pcnet/cmd > > create mode 100644 build/root-common/config/servmgr/pcnet/deps > > create mode 100644 build/root-common/config/servmgr/sis900/cmd > > create mode 100644 build/root-common/config/servmgr/sis900/deps > > > > diff --git a/build/root-common/config/servmgr/default/deps b/build/root-common/config/servmgr/default/deps > > index e9898e5..ebdafbb 100644 > > --- a/build/root-common/config/servmgr/default/deps > > +++ b/build/root-common/config/servmgr/default/deps > > @@ -2,5 +2,5 @@ getterm1 > > getterm2 > > getterm3 > > getterm4 > > -rtl8139 > > +nic > > mount > > diff --git a/build/root-common/config/servmgr/e1000/cmd b/build/root-common/config/servmgr/e1000/cmd > > new file mode 100644 > > index 0000000..60952c6 > > --- /dev/null > > +++ b/build/root-common/config/servmgr/e1000/cmd > > @@ -0,0 +1 @@ > > +/modules/e1000 > > diff --git a/build/root-common/config/servmgr/e1000/deps b/build/root-common/config/servmgr/e1000/deps > > new file mode 100644 > > index 0000000..7f5df2b > > --- /dev/null > > +++ b/build/root-common/config/servmgr/e1000/deps > > @@ -0,0 +1,2 @@ > > +pci > > +tcpip > > diff --git a/build/root-common/config/servmgr/ne2k/cmd b/build/root-common/config/servmgr/ne2k/cmd > > new file mode 100644 > > index 0000000..f4e866f > > --- /dev/null > > +++ b/build/root-common/config/servmgr/ne2k/cmd > > @@ -0,0 +1 @@ > > +/modules/ne2k > > diff --git a/build/root-common/config/servmgr/ne2k/deps b/build/root-common/config/servmgr/ne2k/deps > > new file mode 100644 > > index 0000000..7f5df2b > > --- /dev/null > > +++ b/build/root-common/config/servmgr/ne2k/deps > > @@ -0,0 +1,2 @@ > > +pci > > +tcpip > > diff --git a/build/root-common/config/servmgr/nic/cmd b/build/root-common/config/servmgr/nic/cmd > > new file mode 100644 > > index 0000000..8b13789 > > --- /dev/null > > +++ b/build/root-common/config/servmgr/nic/cmd > > @@ -0,0 +1 @@ > > + > > Hm brauchst du hier wirklich eine leere Datei? Tuts nicht einfach auch > keine? Wollte ich erst, aber dann habe ich zweimal rtl8139 bekommen. servmgr scheint dann einfach das zuletzt geladene nochmal zu laden oder sowas. From toni at tyndur.org Tue Dec 22 02:44:49 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Tue, 22 Dec 2009 02:44:49 +0100 Subject: [tyndur-devel] [PATCH] iso9660: Fehlerbehandlung beim Lesen In-Reply-To: <1261432313-23554-1-git-send-email-kevin@tyndur.org> References: <1261432313-23554-1-git-send-email-kevin@tyndur.org> Message-ID: <20091222014449.GH7894@neo.geekcave.lan> On Mon, Dec 21 22:51, Kevin Wolf wrote: > ! iso9660: Wenn beim Lesen vom Dateisystem etwas schiefgeht, liefert der > Cache NULL zurueck, was man dann auch pruefen sollte > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Tue Dec 22 13:55:51 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Tue, 22 Dec 2009 13:55:51 +0100 Subject: [tyndur-devel] [PATCH] tui: TUIFrame soll nur den Rand malen Message-ID: <1261486551-10645-1-git-send-email-kevin@tyndur.org> ! Pascal-RTL: tui: Wenn TUIFrame nicht immer den ganzen Inhalt loescht, sondern nur den Rand, der von den Kindwidgets nicht gezeichnet wird, flackert das ganze schon deutlich weniger. Signed-off-by: Kevin Wolf --- src/modules/pas/lib/tui/tui.pas | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/modules/pas/lib/tui/tui.pas b/src/modules/pas/lib/tui/tui.pas index 23ac446..abfd094 100644 --- a/src/modules/pas/lib/tui/tui.pas +++ b/src/modules/pas/lib/tui/tui.pas @@ -418,14 +418,12 @@ end; procedure TUIFrame.draw(x, y: integer); var w, h: integer; + + obj_x, obj_y: integer; begin w := f_w; h := f_h; - TextColor(color); - TextBackground(bgcolor); - FillRect(x, y, w, h); - if f_obj_w < w then begin w := f_obj_w; end; @@ -434,7 +432,26 @@ begin h := f_obj_h; end; - f_obj.draw(x + ((f_w - w) div 2), y + ((f_h - h) div 2)); + obj_x := x + ((f_w - w) div 2); + obj_y := y + ((f_h - h) div 2); + + TextColor(color); + TextBackground(bgcolor); + + // Linker Rand + FillRect(x, y, obj_x - x, f_h); + + // Rechter Rand + FillRect(obj_x + w, y, (x + f_w) - (obj_x + w), f_h); + + // Oberer Rand + FillRect(obj_x, y, w, obj_y - y); + + // Unterer Rand + FillRect(obj_x, obj_y + h, w, (y + f_h) - (obj_y + h)); + + // Kindobjekt + f_obj.draw(obj_x, obj_y); end; procedure TUILabel.draw(x, y: integer); -- 1.6.0.2 From kevin at tyndur.org Wed Dec 23 13:57:16 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 23 Dec 2009 13:57:16 +0100 Subject: [tyndur-devel] [PATCH] Pascal-RTL: FirstFirst, FindNext, FindClose in sysutils Message-ID: <1261573036-27197-1-git-send-email-kevin@tyndur.org> + Pascal-RTL: FindFirst/Next/Close in sysutils sind jetzt nicht mehr nur Stubs, sondern Wrapper um die funktionsfaehigen Varianten aus dos. Signed-off-by: Kevin Wolf --- src/modules/pas/lib/rtl/Makefile.all | 6 +++- src/modules/pas/lib/rtl/sysutils.pp | 39 +++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/modules/pas/lib/rtl/Makefile.all b/src/modules/pas/lib/rtl/Makefile.all index 3694dad..87f73b3 100644 --- a/src/modules/pas/lib/rtl/Makefile.all +++ b/src/modules/pas/lib/rtl/Makefile.all @@ -9,12 +9,14 @@ echo 'PPC objpas.pp' && \ $LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/objpas.pp && \ echo 'PPC sysconst.pp' && \ $LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/sysconst.pp && \ +echo 'PPC dos.pp' && \ +$LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas ../dos/dos.pas && \ +echo 'PPC sysutils.pp' && \ +$LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas sysutils.pp && \ echo 'PPC strutils.pp' && \ $LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/strutils.pp && \ echo 'PPC math.pp' && \ $LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/math.pp && \ -echo 'PPC sysutils.pp' && \ -$LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas sysutils.pp && \ echo 'PPC rtlconsts.pp' && \ $LOST_TOOLS_PPC -n -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/rtlconsts.pp && \ echo 'PPC types.pp' && \ diff --git a/src/modules/pas/lib/rtl/sysutils.pp b/src/modules/pas/lib/rtl/sysutils.pp index 8009993..0a89d14 100644 --- a/src/modules/pas/lib/rtl/sysutils.pp +++ b/src/modules/pas/lib/rtl/sysutils.pp @@ -30,7 +30,7 @@ function IsLeapYear(year: word): boolean; {$I include/objpas/sysutils/sysutilh.inc} implementation -uses sysconst; +uses sysconst, dos; {$I include/objpas/sysutils/sysutils.inc} @@ -277,19 +277,44 @@ begin end; function FindFirst(const path: AnsiString; attr: LongInt;out rslt: TSearchRec):LongInt; +var + f: ^SearchRec; begin - Result := 0; // FIXME -end; + New(f); + rslt.FindHandle := THandle(f); + dos.FindFirst(path, attr, f^); + + rslt.name := f^.name; + rslt.size := f^.size; + rslt.attr := f^.attr; + rslt.time := f^.time; + + exit(DosError); +end; function FindNext(var rslt: TSearchRec):LongInt; +var + f: ^SearchRec; begin - Result := 0; // FIXME -end; + f := Pointer(rslt.FindHandle); + dos.FindNext(f^); + + rslt.name := f^.name; + rslt.size := f^.size; + rslt.attr := f^.attr; + rslt.time := f^.time; + + exit(DosError); +end; procedure FindClose(var f: TSearchRec); +var + srec: ^SearchRec; begin - // FIXME -end; + srec := Pointer(f.FindHandle); + dos.FindClose(srec^); + Dispose(srec); +end; function FileGetDate(handle: LongInt):LongInt; begin -- 1.6.0.2 From kevin at tyndur.org Wed Dec 23 23:06:46 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 23 Dec 2009 23:06:46 +0100 Subject: [tyndur-devel] [PATCH] iso9660: Pufferueberlauf bei nicht ausgerichtetem Zugriff Message-ID: <1261606006-15326-1-git-send-email-kevin@tyndur.org> ! iso9660: Wenn man mitten in einem Cacheblock zu lesen anfaengt, darf man nicht mehr den ganzen Block kopieren, sondern nur bis zu Ende des Blocks. Signed-off-by: Kevin Wolf --- src/modules/cdi/iso9660/sector.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/modules/cdi/iso9660/sector.c b/src/modules/cdi/iso9660/sector.c index 5e765ea..b14a795 100644 --- a/src/modules/cdi/iso9660/sector.c +++ b/src/modules/cdi/iso9660/sector.c @@ -66,7 +66,7 @@ size_t iso9660_read(struct iso9660_fs_res *res,size_t pos,size_t size,void *buff break; } - cur_size = MIN(rem_size, res->voldesc->sector_size); + cur_size = MIN(rem_size, res->voldesc->sector_size - offset); memcpy(buffer,cache_block->data+offset,cur_size); cdi_cache_block_release(res->cache,cache_block); -- 1.6.0.2 From kevin at tyndur.org Wed Dec 23 23:36:31 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 23 Dec 2009 23:36:31 +0100 Subject: [tyndur-devel] [PATCH] setup: Leeren Treibernamen abfangen Message-ID: <1261607791-15212-1-git-send-email-kevin@tyndur.org> ! setup: Leeren Netzwerktreibernamen abfangen. Bei AnsiStrings wird der als nil dargestellt, womit C-Funktionen nicht so gut umgehen koennen. Signed-off-by: Kevin Wolf --- src/modules/pas/setup/setup_network.pas | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/modules/pas/setup/setup_network.pas b/src/modules/pas/setup/setup_network.pas index 941f2f3..f591de7 100644 --- a/src/modules/pas/setup/setup_network.pas +++ b/src/modules/pas/setup/setup_network.pas @@ -27,18 +27,20 @@ var path: String; f: text; begin - // Treiber laden - c_servmgr_need(@driver[1]); - - // IP/Gateway setzen - path := 'tcpip:/' + driver + '/0/ip'; - Assign(f, path); -{$i-} - Rewrite(f); -{$i+} - if IOResult = 0 then begin - WriteLn(f, ip); - Close(f); + if driver <> '' then begin + // Treiber laden + c_servmgr_need(@driver[1]); + + // IP/Gateway setzen + path := 'tcpip:/' + driver + '/0/ip'; + Assign(f, path); + {$i-} + Rewrite(f); + {$i+} + if IOResult = 0 then begin + WriteLn(f, ip); + Close(f); + end; end; path := 'tcpip:/route'; -- 1.6.0.2 From kevin at tyndur.org Wed Dec 23 23:36:45 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Wed, 23 Dec 2009 23:36:45 +0100 Subject: [tyndur-devel] [PATCH] setup: Bildschirm gelegentlich loeschen Message-ID: <1261607805-15444-1-git-send-email-kevin@tyndur.org> ! setup: Flackerfrei ist toll, aber wenn eine andere Oberflaeche angezeigt wird, waerer es trotzdem besser, erstmal die Reste vom alten Menue loszuwerden. Signed-off-by: Kevin Wolf --- src/modules/pas/setup/menu.pas | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/modules/pas/setup/menu.pas b/src/modules/pas/setup/menu.pas index da4b4a5..60a6626 100644 --- a/src/modules/pas/setup/menu.pas +++ b/src/modules/pas/setup/menu.pas @@ -20,6 +20,7 @@ resourcestring function StartModule(module: String; back: boolean): boolean; begin + ClrScr; if module = 'keyboard' then begin SetupKeyboard(back); end else if module = 'lpt' then begin @@ -32,6 +33,7 @@ begin exit(false); end; + ClrScr; exit(true); end; -- 1.6.0.2 From toni at tyndur.org Thu Dec 24 10:46:31 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Thu, 24 Dec 2009 10:46:31 +0100 Subject: [tyndur-devel] [PATCH] iso9660: Pufferueberlauf bei nicht ausgerichtetem Zugriff In-Reply-To: <1261606006-15326-1-git-send-email-kevin@tyndur.org> References: <1261606006-15326-1-git-send-email-kevin@tyndur.org> Message-ID: <20091224094630.GA12365@neo.geekcave.lan> On Wed, Dec 23 23:06, Kevin Wolf wrote: > ! iso9660: Wenn man mitten in einem Cacheblock zu lesen anfaengt, darf > man nicht mehr den ganzen Block kopieren, sondern nur bis zu Ende des > Blocks. > > Signed-off-by: Kevin Wolf Sieht einleuchtend aus. Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Thu Dec 24 10:52:14 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Thu, 24 Dec 2009 10:52:14 +0100 Subject: [tyndur-devel] [PATCH] setup: Leeren Treibernamen abfangen In-Reply-To: <1261607791-15212-1-git-send-email-kevin@tyndur.org> References: <1261607791-15212-1-git-send-email-kevin@tyndur.org> Message-ID: <20091224095214.GB12365@neo.geekcave.lan> On Wed, Dec 23 23:36, Kevin Wolf wrote: > ! setup: Leeren Netzwerktreibernamen abfangen. Bei AnsiStrings wird der > als nil dargestellt, womit C-Funktionen nicht so gut umgehen koennen. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Thu Dec 24 11:35:28 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Thu, 24 Dec 2009 11:35:28 +0100 Subject: [tyndur-devel] [PATCH] Pascal-RTL: FirstFirst, FindNext, FindClose in sysutils In-Reply-To: <1261573036-27197-1-git-send-email-kevin@tyndur.org> References: <1261573036-27197-1-git-send-email-kevin@tyndur.org> Message-ID: <20091224103528.GC12365@neo.geekcave.lan> On Wed, Dec 23 13:57, Kevin Wolf wrote: > + Pascal-RTL: FindFirst/Next/Close in sysutils sind jetzt nicht mehr nur > Stubs, sondern Wrapper um die funktionsfaehigen Varianten aus dos. > > Signed-off-by: Kevin Wolf Hm bringt das niemanden durcheinander wenn da jemand DosError ändert? Ich hab ja keine Ahnung davon, aber wenns tut halt rein damit... ;-) Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From toni at tyndur.org Thu Dec 24 11:41:44 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Thu, 24 Dec 2009 11:41:44 +0100 Subject: [tyndur-devel] [PATCH] setup: Bildschirm gelegentlich loeschen In-Reply-To: <1261607805-15444-1-git-send-email-kevin@tyndur.org> References: <1261607805-15444-1-git-send-email-kevin@tyndur.org> Message-ID: <20091224104144.GD12365@neo.geekcave.lan> On Wed, Dec 23 23:36, Kevin Wolf wrote: > ! setup: Flackerfrei ist toll, aber wenn eine andere Oberflaeche > angezeigt wird, waerer es trotzdem besser, erstmal die Reste vom > alten Menue loszuwerden. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL : From kevin at tyndur.org Thu Dec 31 17:33:05 2009 From: kevin at tyndur.org (Kevin Wolf) Date: Thu, 31 Dec 2009 17:33:05 +0100 Subject: [tyndur-devel] [PATCH] kernel2: Fix fuer pm_scheduler_delete Message-ID: <1262277185-15450-1-git-send-email-kevin@tyndur.org> ! kernel2: Wenn man in einer Liste ein Element sucht, sollte man auch gelegentlich die Laufvariable erhöhen. Ansonsten kann man da ziemlich lang suchen, wenn es nicht das erste Element ist. Signed-off-by: Kevin Wolf --- src/kernel2/src/tasks/scheduler.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/kernel2/src/tasks/scheduler.c b/src/kernel2/src/tasks/scheduler.c index 1556999..975412a 100644 --- a/src/kernel2/src/tasks/scheduler.c +++ b/src/kernel2/src/tasks/scheduler.c @@ -86,14 +86,14 @@ void pm_scheduler_add(pm_thread_t* thread) */ void pm_scheduler_delete(pm_thread_t* thread) { - int i = 0; - pm_thread_t* thread_; - + int i; + pm_thread_t* p; + lock(&scheduler_lock); // Die Liste mit den Threads durchsuchen - while ((thread_ = list_get_element_at(threads_available, i))) { - if (thread_ == thread) { + for (i = 0; (p = list_get_element_at(threads_available, i)); i++) { + if (p == thread) { list_remove(threads_available, i); break; } -- 1.6.0.2 From toni at tyndur.org Thu Dec 31 17:35:43 2009 From: toni at tyndur.org (Antoine Kaufmann) Date: Thu, 31 Dec 2009 17:35:43 +0100 Subject: [tyndur-devel] [PATCH] kernel2: Fix fuer pm_scheduler_delete In-Reply-To: <1262277185-15450-1-git-send-email-kevin@tyndur.org> References: <1262277185-15450-1-git-send-email-kevin@tyndur.org> Message-ID: <20091231163542.GA4316@neo.geekcave.lan> On Thu, Dec 31 17:33, Kevin Wolf wrote: > ! kernel2: Wenn man in einer Liste ein Element sucht, sollte man auch > gelegentlich die Laufvariable erhöhen. Ansonsten kann man da ziemlich > lang suchen, wenn es nicht das erste Element ist. > > Signed-off-by: Kevin Wolf Acked-by: Antoine Kaufmann -- Antoine Kaufmann -------------- nächster Teil -------------- Ein Dateianhang mit Binärdaten wurde abgetrennt... Dateiname : nicht verfügbar Dateityp : application/pgp-signature Dateigröße : 198 bytes Beschreibung: nicht verfügbar URL :