test: i386init.c File Reference

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

# i386init.c File Reference

`#include "ki.h"`

Go to the source code of this file.

## Functions

VOID | KiInitializeMachineType (VOID)
VOID | KiInitializeGDT (IN OUT PKGDTENTRY Gdt, IN USHORT GdtLimit, IN PKPCR Pcr, IN USHORT PcrLimit, IN PKTSS Tss, IN USHORT TssLimit, IN USHORT TebLimit)
VOID | KiInitializeGdtEntry (OUT PKGDTENTRY GdtEntry, IN ULONG Base, IN ULONG Limit, IN USHORT Type, IN USHORT Dpl, IN USHORT Granularity)

## Variables

KIRQL | KiProfileIrql = PROFILE_LEVEL
ULONG | KeI386MachineType = 0
BOOLEAN | KeI386NpxPresent
BOOLEAN | KeI386FxsrPresent
ULONG | KeI386ForceNpxEmulation
ULONG | KeI386CpuType
ULONG | KeI386CpuStep
PVOID | Ki387RoundModeTable
ULONG | KiBootFeatureBits
ULONG | KiInBiosCall = FALSE
ULONG | FlagState = 0
KTRAP_FRAME | KiBiosFrame

## Function Documentation

VOID KiInitializeGDT | ( | IN OUT PKGDTENTRY | Gdt,
|  | IN USHORT | GdtLimit,
|  | IN PKPCR | Pcr,
|  | IN USHORT | PcrLimit,
|  | IN PKTSS | Tss,
|  | IN USHORT | TssLimit,
|  | IN USHORT | TebLimit
| ) |

Definition at line 67 of file i386init.c.

References KeBugCheck(), and KiInitializeGdtEntry().

    00079                    :
    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 }

VOID KiInitializeGdtEntry | ( | OUT PKGDTENTRY | GdtEntry,
|  | IN ULONG | Base,
|  | IN ULONG | Limit,
|  | IN USHORT | Type,
|  | IN USHORT | Dpl,
|  | IN USHORT | Granularity
| ) |

Definition at line 146 of file i386init.c.

References USHORT.

Referenced by KiInitializeGDT().

    00157                    :
    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 }

VOID KiInitializeMachineType | ( | VOID |  | ) |

Definition at line 201 of file i386init.c.

References KeI386MachineType, KeLoaderBlock, and _LOADER_PARAMETER_BLOCK::u.

    00207                    :
    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 }
    }

## Variable Documentation

ULONG FlagState = 0

| Definition at line 48 of file i386init.c.

ULONG KeI386CpuStep

| Definition at line 43 of file i386init.c. Referenced by KiInitializeKernel().

ULONG KeI386CpuType

| Definition at line 42 of file i386init.c.

ULONG KeI386ForceNpxEmulation

| Definition at line 41 of file i386init.c. Referenced by KeSetup80387OrEmulate().

BOOLEAN KeI386FxsrPresent

| Definition at line 40 of file i386init.c.

ULONG KeI386MachineType = 0

| Definition at line 38 of file i386init.c. Referenced by CmpInitializeHardwareConfiguration(), IopCreateArcNames(), KeI386VdmInitialize(), KiInitializeMachineType(), MapperAdjustResourceList(), PpFilterNtResource(), and VdmpInitialize().

BOOLEAN KeI386NpxPresent

| Definition at line 39 of file i386init.c. Referenced by CmpInitializeMachineDependentConfiguration(), KeContextFromKframes(), KeContextToKframes(), KeRestoreFloatingPointState(), KeSaveFloatingPointState(), KeSetup80387OrEmulate(), KiInitializeContextThread(), KiInitializeKernel(), and VdmSkipNpxInstruction().

PVOID Ki387RoundModeTable

| Definition at line 44 of file i386init.c. Referenced by KeSetup80387OrEmulate().

KTRAP_FRAME KiBiosFrame

| Definition at line 50 of file i386init.c.

ULONG KiBootFeatureBits

| Definition at line 45 of file i386init.c. Referenced by KiInitializeKernel().

ULONG KiInBiosCall = FALSE

| Definition at line 47 of file i386init.c.

KIRQL KiProfileIrql = PROFILE_LEVEL

| Definition at line 37 of file i386init.c. Referenced by KeStartProfile(), and KeStopProfile().