提交 b69a9bbd 编写于 作者: V vit9696

Build: Improve IA32 compatibility

上级 47a10510
......@@ -80,7 +80,7 @@ GenerateSlideValue (
IN SLIDE_SUPPORT_STATE *SlideSupport
)
{
UINT64 Slide;
UINT32 Slide;
//
// Handle 0 slide case.
......@@ -90,7 +90,7 @@ GenerateSlideValue (
}
do {
Slide = GetPseudoRandomNumber64 () % SlideSupport->ValidSlideCount;
DivU64x32Remainder (GetPseudoRandomNumber64 (), SlideSupport->ValidSlideCount, &Slide);
} while (Slide == 0);
return SlideSupport->ValidSlides[Slide];
......
......@@ -46,29 +46,4 @@ typedef PACKED struct ASM_KERNEL_JUMP_ {
#pragma pack(pop)
/**
Assembly interface to save UEFI environment state in specific way.
@param[in,out] AsmState Assembly state to update, can be preserved.
**/
VOID
EFIAPI
AsmAppleMapPlatformSaveState (
IN OUT ASM_SUPPORT_STATE *AsmState
);
/**
Assembly interface for backjump from kernel code.
Takes kernel arguments through RAX or EAX register.
**/
VOID
AsmAppleMapPlatformPrepareKernelState (
);
/**
Assembly global variable containing ASM_SUPPORT_STATE address.
Must fit into lower 32-bit bytes due to 32-bit .
**/
extern UINT32 gOcAbcAsmStateAddr32;
#endif // CONTEXT_SWITCH_H
/** @file
Copyright (C) 2019, vit9696. All rights reserved.
All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "../BootCompatInternal.h"
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
VOID
AppleMapPlatformSaveState (
IN OUT ASM_SUPPORT_STATE *AsmState,
OUT ASM_KERNEL_JUMP *KernelJump
)
{
CpuDeadLoop ();
}
......@@ -36,12 +36,14 @@
KernelSupport.c
OcAppleBootCompatLib.c
ServiceOverrides.c
# All headers should go to [Sources], this sounds like a bug in EDK II Build System.
IA32/ContextSwitch.h
X64/ContextSwitch.h
[Sources.IA32]
IA32/ContextSwitch.h
IA32/ContextSwitchSupport.c
[Sources.X64]
X64/ContextSwitch.h
X64/ContextSwitch.nasm
X64/ContextSwitchSupport.c
......
......@@ -792,7 +792,7 @@ InternalSimplePointerPollNotifyFunction (
EndTime = GetTimeInNanoSecond (EndTime - StartTime);
// Maximum time allowed in this function is half the interval plus some margin (0.55 * 100ns)
if (EndTime > mSimplePointerPollTime * 55ULL) {
mSimplePointerPollTime = EndTime / 50ULL;
mSimplePointerPollTime = DivU64x32 (EndTime, 50);
if (mSimplePointerPollTime > MAX_POINTER_POLL_FREQUENCY) {
mSimplePointerPollTime = MAX_POINTER_POLL_FREQUENCY;
}
......
;------------------------------------------------------------------------------
; @file
; Copyright (C) 2020, vit9696. All rights reserved.
;
; All rights reserved.
;
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;------------------------------------------------------------------------------
BITS 32
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; AsmAddRngJitter (
; IN UINT64 Value
; );
;------------------------------------------------------------------------------
align 8
global ASM_PFX(AsmAddRngJitter)
ASM_PFX(AsmAddRngJitter):
; This assembly code corresponds to Hamming Weight implementation for targets
; with fast multiplication.
; REF: https://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation
push esi
mov edx, [esp+8]
mov eax, [esp+12]
mov ecx, edx
shr ecx, 1
mov esi, eax
shr esi, 1
and esi, 55555555h
and ecx, 55555555h
sub edx, ecx
sbb eax, esi
mov ecx, eax
and ecx, 33333333h
mov esi, edx
and esi, 33333333h
shr edx, 2
shr eax, 2
and eax, 33333333h
add eax, ecx
and edx, 33333333h
add edx, esi
mov ecx, eax
shld ecx, edx, 1Ch
mov esi, eax
shr esi, 4
add ecx, edx
adc esi, eax
and esi, 0F0F0F0Fh
and ecx, 0F0F0F0Fh
mov edx, 1010101h
mov eax, ecx
mul edx
imul ecx, 1010101h
add ecx, edx
imul eax, esi, 1010101h
add eax, ecx
shr eax, 18h
pop esi
ret
......@@ -32,6 +32,9 @@
OcRngLib.c
OcRngInternals.h
[Sources.IA32]
IA32/RngDelay.nasm
[Sources.X64]
X64/RngDelay.nasm
......
......@@ -28,7 +28,6 @@ SECTION .text
align 8
global ASM_PFX(AsmAddRngJitter)
ASM_PFX(AsmAddRngJitter):
BITS 64
; This assembly code corresponds to Hamming Weight implementation for targets
; with fast multiplication.
; REF: https://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册