Changeset 387416b in mainline for kernel


Ignore:
Timestamp:
2009-12-12T10:11:35Z (16 years ago)
Author:
Pavel Rimsky <pavel@…>
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.
Message:

Synchronizing with head.

Location:
kernel
Files:
2 added
33 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/amd64.c

    r58d5803d r387416b  
    6767#include <ddi/irq.h>
    6868#include <sysinfo/sysinfo.h>
     69#include <memstr.h>
    6970
    7071/** Disable I/O on non-privileged levels
  • kernel/arch/arm32/Makefile.inc

    r58d5803d r387416b  
    6161        arch/$(KARCH)/src/mm/page.c \
    6262        arch/$(KARCH)/src/mm/tlb.c \
    63         arch/$(KARCH)/src/mm/page_fault.c
     63        arch/$(KARCH)/src/mm/page_fault.c \
     64        arch/$(KARCH)/src/ras.c
    6465
    6566ifeq ($(MACHINE),testarm)
  • kernel/arch/arm32/include/atomic.h

    r58d5803d r387416b  
    3737#define KERN_arm32_ATOMIC_H_
    3838
     39#include <arch/asm.h>
     40
    3941/** Atomic addition.
    4042 *
     
    4749static inline long atomic_add(atomic_t *val, int i)
    4850{
    49         int ret;
    50         volatile long *mem = &(val->count);
    51        
    52         asm volatile (
    53                 "1:\n"
    54                         "ldr r2, [%[mem]]\n"
    55                         "add r3, r2, %[i]\n"
    56                         "str r3, %[ret]\n"
    57                         "swp r3, r3, [%[mem]]\n"
    58                         "cmp r3, r2\n"
    59                         "bne 1b\n"
    60                 : [ret] "=m" (ret)
    61                 : [mem] "r" (mem), [i] "r" (i)
    62                 : "r3", "r2"
    63         );
     51        long ret;
     52
     53        /*
     54         * This implementation is for UP pre-ARMv6 systems where we do not have
     55         * the LDREX and STREX instructions.
     56         */
     57        ipl_t ipl = interrupts_disable();
     58        val->count += i;
     59        ret = val->count;
     60        interrupts_restore(ipl);
    6461       
    6562        return ret;
  • kernel/arch/arm32/include/mm/as.h

    r58d5803d r387416b  
    5454#define as_destructor_arch(as)                  (as != as)
    5555#define as_create_arch(as, flags)               (as != as)
    56 #define as_install_arch(as)
    5756#define as_deinstall_arch(as)
    5857#define as_invalidate_translation_cache(as, page, cnt)
  • kernel/arch/arm32/src/arm32.c

    r58d5803d r387416b  
    4848#include <macros.h>
    4949#include <string.h>
     50#include <arch/ras.h>
    5051
    5152#ifdef MACHINE_testarm
     
    8889        exception_init();
    8990        interrupt_init();
     91
     92        /* Initialize Restartable Atomic Sequences support. */
     93        ras_init();
    9094       
    9195        machine_output_init();
     
    136140        uint8_t *stck;
    137141       
    138         tlb_invalidate_all();
    139142        stck = &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];
    140143        supervisor_sp = (uintptr_t) stck;
  • kernel/arch/arm32/src/exc_handler.S

    r58d5803d r387416b  
    148148        mov r0, #0
    149149        mov r1, r13
    150         bl exc_dispatch
     150        bl ras_check
    151151        LOAD_REGS_FROM_STACK
    152152
     
    156156        mov r0, #5
    157157        mov r1, r13
    158         bl exc_dispatch
     158        bl ras_check
    159159        LOAD_REGS_FROM_STACK
    160160
     
    164164        mov r0, #6
    165165        mov r1, r13
    166         bl exc_dispatch
     166        bl ras_check
    167167        LOAD_REGS_FROM_STACK
    168168
     
    171171        mov r0, #1
    172172        mov r1, r13
    173         bl exc_dispatch
     173        bl ras_check
    174174        LOAD_REGS_FROM_STACK
    175175
     
    179179        mov r0, #3
    180180        mov r1, r13
    181         bl exc_dispatch
     181        bl ras_check
    182182        LOAD_REGS_FROM_STACK
    183183
     
    187187        mov r0, #4
    188188        mov r1, r13
    189         bl exc_dispatch
     189        bl ras_check
    190190        LOAD_REGS_FROM_STACK
    191191
     
    195195        mov r0, #2
    196196        mov r1, r13
    197         bl exc_dispatch
     197        bl ras_check
    198198        LOAD_REGS_FROM_STACK
    199199
  • kernel/arch/arm32/src/mm/as.c

    r58d5803d r387416b  
    3636#include <arch/mm/as.h>
    3737#include <genarch/mm/as_pt.h>
     38#include <genarch/mm/page_pt.h>
    3839#include <genarch/mm/asid_fifo.h>
    3940#include <mm/as.h>
     41#include <mm/tlb.h>
    4042#include <arch.h>
    4143
     
    4951}
    5052
     53void as_install_arch(as_t *as)
     54{
     55        tlb_invalidate_all();
     56}
     57
    5158/** @}
    5259 */
  • kernel/arch/arm32/src/userspace.c

    r58d5803d r387416b  
    3535
    3636#include <userspace.h>
     37#include <arch/ras.h>
    3738
    3839/** Struct for holding all general purpose registers.
     
    7475        ustate.r1 = 0;
    7576
     77        /* pass the RAS page address in %r2 */
     78        ustate.r2 = (uintptr_t) ras_page;
     79
    7680        /* clear other registers */
    77         ustate.r2 = ustate.r3  = ustate.r4  = ustate.r5 =
    78             ustate.r6  = ustate.r7  = ustate.r8  = ustate.r9 = ustate.r10 =
    79             ustate.r11 = ustate.r12 = ustate.lr = 0;
     81        ustate.r3  = ustate.r4  = ustate.r5 = ustate.r6 = ustate.r7 =
     82            ustate.r8 = ustate.r9 = ustate.r10 = ustate.r11 = ustate.r12 =
     83            ustate.lr = 0;
    8084
    8185        /* set user stack */
  • kernel/arch/ia32/src/ia32.c

    r58d5803d r387416b  
    6868#include <sysinfo/sysinfo.h>
    6969#include <arch/boot/boot.h>
     70#include <memstr.h>
    7071
    7172#ifdef CONFIG_SMP
  • kernel/arch/ia64/src/cpu/cpu.c

    r58d5803d r387416b  
    3737#include <arch/register.h>
    3838#include <print.h>
     39#include <memstr.h>
    3940
    4041void cpu_arch_init(void)
  • kernel/arch/ppc32/src/mm/as.c

    r58d5803d r387416b  
    3535#include <arch/mm/as.h>
    3636#include <genarch/mm/as_pt.h>
     37#include <genarch/mm/page_pt.h>
    3738#include <genarch/mm/asid_fifo.h>
    3839#include <arch.h>
  • kernel/arch/ppc32/src/mm/tlb.c

    r58d5803d r387416b  
    3838#include <interrupt.h>
    3939#include <mm/as.h>
     40#include <mm/page.h>
    4041#include <arch.h>
    4142#include <print.h>
  • kernel/arch/ppc32/src/ppc32.c

    r58d5803d r387416b  
    4444#include <genarch/ofw/pci.h>
    4545#include <userspace.h>
     46#include <mm/page.h>
    4647#include <proc/uarg.h>
    4748#include <console/console.h>
  • kernel/arch/sparc64/src/drivers/kbd.c

    r58d5803d r387416b  
    3939#include <console/console.h>
    4040#include <ddi/irq.h>
     41#include <mm/page.h>
    4142#include <arch/mm/page.h>
    4243#include <arch/types.h>
  • kernel/arch/sparc64/src/mm/page.c

    r58d5803d r387416b  
    3333 */
    3434
     35#include <mm/page.h>
    3536#include <arch/mm/page.h>
    3637#include <arch/mm/tlb.h>
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    r58d5803d r387416b  
    5050#include <panic.h>
    5151#include <arch/asm.h>
     52#include <genarch/mm/page_ht.h>
    5253
    5354#ifdef CONFIG_TSB
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    r58d5803d r387416b  
    5454#include <arch/cpu.h>
    5555#include <arch/mm/pagesize.h>
     56#include <genarch/mm/page_ht.h>
    5657
    5758#ifdef CONFIG_TSB
  • kernel/genarch/src/drivers/via-cuda/cuda.c

    r58d5803d r387416b  
    4141#include <ddi/device.h>
    4242#include <synch/spinlock.h>
     43#include <memstr.h>
    4344
    4445static irq_ownership_t cuda_claim(irq_t *irq);
  • kernel/genarch/src/fb/fb.c

    r58d5803d r387416b  
    4141#include <console/console.h>
    4242#include <sysinfo/sysinfo.h>
     43#include <mm/page.h>
    4344#include <mm/slab.h>
    4445#include <align.h>
  • kernel/generic/include/arch.h

    r58d5803d r387416b  
    3939#include <proc/thread.h>
    4040#include <proc/task.h>
     41#include <mm/as.h>
    4142
    4243#define DEFAULT_CONTEXT         0
  • kernel/generic/include/proc/task.h

    r58d5803d r387416b  
    5555#include <udebug/udebug.h>
    5656#include <ipc/kbox.h>
     57#include <mm/as.h>
    5758
    5859#define TASK_NAME_BUFLEN        20
  • kernel/generic/include/proc/thread.h

    r58d5803d r387416b  
    225225
    226226extern void thread_init(void);
    227 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
    228     int flags, char *name, bool uncounted);
    229 extern void thread_attach(thread_t *t, task_t *task);
    230 extern void thread_ready(thread_t *t);
     227extern thread_t *thread_create(void (*)(void *), void *, task_t *, int, char *,
     228    bool);
     229extern void thread_attach(thread_t *, task_t *);
     230extern void thread_ready(thread_t *);
    231231extern void thread_exit(void) __attribute__((noreturn));
    232232
    233233#ifndef thread_create_arch
    234 extern void thread_create_arch(thread_t *t);
     234extern void thread_create_arch(thread_t *);
    235235#endif
    236236#ifndef thr_constructor_arch
    237 extern void thr_constructor_arch(thread_t *t);
     237extern void thr_constructor_arch(thread_t *);
    238238#endif
    239239#ifndef thr_destructor_arch
    240 extern void thr_destructor_arch(thread_t *t);
    241 #endif
    242 
    243 extern void thread_sleep(uint32_t sec);
    244 extern void thread_usleep(uint32_t usec);
     240extern void thr_destructor_arch(thread_t *);
     241#endif
     242
     243extern void thread_sleep(uint32_t);
     244extern void thread_usleep(uint32_t);
    245245
    246246#define thread_join(t) \
    247247        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    248 extern int thread_join_timeout(thread_t *t, uint32_t usec, int flags);
    249 extern void thread_detach(thread_t *t);
    250 
    251 extern void thread_register_call_me(void (* call_me)(void *),
    252     void *call_me_with);
     248extern int thread_join_timeout(thread_t *, uint32_t, int);
     249extern void thread_detach(thread_t *);
     250
     251extern void thread_register_call_me(void (*)(void *), void *);
    253252extern void thread_print_list(void);
    254 extern void thread_destroy(thread_t *t);
     253extern void thread_destroy(thread_t *);
    255254extern void thread_update_accounting(void);
    256 extern bool thread_exists(thread_t *t);
     255extern bool thread_exists(thread_t *);
    257256
    258257/** Fpu context slab cache. */
     
    260259
    261260/* Thread syscall prototypes. */
    262 extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg,
    263     char *uspace_name, size_t name_len, thread_id_t *uspace_thread_id);
    264 extern unative_t sys_thread_exit(int uspace_status);
    265 extern unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
     261extern unative_t sys_thread_create(uspace_arg_t *, char *, size_t,
     262    thread_id_t *);
     263extern unative_t sys_thread_exit(int);
     264extern unative_t sys_thread_get_id(thread_id_t *);
     265extern unative_t sys_thread_usleep(uint32_t);
    266266
    267267#endif
  • kernel/generic/include/string.h

    r58d5803d r387416b  
    8787extern void str_cpy(char *dest, size_t size, const char *src);
    8888extern void str_ncpy(char *dest, size_t size, const char *src, size_t n);
    89 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size);
     89extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
    9090
    9191extern char *str_chr(const char *str, wchar_t ch);
  • kernel/generic/include/synch/futex.h

    r58d5803d r387416b  
    3838#include <arch/types.h>
    3939#include <synch/waitq.h>
    40 #include <genarch/mm/page_ht.h>
    41 #include <genarch/mm/page_pt.h>
    4240
    4341/** Kernel-side futex structure. */
     
    5452
    5553extern void futex_init(void);
    56 extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec,
    57     int flags);
    58 extern unative_t sys_futex_wakeup(uintptr_t uaddr);
     54extern unative_t sys_futex_sleep(uintptr_t);
     55extern unative_t sys_futex_wakeup(uintptr_t);
    5956
    6057extern void futex_cleanup(void);
  • kernel/generic/include/syscall/syscall.h

    r58d5803d r387416b  
    4343        SYS_THREAD_EXIT,
    4444        SYS_THREAD_GET_ID,
     45        SYS_THREAD_USLEEP,
    4546       
    4647        SYS_TASK_GET_ID,
  • kernel/generic/src/console/kconsole.c

    r58d5803d r387416b  
    289289                       
    290290                        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);
    292292                       
    293293                        int found;
     
    665665               
    666666                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);
    668668               
    669669                if ((!kcon) && (len == 4) && (str_lcmp(cmdline, "exit", 4) == 0))
  • kernel/generic/src/lib/string.c

    r58d5803d r387416b  
    537537 * null-terminated and containing only complete characters.
    538538 *
    539  * @param dst   Destination buffer.
     539 * @param dest   Destination buffer.
    540540 * @param count Size of the destination buffer (must be > 0).
    541541 * @param src   Source string.
     
    571571 * have to be null-terminated.
    572572 *
    573  * @param dst   Destination buffer.
     573 * @param dest   Destination buffer.
    574574 * @param count Size of the destination buffer (must be > 0).
    575575 * @param src   Source string.
     
    596596}
    597597
    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 */
     608void wstr_to_str(char *dest, size_t size, const wchar_t *src)
     609{
    617610        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;
    620619       
    621620        while ((ch = src[src_idx++]) != 0) {
    622                 if (chr_encode(ch, dst, &dst_off, size) != EOK)
     621                if (chr_encode(ch, dest, &dest_off, size - 1) != EOK)
    623622                        break;
    624623        }
    625        
    626         if (dst_off >= size)
    627                 dst[size - 1] = 0;
    628         else
    629                 dst[dst_off] = 0;
     624
     625        dest[dest_off] = '\0';
    630626}
    631627
  • kernel/generic/src/mm/backend_phys.c

    r58d5803d r387416b  
    4040#include <arch/types.h>
    4141#include <mm/as.h>
     42#include <mm/page.h>
    4243#include <mm/frame.h>
    4344#include <mm/slab.h>
  • kernel/generic/src/proc/task.c

    r58d5803d r387416b  
    5454#include <func.h>
    5555#include <string.h>
     56#include <memstr.h>
    5657#include <syscall/copy.h>
    5758#include <macros.h>
  • kernel/generic/src/proc/thread.c

    r58d5803d r387416b  
    501501void thread_sleep(uint32_t sec)
    502502{
    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        }
    504511}
    505512
     
    575582{
    576583        waitq_t wq;
    577                                  
     584       
    578585        waitq_initialize(&wq);
    579 
     586       
    580587        (void) waitq_sleep_timeout(&wq, usec, SYNCH_FLAGS_NON_BLOCKING);
    581588}
     
    812819}
    813820
     821/** Syscall wrapper for sleeping. */
     822unative_t sys_thread_usleep(uint32_t usec)
     823{
     824        thread_usleep(usec);
     825        return 0;
     826}
     827
    814828/** @}
    815829 */
  • kernel/generic/src/synch/futex.c

    r58d5803d r387416b  
    9090/** Initialize kernel futex structure.
    9191 *
    92  * @param futex Kernel futex structure.
     92 * @param futex         Kernel futex structure.
    9393 */
    9494void futex_initialize(futex_t *futex)
     
    102102/** Sleep in futex wait queue.
    103103 *
    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 */
     110unative_t sys_futex_sleep(uintptr_t uaddr)
    113111{
    114112        futex_t *futex;
     
    140138        udebug_stoppable_begin();
    141139#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);
    145141#ifdef CONFIG_UDEBUG
    146142        udebug_stoppable_end();
     
    151147/** Wakeup one thread waiting in futex wait queue.
    152148 *
    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.
    156152 */
    157153unative_t sys_futex_wakeup(uintptr_t uaddr)
     
    190186 * If the structure does not exist already, a new one is created.
    191187 *
    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.
    195191 */
    196192futex_t *futex_find(uintptr_t paddr)
     
    284280/** Compute hash index into futex hash table.
    285281 *
    286  * @param key Address where the key (i.e. physical address of futex counter) is
    287  *    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.
    290286 */
    291287size_t futex_ht_hash(unative_t *key)
     
    296292/** Compare futex hash table item with a key.
    297293 *
    298  * @param key Address where the key (i.e. physical address of futex counter) is
    299  *    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.
    302298 */
    303299bool futex_ht_compare(unative_t *key, size_t keys, link_t *item)
     
    313309/** Callback for removal items from futex hash table.
    314310 *
    315  * @param item Item removed from the hash table.
     311 * @param item          Item removed from the hash table.
    316312 */
    317313void futex_ht_remove_callback(link_t *item)
  • kernel/generic/src/syscall/syscall.c

    r58d5803d r387416b  
    6262
    6363#ifdef CONFIG_UDEBUG
    64         bool debug;
    65 
    6664        /*
    6765         * 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.
    6967         */
    70         debug = THREAD->udebug.active;
    71        
    72         if (debug) {
     68        if (THREAD->udebug.active) {
    7369                udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false);
    7470        }
     
    8783       
    8884#ifdef CONFIG_UDEBUG
    89         if (debug) {
     85        if (THREAD->udebug.active) {
    9086                udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true);
    9187       
     
    111107        (syshandler_t) sys_thread_exit,
    112108        (syshandler_t) sys_thread_get_id,
     109        (syshandler_t) sys_thread_usleep,
    113110       
    114111        (syshandler_t) sys_task_get_id,
     
    117114       
    118115        /* Synchronization related syscalls. */
    119         (syshandler_t) sys_futex_sleep_timeout,
     116        (syshandler_t) sys_futex_sleep,
    120117        (syshandler_t) sys_futex_wakeup,
    121118        (syshandler_t) sys_smc_coherence,
  • kernel/generic/src/udebug/udebug_ops.c

    r58d5803d r387416b  
    5050#include <udebug/udebug.h>
    5151#include <udebug/udebug_ops.h>
     52#include <memstr.h>
    5253
    5354/**
Note: See TracChangeset for help on using the changeset viewer.