Changes in / [ec7f8b1:c4a8e4a] in mainline
- Files:
-
- 1 added
- 4 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/asm.h
rec7f8b1 rc4a8e4a 41 41 #include <trace.h> 42 42 43 #define IO_SPACE_BOUNDARY ((void *) (64 * 1024))44 45 43 /** Return base address of current stack. 46 44 * … … 79 77 } 80 78 79 #define IO_SPACE_BOUNDARY ((void *) (64 * 1024)) 80 81 81 /** Byte from port 82 82 * … … 91 91 if (port < (ioport8_t *) IO_SPACE_BOUNDARY) { 92 92 uint8_t val; 93 94 93 asm volatile ( 95 94 "inb %w[port], %b[val]\n" … … 97 96 : [port] "d" (port) 98 97 ); 99 100 98 return val; 101 } else 99 } else { 102 100 return (uint8_t) *port; 101 } 103 102 } 104 103 … … 115 114 if (port < (ioport16_t *) IO_SPACE_BOUNDARY) { 116 115 uint16_t val; 117 118 116 asm volatile ( 119 117 "inw %w[port], %w[val]\n" … … 121 119 : [port] "d" (port) 122 120 ); 123 124 121 return val; 125 } else 122 } else { 126 123 return (uint16_t) *port; 124 } 127 125 } 128 126 … … 139 137 if (port < (ioport32_t *) IO_SPACE_BOUNDARY) { 140 138 uint32_t val; 141 142 139 asm volatile ( 143 140 "inl %w[port], %[val]\n" … … 145 142 : [port] "d" (port) 146 143 ); 147 148 144 return val; 149 } else 145 } else { 150 146 return (uint32_t) *port; 147 } 151 148 } 152 149 … … 166 163 :: [val] "a" (val), [port] "d" (port) 167 164 ); 168 } else 165 } else { 169 166 *port = val; 167 } 170 168 } 171 169 … … 185 183 :: [val] "a" (val), [port] "d" (port) 186 184 ); 187 } else 185 } else { 188 186 *port = val; 187 } 189 188 } 190 189 … … 204 203 :: [val] "a" (val), [port] "d" (port) 205 204 ); 206 } else 205 } else { 207 206 *port = val; 207 } 208 208 } 209 209 -
kernel/arch/ia32/include/asm.h
rec7f8b1 rc4a8e4a 118 118 :: [val] "a" (val), [port] "d" (port) 119 119 ); 120 } else 120 } else { 121 121 *port = val; 122 } 122 123 } 123 124 … … 137 138 :: [val] "a" (val), [port] "d" (port) 138 139 ); 139 } else 140 } else { 140 141 *port = val; 142 } 141 143 } 142 144 … … 156 158 :: [val] "a" (val), [port] "d" (port) 157 159 ); 158 } else 160 } else { 159 161 *port = val; 162 } 160 163 } 161 164 … … 172 175 if (((void *)port) < IO_SPACE_BOUNDARY) { 173 176 uint8_t val; 174 175 177 asm volatile ( 176 178 "inb %w[port], %b[val]\n" … … 178 180 : [port] "d" (port) 179 181 ); 180 181 182 return val; 182 } else 183 } else { 183 184 return (uint8_t) *port; 185 } 184 186 } 185 187 … … 196 198 if (((void *)port) < IO_SPACE_BOUNDARY) { 197 199 uint16_t val; 198 199 200 asm volatile ( 200 201 "inw %w[port], %w[val]\n" … … 202 203 : [port] "d" (port) 203 204 ); 204 205 205 return val; 206 } else 206 } else { 207 207 return (uint16_t) *port; 208 } 208 209 } 209 210 … … 220 221 if (((void *)port) < IO_SPACE_BOUNDARY) { 221 222 uint32_t val; 222 223 223 asm volatile ( 224 224 "inl %w[port], %[val]\n" … … 226 226 : [port] "d" (port) 227 227 ); 228 229 228 return val; 230 } else 229 } else { 231 230 return (uint32_t) *port; 231 } 232 232 } 233 233 -
uspace/Makefile
rec7f8b1 rc4a8e4a 176 176 lib/block \ 177 177 lib/clui \ 178 lib/fmtutil \179 178 lib/scsi \ 180 179 lib/softint \ -
uspace/Makefile.common
rec7f8b1 rc4a8e4a 112 112 LIBIMGMAP_PREFIX = $(LIB_PREFIX)/imgmap 113 113 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui 114 LIBFMTUTIL_PREFIX = $(LIB_PREFIX)/fmtutil115 114 116 115 LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2 -
uspace/app/bdsh/Makefile
rec7f8b1 rc4a8e4a 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a \ 32 $(LIBFMTUTIL_PREFIX)/libfmtutil.a 33 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) \ 34 -I$(LIBFMTUTIL_PREFIX) -I. -Icmds/ -Icmds/builtins -Icmds/modules 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 35 34 BINARY = bdsh 36 35 -
uspace/app/bdsh/cmds/modules/help/help.c
rec7f8b1 rc4a8e4a 1 1 /* 2 2 * Copyright (c) 2008 Tim Post 3 * Copyright (c) 2011 Martin Sucha4 3 * All rights reserved. 5 4 * … … 31 30 #include <stdlib.h> 32 31 #include <str.h> 33 #include <fmtutil.h>34 32 35 33 #include "config.h" … … 130 128 static void help_survival(void) 131 129 { 132 print_wrapped_console( 133 "Don't panic!\n\n" 130 printf("Don't panic!\n\n"); 134 131 135 132 printf("This is Bdsh, the Brain dead shell, currently " 136 133 "the primary user interface to HelenOS. Bdsh allows you to enter " 137 134 "commands and supports history (Up, Down arrow keys), " 138 135 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 139 136 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 140 "Ctrl-V), similar to common desktop environments.\n\n" 137 "Ctrl-V), similar to common desktop environments.\n\n"); 141 138 142 139 printf("The most basic filesystem commands are Bdsh builtins. Type " 143 140 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 144 141 "Other commands are external executables located in the /app and " 145 142 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 146 143 "to see their list. You can execute an external command simply " 147 "by entering its name (e.g. type 'tetris' [Enter]).\n\n" 144 "by entering its name (e.g. type 'tetris' [Enter]).\n\n"); 148 145 149 150 "these using the F1-F11 keys.\n\n" 146 printf("HelenOS has virtual consoles (VCs). You can switch between " 147 "these using the F1-F11 keys.\n\n"); 151 148 152 149 printf("This is but a small glimpse of what you can do with HelenOS. " 153 150 "To learn more please point your browser to the HelenOS User's " 154 "Guide: http://trac.helenos.org/wiki/UsersGuide\n\n", 155 ALIGN_LEFT); 151 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 156 152 } 157 153 -
uspace/app/bdsh/compl.c
rec7f8b1 rc4a8e4a 90 90 { 91 91 compl_t *cs = NULL; 92 size_t pref_size; 92 93 char *stext = NULL; 93 94 char *prefix = NULL; 94 95 char *dirname = NULL; 95 int retval;96 97 token_t *tokens = calloc(WORD_MAX, sizeof(token_t));98 if (tokens == NULL) {99 retval = ENOMEM;100 goto error;101 }102 103 size_t pref_size;104 96 char *rpath_sep; 105 97 static const char *dirlist_arg[] = { ".", NULL }; 98 int retval; 106 99 tokenizer_t tok; 107 ssize_t current_token; 100 token_t tokens[WORD_MAX]; 101 unsigned int current_token; 108 102 size_t tokens_length; 109 103 110 104 cs = calloc(1, sizeof(compl_t)); 111 105 if (!cs) { … … 113 107 goto error; 114 108 } 115 109 116 110 /* Convert text buffer to string */ 117 111 stext = wstr_to_astr(text); … … 133 127 134 128 /* Find the current token */ 135 for (current_token = 0; current_token < (ssize_t) tokens_length; 136 current_token++) { 129 for (current_token = 0; current_token < tokens_length; current_token++) { 137 130 token_t *t = &tokens[current_token]; 138 131 size_t end = t->char_start + t->char_length; 139 140 /* 141 * Check if the caret lies inside the token or immediately 132 /* Check if the caret lies inside the token or immediately 142 133 * after it 143 134 */ … … 147 138 } 148 139 149 if (tokens_length == 0) 150 current_token = -1; 151 152 if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE)) 140 if (tokens[current_token].type != TOKTYPE_SPACE) { 153 141 *cstart = tokens[current_token].char_start; 154 else 142 } 143 else { 155 144 *cstart = pos; 156 157 /*158 145 } 146 147 /* Extract the prefix being completed 159 148 * XXX: handle strings, etc. 160 149 */ … … 165 154 goto error; 166 155 } 167 prefix[pref_size] = 0; 168 169 if (current_token >= 0) { 170 str_ncpy(prefix, pref_size + 1, stext + 171 tokens[current_token].byte_start, pref_size); 172 } 156 157 str_ncpy(prefix, pref_size + 1, stext + 158 tokens[current_token].byte_start, pref_size); 173 159 174 160 /* … … 179 165 180 166 /* Skip any whitespace before current token */ 181 ssize_t prev_token = current_token - 1;182 if ( (prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE))167 int prev_token = current_token - 1; 168 if (prev_token != -1 && tokens[prev_token].type == TOKTYPE_SPACE) { 183 169 prev_token--; 184 170 } 171 185 172 /* 186 173 * It is a command if it is the first token or if it immediately 187 174 * follows a pipe token. 188 175 */ 189 if ( (prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE))176 if (prev_token == -1 || tokens[prev_token].type == TOKTYPE_SPACE) 190 177 cs->is_command = true; 191 178 else … … 262 249 if (cs != NULL) 263 250 free(cs); 264 if (tokens != NULL)265 free(tokens);266 251 267 252 return retval; -
uspace/app/bdsh/input.c
rec7f8b1 rc4a8e4a 67 67 int process_input(cliuser_t *usr) 68 68 { 69 token_t *tokens = calloc(WORD_MAX, sizeof(token_t));70 if (tokens == NULL)71 return ENOMEM;72 73 69 char *cmd[WORD_MAX]; 70 token_t tokens_space[WORD_MAX]; 71 token_t *tokens = tokens_space; 74 72 int rc = 0; 75 73 tokenizer_t tok; … … 79 77 char *redir_to = NULL; 80 78 81 if (usr->line == NULL) { 82 free(tokens); 79 if (NULL == usr->line) 83 80 return CL_EFAIL; 84 }85 81 86 82 rc = tok_init(&tok, usr->line, tokens, WORD_MAX); … … 213 209 } 214 210 tok_fini(&tok); 215 free(tokens);216 211 217 212 return rc; -
uspace/app/tester/stdio/stdio1.c
rec7f8b1 rc4a8e4a 39 39 { 40 40 FILE *file; 41 const char *file_name = "/ textdemo";41 const char *file_name = "/readme"; 42 42 43 43 TPRINTF("Open file \"%s\"...", file_name); -
uspace/dist/src/sysel/demos/htxtfile.sy
rec7f8b1 rc4a8e4a 35 35 var out_file : TextFile; 36 36 37 name = "/ textdemo";37 name = "/readme"; 38 38 39 39 in_file = new TextFile(); -
uspace/lib/c/arch/ia32/include/ddi.h
rec7f8b1 rc4a8e4a 43 43 if (port < (ioport8_t *) IO_SPACE_BOUNDARY) { 44 44 uint8_t val; 45 46 45 asm volatile ( 47 46 "inb %w[port], %b[val]\n" … … 49 48 : [port] "d" (port) 50 49 ); 51 52 50 return val; 53 } else 51 } else { 54 52 return (uint8_t) *port; 53 } 55 54 } 56 55 … … 59 58 if (port < (ioport16_t *) IO_SPACE_BOUNDARY) { 60 59 uint16_t val; 61 62 60 asm volatile ( 63 61 "inw %w[port], %w[val]\n" … … 65 63 : [port] "d" (port) 66 64 ); 67 68 65 return val; 69 } else 66 } else { 70 67 return (uint16_t) *port; 68 } 71 69 } 72 70 … … 75 73 if (port < (ioport32_t *) IO_SPACE_BOUNDARY) { 76 74 uint32_t val; 77 78 75 asm volatile ( 79 76 "inl %w[port], %[val]\n" … … 81 78 : [port] "d" (port) 82 79 ); 83 84 80 return val; 85 } else 81 } else { 86 82 return (uint32_t) *port; 83 } 87 84 } 88 85 … … 94 91 :: [val] "a" (val), [port] "d" (port) 95 92 ); 96 } else 93 } else { 97 94 *port = val; 95 } 98 96 } 99 97 … … 105 103 :: [val] "a" (val), [port] "d" (port) 106 104 ); 107 } else 105 } else { 108 106 *port = val; 107 } 109 108 } 110 109 … … 116 115 :: [val] "a" (val), [port] "d" (port) 117 116 ); 118 } else 117 } else { 119 118 *port = val; 119 } 120 120 } 121 121 -
uspace/lib/c/generic/async.c
rec7f8b1 rc4a8e4a 1656 1656 1657 1657 return sess; 1658 }1659 1660 /** Set arguments for new connections.1661 *1662 * FIXME This is an ugly hack to work around the problem that parallel1663 * exchanges are implemented using parallel connections. When we create1664 * a callback session, the framework does not know arguments for the new1665 * connections.1666 *1667 * The proper solution seems to be to implement parallel exchanges using1668 * tagging.1669 */1670 void async_sess_args_set(async_sess_t *sess, sysarg_t arg1, sysarg_t arg2,1671 sysarg_t arg3)1672 {1673 sess->arg1 = arg1;1674 sess->arg2 = arg2;1675 sess->arg3 = arg3;1676 1658 } 1677 1659 -
uspace/lib/c/generic/devman.c
rec7f8b1 rc4a8e4a 89 89 if (devman_driver_block_sess == NULL) 90 90 devman_driver_block_sess = 91 service_connect_blocking(EXCHANGE_ PARALLEL,91 service_connect_blocking(EXCHANGE_SERIALIZE, 92 92 SERVICE_DEVMAN, DEVMAN_DRIVER, 0); 93 93 } … … 138 138 if (devman_driver_sess == NULL) 139 139 devman_driver_sess = 140 service_connect(EXCHANGE_ PARALLEL, SERVICE_DEVMAN,140 service_connect(EXCHANGE_SERIALIZE, SERVICE_DEVMAN, 141 141 DEVMAN_DRIVER, 0); 142 142 -
uspace/lib/c/generic/ns.c
rec7f8b1 rc4a8e4a 56 56 async_exchange_end(exch); 57 57 58 /*59 * FIXME Ugly hack to work around limitation of implementing60 * parallel exchanges using multiple connections. Shift out61 * first argument for non-initial connections.62 */63 async_sess_args_set(sess, arg2, arg3, 0);64 65 58 return sess; 66 59 } … … 73 66 async_connect_me_to_blocking(mgmt, exch, service, arg2, arg3); 74 67 async_exchange_end(exch); 75 76 /*77 * FIXME Ugly hack to work around limitation of implementing78 * parallel exchanges using multiple connections. Shift out79 * first argument for non-initial connections.80 */81 async_sess_args_set(sess, arg2, arg3, 0);82 68 83 69 return sess; -
uspace/lib/c/generic/str.c
rec7f8b1 rc4a8e4a 2 2 * Copyright (c) 2005 Martin Decky 3 3 * Copyright (c) 2008 Jiri Svoboda 4 * Copyright (c) 2011 Martin Sucha5 4 * All rights reserved. 6 5 * … … 719 718 720 719 dest[dlen - 1] = '\0'; 721 }722 723 /** Convert string to wide string.724 *725 * Convert string @a src to wide string. A new wide NULL-terminated726 * string will be allocated on the heap.727 *728 * @param src Source string.729 */730 wchar_t *str_to_awstr(const char *str)731 {732 size_t len = str_length(str);733 734 wchar_t *wstr = calloc(len+1, sizeof(wchar_t));735 if (wstr == NULL)736 return NULL;737 738 str_to_wstr(wstr, len + 1, str);739 return wstr;740 720 } 741 721 -
uspace/lib/c/include/async.h
rec7f8b1 rc4a8e4a 337 337 338 338 /* 339 * FIXME These functions just work around problems with parallel exchange340 * management. Proper solution needs to be implemented.341 */342 void async_sess_args_set(async_sess_t *sess, sysarg_t, sysarg_t, sysarg_t);343 344 /*345 339 * User-friendly wrappers for async_share_in_start(). 346 340 */ -
uspace/lib/c/include/str.h
rec7f8b1 rc4a8e4a 83 83 extern char *wstr_to_astr(const wchar_t *src); 84 84 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src); 85 extern wchar_t *str_to_awstr(const char *src);86 85 87 86 extern char *str_chr(const char *str, wchar_t ch); -
uspace/srv/devman/devman.h
rec7f8b1 rc4a8e4a 63 63 typedef struct fun_node fun_node_t; 64 64 65 typedef struct {66 fibril_mutex_t mutex;67 struct driver *driver;68 } client_t;69 70 65 typedef enum { 71 66 /** Driver has not been started. */ -
uspace/srv/devman/main.c
rec7f8b1 rc4a8e4a 65 65 static dev_tree_t device_tree; 66 66 67 static int init_running_drv(void *drv);68 69 67 /** Register running driver. */ 70 static driver_t *devman_driver_register(ipc_callid_t callid, ipc_call_t *call) 71 { 68 static driver_t *devman_driver_register(void) 69 { 70 ipc_call_t icall; 71 ipc_callid_t iid; 72 72 driver_t *driver = NULL; 73 74 log_msg(LVL_DEBUG, "devman_driver_register"); 75 76 iid = async_get_call(&icall); 77 if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) { 78 async_answer_0(iid, EREFUSED); 79 return NULL; 80 } 81 73 82 char *drv_name = NULL; 74 75 log_msg(LVL_DEBUG, "devman_driver_register");76 83 77 84 /* Get driver name. */ 78 85 int rc = async_data_write_accept((void **) &drv_name, true, 0, 0, 0, 0); 79 86 if (rc != EOK) { 80 async_answer_0( callid, rc);87 async_answer_0(iid, rc); 81 88 return NULL; 82 89 } … … 91 98 free(drv_name); 92 99 drv_name = NULL; 93 async_answer_0( callid, ENOENT);100 async_answer_0(iid, ENOENT); 94 101 return NULL; 95 102 } … … 105 112 driver->name); 106 113 fibril_mutex_unlock(&driver->driver_mutex); 107 async_answer_0( callid, EEXISTS);114 async_answer_0(iid, EEXISTS); 108 115 return NULL; 109 116 } … … 127 134 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.", 128 135 driver->name); 129 driver->sess = async_callback_receive(EXCHANGE_ PARALLEL);136 driver->sess = async_callback_receive(EXCHANGE_SERIALIZE); 130 137 if (!driver->sess) { 131 138 fibril_mutex_unlock(&driver->driver_mutex); 132 async_answer_0( callid, ENOTSUP);139 async_answer_0(iid, ENOTSUP); 133 140 return NULL; 134 141 } 135 /* FIXME: Work around problem with callback sessions */136 async_sess_args_set(driver->sess, DRIVER_DEVMAN, 0, 0);142 143 fibril_mutex_unlock(&driver->driver_mutex); 137 144 138 145 log_msg(LVL_NOTE, … … 140 147 driver->name); 141 148 142 /* 143 * Initialize the driver as running (e.g. pass assigned devices to it) 144 * in a separate fibril; the separate fibril is used to enable the 145 * driver to use devman service during the driver's initialization. 146 */ 147 fid_t fid = fibril_create(init_running_drv, driver); 148 if (fid == 0) { 149 log_msg(LVL_ERROR, "Failed to create initialization fibril " \ 150 "for driver `%s'.", driver->name); 151 fibril_mutex_unlock(&driver->driver_mutex); 152 async_answer_0(callid, ENOMEM); 153 return NULL; 154 } 155 156 fibril_add_ready(fid); 157 fibril_mutex_unlock(&driver->driver_mutex); 158 159 async_answer_0(callid, EOK); 149 async_answer_0(iid, EOK); 150 160 151 return driver; 161 152 } … … 438 429 static void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall) 439 430 { 440 client_t *client;441 driver_t *driver;442 443 431 /* Accept the connection. */ 444 432 async_answer_0(iid, EOK); 445 433 446 client = async_get_client_data(); 447 if (client == NULL) { 448 log_msg(LVL_ERROR, "Failed to allocate client data."); 449 return; 450 } 434 driver_t *driver = devman_driver_register(); 435 if (driver == NULL) 436 return; 437 438 /* 439 * Initialize the driver as running (e.g. pass assigned devices to it) 440 * in a separate fibril; the separate fibril is used to enable the 441 * driver to use devman service during the driver's initialization. 442 */ 443 fid_t fid = fibril_create(init_running_drv, driver); 444 if (fid == 0) { 445 log_msg(LVL_ERROR, "Failed to create initialization fibril " \ 446 "for driver `%s'.", driver->name); 447 return; 448 } 449 fibril_add_ready(fid); 451 450 452 451 while (true) { … … 457 456 break; 458 457 459 if (IPC_GET_IMETHOD(call) != DEVMAN_DRIVER_REGISTER) {460 fibril_mutex_lock(&client->mutex);461 driver = client->driver;462 fibril_mutex_unlock(&client->mutex);463 if (driver == NULL) {464 /* First call must be to DEVMAN_DRIVER_REGISTER */465 async_answer_0(callid, ENOTSUP);466 continue;467 }468 }469 470 458 switch (IPC_GET_IMETHOD(call)) { 471 case DEVMAN_DRIVER_REGISTER:472 fibril_mutex_lock(&client->mutex);473 if (client->driver != NULL) {474 fibril_mutex_unlock(&client->mutex);475 async_answer_0(callid, EINVAL);476 continue;477 }478 client->driver = devman_driver_register(callid, &call);479 fibril_mutex_unlock(&client->mutex);480 break;481 459 case DEVMAN_ADD_FUNCTION: 482 460 devman_add_function(callid, &call); … … 836 814 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 837 815 { 838 /* Select port. */816 /* Select interface. */ 839 817 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { 840 818 case DEVMAN_DRIVER: … … 862 840 } 863 841 864 static void *devman_client_data_create(void)865 {866 client_t *client;867 868 client = calloc(1, sizeof(client_t));869 if (client == NULL)870 return NULL;871 872 fibril_mutex_initialize(&client->mutex);873 return client;874 }875 876 static void devman_client_data_destroy(void *data)877 {878 free(data);879 }880 881 842 /** Initialize device manager internal structures. */ 882 843 static bool devman_init(void) … … 925 886 } 926 887 927 /* Set handlers for incoming connections. */ 928 async_set_client_data_constructor(devman_client_data_create); 929 async_set_client_data_destructor(devman_client_data_destroy); 888 /* Set a handler of incomming connections. */ 930 889 async_set_client_connection(devman_connection); 931 890
Note:
See TracChangeset
for help on using the changeset viewer.