On Tue, Aug 19, 2014 at 4:57 PM, Jordan Justen
<[email protected]> wrote:
> This series:
>  * Adds support for creating object files from .nasm source files to
>    allow NASM source files to be linked into libraries and images
>  * Adds NASM source files for Thunk16 on IA32 and X64
>  * Convert BaseLib to use NASM Source Files for Thunk16 rather than
>    GNU Assembler (.S) files
>    - This will make NASM a build requirement for MdePkg with IA32 &
>      X64 on all toolchains except MSVC and ICC.
>
> Thanks for Liming Gao for the tools_def changes for MSVC. (But, these
> have not been tested very well yet.)
>
> This series is available in this git branch:
> https://github.com/jljusten/edk2.git nasm-v1

I update my nasm branch based on the feedback.

The differences vs. v1 are in the attached patch.

Is anyone interested in seeing a v2 posted to the list?

Liming, in patch 1, I mentioned I only tested with GCC49. Did you have
any testing to add to that?

-Jordan

> Jordan Justen (8):
>   BaseTools/tools_def: Add NASM_FLAGS
>   BaseTools/build_rule: Add .nasm => .obj build rule
>   MdePkg/Base.h: Always define ASM_PFX
>   MdePkg/BaseLib Thunk16: Replace IA32 GAS Thunk16 with NASM version
>   MdePkg/BaseLib Thunk16: Replace X64 GAS Thunk16 with NASM version
>   MdePkg/BaseLib NASM Thunk16: Use NASM local labels
>   MdePkg/BaseLib NASM Thunk16: Use bits 16 for 16-bit code
>   MdePkg/BaseLib NASM Thunk16: Remove remaining 'DB' code
>
>  BaseTools/Conf/build_rule.template       |  15 ++
>  BaseTools/Conf/tools_def.template        | 287 ++++++++++++++++++++++++++-
>  MdePkg/Include/AArch64/ProcessorBind.h   |   4 +
>  MdePkg/Include/Arm/ProcessorBind.h       |   4 +
>  MdePkg/Include/Base.h                    |  25 ++-
>  MdePkg/Include/Ebc/ProcessorBind.h       |   4 +
>  MdePkg/Include/Ia32/ProcessorBind.h      |   4 +
>  MdePkg/Include/Ipf/ProcessorBind.h       |   4 +
>  MdePkg/Include/X64/ProcessorBind.h       |   4 +
>  MdePkg/Library/BaseLib/BaseLib.inf       |   4 +-
>  MdePkg/Library/BaseLib/Ia32/Thunk16.nasm | 260 +++++++++++++++++++++++++
>  MdePkg/Library/BaseLib/X64/Thunk16.nasm  | 321 
> +++++++++++++++++++++++++++++++
>  12 files changed, 914 insertions(+), 22 deletions(-)
>  create mode 100644 MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
>  create mode 100644 MdePkg/Library/BaseLib/X64/Thunk16.nasm
>
> --
> 2.1.0
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index a5ddbcd..ff2f8b8 100644
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -670,7 +670,7 @@ DEFINE SOURCERY_CYGWIN_TOOLS = /cygdrive/c/Program Files/CodeSourcery/Sourcery G
 #
 # Other Supported Tools
 # =====================
-#   NASM                 2.0.3   http://www.nasm.us/
+#   NASM 2.0.7 or later                 http://www.nasm.us/
 #
 ####################################################################################
 ####################################################################################
diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm b/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
index 2e5a580..844d564 100644
--- a/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm
@@ -174,7 +174,7 @@ BITS    16
 
 o32 retf                                ; transfer control to user code
 
-ALIGN   0x10
+ALIGN   16
 _NullSegDesc    DQ      0
 _16CsDesc:
                 DW      -1
@@ -224,7 +224,6 @@ BITS    32
     mov     eax, [esp + 40]             ; eax <- address of transition code
     mov     esi, edx                    ; esi <- 16-bit stack segment
     lea     edx, [eax + (_BackFromUserCode.SavedCr0End - m16Start)]
-    nop
     mov     ecx, eax
     and     ecx, 0fh
     shl     eax, 12
diff --git a/MdePkg/Library/BaseLib/X64/Thunk16.nasm b/MdePkg/Library/BaseLib/X64/Thunk16.nasm
index 8858e74..c7cde3c 100644
--- a/MdePkg/Library/BaseLib/X64/Thunk16.nasm
+++ b/MdePkg/Library/BaseLib/X64/Thunk16.nasm
@@ -190,7 +190,7 @@ o32 lidt    [cs:bp + (_16Idtr - .Base)]
 
 o32 retf                                ; transfer control to user code
 
-ALIGN   0x8
+ALIGN   8
 
 CODE16  equ _16Code - $
 DATA16  equ _16Data - $
@@ -237,11 +237,11 @@ BITS    64
     push    rsi
     push    rdi
     
-    mov     rbx, ds
+    mov     ebx, ds
     push    rbx          ; Save ds segment register on the stack
-    mov     rbx, es
+    mov     ebx, es
     push    rbx          ; Save es segment register on the stack
-    mov     rbx, ss
+    mov     ebx, ss
     push    rbx          ; Save ss segment register on the stack
     
     push    fs
@@ -293,7 +293,7 @@ BITS    64
     mov     ss, edx
     pushfq
     lea     edx, [rdx + DATA16 - DATA32]
-    lea     r8, [.RetFromRealMode]
+    lea     r8, [REL .RetFromRealMode]
     push    r8
     mov     r8d, cs
     mov     [rcx + (_BackFromUserCode.X64JmpEnd - 2 - _BackFromUserCode.SavedCr4End)], r8w
@@ -307,11 +307,11 @@ BITS    64
     pop     gs
     pop     fs
     pop     rbx
-    mov     ss, rbx
+    mov     ss, ebx
     pop     rbx
-    mov     es, rbx
+    mov     es, ebx
     pop     rbx
-    mov     ds, rbx
+    mov     ds, ebx
 
     pop     rdi
     pop     rsi
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to