UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
/**
  Get Protected mode code segment from current GDT table.

  @return  Protected mode code segment value.
**/
Get Protected mode code segment from current GDT table.
Get Protected mode code segment from current GDT table .
UINT16
GetProtectedModeCS (
  VOID
  )
{
  IA32_DESCRIPTOR          GdtrDesc;
  IA32_SEGMENT_DESCRIPTOR  *GdtEntry;
  UINTN                    GdtEntryCount;
  UINT16                   Index;
  AsmReadGdtr (&GdtrDesc);
  GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR);
  GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base;
  for (Index = 0; Index < GdtEntryCount; Index++) {
    if (GdtEntry->Bits.L == 0) {
      if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.DB == 1) {
        break;
      }
    }
    GdtEntry++;
  }
  ASSERT (Index != GdtEntryCount);
  return Index * 8;
}
UINT16 GetProtectedModeCS ( VOID ) { IA32_DESCRIPTOR GdtrDesc ; IA32_SEGMENT_DESCRIPTOR * GdtEntry ; UINTN GdtEntryCount ; UINT16 Index ; AsmReadGdtr ( & GdtrDesc ) ; GdtEntryCount = ( GdtrDesc . Limit + 1 ) / sizeof ( IA32_SEGMENT_DESCRIPTOR ) ; GdtEntry = ( IA32_SEGMENT_DESCRIPTOR * ) GdtrDesc . Base ; for ( Index = 0 ; Index < GdtEntryCount ; Index ++ ) { if ( GdtEntry -> Bits . L == 0 ) { if ( GdtEntry -> Bits . Type > 8 && GdtEntry -> Bits . DB == 1 ) { break ; } } GdtEntry ++ ; } ASSERT ( Index != GdtEntryCount ) ; return Index * 8 ; }
Get Protected mode code segment from current GDT table.
Get Protected mode code segment from current GDT table .