# $Id: Makefile.kmk 60527 2016-04-18 09:11:04Z vboxsync $ ## @file # VirtualBox Validation Kit - Bootsector Kit v3 # # # Copyright (C) 2006-2016 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # The contents of this file may alternatively be used under the terms # of the Common Development and Distribution License Version 1.0 # (CDDL) only, as it comes in the "COPYING.CDDL" file of the # VirtualBox OSE distribution, in which case the provisions of the # CDDL are applicable instead of those of the GPL. # # You may elect to license modified versions of this file under the # terms and conditions of either the GPL or the CDDL or both. # SUB_DEPTH = ../../../../.. include $(KBUILD_PATH)/subheader.kmk # Boot Sector post-link tool (used via the parent Config.kmk). BLDPROGS += VBoxBs3Linker VBoxBs3Linker_TEMPLATE = VBoxBldProg VBoxBs3Linker_SOURCES = $(VBOX_PATH_BS3KIT_SRC)/VBoxBs3Linker.cpp # 64-bit relocation conversion tool (used via the parent Config.kmk). BLDPROGS += VBoxBs3ObjConverter VBoxBs3ObjConverter_TEMPLATE = VBoxAdvBldProg VBoxBs3ObjConverter_DEFS = BS3KIT_BS3CLASS16CODE=$(BS3KIT_BS3CLASS16CODE) VBoxBs3ObjConverter_SOURCES = $(VBOX_PATH_BS3KIT_SRC)/VBoxBs3ObjConverter.cpp # The boot sector. MISCBINS += bs3-bootsector bs3-bootsector_TEMPLATE = VBoxBS3KitBS bs3-bootsector_SOURCES = bs3-bootsector.asm # # Common sources to be compiled into _p16, _p32 and _p64 versions. # VBOX_BS3KIT_COMMON_SOURCES = \ bs3-cmn-A20Disable.asm \ bs3-cmn-A20Enable.asm \ bs3-cmn-KbdRead.asm \ bs3-cmn-KbdWait.asm \ bs3-cmn-KbdWrite.asm \ bs3-cmn-Shutdown.asm \ bs3-cmn-Panic.asm \ bs3-cmn-PrintChr.asm \ bs3-cmn-Printf.c \ bs3-cmn-PrintU32.asm \ bs3-cmn-PrintX32.asm \ bs3-cmn-PrintStr.c \ bs3-cmn-PrintStrN.asm \ bs3-cmn-StrFormatV.c \ bs3-cmn-StrPrintf.c \ bs3-cmn-StrLen.c \ bs3-cmn-StrNLen.c \ bs3-cmn-StrCpy.c \ bs3-cmn-MemCpy.c \ bs3-cmn-MemPCpy.c \ bs3-cmn-MemMove.c \ bs3-cmn-MemZero.asm \ bs3-cmn-MemAlloc.c \ bs3-cmn-MemAllocZ.c \ bs3-cmn-MemFree.c \ bs3-cmn-PagingData.c \ bs3-cmn-PagingInitRootForPP.c \ bs3-cmn-PagingInitRootForPAE.c \ bs3-cmn-PagingInitRootForLM.c \ bs3-cmn-PagingProtect.c \ bs3-cmn-PicMaskAll.c \ bs3-cmn-RegCtxRestore.asm \ bs3-cmn-RegCtxConvertToRingX.c \ bs3-cmn-RegCtxPrint.c \ bs3-cmn-RegCtxSave.asm \ bs3-cmn-SelFar32ToFlat32.c \ bs3-cmn-SelProtFar32ToFlat32.c \ bs3-cmn-SlabInit.c \ bs3-cmn-SlabAlloc.c \ bs3-cmn-SlabAllocEx.c \ bs3-cmn-SlabFree.c \ bs3-cmn-SlabListInit.c \ bs3-cmn-SlabListAdd.c \ bs3-cmn-SlabListAlloc.c \ bs3-cmn-SlabListAllocEx.c \ bs3-cmn-SlabListFree.c \ bs3-cmn-SwitchToRing0.asm \ bs3-cmn-SwitchToRing1.asm \ bs3-cmn-SwitchToRing2.asm \ bs3-cmn-SwitchToRing3.asm \ bs3-cmn-SwitchToRingX.asm \ bs3-cmn-SwitchTo16Bit.asm \ bs3-cmn-SwitchTo16BitV86.asm \ bs3-cmn-SwitchTo32Bit.asm \ bs3-cmn-SwitchTo64Bit.asm \ bs3-cmn-Syscall.asm \ bs3-cmn-TestData.c \ bs3-cmn-TestInit.c \ bs3-cmn-TestFailed.c \ bs3-cmn-TestSkipped.c \ bs3-cmn-TestSub.c \ bs3-cmn-TestSubDone.c \ bs3-cmn-TestSubErrorCount.c \ bs3-cmn-TestTerm.c \ bs3-cmn-TestSendCmdWithStr.asm \ bs3-cmn-TestSendCmdWithU32.asm \ bs3-cmn-TestIsVmmDevTestingPresent.asm \ bs3-cmn-TestCheckRegCtxEx.c \ bs3-cmn-TestPrintf.c \ bs3-cmn-TrapRmV86Init.c \ bs3-cmn-TrapRmV86SetGate.c \ bs3-cmn-Trap16Init.c \ bs3-cmn-Trap16SetGate.c \ bs3-cmn-Trap32Init.c \ bs3-cmn-Trap32SetGate.c \ bs3-cmn-Trap64Init.c \ bs3-cmn-Trap64SetGate.c \ bs3-cmn-TrapDefaultHandler.c \ bs3-cmn-TrapPrintFrame.c \ bs3-cmn-TrapSetHandler.c \ bs3-cmn-TrapSetJmp.asm \ bs3-cmn-TrapSetJmpAndRestore.c \ bs3-cmn-TrapUnsetJmp.c \ ../../../Runtime/common/asm/ASMBitFirstClear.asm \ ../../../Runtime/common/asm/ASMBitFirstSet.asm \ ../../../Runtime/common/asm/ASMBitNextClear.asm \ ../../../Runtime/common/asm/ASMBitNextSet.asm \ ../../../Runtime/common/asm/ASMBitFirstSetU16.asm \ ../../../Runtime/common/asm/ASMBitFirstSetU32.asm \ ../../../Runtime/common/asm/ASMBitFirstSetU64.asm \ ../../../Runtime/common/asm/ASMBitLastSetU16.asm \ ../../../Runtime/common/asm/ASMBitLastSetU32.asm \ ../../../Runtime/common/asm/ASMBitLastSetU64.asm \ ../../../Runtime/common/asm/ASMMemFirstMismatchingU8.asm \ ../../../Runtime/common/asm/ASMSerializeInstruction-cpuid.asm \ ../../../Runtime/common/asm/ASMSerializeInstruction-iret.asm \ ../../../Runtime/common/asm/ASMSerializeInstruction-rdtscp.asm \ # # We generate a list of files with 16-bit far functions for which we generate # near jump stubs. # #$(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk.ts \ #+| $(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk: $(VBOX_PATH_BS3KIT_SRC)/bs3kit.h # $(SED) \ # -n -e '/no-near-stub/d' \ # -e 's/^ *BS3_DECL(.*) *\([a-zA-Z][a-zA-Z0-9_]*\)(.*[;,][^;]*$/\1/p' \ # --output $@ \ # bs3kit.h # .$(CP_CHANGED) --changed -f -- $@ $(PATH_OUT_OBJ)/bs3kit-common-16-near-to-far.kmk #include $(PATH) # The 16-bit BS3Kit library. LIBRARIES += bs3kit-common-16 bs3kit-common-16_TEMPLATE = VBoxBS3KitImg bs3kit-common-16_INSTTYPE = none bs3kit-common-16_DEFS = TMPL_PE16 BS3_CMN_ONLY bs3kit-common-16_ASDEFS = RT_ASMDEFS_INC_FIRST_FILE bs3kit-common-16_SOURCES = $(VBOX_BS3KIT_COMMON_SOURCES) \ bs3-system-data.asm \ bs3-rm-InitAll.c \ bs3-rm-InitMemory.c \ bs3-cmn-hexdigits.c \ bs3-cmn-CpuDetectData.c \ bs3-cmn-PerCpuData.c \ bs3-cmn-ConvertRMStackToP16UsingCxReturnToAx.asm \ bs3-cmn-UInt64Div.c \ bs3-cmn-UInt32Div.c \ bs3-wc16-U8DR.asm \ bs3-wc16-U8DQ.asm \ bs3-wc16-I8DR.asm \ bs3-wc16-I8DQ.asm \ bs3-wc16-I8RS.asm \ bs3-wc16-U8RS.asm \ bs3-wc16-U8LS.asm \ bs3-wc16-U4D.asm \ bs3-wc16-I4D.asm \ bs3-c16-Trap16Generic.asm \ bs3-c16-CreateHybridFarRet.asm bs3kit-common-16_bs3-cmn-UInt64Div.c_CFLAGS = -oh -d0 # -d1+ vs -d0 saves 0x6a3-0x577 = 0x12C (300)! bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS := \ $(sort $(subst bs3-cmn-,Bs3,$(basename $(filter-out \ %Data.c \ bs3-rm-% \ bs3-cmn-hexdigits.c \ ,$(filter %.c,$(bs3kit-common-16_SOURCES)))))) \ Bs3PrintfV \ Bs3StrPrintfV \ Bs3TestPrintfV \ Bs3TestFailedF \ Bs3TestFailedV \ Bs3TestSkippedF \ Bs3TestSkippedV \ Bs3TestSubF \ Bs3TestSubV \ Bs3Trap16InitEx $(call BS3KIT_FN_GEN_NEARSTUBS,bs3kit-common-16,$(bs3kit-common-16_VBOX_NEAR_TO_FAR_FUNCTIONS)) # The 32-bit BS3Kit library. LIBRARIES += bs3kit-common-32 bs3kit-common-32_TEMPLATE = VBoxBS3KitImg32 bs3kit-common-32_INSTTYPE = none bs3kit-common-32_DEFS = TMPL_PE32 BS3_CMN_ONLY bs3kit-common-32_ASDEFS = RT_ASMDEFS_INC_FIRST_FILE bs3kit-common-32_SOURCES = $(VBOX_BS3KIT_COMMON_SOURCES) \ bs3-cmn-UInt64Div.c \ bs3-wc32-U8D.asm \ bs3-wc32-I8D.asm \ bs3-wc32-I8RS.asm \ bs3-wc32-U8RS.asm \ bs3-wc32-U8LS.asm \ bs3-c32-Trap32Generic.asm # The 64-bit BS3Kit library. LIBRARIES += bs3kit-common-64 bs3kit-common-64_TEMPLATE = VBoxBS3KitImg64 bs3kit-common-64_INSTTYPE = none bs3kit-common-64_DEFS = TMPL_LM64 BS3_CMN_ONLY bs3kit-common-64_ASDEFS = RT_ASMDEFS_INC_FIRST_FILE bs3kit-common-64_SOURCES = $(VBOX_BS3KIT_COMMON_SOURCES) \ bs3-c64-Trap64Generic.asm \ ../../../Runtime/common/asm/ASMGetIDTR.asm \ ../../../Runtime/common/asm/ASMSetIDTR.asm \ ../../../Runtime/common/asm/ASMGetGDTR.asm \ ../../../Runtime/common/asm/ASMSetGDTR.asm \ # # Common sources to be compiled for each CPU mode. # VBOX_BS3KIT_MODE_SOURCES = \ bs3-mode-Name.asm \ bs3-mode-SwitchToRM.asm \ bs3-mode-SwitchToPE16.asm \ bs3-mode-SwitchToPE16_32.asm \ bs3-mode-SwitchToPE16_V86.asm \ bs3-mode-SwitchToPE32.asm \ bs3-mode-SwitchToPE32_16.asm \ bs3-mode-SwitchToPEV86.asm \ bs3-mode-SwitchToPP16.asm \ bs3-mode-SwitchToPP16_32.asm \ bs3-mode-SwitchToPP16_V86.asm \ bs3-mode-SwitchToPP32.asm \ bs3-mode-SwitchToPP32_16.asm \ bs3-mode-SwitchToPPV86.asm \ bs3-mode-SwitchToPAE16.asm \ bs3-mode-SwitchToPAE16_32.asm \ bs3-mode-SwitchToPAE16_V86.asm \ bs3-mode-SwitchToPAE32.asm \ bs3-mode-SwitchToPAE32_16.asm \ bs3-mode-SwitchToPAEV86.asm \ bs3-mode-SwitchToLM64.asm \ bs3-mode-SwitchToLM32.asm \ bs3-mode-SwitchToLM16.asm \ bs3-mode-EnteredMode.asm \ bs3-mode-PagingGetRootForPP16.asm \ bs3-mode-PagingGetRootForPP32.asm \ bs3-mode-PagingGetRootForPAE16.asm \ bs3-mode-PagingGetRootForPAE32.asm \ bs3-mode-PagingGetRootForLM64.asm \ bs3-mode-TrapInit.c \ bs3-mode-TrapSystemCallHandler.asm \ bs3-mode-TestDoModes.c \ bs3-mode-TestDoModesHlp.asm \ # The 16-bit real mode BS3Kit library. LIBRARIES += bs3kit-rm bs3kit-rm_TEMPLATE = VBoxBS3KitImg bs3kit-rm_INSTTYPE = none bs3kit-rm_DEFS = TMPL_MODE=BS3_MODE_RM bs3kit-rm_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) \ bs3-first-rm.asm \ bs3-mode-CpuDetect.asm # The 16-bit BS3Kit library for 16-bit protected kernel+tss. LIBRARIES += bs3kit-pe16 bs3kit-pe16_TEMPLATE = VBoxBS3KitImg bs3kit-pe16_INSTTYPE = none bs3kit-pe16_DEFS = TMPL_MODE=BS3_MODE_PE16 bs3kit-pe16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) \ bs3-first-pe16.asm \ # bs3-mode-CpuDetect.asm # The 32-bit BS3Kit library for 16-bit protected kernel+tss. LIBRARIES += bs3kit-pe16_32 bs3kit-pe16_32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pe16_32_INSTTYPE = none bs3kit-pe16_32_DEFS = TMPL_MODE=BS3_MODE_PE16_32 bs3kit-pe16_32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v86 BS3Kit library for 16-bit protected kernel+tss. LIBRARIES += bs3kit-pe16_v86 bs3kit-pe16_v86_TEMPLATE = VBoxBS3KitImg bs3kit-pe16_v86_INSTTYPE = none bs3kit-pe16_v86_DEFS = TMPL_MODE=BS3_MODE_PE16_V86 bs3kit-pe16_v86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 32-bit BS3Kit library for 32-bit protected kernel+tss. LIBRARIES += bs3kit-pe32 bs3kit-pe32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pe32_INSTTYPE = none bs3kit-pe32_DEFS = TMPL_MODE=BS3_MODE_PE32 bs3kit-pe32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit BS3Kit library for 32-bit protected kernel+tss. LIBRARIES += bs3kit-pe32_16 bs3kit-pe32_16_TEMPLATE = VBoxBS3KitImg bs3kit-pe32_16_INSTTYPE = none bs3kit-pe32_16_DEFS = TMPL_MODE=BS3_MODE_PE32_16 bs3kit-pe32_16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v8086 BS3Kit library for 32-bit protected kernel+tss. LIBRARIES += bs3kit-pev86 bs3kit-pev86_TEMPLATE = VBoxBS3KitImg bs3kit-pev86_INSTTYPE = none bs3kit-pev86_DEFS = TMPL_MODE=BS3_MODE_PEV86 bs3kit-pev86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit BS3Kit library for 16-bit paged protected kernel+tss. LIBRARIES += bs3kit-pp16 bs3kit-pp16_TEMPLATE = VBoxBS3KitImg bs3kit-pp16_INSTTYPE = none bs3kit-pp16_DEFS = TMPL_MODE=BS3_MODE_PP16 bs3kit-pp16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) \ bs3-mode-CpuDetect.asm # The 32-bit BS3Kit library for 16-bit paged protected kernel+tss. LIBRARIES += bs3kit-pp16_32 bs3kit-pp16_32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pp16_32_INSTTYPE = none bs3kit-pp16_32_DEFS = TMPL_MODE=BS3_MODE_PP16_32 bs3kit-pp16_32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v8086 BS3Kit library for 16-bit paged protected kernel+tss. LIBRARIES += bs3kit-pp16_v86 bs3kit-pp16_v86_TEMPLATE = VBoxBS3KitImg bs3kit-pp16_v86_INSTTYPE = none bs3kit-pp16_v86_DEFS = TMPL_MODE=BS3_MODE_PP16_V86 bs3kit-pp16_v86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 32-bit BS3Kit library for 32-bit paged protected kernel+tss. LIBRARIES += bs3kit-pp32 bs3kit-pp32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pp32_INSTTYPE = none bs3kit-pp32_DEFS = TMPL_MODE=BS3_MODE_PP32 bs3kit-pp32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit BS3Kit library for 32-bit paged protected kernel+tss. LIBRARIES += bs3kit-pp32_16 bs3kit-pp32_16_TEMPLATE = VBoxBS3KitImg bs3kit-pp32_16_INSTTYPE = none bs3kit-pp32_16_DEFS = TMPL_MODE=BS3_MODE_PP32_16 bs3kit-pp32_16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v8086 BS3Kit library for 32-bit paged protected kernel+tss. LIBRARIES += bs3kit-ppv86 bs3kit-ppv86_TEMPLATE = VBoxBS3KitImg bs3kit-ppv86_INSTTYPE = none bs3kit-ppv86_DEFS = TMPL_MODE=BS3_MODE_PPV86 bs3kit-ppv86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit BS3Kit library for 16-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-pae16 bs3kit-pae16_TEMPLATE = VBoxBS3KitImg bs3kit-pae16_INSTTYPE = none bs3kit-pae16_DEFS = TMPL_MODE=BS3_MODE_PAE16 bs3kit-pae16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) \ bs3-mode-CpuDetect.asm # The 16-bit BS3Kit library for 16-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-pae16_32 bs3kit-pae16_32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pae16_32_INSTTYPE = none bs3kit-pae16_32_DEFS = TMPL_MODE=BS3_MODE_PAE16_32 bs3kit-pae16_32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v8086 BS3Kit library for 16-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-pae16_v86 bs3kit-pae16_v86_TEMPLATE = VBoxBS3KitImg bs3kit-pae16_v86_INSTTYPE = none bs3kit-pae16_v86_DEFS = TMPL_MODE=BS3_MODE_PAE16_V86 bs3kit-pae16_v86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 32-bit BS3Kit library for 32-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-pae32 bs3kit-pae32_TEMPLATE = VBoxBS3KitImg32 bs3kit-pae32_INSTTYPE = none bs3kit-pae32_DEFS = TMPL_MODE=BS3_MODE_PAE32 bs3kit-pae32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit BS3Kit library for 32-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-pae32_16 bs3kit-pae32_16_TEMPLATE = VBoxBS3KitImg bs3kit-pae32_16_INSTTYPE = none bs3kit-pae32_16_DEFS = TMPL_MODE=BS3_MODE_PAE32_16 bs3kit-pae32_16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The v8086 BS3Kit library for 32-bit PAE paged protected kernel+tss. LIBRARIES += bs3kit-paev86 bs3kit-paev86_TEMPLATE = VBoxBS3KitImg bs3kit-paev86_INSTTYPE = none bs3kit-paev86_DEFS = TMPL_MODE=BS3_MODE_PAEV86 bs3kit-paev86_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 16-bit long mode BS3Kit library. LIBRARIES += bs3kit-lm16 bs3kit-lm16_TEMPLATE = VBoxBS3KitImg bs3kit-lm16_INSTTYPE = none bs3kit-lm16_DEFS = TMPL_MODE=BS3_MODE_LM16 bs3kit-lm16_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 32-bit long mode BS3Kit library. LIBRARIES += bs3kit-lm32 bs3kit-lm32_TEMPLATE = VBoxBS3KitImg32 bs3kit-lm32_INSTTYPE = none bs3kit-lm32_DEFS = TMPL_MODE=BS3_MODE_LM32 bs3kit-lm32_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # The 64-bit long mode BS3Kit library. LIBRARIES += bs3kit-lm64 bs3kit-lm64_TEMPLATE = VBoxBS3KitImg64 bs3kit-lm64_INSTTYPE = none bs3kit-lm64_DEFS = TMPL_MODE=BS3_MODE_LM64 bs3kit-lm64_SOURCES = $(VBOX_BS3KIT_MODE_SOURCES) # # shutdown example. # MISCBINS += bs3-shutdown bs3-shutdown_TEMPLATE = VBoxBS3KitImg bs3-shutdown_SOURCES = \ bs3-first-pe16.asm \ bs3-shutdown.c # # DOS Utilities / Testcases. # MISCBINS += bs3cpudt bs3cpudt_TEMPLATE = VBoxBS3KitUtil bs3cpudt_SOURCES = \ bs3-first-dosexe.asm \ bs3cpudt.c # # Rule for regenerating bs3kit-mangling-functions-undef.h. # bs3kit-mangling-code-undef.h: $(PATH_SUB_CURRENT)/bs3kit-mangling-code-define.h $(SED) \ -e 's/#define \([a-zA-Z_][a-zA-Z0-9_]*\) .*$(DOLLAR)/#undef \1/' \ -e 's/Function needing mangling\./Undefining function mangling - automatically generated by the $@ makefile rule./' \ --output $(dir $<)bs3kit-mangling-code-undef.h \ $< include $(FILE_KBUILD_SUB_FOOTER)