stage1/2 loaders: auto-generate binary files. Fixes #10723

This commit is contained in:
Jessica Hamilton
2014-09-10 22:00:30 +12:00
parent 1d3ba85ae6
commit e547662664
8 changed files with 1088 additions and 1118 deletions
Regular → Executable
+7 -3
View File
@@ -169,15 +169,19 @@ rule StaticLibraryFromObjects
rule AssembleNasm
{
Depends $(<) : $(>) [ on $(<) return $(PLATFORM) ] ;
if ! [ on $(1) return $(NASMFLAGS) ] {
NASMFLAGS on $(1) = -f elf32 ;
}
Depends $(1) : $(2) [ on $(2) return $(PLATFORM) ] ;
}
actions AssembleNasm
{
if test $(ASFLAGS) ; then
$(HAIKU_NASM) -d $(ASFLAGS) -f elf32 -o $(1) $(2);
$(HAIKU_NASM) -d $(ASFLAGS) $(NASMFLAGS) -o $(1) $(2);
else
$(HAIKU_NASM) -f elf32 -o $(1) $(2);
$(HAIKU_NASM) $(NASMFLAGS) -o $(1) $(2);
fi
}
+4
View File
@@ -2,6 +2,10 @@ SubDir HAIKU_TOP src add-ons kernel partitioning_systems intel ;
UsePrivateHeaders kernel shared storage ;
UsePrivateSystemHeaders ;
UseHeaders [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) bin writembr ] ;
Includes [ FGristFiles PartitionMapWriter.cpp ]
: <src!bin!writembr>MBR.h ;
KernelAddon intel :
intel.cpp
@@ -37,35 +37,7 @@ using std::nothrow;
#endif
// compiled mbr boot loader code
static const uint8 kBootCode[] = {
// compiled form of //haiku/trunk/src/bin/writembr/mbr.S
// nasm -f bin -O5 -o mbrcode.bin mbr.S -dMBR_CODE_ONLY=1
// bin2h <mbrcode.bin 12
0xfa, 0xfc, 0x31, 0xc0, 0x8e, 0xc0, 0x8e, 0xd8, 0x8e, 0xd0, 0xbc, 0x00,
0x7c, 0xbf, 0x00, 0x08, 0xb9, 0x18, 0x00, 0xf3, 0xaa, 0xbe, 0x00, 0x7c,
0x89, 0x36, 0x0c, 0x08, 0xc6, 0x06, 0x08, 0x08, 0x10, 0xc6, 0x06, 0x0a,
0x08, 0x01, 0xbf, 0x00, 0x06, 0xb5, 0x01, 0xf3, 0xa5, 0xea, 0x32, 0x06,
0x00, 0x00, 0xfb, 0xbe, 0xbe, 0x07, 0xb0, 0x04, 0x80, 0x3c, 0x80, 0x74,
0x09, 0x83, 0xc6, 0x10, 0xfe, 0xc8, 0x75, 0xf4, 0xeb, 0x6d, 0x89, 0x36,
0x04, 0x08, 0x66, 0x8b, 0x44, 0x08, 0x66, 0xa3, 0x10, 0x08, 0x66, 0x85,
0xc0, 0x74, 0x27, 0xb4, 0x41, 0xbb, 0xaa, 0x55, 0xcd, 0x13, 0x72, 0x1e,
0xbe, 0x08, 0x08, 0xb4, 0x42, 0xcd, 0x13, 0x72, 0x15, 0x81, 0x3e, 0xfe,
0x7d, 0x55, 0xaa, 0x75, 0x42, 0xbe, 0xfb, 0x06, 0xe8, 0x52, 0x00, 0x8b,
0x36, 0x04, 0x08, 0xe9, 0x82, 0x75, 0x8b, 0x36, 0x04, 0x08, 0x8a, 0x74,
0x01, 0x8b, 0x4c, 0x02, 0x88, 0xc8, 0x24, 0x3f, 0x84, 0xc0, 0x74, 0x23,
0x3c, 0x3f, 0x75, 0x14, 0x89, 0xc8, 0xc0, 0xec, 0x06, 0x3d, 0xff, 0x03,
0x75, 0x0a, 0x80, 0xfe, 0xff, 0x75, 0x05, 0x80, 0xfe, 0xfe, 0x74, 0x0b,
0xbb, 0x00, 0x7c, 0xb0, 0x01, 0xb4, 0x02, 0xcd, 0x13, 0x73, 0xb6, 0xbe,
0xdf, 0x06, 0xe8, 0x10, 0x00, 0xe8, 0x08, 0x00, 0xbe, 0xd5, 0x06, 0xe8,
0x07, 0x00, 0xcd, 0x18, 0xb4, 0x00, 0xcd, 0x16, 0xc3, 0x31, 0xdb, 0xac,
0xb4, 0x0e, 0xcd, 0x10, 0x08, 0xc0, 0x75, 0xf7, 0xc3, 0x52, 0x4f, 0x4d,
0x20, 0x42, 0x41, 0x53, 0x49, 0x43, 0x00, 0x4e, 0x6f, 0x20, 0x62, 0x6f,
0x6f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76,
0x65, 0x20, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x0d, 0x0a, 0x00, 0x4c,
0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65,
0x6d, 0x0a, 0x0d, 0x00
};
#include "MBR.h"
bool
@@ -133,9 +105,9 @@ PartitionMapWriter::WriteMBR(const PartitionMap* map, bool writeBootCode)
return error;
if (writeBootCode) {
// the boot code must be small enough to fit in the code area
STATIC_ASSERT(sizeof(kBootCode) <= sizeof(partitionTable.code_area));
STATIC_ASSERT(kMBRSize <= sizeof(partitionTable.code_area));
partitionTable.clear_code_area();
partitionTable.fill_code_area(kBootCode, sizeof(kBootCode));
partitionTable.fill_code_area(kMBR, kMBRSize);
}
partitionTable.signature = kPartitionTableSectorSignature;
Regular → Executable
+2 -12
View File
@@ -10,19 +10,9 @@ Application writembr :
# Assemble the MBR code, and convert it into a header file
rule AssembleNasmBin object : source
{
SEARCH on $(source) = $(SUBDIR) ;
MakeLocateDebug $(object) ;
Depends $(object) : $(source) ;
}
NASMFLAGS on [ FGristFiles mbr.bin ] = -f bin -O5 ;
actions AssembleNasmBin
{
$(HAIKU_NASM) -f bin -O5 -o $(1) $(2)
}
AssembleNasmBin [ FGristFiles mbr.bin ] : mbr.S ;
Object [ FGristFiles mbr.bin ] : mbr.nasm ;
DataFileToSourceFile [ FGristFiles MBR.h ] : [ FGristFiles mbr.bin ]
: kMBR : kMBRSize ;
+3 -3
View File
@@ -51,6 +51,6 @@ BootMergeObject boot_platform_bios_ia32.o :
: boot_platform_generic.a
;
# Tell the build system to where stage1.bin can be found, so it can be used
# elsewhere.
SEARCH on stage1.bin = $(SUBDIR) ;
NASMFLAGS on stage1.bin = -f bin -O5 ;
Object stage1.bin : stage1.nasm ;
Binary file not shown.