Subversion Repositories HelenOS-historic

Rev

Rev 1066 | Rev 1083 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1066 Rev 1078
Line 27... Line 27...
27
 */
27
 */
28
 
28
 
29
#include <proc/scheduler.h>
29
#include <proc/scheduler.h>
30
#include <proc/thread.h>
30
#include <proc/thread.h>
31
#include <proc/task.h>
31
#include <proc/task.h>
-
 
32
#include <proc/uarg.h>
32
#include <mm/frame.h>
33
#include <mm/frame.h>
33
#include <mm/page.h>
34
#include <mm/page.h>
34
#include <arch/asm.h>
35
#include <arch/asm.h>
35
#include <arch.h>
36
#include <arch.h>
36
#include <synch/synch.h>
37
#include <synch/synch.h>
Line 427... Line 428...
427
}
428
}
428
 
429
 
429
/** Process syscall to create new thread.
430
/** Process syscall to create new thread.
430
 *
431
 *
431
 */
432
 */
432
__native sys_thread_create(__address function, void *arg, void *stack, char *name)
433
__native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
433
{
434
{
434
        thread_t *t;
435
        thread_t *t;
435
        char namebuf[THREAD_NAME_BUFLEN];
436
        char namebuf[THREAD_NAME_BUFLEN];
436
    uspace_arg_t *uarg;
437
    uspace_arg_t *kernel_uarg;      /* TODO: store kernel_uarg in thread_t */
437
    __u32 tid;
438
    __u32 tid;
438
 
439
 
439
        copy_from_uspace(namebuf, name, THREAD_NAME_BUFLEN);
440
        copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
440
    uarg = (uspace_arg_t *) malloc(sizeof(uarg), 0);
-
 
441
   
441
 
442
    uarg->uspace_entry = function;
442
    kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
443
    uarg->uspace_stack = (__address) stack;
443
    copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t));
444
 
444
 
445
        if ((t = thread_create(uinit, uarg, TASK, 0, namebuf))) {
445
        if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) {
446
        tid = t->tid;
446
        tid = t->tid;
447
                thread_ready(t);
447
                thread_ready(t);
448
        return (__native) tid;
448
        return (__native) tid;
449
        } else {
449
        } else {
450
                free(namebuf);
450
        free(kernel_uarg);
451
        }
451
        }
452
 
452
 
453
        return (__native) -1;
453
        return (__native) -1;
454
}
454
}
455
 
455
 
456
/** Process syscall to terminate thread.
456
/** Process syscall to terminate thread.
457
 *
457
 *
458
 */
458
 */
459
__native sys_thread_exit(int status)
459
__native sys_thread_exit(int uspace_status)
460
{
460
{
461
        thread_exit();
461
        thread_exit();
462
        /* Unreachable */
462
        /* Unreachable */
463
        return 0;
463
        return 0;
464
}
464
}