Subversion Repositories HelenOS

Rev

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

Rev 3203 Rev 3204
Line 60... Line 60...
60
 * Points to the binary image used as the program loader. All non-initial
60
 * Points to the binary image used as the program loader. All non-initial
61
 * tasks are created from this executable image.
61
 * tasks are created from this executable image.
62
 */
62
 */
63
void *program_loader = NULL;
63
void *program_loader = NULL;
64
 
64
 
65
/** Create new task with 1 thread and run it
65
/** Create a program using an existing address space.
66
 *
66
 *
67
 * @param as Address space containing a binary program image.
67
 * @param as        Address space containing a binary program image.
68
 * @param entry_addr Program entry-point address in program address space.
68
 * @param entry_addr    Program entry-point address in program address space.
69
 * @param name Program name.
-
 
70
 *
-
 
71
 * @return Task of the running program or NULL on error.
69
 * @param p     Buffer for storing program information.
72
 */
70
 */
73
void program_create(as_t *as, uintptr_t entry_addr, program_t *p)
71
void program_create(as_t *as, uintptr_t entry_addr, program_t *p)
74
{
72
{
75
    as_area_t *a;
73
    as_area_t *a;
76
    uspace_arg_t *kernel_uarg;
74
    uspace_arg_t *kernel_uarg;
Line 98... Line 96...
98
    p->main_thread = thread_create(uinit, kernel_uarg, p->task,
96
    p->main_thread = thread_create(uinit, kernel_uarg, p->task,
99
        THREAD_FLAG_USPACE, "uinit", false);
97
        THREAD_FLAG_USPACE, "uinit", false);
100
    ASSERT(p->main_thread);
98
    ASSERT(p->main_thread);
101
}
99
}
102
 
100
 
103
/** Parse an executable image in the physical memory.
101
/** Parse an executable image in the kernel memory.
104
 *
102
 *
105
 * If the image belongs to a program loader, it is registered as such,
103
 * If the image belongs to a program loader, it is registered as such,
106
 * (and *task is set to NULL). Otherwise a task is created from the
104
 * (and *task is set to NULL). Otherwise a task is created from the
107
 * executable image. The task is returned in *task.
105
 * executable image. The task is returned in *task.
108
 *
106
 *
109
 * @param program_addr Address of program executable image.
107
 * @param image_addr    Address of an executable program image.
110
 * @param name Program name.
108
 * @param p     Buffer for storing program info. If image_addr
111
 * @param task Where to store the pointer to the newly created task.
109
 *          points to a loader image, p->task will be set to
-
 
110
 *          NULL and EOK will be returned.
112
 *
111
 *
113
 * @return EOK on success or negative error code.
112
 * @return EOK on success or negative error code.
114
 */
113
 */
115
int program_create_from_image(void *image_addr, program_t *p)
114
int program_create_from_image(void *image_addr, program_t *p)
116
{
115
{
Line 139... Line 138...
139
    return EOK;
138
    return EOK;
140
}
139
}
141
 
140
 
142
/** Create a task from the program loader image.
141
/** Create a task from the program loader image.
143
 *
142
 *
144
 * @param name Program name.
-
 
145
 * @param t Buffer for storing pointer to the newly created task.
143
 * @param p Buffer for storing program info.
146
 *
-
 
147
 * @return Task of the running program or NULL on error.
144
 * @return EOK on success or negative error code.
148
 */
145
 */
149
int program_create_loader(program_t *p)
146
int program_create_loader(program_t *p)
150
{
147
{
151
    as_t *as;
148
    as_t *as;
152
    unsigned int rc;
149
    unsigned int rc;
Line 167... Line 164...
167
    program_create(as, ((elf_header_t *) program_loader)->e_entry, p);
164
    program_create(as, ((elf_header_t *) program_loader)->e_entry, p);
168
 
165
 
169
    return EOK;
166
    return EOK;
170
}
167
}
171
 
168
 
172
/** Make task ready.
169
/** Make program ready.
173
 *
170
 *
174
 * Switch task's thread to the ready state.
171
 * Switch program's main thread to the ready state.
175
 *
172
 *
176
 * @param ta Task to make ready.
173
 * @param p Program to make ready.
177
 */
174
 */
178
void program_ready(program_t *p)
175
void program_ready(program_t *p)
179
{
176
{
180
    thread_ready(p->main_thread);
177
    thread_ready(p->main_thread);
181
}
178
}
182
 
179
 
183
/** Syscall for creating a new task from userspace.
180
/** Syscall for creating a new loader instance from userspace.
184
 *
181
 *
185
 * Creates a new task from the program loader image, connects a phone
182
 * Creates a new task from the program loader image, connects a phone
186
 * to it and stores the phone id into the provided buffer.
183
 * to it and stores the phone id into the provided buffer.
187
 *
184
 *
188
 * @param uspace_phone_id Userspace address where to store the phone id.
185
 * @param uspace_phone_id Userspace address where to store the phone id.