Changeset 904b1bc in mainline for uspace/lib
- Timestamp:
- 2018-05-22T10:36:58Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a4eb3ba2
- Parents:
- 4f8772d4
- git-author:
- Jiri Svoboda <jiri@…> (2018-05-21 17:36:30)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-05-22 10:36:58)
- Location:
- uspace/lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/compress/inflate.c
r4f8772d4 r904b1bc 319 319 uint16_t *symbol) 320 320 { 321 uint16_t code = 0; /* Decoded bits */ 322 size_t first = 0; /* First code of the given length */ 323 size_t index = 0; /* Index of the first code of the given length 324 in the symbol table */ 325 326 size_t len; /* Current number of bits in the code */ 321 /* Decode bits */ 322 uint16_t code = 0; 323 324 /* First code of the given length */ 325 size_t first = 0; 326 327 /* 328 * Index of the first code of the given length 329 * in the symbol table 330 */ 331 size_t index = 0; 332 333 /* Current number of bits in the code */ 334 size_t len; 335 327 336 for (len = 1; len <= MAX_HUFFMAN_BIT; len++) { 328 337 /* Get next bit */ -
uspace/lib/drv/generic/logbuf.c
r4f8772d4 r904b1bc 40 40 #define REMAINDER_STR_FMT " (%zu)..." 41 41 /** Expected max size of the remainder string. 42 * String + terminator + number width (enough for 4GB).*/ 42 * String + terminator + number width (enough for 4GB). 43 */ 43 44 #define REMAINDER_STR_LEN (5 + 1 + 10) 44 45 … … 50 51 /** Space between two groups. */ 51 52 #define SPACE_GROUP " " 53 54 /** Formats the dump with space before, takes care of type casting (ugly). */ 55 #define _FORMAT(digits, bits) \ 56 snprintf(dump, dump_size, "%s%0" #digits PRIx##bits, \ 57 space_before, ((uint##bits##_t *)buf)[0]); 52 58 53 59 /** Dump one item into given buffer. … … 77 83 buf += index * item_size; 78 84 79 /* Formats the dump with space before, takes care of type casting (ugly). */80 #define _FORMAT(digits, bits) \81 snprintf(dump, dump_size, "%s%0" #digits PRIx##bits, \82 space_before, ((uint##bits##_t *)buf)[0]);83 84 85 switch (item_size) { 85 86 case 4: … … 90 91 return _FORMAT(2, 8); 91 92 } 92 #undef _FORMAT93 93 } 94 94 -
uspace/lib/hound/src/protocol.c
r4f8772d4 r904b1bc 79 79 80 80 81 /* ***81 /* 82 82 * CLIENT 83 * ***/83 */ 84 84 85 85 /** Well defined service name */ … … 309 309 int flags, pcm_format_t format, size_t bsize) 310 310 { 311 const format_convert_t c = { .f = { 312 .channels = format.channels, 313 .rate = format.sampling_rate / 100, 314 .format = format.sample_format, 315 }}; 311 const format_convert_t c = { 312 .f = { 313 .channels = format.channels, 314 .rate = format.sampling_rate / 100, 315 .format = format.sample_format, 316 } 317 }; 318 316 319 return async_req_4_0(exch, IPC_M_HOUND_STREAM_ENTER, CAP_HANDLE_RAW(id), 317 320 flags, c.arg, bsize); … … 362 365 } 363 366 364 /* ***367 /* 365 368 * SERVER 366 * ***/369 */ 367 370 368 371 static void hound_server_read_data(void *stream); … … 463 466 if (conn) 464 467 ret = async_data_write_accept( 465 (void **)&conn_name, true, 0, 0, 0, 0);468 (void **)&conn_name, true, 0, 0, 0, 0); 466 469 467 470 if (ret == EOK) … … 559 562 case IPC_M_HOUND_STREAM_ENTER: 560 563 /* check interface functions */ 561 if (!server_iface || !server_iface->is_record_context 562 || !server_iface->add_stream563 ||!server_iface->rem_stream) {564 if (!server_iface || !server_iface->is_record_context || 565 !server_iface->add_stream || 566 !server_iface->rem_stream) { 564 567 async_answer_0(chandle, ENOTSUP); 565 568 break; … … 569 572 id = (cap_handle_t) IPC_GET_ARG1(call); 570 573 flags = IPC_GET_ARG2(call); 571 const format_convert_t c = { .arg = IPC_GET_ARG3(call)};574 const format_convert_t c = { .arg = IPC_GET_ARG3(call) }; 572 575 const pcm_format_t f = { 573 574 575 576 .sampling_rate = c.f.rate * 100, 577 .channels = c.f.channels, 578 .sample_format = c.f.format, 576 579 }; 577 580 size_t bsize = IPC_GET_ARG4(call); … … 587 590 server_iface->server, id); 588 591 if (rec) { 589 if (server_iface->stream_data_read) {592 if (server_iface->stream_data_read) { 590 593 async_answer_0(chandle, EOK); 591 594 /* start answering read calls */ … … 631 634 errno_t ret_answer = EOK; 632 635 /* accept data write or drain */ 633 while (async_data_write_receive_call(&chandle, &call, &size) 634 ||(IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {636 while (async_data_write_receive_call(&chandle, &call, &size) || 637 (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) { 635 638 /* check drain first */ 636 639 if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) { … … 660 663 } 661 664 } 662 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 663 ?EOK : EINVAL;665 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT ? 666 EOK : EINVAL; 664 667 665 668 async_answer_0(chandle, ret); … … 678 681 errno_t ret_answer = EOK; 679 682 /* accept data read and drain */ 680 while (async_data_read_receive_call(&chandle, &call, &size) 681 ||(IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {683 while (async_data_read_receive_call(&chandle, &call, &size) || 684 (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) { 682 685 /* drain does not make much sense but it is allowed */ 683 686 if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) { … … 704 707 } 705 708 } 706 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 707 ?EOK : EINVAL;709 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT ? 710 EOK : EINVAL; 708 711 709 712 async_answer_0(chandle, ret); … … 711 714 712 715 713 /* **716 /* 714 717 * SERVER SIDE 715 * **/718 */ 716 719 717 720 /** -
uspace/lib/label/include/std/fat.h
r4f8772d4 r904b1bc 51 51 52 52 typedef struct fat_bs { 53 uint8_t ji[3]; /**< Jump instruction. */ 53 /** Jump instruction */ 54 uint8_t ji[3]; 54 55 uint8_t oem_name[8]; 56 55 57 /* BIOS Parameter Block */ 56 uint16_t bps; /**< Bytes per sector. */ 57 uint8_t spc; /**< Sectors per cluster. */ 58 uint16_t rscnt; /**< Reserved sector count. */ 59 uint8_t fatcnt; /**< Number of FATs. */ 60 uint16_t root_ent_max; /**< Maximum number of root directory 61 entries. */ 62 uint16_t totsec16; /**< Total sectors. 16-bit version. */ 63 uint8_t mdesc; /**< Media descriptor. */ 64 uint16_t sec_per_fat; /**< Sectors per FAT12/FAT16. */ 65 uint16_t sec_per_track; /**< Sectors per track. */ 66 uint16_t headcnt; /**< Number of heads. */ 67 uint32_t hidden_sec; /**< Hidden sectors. */ 68 uint32_t totsec32; /**< Total sectors. 32-bit version. */ 58 59 /** Bytes per sector */ 60 uint16_t bps; 61 /** Sectors per cluster */ 62 uint8_t spc; 63 /** Reserved sector count */ 64 uint16_t rscnt; 65 /** Number of FATs */ 66 uint8_t fatcnt; 67 /** Maximum number of root directory entries */ 68 uint16_t root_ent_max; 69 /** Total sectors. 16-bit version */ 70 uint16_t totsec16; 71 /** Media descriptor */ 72 uint8_t mdesc; 73 /** Sectors per FAT12/FAT16 */ 74 uint16_t sec_per_fat; 75 /** Sectors per track */ 76 uint16_t sec_per_track; 77 /** Number of heads */ 78 uint16_t headcnt; 79 /** Hidden sectors */ 80 uint32_t hidden_sec; 81 /** Total sectors. 32-bit version */ 82 uint32_t totsec32; 69 83 70 84 union { -
uspace/lib/posix/src/fnmatch.c
r4f8772d4 r904b1bc 33 33 */ 34 34 35 /* This file contains an implementation of the fnmatch() pattern matching 35 /* 36 * This file contains an implementation of the fnmatch() pattern matching 36 37 * function. There is more code than necessary to account for the possibility 37 38 * of adding POSIX-like locale support to the system in the future. Functions … … 54 55 #define INVALID_PATTERN -1 55 56 56 /* Type for collating element, simple identity with characters now, 57 /* 58 * Type for collating element, simple identity with characters now, 57 59 * but may be extended for better locale support. 58 60 */ … … 70 72 * @return Matching collating element or COLL_ELM_INVALID. 71 73 */ 72 static coll_elm_t _coll_elm_get(const char *str)74 static coll_elm_t _coll_elm_get(const char *str) 73 75 { 74 76 if (str[0] == '\0' || str[1] != '\0') { … … 306 308 } 307 309 308 /** 309 * Matches the beginning of the given string against a bracket expression 310 * the pattern begins with. 311 * 312 * @param pattern Pointer to the beginning of a bracket expression in a pattern. 313 * On success, the pointer is moved to the first character after the 314 * bracket expression. 315 * @param str Unmatched part of the string. 316 * @param flags Flags given to fnmatch(). 317 * @return INVALID_PATTERN if the pattern is invalid, 0 if there is no match 318 * or the number of matched characters on success. 319 */ 320 static int _match_bracket_expr(const char **pattern, const char *str, int flags) 321 { 322 const bool pathname = (flags & FNM_PATHNAME) != 0; 323 const bool special_period = (flags & FNM_PERIOD) != 0; 324 const char *p = *pattern; 325 bool negative = false; 326 int matched = 0; 327 328 #define _matched(match) { \ 310 #define _matched(match) { \ 329 311 int _match = match; \ 330 312 if (_match < 0) { \ … … 337 319 } 338 320 321 /** 322 * Matches the beginning of the given string against a bracket expression 323 * the pattern begins with. 324 * 325 * @param pattern Pointer to the beginning of a bracket expression in a pattern. 326 * On success, the pointer is moved to the first character after the 327 * bracket expression. 328 * @param str Unmatched part of the string. 329 * @param flags Flags given to fnmatch(). 330 * @return INVALID_PATTERN if the pattern is invalid, 0 if there is no match 331 * or the number of matched characters on success. 332 */ 333 static int _match_bracket_expr(const char **pattern, const char *str, int flags) 334 { 335 const bool pathname = (flags & FNM_PATHNAME) != 0; 336 const bool special_period = (flags & FNM_PERIOD) != 0; 337 const char *p = *pattern; 338 bool negative = false; 339 int matched = 0; 340 339 341 assert(*p == '['); /* calling code should ensure this */ 340 342 p++; … … 342 344 if (*str == '\0' || (pathname && *str == '/') || 343 345 (pathname && special_period && *str == '.' && *(str - 1) == '/')) { 344 /* No bracket expression matches end of string, 346 /* 347 * No bracket expression matches end of string, 345 348 * slash in pathname match or initial period with FNM_PERIOD 346 349 * option. … … 398 401 return negative ? 0 : matched; 399 402 } 400 401 #undef _matched402 403 } 403 404 … … 416 417 static bool _partial_match(const char **pattern, const char **string, int flags) 417 418 { 418 /* Only a single *-delimited subpattern is matched here. 419 /* 420 * Only a single *-delimited subpattern is matched here. 419 421 * So in this function, '*' is understood as the end of pattern. 420 422 */ … … 473 475 474 476 if (*p == '\0') { 475 /* End of pattern, must match end of string or 477 /* 478 * End of pattern, must match end of string or 476 479 * an end of subdirectory name (optional). 477 480 */ … … 628 631 #include <stdio.h> 629 632 633 #define fnmatch_test(x) { if (x) printf("SUCCESS: "#x"\n"); else { printf("FAILED: "#x"\n"); fail++; } } 634 #define match(s1, s2, flags) fnmatch_test(fnmatch(s1, s2, flags) == 0) 635 #define nomatch(s1, s2, flags) fnmatch_test(fnmatch(s1, s2, flags) == FNM_NOMATCH) 636 630 637 void __posix_fnmatch_test() 631 638 { 632 639 int fail = 0; 633 640 634 #undef assert635 #define assert(x) { if (x) printf("SUCCESS: "#x"\n"); else { printf("FAILED: "#x"\n"); fail++; } }636 #define match(s1, s2, flags) assert(fnmatch(s1, s2, flags) == 0)637 #define nomatch(s1, s2, flags) assert(fnmatch(s1, s2, flags) == FNM_NOMATCH)638 641 639 642 static_assert(FNM_PATHNAME == FNM_FILE_NAME); -
uspace/lib/usb/include/usb/classes/hub.h
r4f8772d4 r904b1bc 149 149 uint8_t characteristics; 150 150 151 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0)152 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)153 #define HUB_CHAR_COMPOUND_DEVICE (1 << 2)154 #define HUB_CHAR_OC_PER_PORT_FLAG (1 << 3)155 #define HUB_CHAR_NO_OC_FLAG (1 << 4)156 157 /* These are invalid for superspeed hub */158 #define HUB_CHAR_TT_THINK_16 (1 << 5)159 #define HUB_CHAR_TT_THINK_8 (1 << 6)160 #define HUB_CHAR_INDICATORS_FLAG (1 << 7)161 151 162 152 /** Unused part of characteristics field */ … … 179 169 uint8_t max_current; 180 170 } __attribute__((packed)) usb_hub_descriptor_header_t; 171 172 /* 173 * USB hub characteristics 174 */ 175 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0) 176 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1) 177 #define HUB_CHAR_COMPOUND_DEVICE (1 << 2) 178 #define HUB_CHAR_OC_PER_PORT_FLAG (1 << 3) 179 #define HUB_CHAR_NO_OC_FLAG (1 << 4) 180 181 /* These are invalid for superspeed hub */ 182 #define HUB_CHAR_TT_THINK_16 (1 << 5) 183 #define HUB_CHAR_TT_THINK_8 (1 << 6) 184 #define HUB_CHAR_INDICATORS_FLAG (1 << 7) 181 185 182 186 /** One bit for the device and one bit for every port */ -
uspace/lib/usbhost/src/ddf_helpers.c
r4f8772d4 r904b1bc 66 66 */ 67 67 static errno_t register_endpoint(ddf_fun_t *fun, usb_pipe_desc_t *pipe_desc, 68 68 const usb_endpoint_descriptors_t *ep_desc) 69 69 { 70 70 assert(fun); … … 92 92 } 93 93 94 95 96 97 98 99 100 101 94 /** 95 * DDF usbhc_iface callback. Unregister endpoint that makes the other end of 96 * the pipe described. 97 * 98 * @param fun DDF function of the device in question. 99 * @param pipe_desc Pipe description. 100 * @return Error code. 101 */ 102 102 static errno_t unregister_endpoint(ddf_fun_t *fun, const usb_pipe_desc_t *pipe_desc) 103 103 { … … 182 182 } 183 183 184 /* If the driver didn't name the dev when enumerating, 184 /* 185 * If the driver didn't name the dev when enumerating, 185 186 * do it in some generic way. 186 187 */ … … 281 282 assert(dev); 282 283 283 const usb_target_t target = {{ 284 .address = dev->address, 285 .endpoint = ifreq->endpoint, 286 .stream = ifreq->stream, 287 }}; 284 const usb_target_t target = { 285 { 286 .address = dev->address, 287 .endpoint = ifreq->endpoint, 288 .stream = ifreq->stream, 289 } 290 }; 288 291 289 292 if (!usb_target_is_valid(&target)) -
uspace/lib/usbhost/src/usb2_bus.c
r4f8772d4 r904b1bc 89 89 } 90 90 91 static const usb_target_t usb2_default_target = {{ 92 .address = USB_ADDRESS_DEFAULT, 93 .endpoint = 0, 94 }}; 91 static const usb_target_t usb2_default_target = { 92 { 93 .address = USB_ADDRESS_DEFAULT, 94 .endpoint = 0, 95 } 96 }; 95 97 96 98 /** … … 120 122 121 123 usb_endpoint_descriptors_t ep0_desc = { 122 124 .endpoint.max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE, 123 125 }; 124 126 -
uspace/lib/usbhost/src/utility.c
r4f8772d4 r904b1bc 84 84 } 85 85 86 const usb_target_t control_ep = {{ 87 .address = dev->address, 88 .endpoint = 0, 89 }}; 86 const usb_target_t control_ep = { 87 { 88 .address = dev->address, 89 .endpoint = 0, 90 } 91 }; 90 92 91 93 usb_standard_device_descriptor_t desc = { 0 }; … … 123 125 int hc_get_device_desc(device_t *device, usb_standard_device_descriptor_t *desc) 124 126 { 125 const usb_target_t control_ep = {{ 126 .address = device->address, 127 .endpoint = 0, 128 }}; 127 const usb_target_t control_ep = { 128 { 129 .address = device->address, 130 .endpoint = 0, 131 } 132 }; 129 133 130 134 /* Get std device descriptor */ … … 147 151 int hc_get_hub_desc(device_t *device, usb_hub_descriptor_header_t *desc) 148 152 { 149 const usb_target_t control_ep = {{ 150 .address = device->address, 151 .endpoint = 0, 152 }}; 153 154 const usb_descriptor_type_t type = device->speed >= USB_SPEED_SUPER 155 ? USB_DESCTYPE_SSPEED_HUB : USB_DESCTYPE_HUB; 153 const usb_target_t control_ep = { 154 { 155 .address = device->address, 156 .endpoint = 0, 157 } 158 }; 159 160 const usb_descriptor_type_t type = device->speed >= USB_SPEED_SUPER ? 161 USB_DESCTYPE_SSPEED_HUB : USB_DESCTYPE_HUB; 156 162 157 163 const usb_device_request_setup_packet_t get_hub_desc = { 158 .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST 159 | (USB_REQUEST_TYPE_CLASS << 5)160 |USB_REQUEST_RECIPIENT_DEVICE,164 .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST | 165 (USB_REQUEST_TYPE_CLASS << 5) | 166 USB_REQUEST_RECIPIENT_DEVICE, 161 167 .request = USB_DEVREQ_GET_DESCRIPTOR, 162 168 .value = uint16_host2usb(type << 8), … … 244 250 void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t reset_cb) 245 251 { 246 if (batch->ep->transfer_type != USB_TRANSFER_CONTROL 247 ||batch->dir != USB_DIRECTION_OUT)252 if (batch->ep->transfer_type != USB_TRANSFER_CONTROL || 253 batch->dir != USB_DIRECTION_OUT) 248 254 return; 249 255 250 256 const usb_device_request_setup_packet_t *request = &batch->setup.packet; 251 device_t * const dev = batch->ep->device; 252 253 switch (request->request) 254 { 255 /* Clear Feature ENPOINT_STALL */ 257 device_t *const dev = batch->ep->device; 258 259 switch (request->request) { 260 /* Clear Feature ENPOINT_STALL */ 256 261 case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */ 257 262 /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */ … … 273 278 case USB_DEVREQ_SET_CONFIGURATION: 274 279 case USB_DEVREQ_SET_INTERFACE: 275 /* Recipient must be device, this resets all endpoints, 280 /* 281 * Recipient must be device, this resets all endpoints, 276 282 * In fact there should be no endpoints but EP 0 registered 277 283 * as different interfaces use different endpoints, 278 284 * unless you're changing configuration or alternative 279 * interface of an already setup device. */ 285 * interface of an already setup device. 286 */ 280 287 if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST)) 281 288 for (usb_endpoint_t i = 0; i < 2 * USB_ENDPOINT_MAX; ++i)
Note:
See TracChangeset
for help on using the changeset viewer.