Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

i386init.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 i386init.c 00008 00009 Abstract: 00010 00011 This module contains code to manipulate i386 hardware structures used 00012 only by the kernel. 00013 00014 Author: 00015 00016 Bryan Willman 22 Feb 90 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include "ki.h" 00023 00024 VOID 00025 KiInitializeMachineType ( 00026 VOID 00027 ); 00028 00029 00030 #ifdef ALLOC_PRAGMA 00031 #pragma alloc_text(INIT,KiInitializeGDT) 00032 #pragma alloc_text(INIT,KiInitializeGdtEntry) 00033 #pragma alloc_text(INIT,KiInitializeMachineType) 00034 #endif 00035 00036 00037 KIRQL KiProfileIrql = PROFILE_LEVEL; 00038 ULONG KeI386MachineType = 0; 00039 BOOLEAN KeI386NpxPresent; 00040 BOOLEAN KeI386FxsrPresent; 00041 ULONG KeI386ForceNpxEmulation; 00042 ULONG KeI386CpuType; 00043 ULONG KeI386CpuStep; 00044 PVOID Ki387RoundModeTable; // R3 emulators RoundingMode vector table 00045 ULONG KiBootFeatureBits; 00046 00047 ULONG KiInBiosCall = FALSE; 00048 ULONG FlagState = 0; // bios calls shouldn't automatically turn interrupts back on. 00049 00050 KTRAP_FRAME KiBiosFrame; 00051 00052 #if DBG 00053 UCHAR MsgDpcTrashedEsp[] = "\n*** DPC routine %lx trashed ESP\n"; 00054 UCHAR MsgDpcTimeout[] = "\n*** DPC routine > 1 sec --- This is not a break in KeUpdateSystemTime\n"; 00055 UCHAR MsgISRTimeout[] = "\n*** ISR at %lx took over .5 second\n"; 00056 UCHAR MsgISROverflow[] = "\n*** ISR at %lx - %d interrupts per .5 second\n"; 00057 00058 ULONG KiDPCTimeout = 110; 00059 ULONG KiISRTimeout = 55; 00060 ULONG KiISROverflow = 5500; 00061 ULONG KiSpinlockTimeout = 55; 00062 #endif 00063 00064 00065 00066 VOID 00067 KiInitializeGDT ( 00068 IN OUT PKGDTENTRY Gdt, 00069 IN USHORT GdtLimit, 00070 IN PKPCR Pcr, 00071 IN USHORT PcrLimit, 00072 IN PKTSS Tss, 00073 IN USHORT TssLimit, 00074 IN USHORT TebLimit 00075 ) 00076 00077 /*++ 00078 00079 Routine Description: 00080 00081 This procedure initializes a GDT. It will set standard values 00082 for all descriptors. 00083 00084 It will not set PCR->GDT. 00085 00086 It will set the PCR address in KGDT_PCR. 00087 00088 KGDT_R3_TEB will be set to a base of 0, with a limit of 1 page. 00089 00090 00091 Arguments: 00092 00093 Gdt - Supplies a pointer to an array of KGDTENTRYs. 00094 00095 GdtLimit - Supplies size (in bytes) of Gdt. Used to detect a 00096 GDT which is too small (which will cause a BUGCHECK) 00097 00098 Pcr - FLAT address of Pcr for processor Gdt is for. 00099 00100 PcrLimit - Size Limit of PCR in bytes. 00101 00102 Tss - FLAT adderss of TSS for processor Gdt is for. 00103 00104 TssLimit - Size limit of TSS in bytes. 00105 00106 TebLimit - Size limit of Teb in bytes. 00107 00108 Return Value: 00109 00110 None. 00111 00112 --*/ 00113 00114 { 00115 00116 if ((KGDT_NUMBER * 8) > GdtLimit) 00117 KeBugCheck(MEMORY_MANAGEMENT); 00118 00119 KiInitializeGdtEntry(&Gdt[KGDT_NULL], 0, 0, 0, 0, GRAN_PAGE); 00120 00121 KiInitializeGdtEntry( 00122 &Gdt[KGDT_R0_CODE], 0, (ULONG)-1, TYPE_CODE, DPL_SYSTEM, GRAN_PAGE); 00123 00124 KiInitializeGdtEntry( 00125 &Gdt[KGDT_R0_DATA], 0, (ULONG)-1, TYPE_DATA, DPL_SYSTEM, GRAN_PAGE); 00126 00127 KiInitializeGdtEntry(&Gdt[KGDT_R3_CODE], 0, 00128 (ULONG)-1, TYPE_CODE, DPL_USER, GRAN_PAGE); 00129 00130 KiInitializeGdtEntry(&Gdt[KGDT_R3_DATA], 0, 00131 (ULONG)-1, TYPE_DATA, DPL_USER, GRAN_PAGE); 00132 00133 KiInitializeGdtEntry( 00134 &Gdt[KGDT_TSS], (ULONG)Tss, TssLimit-1, 00135 TYPE_TSS, DPL_SYSTEM, GRAN_BYTE); 00136 00137 KiInitializeGdtEntry( 00138 &Gdt[KGDT_R0_PCR], (ULONG)Pcr, PcrLimit-1, 00139 TYPE_DATA, DPL_SYSTEM, GRAN_BYTE); 00140 00141 KiInitializeGdtEntry( 00142 &Gdt[KGDT_R3_TEB], 0, TebLimit-1, TYPE_DATA, DPL_USER, GRAN_BYTE); 00143 } 00144 00145 VOID 00146 KiInitializeGdtEntry ( 00147 OUT PKGDTENTRY GdtEntry, 00148 IN ULONG Base, 00149 IN ULONG Limit, 00150 IN USHORT Type, 00151 IN USHORT Dpl, 00152 IN USHORT Granularity 00153 ) 00154 00155 /*++ 00156 00157 Routine Description: 00158 00159 This function initializes a GDT entry. Base, Limit, Type (code, 00160 data), and Dpl (0 or 3) are set according to parameters. All other 00161 fields of the entry are set to match standard system values. 00162 00163 Arguments: 00164 00165 GdtEntry - GDT descriptor to be filled in. 00166 00167 Base - Linear address of the first byte mapped by the selector. 00168 00169 Limit - Size of the selector in pages. Note that 0 is 1 page 00170 while 0xffffff is 1 megapage = 4 gigabytes. 00171 00172 Type - Code or Data. All code selectors are marked readable, 00173 all data selectors are marked writeable. 00174 00175 Dpl - User (3) or System (0) 00176 00177 Granularity - 0 for byte, 1 for page 00178 00179 Return Value: 00180 00181 Pointer to the GDT entry. 00182 00183 --*/ 00184 00185 { 00186 GdtEntry->LimitLow = (USHORT)(Limit & 0xffff); 00187 GdtEntry->BaseLow = (USHORT)(Base & 0xffff); 00188 GdtEntry->HighWord.Bytes.BaseMid = (UCHAR)((Base & 0xff0000) >> 16); 00189 GdtEntry->HighWord.Bits.Type = Type; 00190 GdtEntry->HighWord.Bits.Dpl = Dpl; 00191 GdtEntry->HighWord.Bits.Pres = 1; 00192 GdtEntry->HighWord.Bits.LimitHi = (Limit & 0xf0000) >> 16; 00193 GdtEntry->HighWord.Bits.Sys = 0; 00194 GdtEntry->HighWord.Bits.Reserved_0 = 0; 00195 GdtEntry->HighWord.Bits.Default_Big = 1; 00196 GdtEntry->HighWord.Bits.Granularity = Granularity; 00197 GdtEntry->HighWord.Bytes.BaseHi = (UCHAR)((Base & 0xff000000) >> 24); 00198 } 00199 00200 VOID 00201 KiInitializeMachineType ( 00202 VOID 00203 ) 00204 00205 /*++ 00206 00207 Routine Description: 00208 00209 This function initializes machine type, i.e. MCA, ABIOS, ISA 00210 or EISA. 00211 N.B. This is a temporary routine. machine type: 00212 Byte 0 - Machine Type, ISA, EISA or MCA 00213 Byte 1 - CPU type, i386 or i486 00214 Byte 2 - Cpu Step, A or B ... etc. 00215 Highest bit indicates if NPX is present. 00216 00217 Arguments: 00218 00219 None. 00220 00221 Return Value: 00222 00223 None. 00224 00225 --*/ 00226 00227 { 00228 KeI386MachineType = KeLoaderBlock->u.I386.MachineType & 0x000ff; 00229 }

Generated on Sat May 15 19:40:18 2004 for test by doxygen 1.3.7