Skip to content

Commit

Permalink
fix EDK2 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed May 10, 2019
1 parent 50c59b2 commit 5c954da
Show file tree
Hide file tree
Showing 60 changed files with 1,122 additions and 124 deletions.
51 changes: 0 additions & 51 deletions CompilerIntrinsicsLib.inf

This file was deleted.

51 changes: 51 additions & 0 deletions CompilerIntrinsicsLib/CRT/Ia32/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Copyright (c) 2019, TianoCore and contributors. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Subject to the terms and conditions of this license, each copyright holder
and contributor hereby grants to those receiving rights under this license
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except for failure to satisfy the conditions of this license) patent
license to make, have made, use, offer to sell, sell, import, and otherwise
transfer this software, where such license applies only to those patent
claims, already acquired or hereafter acquired, licensable by such copyright
holder or contributor that are necessarily infringed by:

(a) their Contribution(s) (the licensed copyrights of copyright holders and
non-copyrightable additions of contributors, in source or binary form)
alone; or

(b) combination of their Contribution(s) with the work of authorship to
which such Contribution(s) was added by such copyright holder or
contributor, if, at the time the Contribution is added, such addition
causes such combination to be necessarily infringed. The patent license
shall not apply to any other combinations which include the
Contribution.

Except as expressly stated above, no rights or licenses from any copyright
holder or contributor is granted under this license, whether expressly, by
implication, estoppel or otherwise.

DISCLAIMER

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions CompilerIntrinsicsLib/CRT/Ia32/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
These files were taken from the edk2-libc project:
https://github.com/tianocore/edk2-libc/tree/master

They are licensed under a BSD-2-Clause-Patent license.
97 changes: 97 additions & 0 deletions CompilerIntrinsicsLib/CRT/Ia32/lldiv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/** @file
64-bit Math Worker Function.
The 32-bit versions of C compiler generate calls to library routines
to handle 64-bit math. These functions use non-standard calling conventions.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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 <Library/BaseLib.h>


/*
* Divides a 64-bit signed value with a 64-bit signed value and returns
* a 64-bit signed result.
*/
__declspec(naked) void __cdecl _alldiv (void)
{
//
// Wrapper Implementation over EDKII DivS64x64Remainder() routine
// INT64
// EFIAPI
// DivS64x64Remainder (
// IN UINT64 Dividend,
// IN UINT64 Divisor,
// OUT UINT64 *Remainder OPTIONAL
// )
//
_asm {

;Entry:
; Arguments are passed on the stack:
; 1st pushed: divisor (QWORD)
; 2nd pushed: dividend (QWORD)
;
;Exit:
; EDX:EAX contains the quotient (dividend/divisor)
; NOTE: this routine removes the parameters from the stack.
;
; Original local stack when calling _alldiv
; -----------------
; | |
; |---------------|
; | |
; |-- Divisor --|
; | |
; |---------------|
; | |
; |-- Dividend --|
; | |
; |---------------|
; | ReturnAddr** |
; ESP---->|---------------|
;

;
; Set up the local stack for NULL Reminder pointer
;
xor eax, eax
push eax

;
; Set up the local stack for Divisor parameter
;
mov eax, [esp + 20]
push eax
mov eax, [esp + 20]
push eax

;
; Set up the local stack for Dividend parameter
;
mov eax, [esp + 20]
push eax
mov eax, [esp + 20]
push eax

;
; Call native DivS64x64Remainder of BaseLib
;
call DivS64x64Remainder

;
; Adjust stack
;
add esp, 20

ret 16
}
}
100 changes: 100 additions & 0 deletions CompilerIntrinsicsLib/CRT/Ia32/lldvrm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/** @file
64-bit Math Worker Function.
The 32-bit versions of C compiler generate calls to library routines
to handle 64-bit math. These functions use non-standard calling conventions.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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 <Library/BaseLib.h>


/*
* Divides a 64-bit signed value by another 64-bit signed value and returns
* the 64-bit signed result and the 64-bit signed remainder.
*/
__declspec(naked) void __cdecl _alldvrm(void)
{
//
// Wrapper Implementation over EDKII DivS64x64Remainder() routine
// INT64
// EFIAPI
// DivS64x64Remainder (
// IN INT64 Dividend,
// IN INT64 Divisor,
// OUT INT64 *Remainder
// )
//
_asm {
; Original local stack when calling _alldvrm
; -----------------
; | |
; |---------------|
; | |
; |-- Divisor --|
; | |
; |---------------|
; | |
; |-- Dividend --|
; | |
; |---------------|
; | ReturnAddr** |
; ESP---->|---------------|
;
;
; On Exit:
; EDX:EAX contains the quotient (dividend/divisor)
; EBX:ECX contains the remainder (divided % divisor)
; NOTE: this routine removes the parameters from the stack.
;

;
; Set up the local stack for Reminder pointer
;
sub esp, 8
push esp

;
; Set up the local stack for Divisor parameter
;
mov eax, [esp + 28]
push eax
mov eax, [esp + 28]
push eax

;
; Set up the local stack for Dividend parameter
;
mov eax, [esp + 28]
push eax
mov eax, [esp + 28]
push eax

;
; Call native DivS64x64Remainder of BaseLib
;
call DivS64x64Remainder

;
; EDX:EAX contains the quotient (dividend/divisor)
; Put the Remainder in EBX:ECX
;
mov ecx, [esp + 20]
mov ebx, [esp + 24]

;
; Adjust stack
;
add esp, 28

ret 16
}
}
79 changes: 79 additions & 0 deletions CompilerIntrinsicsLib/CRT/Ia32/llmul.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/** @file
64-bit Math Worker Function.
The 32-bit versions of C compiler generate calls to library routines
to handle 64-bit math. These functions use non-standard calling conventions.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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 <Library/BaseLib.h>

/*
* Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value
* and returns a 64-bit result.
*/
__declspec(naked) void __cdecl _allmul (void)
{
//
// Wrapper Implementation over EDKII MultS64x64() routine
// INT64
// EFIAPI
// MultS64x64 (
// IN INT64 Multiplicand,
// IN INT64 Multiplier
// )
//
_asm {
; Original local stack when calling _allmul
; -----------------
; | |
; |---------------|
; | |
; |--Multiplier --|
; | |
; |---------------|
; | |
; |--Multiplicand-|
; | |
; |---------------|
; | ReturnAddr** |
; ESP---->|---------------|
;

;
; Set up the local stack for Multiplicand parameter
;
mov eax, [esp + 16]
push eax
mov eax, [esp + 16]
push eax

;
; Set up the local stack for Multiplier parameter
;
mov eax, [esp + 16]
push eax
mov eax, [esp + 16]
push eax

;
; Call native MulS64x64 of BaseLib
;
call MultS64x64

;
; Adjust stack
;
add esp, 16

ret 16
}
}
Loading

0 comments on commit 5c954da

Please sign in to comment.