Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 43... Line 43...
43
#include <proc/uarg.h>
43
#include <proc/uarg.h>
44
#include <console/console.h>
44
#include <console/console.h>
45
#include <ddi/device.h>
45
#include <ddi/device.h>
46
#include <ddi/irq.h>
46
#include <ddi/irq.h>
47
#include <arch/drivers/pic.h>
47
#include <arch/drivers/pic.h>
-
 
48
#include <macros.h>
-
 
49
#include <string.h>
48
 
50
 
49
#define IRQ_COUNT   64
51
#define IRQ_COUNT  64
50
 
52
 
51
bootinfo_t bootinfo;
53
bootinfo_t bootinfo;
52
 
54
 
-
 
55
/** Performs ppc32-specific initialization before main_bsp() is called. */
53
void arch_pre_main(void)
56
void arch_pre_main(void)
54
{
57
{
55
    /* Setup usermode */
-
 
56
    init.cnt = bootinfo.taskmap.count;
58
    init.cnt = bootinfo.taskmap.count;
57
   
59
   
58
    uint32_t i;
60
    uint32_t i;
59
   
61
   
60
    for (i = 0; i < bootinfo.taskmap.count; i++) {
62
    for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) {
61
        init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
63
        init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
62
        init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
64
        init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
-
 
65
        strncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,
-
 
66
            CONFIG_TASK_NAME_BUFLEN);
63
    }
67
    }
64
}
68
}
65
 
69
 
66
void arch_pre_mm_init(void)
70
void arch_pre_mm_init(void)
67
{
71
{
Line 74... Line 78...
74
 
78
 
75
void arch_post_mm_init(void)
79
void arch_post_mm_init(void)
76
{
80
{
77
    if (config.cpu_active == 1) {
81
    if (config.cpu_active == 1) {
78
        /* Initialize framebuffer */
82
        /* Initialize framebuffer */
-
 
83
        if (bootinfo.screen.addr) {
79
        unsigned int visual;
84
            unsigned int visual;
80
       
85
           
81
        switch (bootinfo.screen.bpp) {
86
            switch (bootinfo.screen.bpp) {
82
        case 8:
87
            case 8:
83
            visual = VISUAL_INDIRECT_8;
88
                visual = VISUAL_INDIRECT_8;
84
            break;
89
                break;
85
        case 16:
90
            case 16:
86
            visual = VISUAL_RGB_5_5_5;
91
                visual = VISUAL_RGB_5_5_5;
87
            break;
92
                break;
88
        case 24:
93
            case 24:
89
            visual = VISUAL_RGB_8_8_8;
94
                visual = VISUAL_RGB_8_8_8;
90
            break;
95
                break;
91
        case 32:
96
            case 32:
92
            visual = VISUAL_RGB_0_8_8_8;
97
                visual = VISUAL_RGB_0_8_8_8;
93
            break;
98
                break;
94
        default:
99
            default:
95
            panic("Unsupported bits per pixel");
100
                panic("Unsupported bits per pixel.");
-
 
101
            }
-
 
102
            fb_properties_t prop = {
-
 
103
                .addr = bootinfo.screen.addr,
-
 
104
                .offset = 0,
-
 
105
                .x = bootinfo.screen.width,
-
 
106
                .y = bootinfo.screen.height,
-
 
107
                .scan = bootinfo.screen.scanline,
-
 
108
                .visual = visual,
-
 
109
            };
-
 
110
            fb_init(&prop);
96
        }
111
        }
97
        fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual);
-
 
98
       
112
       
99
        /* Initialize IRQ routing */
113
        /* Initialize IRQ routing */
100
        irq_init(IRQ_COUNT, IRQ_COUNT);
114
        irq_init(IRQ_COUNT, IRQ_COUNT);
101
   
-
 
102
        /* Initialize PIC */
-
 
103
        pic_init(bootinfo.keyboard.addr, PAGE_SIZE);
-
 
104
       
115
       
-
 
116
        if (bootinfo.macio.addr) {
-
 
117
            /* Initialize PIC */
-
 
118
            pic_init(bootinfo.macio.addr, PAGE_SIZE);
-
 
119
           
105
        /* Initialize I/O controller */
120
            /* Initialize I/O controller */
-
 
121
            cuda_init(device_assign_devno(),
106
        cuda_init(device_assign_devno(), bootinfo.keyboard.addr + 0x16000, 2 * PAGE_SIZE);
122
                bootinfo.macio.addr + 0x16000, 2 * PAGE_SIZE);
-
 
123
        }
107
       
124
       
108
        /* Merge all zones to 1 big zone */
125
        /* Merge all zones to 1 big zone */
109
        zone_merge_all();
126
        zone_merge_all();
110
    }
127
    }
111
}
128
}
Line 126... Line 143...
126
{
143
{
127
}
144
}
128
 
145
 
129
void userspace(uspace_arg_t *kernel_uarg)
146
void userspace(uspace_arg_t *kernel_uarg)
130
{
147
{
131
    userspace_asm((uintptr_t) kernel_uarg->uspace_uarg, (uintptr_t) kernel_uarg->uspace_stack + THREAD_STACK_SIZE - SP_DELTA, (uintptr_t) kernel_uarg->uspace_entry);
148
    userspace_asm((uintptr_t) kernel_uarg->uspace_uarg,
-
 
149
        (uintptr_t) kernel_uarg->uspace_stack +
-
 
150
        THREAD_STACK_SIZE - SP_DELTA,
-
 
151
        (uintptr_t) kernel_uarg->uspace_entry);
132
   
152
   
133
    /* Unreachable */
153
    /* Unreachable */
134
    for (;;)
154
    while (true);
135
        ;
-
 
136
}
155
}
137
 
156
 
138
/** Acquire console back for kernel
157
/** Acquire console back for kernel
139
 *
158
 *
140
 */
159
 */
141
void arch_grab_console(void)
160
void arch_grab_console(void)
142
{
161
{
143
    cuda_grab();
162
    fb_redraw();
144
}
163
}
145
 
164
 
146
/** Return console to userspace
165
/** Return console to userspace
147
 *
166
 *
148
 */
167
 */
149
void arch_release_console(void)
168
void arch_release_console(void)
150
{
169
{
-
 
170
}
-
 
171
 
-
 
172
/** Construct function pointer
-
 
173
 *
-
 
174
 * @param fptr   function pointer structure
-
 
175
 * @param addr   function address
-
 
176
 * @param caller calling function address
-
 
177
 *
-
 
178
 * @return address of the function pointer
-
 
179
 *
-
 
180
 */
-
 
181
void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
-
 
182
{
151
    cuda_release();
183
    return addr;
152
}
184
}
153
 
185
 
154
/** @}
186
/** @}
155
 */
187
 */