Changeset 387416b in mainline for kernel/generic/src
- Timestamp:
- 2009-12-12T10:11:35Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99de22b
- Parents:
- 58d5803d (diff), 1e4cada (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:
- kernel/generic/src
- Files:
-
- 8 edited
-
console/kconsole.c (modified) (2 diffs)
-
lib/string.c (modified) (3 diffs)
-
mm/backend_phys.c (modified) (1 diff)
-
proc/task.c (modified) (1 diff)
-
proc/thread.c (modified) (3 diffs)
-
synch/futex.c (modified) (8 diffs)
-
syscall/syscall.c (modified) (4 diffs)
-
udebug/udebug_ops.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r58d5803d r387416b 289 289 290 290 char tmp[STR_BOUNDS(MAX_CMDLINE)]; 291 wstr_ nstr(tmp, current + beg, position - beg + 1);291 wstr_to_str(tmp, position - beg + 1, current + beg); 292 292 293 293 int found; … … 665 665 666 666 char cmdline[STR_BOUNDS(MAX_CMDLINE)]; 667 wstr_ nstr(cmdline, tmp, STR_BOUNDS(MAX_CMDLINE));667 wstr_to_str(cmdline, STR_BOUNDS(MAX_CMDLINE), tmp); 668 668 669 669 if ((!kcon) && (len == 4) && (str_lcmp(cmdline, "exit", 4) == 0)) -
kernel/generic/src/lib/string.c
r58d5803d r387416b 537 537 * null-terminated and containing only complete characters. 538 538 * 539 * @param d st Destination buffer.539 * @param dest Destination buffer. 540 540 * @param count Size of the destination buffer (must be > 0). 541 541 * @param src Source string. … … 571 571 * have to be null-terminated. 572 572 * 573 * @param d st Destination buffer.573 * @param dest Destination buffer. 574 574 * @param count Size of the destination buffer (must be > 0). 575 575 * @param src Source string. … … 596 596 } 597 597 598 /** Copy NULL-terminated wide string to string 599 * 600 * Copy source wide string @a src to destination buffer @a dst. 601 * No more than @a size bytes are written. NULL-terminator is always 602 * written after the last succesfully copied character (i.e. if the 603 * destination buffer is has at least 1 byte, it will be always 604 * NULL-terminated). 605 * 606 * @param src Source wide string. 607 * @param dst Destination buffer. 608 * @param count Size of the destination buffer. 609 * 610 */ 611 void wstr_nstr(char *dst, const wchar_t *src, size_t size) 612 { 613 /* No space for the NULL-terminator in the buffer */ 614 if (size == 0) 615 return; 616 598 /** Convert wide string to string. 599 * 600 * Convert wide string @a src to string. The output is written to the buffer 601 * specified by @a dest and @a size. @a size must be non-zero and the string 602 * written will always be well-formed. 603 * 604 * @param dest Destination buffer. 605 * @param size Size of the destination buffer. 606 * @param src Source wide string. 607 */ 608 void wstr_to_str(char *dest, size_t size, const wchar_t *src) 609 { 617 610 wchar_t ch; 618 size_t src_idx = 0; 619 size_t dst_off = 0; 611 size_t src_idx; 612 size_t dest_off; 613 614 /* There must be space for a null terminator in the buffer. */ 615 ASSERT(size > 0); 616 617 src_idx = 0; 618 dest_off = 0; 620 619 621 620 while ((ch = src[src_idx++]) != 0) { 622 if (chr_encode(ch, d st, &dst_off, size) != EOK)621 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 623 622 break; 624 623 } 625 626 if (dst_off >= size) 627 dst[size - 1] = 0; 628 else 629 dst[dst_off] = 0; 624 625 dest[dest_off] = '\0'; 630 626 } 631 627 -
kernel/generic/src/mm/backend_phys.c
r58d5803d r387416b 40 40 #include <arch/types.h> 41 41 #include <mm/as.h> 42 #include <mm/page.h> 42 43 #include <mm/frame.h> 43 44 #include <mm/slab.h> -
kernel/generic/src/proc/task.c
r58d5803d r387416b 54 54 #include <func.h> 55 55 #include <string.h> 56 #include <memstr.h> 56 57 #include <syscall/copy.h> 57 58 #include <macros.h> -
kernel/generic/src/proc/thread.c
r58d5803d r387416b 501 501 void thread_sleep(uint32_t sec) 502 502 { 503 thread_usleep(sec * 1000000); 503 /* Sleep in 1000 second steps to support 504 full argument range */ 505 while (sec > 0) { 506 uint32_t period = (sec > 1000) ? 1000 : sec; 507 508 thread_usleep(period * 1000000); 509 sec -= period; 510 } 504 511 } 505 512 … … 575 582 { 576 583 waitq_t wq; 577 584 578 585 waitq_initialize(&wq); 579 586 580 587 (void) waitq_sleep_timeout(&wq, usec, SYNCH_FLAGS_NON_BLOCKING); 581 588 } … … 812 819 } 813 820 821 /** Syscall wrapper for sleeping. */ 822 unative_t sys_thread_usleep(uint32_t usec) 823 { 824 thread_usleep(usec); 825 return 0; 826 } 827 814 828 /** @} 815 829 */ -
kernel/generic/src/synch/futex.c
r58d5803d r387416b 90 90 /** Initialize kernel futex structure. 91 91 * 92 * @param futex Kernel futex structure.92 * @param futex Kernel futex structure. 93 93 */ 94 94 void futex_initialize(futex_t *futex) … … 102 102 /** Sleep in futex wait queue. 103 103 * 104 * @param uaddr Userspace address of the futex counter. 105 * @param usec If non-zero, number of microseconds this thread is willing to 106 * sleep. 107 * @param flags Select mode of operation. 108 * 109 * @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See 110 * synch.h. If there is no physical mapping for uaddr ENOENT is returned. 111 */ 112 unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags) 104 * @param uaddr Userspace address of the futex counter. 105 * 106 * @return If there is no physical mapping for uaddr ENOENT is 107 * returned. Otherwise returns a wait result as defined in 108 * synch.h. 109 */ 110 unative_t sys_futex_sleep(uintptr_t uaddr) 113 111 { 114 112 futex_t *futex; … … 140 138 udebug_stoppable_begin(); 141 139 #endif 142 rc = waitq_sleep_timeout(&futex->wq, usec, flags | 143 SYNCH_FLAGS_INTERRUPTIBLE); 144 140 rc = waitq_sleep_timeout(&futex->wq, 0, SYNCH_FLAGS_INTERRUPTIBLE); 145 141 #ifdef CONFIG_UDEBUG 146 142 udebug_stoppable_end(); … … 151 147 /** Wakeup one thread waiting in futex wait queue. 152 148 * 153 * @param uaddr Userspace address of the futex counter.154 * 155 * @return ENOENT if there is no physical mapping for uaddr.149 * @param uaddr Userspace address of the futex counter. 150 * 151 * @return ENOENT if there is no physical mapping for uaddr. 156 152 */ 157 153 unative_t sys_futex_wakeup(uintptr_t uaddr) … … 190 186 * If the structure does not exist already, a new one is created. 191 187 * 192 * @param paddr Physical address of the userspace futex counter.193 * 194 * @return Address of the kernel futex structure.188 * @param paddr Physical address of the userspace futex counter. 189 * 190 * @return Address of the kernel futex structure. 195 191 */ 196 192 futex_t *futex_find(uintptr_t paddr) … … 284 280 /** Compute hash index into futex hash table. 285 281 * 286 * @param key Address where the key (i.e. physical address of futex counter) is287 * stored.288 * 289 * @return Index into futex hash table.282 * @param key Address where the key (i.e. physical address of futex 283 * counter) is stored. 284 * 285 * @return Index into futex hash table. 290 286 */ 291 287 size_t futex_ht_hash(unative_t *key) … … 296 292 /** Compare futex hash table item with a key. 297 293 * 298 * @param key Address where the key (i.e. physical address of futex counter) is299 * stored.300 * 301 * @return True if the item matches the key. False otherwise.294 * @param key Address where the key (i.e. physical address of futex 295 * counter) is stored. 296 * 297 * @return True if the item matches the key. False otherwise. 302 298 */ 303 299 bool futex_ht_compare(unative_t *key, size_t keys, link_t *item) … … 313 309 /** Callback for removal items from futex hash table. 314 310 * 315 * @param item Item removed from the hash table.311 * @param item Item removed from the hash table. 316 312 */ 317 313 void futex_ht_remove_callback(link_t *item) -
kernel/generic/src/syscall/syscall.c
r58d5803d r387416b 62 62 63 63 #ifdef CONFIG_UDEBUG 64 bool debug;65 66 64 /* 67 65 * Early check for undebugged tasks. We do not lock anything as this 68 * test need not be precise in either way.66 * test need not be precise in either direction. 69 67 */ 70 debug = THREAD->udebug.active; 71 72 if (debug) { 68 if (THREAD->udebug.active) { 73 69 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false); 74 70 } … … 87 83 88 84 #ifdef CONFIG_UDEBUG 89 if ( debug) {85 if (THREAD->udebug.active) { 90 86 udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true); 91 87 … … 111 107 (syshandler_t) sys_thread_exit, 112 108 (syshandler_t) sys_thread_get_id, 109 (syshandler_t) sys_thread_usleep, 113 110 114 111 (syshandler_t) sys_task_get_id, … … 117 114 118 115 /* Synchronization related syscalls. */ 119 (syshandler_t) sys_futex_sleep _timeout,116 (syshandler_t) sys_futex_sleep, 120 117 (syshandler_t) sys_futex_wakeup, 121 118 (syshandler_t) sys_smc_coherence, -
kernel/generic/src/udebug/udebug_ops.c
r58d5803d r387416b 50 50 #include <udebug/udebug.h> 51 51 #include <udebug/udebug_ops.h> 52 #include <memstr.h> 52 53 53 54 /**
Note:
See TracChangeset
for help on using the changeset viewer.
