From 69b1c0214f61bc6f57f8ed1dfc2eb1f436ab423e Mon Sep 17 00:00:00 2001 From: rsun3 Date: Tue, 10 Jan 2012 04:30:33 +0000 Subject: [PATCH] DuetPkg BootSector: Clean up .S files for 64-bit Duet for GCC build. Partly contributed by Sergey Isakov [isakov-sl@bk.ru]. Signed-off-by: rsun3 Reviewed-by: niruiyu git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12921 6f19259b-4bc3-4df7-8a09-765794883524 --- DuetPkg/BootSector/GNUmakefile | 34 +++++++++++++++++++--------------- DuetPkg/BootSector/efi64.S | 17 ++++++++++------- DuetPkg/BootSector/st16_64.S | 21 ++++++++++++--------- DuetPkg/BootSector/st32_64.S | 21 ++++++++++++--------- DuetPkg/BootSector/start64.S | 15 +++++++++------ 5 files changed, 62 insertions(+), 46 deletions(-) diff --git a/DuetPkg/BootSector/GNUmakefile b/DuetPkg/BootSector/GNUmakefile index 66298daf3b..dc26e1f9ec 100644 --- a/DuetPkg/BootSector/GNUmakefile +++ b/DuetPkg/BootSector/GNUmakefile @@ -1,7 +1,7 @@ ## @file # Just use host GCC to compile boot sector image. # -# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -20,11 +20,15 @@ ASSEMBLY_CODE_FILE_LIST = $(MODULE_DIR)/bootsect.S \ $(MODULE_DIR)/bs16.S \ $(MODULE_DIR)/bs32.S \ $(MODULE_DIR)/efi32.S \ + $(MODULE_DIR)/efi64.S \ $(MODULE_DIR)/Gpt.S \ $(MODULE_DIR)/Mbr.S \ $(MODULE_DIR)/start.S \ $(MODULE_DIR)/start16.S \ - $(MODULE_DIR)/start32.S + $(MODULE_DIR)/start32.S \ + $(MODULE_DIR)/start64.S \ + $(MODULE_DIR)/st16_64.S \ + $(MODULE_DIR)/st32_64.S TARGET_FILES = $(OUTPUT_DIR)/bootsect.com \ $(OUTPUT_DIR)/bs16.com \ @@ -34,11 +38,11 @@ TARGET_FILES = $(OUTPUT_DIR)/bootsect.com \ $(OUTPUT_DIR)/start.com \ $(OUTPUT_DIR)/start16.com \ $(OUTPUT_DIR)/start32.com \ - $(OUTPUT_DIR)/efi32.com2 - #$(OUTPUT_DIR)/start64.com \ - #$(OUTPUT_DIR)/st16_64.com \ - #$(OUTPUT_DIR)/st32_64.com \ - #$(OUTPUT_DIR)/efi64.com2 + $(OUTPUT_DIR)/efi32.com2 \ + $(OUTPUT_DIR)/start64.com \ + $(OUTPUT_DIR)/st16_64.com \ + $(OUTPUT_DIR)/st32_64.com \ + $(OUTPUT_DIR)/efi64.com2 .PHONY : all all: $(TARGET_FILES) @@ -98,16 +102,16 @@ $(OUTPUT_DIR)/start64.com: $(OUTPUT_DIR)/start64.o $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start64.com $(OUTPUT_DIR)/start64.o -Ttext 0 -Map $(OUTPUT_DIR)/start64.map # start16_64.S -$(OUTPUT_DIR)/start16_64.o: $(MODULE_DIR)/start16_64.S - $(ASM) -c -o $(OUTPUT_DIR)/start16_64.o $(MODULE_DIR)/start16_64.S -$(OUTPUT_DIR)/start16_64.com: $(OUTPUT_DIR)/start16_64.o - $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start16_64.com $(OUTPUT_DIR)/start16_64.o -Ttext 0 -Map $(OUTPUT_DIR)/start16_64.map +$(OUTPUT_DIR)/st16_64.o: $(MODULE_DIR)/st16_64.S + $(ASM) -c -o $(OUTPUT_DIR)/st16_64.o $(MODULE_DIR)/st16_64.S +$(OUTPUT_DIR)/st16_64.com: $(OUTPUT_DIR)/st16_64.o + $(DLINK) --oformat binary -o $(OUTPUT_DIR)/st16_64.com $(OUTPUT_DIR)/st16_64.o -Ttext 0 -Map $(OUTPUT_DIR)/st16_64.map # start32_64.S -$(OUTPUT_DIR)/start32_64.o: $(MODULE_DIR)/start32_64.S - $(ASM) -c -o $(OUTPUT_DIR)/start32_64.o $(MODULE_DIR)/start32_64.S -$(OUTPUT_DIR)/start32_64.com: $(OUTPUT_DIR)/start32_64.o - $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start32_64.com $(OUTPUT_DIR)/start32_64.o -Ttext 0 -Map $(OUTPUT_DIR)/start32_64.map +$(OUTPUT_DIR)/st32_64.o: $(MODULE_DIR)/st32_64.S + $(ASM) -c -o $(OUTPUT_DIR)/st32_64.o $(MODULE_DIR)/st32_64.S +$(OUTPUT_DIR)/st32_64.com: $(OUTPUT_DIR)/st32_64.o + $(DLINK) --oformat binary -o $(OUTPUT_DIR)/st32_64.com $(OUTPUT_DIR)/st32_64.o -Ttext 0 -Map $(OUTPUT_DIR)/st32_64.map # efi32.S $(OUTPUT_DIR)/efi32.o: $(MODULE_DIR)/efi32.S diff --git a/DuetPkg/BootSector/efi64.S b/DuetPkg/BootSector/efi64.S index fe7a3647ad..ec6ad89761 100644 --- a/DuetPkg/BootSector/efi64.S +++ b/DuetPkg/BootSector/efi64.S @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ #* -#* Copyright (c) 2006, Intel Corporation. All rights reserved.
+#* Copyright (c) 2006 - 2012, Intel Corporation. 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 @@ -24,6 +24,9 @@ .code: .org 0x21000 +.global _start +_start: + .equ DEFAULT_HANDLER_SIZE, INT1 - INT0 .macro jmpCommonIdtEntry @@ -1279,9 +1282,9 @@ looptop: andb $0xf,%bl addb $'0', %bl cmpb $'9', %bl - jle @f + jle LN_C4 addb $7,%bl -@@: +LN_C4: movb %bl, (%edi) addl $2,%edi loop looptop @@ -1300,10 +1303,10 @@ ClearScreen: movb $0xc,%ah movl $0xb8000,%edi movl $80*24,%ecx -LN_C4: +LN_C5: movw %ax, (%edi) addl $2,%edi - loop LN_C4 + loop LN_C5 movl $0xb8000,%edi popl %ecx @@ -1315,9 +1318,9 @@ A2C: andb $0xf,%al addb $'0', %al cmpb $'9', %al - jle @f + jle LN_C6 addb $7,%al -LN_C5: +LN_C6: ret String1: .asciz "*** INT " diff --git a/DuetPkg/BootSector/st16_64.S b/DuetPkg/BootSector/st16_64.S index c6cc5169f6..8eadd28d35 100644 --- a/DuetPkg/BootSector/st16_64.S +++ b/DuetPkg/BootSector/st16_64.S @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ #* -#* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+#* Copyright (c) 2006 - 2012, Intel Corporation. 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 @@ -27,6 +27,10 @@ .equ BLOCK_SHIFT, 9 .org 0x0 + +.global _start +_start: + Ia32Jump: jmp BootSectorEntryPoint # JMP inst - 3 bytes nop @@ -123,11 +127,11 @@ CheckEm64T: movw $18,%cx jmp PrintStringAndHalt CheckEm64TPass: -jumpFarInstruction: +JumpFarInstruction: .byte 0xea -jumpOffset: +JumpOffset: .word 0x200 -jumpSegment: +JumpSegment: .word 0x2000 @@ -431,7 +435,7 @@ A20GateEnabled: # # Enable Protect Mode (set CR0.PE=1) # - movl $cr0, %eax # Read CR0. + movl %cr0, %eax # Read CR0. orl $0x1,%eax # Set PE=1 movl %eax, %cr0 # Write CR0. .byte 0x66 @@ -503,7 +507,7 @@ In32BitProtectedMode: # # Enable paging to activate long mode (set CR0.PG=1) # - movl $cr0, %eax # Read CR0. + movl %cr0, %eax # Read CR0. .byte 0xf .byte 0xba .byte 0xe8 @@ -1098,10 +1102,9 @@ MemoryMap: .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 - .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - #.org 0x0fe0 #Just for pass build + .org 0x0fe0 MyStack: # below is the pieces of the IVT that is used to redirect INT 68h - 6fh # back to INT 08h - 0fh when in real mode... It is 'org'ed to a @@ -1133,7 +1136,7 @@ MyStack: iret - #.org 0x0ffe #Just for pass build + .org 0x0ffe BlockSignature: .word 0xaa55 diff --git a/DuetPkg/BootSector/st32_64.S b/DuetPkg/BootSector/st32_64.S index f1ebf67d18..465b1cf9b2 100644 --- a/DuetPkg/BootSector/st32_64.S +++ b/DuetPkg/BootSector/st32_64.S @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ #* -#* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+#* Copyright (c) 2006 - 2012, Intel Corporation. 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 @@ -27,6 +27,10 @@ .equ BLOCK_SHIFT, 9 .org 0x0 + +.global _start +_start: + Ia32Jump: jmp BootSectorEntryPoint # JMP inst - 3 bytes nop @@ -138,11 +142,11 @@ CheckEm64T: movw $18,%cx jmp PrintStringAndHalt CheckEm64TPass: -jumpFarInstruction: +JumpFarInstruction: .byte 0xea -jumpOffset: +JumpOffset: .word 0x200 -jumpSegment: +JumpSegment: .word 0x2000 @@ -446,7 +450,7 @@ A20GateEnabled: # # Enable Protect Mode (set CR0.PE=1) # - movl $cr0, %eax # Read CR0. + movl %cr0, %eax # Read CR0. orl $0x1,%eax # Set PE=1 movl %eax, %cr0 # Write CR0. .byte 0x66 @@ -518,7 +522,7 @@ In32BitProtectedMode: # # Enable paging to activate long mode (set CR0.PG=1) # - movl $cr0, %eax # Read CR0. + movl %cr0, %eax # Read CR0. .byte 0xf .byte 0xba .byte 0xe8 @@ -1113,10 +1117,9 @@ MemoryMap: .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 - .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - #.org 0x0fe0 #Just for pass build + .org 0x0fe0 MyStack: # below is the pieces of the IVT that is used to redirect INT 68h - 6fh # back to INT 08h - 0fh when in real mode... It is 'org'ed to a @@ -1148,7 +1151,7 @@ MyStack: iret - #.org 0x0ffe #Just for pass build + .org 0x0ffe BlockSignature: .word 0xaa55 diff --git a/DuetPkg/BootSector/start64.S b/DuetPkg/BootSector/start64.S index b8f1e60f8a..75626b86a4 100644 --- a/DuetPkg/BootSector/start64.S +++ b/DuetPkg/BootSector/start64.S @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ #* -#* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+#* Copyright (c) 2006 - 2012, Intel Corporation. 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 @@ -27,6 +27,10 @@ .equ BLOCK_SHIFT, 9 .org 0x0 + +.global _start +_start: + Ia32Jump: jmp BootSectorEntryPoint # JMP inst - 3 bytes nop @@ -123,11 +127,11 @@ CheckEm64T: movw $18,%cx jmp PrintStringAndHalt CheckEm64TPass: -jumpFarInstruction: +JumpFarInstruction: .byte 0xea -jumpOffset: +JumpOffset: .word 0x200 -jumpSegment: +JumpSegment: .word 0x2000 @@ -510,7 +514,7 @@ In32BitProtectedMode: # # Enable paging to activate long mode (set CR0.PG=1) # - movl $cr0, %eax # Read CR0. + movl %cr0, %eax # Read CR0. .byte 0xf .byte 0xba .byte 0xe8 @@ -1105,7 +1109,6 @@ MemoryMap: .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0 - .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .org 0x0fe0 -- 2.39.2