Statistics
| Branch: | Revision:

root / prex-0.9.0 / sys / kern / main.c @ 03e9c04a

History | View | Annotate | Download (2.79 KB)

1
/*-
2
 * Copyright (c) 2005-2009, Kohsuke Ohtani
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29

    
30
/*
31
 * main.c - kernel main routine
32
 */
33

    
34
#include <kernel.h>
35
#include <task.h>
36
#include <thread.h>
37
#include <timer.h>
38
#include <page.h>
39
#include <kmem.h>
40
#include <vm.h>
41
#include <sched.h>
42
#include <exception.h>
43
#include <irq.h>
44
#include <ipc.h>
45
#include <device.h>
46
#include <sync.h>
47
#include <hal.h>
48

    
49
/*
50
 * Initialization code.
51
 *
52
 * Called from kernel_start() routine that is
53
 * implemented in HAL.
54
 * We assume that the following machine state has
55
 * been already set before this routine.
56
 *        - Kernel BSS section is filled with 0.
57
 *        - Kernel stack is configured.
58
 *        - All interrupts are disabled.
59
 *        - Minimum page table is set. (MMU systems only)
60
 */
61
int
62
main(void)
63
{
64

    
65
        sched_lock();
66
        diag_init();
67
        DPRINTF((BANNER));
68

    
69
        /*
70
         * Initialize memory managers.
71
         */
72
        page_init();
73
        kmem_init();
74

    
75
        /*
76
         * Do machine-dependent
77
         * initialization.
78
         */
79
        machine_startup();
80

    
81
        /*
82
         * Initialize kernel core.
83
         */
84
        vm_init();
85
        task_init();
86
        thread_init();
87
        sched_init();
88
        exception_init();
89
        timer_init();
90
        object_init();
91
        msg_init();
92

    
93
        /*
94
         * Enable interrupt and
95
         * initialize devices.
96
         */
97
        irq_init();
98
        clock_init();
99
        device_init();
100

    
101
        /*
102
         * Set up boot tasks.
103
         */
104
        task_bootstrap();
105

    
106
        /*
107
         * Start scheduler and
108
         * enter idle loop.
109
         */
110
        sched_unlock();
111
        thread_idle();
112

    
113
        /* NOTREACHED */
114
        return 0;
115
}