Changeset c47e1a8 in mainline for uspace/app
- Timestamp:
- 2010-05-21T07:50:04Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d51ee2b
- Parents:
- cf8cc36 (diff), 15b592b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 105 added
- 1 deleted
- 91 edited
- 6 moved
-
Makefile.common (deleted)
-
bdsh/Makefile (modified) (2 diffs)
-
bdsh/cmds/builtin_cmds.c (modified) (1 diff)
-
bdsh/cmds/builtins/builtins.h (modified) (1 diff)
-
bdsh/cmds/builtins/cd/cd.c (modified) (2 diffs)
-
bdsh/cmds/builtins/cd/cd_def.h (modified) (1 diff)
-
bdsh/cmds/builtins/exit/exit_def.h (modified) (1 diff)
-
bdsh/cmds/cmds.h (modified) (4 diffs)
-
bdsh/cmds/mod_cmds.c (modified) (1 diff)
-
bdsh/cmds/modules/bdd/bdd.c (modified) (2 diffs)
-
bdsh/cmds/modules/cat/cat.c (modified) (3 diffs)
-
bdsh/cmds/modules/cp/cp.c (modified) (2 diffs)
-
bdsh/cmds/modules/help/help.c (modified) (2 diffs)
-
bdsh/cmds/modules/kcon/kcon.c (modified) (1 diff)
-
bdsh/cmds/modules/ls/ls.c (modified) (2 diffs)
-
bdsh/cmds/modules/mkdir/mkdir.c (modified) (2 diffs)
-
bdsh/cmds/modules/mkfile/mkfile.c (modified) (2 diffs)
-
bdsh/cmds/modules/module_aliases.h (modified) (1 diff)
-
bdsh/cmds/modules/mount/mount.c (modified) (1 diff)
-
bdsh/cmds/modules/pwd/pwd.c (modified) (1 diff)
-
bdsh/cmds/modules/rm/rm.c (modified) (2 diffs)
-
bdsh/cmds/modules/sleep/sleep.c (modified) (1 diff)
-
bdsh/cmds/modules/touch/touch.c (modified) (2 diffs)
-
bdsh/errors.c (modified) (2 diffs)
-
bdsh/errstr.h (modified) (2 diffs)
-
bdsh/exec.c (modified) (3 diffs)
-
bdsh/exec.h (modified) (1 diff)
-
bdsh/input.c (modified) (7 diffs)
-
bdsh/input.h (modified) (1 diff)
-
bdsh/scli.c (modified) (3 diffs)
-
bdsh/scli.h (modified) (2 diffs)
-
bdsh/util.c (modified) (1 diff)
-
edit/Makefile (modified) (2 diffs)
-
edit/edit.c (modified) (16 diffs)
-
edit/sheet.c (modified) (1 diff)
-
getterm/Makefile (modified) (2 diffs)
-
getterm/getterm.c (modified) (2 diffs)
-
getterm/version.c (modified) (1 diff)
-
init/Makefile (modified) (1 diff)
-
init/init.c (modified) (15 diffs)
-
klog/Makefile (modified) (1 diff)
-
klog/klog.c (modified) (3 diffs)
-
mkfat/Makefile (modified) (1 diff)
-
mkfat/fat.h (modified) (2 diffs)
-
mkfat/mkfat.c (modified) (3 diffs)
-
netecho/Makefile (added)
-
netecho/netecho.c (added)
-
netecho/print_error.c (added)
-
netecho/print_error.h (added)
-
nettest1/Makefile (added)
-
nettest1/nettest.c (added)
-
nettest1/nettest.h (added)
-
nettest1/nettest1.c (added)
-
nettest1/print_error.c (added)
-
nettest1/print_error.h (added)
-
nettest2/Makefile (added)
-
nettest2/nettest.c (added)
-
nettest2/nettest.h (added)
-
nettest2/nettest2.c (added)
-
nettest2/print_error.c (added)
-
nettest2/print_error.h (added)
-
ping/Makefile (added)
-
ping/ping.c (added)
-
ping/print_error.c (added)
-
ping/print_error.h (added)
-
redir/Makefile (modified) (1 diff)
-
redir/redir.c (modified) (3 diffs)
-
sbi/Makefile (added)
-
sbi/src/ancr.c (added)
-
sbi/src/ancr.h (added)
-
sbi/src/bigint.c (added)
-
sbi/src/bigint.h (moved) (moved from boot/arch/ppc32/loader/asm.h ) (2 diffs)
-
sbi/src/bigint_t.h (added)
-
sbi/src/builtin.c (added)
-
sbi/src/builtin.h (moved) (moved from boot/arch/arm32/loader/print/print.c ) (2 diffs)
-
sbi/src/builtin/bi_boxed.c (added)
-
sbi/src/builtin/bi_boxed.h (added)
-
sbi/src/builtin/bi_error.c (added)
-
sbi/src/builtin/bi_error.h (added)
-
sbi/src/builtin/bi_fun.c (added)
-
sbi/src/builtin/bi_fun.h (added)
-
sbi/src/builtin/bi_string.c (added)
-
sbi/src/builtin/bi_string.h (added)
-
sbi/src/builtin/bi_textfile.c (added)
-
sbi/src/builtin/bi_textfile.h (added)
-
sbi/src/builtin_t.h (added)
-
sbi/src/compat.h (added)
-
sbi/src/cspan.c (added)
-
sbi/src/cspan.h (added)
-
sbi/src/cspan_t.h (added)
-
sbi/src/debug.h (added)
-
sbi/src/imode.c (added)
-
sbi/src/imode.h (added)
-
sbi/src/input.c (added)
-
sbi/src/input.h (moved) (moved from boot/arch/mips32/loader/types.h ) (2 diffs)
-
sbi/src/input_t.h (added)
-
sbi/src/intmap.c (added)
-
sbi/src/intmap.h (added)
-
sbi/src/intmap_t.h (added)
-
sbi/src/lex.c (added)
-
sbi/src/lex.h (moved) (moved from boot/arch/ia64/loader/types.h ) (2 diffs)
-
sbi/src/lex_t.h (added)
-
sbi/src/list.c (added)
-
sbi/src/list.h (added)
-
sbi/src/list_t.h (added)
-
sbi/src/main.c (added)
-
sbi/src/mytypes.h (added)
-
sbi/src/os/helenos.c (added)
-
sbi/src/os/os.h (added)
-
sbi/src/os/posix.c (added)
-
sbi/src/p_expr.c (added)
-
sbi/src/p_expr.h (added)
-
sbi/src/p_type.c (added)
-
sbi/src/p_type.h (added)
-
sbi/src/parse.c (added)
-
sbi/src/parse.h (added)
-
sbi/src/parse_t.h (added)
-
sbi/src/program.c (added)
-
sbi/src/program.h (added)
-
sbi/src/rdata.c (added)
-
sbi/src/rdata.h (added)
-
sbi/src/rdata_t.h (added)
-
sbi/src/run.c (added)
-
sbi/src/run.h (added)
-
sbi/src/run_expr.c (added)
-
sbi/src/run_expr.h (added)
-
sbi/src/run_t.h (added)
-
sbi/src/run_texpr.c (added)
-
sbi/src/run_texpr.h (added)
-
sbi/src/stree.c (added)
-
sbi/src/stree.h (added)
-
sbi/src/stree_t.h (added)
-
sbi/src/strtab.c (added)
-
sbi/src/strtab.h (added)
-
sbi/src/strtab_t.h (added)
-
sbi/src/stype.c (added)
-
sbi/src/stype.h (added)
-
sbi/src/stype_expr.c (added)
-
sbi/src/stype_expr.h (added)
-
sbi/src/stype_t.h (added)
-
sbi/src/symbol.c (added)
-
sbi/src/symbol.h (moved) (moved from boot/arch/mips32/loader/main.h ) (2 diffs)
-
sbi/src/tdata.c (added)
-
sbi/src/tdata.h (added)
-
sbi/src/tdata_t.h (added)
-
shutters/Makefile (modified) (1 diff)
-
shutters/shutters.c (modified) (1 diff)
-
stats/Makefile (added)
-
stats/stats.c (added)
-
taskdump/Makefile (modified) (1 diff)
-
taskdump/elf_core.c (added)
-
taskdump/include/elf.h (modified) (1 diff)
-
taskdump/include/elf_core.h (added)
-
taskdump/symtab.c (modified) (7 diffs)
-
taskdump/taskdump.c (modified) (8 diffs)
-
tasks/Makefile (added)
-
tasks/tasks.c (added)
-
test_serial/Makefile (modified) (1 diff)
-
test_serial/test_serial.c (modified) (2 diffs)
-
tester/Makefile (modified) (2 diffs)
-
tester/console/console1.c (modified) (8 diffs)
-
tester/fault/fault1.c (modified) (1 diff)
-
tester/fault/fault2.c (modified) (1 diff)
-
tester/fault/fault3.c (modified) (1 diff)
-
tester/fault/fault3.def (modified) (1 diff)
-
tester/ipc/connect.c (modified) (1 diff)
-
tester/ipc/ping_pong.c (modified) (1 diff)
-
tester/ipc/register.c (modified) (1 diff)
-
tester/loop/loop1.c (modified) (1 diff)
-
tester/mm/malloc1.c (modified) (3 diffs)
-
tester/print/print1.c (modified) (1 diff)
-
tester/print/print2.c (modified) (1 diff)
-
tester/print/print3.c (modified) (1 diff)
-
tester/print/print4.c (modified) (1 diff)
-
tester/stdio/stdio1.c (modified) (1 diff)
-
tester/stdio/stdio2.c (modified) (1 diff)
-
tester/tester.c (modified) (2 diffs)
-
tester/tester.h (modified) (1 diff)
-
tester/thread/thread1.c (modified) (1 diff)
-
tester/vfs/vfs1.c (modified) (4 diffs)
-
tetris/Makefile (modified) (2 diffs)
-
tetris/input.c (modified) (1 diff)
-
tetris/scores.c (modified) (1 diff)
-
tetris/scores.h (modified) (1 diff)
-
tetris/screen.c (modified) (9 diffs)
-
tetris/screen.h (modified) (2 diffs)
-
tetris/tetris.c (modified) (1 diff)
-
tetris/tetris.h (modified) (1 diff)
-
top/Makefile (added)
-
top/input.c (added)
-
top/input.h (added)
-
top/screen.c (added)
-
top/screen.h (added)
-
top/top.c (added)
-
top/top.h (moved) (moved from boot/arch/sparc64/loader/main.h ) (2 diffs)
-
trace/Makefile (modified) (2 diffs)
-
trace/errors.h (modified) (1 diff)
-
trace/ipc_desc.h (modified) (1 diff)
-
trace/proto.c (modified) (3 diffs)
-
trace/proto.h (modified) (3 diffs)
-
trace/syscalls.c (modified) (1 diff)
-
trace/syscalls.h (modified) (1 diff)
-
trace/trace.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC _PREFIX)/libc.a32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I . -Icmds/ -Icmds/builtins -Icmds/modules33 34 OUTPUT= bdsh31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) -I. -Icmds/ \ 33 -Icmds/builtins -Icmds/modules 34 BINARY = bdsh 35 35 36 36 SOURCES = \ … … 60 60 scli.c 61 61 62 include ../Makefile.common62 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/bdsh/cmds/builtin_cmds.c
rcf8cc36 rc47e1a8 34 34 #include <stdio.h> 35 35 #include <stdlib.h> 36 #include <str ing.h>36 #include <str.h> 37 37 #include "errors.h" 38 38 #include "cmds.h" -
uspace/app/bdsh/cmds/builtins/builtins.h
rcf8cc36 rc47e1a8 10 10 #include "cd/cd_def.h" 11 11 #include "exit/exit_def.h" 12 {NULL, NULL, NULL, NULL }12 {NULL, NULL, NULL, NULL, NULL} 13 13 }; 14 14 -
uspace/app/bdsh/cmds/builtins/cd/cd.c
rcf8cc36 rc47e1a8 32 32 #include <stdlib.h> 33 33 #include <unistd.h> 34 #include <str ing.h>34 #include <str.h> 35 35 #include <errno.h> 36 36 … … 41 41 #include "cd.h" 42 42 43 static c har *cmdname = "cd";43 static const char *cmdname = "cd"; 44 44 45 45 void help_cmd_cd(unsigned int level) -
uspace/app/bdsh/cmds/builtins/cd/cd_def.h
rcf8cc36 rc47e1a8 4 4 &cmd_cd, 5 5 &help_cmd_cd, 6 0 6 7 }, -
uspace/app/bdsh/cmds/builtins/exit/exit_def.h
rcf8cc36 rc47e1a8 4 4 &cmd_exit, 5 5 &help_cmd_exit, 6 0 6 7 }, -
uspace/app/bdsh/cmds/cmds.h
rcf8cc36 rc47e1a8 33 33 /* Module structure */ 34 34 typedef struct { 35 c har *name;/* Name of the command */36 c har *desc;/* Description of the command */35 const char *name; /* Name of the command */ 36 const char *desc; /* Description of the command */ 37 37 mod_entry_t entry; /* Command (exec) entry function */ 38 38 mod_help_t help; /* Command (help) entry function */ … … 41 41 /* Builtin structure, same as modules except different types of entry points */ 42 42 typedef struct { 43 c har *name;44 c har *desc;43 const char *name; 44 const char *desc; 45 45 builtin_entry_t entry; 46 46 builtin_help_t help; … … 57 57 extern int is_module(const char *); 58 58 extern int is_module_alias(const char *); 59 extern char * alias_for_module(const char *);59 extern char *alias_for_module(const char *); 60 60 extern int help_module(int, unsigned int); 61 61 extern int run_module(int, char *[]); … … 65 65 extern int is_builtin(const char *); 66 66 extern int is_builtin_alias(const char *); 67 extern char * alias_for_builtin(const char *);67 extern char *alias_for_builtin(const char *); 68 68 extern int help_builtin(int, unsigned int); 69 69 extern int run_builtin(int, char *[], cliuser_t *); -
uspace/app/bdsh/cmds/mod_cmds.c
rcf8cc36 rc47e1a8 47 47 #include <stdio.h> 48 48 #include <stdlib.h> 49 #include <str ing.h>49 #include <str.h> 50 50 #include "errors.h" 51 51 #include "cmds.h" -
uspace/app/bdsh/cmds/modules/bdd/bdd.c
rcf8cc36 rc47e1a8 29 29 #include <stdio.h> 30 30 #include <stdlib.h> 31 #include <str ing.h>31 #include <str.h> 32 32 #include "config.h" 33 33 #include "util.h" … … 73 73 size_t block_size; 74 74 int rc; 75 bn_t ba;75 aoff64_t ba; 76 76 uint8_t b; 77 77 -
uspace/app/bdsh/cmds/modules/cat/cat.c
rcf8cc36 rc47e1a8 33 33 #include <unistd.h> 34 34 #include <getopt.h> 35 #include <str ing.h>35 #include <str.h> 36 36 #include <fcntl.h> 37 37 … … 43 43 #include "cmds.h" 44 44 45 static c har *cmdname = "cat";45 static const char *cmdname = "cat"; 46 46 #define CAT_VERSION "0.0.1" 47 47 #define CAT_DEFAULT_BUFLEN 1024 48 48 49 static c har *cat_oops = "That option is not yet supported\n";49 static const char *cat_oops = "That option is not yet supported\n"; 50 50 51 51 static struct option const long_options[] = { … … 85 85 { 86 86 int fd, bytes = 0, count = 0, reads = 0; 87 off _t total = 0;87 off64_t total = 0; 88 88 char *buff = NULL; 89 89 -
uspace/app/bdsh/cmds/modules/cp/cp.c
rcf8cc36 rc47e1a8 33 33 #include <unistd.h> 34 34 #include <getopt.h> 35 #include <str ing.h>35 #include <str.h> 36 36 #include <fcntl.h> 37 37 #include "config.h" … … 74 74 { 75 75 int fd1, fd2, bytes = 0; 76 off _t total = 0;76 off64_t total = 0; 77 77 int64_t copied = 0; 78 78 char *buff = NULL; -
uspace/app/bdsh/cmds/modules/help/help.c
rcf8cc36 rc47e1a8 31 31 #include <stdio.h> 32 32 #include <stdlib.h> 33 #include <str ing.h>33 #include <str.h> 34 34 35 35 #include "config.h" … … 42 42 #include "util.h" 43 43 44 static c har *cmdname = "help";44 static const char *cmdname = "help"; 45 45 extern const char *progname; 46 46 -
uspace/app/bdsh/cmds/modules/kcon/kcon.c
rcf8cc36 rc47e1a8 40 40 #include "cmds.h" 41 41 42 static c har *cmdname = "kcon";42 static const char *cmdname = "kcon"; 43 43 44 44 /* Dispays help for kcon in various levels */ -
uspace/app/bdsh/cmds/modules/ls/ls.c
rcf8cc36 rc47e1a8 40 40 #include <sys/types.h> 41 41 #include <sys/stat.h> 42 #include <str ing.h>42 #include <str.h> 43 43 44 44 #include "errors.h" … … 49 49 #include "cmds.h" 50 50 51 static c har *cmdname = "ls";51 static const char *cmdname = "ls"; 52 52 53 53 static void ls_scan_dir(const char *d, DIR *dirp) -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
rcf8cc36 rc47e1a8 38 38 #include <getopt.h> 39 39 #include <stdarg.h> 40 #include <str ing.h>40 #include <str.h> 41 41 42 42 #include "config.h" … … 49 49 #define MKDIR_VERSION "0.0.1" 50 50 51 static c har *cmdname = "mkdir";51 static const char *cmdname = "mkdir"; 52 52 53 53 static struct option const long_options[] = { -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
rcf8cc36 rc47e1a8 38 38 #include <getopt.h> 39 39 #include <stdarg.h> 40 #include <str ing.h>40 #include <str.h> 41 41 #include <ctype.h> 42 42 … … 51 51 #define BUFFER_SIZE 16384 52 52 53 static c har *cmdname = "mkfile";53 static const char *cmdname = "mkfile"; 54 54 55 55 static struct option const long_options[] = { -
uspace/app/bdsh/cmds/modules/module_aliases.h
rcf8cc36 rc47e1a8 12 12 * the entry point being reached. */ 13 13 14 c har *mod_aliases[] = {14 const char *mod_aliases[] = { 15 15 "ren", "mv", 16 16 "umount", "unmount", -
uspace/app/bdsh/cmds/modules/mount/mount.c
rcf8cc36 rc47e1a8 58 58 { 59 59 unsigned int argc; 60 c har *mopts = "";60 const char *mopts = ""; 61 61 int rc; 62 62 -
uspace/app/bdsh/cmds/modules/pwd/pwd.c
rcf8cc36 rc47e1a8 39 39 #include "pwd.h" 40 40 41 static c har *cmdname = "pwd";41 static const char *cmdname = "pwd"; 42 42 43 43 void help_cmd_pwd(unsigned int level) -
uspace/app/bdsh/cmds/modules/rm/rm.c
rcf8cc36 rc47e1a8 36 36 #include <getopt.h> 37 37 #include <mem.h> 38 #include <str ing.h>38 #include <str.h> 39 39 40 40 #include "config.h" … … 45 45 #include "cmds.h" 46 46 47 static c har *cmdname = "rm";47 static const char *cmdname = "rm"; 48 48 #define RM_VERSION "0.0.1" 49 49 -
uspace/app/bdsh/cmds/modules/sleep/sleep.c
rcf8cc36 rc47e1a8 38 38 #include "cmds.h" 39 39 40 static c har *cmdname = "sleep";40 static const char *cmdname = "sleep"; 41 41 42 42 /* Dispays help for sleep in various levels */ -
uspace/app/bdsh/cmds/modules/touch/touch.c
rcf8cc36 rc47e1a8 38 38 #include <dirent.h> 39 39 #include <sys/types.h> 40 #include <str ing.h>40 #include <str.h> 41 41 42 42 #include "config.h" … … 47 47 #include "cmds.h" 48 48 49 static c har *cmdname = "touch";49 static const char *cmdname = "touch"; 50 50 51 51 /* Dispays help for touch in various levels */ -
uspace/app/bdsh/errors.c
rcf8cc36 rc47e1a8 30 30 31 31 #include <stdio.h> 32 #include <str ing.h>32 #include <str.h> 33 33 #include <stdlib.h> 34 34 #include <unistd.h> … … 47 47 /* Look up errno in cl_errors and return the corresponding string. 48 48 * Return NULL if not found */ 49 static c har *err2str(int err)49 static const char *err2str(int err) 50 50 { 51 51 -
uspace/app/bdsh/errstr.h
rcf8cc36 rc47e1a8 4 4 /* Simple array to translate error codes to meaningful strings */ 5 5 6 static c har *cl_errors[] = {6 static const char *cl_errors[] = { 7 7 "Success", 8 8 "Failure", … … 18 18 }; 19 19 20 static c har *err2str(int);20 static const char *err2str(int); 21 21 22 22 #endif -
uspace/app/bdsh/exec.c
rcf8cc36 rc47e1a8 38 38 #include <stdlib.h> 39 39 #include <unistd.h> 40 #include <str ing.h>40 #include <str.h> 41 41 #include <fcntl.h> 42 #include <str_error.h> 42 43 43 44 #include "config.h" … … 120 121 free(found); 121 122 122 tid = task_spawn( (const char *)tmp, argv);123 tid = task_spawn(tmp, (const char **) argv, &retval); 123 124 free(tmp); 124 125 125 126 if (tid == 0) { 126 cli_error(CL_EEXEC, "Cannot spawn `%s'.", cmd); 127 cli_error(CL_EEXEC, "%s: Cannot spawn `%s' (%s)", progname, cmd, 128 str_error(retval)); 127 129 return 1; 128 130 } … … 130 132 task_wait(tid, &texit, &retval); 131 133 if (texit != TASK_EXIT_NORMAL) { 132 printf(" Command failed (unexpectedly terminated).\n");134 printf("%s: Command failed (unexpectedly terminated)\n", progname); 133 135 } else if (retval != 0) { 134 printf("Command failed (return value %d).\n", retval); 136 printf("%s: Command failed (%s)\n", 137 progname, str_error(retval)); 135 138 } 136 139 -
uspace/app/bdsh/exec.h
rcf8cc36 rc47e1a8 5 5 6 6 extern unsigned int try_exec(char *, char **); 7 7 8 #endif -
uspace/app/bdsh/input.c
rcf8cc36 rc47e1a8 1 1 /* Copyright (c) 2008, Tim Post <tinkertim@gmail.com> 2 2 * All rights reserved. 3 * Copyright (c) 2008, Jiri Svoboda - All Rights Reserved4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 32 31 #include <stdio.h> 33 32 #include <stdlib.h> 34 #include <str ing.h>33 #include <str.h> 35 34 #include <io/console.h> 36 35 #include <io/keycode.h> … … 43 42 #include <assert.h> 44 43 #include <bool.h> 44 #include <tinput.h> 45 45 46 46 #include "config.h" … … 51 51 #include "exec.h" 52 52 53 #define HISTORY_LEN 10 53 extern volatile unsigned int cli_quit; 54 54 55 55 /** Text input field. */ 56 typedef struct { 57 /** Buffer holding text currently being edited */ 58 wchar_t buffer[INPUT_MAX + 1]; 59 /** Screen coordinates of the top-left corner of the text field */ 60 int col0, row0; 61 /** Screen dimensions */ 62 int con_cols, con_rows; 63 /** Number of characters in @c buffer */ 64 int nc; 65 /** Caret position within buffer */ 66 int pos; 67 /** Selection mark position within buffer */ 68 int sel_start; 69 70 /** History (dynamically allocated strings) */ 71 char *history[1 + HISTORY_LEN]; 72 /** Number of entries in @c history, not counting [0] */ 73 int hnum; 74 /** Current position in history */ 75 int hpos; 76 /** Exit flag */ 77 bool done; 78 } tinput_t; 79 80 /** Seek direction */ 81 typedef enum { 82 seek_backward = -1, 83 seek_forward = 1 84 } seek_dir_t; 85 86 static tinput_t tinput; 87 88 static char *tinput_read(tinput_t *ti); 89 static void tinput_insert_string(tinput_t *ti, const char *str); 90 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb); 91 static bool tinput_sel_active(tinput_t *ti); 92 static void tinput_sel_all(tinput_t *ti); 93 static void tinput_sel_delete(tinput_t *ti); 94 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev); 95 static void tinput_key_shift(tinput_t *ti, console_event_t *ev); 96 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev); 97 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev); 98 static void tinput_pre_seek(tinput_t *ti, bool shift_held); 99 static void tinput_post_seek(tinput_t *ti, bool shift_held); 56 static tinput_t *tinput; 100 57 101 58 /* Tokenizes input from console, sees if the first word is a built-in, if so … … 149 106 } 150 107 151 static void tinput_display_tail(tinput_t *ti, int start, int pad) 152 { 153 static wchar_t dbuf[INPUT_MAX + 1]; 154 int sa, sb; 155 int i, p; 156 157 tinput_sel_get_bounds(ti, &sa, &sb); 158 159 console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols, 160 ti->row0 + (ti->col0 + start) / ti->con_cols); 161 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 162 163 p = start; 164 if (p < sa) { 165 memcpy(dbuf, ti->buffer + p, (sa - p) * sizeof(wchar_t)); 166 dbuf[sa - p] = '\0'; 167 printf("%ls", dbuf); 168 p = sa; 169 } 170 171 if (p < sb) { 172 fflush(stdout); 173 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_RED, 0); 174 memcpy(dbuf, ti->buffer + p, 175 (sb - p) * sizeof(wchar_t)); 176 dbuf[sb - p] = '\0'; 177 printf("%ls", dbuf); 178 p = sb; 179 } 180 181 fflush(stdout); 182 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 183 184 if (p < ti->nc) { 185 memcpy(dbuf, ti->buffer + p, 186 (ti->nc - p) * sizeof(wchar_t)); 187 dbuf[ti->nc - p] = '\0'; 188 printf("%ls", dbuf); 189 } 190 191 for (i = 0; i < pad; ++i) 192 putchar(' '); 193 fflush(stdout); 194 } 195 196 static char *tinput_get_str(tinput_t *ti) 197 { 198 return wstr_to_astr(ti->buffer); 199 } 200 201 static void tinput_position_caret(tinput_t *ti) 202 { 203 console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols, 204 ti->row0 + (ti->col0 + ti->pos) / ti->con_cols); 205 } 206 207 /** Update row0 in case the screen could have scrolled. */ 208 static void tinput_update_origin(tinput_t *ti) 209 { 210 int width, rows; 211 212 width = ti->col0 + ti->nc; 213 rows = (width / ti->con_cols) + 1; 214 215 /* Update row0 if the screen scrolled. */ 216 if (ti->row0 + rows > ti->con_rows) 217 ti->row0 = ti->con_rows - rows; 218 } 219 220 static void tinput_insert_char(tinput_t *ti, wchar_t c) 221 { 222 int i; 223 int new_width, new_height; 224 225 if (ti->nc == INPUT_MAX) 226 return; 227 228 new_width = ti->col0 + ti->nc + 1; 229 if (new_width % ti->con_cols == 0) { 230 /* Advancing to new line. */ 231 new_height = (new_width / ti->con_cols) + 1; 232 if (new_height >= ti->con_rows) 233 return; /* Disallow text longer than 1 page for now. */ 234 } 235 236 for (i = ti->nc; i > ti->pos; --i) 237 ti->buffer[i] = ti->buffer[i - 1]; 238 239 ti->buffer[ti->pos] = c; 240 ti->pos += 1; 241 ti->nc += 1; 242 ti->buffer[ti->nc] = '\0'; 243 ti->sel_start = ti->pos; 244 245 tinput_display_tail(ti, ti->pos - 1, 0); 246 tinput_update_origin(ti); 247 tinput_position_caret(ti); 248 } 249 250 static void tinput_insert_string(tinput_t *ti, const char *str) 251 { 252 int i; 253 int new_width, new_height; 254 int ilen; 255 wchar_t c; 256 size_t off; 257 258 ilen = min((ssize_t) str_length(str), INPUT_MAX - ti->nc); 259 if (ilen == 0) 260 return; 261 262 new_width = ti->col0 + ti->nc + ilen; 263 new_height = (new_width / ti->con_cols) + 1; 264 if (new_height >= ti->con_rows) 265 return; /* Disallow text longer than 1 page for now. */ 266 267 for (i = ti->nc - 1; i >= ti->pos; --i) 268 ti->buffer[i + ilen] = ti->buffer[i]; 269 270 off = 0; i = 0; 271 while (i < ilen) { 272 c = str_decode(str, &off, STR_NO_LIMIT); 273 if (c == '\0') 274 break; 275 276 /* Filter out non-printable chars. */ 277 if (c < 32) 278 c = 32; 279 280 ti->buffer[ti->pos + i] = c; 281 ++i; 282 } 283 284 ti->pos += ilen; 285 ti->nc += ilen; 286 ti->buffer[ti->nc] = '\0'; 287 ti->sel_start = ti->pos; 288 289 tinput_display_tail(ti, ti->pos - ilen, 0); 290 tinput_update_origin(ti); 291 tinput_position_caret(ti); 292 } 293 294 static void tinput_backspace(tinput_t *ti) 295 { 296 int i; 297 298 if (tinput_sel_active(ti)) { 299 tinput_sel_delete(ti); 300 return; 301 } 302 303 if (ti->pos == 0) 304 return; 305 306 for (i = ti->pos; i < ti->nc; ++i) 307 ti->buffer[i - 1] = ti->buffer[i]; 308 ti->pos -= 1; 309 ti->nc -= 1; 310 ti->buffer[ti->nc] = '\0'; 311 ti->sel_start = ti->pos; 312 313 tinput_display_tail(ti, ti->pos, 1); 314 tinput_position_caret(ti); 315 } 316 317 static void tinput_delete(tinput_t *ti) 318 { 319 if (tinput_sel_active(ti)) { 320 tinput_sel_delete(ti); 321 return; 322 } 323 324 if (ti->pos == ti->nc) 325 return; 326 327 ti->pos += 1; 328 ti->sel_start = ti->pos; 329 330 tinput_backspace(ti); 331 } 332 333 static void tinput_seek_cell(tinput_t *ti, seek_dir_t dir, bool shift_held) 334 { 335 tinput_pre_seek(ti, shift_held); 336 337 if (dir == seek_forward) { 338 if (ti->pos < ti->nc) 339 ti->pos += 1; 340 } else { 341 if (ti->pos > 0) 342 ti->pos -= 1; 343 } 344 345 tinput_post_seek(ti, shift_held); 346 } 347 348 static void tinput_seek_word(tinput_t *ti, seek_dir_t dir, bool shift_held) 349 { 350 tinput_pre_seek(ti, shift_held); 351 352 if (dir == seek_forward) { 353 if (ti->pos == ti->nc) 354 return; 355 356 while (1) { 357 ti->pos += 1; 358 359 if (ti->pos == ti->nc) 360 break; 361 362 if (ti->buffer[ti->pos - 1] == ' ' && 363 ti->buffer[ti->pos] != ' ') 364 break; 365 } 366 } else { 367 if (ti->pos == 0) 368 return; 369 370 while (1) { 371 ti->pos -= 1; 372 373 if (ti->pos == 0) 374 break; 375 376 if (ti->buffer[ti->pos - 1] == ' ' && 377 ti->buffer[ti->pos] != ' ') 378 break; 379 } 380 381 } 382 383 tinput_post_seek(ti, shift_held); 384 } 385 386 static void tinput_seek_vertical(tinput_t *ti, seek_dir_t dir, bool shift_held) 387 { 388 tinput_pre_seek(ti, shift_held); 389 390 if (dir == seek_forward) { 391 if (ti->pos + ti->con_cols <= ti->nc) 392 ti->pos = ti->pos + ti->con_cols; 393 } else { 394 if (ti->pos - ti->con_cols >= 0) 395 ti->pos = ti->pos - ti->con_cols; 396 } 397 398 tinput_post_seek(ti, shift_held); 399 } 400 401 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held) 402 { 403 tinput_pre_seek(ti, shift_held); 404 405 if (dir == seek_backward) 406 ti->pos = 0; 407 else 408 ti->pos = ti->nc; 409 410 tinput_post_seek(ti, shift_held); 411 } 412 413 static void tinput_pre_seek(tinput_t *ti, bool shift_held) 414 { 415 if (tinput_sel_active(ti) && !shift_held) { 416 /* Unselect and redraw. */ 417 ti->sel_start = ti->pos; 418 tinput_display_tail(ti, 0, 0); 419 tinput_position_caret(ti); 420 } 421 } 422 423 static void tinput_post_seek(tinput_t *ti, bool shift_held) 424 { 425 if (shift_held) { 426 /* Selecting text. Need redraw. */ 427 tinput_display_tail(ti, 0, 0); 428 } else { 429 /* Shift not held. Keep selection empty. */ 430 ti->sel_start = ti->pos; 431 } 432 tinput_position_caret(ti); 433 } 434 435 static void tinput_history_insert(tinput_t *ti, char *str) 436 { 437 int i; 438 439 if (ti->hnum < HISTORY_LEN) { 440 ti->hnum += 1; 441 } else { 442 if (ti->history[HISTORY_LEN] != NULL) 443 free(ti->history[HISTORY_LEN]); 444 } 445 446 for (i = ti->hnum; i > 1; --i) 447 ti->history[i] = ti->history[i - 1]; 448 449 ti->history[1] = str_dup(str); 450 451 if (ti->history[0] != NULL) { 452 free(ti->history[0]); 453 ti->history[0] = NULL; 454 } 455 } 456 457 static void tinput_set_str(tinput_t *ti, char *str) 458 { 459 str_to_wstr(ti->buffer, INPUT_MAX, str); 460 ti->nc = wstr_length(ti->buffer); 461 ti->pos = ti->nc; 462 ti->sel_start = ti->pos; 463 } 464 465 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb) 466 { 467 if (ti->sel_start < ti->pos) { 468 *sa = ti->sel_start; 469 *sb = ti->pos; 470 } else { 471 *sa = ti->pos; 472 *sb = ti->sel_start; 473 } 474 } 475 476 static bool tinput_sel_active(tinput_t *ti) 477 { 478 return ti->sel_start != ti->pos; 479 } 480 481 static void tinput_sel_all(tinput_t *ti) 482 { 483 ti->sel_start = 0; 484 ti->pos = ti->nc; 485 tinput_display_tail(ti, 0, 0); 486 tinput_position_caret(ti); 487 } 488 489 static void tinput_sel_delete(tinput_t *ti) 490 { 491 int sa, sb; 492 493 tinput_sel_get_bounds(ti, &sa, &sb); 494 if (sa == sb) 495 return; 496 497 memmove(ti->buffer + sa, ti->buffer + sb, 498 (ti->nc - sb) * sizeof(wchar_t)); 499 ti->pos = ti->sel_start = sa; 500 ti->nc -= (sb - sa); 501 ti->buffer[ti->nc] = '\0'; 502 503 tinput_display_tail(ti, sa, sb - sa); 504 tinput_position_caret(ti); 505 } 506 507 static void tinput_sel_copy_to_cb(tinput_t *ti) 508 { 509 int sa, sb; 510 wchar_t tmp_c; 511 char *str; 512 513 tinput_sel_get_bounds(ti, &sa, &sb); 514 515 if (sb < ti->nc) { 516 tmp_c = ti->buffer[sb]; 517 ti->buffer[sb] = '\0'; 518 } 519 520 str = wstr_to_astr(ti->buffer + sa); 521 522 if (sb < ti->nc) 523 ti->buffer[sb] = tmp_c; 524 525 if (str == NULL) 526 goto error; 527 528 if (clipboard_put_str(str) != EOK) 529 goto error; 530 531 free(str); 532 return; 533 error: 534 return; 535 /* TODO: Give the user some warning. */ 536 } 537 538 static void tinput_paste_from_cb(tinput_t *ti) 108 void get_input(cliuser_t *usr) 539 109 { 540 110 char *str; 541 111 int rc; 542 543 rc = clipboard_get_str(&str);544 if (rc != EOK || str == NULL)545 return; /* TODO: Give the user some warning. */546 547 tinput_insert_string(ti, str);548 free(str);549 }550 551 static void tinput_history_seek(tinput_t *ti, int offs)552 {553 int pad;554 555 if (ti->hpos + offs < 0 || ti->hpos + offs > ti->hnum)556 return;557 558 if (ti->history[ti->hpos] != NULL) {559 free(ti->history[ti->hpos]);560 ti->history[ti->hpos] = NULL;561 }562 563 ti->history[ti->hpos] = tinput_get_str(ti);564 ti->hpos += offs;565 566 pad = ti->nc - str_length(ti->history[ti->hpos]);567 if (pad < 0) pad = 0;568 569 tinput_set_str(ti, ti->history[ti->hpos]);570 tinput_display_tail(ti, 0, pad);571 tinput_update_origin(ti);572 tinput_position_caret(ti);573 }574 575 /** Initialize text input field.576 *577 * Must be called before using the field. It clears the history.578 */579 static void tinput_init(tinput_t *ti)580 {581 ti->hnum = 0;582 ti->hpos = 0;583 ti->history[0] = NULL;584 }585 586 /** Read in one line of input. */587 static char *tinput_read(tinput_t *ti)588 {589 console_event_t ev;590 char *str;591 592 fflush(stdout);593 594 if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK)595 return NULL;596 if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK)597 return NULL;598 599 ti->pos = ti->sel_start = 0;600 ti->nc = 0;601 ti->buffer[0] = '\0';602 ti->done = false;603 604 while (!ti->done) {605 fflush(stdout);606 if (!console_get_event(fphone(stdin), &ev))607 return NULL;608 609 if (ev.type != KEY_PRESS)610 continue;611 612 if ((ev.mods & KM_CTRL) != 0 &&613 (ev.mods & (KM_ALT | KM_SHIFT)) == 0) {614 tinput_key_ctrl(ti, &ev);615 }616 617 if ((ev.mods & KM_SHIFT) != 0 &&618 (ev.mods & (KM_CTRL | KM_ALT)) == 0) {619 tinput_key_shift(ti, &ev);620 }621 622 if ((ev.mods & KM_CTRL) != 0 &&623 (ev.mods & KM_SHIFT) != 0 &&624 (ev.mods & KM_ALT) == 0) {625 tinput_key_ctrl_shift(ti, &ev);626 }627 628 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {629 tinput_key_unmod(ti, &ev);630 }631 632 if (ev.c >= ' ') {633 tinput_sel_delete(ti);634 tinput_insert_char(ti, ev.c);635 }636 }637 638 ti->pos = ti->nc;639 tinput_position_caret(ti);640 putchar('\n');641 642 str = tinput_get_str(ti);643 if (str_cmp(str, "") != 0)644 tinput_history_insert(ti, str);645 646 ti->hpos = 0;647 648 return str;649 }650 651 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev)652 {653 switch (ev->key) {654 case KC_LEFT:655 tinput_seek_word(ti, seek_backward, false);656 break;657 case KC_RIGHT:658 tinput_seek_word(ti, seek_forward, false);659 break;660 case KC_UP:661 tinput_seek_vertical(ti, seek_backward, false);662 break;663 case KC_DOWN:664 tinput_seek_vertical(ti, seek_forward, false);665 break;666 case KC_X:667 tinput_sel_copy_to_cb(ti);668 tinput_sel_delete(ti);669 break;670 case KC_C:671 tinput_sel_copy_to_cb(ti);672 break;673 case KC_V:674 tinput_sel_delete(ti);675 tinput_paste_from_cb(ti);676 break;677 case KC_A:678 tinput_sel_all(ti);679 break;680 default:681 break;682 }683 }684 685 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev)686 {687 switch (ev->key) {688 case KC_LEFT:689 tinput_seek_word(ti, seek_backward, true);690 break;691 case KC_RIGHT:692 tinput_seek_word(ti, seek_forward, true);693 break;694 case KC_UP:695 tinput_seek_vertical(ti, seek_backward, true);696 break;697 case KC_DOWN:698 tinput_seek_vertical(ti, seek_forward, true);699 break;700 default:701 break;702 }703 }704 705 static void tinput_key_shift(tinput_t *ti, console_event_t *ev)706 {707 switch (ev->key) {708 case KC_LEFT:709 tinput_seek_cell(ti, seek_backward, true);710 break;711 case KC_RIGHT:712 tinput_seek_cell(ti, seek_forward, true);713 break;714 case KC_UP:715 tinput_seek_vertical(ti, seek_backward, true);716 break;717 case KC_DOWN:718 tinput_seek_vertical(ti, seek_forward, true);719 break;720 case KC_HOME:721 tinput_seek_max(ti, seek_backward, true);722 break;723 case KC_END:724 tinput_seek_max(ti, seek_forward, true);725 break;726 default:727 break;728 }729 }730 731 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev)732 {733 switch (ev->key) {734 case KC_ENTER:735 case KC_NENTER:736 ti->done = true;737 break;738 case KC_BACKSPACE:739 tinput_backspace(ti);740 break;741 case KC_DELETE:742 tinput_delete(ti);743 break;744 case KC_LEFT:745 tinput_seek_cell(ti, seek_backward, false);746 break;747 case KC_RIGHT:748 tinput_seek_cell(ti, seek_forward, false);749 break;750 case KC_HOME:751 tinput_seek_max(ti, seek_backward, false);752 break;753 case KC_END:754 tinput_seek_max(ti, seek_forward, false);755 break;756 case KC_UP:757 tinput_history_seek(ti, +1);758 break;759 case KC_DOWN:760 tinput_history_seek(ti, -1);761 break;762 default:763 break;764 }765 }766 767 void get_input(cliuser_t *usr)768 {769 char *str;770 112 771 113 fflush(stdout); … … 775 117 console_set_style(fphone(stdout), STYLE_NORMAL); 776 118 777 str = tinput_read(&tinput); 119 rc = tinput_read(tinput, &str); 120 if (rc == ENOENT) { 121 /* User requested exit */ 122 cli_quit = 1; 123 putchar('\n'); 124 return; 125 } 126 127 if (rc != EOK) { 128 /* Error in communication with console */ 129 return; 130 } 778 131 779 132 /* Check for empty input. */ … … 787 140 } 788 141 789 voidinput_init(void)142 int input_init(void) 790 143 { 791 tinput_init(&tinput); 144 tinput = tinput_new(); 145 if (tinput == NULL) { 146 printf("Failed to initialize input.\n"); 147 return 1; 148 } 149 150 return 0; 792 151 } -
uspace/app/bdsh/input.h
rcf8cc36 rc47e1a8 8 8 extern void get_input(cliuser_t *); 9 9 extern int tok_input(cliuser_t *); 10 extern voidinput_init(void);10 extern int input_init(void); 11 11 12 12 #endif -
uspace/app/bdsh/scli.c
rcf8cc36 rc47e1a8 31 31 #include <stdio.h> 32 32 #include <stdlib.h> 33 #include <str ing.h>33 #include <str.h> 34 34 #include <unistd.h> 35 35 #include "config.h" … … 65 65 usr->lasterr = 0; 66 66 67 input_init(); 67 if (input_init() != 0) 68 return 1; 68 69 69 70 return (int) cli_set_prompt(usr); … … 99 100 } 100 101 } 101 goto finit;102 102 103 finit: 103 printf("Leaving %s.\n", progname); 104 104 105 cli_finit(&usr); 105 106 return ret; -
uspace/app/bdsh/scli.h
rcf8cc36 rc47e1a8 6 6 7 7 typedef struct { 8 c har *name;8 const char *name; 9 9 char *line; 10 10 char *cwd; … … 13 13 } cliuser_t; 14 14 15 extern const char *progname; 16 15 17 #endif -
uspace/app/bdsh/util.c
rcf8cc36 rc47e1a8 29 29 30 30 #include <stdio.h> 31 #include <str ing.h>31 #include <str.h> 32 32 #include <stdarg.h> 33 33 #include <stdlib.h> -
uspace/app/edit/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = edit 31 BINARY = edit 34 32 35 33 SOURCES = \ … … 37 35 sheet.c 38 36 39 include ../Makefile.common37 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/edit/edit.c
rcf8cc36 rc47e1a8 40 40 #include <vfs/vfs.h> 41 41 #include <io/console.h> 42 #include <io/ color.h>42 #include <io/style.h> 43 43 #include <io/keycode.h> 44 44 #include <errno.h> … … 100 100 static bool cursor_visible; 101 101 102 static int scr_rows, scr_columns; 102 static ipcarg_t scr_rows; 103 static ipcarg_t scr_columns; 103 104 104 105 #define ROW_BUF_SIZE 4096 … … 475 476 static void file_save_as(void) 476 477 { 477 char *old_fname, *fname; 478 int rc; 479 480 old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 478 const char *old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 479 char *fname; 480 481 481 fname = filename_prompt("Save As", old_fname); 482 482 if (fname == NULL) { … … 485 485 } 486 486 487 rc = file_save(fname);487 int rc = file_save(fname); 488 488 if (rc != EOK) 489 489 return; … … 506 506 asprintf(&str, "%s: %s", prompt, init_value); 507 507 status_display(str); 508 console_ goto(con, 1 + str_length(str), scr_rows - 1);508 console_set_pos(con, 1 + str_length(str), scr_rows - 1); 509 509 free(str); 510 510 511 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);511 console_set_style(con, STYLE_INVERTED); 512 512 513 513 max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt)); … … 553 553 str = wstr_to_astr(buffer); 554 554 555 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);555 console_set_style(con, STYLE_NORMAL); 556 556 557 557 return str; … … 672 672 { 673 673 int sh_rows, rows; 674 int i, j;675 674 676 675 sheet_get_num_rows(&doc.sh, &sh_rows); … … 679 678 /* Draw rows from the sheet. */ 680 679 681 console_ goto(con, 0, 0);680 console_set_pos(con, 0, 0); 682 681 pane_row_range_display(0, rows); 683 682 684 683 /* Clear the remaining rows if file is short. */ 685 684 685 int i; 686 ipcarg_t j; 686 687 for (i = rows; i < pane.rows; ++i) { 687 console_ goto(con, 0, i);688 console_set_pos(con, 0, i); 688 689 for (j = 0; j < scr_columns; ++j) 689 690 putchar(' '); … … 718 719 wchar_t c; 719 720 size_t pos, size; 720 unsigneds_column;721 int s_column; 721 722 coord_t csel_start, csel_end, ctmp; 722 723 … … 737 738 /* Draw rows from the sheet. */ 738 739 739 console_ goto(con, 0, 0);740 console_set_pos(con, 0, 0); 740 741 for (i = r0; i < r1; ++i) { 741 742 /* Starting point for row display */ … … 757 758 coord_cmp(&rbc, &csel_end) < 0) { 758 759 fflush(stdout); 759 console_set_ color(con, COLOR_BLACK, COLOR_RED, 0);760 console_set_style(con, STYLE_SELECTED); 760 761 fflush(stdout); 761 762 } 762 763 763 console_ goto(con, 0, i);764 console_set_pos(con, 0, i); 764 765 size = str_size(row_buf); 765 766 pos = 0; 766 767 s_column = pane.sh_column; 767 768 while (pos < size) { 768 if ( csel_start.row == rbc.row && csel_start.column == s_column) {769 if ((csel_start.row == rbc.row) && (csel_start.column == s_column)) { 769 770 fflush(stdout); 770 console_set_ color(con, COLOR_BLACK, COLOR_RED, 0);771 console_set_style(con, STYLE_SELECTED); 771 772 fflush(stdout); 772 773 } 773 774 774 if ( csel_end.row == rbc.row && csel_end.column == s_column) {775 if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) { 775 776 fflush(stdout); 776 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);777 console_set_style(con, STYLE_NORMAL); 777 778 fflush(stdout); 778 779 } … … 792 793 } 793 794 794 if ( csel_end.row == rbc.row && csel_end.column == s_column) {795 if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) { 795 796 fflush(stdout); 796 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);797 console_set_style(con, STYLE_NORMAL); 797 798 fflush(stdout); 798 799 } … … 808 809 putchar(' '); 809 810 fflush(stdout); 810 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);811 console_set_style(con, STYLE_NORMAL); 811 812 } 812 813 … … 819 820 spt_t caret_pt; 820 821 coord_t coord; 821 char *fname;822 int n;823 822 824 823 tag_get_pt(&pane.caret_pos, &caret_pt); 825 824 spt_get_coord(&caret_pt, &coord); 826 825 827 fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>";828 829 console_ goto(con, 0, scr_rows - 1);830 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);831 n = printf(" %d, %d: File '%s'. Ctrl-Q Quit Ctrl-S Save "826 const char *fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>"; 827 828 console_set_pos(con, 0, scr_rows - 1); 829 console_set_style(con, STYLE_INVERTED); 830 int n = printf(" %d, %d: File '%s'. Ctrl-Q Quit Ctrl-S Save " 832 831 "Ctrl-E Save As", coord.row, coord.column, fname); 833 832 printf("%*s", scr_columns - 1 - n, ""); 834 833 fflush(stdout); 835 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);834 console_set_style(con, STYLE_NORMAL); 836 835 837 836 pane.rflags |= REDRAW_CARET; … … 847 846 848 847 spt_get_coord(&caret_pt, &coord); 849 console_ goto(con, coord.column - pane.sh_column,848 console_set_pos(con, coord.column - pane.sh_column, 850 849 coord.row - pane.sh_row); 851 850 } … … 1152 1151 static void status_display(char const *str) 1153 1152 { 1154 console_ goto(con, 0, scr_rows - 1);1155 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);1153 console_set_pos(con, 0, scr_rows - 1); 1154 console_set_style(con, STYLE_INVERTED); 1156 1155 printf(" %*s ", -(scr_columns - 3), str); 1157 1156 fflush(stdout); 1158 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);1157 console_set_style(con, STYLE_NORMAL); 1159 1158 1160 1159 pane.rflags |= REDRAW_CARET; -
uspace/app/edit/sheet.c
rcf8cc36 rc47e1a8 50 50 51 51 #include <stdlib.h> 52 #include <str ing.h>52 #include <str.h> 53 53 #include <errno.h> 54 54 #include <adt/list.h> -
uspace/app/getterm/Makefile
rcf8cc36 rc47e1a8 28 28 # 29 29 30 include ../../../version31 DEFS += -DRELEASE=$(RELEASE) "-DNAME=$(NAME)"32 33 30 USPACE_PREFIX = ../.. 34 LIBS = $(LIBC_PREFIX)/libc.a 35 36 OUTPUT = getterm 31 DEFS = -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" 32 BINARY = getterm 37 33 38 34 SOURCES = \ … … 40 36 version.c 41 37 42 include ../Makefile.common38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/getterm/getterm.c
rcf8cc36 rc47e1a8 40 40 #include <stdio.h> 41 41 #include <task.h> 42 #include <str_error.h> 42 43 #include "version.h" 44 45 #define APP_NAME "getterm" 43 46 44 47 static void usage(void) 45 48 { 46 printf("Usage: getterm <terminal> <path>\n");49 printf("Usage: %s <terminal> <path>\n", APP_NAME); 47 50 } 48 51 … … 69 72 } 70 73 71 static task_id_t spawn(c har *fname)74 static task_id_t spawn(const char *fname) 72 75 { 73 c har *args[2];76 const char *args[2]; 74 77 75 78 args[0] = fname; 76 79 args[1] = NULL; 77 80 78 task_id_t id = task_spawn(fname, args); 81 int err; 82 task_id_t id = task_spawn(fname, args, &err); 79 83 80 84 if (id == 0) 81 printf("Error spawning %s\n", fname); 85 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname, 86 str_error(err)); 82 87 83 88 return id; -
uspace/app/getterm/version.c
rcf8cc36 rc47e1a8 40 40 #include "version.h" 41 41 42 static c har *release = STRING(RELEASE);43 static c har *name = STRING(NAME);44 static c har *arch = STRING(UARCH);42 static const char *release = STRING(RELEASE); 43 static const char *name = STRING(NAME); 44 static const char *arch = STRING(UARCH); 45 45 46 46 #ifdef REVISION 47 static c har *revision = ", revision " STRING(REVISION);47 static const char *revision = ", revision " STRING(REVISION); 48 48 #else 49 static c har *revision = "";49 static const char *revision = ""; 50 50 #endif 51 51 52 52 #ifdef TIMESTAMP 53 static c har *timestamp = "\nBuilt on " STRING(TIMESTAMP);53 static const char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 54 54 #else 55 static c har *timestamp = "";55 static const char *timestamp = ""; 56 56 #endif 57 57 -
uspace/app/init/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = init 31 BINARY = init 34 32 35 33 SOURCES = \ 36 34 init.c 37 35 38 include ../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/init/init.c
rcf8cc36 rc47e1a8 46 46 #include <malloc.h> 47 47 #include <macros.h> 48 #include <str ing.h>48 #include <str.h> 49 49 #include <devmap.h> 50 #include <str_error.h> 50 51 #include "init.h" 51 52 53 #define ROOT_DEVICE "bd/initrd" 54 #define ROOT_MOUNT_POINT "/" 55 56 #define DEVFS_FS_TYPE "devfs" 52 57 #define DEVFS_MOUNT_POINT "/dev" 58 59 #define SCRATCH_FS_TYPE "tmpfs" 60 #define SCRATCH_MOUNT_POINT "/scratch" 61 62 #define DATA_FS_TYPE "fat" 63 #define DATA_DEVICE "bd/disk0" 64 #define DATA_MOUNT_POINT "/data" 53 65 54 66 #define SRV_CONSOLE "/srv/console" … … 57 69 static void info_print(void) 58 70 { 59 printf(NAME ": HelenOS init\n"); 71 printf("%s: HelenOS init\n", NAME); 72 } 73 74 static bool mount_report(const char *desc, const char *mntpt, 75 const char *fstype, const char *dev, int rc) 76 { 77 switch (rc) { 78 case EOK: 79 if (dev != NULL) 80 printf("%s: %s mounted on %s (%s at %s)\n", NAME, desc, mntpt, 81 fstype, dev); 82 else 83 printf("%s: %s mounted on %s (%s)\n", NAME, desc, mntpt, fstype); 84 break; 85 case EBUSY: 86 printf("%s: %s already mounted on %s\n", NAME, desc, mntpt); 87 return false; 88 case ELIMIT: 89 printf("%s: %s limit exceeded\n", NAME, desc); 90 return false; 91 case ENOENT: 92 printf("%s: %s unknown type (%s)\n", NAME, desc, fstype); 93 return false; 94 default: 95 printf("%s: %s not mounted on %s (%s)\n", NAME, desc, mntpt, 96 str_error(rc)); 97 return false; 98 } 99 100 return true; 60 101 } 61 102 62 103 static bool mount_root(const char *fstype) 63 104 { 64 char *opts = ""; 65 const char *root_dev = "bd/initrd"; 105 const char *opts = ""; 66 106 67 107 if (str_cmp(fstype, "tmpfs") == 0) 68 108 opts = "restore"; 69 109 70 int rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING); 71 72 switch (rc) { 73 case EOK: 74 printf(NAME ": Root filesystem mounted, %s at %s\n", 75 fstype, root_dev); 76 break; 77 case EBUSY: 78 printf(NAME ": Root filesystem already mounted\n"); 79 return false; 80 case ELIMIT: 81 printf(NAME ": Unable to mount root filesystem\n"); 82 return false; 83 case ENOENT: 84 printf(NAME ": Unknown filesystem type (%s)\n", fstype); 85 return false; 86 default: 87 printf(NAME ": Error mounting root filesystem (%d)\n", rc); 88 return false; 89 } 90 91 return true; 110 int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts, 111 IPC_FLAG_BLOCKING); 112 return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype, 113 ROOT_DEVICE, rc); 92 114 } 93 115 94 116 static bool mount_devfs(void) 95 117 { 96 int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING); 97 98 switch (rc) { 99 case EOK: 100 printf(NAME ": Device filesystem mounted\n"); 101 break; 102 case EBUSY: 103 printf(NAME ": Device filesystem already mounted\n"); 104 105 return false; 106 case ELIMIT: 107 printf(NAME ": Unable to mount device filesystem\n"); 108 109 return false; 110 case ENOENT: 111 printf(NAME ": Unknown filesystem type (devfs)\n"); 112 113 return false; 114 default: 115 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 116 117 return false; 118 } 119 120 return true; 121 } 122 123 static void spawn(char *fname) 124 { 125 char *argv[2]; 118 int rc = mount(DEVFS_FS_TYPE, DEVFS_MOUNT_POINT, "", "", 119 IPC_FLAG_BLOCKING); 120 return mount_report("Device filesystem", DEVFS_MOUNT_POINT, DEVFS_FS_TYPE, 121 NULL, rc); 122 } 123 124 static void spawn(const char *fname) 125 { 126 const char *argv[2]; 126 127 struct stat s; 127 128 … … 129 130 return; 130 131 131 printf( NAME ": Spawning %s\n", fname);132 printf("%s: Spawning %s\n", NAME, fname); 132 133 133 134 argv[0] = fname; 134 135 argv[1] = NULL; 135 136 136 if (!task_spawn(fname, argv)) 137 printf(NAME ": Error spawning %s\n", fname); 138 } 139 140 static void srv_start(char *fname) 141 { 142 char *argv[2]; 137 int err; 138 if (!task_spawn(fname, argv, &err)) 139 printf("%s: Error spawning %s (%s)\n", NAME, fname, 140 str_error(err)); 141 } 142 143 static void srv_start(const char *fname) 144 { 145 const char *argv[2]; 143 146 task_id_t id; 144 147 task_exit_t texit; … … 149 152 return; 150 153 151 printf( NAME ": Starting %s\n", fname);154 printf("%s: Starting %s\n", NAME, fname); 152 155 153 156 argv[0] = fname; 154 157 argv[1] = NULL; 155 158 156 id = task_spawn(fname, argv );159 id = task_spawn(fname, argv, &retval); 157 160 if (!id) { 158 printf(NAME ": Error spawning %s\n", fname); 161 printf("%s: Error spawning %s (%s)\n", NAME, fname, 162 str_error(retval)); 159 163 return; 160 164 } 161 165 162 166 rc = task_wait(id, &texit, &retval); 163 167 if (rc != EOK) { 164 printf(NAME ": Error waiting for %s\n", fname); 168 printf("%s: Error waiting for %s (%s(\n", NAME, fname, 169 str_error(retval)); 165 170 return; 166 171 } 167 172 168 173 if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) { 169 printf( NAME ": Server %s failed to start (returned %d)\n",170 fname, retval);171 } 172 } 173 174 static void console(c har *dev)175 { 176 c har *argv[3];174 printf("%s: Server %s failed to start (%s)\n", NAME, 175 fname, str_error(retval)); 176 } 177 } 178 179 static void console(const char *dev) 180 { 181 const char *argv[3]; 177 182 char hid_in[DEVMAP_NAME_MAXLEN]; 178 183 int rc; … … 180 185 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 181 186 182 printf( NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in);187 printf("%s: Spawning %s %s\n", NAME, SRV_CONSOLE, hid_in); 183 188 184 189 /* Wait for the input device to be ready */ … … 191 196 argv[2] = NULL; 192 197 193 if (!task_spawn(SRV_CONSOLE, argv)) 194 printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in); 198 if (!task_spawn(SRV_CONSOLE, argv, &rc)) 199 printf("%s: Error spawning %s %s (%s)\n", NAME, SRV_CONSOLE, 200 hid_in, str_error(rc)); 195 201 } else 196 printf(NAME ": Error waiting on %s\n", hid_in); 197 } 198 199 static void getterm(char *dev, char *app) 200 { 201 char *argv[4]; 202 printf("%s: Error waiting on %s (%s)\n", NAME, hid_in, 203 str_error(rc)); 204 } 205 206 static void getterm(const char *dev, const char *app) 207 { 208 const char *argv[4]; 202 209 char term[DEVMAP_NAME_MAXLEN]; 203 210 int rc; … … 205 212 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 206 213 207 printf( NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app);214 printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app); 208 215 209 216 /* Wait for the terminal device to be ready */ … … 217 224 argv[3] = NULL; 218 225 219 if (!task_spawn(APP_GETTERM, argv ))220 printf( NAME ": Error spawning %s with %s %s\n", APP_GETTERM,221 term, app );226 if (!task_spawn(APP_GETTERM, argv, &rc)) 227 printf("%s: Error spawning %s %s %s (%s)\n", NAME, APP_GETTERM, 228 term, app, str_error(rc)); 222 229 } else 223 printf(NAME ": Error waiting on %s\n", term); 224 } 225 226 static void mount_scratch(void) 227 { 228 int rc; 229 230 printf("Trying to mount null/0 on /scratch... "); 231 fflush(stdout); 232 233 rc = mount("tmpfs", "/scratch", "null/0", "", 0); 234 if (rc == EOK) 235 printf("OK\n"); 236 else 237 printf("Failed\n"); 238 } 239 240 static void mount_data(void) 241 { 242 int rc; 243 244 printf("Trying to mount bd/disk0 on /data... "); 245 fflush(stdout); 246 247 rc = mount("fat", "/data", "bd/disk0", "wtcache", 0); 248 if (rc == EOK) 249 printf("OK\n"); 250 else 251 printf("Failed\n"); 230 printf("%s: Error waiting on %s (%s)\n", NAME, term, 231 str_error(rc)); 232 } 233 234 static bool mount_scratch(void) 235 { 236 int rc = mount(SCRATCH_FS_TYPE, SCRATCH_MOUNT_POINT, "", "", 0); 237 return mount_report("Scratch filesystem", SCRATCH_MOUNT_POINT, 238 SCRATCH_FS_TYPE, NULL, rc); 239 } 240 241 static bool mount_data(void) 242 { 243 int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0); 244 return mount_report("Data filesystem", DATA_MOUNT_POINT, DATA_FS_TYPE, 245 DATA_DEVICE, rc); 252 246 } 253 247 … … 257 251 258 252 if (!mount_root(STRING(RDFMT))) { 259 printf( NAME ": Exiting\n");253 printf("%s: Exiting\n", NAME); 260 254 return -1; 261 255 } 262 256 263 257 /* Make sure tmpfs is running. */ 264 258 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { … … 270 264 271 265 if (!mount_devfs()) { 272 printf( NAME ": Exiting\n");266 printf("%s: Exiting\n", NAME); 273 267 return -2; 274 268 } 275 269 276 270 mount_scratch(); 277 271 … … 282 276 srv_start("/srv/adb_ms"); 283 277 srv_start("/srv/char_ms"); 284 278 285 279 spawn("/srv/fb"); 286 280 spawn("/srv/kbd"); … … 288 282 289 283 spawn("/srv/clip"); 290 284 291 285 /* 292 286 * Start these synchronously so that mount_data() can be … … 299 293 (void) srv_start; 300 294 #endif 301 295 302 296 #ifdef CONFIG_MOUNT_DATA 303 297 mount_data(); … … 305 299 (void) mount_data; 306 300 #endif 307 301 308 302 getterm("term/vc0", "/app/bdsh"); 309 303 getterm("term/vc1", "/app/bdsh"); … … 314 308 getterm("term/vc6", "/app/klog"); 315 309 getterm("term/vc7", "/srv/devman"); 316 317 //usleep(1000000);318 //spawn("/srv/dd");319 320 310 321 311 return 0; -
uspace/app/klog/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = klog 31 BINARY = klog 34 32 35 33 SOURCES = \ 36 34 klog.c 37 35 38 include ../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/klog/klog.c
rcf8cc36 rc47e1a8 64 64 int main(int argc, char *argv[]) 65 65 { 66 size_t klog_pages = sysinfo_value("klog.pages"); 66 size_t klog_pages; 67 if (sysinfo_get_value("klog.pages", &klog_pages) != EOK) { 68 printf("%s: Error getting klog address\n", NAME); 69 return -1; 70 } 71 67 72 size_t klog_size = klog_pages * PAGE_SIZE; 68 73 klog_length = klog_size / sizeof(wchar_t); … … 70 75 klog = (wchar_t *) as_get_mappable_page(klog_size); 71 76 if (klog == NULL) { 72 printf( NAME ": Error allocating memory area\n");77 printf("%s: Error allocating memory area\n", NAME); 73 78 return -1; 74 79 } … … 77 82 klog_size, SERVICE_MEM_KLOG); 78 83 if (res != EOK) { 79 printf( NAME ": Error initializing memory area\n");84 printf("%s: Error initializing memory area\n", NAME); 80 85 return -1; 81 86 } 82 87 83 88 if (event_subscribe(EVENT_KLOG, 0) != EOK) { 84 printf( NAME ": Error registering klog notifications\n");89 printf("%s: Error registering klog notifications\n", NAME); 85 90 return -1; 86 91 } -
uspace/app/mkfat/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a 32 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) 33 34 OUTPUT = mkfat 33 BINARY = mkfat 35 34 36 35 SOURCES = \ 37 36 mkfat.c 38 37 39 include ../Makefile.common38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/mkfat/fat.h
rcf8cc36 rc47e1a8 78 78 uint16_t signature; 79 79 } __attribute__ ((packed)); 80 struct fat32{80 struct { 81 81 /* FAT32 only */ 82 82 /** Sectors per FAT. */ … … 108 108 /** Signature. */ 109 109 uint16_t signature; 110 } __attribute__ ((packed));110 } fat32 __attribute__ ((packed)); 111 111 }; 112 112 } __attribute__ ((packed)) fat_bs_t; -
uspace/app/mkfat/mkfat.c
rcf8cc36 rc47e1a8 98 98 size_t block_size; 99 99 char *endptr; 100 bn_t dev_nblocks;100 aoff64_t dev_nblocks; 101 101 102 102 cfg.total_sectors = 0; … … 160 160 printf(NAME ": Warning, failed to obtain block device size.\n"); 161 161 } else { 162 printf(NAME ": Block device has %" PRIu BN" blocks.\n",162 printf(NAME ": Block device has %" PRIuOFF64 " blocks.\n", 163 163 dev_nblocks); 164 164 cfg.total_sectors = dev_nblocks; … … 236 236 static int fat_blocks_write(struct fat_params const *par, dev_handle_t handle) 237 237 { 238 bn_t addr;238 aoff64_t addr; 239 239 uint8_t *buffer; 240 240 int i; -
uspace/app/redir/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = redir 31 BINARY = redir 34 32 35 33 SOURCES = \ 36 34 redir.c 37 35 38 include ../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/redir/redir.c
rcf8cc36 rc47e1a8 39 39 #include <fcntl.h> 40 40 #include <unistd.h> 41 #include <str ing.h>41 #include <str.h> 42 42 #include <stdio.h> 43 43 #include <task.h> 44 #include <str_error.h> 45 46 #define NAME "redir" 44 47 45 48 static void usage(void) 46 49 { 47 printf("Usage: redir [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n"); 50 printf("Usage: %s [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n", 51 NAME); 48 52 } 49 53 … … 72 76 static task_id_t spawn(int argc, char *argv[]) 73 77 { 74 c har **args = (char*) calloc(argc + 1, sizeof(char *));78 const char **args = (const char **) calloc(argc + 1, sizeof(char *)); 75 79 if (!args) { 76 80 printf("No memory available\n"); … … 84 88 args[argc] = NULL; 85 89 86 task_id_t id = task_spawn(argv[0], args); 90 int err; 91 task_id_t id = task_spawn(argv[0], args, &err); 87 92 88 93 free(args); 89 94 90 95 if (id == 0) 91 printf("Error spawning %s\n", argv[0]); 96 printf("%s: Error spawning %s (%s)\n", NAME, argv[0], 97 str_error(err)); 92 98 93 99 return id; -
uspace/app/sbi/src/bigint.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 20 06 Martin Decky2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef B OOT_ppc32_ASM_H_30 #define B OOT_ppc32_ASM_H_29 #ifndef BIGINT_H_ 30 #define BIGINT_H_ 31 31 32 #define PAGE_WIDTH 12 33 #define PAGE_SIZE (1 << PAGE_WIDTH) 32 #include "mytypes.h" 34 33 35 #define TRANS_SIZE 1024 36 #define BOOT_OFFSET 0x8000 34 void bigint_init(bigint_t *bigint, int value); 35 void bigint_shallow_copy(bigint_t *src, bigint_t *dest); 36 void bigint_clone(bigint_t *src, bigint_t *dest); 37 void bigint_reverse_sign(bigint_t *src, bigint_t *dest); 38 void bigint_destroy(bigint_t *bigint); 37 39 38 #define BALLOC_MAX_SIZE (128 * 1024) 40 int bigint_get_value_int(bigint_t *bigint, int *dval); 41 bool_t bigint_is_zero(bigint_t *bigint); 42 bool_t bigint_is_negative(bigint_t *bigint); 39 43 40 #ifndef __ASM__ 44 void bigint_div_digit(bigint_t *a, bigint_word_t b, bigint_t *quot, 45 bigint_word_t *rem); 41 46 42 #include "types.h" 43 #include "main.h" 44 #include "ofwarch.h" 45 46 #define PA2KA(x) (((uintptr_t) (x)) + 0x80000000) 47 48 extern uint8_t balloc_base[BALLOC_MAX_SIZE]; 49 extern uintptr_t trans[TRANS_SIZE]; 50 51 extern void halt(); 52 extern void jump_to_kernel(void *bootinfo, unsigned int bootinfo_size, 53 uintptr_t trans[], unsigned int kernel_size, void *real_mode) __attribute__((noreturn)); 54 extern void real_mode(); 55 56 #else 57 58 #define PA2KA(x) ((x) + 0x80000000) 47 void bigint_add(bigint_t *a, bigint_t *b, bigint_t *dest); 48 void bigint_sub(bigint_t *a, bigint_t *b, bigint_t *dest); 49 void bigint_mul(bigint_t *a, bigint_t *b, bigint_t *dest); 50 void bigint_print(bigint_t *bigint); 59 51 60 52 #endif 61 62 #endif -
uspace/app/sbi/src/builtin.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 2007 Michal Kebrt 3 * Copyright (c) 2009 Vineeth Pillai 2 * Copyright (c) 2010 Jiri Svoboda 4 3 * All rights reserved. 5 4 * … … 28 27 */ 29 28 29 #ifndef BUILTIN_H_ 30 #define BUILTIN_H_ 30 31 31 /** @addtogroup arm32boot 32 * @{ 33 */ 34 /** @file 35 * @brief bootloader output logic 36 */ 32 #include "mytypes.h" 37 33 34 void builtin_declare(stree_program_t *program); 35 void builtin_bind(builtin_t *bi); 36 void builtin_code_snippet(builtin_t *bi, const char *snippet); 38 37 39 #include <printf.h> 38 stree_csi_t *builtin_get_gf_class(builtin_t *builtin); 39 void builtin_run_proc(run_t *run, stree_proc_t *proc); 40 40 41 rdata_var_t *builtin_get_self_mbr_var(run_t *run, const char *mbr_name); 41 42 42 /** Address where characters to be printed are expected. */ 43 #ifdef MACHINE_testarm 44 #define PUTC_ADDRESS 0x10000000 43 stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name); 44 void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name); 45 46 stree_symbol_t *builtin_find_lvl0(builtin_t *bi, const char *sym_name); 47 stree_symbol_t *builtin_find_lvl1(builtin_t *bi, const char *csi_name, 48 const char *sym_name); 49 50 void builtin_fun_bind(builtin_t *bi, const char *csi_name, 51 const char *sym_name, builtin_proc_t bproc); 52 45 53 #endif 46 47 #ifdef MACHINE_integratorcp48 #define PUTC_ADDRESS 0x1600000049 #endif50 51 52 53 /** Prints a character to the console.54 *55 * @param ch Character to be printed.56 */57 static void putc(char ch)58 {59 if (ch == '\n')60 *((volatile char *) PUTC_ADDRESS) = '\r';61 *((volatile char *) PUTC_ADDRESS) = ch;62 }63 64 65 /** Prints a string to the console.66 *67 * @param str String to be printed.68 * @param len Number of characters to be printed.69 */70 void write(const char *str, const int len)71 {72 int i;73 for (i = 0; i < len; ++i) {74 putc(str[i]);75 }76 }77 78 /** @}79 */80 -
uspace/app/sbi/src/input.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 20 06 Martin Decky2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_mips32_TYPES_H_30 #define BOOT_mips32_TYPES_H_29 #ifndef INPUT_H_ 30 #define INPUT_H_ 31 31 32 #include <gentypes.h>32 #include "mytypes.h" 33 33 34 typedef signed char int8_t; 34 int input_new_file(input_t **input, const char *fname); 35 int input_new_interactive(input_t **input); 36 int input_new_string(input_t **input, const char *str); 35 37 36 typedef unsigned char uint8_t; 37 typedef unsigned short uint16_t; 38 typedef unsigned int uint32_t; 39 typedef unsigned long long uint64_t; 40 41 typedef uint32_t uintptr_t; 42 typedef uint32_t unative_t; 38 int input_get_line(input_t *input, char **line); 39 int input_get_line_no(input_t *input); 43 40 44 41 #endif -
uspace/app/sbi/src/lex.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 20 06 Martin Decky2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_ia64_TYPES_H_30 #define BOOT_ia64_TYPES_H_29 #ifndef LEX_H_ 30 #define LEX_H_ 31 31 32 #include <gentypes.h>32 #include "mytypes.h" 33 33 34 typedef signed char int8_t; 34 void lclass_print(lclass_t lclass); 35 void lem_print(lem_t *lem); 36 void lem_print_coords(lem_t *lem); 35 37 36 typedef unsigned char uint8_t; 37 typedef unsigned short uint16_t; 38 typedef unsigned int uint32_t; 39 typedef unsigned long uint64_t; 40 41 typedef uint64_t uintptr_t; 42 typedef uint64_t unative_t; 38 void lex_init(lex_t *lex, struct input *input); 39 void lex_next(lex_t *lex); 40 lem_t *lex_get_current(lex_t *lex); 41 lem_t *lex_peek_prev(lex_t *lex); 43 42 44 43 #endif -
uspace/app/sbi/src/symbol.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 20 05 Martin Decky2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_mips32_MAIN_H_30 #define BOOT_mips32_MAIN_H_29 #ifndef SYMBOL_H_ 30 #define SYMBOL_H_ 31 31 32 #define CPUMAP 0x80001000 33 #define INITIAL_STACK 0x80002000 34 #define MSIM_DORDER_ADDRESS 0xb0000004 32 #include "mytypes.h" 35 33 36 #define TASKMAP_MAX_RECORDS 32 37 #define CPUMAP_MAX_RECORDS 32 34 stree_symbol_t *symbol_xlookup_in_csi(stree_program_t *prog, 35 stree_csi_t *scope, stree_texpr_t *texpr); 36 stree_symbol_t *symbol_lookup_in_csi(stree_program_t *prog, stree_csi_t *scope, 37 stree_ident_t *name); 38 stree_symbol_t *symbol_search_csi(stree_program_t *prog, stree_csi_t *scope, 39 stree_ident_t *name); 40 stree_symbol_t *symbol_search_csi_no_base(stree_program_t *prog, 41 stree_csi_t *scope, stree_ident_t *name); 42 stree_symbol_t *symbol_find_epoint(stree_program_t *prog, stree_ident_t *name); 38 43 39 #ifndef __ASM__ 44 stree_deleg_t *symbol_to_deleg(stree_symbol_t *symbol); 45 stree_symbol_t *deleg_to_symbol(stree_deleg_t *deleg); 46 stree_csi_t *symbol_to_csi(stree_symbol_t *symbol); 47 stree_symbol_t *csi_to_symbol(stree_csi_t *csi); 48 stree_ctor_t *symbol_to_ctor(stree_symbol_t *symbol); 49 stree_symbol_t *ctor_to_symbol(stree_ctor_t *ctor); 50 stree_enum_t *symbol_to_enum(stree_symbol_t *symbol); 51 stree_symbol_t *enum_to_symbol(stree_enum_t *enum_d); 52 stree_fun_t *symbol_to_fun(stree_symbol_t *symbol); 53 stree_symbol_t *fun_to_symbol(stree_fun_t *fun); 54 stree_var_t *symbol_to_var(stree_symbol_t *symbol); 55 stree_symbol_t *var_to_symbol(stree_var_t *var); 56 stree_prop_t *symbol_to_prop(stree_symbol_t *symbol); 57 stree_symbol_t *prop_to_symbol(stree_prop_t *prop); 40 58 41 /** Size of buffer for storing task name in task_t. */ 42 #define BOOTINFO_TASK_NAME_BUFLEN 32 43 44 /** Struct holding information about single loaded task. */ 45 typedef struct { 46 /** Address where the task was placed. */ 47 void *addr; 48 /** Size of the task's binary. */ 49 unsigned int size; 50 /** Task name. */ 51 char name[BOOTINFO_TASK_NAME_BUFLEN]; 52 } task_t; 53 54 typedef struct { 55 unsigned int cpumap; 56 unsigned int cnt; 57 task_t tasks[TASKMAP_MAX_RECORDS]; 58 } bootinfo_t; 59 60 extern void start(void); 61 extern void bootstrap(void); 59 void symbol_print_fqn(stree_symbol_t *symbol); 62 60 63 61 #endif 64 65 #endif -
uspace/app/shutters/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = shutters 31 BINARY = shutters 34 32 35 33 SOURCES = \ 36 34 shutters.c 37 35 38 include ../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/shutters/shutters.c
rcf8cc36 rc47e1a8 53 53 #include <sys/stat.h> 54 54 55 #include <str ing.h>55 #include <str.h> 56 56 57 57 #define NAME "shutters" -
uspace/app/taskdump/Makefile
rcf8cc36 rc47e1a8 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBC_PREFIX)/libc.a31 30 EXTRA_CFLAGS = -Iinclude 32 33 OUTPUT = taskdump 31 BINARY = taskdump 34 32 35 33 SOURCES = \ 34 elf_core.c \ 36 35 taskdump.c \ 37 36 symtab.c 38 37 39 include ../Makefile.common38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/taskdump/include/elf.h
rcf8cc36 rc47e1a8 148 148 #define SHF_MASKPROC 0xf0000000 149 149 150 /** Macros for decomposing elf_symbol.st_info into binging and type */ 151 #define ELF_ST_BIND(i) ((i) >> 4) 152 #define ELF_ST_TYPE(i) ((i) & 0x0f) 153 #define ELF_ST_INFO(b, t) (((b) << 4) + ((t) & 0x0f)) 154 150 155 /** 151 156 * Symbol binding -
uspace/app/taskdump/symtab.c
rcf8cc36 rc47e1a8 49 49 static int section_hdr_load(int fd, const elf_header_t *ehdr, int idx, 50 50 elf_section_header_t *shdr); 51 static int chunk_load(int fd, off _t start, off_t size, void **ptr);51 static int chunk_load(int fd, off64_t start, size_t size, void **ptr); 52 52 static int read_all(int fd, void *buf, size_t len); 53 53 … … 65 65 elf_header_t elf_hdr; 66 66 elf_section_header_t sec_hdr; 67 off_t shstrt_start, shstrt_size; 67 off64_t shstrt_start; 68 size_t shstrt_size; 68 69 char *shstrt, *sec_name; 69 70 void *data; … … 206 207 size_t i; 207 208 char *sname; 209 unsigned stype; 208 210 209 211 for (i = 0; i < st->sym_size / sizeof(elf_symbol_t); ++i) { 210 212 if (st->sym[i].st_name == 0) 213 continue; 214 215 stype = ELF_ST_TYPE(st->sym[i].st_info); 216 if (stype != STT_OBJECT && stype != STT_FUNC) 211 217 continue; 212 218 … … 240 246 uintptr_t saddr, best_addr; 241 247 char *sname, *best_name; 248 unsigned stype; 242 249 243 250 best_name = NULL; … … 248 255 continue; 249 256 257 stype = ELF_ST_TYPE(st->sym[i].st_info); 258 if (stype != STT_OBJECT && stype != STT_FUNC && 259 stype != STT_NOTYPE) { 260 continue; 261 } 262 250 263 saddr = st->sym[i].st_value; 251 264 sname = st->strtab + st->sym[i].st_name; 265 266 /* An ugly hack to filter out some special ARM symbols. */ 267 if (sname[0] == '$') 268 continue; 252 269 253 270 if (best_name == NULL || (saddr <= addr && saddr > best_addr)) { … … 291 308 rc = lseek(fd, elf_hdr->e_shoff + idx * sizeof(elf_section_header_t), 292 309 SEEK_SET); 293 if (rc == (off _t) -1)310 if (rc == (off64_t) -1) 294 311 return EIO; 295 312 … … 312 329 * @return EOK on success or EIO on failure. 313 330 */ 314 static int chunk_load(int fd, off _t start, off_t size, void **ptr)331 static int chunk_load(int fd, off64_t start, size_t size, void **ptr) 315 332 { 316 333 int rc; 317 334 318 335 rc = lseek(fd, start, SEEK_SET); 319 if (rc == (off _t) -1) {336 if (rc == (off64_t) -1) { 320 337 printf("failed seeking chunk\n"); 321 338 *ptr = NULL; -
uspace/app/taskdump/taskdump.c
rcf8cc36 rc47e1a8 40 40 #include <udebug.h> 41 41 #include <task.h> 42 #include < kernel/mm/as.h>42 #include <as.h> 43 43 #include <sys/types.h> 44 44 #include <sys/typefmt.h> … … 49 49 50 50 #include <symtab.h> 51 #include <elf_core.h> 51 52 #include <stacktrace.h> 52 53 53 54 #define LINE_BYTES 16 54 55 #define DBUF_SIZE 409656 static uint8_t data_buf[DBUF_SIZE];57 55 58 56 static int phoneid; 59 57 static task_id_t task_id; 60 static bool dump_memory; 58 static bool write_core_file; 59 static char *core_file_name; 61 60 static char *app_name; 62 61 static symtab_t *app_symtab; … … 68 67 static int thread_dump(uintptr_t thash); 69 68 static int areas_dump(void); 70 static int area_dump(as_area_info_t *area);71 static void hex_dump(uintptr_t addr, void *buffer, size_t size);72 69 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value); 73 70 … … 80 77 int rc; 81 78 82 /*83 * FIXME: The stdio module cannot currently detect whether we are84 * writing to a console or file. This workaround make file output85 * faster.86 */87 setvbuf(stdout, NULL, _IOFBF, 32768);88 89 79 printf("Task Dump Utility\n"); 90 dump_memory= false;80 write_core_file = false; 91 81 92 82 if (parse_args(argc, argv) < 0) … … 172 162 return -1; 173 163 } 174 } else if (arg[1] == 'm' && arg[2] == '\0') { 175 dump_memory = true; 164 } else if (arg[1] == 'c' && arg[2] == '\0') { 165 write_core_file = true; 166 167 --argc; ++argv; 168 core_file_name = *argv; 176 169 } else { 177 170 printf("Uknown option '%s'\n", arg[0]); … … 203 196 static void print_syntax(void) 204 197 { 205 printf("Syntax: taskdump [- m] -t <task_id>\n");206 printf("\t- m\tDump memory area contents.\n");198 printf("Syntax: taskdump [-c <core_file>] -t <task_id>\n"); 199 printf("\t-c <core_file_id>\tName of core file to write.\n"); 207 200 printf("\t-t <task_id>\tWhich task to dump.\n"); 208 201 } … … 297 290 (ainfo_buf[i].flags & AS_AREA_CACHEABLE) ? 'C' : '-', 298 291 ainfo_buf[i].start_addr, ainfo_buf[i].size); 299 300 if (dump_memory) { 301 putchar('\n'); 302 area_dump(&ainfo_buf[i]); 303 putchar('\n'); 292 } 293 294 putchar('\n'); 295 296 if (write_core_file) { 297 printf("Writing core file '%s'\n", core_file_name); 298 rc = elf_core_save(core_file_name, ainfo_buf, n_areas, phoneid); 299 if (rc != EOK) { 300 printf("Failed writing core file.\n"); 301 return EIO; 304 302 } 305 303 } 306 307 putchar('\n');308 304 309 305 free(ainfo_buf); … … 353 349 354 350 return EOK; 355 }356 357 static int area_dump(as_area_info_t *area)358 {359 size_t to_copy;360 size_t total;361 uintptr_t addr;362 int rc;363 364 addr = area->start_addr;365 total = 0;366 367 while (total < area->size) {368 to_copy = min(area->size - total, DBUF_SIZE);369 rc = udebug_mem_read(phoneid, data_buf, addr, to_copy);370 if (rc < 0) {371 printf("udebug_mem_read() failed.\n");372 return rc;373 }374 375 hex_dump(addr, data_buf, to_copy);376 377 addr += to_copy;378 total += to_copy;379 }380 381 return EOK;382 }383 384 static void hex_dump(uintptr_t addr, void *buffer, size_t size)385 {386 uint8_t *data = (uint8_t *) buffer;387 uint8_t b;388 size_t pos, i;389 390 assert(addr % LINE_BYTES == 0);391 assert(size % LINE_BYTES == 0);392 393 pos = 0;394 395 while (pos < size) {396 printf("%08lx:", addr + pos);397 for (i = 0; i < LINE_BYTES; ++i) {398 if (i % 4 == 0) putchar(' ');399 printf(" %02x", data[pos + i]);400 }401 putchar('\t');402 403 for (i = 0; i < LINE_BYTES; ++i) {404 b = data[pos + i];405 if (b >= 32 && b < 127) {406 putchar(b);407 } else {408 putchar(' ');409 }410 }411 putchar('\n');412 pos += LINE_BYTES;413 }414 351 } 415 352 -
uspace/app/test_serial/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = test_serial 31 BINARY = test_serial 34 32 35 33 SOURCES = \ 36 34 test_serial.c 37 35 38 include ../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/test_serial/test_serial.c
rcf8cc36 rc47e1a8 45 45 #include <devman.h> 46 46 #include <device/char.h> 47 #include <str ing.h>47 #include <str.h> 48 48 #include <ipc/serial_ctl.h> 49 49 … … 136 136 } 137 137 138 c har *the_end = "\n---------\nTHE END\n---------\n";139 write_dev(phone, the_end, str_size(the_end));138 const char *the_end = "\n---------\nTHE END\n---------\n"; 139 write_dev(phone, (void *)the_end, str_size(the_end)); 140 140 141 141 // restore original communication settings -
uspace/app/tester/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = tester 31 BINARY = tester 34 32 35 33 SOURCES = \ … … 53 51 mm/malloc1.c 54 52 55 include ../Makefile.common53 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/tester/console/console1.c
rcf8cc36 rc47e1a8 36 36 #include "../tester.h" 37 37 38 const char *color_name[] = {38 static const char *color_name[] = { 39 39 [COLOR_BLACK] = "black", 40 40 [COLOR_BLUE] = "blue", … … 47 47 }; 48 48 49 c har *test_console1(void)49 const char *test_console1(void) 50 50 { 51 51 if (!test_quiet) { … … 53 53 fflush(stdout); 54 54 console_set_style(fphone(stdout), STYLE_NORMAL); 55 printf(" normal ");55 printf(" normal "); 56 56 fflush(stdout); 57 57 console_set_style(fphone(stdout), STYLE_EMPHASIS); 58 printf("emphasized"); 58 printf(" emphasized "); 59 fflush(stdout); 60 console_set_style(fphone(stdout), STYLE_INVERTED); 61 printf(" inverted "); 62 fflush(stdout); 63 console_set_style(fphone(stdout), STYLE_SELECTED); 64 printf(" selected "); 59 65 fflush(stdout); 60 66 console_set_style(fphone(stdout), STYLE_NORMAL); 61 printf(" .\n");67 printf("\n"); 62 68 63 69 unsigned int i; … … 73 79 } 74 80 fflush(stdout); 75 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);81 console_set_style(fphone(stdout), STYLE_NORMAL); 76 82 putchar('\n'); 77 83 } … … 86 92 } 87 93 fflush(stdout); 88 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);94 console_set_style(fphone(stdout), STYLE_NORMAL); 89 95 putchar('\n'); 90 96 } … … 94 100 for (i = 0; i < 255; i += 16) { 95 101 fflush(stdout); 96 console_set_rgb_color(fphone(stdout), 0xffffff, i << 16);102 console_set_rgb_color(fphone(stdout), (255 - i) << 16, i << 16); 97 103 putchar('X'); 98 104 } … … 103 109 for (i = 0; i < 255; i += 16) { 104 110 fflush(stdout); 105 console_set_rgb_color(fphone(stdout), 0xffffff, i << 8);111 console_set_rgb_color(fphone(stdout), (255 - i) << 8, i << 8); 106 112 putchar('X'); 107 113 } … … 112 118 for (i = 0; i < 255; i += 16) { 113 119 fflush(stdout); 114 console_set_rgb_color(fphone(stdout), 0xffffff, i);120 console_set_rgb_color(fphone(stdout), 255 - i, i); 115 121 putchar('X'); 116 122 } 117 123 fflush(stdout); 118 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);124 console_set_style(fphone(stdout), STYLE_NORMAL); 119 125 putchar('\n'); 120 126 } -
uspace/app/tester/fault/fault1.c
rcf8cc36 rc47e1a8 30 30 #include "../tester.h" 31 31 32 c har *test_fault1(void)32 const char *test_fault1(void) 33 33 { 34 34 ((int *)(0))[1] = 0; -
uspace/app/tester/fault/fault2.c
rcf8cc36 rc47e1a8 30 30 #include "../tester.h" 31 31 32 char *test_fault2(void) 32 typedef int __attribute__((may_alias)) aliasing_int; 33 34 const char *test_fault2(void) 33 35 { 34 36 volatile long long var; 35 37 volatile int var1; 36 38 37 var1 = *(( int *) (((char *) (&var)) + 1));39 var1 = *((aliasing_int *) (((char *) (&var)) + 1)); 38 40 39 41 return "Survived unaligned read"; -
uspace/app/tester/fault/fault3.c
rcf8cc36 rc47e1a8 30 30 #include <stdlib.h> 31 31 32 c har *test_fault3(void)32 const char *test_fault3(void) 33 33 { 34 34 abort(); -
uspace/app/tester/fault/fault3.def
rcf8cc36 rc47e1a8 3 3 "Abort", 4 4 &test_fault3, 5 true5 false 6 6 }, -
uspace/app/tester/ipc/connect.c
rcf8cc36 rc47e1a8 39 39 } 40 40 41 c har *test_connect(void)41 const char *test_connect(void) 42 42 { 43 43 TPRINTF("Connecting to %u...", IPC_TEST_SERVICE); -
uspace/app/tester/ipc/ping_pong.c
rcf8cc36 rc47e1a8 38 38 #define COUNT_GRANULARITY 100 39 39 40 c har *test_ping_pong(void)40 const char *test_ping_pong(void) 41 41 { 42 42 TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS); -
uspace/app/tester/ipc/register.c
rcf8cc36 rc47e1a8 74 74 } 75 75 76 c har *test_register(void)76 const char *test_register(void) 77 77 { 78 78 async_set_client_connection(client_connection); -
uspace/app/tester/loop/loop1.c
rcf8cc36 rc47e1a8 31 31 #include "../tester.h" 32 32 33 c har *test_loop1(void)33 const char *test_loop1(void) 34 34 { 35 35 TPRINTF("Looping..."); -
uspace/app/tester/mm/malloc1.c
rcf8cc36 rc47e1a8 73 73 74 74 typedef struct { 75 c har *name;75 const char *name; 76 76 sp_term_cond_s cond; 77 77 sp_action_prob_s prob; … … 90 90 91 91 typedef struct { 92 c har *name;92 const char *name; 93 93 ph_alloc_size_s alloc; 94 94 subphase_s *subphases; … … 628 628 } 629 629 630 c har *test_malloc1(void)630 const char *test_malloc1(void) 631 631 { 632 632 init_mem(); -
uspace/app/tester/print/print1.c
rcf8cc36 rc47e1a8 31 31 #include "../tester.h" 32 32 33 c har *test_print1(void)33 const char *test_print1(void) 34 34 { 35 35 TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n"); -
uspace/app/tester/print/print2.c
rcf8cc36 rc47e1a8 31 31 #include "../tester.h" 32 32 33 c har *test_print2(void)33 const char *test_print2(void) 34 34 { 35 35 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); -
uspace/app/tester/print/print3.c
rcf8cc36 rc47e1a8 34 34 #define BUFFER_SIZE 32 35 35 36 c har *test_print3(void)36 const char *test_print3(void) 37 37 { 38 38 char buffer[BUFFER_SIZE]; -
uspace/app/tester/print/print4.c
rcf8cc36 rc47e1a8 31 31 #include "../tester.h" 32 32 33 c har *test_print4(void)33 const char *test_print4(void) 34 34 { 35 35 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); -
uspace/app/tester/stdio/stdio1.c
rcf8cc36 rc47e1a8 36 36 static char buf[BUF_SIZE + 1]; 37 37 38 c har *test_stdio1(void)38 const char *test_stdio1(void) 39 39 { 40 40 FILE *file; 41 c har *file_name = "/readme";41 const char *file_name = "/readme"; 42 42 43 43 TPRINTF("Open file \"%s\"...", file_name); -
uspace/app/tester/stdio/stdio2.c
rcf8cc36 rc47e1a8 32 32 #include "../tester.h" 33 33 34 c har *test_stdio2(void)34 const char *test_stdio2(void) 35 35 { 36 36 FILE *file; 37 c har *file_name = "/test";37 const char *file_name = "/test"; 38 38 39 39 TPRINTF("Open file \"%s\" for writing...", file_name); -
uspace/app/tester/tester.c
rcf8cc36 rc47e1a8 38 38 #include <unistd.h> 39 39 #include <stdio.h> 40 #include <str ing.h>40 #include <str.h> 41 41 #include "tester.h" 42 42 … … 69 69 { 70 70 /* Execute the test */ 71 c har *ret = test->entry();71 const char *ret = test->entry(); 72 72 73 73 if (ret == NULL) { -
uspace/app/tester/tester.h
rcf8cc36 rc47e1a8 54 54 } 55 55 56 typedef c har *(*test_entry_t)(void);56 typedef const char *(*test_entry_t)(void); 57 57 58 58 typedef struct { 59 c har *name;60 c har *desc;59 const char *name; 60 const char *desc; 61 61 test_entry_t entry; 62 62 bool safe; 63 63 } test_t; 64 64 65 extern c har *test_thread1(void);66 extern c har *test_print1(void);67 extern c har *test_print2(void);68 extern c har *test_print3(void);69 extern c har *test_print4(void);70 extern c har *test_console1(void);71 extern c har *test_stdio1(void);72 extern c har *test_stdio2(void);73 extern c har *test_fault1(void);74 extern c har *test_fault2(void);75 extern c har *test_fault3(void);76 extern c har *test_vfs1(void);77 extern c har *test_ping_pong(void);78 extern c har *test_register(void);79 extern c har *test_connect(void);80 extern c har *test_loop1(void);81 extern c har *test_malloc1(void);65 extern const char *test_thread1(void); 66 extern const char *test_print1(void); 67 extern const char *test_print2(void); 68 extern const char *test_print3(void); 69 extern const char *test_print4(void); 70 extern const char *test_console1(void); 71 extern const char *test_stdio1(void); 72 extern const char *test_stdio2(void); 73 extern const char *test_fault1(void); 74 extern const char *test_fault2(void); 75 extern const char *test_fault3(void); 76 extern const char *test_vfs1(void); 77 extern const char *test_ping_pong(void); 78 extern const char *test_register(void); 79 extern const char *test_connect(void); 80 extern const char *test_loop1(void); 81 extern const char *test_malloc1(void); 82 82 83 83 extern test_t tests[]; -
uspace/app/tester/thread/thread1.c
rcf8cc36 rc47e1a8 50 50 } 51 51 52 c har *test_thread1(void)52 const char *test_thread1(void) 53 53 { 54 54 unsigned int i; 55 int total = 0;55 atomic_count_t total = 0; 56 56 57 57 atomic_set(&finish, 1); -
uspace/app/tester/vfs/vfs1.c
rcf8cc36 rc47e1a8 30 30 #include <stdio.h> 31 31 #include <stdlib.h> 32 #include <str ing.h>32 #include <str.h> 33 33 #include <vfs/vfs.h> 34 34 #include <unistd.h> … … 54 54 static char text[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; 55 55 56 static c har *read_root(void)56 static const char *read_root(void) 57 57 { 58 58 TPRINTF("Opening the root directory..."); … … 73 73 } 74 74 75 c har *test_vfs1(void)75 const char *test_vfs1(void) 76 76 { 77 77 if (mkdir(MOUNT_POINT, 0) != 0) … … 121 121 close(fd0); 122 122 123 c har *rv = read_root();123 const char *rv = read_root(); 124 124 if (rv != NULL) 125 125 return rv; -
uspace/app/tetris/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = tetris 31 BINARY = tetris 34 32 35 33 SOURCES = \ … … 40 38 screen.c 41 39 42 include ../Makefile.common40 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/tetris/input.c
rcf8cc36 rc47e1a8 52 52 #include <errno.h> 53 53 #include <unistd.h> 54 #include <str ing.h>54 #include <str.h> 55 55 56 56 #include "input.h" -
uspace/app/tetris/scores.c
rcf8cc36 rc47e1a8 52 52 #include <errno.h> 53 53 #include <stdio.h> 54 #include <str ing.h>54 #include <str.h> 55 55 #include <io/console.h> 56 56 #include <io/keycode.h> -
uspace/app/tetris/scores.h
rcf8cc36 rc47e1a8 48 48 49 49 #include <sys/time.h> 50 #include <str ing.h>50 #include <str.h> 51 51 52 52 #define MAXLOGNAME 16 -
uspace/app/tetris/screen.c
rcf8cc36 rc47e1a8 49 49 #include <stdio.h> 50 50 #include <stdlib.h> 51 #include <str ing.h>51 #include <str.h> 52 52 #include <unistd.h> 53 53 #include <vfs/vfs.h> 54 54 #include <async.h> 55 #include <bool.h> 56 #include <io/console.h> 57 #include <io/style.h> 55 58 #include "screen.h" 56 59 #include "tetris.h" 57 #include <io/console.h>58 60 59 61 #define STOP (B_COLS - 3) … … 63 65 static int isset; /* true => terminal is in game mode */ 64 66 65 static int use_color;/* true => use colors */67 static bool use_color; /* true => use colors */ 66 68 67 69 static const struct shape *lastshape; … … 72 74 * simply literal strings); 73 75 */ 74 static inline void putstr(c har *s)76 static inline void putstr(const char *s) 75 77 { 76 78 while (*s) … … 81 83 { 82 84 fflush(stdout); 83 console_set_rgb_color(fphone(stdout), 0xf 0f0f0,85 console_set_rgb_color(fphone(stdout), 0xffffff, 84 86 use_color ? color : 0x000000); 85 87 } … … 88 90 { 89 91 fflush(stdout); 90 console_set_ rgb_color(fphone(stdout), 0, 0xf0f0f0);92 console_set_style(fphone(stdout), STYLE_NORMAL); 91 93 } 92 94 … … 118 120 } 119 121 120 void moveto(i nt r, int c)122 void moveto(ipcarg_t r, ipcarg_t c) 121 123 { 122 124 fflush(stdout); 123 console_ goto(fphone(stdout), c, r);125 console_set_pos(fphone(stdout), c, r); 124 126 } 125 127 … … 131 133 } 132 134 133 static int get_display_color_sup(void) 134 { 135 int rc; 136 int ccap; 137 138 rc = console_get_color_cap(fphone(stdout), &ccap); 135 static bool get_display_color_sup(void) 136 { 137 ipcarg_t ccap; 138 int rc = console_get_color_cap(fphone(stdout), &ccap); 139 139 140 if (rc != 0) 140 return 0;141 141 return false; 142 142 143 return (ccap >= CONSOLE_CCAP_RGB); 143 144 } … … 181 182 } 182 183 183 void stop(c har *why)184 void stop(const char *why) 184 185 { 185 186 if (isset) … … 308 309 * (We need its length in case we have to overwrite with blanks.) 309 310 */ 310 void scr_msg(char *s, intset)311 void scr_msg(char *s, bool set) 311 312 { 312 313 int l = str_size(s); -
uspace/app/tetris/screen.h
rcf8cc36 rc47e1a8 48 48 49 49 #include <sys/types.h> 50 #include <ipc/ipc.h> 50 51 #include <async.h> 52 #include <bool.h> 51 53 52 54 typedef struct { 53 i nt ws_row;54 i nt ws_col;55 ipcarg_t ws_row; 56 ipcarg_t ws_col; 55 57 } winsize_t; 56 58 57 59 extern winsize_t winsize; 58 60 59 extern void moveto(i nt r, int c);61 extern void moveto(ipcarg_t r, ipcarg_t c); 60 62 extern void clear_screen(void); 61 63 … … 65 67 extern void scr_end(void); 66 68 extern void scr_init(void); 67 extern void scr_msg(char *, int);69 extern void scr_msg(char *, bool); 68 70 extern void scr_set(void); 69 71 extern void scr_update(void); -
uspace/app/tetris/tetris.c
rcf8cc36 rc47e1a8 53 53 #include <stdio.h> 54 54 #include <stdlib.h> 55 #include <str ing.h>55 #include <str.h> 56 56 #include <unistd.h> 57 57 #include <getopt.h> -
uspace/app/tetris/tetris.h
rcf8cc36 rc47e1a8 186 186 extern int fits_in(const struct shape *, int); 187 187 extern void place(const struct shape *, int, int); 188 extern void stop(c har *);188 extern void stop(const char *); 189 189 190 190 /** @} -
uspace/app/top/top.h
rcf8cc36 rc47e1a8 1 1 /* 2 * Copyright (c) 2005 Martin Decky 2 * Copyright (c) 2010 Stanislav Kozina 3 * Copyright (c) 2010 Martin Decky 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 #ifndef BOOT_sparc64_MAIN_H_ 30 #define BOOT_sparc64_MAIN_H_ 30 /** @addtogroup top 31 * @{ 32 */ 31 33 32 #include <ofw.h> 33 #include <ofw_tree.h> 34 #include <balloc.h> 35 #include <types.h> 34 #ifndef TOP_TOP_H_ 35 #define TOP_TOP_H_ 36 36 37 #define KERNEL_VIRTUAL_ADDRESS 0x400000 37 #include <task.h> 38 #include <stats.h> 39 #include <time.h> 38 40 39 #define TASKMAP_MAX_RECORDS 32 41 #define FRACTION_TO_FLOAT(float, a, b) { \ 42 (float).upper = (a); \ 43 (float).lower = (b); \ 44 } 40 45 41 /** Size of buffer for storing task name in task_t. */ 42 #define BOOTINFO_TASK_NAME_BUFLEN 3246 #define OP_TASKS 1 47 #define OP_IPC 2 43 48 44 #define BSP_PROCESSOR 1 45 #define AP_PROCESSOR 0 46 47 #define SUBARCH_US 1 48 #define SUBARCH_US3 3 49 extern int operation_type; 49 50 50 51 typedef struct { 51 void *addr; 52 uint32_t size; 53 char name[BOOTINFO_TASK_NAME_BUFLEN]; 54 } task_t; 52 uint64_t upper; 53 uint64_t lower; 54 } fixed_float; 55 55 56 56 typedef struct { 57 uint32_t count;58 task_t tasks[TASKMAP_MAX_RECORDS];59 } taskmap_t;57 fixed_float idle; 58 fixed_float busy; 59 } perc_cpu_t; 60 60 61 61 typedef struct { 62 uintptr_t physmem_start; 63 taskmap_t taskmap; 64 memmap_t memmap; 65 ballocs_t ballocs; 66 ofw_tree_node_t *ofw_root; 67 } bootinfo_t; 62 fixed_float ucycles; 63 fixed_float kcycles; 64 fixed_float virtmem; 65 } perc_task_t; 68 66 69 extern uint32_t silo_ramdisk_image; 70 extern uint32_t silo_ramdisk_size; 71 72 extern void start(void); 73 extern void bootstrap(void); 67 typedef struct { 68 time_t hours; 69 time_t minutes; 70 time_t seconds; 71 72 sysarg_t udays; 73 sysarg_t uhours; 74 sysarg_t uminutes; 75 sysarg_t useconds; 76 77 size_t load_count; 78 load_t *load; 79 80 size_t cpus_count; 81 stats_cpu_t *cpus; 82 perc_cpu_t *cpus_perc; 83 84 size_t tasks_count; 85 stats_task_t *tasks; 86 perc_task_t *tasks_perc; 87 88 size_t threads_count; 89 stats_thread_t *threads; 90 91 stats_physmem_t *physmem; 92 } data_t; 74 93 75 94 #endif 95 96 /** 97 * @} 98 */ -
uspace/app/trace/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = trace 31 BINARY = trace 34 32 35 33 SOURCES = \ … … 41 39 errors.c 42 40 43 include ../Makefile.common41 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/trace/errors.h
rcf8cc36 rc47e1a8 37 37 38 38 typedef struct { 39 c har *name;/**< Error value name (Exx) */40 c har *desc;/**< Error description */39 const char *name; /**< Error value name (Exx) */ 40 const char *desc; /**< Error description */ 41 41 } err_desc_t; 42 42 -
uspace/app/trace/ipc_desc.h
rcf8cc36 rc47e1a8 38 38 typedef struct { 39 39 int number; 40 c har *name;40 const char *name; 41 41 } ipc_m_desc_t; 42 42 -
uspace/app/trace/proto.c
rcf8cc36 rc47e1a8 157 157 } 158 158 159 static void proto_struct_init(proto_t *proto, c har *name)159 static void proto_struct_init(proto_t *proto, const char *name) 160 160 { 161 161 proto->name = name; … … 164 164 } 165 165 166 proto_t *proto_new(c har *name)166 proto_t *proto_new(const char *name) 167 167 { 168 168 proto_t *p; … … 206 206 } 207 207 208 static void oper_struct_init(oper_t *oper, c har *name)208 static void oper_struct_init(oper_t *oper, const char *name) 209 209 { 210 210 oper->name = name; 211 211 } 212 212 213 oper_t *oper_new(c har *name, int argc, val_type_t *arg_types,213 oper_t *oper_new(const char *name, int argc, val_type_t *arg_types, 214 214 val_type_t rv_type, int respc, val_type_t *resp_types) 215 215 { -
uspace/app/trace/proto.h
rcf8cc36 rc47e1a8 43 43 44 44 typedef struct { 45 c har *name;45 const char *name; 46 46 47 47 int argc; … … 56 56 typedef struct { 57 57 /** Protocol name */ 58 c har *name;58 const char *name; 59 59 60 60 /** Maps method number to operation */ … … 70 70 void proto_register(int srv, proto_t *proto); 71 71 proto_t *proto_get_by_srv(int srv); 72 proto_t *proto_new(c har *name);72 proto_t *proto_new(const char *name); 73 73 void proto_delete(proto_t *proto); 74 74 void proto_add_oper(proto_t *proto, int method, oper_t *oper); 75 75 oper_t *proto_get_oper(proto_t *proto, int method); 76 76 77 oper_t *oper_new(c har *name, int argc, val_type_t *arg_types,77 oper_t *oper_new(const char *name, int argc, val_type_t *arg_types, 78 78 val_type_t rv_type, int respc, val_type_t *resp_types); 79 79 -
uspace/app/trace/syscalls.c
rcf8cc36 rc47e1a8 76 76 [SYS_INTERRUPT_ENABLE] = { "interrupt_enable", 2, V_ERRNO }, 77 77 78 [SYS_SYSINFO_VALID] = { "sysinfo_valid", 2, V_HASH }, 79 [SYS_SYSINFO_VALUE] = { "sysinfo_value", 2, V_HASH }, 78 [SYS_SYSINFO_GET_TAG] = { "sysinfo_get_tag", 2, V_INTEGER }, 79 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, 80 [SYS_SYSINFO_GET_DATA_SIZE] = { "sysinfo_get_data_size", 3, V_ERRNO }, 81 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 4, V_ERRNO }, 82 80 83 [SYS_DEBUG_ENABLE_CONSOLE] = { "debug_enable_console", 0, V_ERRNO }, 81 84 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } -
uspace/app/trace/syscalls.h
rcf8cc36 rc47e1a8 39 39 40 40 typedef struct { 41 c har *name;41 const char *name; 42 42 int n_args; 43 43 val_type_t rv_type; -
uspace/app/trace/trace.c
rcf8cc36 rc47e1a8 43 43 #include <task.h> 44 44 #include <mem.h> 45 #include <str ing.h>45 #include <str.h> 46 46 #include <bool.h> 47 47 #include <loader/loader.h> … … 585 585 } 586 586 587 static loader_t *preload_task(const char *path, char * const argv[],587 static loader_t *preload_task(const char *path, char **argv, 588 588 task_id_t *task_id) 589 589 { … … 591 591 int rc; 592 592 593 /* Spawn a program loader */ 593 /* Spawn a program loader */ 594 594 ldr = loader_connect(); 595 595 if (ldr == NULL) … … 607 607 608 608 /* Send arguments */ 609 rc = loader_set_args(ldr, argv);609 rc = loader_set_args(ldr, (const char **) argv); 610 610 if (rc != EOK) 611 611 goto error; … … 870 870 } 871 871 872 static display_mask_t parse_display_mask(c har *text)872 static display_mask_t parse_display_mask(const char *text) 873 873 { 874 874 display_mask_t dm; 875 char *c; 876 877 c = text; 878 875 const char *c = text; 876 879 877 while (*c) { 880 878 switch (*c) { 881 case 't': dm = dm | DM_THREAD; break; 882 case 's': dm = dm | DM_SYSCALL; break; 883 case 'i': dm = dm | DM_IPC; break; 884 case 'p': dm = dm | DM_SYSTEM | DM_USER; break; 879 case 't': 880 dm = dm | DM_THREAD; 881 break; 882 case 's': 883 dm = dm | DM_SYSCALL; 884 break; 885 case 'i': 886 dm = dm | DM_IPC; 887 break; 888 case 'p': 889 dm = dm | DM_SYSTEM | DM_USER; 890 break; 885 891 default: 886 892 printf("Unexpected event type '%c'.\n", *c); 887 893 exit(1); 888 894 } 889 895 890 896 ++c; 891 897 } 892 898 893 899 return dm; 894 900 } … … 896 902 static int parse_args(int argc, char *argv[]) 897 903 { 898 char *arg;899 904 char *err_p; 900 905 901 906 task_id = 0; 902 907 903 --argc; ++argv; 908 --argc; 909 ++argv; 904 910 905 911 while (argc > 0) { 906 arg = *argv;912 char *arg = *argv; 907 913 if (arg[0] == '+') { 908 914 display_mask = parse_display_mask(&arg[1]); … … 910 916 if (arg[1] == 't') { 911 917 /* Trace an already running task */ 912 --argc; ++argv; 918 --argc; 919 ++argv; 913 920 task_id = strtol(*argv, &err_p, 10); 914 921 task_ldr = NULL; … … 927 934 break; 928 935 } 929 930 --argc; ++argv; 936 937 --argc; 938 ++argv; 931 939 } 932 940 933 941 if (task_id != 0) { 934 if (argc == 0) return 0; 942 if (argc == 0) 943 return 0; 935 944 printf("Extra arguments\n"); 936 945 print_syntax(); … … 946 955 /* Preload the specified program file. */ 947 956 printf("Spawning '%s' with arguments:\n", *argv); 948 { 949 char **cp = argv; 950 while (*cp) printf("'%s'\n", *cp++); 951 } 957 958 char **cp = argv; 959 while (*cp) 960 printf("'%s'\n", *cp++); 961 952 962 task_ldr = preload_task(*argv, argv, &task_id); 953 963 task_wait_for = true;
Note:
See TracChangeset
for help on using the changeset viewer.
