X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseLib%2FX64%2FGccInlinePriv.c;fp=MdePkg%2FLibrary%2FBaseLib%2FX64%2FGccInlinePriv.c;h=f63e03e0c50b15e2d61423b90b9475273ccd6565;hp=c3feb9f9223544970f99c7db4ae1bd37c3f16346;hb=2f88bd3a1296c522317f1c21377876de63de5be7;hpb=1436aea4d5707e672672a11bda72be2c63c936c3 diff --git a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c b/MdePkg/Library/BaseLib/X64/GccInlinePriv.c index c3feb9f922..f63e03e0c5 100644 --- a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c +++ b/MdePkg/Library/BaseLib/X64/GccInlinePriv.c @@ -8,7 +8,6 @@ **/ - #include "BaseLibInternals.h" #include @@ -27,7 +26,6 @@ EnableInterrupts ( __asm__ __volatile__ ("sti"::: "memory"); } - /** Disables CPU interrupts. @@ -60,13 +58,13 @@ DisableInterrupts ( UINT64 EFIAPI AsmReadMsr64 ( - IN UINT32 Index + IN UINT32 Index ) { - UINT32 LowData; - UINT32 HighData; - UINT64 Value; - BOOLEAN Flag; + UINT32 LowData; + UINT32 HighData; + UINT64 Value; + BOOLEAN Flag; Flag = FilterBeforeMsrRead (Index, &Value); if (Flag) { @@ -75,9 +73,10 @@ AsmReadMsr64 ( : "=a" (LowData), // %0 "=d" (HighData) // %1 : "c" (Index) // %2 - ); + ); Value = (((UINT64)HighData) << 32) | LowData; } + FilterAfterMsrRead (Index, &Value); return Value; @@ -103,13 +102,13 @@ AsmReadMsr64 ( UINT64 EFIAPI AsmWriteMsr64 ( - IN UINT32 Index, - IN UINT64 Value + IN UINT32 Index, + IN UINT64 Value ) { - UINT32 LowData; - UINT32 HighData; - BOOLEAN Flag; + UINT32 LowData; + UINT32 HighData; + BOOLEAN Flag; Flag = FilterBeforeMsrWrite (Index, &Value); if (Flag) { @@ -121,8 +120,9 @@ AsmWriteMsr64 ( : "c" (Index), "a" (LowData), "d" (HighData) - ); + ); } + FilterAfterMsrWrite (Index, &Value); return Value; @@ -144,17 +144,16 @@ AsmReadCr0 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%cr0,%0" : "=r" (Data) // %0 - ); + ); return Data; } - /** Reads the current value of the Control Register 2 (CR2). @@ -171,12 +170,12 @@ AsmReadCr2 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%cr2, %0" : "=r" (Data) // %0 - ); + ); return Data; } @@ -197,17 +196,16 @@ AsmReadCr3 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%cr3, %0" : "=r" (Data) // %0 - ); + ); return Data; } - /** Reads the current value of the Control Register 4 (CR4). @@ -224,17 +222,16 @@ AsmReadCr4 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%cr4, %0" : "=r" (Data) // %0 - ); + ); return Data; } - /** Writes a value to Control Register 0 (CR0). @@ -256,11 +253,10 @@ AsmWriteCr0 ( "mov %0, %%cr0" : : "r" (Cr0) - ); + ); return Cr0; } - /** Writes a value to Control Register 2 (CR2). @@ -282,11 +278,10 @@ AsmWriteCr2 ( "mov %0, %%cr2" : : "r" (Cr2) - ); + ); return Cr2; } - /** Writes a value to Control Register 3 (CR3). @@ -308,11 +303,10 @@ AsmWriteCr3 ( "mov %0, %%cr3" : : "r" (Cr3) - ); + ); return Cr3; } - /** Writes a value to Control Register 4 (CR4). @@ -334,11 +328,10 @@ AsmWriteCr4 ( "mov %0, %%cr4" : : "r" (Cr4) - ); + ); return Cr4; } - /** Reads the current value of Debug Register 0 (DR0). @@ -355,17 +348,16 @@ AsmReadDr0 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr0, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 1 (DR1). @@ -382,17 +374,16 @@ AsmReadDr1 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr1, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 2 (DR2). @@ -409,17 +400,16 @@ AsmReadDr2 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr2, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 3 (DR3). @@ -436,17 +426,16 @@ AsmReadDr3 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr3, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 4 (DR4). @@ -463,17 +452,16 @@ AsmReadDr4 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr4, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 5 (DR5). @@ -490,17 +478,16 @@ AsmReadDr5 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr5, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 6 (DR6). @@ -517,17 +504,16 @@ AsmReadDr6 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr6, %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current value of Debug Register 7 (DR7). @@ -544,17 +530,16 @@ AsmReadDr7 ( VOID ) { - UINTN Data; + UINTN Data; __asm__ __volatile__ ( "mov %%dr7, %0" : "=r" (Data) - ); + ); return Data; } - /** Writes a value to Debug Register 0 (DR0). @@ -576,11 +561,10 @@ AsmWriteDr0 ( "mov %0, %%dr0" : : "r" (Dr0) - ); + ); return Dr0; } - /** Writes a value to Debug Register 1 (DR1). @@ -602,11 +586,10 @@ AsmWriteDr1 ( "mov %0, %%dr1" : : "r" (Dr1) - ); + ); return Dr1; } - /** Writes a value to Debug Register 2 (DR2). @@ -628,11 +611,10 @@ AsmWriteDr2 ( "mov %0, %%dr2" : : "r" (Dr2) - ); + ); return Dr2; } - /** Writes a value to Debug Register 3 (DR3). @@ -654,11 +636,10 @@ AsmWriteDr3 ( "mov %0, %%dr3" : : "r" (Dr3) - ); + ); return Dr3; } - /** Writes a value to Debug Register 4 (DR4). @@ -680,11 +661,10 @@ AsmWriteDr4 ( "mov %0, %%dr4" : : "r" (Dr4) - ); + ); return Dr4; } - /** Writes a value to Debug Register 5 (DR5). @@ -706,11 +686,10 @@ AsmWriteDr5 ( "mov %0, %%dr5" : : "r" (Dr5) - ); + ); return Dr5; } - /** Writes a value to Debug Register 6 (DR6). @@ -732,11 +711,10 @@ AsmWriteDr6 ( "mov %0, %%dr6" : : "r" (Dr6) - ); + ); return Dr6; } - /** Writes a value to Debug Register 7 (DR7). @@ -758,11 +736,10 @@ AsmWriteDr7 ( "mov %0, %%dr7" : : "r" (Dr7) - ); + ); return Dr7; } - /** Reads the current value of Code Segment Register (CS). @@ -783,12 +760,11 @@ AsmReadCs ( __asm__ __volatile__ ( "mov %%cs, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of Data Segment Register (DS). @@ -809,12 +785,11 @@ AsmReadDs ( __asm__ __volatile__ ( "mov %%ds, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of Extra Segment Register (ES). @@ -835,12 +810,11 @@ AsmReadEs ( __asm__ __volatile__ ( "mov %%es, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of FS Data Segment Register (FS). @@ -861,12 +835,11 @@ AsmReadFs ( __asm__ __volatile__ ( "mov %%fs, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of GS Data Segment Register (GS). @@ -887,12 +860,11 @@ AsmReadGs ( __asm__ __volatile__ ( "mov %%gs, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of Stack Segment Register (SS). @@ -913,12 +885,11 @@ AsmReadSs ( __asm__ __volatile__ ( "mov %%ss, %0" :"=a" (Data) - ); + ); return Data; } - /** Reads the current value of Task Register (TR). @@ -939,12 +910,11 @@ AsmReadTr ( __asm__ __volatile__ ( "str %0" : "=r" (Data) - ); + ); return Data; } - /** Reads the current Global Descriptor Table Register(GDTR) descriptor. @@ -957,16 +927,15 @@ AsmReadTr ( VOID EFIAPI InternalX86ReadGdtr ( - OUT IA32_DESCRIPTOR *Gdtr + OUT IA32_DESCRIPTOR *Gdtr ) { __asm__ __volatile__ ( "sgdt %0" : "=m" (*Gdtr) - ); + ); } - /** Writes the current Global Descriptor Table Register (GDTR) descriptor. @@ -979,18 +948,16 @@ InternalX86ReadGdtr ( VOID EFIAPI InternalX86WriteGdtr ( - IN CONST IA32_DESCRIPTOR *Gdtr + IN CONST IA32_DESCRIPTOR *Gdtr ) { __asm__ __volatile__ ( "lgdt %0" : : "m" (*Gdtr) - ); - + ); } - /** Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. @@ -1003,16 +970,15 @@ InternalX86WriteGdtr ( VOID EFIAPI InternalX86ReadIdtr ( - OUT IA32_DESCRIPTOR *Idtr + OUT IA32_DESCRIPTOR *Idtr ) { __asm__ __volatile__ ( "sidt %0" : "=m" (*Idtr) - ); + ); } - /** Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. @@ -1025,17 +991,16 @@ InternalX86ReadIdtr ( VOID EFIAPI InternalX86WriteIdtr ( - IN CONST IA32_DESCRIPTOR *Idtr + IN CONST IA32_DESCRIPTOR *Idtr ) { __asm__ __volatile__ ( "lidt %0" : : "m" (*Idtr) - ); + ); } - /** Reads the current Local Descriptor Table Register(LDTR) selector. @@ -1056,12 +1021,11 @@ AsmReadLdtr ( __asm__ __volatile__ ( "sldt %0" : "=g" (Data) // %0 - ); + ); return Data; } - /** Writes the current Local Descriptor Table Register (GDTR) selector. @@ -1074,14 +1038,14 @@ AsmReadLdtr ( VOID EFIAPI AsmWriteLdtr ( - IN UINT16 Ldtr + IN UINT16 Ldtr ) { __asm__ __volatile__ ( "lldtw %0" : : "g" (Ldtr) // %0 - ); + ); } /** @@ -1098,7 +1062,7 @@ AsmWriteLdtr ( UINT64 EFIAPI AsmReadPmc ( - IN UINT32 Index + IN UINT32 Index ) { UINT32 LowData; @@ -1109,7 +1073,7 @@ AsmReadPmc ( : "=a" (LowData), "=d" (HiData) : "c" (Index) - ); + ); return (((UINT64)HiData) << 32) | LowData; } @@ -1133,9 +1097,9 @@ AsmReadPmc ( UINTN EFIAPI AsmMonitor ( - IN UINTN Eax, - IN UINTN Ecx, - IN UINTN Edx + IN UINTN Eax, + IN UINTN Ecx, + IN UINTN Edx ) { __asm__ __volatile__ ( @@ -1144,7 +1108,7 @@ AsmMonitor ( : "a" (Eax), "c" (Ecx), "d" (Edx) - ); + ); return Eax; } @@ -1166,8 +1130,8 @@ AsmMonitor ( UINTN EFIAPI AsmMwait ( - IN UINTN Eax, - IN UINTN Ecx + IN UINTN Eax, + IN UINTN Ecx ) { __asm__ __volatile__ ( @@ -1175,7 +1139,7 @@ AsmMwait ( : : "a" (Eax), "c" (Ecx) - ); + ); return Eax; } @@ -1210,10 +1174,8 @@ AsmInvd ( ) { __asm__ __volatile__ ("invd":::"memory"); - } - /** Flushes a cache line from all the instruction and data caches within the coherency domain of the CPU. @@ -1232,7 +1194,7 @@ AsmInvd ( VOID * EFIAPI AsmFlushCacheLine ( - IN VOID *LinearAddress + IN VOID *LinearAddress ) { __asm__ __volatile__ ( @@ -1240,7 +1202,7 @@ AsmFlushCacheLine ( : : "r" (LinearAddress) : "memory" - ); + ); - return LinearAddress; + return LinearAddress; }