Implement ArSetGdtEntryBase() routine
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Rafal Kupiec 2023-03-02 22:51:57 +01:00
parent 9f311db9fc
commit dfae0b4727
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 86 additions and 7 deletions

View File

@ -73,6 +73,40 @@ ArInitializeProcessor(VOID)
ArpIdentifyProcessor();
}
/**
* Updates an existing AMD64 GDT entry with new base address.
*
* @param Gdt
* Supplies a pointer to the GDT.
*
* @param Selector
* Specifies a segment selector of the GDT entry.
*
* @param Base
* Specifies a base address value of the descriptor.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,
IN USHORT Selector,
IN ULONG_PTR Base)
{
PKGDTENTRY GdtEntry;
/* Get GDT entry */
GdtEntry = (PKGDTENTRY)((ULONG_PTR)Gdt + (Selector & ~RPL_MASK));
/* Set new GDT descriptor base */
GdtEntry->BaseLow = (Base & 0xFFFF);
GdtEntry->Bytes.BaseMiddle = ((Base >> 16) & 0xFF);
GdtEntry->Bytes.BaseHigh = ((Base >> 24) & 0xFF);
GdtEntry->BaseUpper = (Base >> 32);
}
/**
* Identifies processor type (vendor, model, stepping) as well as looks for available CPU features and stores them
* in Processor Control Block (PRCB).
@ -450,14 +484,14 @@ ArpSetGdtEntry(IN PKGDTENTRY Gdt,
GdtEntry = (PKGDTENTRY)((ULONG_PTR)Gdt + (Selector & ~RPL_MASK));
/* Set GDT descriptor base */
GdtEntry->BaseLow = Base & 0xFFFF;
GdtEntry->Bytes.BaseMiddle = (Base >> 16) & 0xFF;
GdtEntry->Bytes.BaseHigh = (Base >> 24) & 0xFF;
GdtEntry->BaseUpper = Base >> 32;
GdtEntry->BaseLow = (Base & 0xFFFF);
GdtEntry->Bytes.BaseMiddle = ((Base >> 16) & 0xFF);
GdtEntry->Bytes.BaseHigh = ((Base >> 24) & 0xFF);
GdtEntry->BaseUpper = (Base >> 32);
/* Set descriptor limit */
GdtEntry->LimitLow = Limit & 0xFFFF;
GdtEntry->Bits.LimitHigh = (Limit >> 16) & 0xF;
GdtEntry->LimitLow = (Limit & 0xFFFF);
GdtEntry->Bits.LimitHigh = ((Limit >> 16) & 0xF);
/* Initialize GDT entry */
GdtEntry->Bits.DefaultBig = !!(SegmentMode & 2);

View File

@ -71,6 +71,39 @@ ArInitializeProcessor(VOID)
ArpIdentifyProcessor();
}
/**
* Updates an existing i686 GDT entry with new base address.
*
* @param Gdt
* Supplies a pointer to the GDT.
*
* @param Selector
* Specifies a segment selector of the GDT entry.
*
* @param Base
* Specifies a base address value of the descriptor.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,
IN USHORT Selector,
IN ULONG_PTR Base)
{
PKGDTENTRY GdtEntry;
/* Get GDT entry */
GdtEntry = (PKGDTENTRY)((ULONG_PTR)Gdt + (Selector & ~RPL_MASK));
/* Set new GDT descriptor base */
GdtEntry->BaseLow = (Base & 0xFFFF);
GdtEntry->Bytes.BaseMiddle = ((Base >> 16) & 0xFF);
GdtEntry->Bytes.BaseHigh = ((Base >> 24) & 0xFF);
}
/**
* Identifies processor type (vendor, model, stepping) as well as looks for available CPU features and stores them
* in Processor Control Block (PRCB).
@ -416,7 +449,7 @@ ArpSetDoubleFaultTssEntry(IN PKPROCESSOR_BLOCK ProcessorBlock)
}
/**
* Fills in an AMD64 GDT entry.
* Fills in an i686 GDT entry.
*
* @param Gdt
* Supplies a pointer to the GDT.

View File

@ -12,6 +12,12 @@
#include <xtos.h>
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,
IN USHORT Selector,
IN ULONG_PTR Base);
XTCDECL
VOID
ArpHandleSystemCall32();

View File

@ -12,6 +12,12 @@
#include <xtos.h>
XTAPI
VOID
ArSetGdtEntryBase(IN PKGDTENTRY Gdt,
IN USHORT Selector,
IN ULONG_PTR Base);
XTCDECL
VOID
ArpHandleTrap00();