ia32.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2001-2004 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #include <arch.h>
00036 
00037 #include <arch/types.h>
00038 #include <typedefs.h>
00039 
00040 #include <arch/pm.h>
00041 
00042 #include <arch/drivers/ega.h>
00043 #include <arch/drivers/vesa.h>
00044 #include <genarch/i8042/i8042.h>
00045 #include <arch/drivers/i8254.h>
00046 #include <arch/drivers/i8259.h>
00047 
00048 #include <arch/context.h>
00049 
00050 #include <config.h>
00051 
00052 #include <arch/interrupt.h>
00053 #include <arch/asm.h>
00054 #include <genarch/acpi/acpi.h>
00055 
00056 #include <arch/bios/bios.h>
00057 
00058 #include <arch/mm/memory_init.h>
00059 #include <interrupt.h>
00060 #include <arch/debugger.h>
00061 #include <proc/thread.h>
00062 #include <syscall/syscall.h>
00063 #include <console/console.h>
00064 
00065 void arch_pre_mm_init(void)
00066 {
00067         pm_init();
00068 
00069         if (config.cpu_active == 1) {
00070                 bios_init();
00071                 i8259_init();   /* PIC */
00072                 i8254_init();   /* hard clock */
00073                 
00074                 exc_register(VECTOR_SYSCALL, "syscall", (iroutine) syscall);
00075                 
00076                 #ifdef CONFIG_SMP
00077                 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
00078                              (iroutine) tlb_shootdown_ipi);
00079                 #endif /* CONFIG_SMP */
00080         }
00081 }
00082 
00083 void arch_post_mm_init(void)
00084 {
00085         if (config.cpu_active == 1) {
00086 
00087 #ifdef CONFIG_FB
00088                 if (vesa_present()) 
00089                         vesa_init();
00090                 else
00091 #endif
00092                         ega_init();     /* video */
00093                 
00094                 
00095                 /* Enable debugger */
00096                 debugger_init();
00097                 /* Merge all memory zones to 1 big zone */
00098                 zone_merge_all();
00099         }
00100 }
00101 
00102 void arch_pre_smp_init(void)
00103 {
00104         if (config.cpu_active == 1) {
00105                 memory_print_map();
00106                 
00107                 #ifdef CONFIG_SMP
00108                 acpi_init();
00109                 #endif /* CONFIG_SMP */
00110         }
00111 }
00112 
00113 void arch_post_smp_init(void)
00114 {
00115         i8042_init();   /* keyboard controller */
00116 }
00117 
00118 void calibrate_delay_loop(void)
00119 {
00120         i8254_calibrate_delay_loop();
00121         if (config.cpu_active == 1) {
00122                 /*
00123                  * This has to be done only on UP.
00124                  * On SMP, i8254 is not used for time keeping and its interrupt pin remains masked.
00125                  */
00126                 i8254_normal_operation();
00127         }
00128 }
00129 
00135 __native sys_tls_set(__native addr)
00136 {
00137         THREAD->arch.tls = addr;
00138         set_tls_desc(addr);
00139 
00140         return 0;
00141 }
00142 
00146 void arch_grab_console(void)
00147 {
00148         i8042_grab();
00149 }
00153 void arch_release_console(void)
00154 {
00155         i8042_release();
00156 }
00157 

Generated on Sun Jun 18 16:38:50 2006 for HelenOS Kernel (ia32) by  doxygen 1.4.6