[ros-dev] [ros-diffs] [dgorbachev] 42305: Add a hack in KiSystemStartupReal function until Better Times.

Aleksey Bragin aleksey at reactos.org
Thu Jul 30 21:27:14 CEST 2009


That function is not supposed to be called by old bootloader  
directly. Why is that needed? And why in this function?


WBR,
Aleksey Bragin.

On Jul 30, 2009, at 9:54 PM, dgorbachev at svn.reactos.org wrote:

> Author: dgorbachev
> Date: Thu Jul 30 19:54:01 2009
> New Revision: 42305
>
> URL: http://svn.reactos.org/svn/reactos?rev=42305&view=rev
> Log:
> Add a hack in KiSystemStartupReal function until Better Times.
>
> Modified:
>     trunk/reactos/ntoskrnl/ke/i386/kiinit.c
>
> Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
> URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/ 
> i386/kiinit.c?rev=42305&r1=42304&r2=42305&view=diff
> ====================================================================== 
> ========
> --- trunk/reactos/ntoskrnl/ke/i386/kiinit.c [iso-8859-1] (original)
> +++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c [iso-8859-1] Thu Jul 30  
> 19:54:01 2009
> @@ -712,18 +712,34 @@
>      Ke386SetDs(KGDT_R3_DATA | RPL_MASK);
>      Ke386SetEs(KGDT_R3_DATA | RPL_MASK);
>
> -    /* Save NMI and double fault traps */
> -    RtlCopyMemory(&NmiEntry, &Idt[2], sizeof(KIDTENTRY));
> -    RtlCopyMemory(&DoubleFaultEntry, &Idt[8], sizeof(KIDTENTRY));
> -
> -    /* Copy kernel's trap handlers */
> -    RtlCopyMemory(Idt,
> -                  (PVOID)KiIdtDescriptor.Base,
> -                  KiIdtDescriptor.Limit + 1);
> -
> -    /* Restore NMI and double fault */
> -    RtlCopyMemory(&Idt[2], &NmiEntry, sizeof(KIDTENTRY));
> -    RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY));
> +    /* HACK compensates for KiRosPrepareForSystemStartup hack */
> +    if ((ULONG)Idt == KiIdtDescriptor.Base)
> +    {
> +        USHORT FlippedSelector;
> +
> +        FlippedSelector = KiIdt[2].Selector;
> +        KiIdt[2].Selector = KiIdt[2].ExtendedOffset;
> +        KiIdt[2].ExtendedOffset = FlippedSelector;
> +
> +        FlippedSelector = KiIdt[8].Selector;
> +        KiIdt[8].Selector = KiIdt[8].ExtendedOffset;
> +        KiIdt[8].ExtendedOffset = FlippedSelector;
> +    }
> +    else
> +    {
> +        /* Save NMI and double fault traps */
> +        RtlCopyMemory(&NmiEntry, &Idt[2], sizeof(KIDTENTRY));
> +        RtlCopyMemory(&DoubleFaultEntry, &Idt[8], sizeof(KIDTENTRY));
> +
> +        /* Copy kernel's trap handlers */
> +        RtlCopyMemory(Idt,
> +                      (PVOID)KiIdtDescriptor.Base,
> +                      KiIdtDescriptor.Limit + 1);
> +
> +        /* Restore NMI and double fault */
> +        RtlCopyMemory(&Idt[2], &NmiEntry, sizeof(KIDTENTRY));
> +        RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY));
> +    }
>
>  AppCpuInit:
>      /* Loop until we can release the freeze lock */
>
>




More information about the Ros-dev mailing list