Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2001-2004 Jakub Jermar
2
 * Copyright (c) 2001-2004 Jakub Jermar
-
 
3
 * Copyright (c) 2009 Jiri Svoboda
-
 
4
 * Copyright (c) 2009 Martin Decky
3
 * All rights reserved.
5
 * All rights reserved.
4
 *
6
 *
5
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
8
 * modification, are permitted provided that the following conditions
7
 * are met:
9
 * are met:
Line 36... Line 38...
36
 
38
 
37
#include <arch/types.h>
39
#include <arch/types.h>
38
 
40
 
39
#include <arch/pm.h>
41
#include <arch/pm.h>
40
 
42
 
-
 
43
#include <genarch/multiboot/multiboot.h>
-
 
44
#include <genarch/drivers/legacy/ia32/io.h>
41
#include <arch/drivers/ega.h>
45
#include <genarch/drivers/ega/ega.h>
42
#include <arch/drivers/vesa.h>
46
#include <arch/drivers/vesa.h>
-
 
47
#include <genarch/drivers/i8042/i8042.h>
43
#include <genarch/kbd/i8042.h>
48
#include <genarch/kbrd/kbrd.h>
44
#include <arch/drivers/i8254.h>
49
#include <arch/drivers/i8254.h>
45
#include <arch/drivers/i8259.h>
50
#include <arch/drivers/i8259.h>
46
 
51
 
47
#include <arch/context.h>
52
#include <arch/context.h>
48
 
53
 
Line 59... Line 64...
59
#include <arch/debugger.h>
64
#include <arch/debugger.h>
60
#include <proc/thread.h>
65
#include <proc/thread.h>
61
#include <syscall/syscall.h>
66
#include <syscall/syscall.h>
62
#include <console/console.h>
67
#include <console/console.h>
63
#include <ddi/device.h>
68
#include <ddi/device.h>
-
 
69
#include <sysinfo/sysinfo.h>
-
 
70
#include <arch/boot/boot.h>
64
 
71
 
65
#ifdef CONFIG_SMP
72
#ifdef CONFIG_SMP
66
#include <arch/smp/apic.h>
73
#include <arch/smp/apic.h>
67
#endif
74
#endif
68
 
75
 
-
 
76
/** Perform ia32-specific initialization before main_bsp() is called.
-
 
77
 *
-
 
78
 * @param signature Should contain the multiboot signature.
-
 
79
 * @param mi        Pointer to the multiboot information structure.
-
 
80
 */
-
 
81
void arch_pre_main(uint32_t signature, const multiboot_info_t *mi)
-
 
82
{
-
 
83
    /* Parse multiboot information obtained from the bootloader. */
-
 
84
    multiboot_info_parse(signature, mi);   
-
 
85
   
-
 
86
#ifdef CONFIG_SMP
-
 
87
    /* Copy AP bootstrap routines below 1 MB. */
-
 
88
    memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
-
 
89
        (size_t) &_hardcoded_unmapped_size);
-
 
90
#endif
-
 
91
}
-
 
92
 
69
void arch_pre_mm_init(void)
93
void arch_pre_mm_init(void)
70
{
94
{
71
    pm_init();
95
    pm_init();
72
 
96
 
73
    if (config.cpu_active == 1) {
97
    if (config.cpu_active == 1) {
Line 91... Line 115...
91
#ifdef CONFIG_FB
115
#ifdef CONFIG_FB
92
        if (vesa_present())
116
        if (vesa_present())
93
            vesa_init();
117
            vesa_init();
94
        else
118
        else
95
#endif
119
#endif
96
            ega_init(); /* video */
120
            ega_init(EGA_BASE, EGA_VIDEORAM);   /* video */
97
       
121
       
98
        /* Enable debugger */
122
        /* Enable debugger */
99
        debugger_init();
123
        debugger_init();
100
        /* Merge all memory zones to 1 big zone */
124
        /* Merge all memory zones to 1 big zone */
101
        zone_merge_all();
125
        zone_merge_all();
Line 121... Line 145...
121
    }
145
    }
122
}
146
}
123
 
147
 
124
void arch_post_smp_init(void)
148
void arch_post_smp_init(void)
125
{
149
{
126
    devno_t kbd = device_assign_devno();
150
    devno_t devno = device_assign_devno();
-
 
151
 
-
 
152
    /*
127
    devno_t mouse = device_assign_devno();
153
     * Initialize the keyboard module and conect it to stdin. Then
-
 
154
     * initialize the i8042 controller and connect it to kbrdin. Enable
128
    /* keyboard controller */
155
     * keyboard interrupts.
-
 
156
     */
-
 
157
    kbrd_init(stdin);
129
    i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE);
158
    (void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD, &kbrdin);
-
 
159
    trap_virtual_enable_irqs(1 << IRQ_KBD);
-
 
160
 
-
 
161
    /*
-
 
162
     * This is the necessary evil until the userspace driver is entirely
-
 
163
     * self-sufficient.
-
 
164
     */
-
 
165
    sysinfo_set_item_val("kbd", NULL, true);
-
 
166
    sysinfo_set_item_val("kbd.devno", NULL, devno);
-
 
167
    sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
-
 
168
    sysinfo_set_item_val("kbd.address.physical", NULL,
-
 
169
        (uintptr_t) I8042_BASE);
-
 
170
    sysinfo_set_item_val("kbd.address.kernel", NULL,
-
 
171
        (uintptr_t) I8042_BASE);
130
}
172
}
131
 
173
 
132
void calibrate_delay_loop(void)
174
void calibrate_delay_loop(void)
133
{
175
{
134
    i8254_calibrate_delay_loop();
176
    i8254_calibrate_delay_loop();
Line 157... Line 199...
157
/** Acquire console back for kernel
199
/** Acquire console back for kernel
158
 *
200
 *
159
 */
201
 */
160
void arch_grab_console(void)
202
void arch_grab_console(void)
161
{
203
{
-
 
204
#ifdef CONFIG_FB
-
 
205
    vesa_redraw();
-
 
206
#else
162
    i8042_grab();
207
    ega_redraw();
-
 
208
#endif
163
}
209
}
-
 
210
 
164
/** Return console to userspace
211
/** Return console to userspace
165
 *
212
 *
166
 */
213
 */
167
void arch_release_console(void)
214
void arch_release_console(void)
168
{
215
{
-
 
216
}
-
 
217
 
-
 
218
/** Construct function pointer
-
 
219
 *
-
 
220
 * @param fptr   function pointer structure
-
 
221
 * @param addr   function address
-
 
222
 * @param caller calling function address
-
 
223
 *
-
 
224
 * @return address of the function pointer
-
 
225
 *
-
 
226
 */
-
 
227
void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
-
 
228
{
169
    i8042_release();
229
    return addr;
170
}
230
}
171
 
231
 
172
/** @}
232
/** @}
173
 */
233
 */