Changeset 04803bf in mainline for uspace/app
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (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:
-
- 149 added
- 3 deleted
- 79 edited
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/Makefile
rb50b5af2 r04803bf 1 # Copyright (c) 2005, Martin Decky2 # All rights reserved.3 # Copyright (c) 200 8, Tim Post <tinkertim@gmail.com>1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 4 4 # All rights reserved. 5 5 # 6 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions are met: 7 # modification, are permitted provided that the following conditions 8 # are met: 8 9 # 9 # Redistributions of source code must retain the above copyright notice, this 10 # list of conditions and the following disclaimer. 10 # - Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # - Redistributions in binary form must reproduce the above copyright 13 # notice, this list of conditions and the following disclaimer in the 14 # documentation and/or other materials provided with the distribution. 15 # - The name of the author may not be used to endorse or promote products 16 # derived from this software without specific prior written permission. 11 17 # 12 # Redistributions in binary form must reproduce the above copyright notice, 13 # this list of conditions and the following disclaimer in the documentation 14 # and/or other materials provided with the distribution. 18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 28 # 16 # Neither the name of the original program's authors nor the names of its17 # contributors may be used to endorse or promote products derived from this18 # software without specific prior written permission.19 #20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE24 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE30 # POSSIBILITY OF SUCH DAMAGE.31 29 32 include ../../../version 33 34 LIBC_PREFIX = ../../lib/libc 35 SOFTINT_PREFIX = ../../lib/softint 36 LIBBLOCK_PREFIX = ../../lib/libblock 37 38 include $(LIBC_PREFIX)/Makefile.toolchain 39 include $(LIBC_PREFIX)/Makefile.app 40 41 CFLAGS += -I../../srv/kbd/include -I$(LIBBLOCK_PREFIX) 42 43 LIBS += $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a 44 DEFS += -DRELEASE=$(RELEASE) 45 46 PROGRAM = bdsh 47 48 # Any directory that cleaning targets should know about 49 SUBDIRS = \ 50 ./ \ 51 cmds/ \ 52 cmds/modules/ \ 53 cmds/modules/help/ \ 54 cmds/modules/mkdir/ \ 55 cmds/modules/rm/ \ 56 cmds/modules/bdd/ \ 57 cmds/modules/cat/ \ 58 cmds/modules/touch/ \ 59 cmds/modules/ls/ \ 60 cmds/modules/pwd/ \ 61 cmds/modules/sleep/ \ 62 cmds/modules/cp/ \ 63 cmds/modules/mv/ \ 64 cmds/modules/mount/ \ 65 cmds/modules/kcon/ \ 66 cmds/builtins/ \ 67 cmds/builtins/exit/\ 68 cmds/builtins/cd/ 30 USPACE_PREFIX = ../.. 31 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 69 35 70 36 SOURCES = \ 71 37 cmds/modules/help/help.c \ 72 38 cmds/modules/mkdir/mkdir.c \ 39 cmds/modules/mkfile/mkfile.c \ 73 40 cmds/modules/rm/rm.c \ 74 41 cmds/modules/bdd/bdd.c \ … … 81 48 cmds/modules/mv/mv.c \ 82 49 cmds/modules/mount/mount.c \ 50 cmds/modules/unmount/unmount.c \ 83 51 cmds/modules/kcon/kcon.c \ 84 52 cmds/builtins/exit/exit.c \ … … 92 60 scli.c 93 61 94 CFLAGS += -I. -Icmds/ -Icmds/builtins -Icmds/modules 95 96 OBJECTS = $(SOURCES:.c=.o) 97 98 # For easy cleaning, *.o is already handled 99 CLEANDIRS := $(addsuffix *~,$(SUBDIRS)) 100 CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS)) 101 CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS)) 102 CLEANDIRS += $(addsuffix *.out,$(SUBDIRS)) 103 CLEANDIRS += $(addsuffix *.d,$(SUBDIRS)) 104 CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS) ) 105 106 %.o: %.S 107 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 108 109 %.o: %.s 110 $(AS) $(AFLAGS) $< -o $@ 111 112 %.o: %.c 113 $(CC) $(CFLAGS) $(INC) -c $< -o $@ 114 @$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d 115 116 $(PROGRAM): $(OBJECTS) $(LIBS) 117 $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map 118 119 # Everything else is a phony target 120 .PHONY: all clean distclean depend disasm 121 122 all: $(PROGRAM) disasm 123 124 clean: 125 @-rm -f $(OBJECTS) 126 @-rm -f $(PROGRAM) 127 @-rm -f $(PROGRAM).map 128 @-rm -f $(PROGRAM).disasm 129 @-rm -f $(CLEANDIRS) 130 131 depend: 132 @echo '' 133 134 disasm: 135 $(OBJDUMP) -d $(PROGRAM) >$(PROGRAM).disasm 136 137 distclean: clean 138 139 # Do not delete - dependencies 140 -include $(OBJECTS:.o=.d) 62 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/bdsh/cmds/builtin_cmds.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 10 10 #include "cd/cd_def.h" 11 11 #include "exit/exit_def.h" 12 {NULL, NULL, NULL, NULL }12 {NULL, NULL, NULL, NULL, 0} 13 13 }; 14 14 -
uspace/app/bdsh/cmds/builtins/cd/cd.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 4 4 &cmd_cd, 5 5 &help_cmd_cd, 6 0 6 7 }, -
uspace/app/bdsh/cmds/builtins/exit/exit_def.h
rb50b5af2 r04803bf 4 4 &cmd_exit, 5 5 &help_cmd_exit, 6 0 6 7 }, -
uspace/app/bdsh/cmds/cmds.h
rb50b5af2 r04803bf 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 * 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 * 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 29 29 #include <stdio.h> 30 30 #include <stdlib.h> 31 #include <string.h> 31 #include <str.h> 32 #include <sys/typefmt.h> 32 33 #include "config.h" 33 34 #include "util.h" … … 40 41 #include <devmap.h> 41 42 #include <errno.h> 43 #include <assert.h> 42 44 43 #define BLOCK_SIZE 512 44 #define BPR 16 45 enum { 46 /* Number of bytes per row */ 47 BPR = 16 48 }; 45 49 46 50 static const char *cmdname = "bdd"; … … 65 69 unsigned int argc; 66 70 unsigned int i, j; 67 dev _handle_t handle;68 block_t *block;71 devmap_handle_t handle; 72 aoff64_t offset; 69 73 uint8_t *blk; 70 74 size_t size, bytes, rows; 75 size_t block_size; 71 76 int rc; 72 bn_t boff;77 aoff64_t ba; 73 78 uint8_t b; 74 79 … … 82 87 83 88 if (argc >= 3) 84 b off= strtol(argv[2], NULL, 0);89 ba = strtol(argv[2], NULL, 0); 85 90 else 86 b off= 0;91 ba = 0; 87 92 88 93 if (argc >= 4) … … 93 98 rc = devmap_device_get_handle(argv[1], &handle, 0); 94 99 if (rc != EOK) { 95 printf(" Error: could not resolve device `%s'.\n", argv[1]);100 printf("%s: Error resolving device `%s'.\n", cmdname, argv[1]); 96 101 return CMD_FAILURE; 97 102 } 98 103 99 rc = block_init(handle, BLOCK_SIZE);104 rc = block_init(handle, 2048); 100 105 if (rc != EOK) { 101 printf(" Error: could not init libblock.\n");106 printf("%s: Error initializing libblock.\n", cmdname); 102 107 return CMD_FAILURE; 103 108 } 104 109 105 rc = block_ cache_init(handle, BLOCK_SIZE, 2, CACHE_MODE_WB);110 rc = block_get_bsize(handle, &block_size); 106 111 if (rc != EOK) { 107 printf(" Error: could not init block cache.\n");112 printf("%s: Error determining device block size.\n", cmdname); 108 113 return CMD_FAILURE; 109 114 } 110 115 116 blk = malloc(block_size); 117 if (blk == NULL) { 118 printf("%s: Error allocating memory.\n", cmdname); 119 block_fini(handle); 120 return CMD_FAILURE; 121 } 122 123 offset = ba * block_size; 124 111 125 while (size > 0) { 112 block = block_get(handle, boff, 0); 113 blk = (uint8_t *) block->data; 126 rc = block_read_direct(handle, ba, 1, blk); 127 if (rc != EOK) { 128 printf("%s: Error reading block %" PRIuOFF64 "\n", cmdname, ba); 129 free(blk); 130 block_fini(handle); 131 return CMD_FAILURE; 132 } 114 133 115 bytes = (size < BLOCK_SIZE) ? size : BLOCK_SIZE;134 bytes = (size < block_size) ? size : block_size; 116 135 rows = (bytes + BPR - 1) / BPR; 117 136 118 137 for (j = 0; j < rows; j++) { 138 printf("[%06" PRIxOFF64 "] ", offset); 119 139 for (i = 0; i < BPR; i++) { 120 140 if (j * BPR + i < bytes) … … 136 156 } 137 157 } 158 offset += BPR; 138 159 putchar('\n'); 139 160 } 140 141 block_put(block);142 161 143 162 if (size > rows * BPR) … … 146 165 size = 0; 147 166 148 boff += rows * BPR; 167 /* Next block */ 168 ba += 1; 149 169 } 150 170 171 free(blk); 151 172 block_fini(handle); 152 173 -
uspace/app/bdsh/cmds/modules/cat/cat.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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; … … 95 95 96 96 if (vb) 97 printf("% dbytes to copy\n", total);97 printf("%" PRIu64 " bytes to copy\n", total); 98 98 99 99 lseek(fd1, 0, SEEK_SET); … … 130 130 */ 131 131 if (res != 0) { 132 printf("\n% d more bytes than actually exist were copied\n", res);132 printf("\n%zd more bytes than actually exist were copied\n", res); 133 133 goto err; 134 134 } … … 187 187 return CMD_SUCCESS; 188 188 case 'v': 189 printf("% d\n", CP_VERSION);189 printf("%s\n", CP_VERSION); 190 190 return CMD_SUCCESS; 191 191 case 'V': … … 223 223 224 224 if (verbose) 225 printf("% dbytes copied\n", ret);225 printf("%" PRId64 " bytes copied\n", ret); 226 226 227 227 if (ret >= 0) -
uspace/app/bdsh/cmds/modules/help/help.c
rb50b5af2 r04803bf 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 47 #define HELP_IS_MODULE 1 48 #define HELP_IS_BUILTIN 0 49 #define HELP_IS_RUBBISH -1 47 #define HELP_IS_COMMANDS 2 48 #define HELP_IS_MODULE 1 49 #define HELP_IS_BUILTIN 0 50 #define HELP_IS_RUBBISH -1 50 51 51 52 volatile int mod_switch = -1; … … 55 56 { 56 57 int rc = HELP_IS_RUBBISH; 58 59 if (str_cmp(cmd, "commands") == 0) 60 return HELP_IS_COMMANDS; 57 61 58 62 rc = is_builtin(cmd); … … 90 94 } 91 95 92 int cmd_help(char *argv[])96 static void help_commands(void) 93 97 { 98 builtin_t *cmd; 94 99 module_t *mod; 95 builtin_t *cmd; 96 unsigned int i = 0; 97 int rc = 0; 98 int argc; 99 int level = HELP_SHORT; 100 unsigned int i; 100 101 101 argc = cli_count_args(argv); 102 103 if (argc > 3) { 104 printf("\nToo many arguments to `%s', try:\n", cmdname); 105 help_cmd_help(HELP_SHORT); 106 return CMD_FAILURE; 107 } 108 109 if (argc == 3) { 110 if (!str_cmp("extended", argv[2])) 111 level = HELP_LONG; 112 else 113 level = HELP_SHORT; 114 } 115 116 if (argc > 1) { 117 rc = is_mod_or_builtin(argv[1]); 118 switch (rc) { 119 case HELP_IS_RUBBISH: 120 printf("Invalid command %s\n", argv[1]); 121 return CMD_FAILURE; 122 case HELP_IS_MODULE: 123 help_module(mod_switch, level); 124 return CMD_SUCCESS; 125 case HELP_IS_BUILTIN: 126 help_builtin(mod_switch, level); 127 return CMD_SUCCESS; 128 } 129 } 130 131 printf("\n Available commands are:\n"); 102 printf("\n Bdsh built-in commands:\n"); 132 103 printf(" ------------------------------------------------------------\n"); 133 104 … … 154 125 printf("\n Try %s %s for more information on how `%s' works.\n\n", 155 126 cmdname, cmdname, cmdname); 127 } 128 129 /** Display survival tips. ('help' without arguments) */ 130 static void help_survival(void) 131 { 132 printf("Don't panic!\n\n"); 133 134 printf("This is Bdsh, the Brain dead shell, currently " 135 "the primary user interface to HelenOS. Bdsh allows you to enter " 136 "commands and supports history (Up, Down arrow keys), " 137 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 138 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 139 "Ctrl-V), similar to common desktop environments.\n\n"); 140 141 printf("The most basic filesystem commands are Bdsh builtins. Type " 142 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 143 "Other commands are external executables located in the /app and " 144 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 145 "to see their list. You can execute an external command simply " 146 "by entering its name (e.g. type 'tetris' [Enter]).\n\n"); 147 148 printf("HelenOS has virtual consoles (VCs). You can switch between " 149 "these using the F1-F11 keys.\n\n"); 150 151 printf("This is but a small glimpse of what you can do with HelenOS. " 152 "To learn more please point your browser to the HelenOS User's " 153 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 154 } 155 156 int cmd_help(char *argv[]) 157 { 158 int rc = 0; 159 int argc; 160 int level = HELP_SHORT; 161 162 argc = cli_count_args(argv); 163 164 if (argc > 3) { 165 printf("\nToo many arguments to `%s', try:\n", cmdname); 166 help_cmd_help(HELP_SHORT); 167 return CMD_FAILURE; 168 } 169 170 if (argc == 3) { 171 if (!str_cmp("extended", argv[2])) 172 level = HELP_LONG; 173 else 174 level = HELP_SHORT; 175 } 176 177 if (argc > 1) { 178 rc = is_mod_or_builtin(argv[1]); 179 switch (rc) { 180 case HELP_IS_RUBBISH: 181 printf("Invalid topic %s\n", argv[1]); 182 return CMD_FAILURE; 183 case HELP_IS_COMMANDS: 184 help_commands(); 185 return CMD_SUCCESS; 186 case HELP_IS_MODULE: 187 help_module(mod_switch, level); 188 return CMD_SUCCESS; 189 case HELP_IS_BUILTIN: 190 help_builtin(mod_switch, level); 191 return CMD_SUCCESS; 192 } 193 } 194 195 help_survival(); 156 196 157 197 return CMD_SUCCESS; -
uspace/app/bdsh/cmds/modules/kcon/kcon.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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) … … 100 100 if (s.is_file) 101 101 printf("%-40s\t%llu\n", name, (long long) s.size); 102 else if (s.is_directory) 103 printf("%-40s\t<dir>\n", name); 102 104 else 103 105 printf("%-40s\n", name); -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
rb50b5af2 r04803bf 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/module_aliases.h
rb50b5af2 r04803bf 12 12 * the entry point being reached. */ 13 13 14 c har *mod_aliases[] = {14 const char *mod_aliases[] = { 15 15 "ren", "mv", 16 "umount", "unmount", 16 17 NULL, NULL 17 18 }; -
uspace/app/bdsh/cmds/modules/modules.h
rb50b5af2 r04803bf 20 20 #include "help/entry.h" 21 21 #include "mkdir/entry.h" 22 #include "mkfile/entry.h" 22 23 #include "rm/entry.h" 23 24 #include "bdd/entry.h" … … 30 31 #include "mv/entry.h" 31 32 #include "mount/entry.h" 33 #include "unmount/entry.h" 32 34 #include "kcon/entry.h" 33 35 … … 39 41 #include "help/help_def.h" 40 42 #include "mkdir/mkdir_def.h" 43 #include "mkfile/mkfile_def.h" 41 44 #include "rm/rm_def.h" 42 45 #include "bdd/bdd_def.h" … … 49 52 #include "mv/mv_def.h" 50 53 #include "mount/mount_def.h" 54 #include "unmount/unmount_def.h" 51 55 #include "kcon/kcon_def.h" 52 56 -
uspace/app/bdsh/cmds/modules/mount/mount.c
rb50b5af2 r04803bf 31 31 #include <vfs/vfs.h> 32 32 #include <errno.h> 33 #include <getopt.h> 33 34 #include "config.h" 34 35 #include "util.h" … … 40 41 static const char *cmdname = "mount"; 41 42 42 /* Dispays help for mount in various levels */ 43 static struct option const long_options[] = { 44 { "help", no_argument, 0, 'h' }, 45 { 0, 0, 0, 0 } 46 }; 47 48 49 /* Displays help for mount in various levels */ 43 50 void help_cmd_mount(unsigned int level) 44 51 { … … 58 65 { 59 66 unsigned int argc; 60 c har *mopts = "";61 int rc ;67 const char *mopts = ""; 68 int rc, c, opt_ind; 62 69 63 70 argc = cli_count_args(argv); 64 71 72 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 73 c = getopt_long(argc, argv, "h", long_options, &opt_ind); 74 switch (c) { 75 case 'h': 76 help_cmd_mount(HELP_LONG); 77 return CMD_SUCCESS; 78 } 79 } 80 65 81 if ((argc < 4) || (argc > 5)) { 66 printf("%s: invalid number of arguments. \n",82 printf("%s: invalid number of arguments. Try `mount --help'\n", 67 83 cmdname); 68 84 return CMD_FAILURE; -
uspace/app/bdsh/cmds/modules/pwd/pwd.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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> 43 #include <errno.h> 42 44 43 45 #include "config.h" … … 115 117 task_exit_t texit; 116 118 char *tmp; 117 int r etval;119 int rc, retval; 118 120 119 121 tmp = str_dup(find_command(cmd)); 120 122 free(found); 121 123 122 tid = task_spawn((const char *)tmp,argv);124 rc = task_spawnv(&tid, tmp, (const char **) argv); 123 125 free(tmp); 124 126 125 if (tid == 0) { 126 cli_error(CL_EEXEC, "Cannot spawn `%s'.", cmd); 127 if (rc != 0) { 128 cli_error(CL_EEXEC, "%s: Cannot spawn `%s' (%s)", progname, cmd, 129 str_error(rc)); 127 130 return 1; 128 131 } 129 132 130 task_wait(tid, &texit, &retval); 131 if (texit != TASK_EXIT_NORMAL) { 132 printf("Command failed (unexpectedly terminated).\n"); 133 rc = task_wait(tid, &texit, &retval); 134 if (rc != EOK) { 135 printf("%s: Failed waiting for command (%s)\n", progname, 136 str_error(rc)); 137 } else if (texit != TASK_EXIT_NORMAL) { 138 printf("%s: Command failed (unexpectedly terminated)\n", progname); 133 139 } else if (retval != 0) { 134 printf("Command failed (return value %d).\n", retval); 140 printf("%s: Command failed (exit code %d)\n", 141 progname, retval); 135 142 } 136 143 -
uspace/app/bdsh/exec.h
rb50b5af2 r04803bf 5 5 6 6 extern unsigned int try_exec(char *, char **); 7 7 8 #endif -
uspace/app/bdsh/input.c
rb50b5af2 r04803bf 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> 37 36 #include <io/style.h> 37 #include <io/color.h> 38 38 #include <vfs/vfs.h> 39 #include <clipboard.h> 40 #include <macros.h> 39 41 #include <errno.h> 42 #include <assert.h> 40 43 #include <bool.h> 44 #include <tinput.h> 41 45 42 46 #include "config.h" … … 47 51 #include "exec.h" 48 52 49 static void read_line(char *, int); 53 extern volatile unsigned int cli_quit; 54 55 /** Text input field. */ 56 static tinput_t *tinput; 50 57 51 58 /* Tokenizes input from console, sees if the first word is a built-in, if so … … 99 106 } 100 107 101 static void read_line(char *buffer, int n)102 {103 console_event_t ev;104 size_t offs, otmp;105 wchar_t dec;106 107 offs = 0;108 while (true) {109 fflush(stdout);110 if (!console_get_event(fphone(stdin), &ev))111 return;112 113 if (ev.type != KEY_PRESS)114 continue;115 116 if (ev.key == KC_ENTER || ev.key == KC_NENTER)117 break;118 if (ev.key == KC_BACKSPACE) {119 if (offs > 0) {120 /*121 * Back up until we reach valid start of122 * character.123 */124 while (offs > 0) {125 --offs; otmp = offs;126 dec = str_decode(buffer, &otmp, n);127 if (dec != U_SPECIAL)128 break;129 }130 putchar('\b');131 }132 continue;133 }134 if (ev.c >= ' ') {135 if (chr_encode(ev.c, buffer, &offs, n - 1) == EOK)136 putchar(ev.c);137 }138 }139 putchar('\n');140 buffer[offs] = '\0';141 }142 143 /* TODO:144 * Implement something like editline() / readline(), if even145 * just for command history and making arrows work. */146 108 void get_input(cliuser_t *usr) 147 109 { 148 char line[INPUT_MAX]; 110 char *str; 111 int rc; 149 112 150 113 fflush(stdout); … … 154 117 console_set_style(fphone(stdout), STYLE_NORMAL); 155 118 156 read_line(line, INPUT_MAX); 157 /* Make sure we don't have rubbish or a C/R happy user */ 158 if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0) 119 rc = tinput_read(tinput, &str); 120 if (rc == ENOENT) { 121 /* User requested exit */ 122 cli_quit = 1; 123 putchar('\n'); 159 124 return; 160 usr->line = str_dup(line);125 } 161 126 127 if (rc != EOK) { 128 /* Error in communication with console */ 129 return; 130 } 131 132 /* Check for empty input. */ 133 if (str_cmp(str, "") == 0) { 134 free(str); 135 return; 136 } 137 138 usr->line = str; 162 139 return; 163 140 } 164 141 142 int input_init(void) 143 { 144 tinput = tinput_new(); 145 if (tinput == NULL) { 146 printf("Failed to initialize input.\n"); 147 return 1; 148 } 149 150 return 0; 151 } -
uspace/app/bdsh/input.h
rb50b5af2 r04803bf 8 8 extern void get_input(cliuser_t *); 9 9 extern int tok_input(cliuser_t *); 10 extern int input_init(void); 10 11 11 12 #endif -
uspace/app/bdsh/scli.c
rb50b5af2 r04803bf 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" … … 61 61 usr->line = (char *) NULL; 62 62 usr->name = "root"; 63 usr->home = "/";64 63 usr->cwd = (char *) NULL; 65 64 usr->prompt = (char *) NULL; 66 chdir(usr->home);67 65 usr->lasterr = 0; 66 67 if (input_init() != 0) 68 return 1; 69 68 70 return (int) cli_set_prompt(usr); 69 71 } … … 87 89 exit(EXIT_FAILURE); 88 90 89 printf("Welcome to %s - %s\nType `help' at any time for usage information.\n",90 progname, PACKAGE_STRING);91 92 91 while (!cli_quit) { 93 92 get_input(&usr); … … 98 97 } 99 98 } 100 goto finit;101 99 102 finit: 100 printf("Leaving %s.\n", progname); 101 103 102 cli_finit(&usr); 104 103 return ret; -
uspace/app/bdsh/scli.h
rb50b5af2 r04803bf 6 6 7 7 typedef struct { 8 char *name; 9 char *home; 8 const char *name; 10 9 char *line; 11 10 char *cwd; … … 14 13 } cliuser_t; 15 14 15 extern const char *progname; 16 16 17 #endif -
uspace/app/bdsh/util.c
rb50b5af2 r04803bf 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/dload/Makefile
rb50b5af2 r04803bf 1 1 # 2 # Copyright (c) 20 05 Martin Decky2 # Copyright (c) 2011 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 include ../../../version 29 USPACE_PREFIX = ../.. 30 LIBS = 31 EXTRA_CFLAGS = -I../../srv/loader/include -I../../lib/c/rtld/include -Iinclude 32 BINARY = dload 30 33 31 ## Setup toolchain 32 # 33 34 LIBC_PREFIX = ../../lib/libc 35 SOFTINT_PREFIX = ../../lib/softint 36 37 include $(LIBC_PREFIX)/Makefile.toolchain 34 include $(USPACE_PREFIX)/../Makefile.config 38 35 include arch/$(UARCH)/Makefile.inc 39 36 40 CFLAGS += -Iinclude -I../../srv/loader/include -I../../lib/libc/rtld/include -O0 -ggdb 41 LFLAGS += 37 SOURCES = \ 38 dload.c \ 39 $(ARCH_SOURCES) 42 40 43 LIBS = $(LIBC_PREFIX)/libc.a $(SOFTINT_PREFIX)/libsoftint.a 44 DEFS += -DRELEASE=\"$(RELEASE)\" 45 46 ## Sources 47 # 48 49 OUTPUT = dload 50 GENERIC_SOURCES = \ 51 dload.c 52 53 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) 54 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) 55 56 .PHONY: all clean depend disasm sections inc 57 58 all: inc $(OUTPUT) disasm sections 59 60 inc: 61 ln -sfn ../arch/$(UARCH)/include include/arch 62 63 -include Makefile.depend 64 65 clean: 66 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm $(OUTPUT).sections Makefile.depend *.o arch/$(UARCH)/_link.ld include/arch 67 find arch/$(UARCH)/ -name '*.o' -follow -exec rm \{\} \; 68 69 depend: 70 $(CC) $(DEFS) $(CFLAGS) -M $(ARCH_SOURCES) $(GENERIC_SOURCES)> Makefile.depend 71 72 $(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(LIBS) arch/$(UARCH)/_link.ld 73 $(LD) -T arch/$(UARCH)/_link.ld $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 74 75 disasm: 76 $(OBJDUMP) -d -S -s $(OUTPUT) >$(OUTPUT).disasm 77 78 sections: 79 $(OBJDUMP) -h $(OUTPUT) >$(OUTPUT).sections 80 81 arch/$(UARCH)/_link.ld: arch/$(UARCH)/_link.ld.in 82 $(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@ 83 84 %.o: %.S 85 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 86 87 %.o: %.s 88 $(AS) $(AFLAGS) $< -o $@ 89 90 %.o: %.c 91 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 41 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/dload/arch/ia32/start.c
rb50b5af2 r04803bf 36 36 37 37 #include <loader/pcb.h> 38 #include "start.h" 38 39 39 40 void program_run(void *entry, pcb_t *pcb) -
uspace/app/dload/dload.c
rb50b5af2 r04803bf 48 48 #include <module.h> 49 49 50 void program_run(void *entry, pcb_t *pcb); 50 #include "start.h" 51 51 52 52 runtime_env_t dload_re; -
uspace/app/dltest/Makefile
rb50b5af2 r04803bf 1 1 # 2 # Copyright (c) 20 05 Martin Decky2 # Copyright (c) 2011 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 include ../../../version 29 USPACE_PREFIX = ../.. 30 BINARY = dltest 30 31 31 ## Setup toolchain32 #33 34 LIBC_PREFIX = ../../lib/libc35 SOFTINT_PREFIX = ../../lib/softint36 37 include $(LIBC_PREFIX)/Makefile.toolchain38 39 CFLAGS += -I../../lib/libc -O040 LFLAGS := -Bdynamic -I/lib/rtld -rpath-link $(LIBC_PREFIX)/shared41 42 LIBS = $(LIBC_PREFIX)/shared/libc.so.043 44 ## Sources45 #46 47 OUTPUT = dltest48 32 SOURCES = \ 49 33 dltest.c 50 34 51 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 52 53 .PHONY: all clean depend disasm 54 55 all: $(OUTPUT) disasm 56 57 -include Makefile.depend 58 59 clean: 60 -rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend arch/$(UARCH)/_link.ld 61 62 depend: 63 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 64 65 $(OUTPUT): $(OBJECTS) $(LIBS) 66 $(LD) -T $(LIBC_PREFIX)/shared/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 67 68 disasm: 69 $(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm 70 71 %.o: %.S 72 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 73 74 %.o: %.s 75 $(AS) $(AFLAGS) $< -o $@ 76 77 %.o: %.c 78 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/dltest/dltest.c
rb50b5af2 r04803bf 70 70 int i; 71 71 72 c har *lib_name;73 c har *sym_name;72 const char *lib_name; 73 const char *sym_name; 74 74 75 //kputint(-1);75 if (0) kputint(-1); 76 76 printf("Hello from dltest!\n"); 77 77 … … 85 85 } else { 86 86 printf("failed to dlopen() library '%s'\n", lib_name); 87 return -1; 87 88 } 88 89 -
uspace/app/dltest2/Makefile
rb50b5af2 r04803bf 1 1 # 2 # Copyright (c) 20 05 Martin Decky2 # Copyright (c) 2011 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 include ../../../version 29 USPACE_PREFIX = ../.. 30 BINARY = dltest2 30 31 31 ## Setup toolchain32 #33 34 LIBC_PREFIX = ../../lib/libc35 SOFTINT_PREFIX = ../../lib/softint36 37 include $(LIBC_PREFIX)/Makefile.toolchain38 39 CFLAGS += -D__32_BITS__ -I../../srv/loader/include -I../../lib/rtld/include -I../../lib/libc -O040 LIBS = $(LIBC_PREFIX)/libc.a $(SOFTINT_PREFIX)/libsoftint.a41 42 ## Sources43 #44 45 OUTPUT = dltest246 32 SOURCES = \ 47 33 dltest2.c 48 34 49 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 50 51 .PHONY: all clean depend disasm 52 53 all: $(OUTPUT) disasm 54 55 -include Makefile.depend 56 57 clean: 58 -rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend arch/$(UARCH)/_link.ld 59 60 depend: 61 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 62 63 $(OUTPUT): $(OBJECTS) $(LIBS) 64 $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LFLAGS) $(LIBS) -o $@ -Map $(OUTPUT).map 65 66 disasm: 67 $(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm 68 69 %.o: %.S 70 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 71 72 %.o: %.s 73 $(AS) $(AFLAGS) $< -o $@ 74 75 %.o: %.c 76 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/dltest2/dltest2.c
rb50b5af2 r04803bf 70 70 int i; 71 71 72 c har *lib_name;73 c har *sym_name;72 const char *lib_name; 73 const char *sym_name; 74 74 75 //kputint(-1);75 if (0) kputint(-1); 76 76 printf("Hello from dltest!\n"); 77 77 … … 85 85 } else { 86 86 printf("failed to dlopen() library '%s'\n", lib_name); 87 return -1; 87 88 } 88 89 -
uspace/app/edit/Makefile
rb50b5af2 r04803bf 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 29 #include <arch/asm/macro.h> 30 USPACE_PREFIX = ../.. 31 BINARY = edit 30 32 31 .text 32 .global panic_printf 33 SOURCES = \ 34 edit.c \ 35 sheet.c 33 36 34 panic_printf: 35 lis %r14, halt@ha 36 addi %r14, %r14, halt@l 37 mtlr %r14 # fake stack to make printf return to halt 38 b printf 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/getterm/getterm.c
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup get vc GetVC29 /** @addtogroup getterm GetTerm 30 30 * @brief Console initialization task. 31 31 * @{ … … 36 36 37 37 #include <sys/types.h> 38 #include <fcntl.h> 38 39 #include <unistd.h> 39 40 #include <stdio.h> 40 41 #include <task.h> 42 #include <str_error.h> 43 #include <errno.h> 41 44 #include "version.h" 45 #include "welcome.h" 46 47 #define APP_NAME "getterm" 42 48 43 49 static void usage(void) 44 50 { 45 printf("Usage: getvc <device> <path>\n");51 printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME); 46 52 } 47 53 48 static void closeall(void)54 static void reopen(FILE **stream, int fd, const char *path, int flags, const char *mode) 49 55 { 50 fclose(stdin); 51 fclose(stdout); 52 fclose(stderr); 56 if (fclose(*stream)) 57 return; 53 58 54 close(0); 55 close(1); 56 close(2); 57 } 58 59 static task_id_t spawn(char *fname) 60 { 61 char *argv[2]; 59 *stream = NULL; 62 60 63 argv[0] = fname; 64 argv[1] = NULL; 61 int oldfd = open(path, flags); 62 if (oldfd < 0) 63 return; 65 64 66 task_id_t id = task_spawn(fname, argv); 65 if (oldfd != fd) { 66 if (dup2(oldfd, fd) != fd) 67 return; 68 69 if (close(oldfd)) 70 return; 71 } 67 72 68 if (id == 0) 69 printf("Error spawning %s\n", fname); 70 71 return id; 73 *stream = fdopen(fd, mode); 72 74 } 73 75 74 76 int main(int argc, char *argv[]) 75 77 { 78 int rc; 76 79 task_exit_t texit; 77 80 int retval; 81 task_id_t id; 82 char *fname, *term; 83 char **cmd_args; 84 bool print_wmsg; 78 85 79 if (argc < 3) { 86 argv++; 87 argc--; 88 if (argc < 1) { 80 89 usage(); 81 90 return -1; 82 91 } 92 93 if (str_cmp(*argv, "-w") == 0) { 94 print_wmsg = true; 95 argv++; 96 argc--; 97 } else { 98 print_wmsg = false; 99 } 100 101 if (argc < 2) { 102 usage(); 103 return -1; 104 } 105 106 term = *argv++; 107 fname = *argv; 108 cmd_args = argv; 83 109 84 closeall(); 110 reopen(&stdin, 0, term, O_RDONLY, "r"); 111 reopen(&stdout, 1, term, O_WRONLY, "w"); 112 reopen(&stderr, 2, term, O_WRONLY, "w"); 85 113 86 stdin = fopen(argv[1], "r");87 stdout = fopen(argv[1], "w");88 stderr = fopen(argv[1], "w");89 90 114 /* 91 * FIXME: f open() should actually detect that we are opening a console115 * FIXME: fdopen() should actually detect that we are opening a console 92 116 * and it should set line-buffering mode automatically. 93 117 */ 94 118 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); 95 119 96 if ((stdin == NULL) 97 || (stdout == NULL) 98 || (stderr == NULL)) 120 if (stdin == NULL) 99 121 return -2; 100 122 101 version_print(argv[1]); 102 task_id_t id = spawn(argv[2]); 103 task_wait(id, &texit, &retval); 123 if (stdout == NULL) 124 return -3; 104 125 126 if (stderr == NULL) 127 return -4; 128 129 version_print(term); 130 if (print_wmsg) 131 welcome_msg_print(); 132 133 rc = task_spawnv(&id, fname, (const char * const *) cmd_args); 134 if (rc != EOK) { 135 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname, 136 str_error(rc)); 137 return -5; 138 } 139 140 rc = task_wait(id, &texit, &retval); 141 if (rc != EOK) { 142 printf("%s: Error waiting for %s (%s)\n", APP_NAME, fname, 143 str_error(rc)); 144 return -6; 145 } 146 105 147 return 0; 106 148 } -
uspace/app/getterm/getterm.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 34 34 */ 35 35 36 #ifndef GET VC_H__37 #define GET VC_H__36 #ifndef GETTERM_H__ 37 #define GETTERM_H__ 38 38 39 39 #endif -
uspace/app/getterm/version.c
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 37 37 #include <stdio.h> 38 38 #include <macros.h> 39 #include "get vc.h"39 #include "getterm.h" 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 58 58 /** Print version information. */ 59 void version_print(const char * vc)59 void version_print(const char *term) 60 60 { 61 61 printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp); 62 printf("Running on %s (%s)\n", arch, vc);63 printf("Copyright (c) 2001-20 09HelenOS project\n\n");62 printf("Running on %s (%s)\n", arch, term); 63 printf("Copyright (c) 2001-2010 HelenOS project\n\n"); 64 64 } 65 65 -
uspace/app/getterm/version.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 37 37 #define VERSION_H__ 38 38 39 extern void version_print(const char * vc);39 extern void version_print(const char *term); 40 40 41 41 #endif -
uspace/app/init/Makefile
rb50b5af2 r04803bf 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 29 ## Setup toolchain 30 # 30 USPACE_PREFIX = ../.. 31 BINARY = init 31 32 32 LIBC_PREFIX = ../../lib/libc33 SOFTINT_PREFIX = ../../lib/softint34 35 include $(LIBC_PREFIX)/Makefile.toolchain36 37 CFLAGS += -I../../..38 LIBS = $(LIBC_PREFIX)/libc.a39 40 ## Sources41 #42 43 OUTPUT = init44 33 SOURCES = \ 45 34 init.c 46 35 47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 48 49 .PHONY: all clean depend disasm 50 51 all: $(OUTPUT) $(OUTPUT).disasm 52 53 -include Makefile.depend 54 55 clean: 56 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS) 57 58 depend: 59 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 60 61 $(OUTPUT): $(OBJECTS) $(LIBS) 62 $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 63 64 disasm: $(OUTPUT).disasm 65 66 $(OUTPUT).disasm: $(OUTPUT) 67 $(OBJDUMP) -d $< > $@ 68 69 %.o: %.S 70 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 71 72 %.o: %.s 73 $(AS) $(AFLAGS) $< -o $@ 74 75 %.o: %.c 76 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/init/init.c
rb50b5af2 r04803bf 37 37 #include <stdio.h> 38 38 #include <unistd.h> 39 #include <ipc/ipc.h>40 39 #include <vfs/vfs.h> 41 40 #include <bool.h> … … 46 45 #include <malloc.h> 47 46 #include <macros.h> 48 #include <str ing.h>47 #include <str.h> 49 48 #include <devmap.h> 50 #include < config.h>49 #include <str_error.h> 51 50 #include "init.h" 52 51 52 #define ROOT_DEVICE "bd/initrd" 53 #define ROOT_MOUNT_POINT "/" 54 55 #define DEVFS_FS_TYPE "devfs" 56 #define DEVFS_MOUNT_POINT "/dev" 57 58 #define TMPFS_FS_TYPE "tmpfs" 59 #define TMPFS_MOUNT_POINT "/tmp" 60 61 #define DATA_FS_TYPE "fat" 62 #define DATA_DEVICE "bd/ata1disk0" 63 #define DATA_MOUNT_POINT "/data" 64 65 #define SRV_CONSOLE "/srv/console" 66 #define APP_GETTERM "/app/getterm" 67 53 68 static void info_print(void) 54 69 { 55 printf(NAME ": HelenOS init\n"); 70 printf("%s: HelenOS init\n", NAME); 71 } 72 73 static bool mount_report(const char *desc, const char *mntpt, 74 const char *fstype, const char *dev, int rc) 75 { 76 switch (rc) { 77 case EOK: 78 if (dev != NULL) 79 printf("%s: %s mounted on %s (%s at %s)\n", NAME, desc, mntpt, 80 fstype, dev); 81 else 82 printf("%s: %s mounted on %s (%s)\n", NAME, desc, mntpt, fstype); 83 break; 84 case EBUSY: 85 printf("%s: %s already mounted on %s\n", NAME, desc, mntpt); 86 return false; 87 case ELIMIT: 88 printf("%s: %s limit exceeded\n", NAME, desc); 89 return false; 90 case ENOENT: 91 printf("%s: %s unknown type (%s)\n", NAME, desc, fstype); 92 return false; 93 default: 94 printf("%s: %s not mounted on %s (%s)\n", NAME, desc, mntpt, 95 str_error(rc)); 96 return false; 97 } 98 99 return true; 56 100 } 57 101 58 102 static bool mount_root(const char *fstype) 59 103 { 60 char *opts = ""; 61 const char *root_dev = "initrd"; 104 const char *opts = ""; 62 105 63 106 if (str_cmp(fstype, "tmpfs") == 0) 64 107 opts = "restore"; 65 108 66 int rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING); 67 68 switch (rc) { 69 case EOK: 70 printf(NAME ": Root filesystem mounted, %s at %s\n", 71 fstype, root_dev); 72 break; 73 case EBUSY: 74 printf(NAME ": Root filesystem already mounted\n"); 75 return false; 76 case ELIMIT: 77 printf(NAME ": Unable to mount root filesystem\n"); 78 return false; 79 case ENOENT: 80 printf(NAME ": Unknown filesystem type (%s)\n", fstype); 81 return false; 82 default: 83 printf(NAME ": Error mounting root filesystem (%d)\n", rc); 84 return false; 85 } 86 87 return true; 109 int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts, 110 IPC_FLAG_BLOCKING); 111 return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype, 112 ROOT_DEVICE, rc); 88 113 } 89 114 90 115 static bool mount_devfs(void) 91 116 { 92 char null[MAX_DEVICE_NAME]; 93 int null_id = devmap_null_create(); 94 95 if (null_id == -1) { 96 printf(NAME ": Unable to create null device\n"); 97 return false; 98 } 99 100 snprintf(null, MAX_DEVICE_NAME, "null%d", null_id); 101 int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING); 102 103 switch (rc) { 104 case EOK: 105 printf(NAME ": Device filesystem mounted\n"); 106 break; 107 case EBUSY: 108 printf(NAME ": Device filesystem already mounted\n"); 109 devmap_null_destroy(null_id); 110 return false; 111 case ELIMIT: 112 printf(NAME ": Unable to mount device filesystem\n"); 113 devmap_null_destroy(null_id); 114 return false; 115 case ENOENT: 116 printf(NAME ": Unknown filesystem type (devfs)\n"); 117 devmap_null_destroy(null_id); 118 return false; 119 default: 120 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 121 devmap_null_destroy(null_id); 122 return false; 123 } 124 125 return true; 126 } 127 128 static void spawn(char *fname) 129 { 130 char *argv[2]; 117 int rc = mount(DEVFS_FS_TYPE, DEVFS_MOUNT_POINT, "", "", 118 IPC_FLAG_BLOCKING); 119 return mount_report("Device filesystem", DEVFS_MOUNT_POINT, DEVFS_FS_TYPE, 120 NULL, rc); 121 } 122 123 static void spawn(const char *fname) 124 { 125 int rc; 131 126 struct stat s; 132 127 … … 134 129 return; 135 130 136 printf(NAME ": Spawning %s\n", fname); 137 138 argv[0] = fname; 139 argv[1] = NULL; 140 141 if (!task_spawn(fname, argv)) 142 printf(NAME ": Error spawning %s\n", fname); 143 } 144 145 static void srv_start(char *fname) 146 { 147 char *argv[2]; 131 printf("%s: Spawning %s\n", NAME, fname); 132 rc = task_spawnl(NULL, fname, fname, NULL); 133 if (rc != EOK) { 134 printf("%s: Error spawning %s (%s)\n", NAME, fname, 135 str_error(rc)); 136 } 137 } 138 139 static void srv_start(const char *fname) 140 { 148 141 task_id_t id; 149 142 task_exit_t texit; … … 154 147 return; 155 148 156 printf(NAME ": Starting %s\n", fname); 157 158 argv[0] = fname; 159 argv[1] = NULL; 160 161 id = task_spawn(fname, argv); 149 printf("%s: Starting %s\n", NAME, fname); 150 rc = task_spawnl(&id, fname, fname, NULL); 162 151 if (!id) { 163 printf(NAME ": Error spawning %s\n", fname); 164 return; 165 } 166 152 printf("%s: Error spawning %s (%s)\n", NAME, fname, 153 str_error(rc)); 154 return; 155 } 156 167 157 rc = task_wait(id, &texit, &retval); 168 158 if (rc != EOK) { 169 printf(NAME ": Error waiting for %s\n", fname); 170 return; 171 } 172 173 if (texit != TASK_EXIT_NORMAL || retval != 0) { 174 printf(NAME ": Server %s failed to start (returned %d)\n", 159 printf("%s: Error waiting for %s (%s(\n", NAME, fname, 160 str_error(rc)); 161 return; 162 } 163 164 if (texit != TASK_EXIT_NORMAL) { 165 printf("%s: Server %s failed to start (unexpectedly " 166 "terminated)\n", NAME, fname); 167 return; 168 } 169 170 if (retval != 0) { 171 printf("%s: Server %s failed to start (exit code %d)\n", NAME, 175 172 fname, retval); 176 173 } 177 174 } 178 175 179 static void getvc(char *dev, char *app) 180 { 181 char *argv[4]; 182 char vc[MAX_DEVICE_NAME]; 176 static void console(const char *dev) 177 { 178 char hid_in[DEVMAP_NAME_MAXLEN]; 183 179 int rc; 184 180 185 snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev); 186 187 printf(NAME ": Spawning getvc on %s\n", vc); 188 189 dev_handle_t handle; 181 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 182 183 printf("%s: Spawning %s %s\n", NAME, SRV_CONSOLE, hid_in); 184 185 /* Wait for the input device to be ready */ 186 devmap_handle_t handle; 190 187 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 191 192 if (rc == EOK) { 193 argv[0] = "/app/getvc"; 194 argv[1] = vc; 195 argv[2] = app; 196 argv[3] = NULL; 197 198 if (!task_spawn("/app/getvc", argv)) 199 printf(NAME ": Error spawning getvc on %s\n", vc); 188 if (rc != EOK) { 189 printf("%s: Error waiting on %s (%s)\n", NAME, hid_in, 190 str_error(rc)); 191 return; 192 } 193 194 rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, hid_in, NULL); 195 if (rc != EOK) { 196 printf("%s: Error spawning %s %s (%s)\n", NAME, SRV_CONSOLE, 197 hid_in, str_error(rc)); 198 } 199 } 200 201 static void getterm(const char *dev, const char *app, bool wmsg) 202 { 203 char term[DEVMAP_NAME_MAXLEN]; 204 int rc; 205 206 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 207 208 printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app); 209 210 /* Wait for the terminal device to be ready */ 211 devmap_handle_t handle; 212 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 213 if (rc != EOK) { 214 printf("%s: Error waiting on %s (%s)\n", NAME, term, 215 str_error(rc)); 216 return; 217 } 218 219 if (wmsg) { 220 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term, 221 app, NULL); 222 if (rc != EOK) { 223 printf("%s: Error spawning %s -w %s %s (%s)\n", NAME, 224 APP_GETTERM, term, app, str_error(rc)); 225 } 200 226 } else { 201 printf(NAME ": Error waiting on %s\n", vc); 202 } 203 } 204 205 static void mount_data(void) 206 { 207 int rc; 208 209 printf("Trying to mount disk0 on /data... "); 210 fflush(stdout); 211 212 rc = mount("fat", "/data", "disk0", "wtcache", 0); 213 if (rc == EOK) 214 printf("OK\n"); 215 else 216 printf("Failed\n"); 227 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app, 228 NULL); 229 if (rc != EOK) { 230 printf("%s: Error spawning %s %s %s (%s)\n", NAME, 231 APP_GETTERM, term, app, str_error(rc)); 232 } 233 } 234 } 235 236 static bool mount_tmpfs(void) 237 { 238 int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0); 239 return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT, 240 TMPFS_FS_TYPE, NULL, rc); 241 } 242 243 static bool mount_data(void) 244 { 245 int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0); 246 return mount_report("Data filesystem", DATA_MOUNT_POINT, DATA_FS_TYPE, 247 DATA_DEVICE, rc); 217 248 } 218 249 … … 222 253 223 254 if (!mount_root(STRING(RDFMT))) { 224 printf( NAME ": Exiting\n");255 printf("%s: Exiting\n", NAME); 225 256 return -1; 226 257 } 227 258 259 /* Make sure tmpfs is running. */ 260 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 261 spawn("/srv/tmpfs"); 262 } 263 228 264 spawn("/srv/devfs"); 265 spawn("/srv/taskmon"); 229 266 230 267 if (!mount_devfs()) { 231 printf( NAME ": Exiting\n");268 printf("%s: Exiting\n", NAME); 232 269 return -2; 233 270 } 271 272 mount_tmpfs(); 273 274 spawn("/srv/apic"); 275 spawn("/srv/i8259"); 276 spawn("/srv/fhc"); 277 spawn("/srv/obio"); 278 srv_start("/srv/cuda_adb"); 279 srv_start("/srv/i8042"); 280 srv_start("/srv/s3c24ser"); 281 srv_start("/srv/adb_ms"); 282 srv_start("/srv/char_ms"); 283 srv_start("/srv/s3c24ts"); 234 284 235 285 spawn("/srv/fb"); 236 286 spawn("/srv/kbd"); 237 spawn("/srv/console");238 spawn("/srv/fhc");239 spawn("/srv/ obio");240 287 console("hid_in/kbd"); 288 289 spawn("/srv/clip"); 290 241 291 /* 242 292 * Start these synchronously so that mount_data() can be … … 249 299 (void) srv_start; 250 300 #endif 251 301 252 302 #ifdef CONFIG_MOUNT_DATA 253 303 mount_data(); … … 255 305 (void) mount_data; 256 306 #endif 257 258 get vc("vc0", "/app/bdsh");259 get vc("vc1", "/app/bdsh");260 get vc("vc2", "/app/bdsh");261 get vc("vc3", "/app/bdsh");262 get vc("vc4", "/app/bdsh");263 get vc("vc5", "/app/bdsh");264 get vc("vc6", "/app/klog");307 308 getterm("term/vc0", "/app/bdsh", true); 309 getterm("term/vc1", "/app/bdsh", false); 310 getterm("term/vc2", "/app/bdsh", false); 311 getterm("term/vc3", "/app/bdsh", false); 312 getterm("term/vc4", "/app/bdsh", false); 313 getterm("term/vc5", "/app/bdsh", false); 314 getterm("term/vc6", "/app/klog", false); 265 315 266 316 return 0; -
uspace/app/init/init.h
rb50b5af2 r04803bf 39 39 #define NAME "init" 40 40 41 #define MAX_DEVICE_NAME 3242 43 41 #endif 44 42 -
uspace/app/kill/Makefile
rb50b5af2 r04803bf 1 1 # 2 # Copyright (c) 20 05 Jakub Jermar2 # Copyright (c) 2010 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 .text 29 USPACE_PREFIX = ../.. 30 LIBS = 31 EXTRA_CFLAGS = 32 BINARY = kill 30 33 31 #include <arch/stack.h> 34 SOURCES = \ 35 kill.c 32 36 33 .global panic_printf 34 panic_printf: 35 call printf 36 nop 37 call halt 38 nop 39 /* Not reached. */ 40 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/klog/Makefile
rb50b5af2 r04803bf 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 29 ## Setup toolchain 30 # 30 USPACE_PREFIX = ../.. 31 BINARY = klog 31 32 32 LIBC_PREFIX = ../../lib/libc33 SOFTINT_PREFIX = ../../lib/softint34 35 include $(LIBC_PREFIX)/Makefile.toolchain36 include $(LIBC_PREFIX)/Makefile.app37 38 ## Sources39 #40 41 OUTPUT = klog42 33 SOURCES = \ 43 34 klog.c 44 35 45 46 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 47 48 .PHONY: all clean depend disasm 49 50 all: $(OUTPUT) $(OUTPUT).disasm 51 52 -include Makefile.depend 53 54 clean: 55 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS) 56 57 depend: 58 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 59 60 $(OUTPUT): $(OBJECTS) $(LIBS) 61 $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 62 63 disasm: $(OUTPUT).disasm 64 65 $(OUTPUT).disasm: $(OUTPUT) 66 $(OBJDUMP) -d $< > $@ 67 68 %.o: %.S 69 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 70 71 %.o: %.s 72 $(AS) $(AFLAGS) $< -o $@ 73 74 %.o: %.c 75 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 36 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/klog/klog.c
rb50b5af2 r04803bf 36 36 37 37 #include <stdio.h> 38 #include <ipc/ipc.h>39 38 #include <async.h> 40 #include <ipc/services.h>41 39 #include <as.h> 42 #include < sysinfo.h>40 #include <ddi.h> 43 41 #include <event.h> 44 42 #include <errno.h> 43 #include <str_error.h> 45 44 #include <io/klog.h> 45 #include <sysinfo.h> 46 46 47 #define NAME "klog" 47 #define NAME "klog" 48 #define LOG_FNAME "/log/klog" 48 49 49 50 /* Pointer to klog area */ 50 51 static wchar_t *klog; 51 52 static size_t klog_length; 53 54 static FILE *log; 52 55 53 56 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) … … 58 61 size_t i; 59 62 60 for (i = klog_len - klog_stored; i < klog_len; i++) 61 putchar(klog[(klog_start + i) % klog_length]); 63 for (i = klog_len - klog_stored; i < klog_len; i++) { 64 wchar_t ch = klog[(klog_start + i) % klog_length]; 65 66 putchar(ch); 67 68 if (log != NULL) 69 fputc(ch, log); 70 } 71 72 if (log != NULL) { 73 fflush(log); 74 fsync(fileno(log)); 75 } 62 76 } 63 77 64 78 int main(int argc, char *argv[]) 65 79 { 66 size_t klog_pages = sysinfo_value("klog.pages"); 67 size_t klog_size = klog_pages * PAGE_SIZE; 68 klog_length = klog_size / sizeof(wchar_t); 69 70 klog = (wchar_t *) as_get_mappable_page(klog_size); 71 if (klog == NULL) { 72 printf(NAME ": Error allocating memory area\n"); 73 return -1; 74 } 75 76 printf("got area at 0x%08lx, length %lx byes\n", klog, klog_size); 77 78 int res = ipc_share_in_start_1_0(PHONE_NS, (void *) klog, 79 klog_size, SERVICE_MEM_KLOG); 80 if (res != EOK) { 81 printf(NAME ": Error initializing memory area\n"); 82 return -1; 80 size_t pages; 81 int rc = sysinfo_get_value("klog.pages", &pages); 82 if (rc != EOK) { 83 fprintf(stderr, "%s: Unable to get number of klog pages\n", 84 NAME); 85 return rc; 83 86 } 84 87 85 if (event_subscribe(EVENT_KLOG, 0) != EOK) { 86 printf(NAME ": Error registering klog notifications\n"); 87 return -1; 88 uintptr_t faddr; 89 rc = sysinfo_get_value("klog.faddr", &faddr); 90 if (rc != EOK) { 91 fprintf(stderr, "%s: Unable to get klog physical address\n", 92 NAME); 93 return rc; 88 94 } 95 96 size_t size = pages * PAGE_SIZE; 97 klog_length = size / sizeof(wchar_t); 98 99 klog = (wchar_t *) as_get_mappable_page(size); 100 if (klog == NULL) { 101 fprintf(stderr, "%s: Unable to allocate virtual memory area\n", 102 NAME); 103 return ENOMEM; 104 } 105 106 rc = physmem_map((void *) faddr, (void *) klog, pages, 107 AS_AREA_READ | AS_AREA_CACHEABLE); 108 if (rc != EOK) { 109 fprintf(stderr, "%s: Unable to map klog\n", NAME); 110 return rc; 111 } 112 113 rc = event_subscribe(EVENT_KLOG, 0); 114 if (rc != EOK) { 115 fprintf(stderr, "%s: Unable to register klog notifications\n", 116 NAME); 117 return rc; 118 } 119 120 /* 121 * Mode "a" would be definitively much better here, but it is 122 * not well supported by the FAT driver. 123 */ 124 log = fopen(LOG_FNAME, "w"); 125 if (log == NULL) 126 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME, 127 str_error(errno)); 89 128 90 129 async_set_interrupt_received(interrupt_received); -
uspace/app/netecho/print_error.h
rb50b5af2 r04803bf 1 1 /* 2 * Copyright (c) 200 5 Jakub Jermar2 * Copyright (c) 2009 Lukas Mejdrech 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libcia6429 /** @addtogroup net_app 30 30 * @{ 31 31 */ 32 32 33 /** @file 34 * Generic application error printing functions. 33 35 */ 34 36 35 #ifndef LIBC_ia64_ATOMIC_H_36 #define LIBC_ia64_ATOMIC_H_37 #ifndef NET_APP_PRINT_ 38 #define NET_APP_PRINT_ 37 39 38 /** Atomic addition. 40 #include <stdio.h> 41 42 /** Returns whether the error code may be an ICMP error code. 39 43 * 40 * @param val Atomic value. 41 * @param imm Value to add. 44 * @param[in] error_code The error code. 45 * @return A value indicating whether the error code may be an ICMP error code. 46 */ 47 #define IS_ICMP_ERROR(error_code) ((error_code) > 0) 48 49 /** Returns whether the error code may be socket error code. 42 50 * 43 * @return Value before addition. 51 * @param[in] error_code The error code. 52 * @return A value indicating whether the error code may be a socket error code. 44 53 */ 45 static inline long atomic_add(atomic_t *val, int imm) 46 { 47 long v; 54 #define IS_SOCKET_ERROR(error_code) ((error_code) < 0) 48 55 49 asm volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), "+m" (val->count) : "i" (imm)); 50 51 return v; 52 } 53 54 static inline void atomic_inc(atomic_t *val) { atomic_add(val, 1); } 55 static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); } 56 57 static inline long atomic_preinc(atomic_t *val) { return atomic_add(val, 1) + 1; } 58 static inline long atomic_predec(atomic_t *val) { return atomic_add(val, -1) - 1; } 59 60 static inline long atomic_postinc(atomic_t *val) { return atomic_add(val, 1); } 61 static inline long atomic_postdec(atomic_t *val) { return atomic_add(val, -1); } 56 extern void icmp_print_error(FILE *, int, const char *, const char *); 57 extern void print_error(FILE *, int, const char *, const char *); 58 extern void socket_print_error(FILE *, int, const char *, const char *); 62 59 63 60 #endif -
uspace/app/nettest1/nettest.h
rb50b5af2 r04803bf 1 1 /* 2 * Copyright (c) 200 5 Jakub Jermar2 * Copyright (c) 2009 Lukas Mejdrech 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mips3229 /** @addtogroup nettest 30 30 * @{ 31 31 */ 32 32 33 /** @file 34 * Networking test support functions. 33 35 */ 34 36 35 #ifndef KERN_mips32_ARG_H_36 #define KERN_mips32_ARG_H_37 #ifndef NET_TEST_ 38 #define NET_TEST_ 37 39 38 #include < arch/types.h>40 #include <net/socket.h> 39 41 40 /** 41 * va_arg macro for MIPS32 - problem is that 64 bit values must be aligned on an 8-byte boundary (32bit values not) 42 * To satisfy this, paddings must be sometimes inserted. 43 */ 44 45 typedef uintptr_t va_list; 46 47 #define va_start(ap, lst) \ 48 ((ap) = (va_list)&(lst) + sizeof(lst)) 49 50 #define va_arg(ap, type) \ 51 (((type *)((ap) = (va_list)( (sizeof(type) <= 4) ? ((uintptr_t)((ap) + 2*4 - 1) & (~3)) : ((uintptr_t)((ap) + 2*8 -1) & (~7)) )))[-1]) 52 53 #define va_copy(dst,src) ((dst)=(src)) 54 55 #define va_end(ap) 42 extern void print_mark(int); 43 extern int sockets_create(int, int *, int, int, sock_type_t); 44 extern int sockets_close(int, int *, int); 45 extern int sockets_connect(int, int *, int, struct sockaddr *, socklen_t); 46 extern int sockets_sendto(int, int *, int, struct sockaddr *, socklen_t, char *, int, int); 47 extern int sockets_recvfrom(int, int *, int, struct sockaddr *, socklen_t *, char *, int, int); 48 extern int sockets_sendto_recvfrom(int, int *, int, struct sockaddr *, socklen_t *, char *, int, int); 56 49 57 50 #endif … … 59 52 /** @} 60 53 */ 54 -
uspace/app/sbi/Makefile
rb50b5af2 r04803bf 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2010 Jiri Svoboda 4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 ## Common compiler flags 31 # 29 USPACE_PREFIX = ../.. 30 LIBS = $(LIBCLUI_PREFIX)/libclui.a 31 EXTRA_CFLAGS = -D__HELENOS__ -I$(LIBCLUI_PREFIX) 32 32 33 LIBC_PREFIX = ../libc 34 35 ## Setup toolchain 36 # 37 38 include $(LIBC_PREFIX)/Makefile.toolchain 39 40 CFLAGS += -Iinclude 41 42 ## Sources 43 # 33 BINARY = sbi 44 34 45 35 SOURCES = \ 46 libblock.c 36 src/builtin/bi_boxed.c \ 37 src/builtin/bi_error.c \ 38 src/builtin/bi_char.c \ 39 src/builtin/bi_console.c \ 40 src/builtin/bi_int.c \ 41 src/builtin/bi_task.c \ 42 src/builtin/bi_textfile.c \ 43 src/builtin/bi_string.c \ 44 src/os/helenos.c \ 45 src/ancr.c \ 46 src/bigint.c \ 47 src/builtin.c \ 48 src/cspan.c \ 49 src/imode.c \ 50 src/input.c \ 51 src/intmap.c \ 52 src/lex.c \ 53 src/list.c \ 54 src/main.c \ 55 src/p_expr.c \ 56 src/p_type.c \ 57 src/parse.c \ 58 src/program.c \ 59 src/rdata.c \ 60 src/run.c \ 61 src/run_expr.c \ 62 src/run_texpr.c \ 63 src/stree.c \ 64 src/strtab.c \ 65 src/stype.c \ 66 src/stype_expr.c \ 67 src/symbol.c \ 68 src/tdata.c 47 69 48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 49 50 .PHONY: all clean depend 51 52 all: libblock.a 53 54 -include Makefile.depend 55 56 clean: 57 -rm -f libblock.a Makefile.depend 58 find . -name '*.o' -follow -exec rm \{\} \; 59 60 depend: 61 -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null 62 63 libblock.a: depend $(OBJECTS) 64 $(AR) rc libblock.a $(OBJECTS) 65 66 %.o: %.c 67 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 70 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/sbi/src/lex.h
rb50b5af2 r04803bf 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/tester/Makefile
rb50b5af2 r04803bf 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 29 ## Setup toolchain 30 # 30 USPACE_PREFIX = ../.. 31 BINARY = tester 31 32 32 LIBC_PREFIX = ../../lib/libc 33 SOFTINT_PREFIX = ../../lib/softint 34 35 include $(LIBC_PREFIX)/Makefile.toolchain 36 include $(LIBC_PREFIX)/Makefile.app 37 38 CFLAGS += -I../../srv/kbd/include 39 40 ## Sources 41 # 42 43 OUTPUT = tester 44 SOURCES = tester.c \ 33 SOURCES = \ 34 tester.c \ 45 35 thread/thread1.c \ 46 36 print/print1.c \ … … 48 38 print/print3.c \ 49 39 print/print4.c \ 40 print/print5.c \ 50 41 console/console1.c \ 51 42 stdio/stdio1.c \ … … 53 44 fault/fault1.c \ 54 45 fault/fault2.c \ 46 fault/fault3.c \ 55 47 vfs/vfs1.c \ 56 48 ipc/ping_pong.c \ 57 ipc/register.c \58 ipc/connect.c \59 49 loop/loop1.c \ 60 mm/malloc1.c 50 mm/malloc1.c \ 51 hw/misc/virtchar1.c \ 52 hw/serial/serial1.c 61 53 62 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 63 64 .PHONY: all clean depend disasm 65 66 all: $(OUTPUT) $(OUTPUT).disasm 67 68 -include Makefile.depend 69 70 clean: 71 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS) 72 73 depend: 74 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 75 76 $(OUTPUT): $(OBJECTS) $(LIBS) 77 $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 78 79 disasm: $(OUTPUT).disasm 80 81 $(OUTPUT).disasm: $(OUTPUT) 82 $(OBJDUMP) -d $< > $@ 83 84 %.o: %.S 85 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 86 87 %.o: %.s 88 $(AS) $(AFLAGS) $< -o $@ 89 90 %.o: %.c 91 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 54 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/tester/console/console1.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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/ipc/ping_pong.c
rb50b5af2 r04803bf 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); … … 72 72 } 73 73 74 TPRINTF("OK\nCompleted % llu round trips in %u seconds, %llurt/s.\n",74 TPRINTF("OK\nCompleted %" PRIu64 " round trips in %u seconds, %" PRIu64 " rt/s.\n", 75 75 count, DURATION_SECS, count / DURATION_SECS); 76 76 -
uspace/app/tester/loop/loop1.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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"); … … 49 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 50 51 TPRINTF("Testing printf(\"%%s\", NULL):\n");52 TPRINTF("Expected output: \"(NULL)\"\n");53 TPRINTF("Real output: \"%s\"\n\n", NULL);54 55 51 return NULL; 56 52 } -
uspace/app/tester/print/print2.c
rb50b5af2 r04803bf 31 31 #include "../tester.h" 32 32 33 c har *test_print2(void)33 const char *test_print2(void) 34 34 { 35 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");36 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n");37 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');35 TPRINTF("Testing printf(\"%%c\", 'a'):\n"); 36 TPRINTF("Expected output: [a]\n"); 37 TPRINTF("Real output: [%c]\n\n", 'a'); 38 38 39 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); -
uspace/app/tester/print/print3.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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"); … … 45 45 TPRINTF(" "); 46 46 for (index = 0; index < 32; index++) 47 TPRINTF("%lc", (w char_t) ((group << 5) + index));47 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 48 48 49 49 TPRINTF("\n"); … … 57 57 uint8_t index; 58 58 for (index = 0; index < 32; index++) 59 TPRINTF("%lc", (w char_t) ((group << 5) + index));59 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 60 60 61 61 TPRINTF("\n"); -
uspace/app/tester/stdio/stdio1.c
rb50b5af2 r04803bf 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); … … 60 60 61 61 buf[cnt] = '\0'; 62 TPRINTF("Read % u bytes, string \"%s\"\n", cnt, buf);62 TPRINTF("Read %zu bytes, string \"%s\"\n", cnt, buf); 63 63 64 64 TPRINTF("Seek to beginning..."); -
uspace/app/tester/stdio/stdio2.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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 … … 51 51 #include "print/print3.def" 52 52 #include "print/print4.def" 53 #include "print/print5.def" 53 54 #include "console/console1.def" 54 55 #include "stdio/stdio1.def" … … 56 57 #include "fault/fault1.def" 57 58 #include "fault/fault2.def" 59 #include "fault/fault3.def" 58 60 #include "vfs/vfs1.def" 59 61 #include "ipc/ping_pong.def" 60 #include "ipc/register.def"61 #include "ipc/connect.def"62 62 #include "loop/loop1.def" 63 63 #include "mm/malloc1.def" 64 #include "hw/serial/serial1.def" 65 #include "hw/misc/virtchar1.def" 64 66 {NULL, NULL, NULL, false} 65 67 }; … … 68 70 { 69 71 /* Execute the test */ 70 c har *ret = test->entry();72 const char *ret = test->entry(); 71 73 72 74 if (ret == NULL) { … … 109 111 } 110 112 113 unsigned int _len = (unsigned int) len; 114 if ((_len != len) || (((int) _len) < 0)) { 115 printf("Command length overflow\n"); 116 return; 117 } 118 111 119 for (test = tests; test->name != NULL; test++) 112 printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); 120 printf("%-*s %s%s\n", _len, test->name, test->desc, 121 (test->safe ? "" : " (unsafe)")); 113 122 114 printf("%-*s Run all safe tests\n", len, "*");123 printf("%-*s Run all safe tests\n", _len, "*"); 115 124 } 116 125 -
uspace/app/tester/tester.h
rb50b5af2 r04803bf 38 38 #include <sys/types.h> 39 39 #include <bool.h> 40 #include <ipc/ipc.h>41 40 42 41 #define IPC_TEST_SERVICE 10240 … … 54 53 } 55 54 56 typedef c har *(*test_entry_t)(void);55 typedef const char *(*test_entry_t)(void); 57 56 58 57 typedef struct { 59 c har *name;60 c har *desc;58 const char *name; 59 const char *desc; 61 60 test_entry_t entry; 62 61 bool safe; 63 62 } test_t; 64 63 65 extern char *test_thread1(void); 66 extern char *test_print1(void); 67 extern char *test_print2(void); 68 extern char *test_print3(void); 69 extern char *test_print4(void); 70 extern char *test_console1(void); 71 extern char *test_stdio1(void); 72 extern char *test_stdio2(void); 73 extern char *test_fault1(void); 74 extern char *test_fault2(void); 75 extern char *test_vfs1(void); 76 extern char *test_ping_pong(void); 77 extern char *test_register(void); 78 extern char *test_connect(void); 79 extern char *test_loop1(void); 80 extern char *test_malloc1(void); 64 extern const char *test_thread1(void); 65 extern const char *test_print1(void); 66 extern const char *test_print2(void); 67 extern const char *test_print3(void); 68 extern const char *test_print4(void); 69 extern const char *test_print5(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_loop1(void); 79 extern const char *test_malloc1(void); 80 extern const char *test_serial1(void); 81 extern const char *test_virtchar1(void); 81 82 82 83 extern test_t tests[]; -
uspace/app/tester/thread/thread1.c
rb50b5af2 r04803bf 35 35 #include <stdio.h> 36 36 #include <unistd.h> 37 #include <inttypes.h> 37 38 #include "../tester.h" 38 39 … … 50 51 } 51 52 52 c har *test_thread1(void)53 const char *test_thread1(void) 53 54 { 54 55 unsigned int i; 55 int total = 0;56 atomic_count_t total = 0; 56 57 57 58 atomic_set(&finish, 1); … … 74 75 atomic_set(&finish, 0); 75 76 while (atomic_get(&threads_finished) < total) { 76 TPRINTF("Threads left: %u\n", total - atomic_get(&threads_finished)); 77 TPRINTF("Threads left: %" PRIua "\n", 78 total - atomic_get(&threads_finished)); 77 79 sleep(1); 78 80 } -
uspace/app/tester/vfs/vfs1.c
rb50b5af2 r04803bf 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> … … 40 40 #include "../tester.h" 41 41 42 #define FS_TYPE "tmpfs" 43 #define MOUNT_POINT "/tmp" 44 #define OPTIONS "" 45 #define FLAGS 0 46 47 #define TEST_DIRECTORY MOUNT_POINT "/testdir" 42 #define TEST_DIRECTORY "/tmp/testdir" 48 43 #define TEST_FILE TEST_DIRECTORY "/testfile" 49 44 #define TEST_FILE2 TEST_DIRECTORY "/nextfile" … … 54 49 static char text[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; 55 50 56 static c har *read_root(void)51 static const char *read_root(void) 57 52 { 58 53 TPRINTF("Opening the root directory..."); … … 73 68 } 74 69 75 c har *test_vfs1(void)70 const char *test_vfs1(void) 76 71 { 77 if (mkdir(MOUNT_POINT, 0) != 0) 72 int rc; 73 if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) { 74 TPRINTF("rc=%d\n", rc); 78 75 return "mkdir() failed"; 79 TPRINTF("Created directory %s\n", MOUNT_POINT);80 81 char null[MAX_DEVICE_NAME];82 int null_id = devmap_null_create();83 84 if (null_id == -1)85 return "Unable to create null device";86 87 snprintf(null, MAX_DEVICE_NAME, "null%d", null_id);88 int rc = mount(FS_TYPE, MOUNT_POINT, null, OPTIONS, FLAGS);89 switch (rc) {90 case EOK:91 TPRINTF("Mounted /dev/%s as %s on %s\n", null, FS_TYPE, MOUNT_POINT);92 break;93 case EBUSY:94 TPRINTF("(INFO) Filesystem already mounted on %s\n", MOUNT_POINT);95 break;96 default:97 TPRINTF("(ERR) IPC returned errno %d (is tmpfs loaded?)\n", rc);98 return "mount() failed";99 76 } 100 101 if (mkdir(TEST_DIRECTORY, 0) != 0)102 return "mkdir() failed";103 77 TPRINTF("Created directory %s\n", TEST_DIRECTORY); 104 78 … … 112 86 if (cnt < 0) 113 87 return "write() failed"; 114 TPRINTF("Written % d bytes\n", cnt);88 TPRINTF("Written %zd bytes\n", cnt); 115 89 116 90 if (lseek(fd0, 0, SEEK_SET) != 0) … … 123 97 return "read() failed"; 124 98 125 TPRINTF("Read %d bytes: \".*s\"\n", cnt, cnt, buf); 99 int _cnt = (int) cnt; 100 if (_cnt != cnt) { 101 /* Count overflow, just to be sure. */ 102 TPRINTF("Read %zd bytes\n", cnt); 103 } else { 104 TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf); 105 } 126 106 } 127 107 128 108 close(fd0); 129 109 130 c har *rv = read_root();110 const char *rv = read_root(); 131 111 if (rv != NULL) 132 112 return rv; -
uspace/app/tetris/Makefile
rb50b5af2 r04803bf 1 LIBC_PREFIX = ../../lib/libc 2 SOFTINT_PREFIX = ../../lib/softint 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # - Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # - Redistributions in binary form must reproduce the above copyright 13 # notice, this list of conditions and the following disclaimer in the 14 # documentation and/or other materials provided with the distribution. 15 # - The name of the author may not be used to endorse or promote products 16 # derived from this software without specific prior written permission. 17 # 18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # 3 29 4 include $(LIBC_PREFIX)/Makefile.toolchain 5 include $(LIBC_PREFIX)/Makefile.app 30 USPACE_PREFIX = ../.. 31 BINARY = tetris 6 32 7 OUTPUT = tetris 8 SOURCES = shapes.c scores.c input.c tetris.c screen.c 9 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 33 SOURCES = \ 34 shapes.c \ 35 scores.c \ 36 input.c \ 37 tetris.c \ 38 screen.c 10 39 11 .PHONY: all clean depend disasm 12 13 all: $(OUTPUT) $(OUTPUT).disasm 14 15 -include Makefile.depend 16 17 depend: 18 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 19 20 $(OUTPUT): $(OBJECTS) $(LIBS) 21 $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 22 23 clean: 24 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend *.o 25 26 disasm: $(OUTPUT).disasm 27 28 $(OUTPUT).disasm: $(OUTPUT) 29 $(OBJDUMP) -d $< > $@ 30 31 %.o: %.S 32 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 33 34 %.o: %.s 35 $(AS) $(AFLAGS) $< -o $@ 36 37 %.o: %.c 38 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 40 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/tetris/input.c
rb50b5af2 r04803bf 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" … … 97 97 struct timeval starttv, endtv, *s; 98 98 static ipc_call_t charcall; 99 ipcarg_t rc;99 sysarg_t rc; 100 100 101 101 /* -
uspace/app/tetris/scores.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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( int r, int c)122 void moveto(sysarg_t r, sysarg_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 sysarg_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
rb50b5af2 r04803bf 49 49 #include <sys/types.h> 50 50 #include <async.h> 51 #include <bool.h> 51 52 52 53 typedef struct { 53 ipcarg_t ws_row;54 ipcarg_t ws_col;54 sysarg_t ws_row; 55 sysarg_t ws_col; 55 56 } winsize_t; 56 57 57 58 extern winsize_t winsize; 58 59 59 extern void moveto( int r, int c);60 extern void moveto(sysarg_t r, sysarg_t c); 60 61 extern void clear_screen(void); 61 62 … … 65 66 extern void scr_end(void); 66 67 extern void scr_init(void); 67 extern void scr_msg(char *, int);68 extern void scr_msg(char *, bool); 68 69 extern void scr_set(void); 69 70 extern void scr_update(void); -
uspace/app/tetris/tetris.c
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 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 do { \ 43 if ((b) != 0) { \ 44 (float).upper = (a); \ 45 (float).lower = (b); \ 46 } else { \ 47 (float).upper = 0; \ 48 (float).lower = 1; \ 49 } \ 50 } while (0) 40 51 41 /** Size of buffer for storing task name in task_t. */ 42 #define BOOTINFO_TASK_NAME_BUFLEN 32 52 typedef enum { 53 OP_TASKS, 54 OP_IPC, 55 OP_EXCS, 56 OP_HELP 57 } op_mode_t; 43 58 44 #define BSP_PROCESSOR 1 45 #define AP_PROCESSOR 0 59 typedef enum { 60 SORT_TASK_CYCLES 61 } sort_mode_t; 46 62 47 #define SUBARCH_US 1 48 #define SUBARCH_US3 3 63 extern op_mode_t op_mode; 64 extern sort_mode_t sort_mode; 65 extern bool excs_all; 49 66 50 67 typedef struct { 51 void *addr; 52 uint32_t size; 53 char name[BOOTINFO_TASK_NAME_BUFLEN]; 54 } task_t; 68 uint64_t upper; 69 uint64_t lower; 70 } fixed_float; 55 71 56 72 typedef struct { 57 uint32_t count;58 task_t tasks[TASKMAP_MAX_RECORDS];59 } taskmap_t;73 fixed_float idle; 74 fixed_float busy; 75 } perc_cpu_t; 60 76 61 77 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; 78 fixed_float virtmem; 79 fixed_float resmem; 80 fixed_float ucycles; 81 fixed_float kcycles; 82 } perc_task_t; 68 83 69 extern uint32_t silo_ramdisk_image; 70 extern uint32_t silo_ramdisk_size; 84 typedef struct { 85 fixed_float cycles; 86 fixed_float count; 87 } perc_exc_t; 71 88 72 extern void start(void); 73 extern void bootstrap(void); 89 typedef struct { 90 time_t hours; 91 time_t minutes; 92 time_t seconds; 93 94 sysarg_t udays; 95 sysarg_t uhours; 96 sysarg_t uminutes; 97 sysarg_t useconds; 98 99 size_t load_count; 100 load_t *load; 101 102 size_t cpus_count; 103 stats_cpu_t *cpus; 104 perc_cpu_t *cpus_perc; 105 106 size_t tasks_count; 107 stats_task_t *tasks; 108 perc_task_t *tasks_perc; 109 size_t *tasks_map; 110 111 size_t threads_count; 112 stats_thread_t *threads; 113 114 size_t exceptions_count; 115 stats_exc_t *exceptions; 116 perc_exc_t *exceptions_perc; 117 118 stats_physmem_t *physmem; 119 120 uint64_t *ucycles_diff; 121 uint64_t *kcycles_diff; 122 uint64_t *ecycles_diff; 123 uint64_t *ecount_diff; 124 } data_t; 74 125 75 126 #endif 127 128 /** 129 * @} 130 */ -
uspace/app/trace/Makefile
rb50b5af2 r04803bf 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 29 ## Setup toolchain 30 # 30 USPACE_PREFIX = ../.. 31 BINARY = trace 31 32 32 LIBC_PREFIX = ../../lib/libc 33 SOFTINT_PREFIX = ../../lib/softint 34 35 include $(LIBC_PREFIX)/Makefile.toolchain 36 include $(LIBC_PREFIX)/Makefile.app 37 38 CFLAGS += -I../../srv/kbd/include 39 40 ## Sources 41 # 42 43 OUTPUT = trace 44 SOURCES = trace.c \ 33 SOURCES = \ 34 trace.c \ 45 35 syscalls.c \ 46 36 ipcp.c \ … … 49 39 errors.c 50 40 51 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 52 53 .PHONY: all clean depend disasm 54 55 all: $(OUTPUT) disasm 56 57 -include Makefile.depend 58 59 clean: 60 -rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend 61 62 depend: 63 $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend 64 65 $(OUTPUT): $(OBJECTS) $(LIBS) 66 $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 67 68 disasm: 69 $(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm 70 71 %.o: %.S 72 $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ 73 74 %.o: %.s 75 $(AS) $(AFLAGS) $< -o $@ 76 77 %.o: %.c 78 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 41 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/trace/errors.h
rb50b5af2 r04803bf 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.c
rb50b5af2 r04803bf 33 33 */ 34 34 35 #include <ipc/common.h> 35 36 #include <stdlib.h> 36 #include <ipc/ipc.h>37 37 #include "ipc_desc.h" 38 38 -
uspace/app/trace/ipc_desc.h
rb50b5af2 r04803bf 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/ipcp.c
rb50b5af2 r04803bf 36 36 #include <stdlib.h> 37 37 #include <adt/hash_table.h> 38 #include <sys/typefmt.h> 38 39 39 40 #include "ipc_desc.h" … … 45 46 46 47 typedef struct { 47 ipcarg_t phone_hash;48 sysarg_t phone_hash; 48 49 ipc_call_t question; 49 50 oper_t *oper; … … 123 124 } 124 125 125 static void ipc_m_print(proto_t *proto, ipcarg_t method)126 static void ipc_m_print(proto_t *proto, sysarg_t method) 126 127 { 127 128 oper_t *oper; … … 136 137 137 138 if (oper != NULL) { 138 printf("%s (% ld)", oper->name, method);139 printf("%s (%" PRIun ")", oper->name, method); 139 140 return; 140 141 } 141 142 142 printf("% ld", method);143 printf("%" PRIun, method); 143 144 } 144 145 … … 191 192 unsigned long key[1]; 192 193 oper_t *oper; 193 ipcarg_t *args;194 sysarg_t *args; 194 195 int i; 195 196 … … 200 201 201 202 if ((display_mask & DM_IPC) != 0) { 202 printf("Call ID: 0x%lx, phone: %d, proto: %s, method: ", hash, 203 phone, (proto ? proto->name : "n/a")); 204 ipc_m_print(proto, IPC_GET_METHOD(*call)); 205 printf(" args: (%lu, %lu, %lu, %lu, %lu)\n", args[1], args[2], 206 args[3], args[4], args[5]); 203 printf("Call ID: %p, phone: %d, proto: %s, method: ", 204 (void *) hash, phone, 205 (proto ? proto->name : "n/a")); 206 ipc_m_print(proto, IPC_GET_IMETHOD(*call)); 207 printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", " 208 "%" PRIun ", %" PRIun ")\n", 209 args[1], args[2], args[3], args[4], args[5]); 207 210 } 208 211 … … 211 214 212 215 if (proto != NULL) { 213 oper = proto_get_oper(proto, IPC_GET_ METHOD(*call));216 oper = proto_get_oper(proto, IPC_GET_IMETHOD(*call)); 214 217 } else { 215 218 oper = NULL; … … 259 262 ipc_call_t *answer) 260 263 { 261 ipcarg_t phone;262 ipcarg_t method;263 ipcarg_t service;264 ipcarg_t retval;264 sysarg_t phone; 265 sysarg_t method; 266 sysarg_t service; 267 sysarg_t retval; 265 268 proto_t *proto; 266 269 int cphone; 267 270 268 ipcarg_t *resp;271 sysarg_t *resp; 269 272 oper_t *oper; 270 273 int i; … … 273 276 274 277 phone = pcall->phone_hash; 275 method = IPC_GET_ METHOD(pcall->question);278 method = IPC_GET_IMETHOD(pcall->question); 276 279 retval = IPC_GET_RETVAL(*answer); 277 280 … … 279 282 280 283 if ((display_mask & DM_IPC) != 0) { 281 printf("Response to 0x%lx: retval=%ld, args = (%lu, %lu, %lu, %lu, %lu)\n", 282 hash, retval, IPC_GET_ARG1(*answer), 283 IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), 284 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 284 printf("Response to %p: retval=%" PRIdn ", args = (%" PRIun ", " 285 "%" PRIun ", %" PRIun ", %" PRIun ", %" PRIun ")\n", 286 (void *) hash, retval, IPC_GET_ARG1(*answer), 287 IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), 288 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 285 289 } 286 290 … … 336 340 /* Not a response */ 337 341 if ((display_mask & DM_IPC) != 0) { 338 printf("Not a response (hash 0x%lx)\n",hash);342 printf("Not a response (hash %p)\n", (void *) hash); 339 343 } 340 344 return; -
uspace/app/trace/ipcp.h
rb50b5af2 r04803bf 36 36 #define IPCP_H_ 37 37 38 #include <ipc/ipc.h>39 38 #include "proto.h" 40 39 -
uspace/app/trace/proto.c
rb50b5af2 r04803bf 35 35 #include <stdio.h> 36 36 #include <stdlib.h> 37 #include <ipc/ipc.h>38 37 #include <adt/hash_table.h> 39 38 … … 53 52 54 53 typedef struct { 55 ipcarg_t method;54 sysarg_t method; 56 55 oper_t *oper; 57 56 link_t link; … … 157 156 } 158 157 159 static void proto_struct_init(proto_t *proto, c har *name)158 static void proto_struct_init(proto_t *proto, const char *name) 160 159 { 161 160 proto->name = name; … … 164 163 } 165 164 166 proto_t *proto_new(c har *name)165 proto_t *proto_new(const char *name) 167 166 { 168 167 proto_t *p; … … 206 205 } 207 206 208 static void oper_struct_init(oper_t *oper, c har *name)207 static void oper_struct_init(oper_t *oper, const char *name) 209 208 { 210 209 oper->name = name; 211 210 } 212 211 213 oper_t *oper_new(c har *name, int argc, val_type_t *arg_types,212 oper_t *oper_new(const char *name, int argc, val_type_t *arg_types, 214 213 val_type_t rv_type, int respc, val_type_t *resp_types) 215 214 { -
uspace/app/trace/proto.h
rb50b5af2 r04803bf 36 36 #define PROTO_H_ 37 37 38 #include <ipc/common.h> 38 39 #include <adt/hash_table.h> 39 #include <ipc/ipc.h>40 40 #include "trace.h" 41 41 … … 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
rb50b5af2 r04803bf 64 64 [SYS_IPC_POKE] = { "ipc_poke", 0, V_ERRNO }, 65 65 [SYS_IPC_HANGUP] = { "ipc_hangup", 1, V_ERRNO }, 66 [SYS_IPC_REGISTER_IRQ] = { "ipc_register_irq", 4, V_ERRNO },67 [SYS_IPC_UNREGISTER_IRQ] = { "ipc_unregister_irq", 2, V_ERRNO },68 66 69 67 [SYS_EVENT_SUBSCRIBE] = { "event_subscribe", 2, V_ERRNO }, … … 73 71 [SYS_PHYSMEM_MAP] = { "physmem_map", 4, V_ERRNO }, 74 72 [SYS_IOSPACE_ENABLE] = { "iospace_enable", 1, V_ERRNO }, 75 [SYS_PREEMPT_CONTROL] = { "preempt_control", 1, V_ERRNO }, 73 [SYS_REGISTER_IRQ] = { "register_irq", 4, V_ERRNO }, 74 [SYS_UNREGISTER_IRQ] = { "unregister_irq", 2, V_ERRNO }, 76 75 77 [SYS_SYSINFO_VALID] = { "sysinfo_valid", 2, V_HASH }, 78 [SYS_SYSINFO_VALUE] = { "sysinfo_value", 2, V_HASH }, 76 [SYS_SYSINFO_GET_TAG] = { "sysinfo_get_tag", 2, V_INTEGER }, 77 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, 78 [SYS_SYSINFO_GET_DATA_SIZE] = { "sysinfo_get_data_size", 3, V_ERRNO }, 79 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 5, V_ERRNO }, 80 79 81 [SYS_DEBUG_ENABLE_CONSOLE] = { "debug_enable_console", 0, V_ERRNO }, 80 82 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } -
uspace/app/trace/syscalls.h
rb50b5af2 r04803bf 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
rb50b5af2 r04803bf 36 36 #include <stdlib.h> 37 37 #include <unistd.h> 38 #include <ipc/ipc.h>39 38 #include <fibril.h> 40 39 #include <errno.h> … … 43 42 #include <task.h> 44 43 #include <mem.h> 45 #include <str ing.h>44 #include <str.h> 46 45 #include <bool.h> 47 46 #include <loader/loader.h> 48 47 #include <io/console.h> 49 48 #include <io/keycode.h> 50 #include <fibril_sync.h> 49 #include <fibril_synch.h> 50 #include <sys/types.h> 51 #include <sys/typefmt.h> 51 52 52 53 #include <libc.h> … … 147 148 int rc; 148 149 149 rc = ipc_connect_kbox(task_id);150 rc = async_connect_kbox(task_id); 150 151 151 152 if (rc == ENOTSUP) { … … 159 160 if (rc < 0) { 160 161 printf("Error connecting\n"); 161 printf("ipc_connect_task(% lld) -> %d ", task_id, rc);162 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc); 162 163 return rc; 163 164 } … … 198 199 printf("Threads:"); 199 200 for (i = 0; i < n_threads; i++) { 200 printf(" [%d] (hash 0x%lx)", 1+i,thread_hash_buf[i]);201 } 202 printf("\ntotal of % u threads\n", tb_needed / sizeof(uintptr_t));201 printf(" [%d] (hash %p)", 1 + i, (void *) thread_hash_buf[i]); 202 } 203 printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t)); 203 204 204 205 return 0; … … 222 223 case V_HASH: 223 224 case V_PTR: 224 printf(" 0x%08lx",val);225 printf("%p", (void *) val); 225 226 break; 226 227 … … 246 247 case V_CHAR: 247 248 if (sval >= 0x20 && sval < 0x7f) { 248 printf("'%c'", sval);249 printf("'%c'", (char) sval); 249 250 } else { 250 251 switch (sval) { … … 255 256 case '\t': printf("'\\t'"); break; 256 257 case '\\': printf("'\\\\'"); break; 257 default: printf("'\\x%02 lX'", val); break;258 default: printf("'\\x%02" PRIxn "'", val); break; 258 259 } 259 260 } … … 275 276 276 277 putchar('('); 277 if (n > 0) printf("% ld", sc_args[0]);278 if (n > 0) printf("%" PRIun, sc_args[0]); 278 279 for (i = 1; i < n; i++) { 279 printf(", % ld", sc_args[i]);280 printf(", %" PRIun, sc_args[i]); 280 281 } 281 282 putchar(')'); … … 285 286 { 286 287 ipc_call_t call; 287 ipcarg_t phoneid;288 sysarg_t phoneid; 288 289 289 290 if (sc_rc == (sysarg_t) IPC_CALLRET_FATAL || … … 293 294 phoneid = sc_args[0]; 294 295 295 IPC_SET_ METHOD(call, sc_args[1]);296 IPC_SET_IMETHOD(call, sc_args[1]); 296 297 IPC_SET_ARG1(call, sc_args[2]); 297 298 IPC_SET_ARG2(call, sc_args[3]); … … 329 330 phoneidx = sc_args[0]; 330 331 331 IPC_SET_ METHOD(question, sc_args[1]);332 IPC_SET_IMETHOD(question, sc_args[1]); 332 333 IPC_SET_ARG1(question, sc_args[2]); 333 334 IPC_SET_ARG2(question, sc_args[3]); … … 487 488 { 488 489 async_serialize_start(); 489 printf("New thread, hash 0x%lx\n",hash);490 printf("New thread, hash %p\n", (void *) hash); 490 491 async_serialize_end(); 491 492 … … 508 509 } 509 510 510 printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash); 511 printf("Start tracing thread [%u] (hash %p).\n", 512 thread_id, (void *) thread_hash); 511 513 512 514 while (!abort_trace) { … … 514 516 fibril_mutex_lock(&state_lock); 515 517 if (paused) { 516 printf("Thread [% d] paused. Press R to resume.\n",518 printf("Thread [%u] paused. Press R to resume.\n", 517 519 thread_id); 518 520 … … 520 522 fibril_condvar_wait(&state_cv, &state_lock); 521 523 522 printf("Thread [% d] resumed.\n", thread_id);524 printf("Thread [%u] resumed.\n", thread_id); 523 525 } 524 526 fibril_mutex_unlock(&state_lock); … … 552 554 break; 553 555 case UDEBUG_EVENT_THREAD_E: 554 printf("Thread 0x%lxexited.\n", val0);556 printf("Thread %" PRIun " exited.\n", val0); 555 557 fibril_mutex_lock(&state_lock); 556 558 abort_trace = true; … … 583 585 } 584 586 585 static loader_t *preload_task(const char *path, char * const argv[],587 static loader_t *preload_task(const char *path, char **argv, 586 588 task_id_t *task_id) 587 589 { … … 589 591 int rc; 590 592 591 /* Spawn a program loader */ 593 /* Spawn a program loader */ 592 594 ldr = loader_connect(); 593 595 if (ldr == NULL) … … 605 607 606 608 /* Send arguments */ 607 rc = loader_set_args(ldr, argv);609 rc = loader_set_args(ldr, (const char **) argv); 608 610 if (rc != EOK) 609 611 goto error; … … 742 744 abort_trace = true; 743 745 udebug_end(phoneid); 744 ipc_hangup(phoneid);746 async_hangup(phoneid); 745 747 746 748 ipcp_cleanup(); … … 868 870 } 869 871 870 static display_mask_t parse_display_mask(c har *text)872 static display_mask_t parse_display_mask(const char *text) 871 873 { 872 874 display_mask_t dm; 873 char *c; 874 875 c = text; 876 875 const char *c = text; 876 877 877 while (*c) { 878 878 switch (*c) { 879 case 't': dm = dm | DM_THREAD; break; 880 case 's': dm = dm | DM_SYSCALL; break; 881 case 'i': dm = dm | DM_IPC; break; 882 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; 883 891 default: 884 892 printf("Unexpected event type '%c'.\n", *c); 885 893 exit(1); 886 894 } 887 895 888 896 ++c; 889 897 } 890 898 891 899 return dm; 892 900 } … … 894 902 static int parse_args(int argc, char *argv[]) 895 903 { 896 char *arg;897 904 char *err_p; 898 905 899 906 task_id = 0; 900 907 901 --argc; ++argv; 908 --argc; 909 ++argv; 902 910 903 911 while (argc > 0) { 904 arg = *argv;912 char *arg = *argv; 905 913 if (arg[0] == '+') { 906 914 display_mask = parse_display_mask(&arg[1]); … … 908 916 if (arg[1] == 't') { 909 917 /* Trace an already running task */ 910 --argc; ++argv; 918 --argc; 919 ++argv; 911 920 task_id = strtol(*argv, &err_p, 10); 912 921 task_ldr = NULL; … … 918 927 } 919 928 } else { 920 printf("Uknown option '% s'\n", arg[0]);929 printf("Uknown option '%c'\n", arg[0]); 921 930 print_syntax(); 922 931 return -1; … … 925 934 break; 926 935 } 927 928 --argc; ++argv; 936 937 --argc; 938 ++argv; 929 939 } 930 940 931 941 if (task_id != 0) { 932 if (argc == 0) return 0; 942 if (argc == 0) 943 return 0; 933 944 printf("Extra arguments\n"); 934 945 print_syntax(); … … 944 955 /* Preload the specified program file. */ 945 956 printf("Spawning '%s' with arguments:\n", *argv); 946 { 947 char **cp = argv; 948 while (*cp) printf("'%s'\n", *cp++); 949 } 957 958 char **cp = argv; 959 while (*cp) 960 printf("'%s'\n", *cp++); 961 950 962 task_ldr = preload_task(*argv, argv, &task_id); 951 963 task_wait_for = true; … … 972 984 rc = connect_task(task_id); 973 985 if (rc < 0) { 974 printf("Failed connecting to task % lld.\n", task_id);986 printf("Failed connecting to task %" PRIu64 ".\n", task_id); 975 987 return 1; 976 988 } 977 989 978 printf("Connected to task % lld.\n", task_id);990 printf("Connected to task %" PRIu64 ".\n", task_id); 979 991 980 992 if (task_ldr != NULL)
Note:
See TracChangeset
for help on using the changeset viewer.