[BOOTSECTOR]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 9 Jun 2011 13:56:44 +0000 (13:56 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 9 Jun 2011 13:56:44 +0000 (13:56 +0000)
- export obj2bin on gcc builds, too
- Add new macro CreateBootSectorTarget2, which uses portable assembly and use it with isoboot.S. I will replace all bootsectors with the new code one at a time, and in the end we can eventually drop nmake
- add wrapper isobtrt.S, which defines ROS_REGTEST and includes isoboot.S

svn path=/trunk/; revision=52156

reactos/CMakeLists.txt
reactos/boot/freeldr/bootsect/CMakeLists.txt
reactos/boot/freeldr/bootsect/isoboot.S
reactos/boot/freeldr/bootsect/isobtrt.S [new file with mode: 0644]
reactos/gcc.cmake
reactos/msc.cmake

index c5290ff..449b5b1 100644 (file)
@@ -59,7 +59,7 @@ if(NOT CMAKE_CROSSCOMPILING)
     add_subdirectory(lib)
 
     if(NOT MSVC)
-        export(TARGETS widl wrc gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
+        export(TARGETS widl wrc gendib cabman cdmake mkhive obj2bin spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
     else()
         export(TARGETS gendib cabman cdmake mkhive obj2bin spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
     endif()
index 8162d6c..d128414 100644 (file)
@@ -1,12 +1,18 @@
 
-if(MSVC)
-CreateBootSectorTarget(fat32 ${CMAKE_CURRENT_SOURCE_DIR}/fat32.S ${CMAKE_CURRENT_BINARY_DIR}/fat32.bin 7c00)
-else()
+if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
+
+#CreateBootSectorTarget2(dosmbr ${CMAKE_CURRENT_SOURCE_DIR}/dosmbr.S ${CMAKE_CURRENT_BINARY_DIR}/dosmbr.bin 0)
+#CreateBootSectorTarget2(ext2 ${CMAKE_CURRENT_SOURCE_DIR}/ext2.S ${CMAKE_CURRENT_BINARY_DIR}/ext2.bin 0)
+#CreateBootSectorTarget2(fat32 ${CMAKE_CURRENT_SOURCE_DIR}/fat32.S ${CMAKE_CURRENT_BINARY_DIR}/fat32.bin 7c00)
+#CreateBootSectorTarget2(fat ${CMAKE_CURRENT_SOURCE_DIR}/fat.S ${CMAKE_CURRENT_BINARY_DIR}/fat.bin 0)
+CreateBootSectorTarget2(isoboot ${CMAKE_CURRENT_SOURCE_DIR}/isoboot.S ${CMAKE_CURRENT_BINARY_DIR}/isoboot.bin 7000)
+#CreateBootSectorTarget2(isobtrt ${CMAKE_CURRENT_SOURCE_DIR}/isobtrt.S ${CMAKE_CURRENT_BINARY_DIR}/isobtrt.bin 0)
+
+if(NOT MSVC)
 CreateBootSectorTarget(dosmbr ${CMAKE_CURRENT_SOURCE_DIR}/dosmbr.asm ${CMAKE_CURRENT_BINARY_DIR}/dosmbr.bin 0)
 CreateBootSectorTarget(ext2 ${CMAKE_CURRENT_SOURCE_DIR}/ext2.asm ${CMAKE_CURRENT_BINARY_DIR}/ext2.bin 0)
-CreateBootSectorTarget(fat32 ${CMAKE_CURRENT_SOURCE_DIR}/fat32.asm ${CMAKE_CURRENT_BINARY_DIR}/fat32.bin 0)
+CreateBootSectorTarget(fat32 ${CMAKE_CURRENT_SOURCE_DIR}/fat32.asm ${CMAKE_CURRENT_BINARY_DIR}/fat32.bin 7c00)
 CreateBootSectorTarget(fat ${CMAKE_CURRENT_SOURCE_DIR}/fat.asm ${CMAKE_CURRENT_BINARY_DIR}/fat.bin 0)
-CreateBootSectorTarget(isoboot ${CMAKE_CURRENT_SOURCE_DIR}/isoboot.asm ${CMAKE_CURRENT_BINARY_DIR}/isoboot.bin 0)
 CreateBootSectorTarget(isobtrt ${CMAKE_CURRENT_SOURCE_DIR}/isobtrt.asm ${CMAKE_CURRENT_BINARY_DIR}/isobtrt.bin 0)
 endif()
 
@@ -17,3 +23,5 @@ add_cd_file(TARGET fat DESTINATION loader NO_CAB FILE ${CMAKE_CURRENT_BINARY_DIR
 add_cd_file(TARGET isoboot DESTINATION loader NO_CAB FILE ${CMAKE_CURRENT_BINARY_DIR}/isoboot.bin FOR all)
 add_cd_file(TARGET isobtrt DESTINATION loader NO_CAB FILE ${CMAKE_CURRENT_BINARY_DIR}/isobtrt.bin FOR all)
 
+endif()
+
index 9d9e089..0f12545 100644 (file)
@@ -45,8 +45,9 @@
 // ****************************************************************************
 
 //#define DEBUG_MESSAGES                /* Uncomment to get debugging messages */
+#ifndef ROS_REGTEST
 #define WAIT_FOR_KEY
-
+#endif
 
 // ****************************************************************************
 //    BEGIN THE BIOS/CODE/DATA SEGMENT
@@ -129,7 +130,6 @@ relocate:
 #endif
 
     // Make sure the keyboard buffer is empty
-#ifdef WAIT_FOR_KEY
     call pollchar_and_empty
 
     // Check for MBR on harddisk
@@ -148,6 +148,7 @@ relocate:
     je .boot_cdrom // no boot sector found (hopefully there are no weird bootsectors which begin with 0)
     pop ax
 
+#ifdef WAIT_FOR_KEY
     // Display the 'Press key' message and wait for a maximum of 5 seconds
     call crlf
     mov si, offset presskey_msg // si points to 'Press key' message
@@ -171,6 +172,7 @@ relocate:
     dec byte ptr ds:[TimeoutCount]        // decrement timeout counter
     jz .boot_harddisk
     jmp .next_second
+#endif
 
 .boot_harddisk:
     call crlf
@@ -192,7 +194,6 @@ relocate:
     mov dx, HEX(0080)
 
     ljmp16 0, HEX(7C00)
-#endif
 
 .boot_cdrom:
 #ifdef WAIT_FOR_KEY
diff --git a/reactos/boot/freeldr/bootsect/isobtrt.S b/reactos/boot/freeldr/bootsect/isobtrt.S
new file mode 100644 (file)
index 0000000..03f7612
--- /dev/null
@@ -0,0 +1,3 @@
+
+#define ROS_REGTEST
+#include "isoboot.S"
index f562dbf..f007b94 100644 (file)
@@ -352,3 +352,23 @@ macro(CreateBootSectorTarget _target_name _asm_file _object_file _base_address)
     set_source_files_properties(${_object_file} PROPERTIES GENERATED TRUE)
     add_custom_target(${_target_name} ALL DEPENDS ${_object_file})
 endmacro()
+
+macro(CreateBootSectorTarget2 _target_name _asm_file _binary_file _base_address)
+    set(_object_file ${_binary_file}.o)
+
+    add_custom_command(
+        OUTPUT ${_object_file}
+        COMMAND ${CMAKE_ASM_COMPILER} -x assembler-with-cpp -o ${_object_file} -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm -D__ASM__ -c ${_asm_file}
+        DEPENDS ${_asm_file})
+
+    add_custom_command(
+        OUTPUT ${_binary_file}
+        COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
+        # COMMAND objcopy --output-target binary --image-base 0x${_base_address} ${_object_file} ${_binary_file}
+        DEPENDS ${_object_file})
+
+    set_source_files_properties(${_object_file} ${_binary_file} PROPERTIES GENERATED TRUE)
+
+    add_custom_target(${_target_name} ALL DEPENDS ${_binary_file})
+
+endmacro()
index 36bc808..8516867 100644 (file)
@@ -192,7 +192,7 @@ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
 #pseh workaround
 set(PSEH_LIB "pseh")
 
-macro(CreateBootSectorTarget _target_name _asm_file _binary_file _base_address)
+macro(CreateBootSectorTarget2 _target_name _asm_file _binary_file _base_address)
 
     set(_object_file ${_binary_file}.obj)
     set(_temp_file ${_binary_file}.tmp)