Subversion Repositories HelenOS-historic

Rev

Rev 965 | Rev 1027 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 965 Rev 973
Line 25... Line 25...
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <main/kinit.h>
29
#include <main/kinit.h>
30
#include <main/uinit.h>
-
 
31
#include <config.h>
30
#include <config.h>
32
#include <arch.h>
31
#include <arch.h>
33
#include <proc/scheduler.h>
32
#include <proc/scheduler.h>
34
#include <proc/task.h>
33
#include <proc/task.h>
35
#include <proc/thread.h>
34
#include <proc/thread.h>
Line 44... Line 43...
44
#include <print.h>
43
#include <print.h>
45
#include <memstr.h>
44
#include <memstr.h>
46
#include <console/console.h>
45
#include <console/console.h>
47
#include <interrupt.h>
46
#include <interrupt.h>
48
#include <console/kconsole.h>
47
#include <console/kconsole.h>
49
#include <elf.h>
-
 
50
#include <ipc/ns.h>
48
#include <ipc/ns.h>
51
 
49
 
52
#ifdef CONFIG_SMP
50
#ifdef CONFIG_SMP
53
#include <arch/smp/mps.h>
51
#include <arch/smp/mps.h>
54
#endif /* CONFIG_SMP */
52
#endif /* CONFIG_SMP */
Line 69... Line 67...
69
 * @param arg Not used.
67
 * @param arg Not used.
70
 */
68
 */
71
void kinit(void *arg)
69
void kinit(void *arg)
72
{
70
{
73
    thread_t *t;
71
    thread_t *t;
74
    as_t *as;
-
 
75
    as_area_t *a;
-
 
76
    int rc;
-
 
77
    task_t *u;
-
 
78
 
72
 
79
    interrupts_disable();
73
    interrupts_disable();
80
 
74
 
81
#ifdef CONFIG_SMP           
75
#ifdef CONFIG_SMP           
82
    if (config.cpu_count > 1) {
76
    if (config.cpu_count > 1) {
Line 148... Line 142...
148
         */
142
         */
149
       
143
       
150
        if (config.init_addr % FRAME_SIZE)
144
        if (config.init_addr % FRAME_SIZE)
151
            panic("config.init_addr is not frame aligned");
145
            panic("config.init_addr is not frame aligned");
152
       
146
 
153
        as = as_create(0);
-
 
154
        if (!as)
-
 
155
            panic("as_create\n");
-
 
156
 
-
 
157
        rc = elf_load((elf_header_t *) config.init_addr, as);
147
        if (!task_run_program((void *)config.init_addr)) {
158
        if (rc != EE_OK) {
-
 
159
            printf("elf_load failed: %s\n", elf_error(rc));
-
 
160
        } else {
-
 
161
            u = task_create(as);
-
 
162
            if (!u)
-
 
163
                panic("task_create\n");
-
 
164
            t = thread_create(uinit, (void *)((elf_header_t *) config.init_addr)->e_entry, u, THREAD_USER_STACK);
-
 
165
            if (!t)
-
 
166
                panic("thread_create\n");
-
 
167
       
-
 
168
            /*
-
 
169
             * Create the data as_area.
-
 
170
             */
-
 
171
            a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
-
 
172
            if (!a)
-
 
173
                panic("as_area_create: stack\n");
148
            printf("Userspace not started.\n");
174
 
-
 
175
            thread_ready(t);
-
 
176
        }
149
        }
177
    }
150
    }
178
 
151
 
179
#ifdef CONFIG_TEST
152
#ifdef CONFIG_TEST
180
    test();
153
    test();