Changes in / [9d58539:d9f53877] in mainline
- Files:
-
- 3 added
- 3 deleted
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/check.sh
r9d58539 rd9f53877 66 66 do 67 67 echo -n ">>>> Building $P... " 68 ( make distclean && make PROFILE=$P HANDS_OFF=y $1) >>/dev/null 2>>/dev/null68 ( make distclean && make PROFILE=$P HANDS_OFF=y "$@" ) >>/dev/null 2>>/dev/null 69 69 if [ $? -ne 0 ]; 70 70 then -
tools/checkers/clang.py
r9d58539 rd9f53877 114 114 for job in jobs: 115 115 if (not clang(rootdir, job)): 116 print 116 print() 117 117 print("Failed job: %s" % job) 118 118 return -
tools/checkers/stanse.py
r9d58539 rd9f53877 127 127 for job in jobs: 128 128 if (not stanse(rootdir, job)): 129 print 129 print() 130 130 print("Failed job: %s" % job) 131 131 return -
tools/checkers/vcc.py
r9d58539 rd9f53877 204 204 for job in jobs: 205 205 if (not vcc(vcc_path, rootdir, job)): 206 print 206 print() 207 207 print("Failed job: %s" % job) 208 208 return 209 209 210 print 210 print() 211 211 print("All jobs passed") 212 212 -
tools/filldir.py
r9d58539 rd9f53877 37 37 38 38 if len(sys.argv) < 3: 39 print 'Usage: filldir <parent-dir> <count>'39 print('Usage: filldir <parent-dir> <count>') 40 40 exit(2) 41 41 -
tools/gentestfile.py
r9d58539 rd9f53877 36 36 37 37 if len(sys.argv) < 2: 38 print "Usage: gentestfile.py <count of 64-bit numbers to output>"38 print("Usage: gentestfile.py <count of 64-bit numbers to output>") 39 39 exit() 40 40 41 m = long(sys.argv[1])41 m = int(sys.argv[1]) 42 42 i = 0 43 43 pow_2_64 = 2 ** 64 -
tools/mkfat.py
r9d58539 rd9f53877 168 168 """ 169 169 170 def mangle_fname(name): 170 LFN_ENTRY = """little: 171 uint8_t pos 172 uint16_t name1[5] 173 uint8_t attr 174 uint8_t type 175 uint8_t csum 176 uint16_t name2[6] 177 uint16_t fc 178 uint16_t name3[2] 179 """ 180 181 # Global variable to hold the file names in 8.3 format. Needed to 182 # keep track of "number" when creating a short fname from a LFN. 183 name83_list = [] 184 185 def name83(fname): 186 "Create a 8.3 name for the given fname" 187 171 188 # FIXME: filter illegal characters 172 parts = name.split('.') 173 189 parts = fname.split('.') 190 191 name = '' 192 ext = '' 193 lfn = False 194 195 if len(fname) > 11 : 196 lfn = True 197 174 198 if len(parts) > 0: 175 fname = parts[0] 176 else: 177 fname = '' 178 179 if len(fname) > 8: 180 sys.stdout.write("mkfat.py: error: Directory entry " + name + 181 " base name is longer than 8 characters\n") 182 sys.exit(1); 183 184 return (fname + ' ').upper()[0:8] 185 186 def mangle_ext(name): 187 # FIXME: filter illegal characters 188 parts = name.split('.') 189 190 if len(parts) > 1: 191 ext = parts[1] 192 else: 193 ext = '' 194 195 if len(parts) > 2: 196 sys.stdout.write("mkfat.py: error: Directory entry " + name + 197 " has more than one extension\n") 198 sys.exit(1); 199 200 if len(ext) > 3: 201 sys.stdout.write("mkfat.py: error: Directory entry " + name + 202 " extension is longer than 3 characters\n") 203 sys.exit(1); 204 205 return (ext + ' ').upper()[0:3] 199 name = parts[0] 200 if len(name) > 8 : 201 lfn = True 202 203 if len(parts) > 1 : 204 ext = parts[-1] 205 if len(ext) > 3 : 206 lfn = True 207 208 if len(parts) > 2 : 209 lfn = True 210 211 if (lfn == False) : 212 return (name.ljust(8)[0:8], ext.ljust(3)[0:3], False) 213 214 # For filenames with multiple extensions, we treat the last one 215 # as the actual extension. The rest of the filename is stripped 216 # of dots and concatenated to form the short name 217 for _name in parts[1:-1]: 218 name = name + _name 219 220 global name83_list 221 for number in range(1, 10000) : 222 number_str = '~' + str(number) 223 224 if len(name) + len(number_str) > 8 : 225 name = name[0:8 - len(number_str)] 226 227 name = name + number_str; 228 229 if (name + ext) not in name83_list : 230 break 231 232 name83_list.append(name + ext) 233 234 return (name.ljust(8)[0:8], ext.ljust(3)[0:3], True) 235 236 def get_utf16(name, l) : 237 "Create a int array out of a string which we can store in uint16_t arrays" 238 239 bs = [0xFFFF for i in range(l)] 240 241 for i in range(len(name)) : 242 bs[i] = ord(name[i]) 243 244 if (len(name) < l) : 245 bs[len(name)] = 0; 246 247 return bs 248 249 def create_lfn_entry(name_index) : 250 (name, index) = name_index 251 entry = xstruct.create(LFN_ENTRY) 252 253 entry.name1 = get_utf16(name[0:5], 5) 254 entry.name2 = get_utf16(name[5:11], 6) 255 entry.name3 = get_utf16(name[11:13], 2) 256 entry.pos = index 257 258 entry.attr = 0xF 259 entry.fc = 0 260 entry.type = 0 261 262 return entry 206 263 207 264 def create_dirent(name, directory, cluster, size): 265 208 266 dir_entry = xstruct.create(DIR_ENTRY) 209 267 210 dir_entry.name = mangle_fname(name).encode('ascii') 211 dir_entry.ext = mangle_ext(name).encode('ascii') 212 268 dir_entry.name, dir_entry.ext, lfn = name83(name) 269 270 dir_entry.name = dir_entry.name.upper().encode('ascii') 271 dir_entry.ext = dir_entry.ext.upper().encode('ascii') 272 213 273 if (directory): 214 274 dir_entry.attr = 0x30 … … 230 290 dir_entry.size = size 231 291 232 return dir_entry 292 293 if not lfn: 294 return [dir_entry] 295 296 n = (int) (len(name) / 13 + 1) 297 names = [(name[i * 13: (i + 1) * 13 + 1], i + 1) for i in range(n)] 298 299 entries = sorted(map (create_lfn_entry, names), reverse = True, key = lambda e : e.pos) 300 entries[0].pos |= 0x40 301 302 fname11 = str(dir_entry.name + dir_entry.ext) 303 304 csum = 0 305 for i in range(0, 11) : 306 csum = ((csum & 1) << 7) + (csum >> 1) + ord(fname11[i]) 307 csum = csum & 0xFF 308 309 for e in entries : 310 e.csum = csum; 311 312 entries.append(dir_entry) 313 314 return entries 233 315 234 316 def create_dot_dirent(empty_cluster): … … 288 370 if item.is_file: 289 371 rv = write_file(item, outf, cluster_size, data_start, fat, reserved_clusters) 290 directory. append(create_dirent(item.name, False, rv[0], rv[1]))372 directory.extend(create_dirent(item.name, False, rv[0], rv[1])) 291 373 elif item.is_dir: 292 374 rv = recursion(False, item.path, outf, cluster_size, root_start, data_start, fat, reserved_clusters, dirent_size, empty_cluster) 293 directory. append(create_dirent(item.name, True, rv[0], rv[1]))375 directory.extend(create_dirent(item.name, True, rv[0], rv[1])) 294 376 295 377 if (head): -
tools/mkuimage.py
r9d58539 rd9f53877 124 124 header.img_type = 2 # Kernel 125 125 header.compression = 0 # None 126 header.img_name = image_name 126 header.img_name = image_name.encode('ascii') 127 127 128 128 header_crc = calc_crc32(header.pack()) … … 140 140 signed_crc = zlib.crc32(byteseq, 0) 141 141 if signed_crc < 0: 142 return (long(signed_crc) + (long(2) ** long(32))) # 2^32L142 return signed_crc + (1 << 32) 143 143 else: 144 144 return signed_crc … … 148 148 def print_syntax(cmd): 149 149 print("syntax: " + cmd + " [<options>] <raw_image> <uImage>") 150 print 150 print() 151 151 print("\traw_image\tInput image name (raw binary data)") 152 152 print("\tuImage\t\tOutput uImage name (U-Boot image)") 153 print 153 print() 154 154 print("options:") 155 155 print("\t-name <name>\tImage name (default: 'Noname')") -
tools/xstruct.py
r9d58539 rd9f53877 32 32 33 33 import struct 34 import sys 34 35 import types 35 36 37 integer_types = (int, long) if sys.version < '3' else (int,) 38 36 39 ranges = { 37 'B': ( (int, long), 0x00, 0xff),38 'H': ( (int, long), 0x0000, 0xffff),39 'L': ( (int, long), 0x00000000, 0xffffffff),40 'Q': ( (int, long), 0x0000000000000000, 0xffffffffffffffff),41 'b': ( (int, long), -0x80, 0x7f),42 'h': ( (int, long), -0x8000, 0x7fff),43 'l': ( (int, long), -0x80000000, 0x7fffffff) ,44 'q': ( (int, long), -0x8000000000000000, 0x7fffffffffffffff),40 'B': (integer_types, 0x00, 0xff), 41 'H': (integer_types, 0x0000, 0xffff), 42 'L': (integer_types, 0x00000000, 0xffffffff), 43 'Q': (integer_types, 0x0000000000000000, 0xffffffffffffffff), 44 'b': (integer_types, -0x80, 0x7f), 45 'h': (integer_types, -0x8000, 0x7fff), 46 'l': (integer_types, -0x80000000, 0x7fffffff) , 47 'q': (integer_types, -0x8000000000000000, 0x7fffffffffffffff), 45 48 } 46 49 -
uspace/app/bdsh/cmds/builtins/cd/cd.c
r9d58539 rd9f53877 63 63 argc = cli_count_args(argv); 64 64 65 /* Handle cd -- -. Override to switch to a directory named '-' */ 66 bool hyphen_override = false; 67 if (argc == 3) { 68 if(!str_cmp(argv[1], "--")) { 69 hyphen_override = true; 70 argc--; 71 } 72 } 73 65 74 /* We don't yet play nice with whitespace, a getopt implementation should 66 75 * protect "quoted\ destination" as a single argument. Its not our job to … … 79 88 } 80 89 81 /* We have the correct # of arguments 82 *TODO: handle tidle (~) expansion? */90 /* We have the correct # of arguments */ 91 // TODO: handle tidle (~) expansion? */ 83 92 84 rc = chdir(argv[1]); 93 /* Handle 'cd -' first. */ 94 if (!str_cmp(argv[1], "-") && !hyphen_override) { 95 char *buffer = (char *) malloc(PATH_MAX); 96 if (!buffer) { 97 cli_error(CL_ENOMEM, "Cannot switch to previous directory"); 98 return CMD_FAILURE; 99 } 100 memset(buffer, 0, PATH_MAX); 101 getprevwd(buffer, PATH_MAX); 102 if (*buffer == '\0') { 103 cli_error(CL_EFAIL, "No previous directory to switch to"); 104 free(buffer); 105 return CMD_FAILURE; 106 } else { 107 rc = chdir(buffer); 108 free(buffer); 109 } 110 } else if (hyphen_override) { 111 /* Handles 'cd -- <dirname>'. 112 * Override for directory named '-'. 113 */ 114 rc = chdir(argv[2]); 115 } else { 116 rc = chdir(argv[1]); 117 } 85 118 86 119 if (rc == 0) { -
uspace/app/bdsh/cmds/modules/cat/cat.c
r9d58539 rd9f53877 52 52 #define CAT_VERSION "0.0.1" 53 53 #define CAT_DEFAULT_BUFLEN 1024 54 55 static const char *cat_oops = "That option is not yet supported\n"; 54 #define CAT_FULL_FILE 0 55 56 56 static const char *hexchars = "0123456789abcdef"; 57 57 … … 163 163 } 164 164 165 static unsigned int cat_file(const char *fname, size_t blen, bool hex) 165 static unsigned int cat_file(const char *fname, size_t blen, bool hex, 166 off64_t head, off64_t tail, bool tail_first) 166 167 { 167 168 int fd, bytes = 0, count = 0, reads = 0; 168 169 char *buff = NULL; 169 170 int i; 170 size_t offset = 0; 171 size_t offset = 0, copied_bytes = 0; 172 off64_t file_size = 0, length = 0; 171 173 172 174 fd = open(fname, O_RDONLY); … … 183 185 } 184 186 187 if (tail != CAT_FULL_FILE) { 188 file_size = lseek(fd, 0, SEEK_END); 189 if (head == CAT_FULL_FILE) { 190 head = file_size; 191 length = tail; 192 } else if (tail_first) { 193 length = head; 194 } else { 195 if (tail > head) 196 tail = head; 197 length = tail; 198 } 199 200 if (tail_first) { 201 lseek(fd, (tail >= file_size) ? 0 : (file_size - tail), SEEK_SET); 202 } else { 203 lseek(fd, ((head - tail) >= file_size) ? 0 : (head - tail), SEEK_SET); 204 } 205 } else 206 length = head; 207 185 208 do { 186 bytes = read(fd, buff, blen); 209 bytes = read(fd, buff + copied_bytes, ( 210 (length != CAT_FULL_FILE && length - (off64_t)count <= (off64_t)(blen - copied_bytes)) ? 211 (size_t)(length - count) : 212 (blen - copied_bytes) ) ); 213 bytes += copied_bytes; 214 copied_bytes = 0; 215 187 216 if (bytes > 0) { 188 count += bytes;189 217 buff[bytes] = '\0'; 190 218 offset = 0; … … 193 221 paged_char(hexchars[((uint8_t)buff[i])/16]); 194 222 paged_char(hexchars[((uint8_t)buff[i])%16]); 223 paged_char(((count+i+1) & 0xf) == 0 ? '\n' : ' '); 195 224 } 196 225 else { … … 199 228 /* Reached end of string */ 200 229 break; 230 } else if (c == U_SPECIAL && offset + 2 >= (size_t)bytes) { 231 /* If an extended character is cut off due to the size of the buffer, 232 we will copy it over to the next buffer so it can be read correctly. */ 233 copied_bytes = bytes - offset + 1; 234 memcpy(buff, buff + offset - 1, copied_bytes); 235 break; 201 236 } 202 237 paged_char(c); … … 204 239 205 240 } 241 count += bytes; 206 242 reads++; 207 243 } 208 } while (bytes > 0 && !should_quit );244 } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 209 245 210 246 close(fd); … … 223 259 int cmd_cat(char **argv) 224 260 { 225 unsigned int argc, i, ret = 0, buffer = 0; 261 unsigned int argc, i, ret = 0; 262 size_t buffer = 0; 226 263 int c, opt_ind; 264 aoff64_t head = CAT_FULL_FILE, tail = CAT_FULL_FILE; 227 265 bool hex = false; 228 266 bool more = false; 267 bool tailFirst = false; 229 268 sysarg_t rows, cols; 230 269 int rc; … … 254 293 return CMD_SUCCESS; 255 294 case 'H': 256 printf("%s", cat_oops); 257 return CMD_FAILURE; 295 if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK ) { 296 puts("Invalid head size\n"); 297 return CMD_FAILURE; 298 } 299 break; 258 300 case 't': 259 printf("%s", cat_oops); 260 return CMD_FAILURE; 301 if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK ) { 302 puts("Invalid tail size\n"); 303 return CMD_FAILURE; 304 } 305 if (head == CAT_FULL_FILE) 306 tailFirst = true; 307 break; 261 308 case 'b': 262 printf("%s", cat_oops); 309 if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK ) { 310 puts("Invalid buffer size\n"); 311 return CMD_FAILURE; 312 } 263 313 break; 264 314 case 'm': … … 279 329 } 280 330 281 if (buffer < = 0)331 if (buffer < 4) 282 332 buffer = CAT_DEFAULT_BUFLEN; 283 333 … … 295 345 296 346 for (i = optind; argv[i] != NULL && !should_quit; i++) 297 ret += cat_file(argv[i], buffer, hex );347 ret += cat_file(argv[i], buffer, hex, head, tail, tailFirst); 298 348 299 349 if (ret) -
uspace/app/bdsh/cmds/modules/cat/cat.h
r9d58539 rd9f53877 4 4 /* Prototypes for the cat command, excluding entry points */ 5 5 6 static unsigned int cat_file(const char *, size_t, bool);7 8 6 #endif /* CAT_H */ 9 7 -
uspace/app/bdsh/cmds/modules/cp/cp.c
r9d58539 rd9f53877 30 30 #include <stdlib.h> 31 31 #include <unistd.h> 32 #include <io/console.h> 33 #include <io/keycode.h> 32 34 #include <getopt.h> 33 35 #include <str.h> … … 46 48 47 49 static const char *cmdname = "cp"; 50 static console_ctrl_t *con; 48 51 49 52 static struct option const long_options[] = { 50 53 { "buffer", required_argument, 0, 'b' }, 51 54 { "force", no_argument, 0, 'f' }, 55 { "interactive", no_argument, 0, 'i'}, 52 56 { "recursive", no_argument, 0, 'r' }, 53 57 { "help", no_argument, 0, 'h' }, … … 139 143 } 140 144 145 static bool get_user_decision(bool bdefault, const char *message, ...) 146 { 147 va_list args; 148 149 va_start(args, message); 150 vprintf(message, args); 151 va_end(args); 152 153 while (true) { 154 kbd_event_t ev; 155 console_flush(con); 156 console_get_kbd_event(con, &ev); 157 if ((ev.type != KEY_PRESS) 158 || (ev.mods & (KM_CTRL | KM_ALT)) != 0) { 159 continue; 160 } 161 162 switch(ev.key) { 163 case KC_Y: 164 printf("y\n"); 165 return true; 166 case KC_N: 167 printf("n\n"); 168 return false; 169 case KC_ENTER: 170 printf("%c\n", bdefault ? 'Y' : 'N'); 171 return bdefault; 172 default: 173 break; 174 } 175 } 176 } 177 141 178 static int64_t do_copy(const char *src, const char *dest, 142 size_t blen, int vb, int recursive, int force )179 size_t blen, int vb, int recursive, int force, int interactive) 143 180 { 144 181 int r = -1; … … 192 229 /* e.g. cp file_name existing_file */ 193 230 194 /* dest already exists, if force is set we will 195 * try to remove it. 231 /* dest already exists, 232 * if force is set we will try to remove it. 233 * if interactive is set user input is required. 196 234 */ 197 if (force ) {235 if (force && !interactive) { 198 236 if (unlink(dest_path)) { 199 237 printf("Unable to remove %s\n", … … 201 239 goto exit; 202 240 } 241 } else if (!force && interactive) { 242 bool overwrite = get_user_decision(false, 243 "File already exists: %s. Overwrite? [y/N]: ", 244 dest_path); 245 if (overwrite) { 246 printf("Overwriting file: %s\n", dest_path); 247 if (unlink(dest_path)) { 248 printf("Unable to remove %s\n", dest_path); 249 goto exit; 250 } 251 } else { 252 printf("Not overwriting file: %s\n", dest_path); 253 r = 0; 254 goto exit; 255 } 203 256 } else { 204 printf(" file already exists: %s\n", dest_path);257 printf("File already exists: %s\n", dest_path); 205 258 goto exit; 206 259 } … … 302 355 /* Recursively call do_copy() */ 303 356 r = do_copy(src_dent, dest_dent, blen, vb, recursive, 304 force );357 force, interactive); 305 358 if (r) 306 359 goto exit; … … 315 368 return r; 316 369 } 317 318 370 319 371 static int64_t copy_file(const char *src, const char *dest, … … 380 432 " -v, --version Print version information and exit\n" 381 433 " -V, --verbose Be annoyingly noisy about what's being done\n" 382 " -f, --force Do not complain when <dest> exists\n" 434 " -f, --force Do not complain when <dest> exists (overrides a previous -i)\n" 435 " -i, --interactive Ask what to do when <dest> exists (overrides a previous -f)\n" 383 436 " -r, --recursive Copy entire directories\n" 384 437 " -b, --buffer ## Set the read buffer size to ##\n"; … … 397 450 unsigned int argc, verbose = 0; 398 451 int buffer = 0, recursive = 0; 399 int force = 0 ;452 int force = 0, interactive = 0; 400 453 int c, opt_ind; 401 454 int64_t ret; 402 455 456 con = console_init(stdin, stdout); 403 457 argc = cli_count_args(argv); 404 458 405 459 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 406 c = getopt_long(argc, argv, "hvVf rb:", long_options, &opt_ind);460 c = getopt_long(argc, argv, "hvVfirb:", long_options, &opt_ind); 407 461 switch (c) { 408 462 case 'h': … … 416 470 break; 417 471 case 'f': 472 interactive = 0; 418 473 force = 1; 474 break; 475 case 'i': 476 force = 0; 477 interactive = 1; 419 478 break; 420 479 case 'r': … … 426 485 "(should be a number greater than zero)\n", 427 486 cmdname); 487 console_done(con); 428 488 return CMD_FAILURE; 429 489 } … … 442 502 printf("%s: invalid number of arguments. Try %s --help\n", 443 503 cmdname, cmdname); 504 console_done(con); 444 505 return CMD_FAILURE; 445 506 } 446 507 447 508 ret = do_copy(argv[optind], argv[optind + 1], buffer, verbose, 448 recursive, force); 509 recursive, force, interactive); 510 511 console_done(con); 449 512 450 513 if (ret == 0) -
uspace/app/bdsh/cmds/modules/help/help.h
r9d58539 rd9f53877 3 3 4 4 /* Prototypes for the help command (excluding entry points) */ 5 static int is_mod_or_builtin(char *);6 5 7 6 #endif -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.h
r9d58539 rd9f53877 4 4 /* Prototypes for the mkdir command, excluding entry points */ 5 5 6 static unsigned int create_directory(const char *, unsigned int);7 6 #endif /* MKDIR_H */ 8 7 -
uspace/app/bdsh/cmds/modules/printf/TODO
r9d58539 rd9f53877 11 11 * Add width/precision options for number printings 12 12 * Add more format flags (%f %b ...) 13 -
uspace/app/bdsh/cmds/modules/printf/printf.c
r9d58539 rd9f53877 47 47 help_cmd_printf(HELP_SHORT); 48 48 printf( 49 "Usage: %s FORMAT [ARGS ...] \n"50 "Prints ARGS according to FORMAT. Number of expected arguments in\n"51 "FORMAT must be equals to the number of ARGS. Currently supported\n"52 "format flags are:\n",53 cmdname);49 "Usage: %s FORMAT [ARGS ...] \n" 50 "Prints ARGS according to FORMAT. Number of expected arguments in\n" 51 "FORMAT must be equals to the number of ARGS. Currently supported\n" 52 "format flags are:\n", 53 cmdname); 54 54 } 55 55 … … 172 172 break; 173 173 174 emit: putchar(ch); 175 esc_flag = false; 174 emit: 175 putchar(ch); 176 esc_flag = false; 176 177 } 177 178 } -
uspace/app/bdsh/cmds/modules/rm/rm.c
r9d58539 rd9f53877 46 46 #define RM_VERSION "0.0.1" 47 47 48 static rm_job_t rm;49 50 48 static struct option const long_options[] = { 51 49 { "help", no_argument, 0, 'h' }, … … 57 55 }; 58 56 57 /* Return values for rm_scope() */ 58 #define RM_BOGUS 0 59 #define RM_FILE 1 60 #define RM_DIR 2 61 62 /* Flags for rm_update() */ 63 #define _RM_ENTRY 0 64 #define _RM_ADVANCE 1 65 #define _RM_REWIND 2 66 #define _RM_EXIT 3 67 68 /* A simple job structure */ 69 typedef struct { 70 /* Options set at run time */ 71 unsigned int force; /* -f option */ 72 unsigned int recursive; /* -r option */ 73 unsigned int safe; /* -s option */ 74 75 /* Keeps track of the job in progress */ 76 int advance; /* How far deep we've gone since entering */ 77 DIR *entry; /* Entry point to the tree being removed */ 78 char *owd; /* Where we were when we invoked rm */ 79 char *cwd; /* Current directory being transversed */ 80 char *nwd; /* Next directory to be transversed */ 81 82 /* Counters */ 83 int f_removed; /* Number of files unlinked */ 84 int d_removed; /* Number of directories unlinked */ 85 } rm_job_t; 86 87 static rm_job_t rm; 88 89 static unsigned int rm_recursive(const char *); 90 59 91 static unsigned int rm_start(rm_job_t *rm) 60 92 { … … 95 127 if (NULL != rm->cwd) 96 128 free(rm->cwd); 129 } 130 131 static unsigned int rm_single(const char *path) 132 { 133 if (unlink(path)) { 134 cli_error(CL_EFAIL, "rm: could not remove file %s", path); 135 return 1; 136 } 137 return 0; 138 } 139 140 static unsigned int rm_scope(const char *path) 141 { 142 int fd; 143 DIR *dirp; 144 145 dirp = opendir(path); 146 if (dirp) { 147 closedir(dirp); 148 return RM_DIR; 149 } 150 151 fd = open(path, O_RDONLY); 152 if (fd > 0) { 153 close(fd); 154 return RM_FILE; 155 } 156 157 return RM_BOGUS; 97 158 } 98 159 … … 154 215 155 216 return ret + 1; 156 }157 158 static unsigned int rm_single(const char *path)159 {160 if (unlink(path)) {161 cli_error(CL_EFAIL, "rm: could not remove file %s", path);162 return 1;163 }164 return 0;165 }166 167 static unsigned int rm_scope(const char *path)168 {169 int fd;170 DIR *dirp;171 172 dirp = opendir(path);173 if (dirp) {174 closedir(dirp);175 return RM_DIR;176 }177 178 fd = open(path, O_RDONLY);179 if (fd > 0) {180 close(fd);181 return RM_FILE;182 }183 184 return RM_BOGUS;185 217 } 186 218 -
uspace/app/bdsh/cmds/modules/rm/rm.h
r9d58539 rd9f53877 2 2 #define RM_H 3 3 4 /* Return values for rm_scope() */5 #define RM_BOGUS 06 #define RM_FILE 17 #define RM_DIR 28 9 /* Flags for rm_update() */10 #define _RM_ENTRY 011 #define _RM_ADVANCE 112 #define _RM_REWIND 213 #define _RM_EXIT 314 15 /* A simple job structure */16 typedef struct {17 /* Options set at run time */18 unsigned int force; /* -f option */19 unsigned int recursive; /* -r option */20 unsigned int safe; /* -s option */21 22 /* Keeps track of the job in progress */23 int advance; /* How far deep we've gone since entering */24 DIR *entry; /* Entry point to the tree being removed */25 char *owd; /* Where we were when we invoked rm */26 char *cwd; /* Current directory being transversed */27 char *nwd; /* Next directory to be transversed */28 29 /* Counters */30 int f_removed; /* Number of files unlinked */31 int d_removed; /* Number of directories unlinked */32 } rm_job_t;33 34 35 4 /* Prototypes for the rm command, excluding entry points */ 36 static unsigned int rm_start(rm_job_t *);37 static void rm_end(rm_job_t *rm);38 static unsigned int rm_recursive(const char *);39 static unsigned int rm_single(const char *);40 static unsigned int rm_scope(const char *);41 5 42 6 #endif /* RM_H */ -
uspace/app/bdsh/cmds/modules/sleep/sleep.c
r9d58539 rd9f53877 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> 32 #include <unistd.h> 31 33 #include "config.h" 32 34 #include "util.h" … … 41 43 void help_cmd_sleep(unsigned int level) 42 44 { 43 printf("This is the %s help for '%s'.\n", 44 level ? EXT_HELP : SHORT_HELP, cmdname); 45 if (level == HELP_SHORT) { 46 printf("`%s' pauses for a given time interval\n", cmdname); 47 } else { 48 help_cmd_sleep(HELP_SHORT); 49 printf( 50 "Usage: %s <duration>\n" 51 "The duration is a decimal number of seconds.\n", 52 cmdname); 53 } 54 45 55 return; 56 } 57 58 /** Convert string containing decimal seconds to useconds_t. 59 * 60 * @param nptr Pointer to string. 61 * @param result Result of the conversion. 62 * @return EOK if conversion was successful. 63 */ 64 static int decimal_to_useconds(const char *nptr, useconds_t *result) 65 { 66 int ret; 67 uint64_t whole_seconds; 68 uint64_t frac_seconds; 69 char *endptr; 70 71 /* Check for whole seconds */ 72 if (*nptr == '.') { 73 whole_seconds = 0; 74 endptr = (char *)nptr; 75 } else { 76 ret = str_uint64_t(nptr, &endptr, 10, false, &whole_seconds); 77 if (ret != EOK) 78 return ret; 79 } 80 81 /* Check for fractional seconds */ 82 if (*endptr == '\0') { 83 frac_seconds = 0; 84 } else if (*endptr == '.' && endptr[1] == '\0') { 85 frac_seconds = 0; 86 } else if (*endptr == '.') { 87 nptr = endptr + 1; 88 ret = str_uint64_t(nptr, &endptr, 10, true, &frac_seconds); 89 if (ret != EOK) 90 return ret; 91 92 int ndigits = endptr - nptr; 93 for (; ndigits < 6; ndigits++) 94 frac_seconds *= 10; 95 for (; ndigits > 6; ndigits--) 96 frac_seconds /= 10; 97 } else { 98 return EINVAL; 99 } 100 101 /* Check for overflow */ 102 useconds_t total = whole_seconds * 1000000 + frac_seconds; 103 if (total / 1000000 != whole_seconds) 104 return EOVERFLOW; 105 106 *result = total; 107 108 return EOK; 46 109 } 47 110 … … 49 112 int cmd_sleep(char **argv) 50 113 { 114 int ret; 51 115 unsigned int argc; 52 u nsigned int i;116 useconds_t duration; 53 117 54 118 /* Count the arguments */ 55 for (argc = 0; argv[argc] != NULL; argc ++);119 argc = cli_count_args(argv); 56 120 57 printf("%s %s\n", TEST_ANNOUNCE, cmdname); 58 printf("%d arguments passed to %s", argc - 1, cmdname); 59 60 if (argc < 2) { 61 printf("\n"); 62 return CMD_SUCCESS; 121 if (argc != 2) { 122 printf("%s - incorrect number of arguments. Try `help %s'\n", 123 cmdname, cmdname); 124 return CMD_FAILURE; 63 125 } 64 126 65 printf(":\n"); 66 for (i = 1; i < argc; i++) 67 printf("[%d] -> %s\n", i, argv[i]); 127 ret = decimal_to_useconds(argv[1], &duration); 128 if (ret != EOK) { 129 printf("%s - invalid duration.\n", cmdname); 130 return CMD_FAILURE; 131 } 132 133 (void) usleep(duration); 68 134 69 135 return CMD_SUCCESS; -
uspace/app/sportdmp/sportdmp.c
r9d58539 rd9f53877 27 27 */ 28 28 29 #include <device/char_dev.h> 29 30 #include <errno.h> 31 #include <ipc/serial_ctl.h> 32 #include <loc.h> 30 33 #include <stdio.h> 31 #include <devman.h>32 #include <ipc/devman.h>33 #include <device/char_dev.h>34 #include <ipc/serial_ctl.h>35 34 36 35 #define BUF_SIZE 1 37 36 38 static void syntax_print() { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_path>\n"); 37 static void syntax_print(void) 38 { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n"); 40 40 } 41 41 42 42 int main(int argc, char **argv) 43 43 { 44 const char* devpath = "/hw/pci0/00:01.0/com1/a";44 const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a"; 45 45 sysarg_t baud = 9600; 46 46 … … 56 56 57 57 if (argc > 2) { 58 devpath = argv[2];58 svc_path = argv[2]; 59 59 } 60 60 … … 64 64 } 65 65 66 devman_handle_t device;67 int rc = devman_fun_get_handle(devpath, &device, IPC_FLAG_BLOCKING);66 service_id_t svc_id; 67 int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING); 68 68 if (rc != EOK) { 69 fprintf(stderr, "Cannot open device %s\n", devpath);69 fprintf(stderr, "Cannot find device service %s\n", svc_path); 70 70 return 1; 71 71 } 72 72 73 async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, device,73 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 74 74 IPC_FLAG_BLOCKING); 75 75 if (!sess) { 76 fprintf(stderr, " Cannot connect device\n");76 fprintf(stderr, "Failed connecting to service %s\n", svc_path); 77 77 } 78 78 … … 83 83 84 84 if (rc != EOK) { 85 fprintf(stderr, " Cannot setserial properties\n");85 fprintf(stderr, "Failed setting serial properties\n"); 86 86 return 2; 87 87 } … … 89 89 uint8_t *buf = (uint8_t *) malloc(BUF_SIZE); 90 90 if (buf == NULL) { 91 fprintf(stderr, " Cannot allocatebuffer\n");91 fprintf(stderr, "Failed allocating buffer\n"); 92 92 return 3; 93 93 } -
uspace/app/tester/hw/serial/serial1.c
r9d58539 rd9f53877 42 42 #include <async.h> 43 43 #include <ipc/services.h> 44 #include <ipc/devman.h> 45 #include <devman.h> 44 #include <loc.h> 46 45 #include <device/char_dev.h> 47 46 #include <str.h> … … 71 70 } 72 71 73 devman_handle_t handle;74 int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle,75 IPC_FLAG_BLOCKING);72 service_id_t svc_id; 73 int res = loc_service_get_id("devices/\\hw\\pci0\\00:01.0\\com1\\a", 74 &svc_id, IPC_FLAG_BLOCKING); 76 75 if (res != EOK) 77 return " Could not get serial device handle";78 79 async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,76 return "Failed getting serial port service ID"; 77 78 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 80 79 IPC_FLAG_BLOCKING); 81 80 if (!sess) 82 return " Unable to connectto serial device";81 return "Failed connecting to serial device"; 83 82 84 83 char *buf = (char *) malloc(cnt + 1); 85 84 if (buf == NULL) { 86 85 async_hangup(sess); 87 return "Failed to allocateinput buffer";86 return "Failed allocating input buffer"; 88 87 } 89 88 … … 112 111 free(buf); 113 112 async_hangup(sess); 114 return "Failed to setserial communication parameters";115 } 116 117 TPRINTF("Trying to read%zu characters from serial device "118 "( handle=%" PRIun ")\n", cnt, handle);113 return "Failed setting serial communication parameters"; 114 } 115 116 TPRINTF("Trying reading %zu characters from serial device " 117 "(svc_id=%" PRIun ")\n", cnt, svc_id); 119 118 120 119 size_t total = 0; … … 130 129 free(buf); 131 130 async_hangup(sess); 132 return "Failed read from serial device";131 return "Failed reading from serial device"; 133 132 } 134 133 … … 165 164 free(buf); 166 165 async_hangup(sess); 167 return "Failed writ eto serial device";166 return "Failed writing to serial device"; 168 167 } 169 168 -
uspace/app/websrv/websrv.c
r9d58539 rd9f53877 200 200 { 201 201 if (str_cmp(uri, "/") == 0) 202 uri = "/index.htm ";202 uri = "/index.html"; 203 203 204 204 char *fname; -
uspace/drv/bus/isa/isa.c
r9d58539 rd9f53877 66 66 #include <ops/hw_res.h> 67 67 68 #include <devman.h>69 #include <ipc/devman.h>70 68 #include <device/hw_res.h> 71 69 -
uspace/drv/bus/usb/uhcirh/port.c
r9d58539 rd9f53877 37 37 #include <str_error.h> 38 38 #include <async.h> 39 #include <devman.h>40 39 41 40 #include <usb/usb.h> /* usb_address_t */ -
uspace/drv/bus/usb/usbhub/port.c
r9d58539 rd9f53877 35 35 36 36 #include <bool.h> 37 #include <devman.h>38 37 #include <errno.h> 39 38 #include <str_error.h> -
uspace/drv/char/ns8250/ns8250.c
r9d58539 rd9f53877 74 74 #define DLAB_MASK (1 << 7) 75 75 76 /** Interrupt Enable Register definition. */ 77 #define NS8250_IER_RXREADY (1 << 0) 78 #define NS8250_IER_THRE (1 << 1) 79 #define NS8250_IER_RXSTATUS (1 << 2) 80 #define NS8250_IER_MODEM_STATUS (1 << 3) 81 82 /** Interrupt ID Register definition. */ 83 #define NS8250_IID_ACTIVE (1 << 0) 84 85 /** FIFO Control Register definition. */ 86 #define NS8250_FCR_FIFOENABLE (1 << 0) 87 #define NS8250_FCR_RXFIFORESET (1 << 1) 88 #define NS8250_FCR_TXFIFORESET (1 << 2) 89 #define NS8250_FCR_DMAMODE (1 << 3) 90 #define NS8250_FCR_RXTRIGGERLOW (1 << 6) 91 #define NS8250_FCR_RXTRIGGERHI (1 << 7) 92 93 /** Line Control Register definition. */ 94 #define NS8250_LCR_STOPBITS (1 << 2) 95 #define NS8250_LCR_PARITY (1 << 3) 96 #define NS8250_LCR_SENDBREAK (1 << 6) 97 #define NS8250_LCR_DLAB (1 << 7) 98 99 /** Modem Control Register definition. */ 100 #define NS8250_MCR_DTR (1 << 0) 101 #define NS8250_MCR_RTS (1 << 1) 102 #define NS8250_MCR_OUT1 (1 << 2) 103 #define NS8250_MCR_OUT2 (1 << 3) 104 #define NS8250_MCR_LOOPBACK (1 << 4) 105 #define NS8250_MCR_ALL (0x1f) 106 107 /** Line Status Register definition. */ 108 #define NS8250_LSR_RXREADY (1 << 0) 109 #define NS8250_LSR_OE (1 << 1) 110 #define NS8250_LSR_PE (1 << 2) 111 #define NS8250_LSR_FE (1 << 3) 112 #define NS8250_LSR_BREAK (1 << 4) 113 #define NS8250_LSR_THRE (1 << 5) 114 #define NS8250_LSR_TSE (1 << 6) 115 116 /** Modem Status Register definition. */ 117 #define NS8250_MSR_DELTACTS (1 << 0) 118 #define NS8250_MSR_DELTADSR (1 << 1) 119 #define NS8250_MSR_RITRAILING (1 << 2) 120 #define NS8250_MSR_DELTADCD (1 << 3) 121 #define NS8250_MSR_CTS (1 << 4) 122 #define NS8250_MSR_DSR (1 << 5) 123 #define NS8250_MSR_RI (1 << 6) 124 #define NS8250_MSR_DCD (1 << 7) 125 #define NS8250_MSR_SIGNALS (NS8250_MSR_CTS | NS8250_MSR_DSR \ 126 | NS8250_MSR_RI | NS8250_MSR_DCD) 127 76 128 /** Obtain soft-state structure from function node */ 77 129 #define NS8250(fnode) ((ns8250_t *) ((fnode)->dev->driver_data)) … … 96 148 } stop_bit_t; 97 149 150 /** 8250 UART registers layout. */ 151 typedef struct { 152 ioport8_t data; /**< Data register. */ 153 ioport8_t ier; /**< Interrupt Enable Reg. */ 154 ioport8_t iid; /**< Interrupt ID Reg. */ 155 ioport8_t lcr; /**< Line Control Reg. */ 156 ioport8_t mcr; /**< Modem Control Reg. */ 157 ioport8_t lsr; /**< Line Status Reg. */ 158 ioport8_t msr; /**< Modem Status Reg. */ 159 } ns8250_regs_t; 160 98 161 /** The driver data for the serial port devices. */ 99 162 typedef struct ns8250 { … … 102 165 /** DDF function node */ 103 166 ddf_fun_t *fun; 167 /** I/O registers **/ 168 ns8250_regs_t *regs; 104 169 /** Is there any client conntected to the device? */ 105 170 bool client_connected; … … 124 189 * otherwise. 125 190 */ 126 static bool ns8250_received( ioport8_t *port)127 { 128 return (pio_read_8( port + 5) & 1) != 0;191 static bool ns8250_received(ns8250_regs_t *regs) 192 { 193 return (pio_read_8(®s->lsr) & NS8250_LSR_RXREADY) != 0; 129 194 } 130 195 … … 134 199 * @return The data read. 135 200 */ 136 static uint8_t ns8250_read_8( ioport8_t *port)137 { 138 return pio_read_8( port);201 static uint8_t ns8250_read_8(ns8250_regs_t *regs) 202 { 203 return pio_read_8(®s->data); 139 204 } 140 205 … … 143 208 * @param port The base address of the serial port device's ports. 144 209 */ 145 static bool is_transmit_empty( ioport8_t *port)146 { 147 return (pio_read_8( port + 5) & 0x20) != 0;210 static bool is_transmit_empty(ns8250_regs_t *regs) 211 { 212 return (pio_read_8(®s->lsr) & NS8250_LSR_THRE) != 0; 148 213 } 149 214 … … 153 218 * @param c The character to be written to the serial port device. 154 219 */ 155 static void ns8250_write_8( ioport8_t *port, uint8_t c)156 { 157 while (!is_transmit_empty( port))220 static void ns8250_write_8(ns8250_regs_t *regs, uint8_t c) 221 { 222 while (!is_transmit_empty(regs)) 158 223 ; 159 224 160 pio_write_8( port, c);225 pio_write_8(®s->data, c); 161 226 } 162 227 … … 193 258 { 194 259 fibril_mutex_lock(&ns->mutex); 195 ns8250_write_8(ns-> port, c);260 ns8250_write_8(ns->regs, c); 196 261 fibril_mutex_unlock(&ns->mutex); 197 262 } … … 212 277 ns8250_putchar(ns, (uint8_t) buf[idx]); 213 278 214 return 0;279 return count; 215 280 } 216 281 … … 266 331 return false; 267 332 } 333 334 ns->regs = (ns8250_regs_t *)ns->port; 268 335 269 336 return true; … … 279 346 ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name); 280 347 281 ioport8_t *port_addr = ns->port;282 348 bool res = true; 283 349 uint8_t olddata; 284 350 285 olddata = pio_read_8( port_addr + 4);286 287 pio_write_8( port_addr + 4, 0x10);288 if (pio_read_8( port_addr + 6) & 0xf0)351 olddata = pio_read_8(&ns->regs->mcr); 352 353 pio_write_8(&ns->regs->mcr, NS8250_MCR_LOOPBACK); 354 if (pio_read_8(&ns->regs->msr) & NS8250_MSR_SIGNALS) 289 355 res = false; 290 356 291 pio_write_8(port_addr + 4, 0x1f); 292 if ((pio_read_8(port_addr + 6) & 0xf0) != 0xf0) 357 pio_write_8(&ns->regs->mcr, NS8250_MCR_ALL); 358 if ((pio_read_8(&ns->regs->msr) & NS8250_MSR_SIGNALS) 359 != NS8250_MSR_SIGNALS) 293 360 res = false; 294 361 295 pio_write_8( port_addr + 4, olddata);362 pio_write_8(&ns->regs->mcr, olddata); 296 363 297 364 if (!res) { … … 390 457 * @param port The base address of the serial port device's ports. 391 458 */ 392 static inline void ns8250_port_interrupts_enable(ioport8_t *port) 393 { 394 pio_write_8(port + 1, 0x1); /* Interrupt when data received. */ 395 pio_write_8(port + 4, 0xB); 459 static inline void ns8250_port_interrupts_enable(ns8250_regs_t *regs) 460 { 461 /* Interrupt when data received. */ 462 pio_write_8(®s->ier, NS8250_IER_RXREADY); 463 pio_write_8(®s->mcr, NS8250_MCR_DTR | NS8250_MCR_RTS 464 | NS8250_MCR_OUT2); 396 465 } 397 466 … … 400 469 * @param port The base address of the serial port device's ports 401 470 */ 402 static inline void ns8250_port_interrupts_disable( ioport8_t *port)403 { 404 pio_write_8( port + 1, 0x0); /* Disable all interrupts. */471 static inline void ns8250_port_interrupts_disable(ns8250_regs_t *regs) 472 { 473 pio_write_8(®s->ier, 0x0); /* Disable all interrupts. */ 405 474 } 406 475 … … 431 500 432 501 /* Enable interrupt on the serial port. */ 433 ns8250_port_interrupts_enable(ns-> port);502 ns8250_port_interrupts_enable(ns->regs); 434 503 435 504 return EOK; … … 443 512 * @param port The base address of the serial port device's ports. 444 513 */ 445 static inline void enable_dlab( ioport8_t *port)446 { 447 uint8_t val = pio_read_8( port + 3);448 pio_write_8( port + 3, val | DLAB_MASK);514 static inline void enable_dlab(ns8250_regs_t *regs) 515 { 516 uint8_t val = pio_read_8(®s->lcr); 517 pio_write_8(®s->lcr, val | NS8250_LCR_DLAB); 449 518 } 450 519 … … 453 522 * @param port The base address of the serial port device's ports. 454 523 */ 455 static inline void clear_dlab( ioport8_t *port)456 { 457 uint8_t val = pio_read_8( port + 3);458 pio_write_8( port + 3, val & (~DLAB_MASK));524 static inline void clear_dlab(ns8250_regs_t *regs) 525 { 526 uint8_t val = pio_read_8(®s->lcr); 527 pio_write_8(®s->lcr, val & (~NS8250_LCR_DLAB)); 459 528 } 460 529 … … 466 535 * if the specified baud_rate is not valid). 467 536 */ 468 static int ns8250_port_set_baud_rate( ioport8_t *port, unsigned int baud_rate)537 static int ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate) 469 538 { 470 539 uint16_t divisor; … … 482 551 483 552 /* Enable DLAB to be able to access baud rate divisor. */ 484 enable_dlab( port);553 enable_dlab(regs); 485 554 486 555 /* Set divisor low byte. */ 487 pio_write_8( port + 0, div_low);556 pio_write_8(®s->data, div_low); 488 557 /* Set divisor high byte. */ 489 pio_write_8( port + 1, div_high);490 491 clear_dlab( port);558 pio_write_8(®s->ier, div_high); 559 560 clear_dlab(regs); 492 561 493 562 return EOK; … … 499 568 * @param baud_rate The ouput parameter to which the baud rate is stored. 500 569 */ 501 static unsigned int ns8250_port_get_baud_rate( ioport8_t *port)570 static unsigned int ns8250_port_get_baud_rate(ns8250_regs_t *regs) 502 571 { 503 572 uint16_t divisor; … … 505 574 506 575 /* Enable DLAB to be able to access baud rate divisor. */ 507 enable_dlab( port);576 enable_dlab(regs); 508 577 509 578 /* Get divisor low byte. */ 510 div_low = pio_read_8( port + 0);579 div_low = pio_read_8(®s->data); 511 580 /* Get divisor high byte. */ 512 div_high = pio_read_8( port + 1);513 514 clear_dlab( port);581 div_high = pio_read_8(®s->ier); 582 583 clear_dlab(regs); 515 584 516 585 divisor = (div_high << 8) | div_low; … … 525 594 * @param stop_bits The number of stop bits used (one or two). 526 595 */ 527 static void ns8250_port_get_com_props( ioport8_t *port, unsigned int *parity,596 static void ns8250_port_get_com_props(ns8250_regs_t *regs, unsigned int *parity, 528 597 unsigned int *word_length, unsigned int *stop_bits) 529 598 { 530 599 uint8_t val; 531 600 532 val = pio_read_8( port + 3);533 *parity = ((val >> 3) & 7);601 val = pio_read_8(®s->lcr); 602 *parity = ((val >> NS8250_LCR_PARITY) & 7); 534 603 535 604 switch (val & 3) { … … 548 617 } 549 618 550 if ((val >> 2) & 1)619 if ((val >> NS8250_LCR_STOPBITS) & 1) 551 620 *stop_bits = 2; 552 621 else … … 562 631 * is invalid. 563 632 */ 564 static int ns8250_port_set_com_props( ioport8_t *port, unsigned int parity,633 static int ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity, 565 634 unsigned int word_length, unsigned int stop_bits) 566 635 { … … 586 655 switch (stop_bits) { 587 656 case 1: 588 val |= ONE_STOP_BIT << 2;657 val |= ONE_STOP_BIT << NS8250_LCR_STOPBITS; 589 658 break; 590 659 case 2: 591 val |= TWO_STOP_BITS << 2;660 val |= TWO_STOP_BITS << NS8250_LCR_STOPBITS; 592 661 break; 593 662 default: … … 601 670 case SERIAL_MARK_PARITY: 602 671 case SERIAL_SPACE_PARITY: 603 val |= parity << 3;672 val |= parity << NS8250_LCR_PARITY; 604 673 break; 605 674 default: … … 607 676 } 608 677 609 pio_write_8( port + 3, val);678 pio_write_8(®s->lcr, val); 610 679 611 680 return EOK; … … 620 689 static void ns8250_initialize_port(ns8250_t *ns) 621 690 { 622 ioport8_t *port = ns->port;623 624 691 /* Disable interrupts. */ 625 ns8250_port_interrupts_disable( port);692 ns8250_port_interrupts_disable(ns->regs); 626 693 /* Set baud rate. */ 627 ns8250_port_set_baud_rate( port, 38400);694 ns8250_port_set_baud_rate(ns->regs, 38400); 628 695 /* 8 bits, no parity, two stop bits. */ 629 ns8250_port_set_com_props( port, SERIAL_NO_PARITY, 8, 2);696 ns8250_port_set_com_props(ns->regs, SERIAL_NO_PARITY, 8, 2); 630 697 /* Enable FIFO, clear them, with 14-byte threshold. */ 631 pio_write_8(port + 2, 0xC7); 698 pio_write_8(&ns->regs->iid, NS8250_FCR_FIFOENABLE 699 | NS8250_FCR_RXFIFORESET | NS8250_FCR_TXFIFORESET 700 | NS8250_FCR_RXTRIGGERLOW | NS8250_FCR_RXTRIGGERHI); 632 701 /* 633 702 * RTS/DSR set (Request to Send and Data Terminal Ready lines enabled), 634 703 * Aux Output2 set - needed for interrupts. 635 704 */ 636 pio_write_8(port + 4, 0x0B); 705 pio_write_8(&ns->regs->mcr, NS8250_MCR_DTR | NS8250_MCR_RTS 706 | NS8250_MCR_OUT2); 637 707 } 638 708 … … 644 714 { 645 715 /* Disable FIFO */ 646 pio_write_8( ns->port + 2, 0x00);716 pio_write_8(&ns->regs->iid, 0x00); 647 717 /* Disable DTR, RTS, OUT1, OUT2 (int. enable) */ 648 pio_write_8( ns->port + 4, 0x00);718 pio_write_8(&ns->regs->mcr, 0x00); 649 719 /* Disable all interrupts from the port */ 650 ns8250_port_interrupts_disable(ns-> port);720 ns8250_port_interrupts_disable(ns->regs); 651 721 } 652 722 … … 658 728 static void ns8250_read_from_device(ns8250_t *ns) 659 729 { 660 ioport8_t *port = ns->port;730 ns8250_regs_t *regs = ns->regs; 661 731 bool cont = true; 662 732 … … 664 734 fibril_mutex_lock(&ns->mutex); 665 735 666 cont = ns8250_received( port);736 cont = ns8250_received(regs); 667 737 if (cont) { 668 uint8_t val = ns8250_read_8( port);738 uint8_t val = ns8250_read_8(regs); 669 739 670 740 if (ns->client_connected) { … … 896 966 { 897 967 ns8250_t *data = (ns8250_t *) dev->driver_data; 898 ioport8_t *port = data->port;968 ns8250_regs_t *regs = data->regs; 899 969 900 970 fibril_mutex_lock(&data->mutex); 901 ns8250_port_interrupts_disable( port);902 *baud_rate = ns8250_port_get_baud_rate( port);903 ns8250_port_get_com_props( port, parity, word_length, stop_bits);904 ns8250_port_interrupts_enable( port);971 ns8250_port_interrupts_disable(regs); 972 *baud_rate = ns8250_port_get_baud_rate(regs); 973 ns8250_port_get_com_props(regs, parity, word_length, stop_bits); 974 ns8250_port_interrupts_enable(regs); 905 975 fibril_mutex_unlock(&data->mutex); 906 976 … … 927 997 928 998 ns8250_t *data = (ns8250_t *) dev->driver_data; 929 ioport8_t *port = data->port;999 ns8250_regs_t *regs = data->regs; 930 1000 int ret; 931 1001 932 1002 fibril_mutex_lock(&data->mutex); 933 ns8250_port_interrupts_disable( port);934 ret = ns8250_port_set_baud_rate( port, baud_rate);1003 ns8250_port_interrupts_disable(regs); 1004 ret = ns8250_port_set_baud_rate(regs, baud_rate); 935 1005 if (ret == EOK) 936 ret = ns8250_port_set_com_props( port, parity, word_length, stop_bits);937 ns8250_port_interrupts_enable( port);1006 ret = ns8250_port_set_com_props(regs, parity, word_length, stop_bits); 1007 ns8250_port_interrupts_enable(regs); 938 1008 fibril_mutex_unlock(&data->mutex); 939 1009 -
uspace/drv/char/ps2mouse/main.c
r9d58539 rd9f53877 35 35 #include <libarch/inttypes.h> 36 36 #include <ddf/driver.h> 37 #include <devman.h>38 37 #include <device/hw_res_parsed.h> 39 38 #include <errno.h> -
uspace/drv/char/xtkbd/main.c
r9d58539 rd9f53877 35 35 #include <libarch/inttypes.h> 36 36 #include <ddf/driver.h> 37 #include <devman.h>38 37 #include <device/hw_res_parsed.h> 39 38 #include <errno.h> -
uspace/drv/infrastructure/root/root.c
r9d58539 rd9f53877 53 53 #include <ddf/driver.h> 54 54 #include <ddf/log.h> 55 #include <devman.h>56 #include <ipc/devman.h>57 55 58 56 #define NAME "root" -
uspace/drv/infrastructure/rootpc/rootpc.c
r9d58539 rd9f53877 48 48 #include <ddf/driver.h> 49 49 #include <ddf/log.h> 50 #include <devman.h>51 #include <ipc/devman.h>52 50 #include <ipc/dev_iface.h> 53 51 #include <ops/hw_res.h> -
uspace/drv/nic/e1k/e1k.c
r9d58539 rd9f53877 46 46 #include <ddf/log.h> 47 47 #include <ddf/interrupt.h> 48 #include <devman.h>49 48 #include <device/hw_res_parsed.h> 50 49 #include <device/pci.h> -
uspace/lib/c/generic/vfs/vfs.c
r9d58539 rd9f53877 58 58 static async_sess_t *vfs_sess = NULL; 59 59 60 /* Current (working) directory. */ 60 61 static FIBRIL_MUTEX_INITIALIZE(cwd_mutex); 61 62 62 static int cwd_fd = -1; 63 63 static char *cwd_path = NULL; 64 64 static size_t cwd_size = 0; 65 66 /* Previous directory. */ 67 static FIBRIL_MUTEX_INITIALIZE(pwd_mutex); 68 static int pwd_fd = -1; 69 static char *pwd_path = NULL; 70 static size_t pwd_size = 0; 71 65 72 66 73 /** Start an async exchange on the VFS session. … … 751 758 fibril_mutex_lock(&cwd_mutex); 752 759 753 if (cwd_fd >= 0) 754 close(cwd_fd); 755 756 757 if (cwd_path) 758 free(cwd_path); 759 760 761 fibril_mutex_lock(&pwd_mutex); 762 763 if (pwd_fd >= 0) 764 close(pwd_fd); 765 766 767 if (pwd_path) 768 free(pwd_path); 769 770 771 pwd_fd = cwd_fd; 772 pwd_path = cwd_path; 773 pwd_size = cwd_size; 774 775 fibril_mutex_unlock(&pwd_mutex); 776 760 777 cwd_fd = fd; 761 778 cwd_path = abs; … … 781 798 fibril_mutex_unlock(&cwd_mutex); 782 799 800 return buf; 801 } 802 803 804 char *getprevwd(char *buf, size_t size) 805 { 806 if (size == 0) 807 return NULL; 808 809 fibril_mutex_lock(&pwd_mutex); 810 811 if ((pwd_size == 0) || (size < pwd_size + 1)) { 812 fibril_mutex_unlock(&pwd_mutex); 813 return NULL; 814 } 815 816 str_cpy(buf, size, pwd_path); 817 fibril_mutex_unlock(&pwd_mutex); 818 783 819 return buf; 784 820 } -
uspace/lib/c/include/unistd.h
r9d58539 rd9f53877 58 58 #define getpagesize() (PAGE_SIZE) 59 59 60 extern int dup2(int oldfd, int newfd);60 extern int dup2(int, int); 61 61 62 62 extern ssize_t write(int, const void *, size_t); … … 73 73 extern int unlink(const char *); 74 74 75 extern char *getcwd(char *buf, size_t); 75 extern char *getcwd(char *, size_t); 76 extern char *getprevwd(char *, size_t); 76 77 extern int rmdir(const char *); 77 78 extern int chdir(const char *); -
uspace/lib/net/generic/net_remote.c
r9d58539 rd9f53877 40 40 #include <malloc.h> 41 41 #include <async.h> 42 #include <devman.h>43 42 #include <generic.h> 44 43 #include <net/modules.h> -
uspace/lib/usb/src/ddfiface.c
r9d58539 rd9f53877 33 33 * Implementations of DDF interfaces functions (actual implementation). 34 34 */ 35 #include <ipc/devman.h>36 35 #include <devman.h> 37 36 #include <async.h> -
uspace/lib/usbvirt/src/ipc_dev.c
r9d58539 rd9f53877 38 38 #include <assert.h> 39 39 #include <async.h> 40 #include <devman.h>41 40 #include <usbvirt/device.h> 42 41 #include <usbvirt/ipc.h> -
uspace/lib/usbvirt/src/ipc_hc.c
r9d58539 rd9f53877 38 38 #include <assert.h> 39 39 #include <async.h> 40 #include <devman.h>41 40 #include <usbvirt/device.h> 42 41 #include <usbvirt/ipc.h>
Note:
See TracChangeset
for help on using the changeset viewer.