[FREELDR]

Fix MSVC and amd64 build

svn path=/trunk/; revision=52172
This commit is contained in:
Timo Kreuzer 2011-06-10 12:55:14 +00:00
parent 74fcd7f506
commit 4076751ce2
13 changed files with 173 additions and 63 deletions

View file

@ -18,9 +18,14 @@ if(ARCH MATCHES i386)
arch/i386/arch.S) arch/i386/arch.S)
endif() endif()
elseif(ARCH MATCHES amd64) elseif(ARCH MATCHES amd64)
if(MSVC)
list(APPEND FREELDR_BASE64K_SOURCE
arch/amd64/stubs.S)
else()
list(APPEND FREELDR_STARTUP_SOURCE list(APPEND FREELDR_STARTUP_SOURCE
arch/i386/fathelp.S arch/i386/fathelp.S
arch/amd64/arch.S) arch/amd64/arch.S)
endif()
endif() endif()
if(ARCH MATCHES i386) if(ARCH MATCHES i386)
@ -39,12 +44,14 @@ if(ARCH MATCHES i386)
arch/i386/i386bug.c) arch/i386/i386bug.c)
endif() endif()
elseif(ARCH MATCHES amd64) elseif(ARCH MATCHES amd64)
if(NOT MSVC)
list(APPEND FREELDR_BASE64K_SOURCE list(APPEND FREELDR_BASE64K_SOURCE
arch/i386/drvmap.S arch/i386/drvmap.S
arch/i386/i386cpu.S arch/i386/i386cpu.S
arch/i386/i386idt.S arch/i386/i386idt.S
arch/i386/i386trap.S arch/i386/i386trap.S
arch/amd64/mb.S) arch/amd64/mb.S)
endif()
endif() endif()
set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_") set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
@ -60,7 +67,7 @@ list(APPEND FREELDR_BASE_SOURCE
disk/disk.c disk/disk.c
disk/partition.c disk/partition.c
disk/ramdisk.c disk/ramdisk.c
disk/scsiport.c #disk/scsiport.c
fs/ext2.c fs/ext2.c
fs/fat.c fs/fat.c
fs/fs.c fs/fs.c
@ -148,6 +155,25 @@ if(ARCH MATCHES i386)
arch/i386/xboxvideo.c arch/i386/xboxvideo.c
windows/i386/ntsetup.c windows/i386/ntsetup.c
windows/i386/wlmemory.c) windows/i386/wlmemory.c)
elseif(ARCH MATCHES amd64)
list(APPEND FREELDR_ARCH_SOURCE
arch/amd64/loader.c
arch/i386/hardware.c
arch/i386/hwacpi.c
arch/i386/hwapm.c
arch/i386/hwpci.c
arch/i386/i386rtl.c
arch/i386/i386disk.c
arch/i386/i386vid.c
arch/i386/machpc.c
arch/i386/ntoskrnl.c
arch/i386/pccons.c
arch/i386/pcdisk.c
arch/i386/pcmem.c
arch/i386/pcrtc.c
arch/i386/pcvideo.c
windows/amd64/ntsetup.c
windows/amd64/wlmemory.c)
else() else()
#TBD #TBD
endif() endif()

View file

@ -32,14 +32,14 @@ RealEntryPoint:
/* Zero BootDrive and BootPartition */ /* Zero BootDrive and BootPartition */
xor eax, eax xor eax, eax
mov BootDrive, eax mov FrldrBootDrive, eax
mov BootPartition, eax mov FrldrBootPartition, eax
/* Store the boot drive */ /* Store the boot drive */
mov BootDrive, dl mov FrldrBootDrive, dl
/* Store the boot partition */ /* Store the boot partition */
mov BootPartition, dh mov FrldrBootPartition, dh
/* Load the GDT */ /* Load the GDT */
lgdt gdtptr lgdt gdtptr
@ -408,12 +408,12 @@ gdtptr:
.long gdt /* Base Address */ .long gdt /* Base Address */
.global BootDrive .global FrldrBootDrive
BootDrive: FrldrBootDrive:
.long 0 .long 0
.global BootPartition .global FrldrBootPartition
BootPartition: FrldrBootPartition:
.long 0 .long 0
.global NotAnX64Processor .global NotAnX64Processor

View file

@ -27,7 +27,6 @@ extern ULONG_PTR KernelBase;
ULONG_PTR GdtBase, IdtBase, TssBase; ULONG_PTR GdtBase, IdtBase, TssBase;
extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint; extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint;
PPAGE_DIRECTORY_AMD64 pPML4;
PVOID pIdt, pGdt; PVOID pIdt, pGdt;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/

View file

@ -0,0 +1,48 @@
#include <asm.inc>
EXTERN BootMain:PROC
.code64
/* 64 bit entry point */
PUBLIC mainCRTStartup
mainCRTStartup:
jmp BootMain
PUBLIC Int386
Int386:
ret
PUBLIC __lgdt
__lgdt:
PUBLIC __ltr
__ltr:
PUBLIC PxeCallApi
PxeCallApi:
.long 0
PUBLIC PageDirectoryStart
PageDirectoryStart:
.long 0
PUBLIC PageDirectoryEnd
PageDirectoryEnd:
.long 0
PUBLIC PnpBiosGetDeviceNode
PnpBiosGetDeviceNode:
.long 0
PUBLIC PnpBiosGetDeviceNodeCount
PnpBiosGetDeviceNodeCount:
.long 0
PUBLIC PnpBiosSupported
PnpBiosSupported:
.long 0
END

View file

@ -14,10 +14,10 @@ _LoaderEntry:
// globals // globals
PUBLIC _BootPartition PUBLIC _FrldrBootPartition
_BootPartition: _FrldrBootPartition:
PUBLIC _BootDrive PUBLIC _FrldrBootDrive
_BootDrive: _FrldrBootDrive:
PUBLIC _PageDirectoryStart PUBLIC _PageDirectoryStart
_PageDirectoryStart: _PageDirectoryStart:

View file

@ -132,14 +132,17 @@ DiskGetBootPath(char *BootPath, unsigned Size)
/* FIXME */ /* FIXME */
else if (DiskReadBootRecord(FrldrBootDrive, 0, &MasterBootRecord)) else if (DiskReadBootRecord(FrldrBootDrive, 0, &MasterBootRecord))
{ {
/* This is a hard disk */ ULONG BootPartition;
if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry, &FrldrBootPartition)) /* This is a hard disk */
if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition))
{ {
DbgPrint("Invalid active partition information\n"); DbgPrint("Invalid active partition information\n");
return FALSE; return FALSE;
} }
FrldrBootPartition = BootPartition;
if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition)) if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition))
{ {
return FALSE; return FALSE;

View file

@ -11,6 +11,33 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#undef ScsiPortLogError
#undef ScsiPortMoveMemory
#undef ScsiPortWritePortBufferUchar
#undef ScsiPortWritePortBufferUlong
#undef ScsiPortWritePortBufferUshort
#undef ScsiPortWritePortUchar
#undef ScsiPortWritePortUlong
#undef ScsiPortWritePortUshort
#undef ScsiPortWriteRegisterBufferUchar
#undef ScsiPortWriteRegisterBufferUlong
#undef ScsiPortWriteRegisterBufferUshort
#undef ScsiPortWriteRegisterUchar
#undef ScsiPortWriteRegisterUlong
#undef ScsiPortWriteRegisterUshort
#undef ScsiPortReadPortBufferUchar
#undef ScsiPortReadPortBufferUlong
#undef ScsiPortReadPortBufferUshort
#undef ScsiPortReadPortUchar
#undef ScsiPortReadPortUlong
#undef ScsiPortReadPortUshort
#undef ScsiPortReadRegisterBufferUchar
#undef ScsiPortReadRegisterBufferUlong
#undef ScsiPortReadRegisterBufferUshort
#undef ScsiPortReadRegisterUchar
#undef ScsiPortReadRegisterUlong
#undef ScsiPortReadRegisterUshort
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -54,17 +54,6 @@ VOID BootMain(LPSTR CmdLine)
RunLoader(); RunLoader();
} }
#ifdef _MSC_VER
long _ftol2(double f)
{
return _ftol(f);
}
long _ftol2_sse(double f)
{
return _ftol(f);
}
#endif
// We need to emulate these, because the original ones don't work in freeldr // We need to emulate these, because the original ones don't work in freeldr
int __cdecl wctomb(char *mbchar, wchar_t wchar) int __cdecl wctomb(char *mbchar, wchar_t wchar)
{ {

View file

@ -18,7 +18,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef __ASM__
#pragma once #pragma once
#endif
// This is needed because headers define wrong one for ReactOS // This is needed because headers define wrong one for ReactOS
#undef KIP0PCRADDRESS #undef KIP0PCRADDRESS
@ -52,14 +54,13 @@
#define NUM_PAGES_KERNEL #define NUM_PAGES_KERNEL
#ifndef ASM #ifndef ASM
typedef struct _PAGE_DIRECTORY_AMD64
{
HARDWARE_PTE Pde[512];
} PAGE_DIRECTORY_AMD64, *PPAGE_DIRECTORY_AMD64;
VOID FrLdrSetupGdtIdt(VOID); VOID FrLdrSetupGdtIdt(VOID);
#include <arch/i386/realmode.h>
#define FrldrBootDrive *((PULONG)BSS_BootDrive)
#define FrldrBootPartition *((PULONG)BSS_BootPartition)
#endif #endif
/* EOF */ /* EOF */

View file

@ -49,6 +49,7 @@ VOID PcPrepareForReactOS(IN BOOLEAN Setup);
ULONG PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize); ULONG PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOLEAN PcDiskGetBootPath(char *BootPath, unsigned Size);
BOOLEAN PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); BOOLEAN PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);

View file

@ -0,0 +1,13 @@
/* These addresses specify the realmode "BSS section" */
#define BSS_START HEX(7000)
#define BSS_CallbackAddress BSS_START + 0
#define BSS_CallbackReturn BSS_START + 8
#define BSS_BootDrive BSS_START + 16
#define BSS_BootPartition BSS_START + 20
#define PE_LOAD_BASE HEX(9000)
#define IMAGE_DOS_HEADER_e_lfanew 36
#define IMAGE_FILE_HEADER_SIZE 20
#define IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint 16

View file

@ -123,8 +123,10 @@ PCSTR DiskGetErrorCodeString(ULONG ErrorCode);
BOOLEAN DiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); // Implemented in i386disk.c BOOLEAN DiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); // Implemented in i386disk.c
BOOLEAN DiskIsDriveRemovable(ULONG DriveNumber); BOOLEAN DiskIsDriveRemovable(ULONG DriveNumber);
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
#ifndef _M_AMD64
extern ULONG FrldrBootDrive; extern ULONG FrldrBootDrive;
extern ULONG FrldrBootPartition; extern ULONG FrldrBootPartition;
#endif
BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size); BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size);

View file

@ -95,6 +95,7 @@
#elif defined(_M_AMD64) #elif defined(_M_AMD64)
#include <arch/amd64/hardware.h> #include <arch/amd64/hardware.h>
#include <arch/amd64/machpc.h> #include <arch/amd64/machpc.h>
#include <arch/i386/pxe.h>
#include <internal/amd64/intrin_i.h> #include <internal/amd64/intrin_i.h>
#endif #endif
/* misc files */ /* misc files */