[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,10 +18,15 @@ if(ARCH MATCHES i386)
arch/i386/arch.S)
endif()
elseif(ARCH MATCHES amd64)
if(MSVC)
list(APPEND FREELDR_BASE64K_SOURCE
arch/amd64/stubs.S)
else()
list(APPEND FREELDR_STARTUP_SOURCE
arch/i386/fathelp.S
arch/amd64/arch.S)
endif()
endif()
if(ARCH MATCHES i386)
if(NOT MSVC)
@ -39,6 +44,7 @@ if(ARCH MATCHES i386)
arch/i386/i386bug.c)
endif()
elseif(ARCH MATCHES amd64)
if(NOT MSVC)
list(APPEND FREELDR_BASE64K_SOURCE
arch/i386/drvmap.S
arch/i386/i386cpu.S
@ -46,6 +52,7 @@ elseif(ARCH MATCHES amd64)
arch/i386/i386trap.S
arch/amd64/mb.S)
endif()
endif()
set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
@ -60,7 +67,7 @@ list(APPEND FREELDR_BASE_SOURCE
disk/disk.c
disk/partition.c
disk/ramdisk.c
disk/scsiport.c
#disk/scsiport.c
fs/ext2.c
fs/fat.c
fs/fs.c
@ -148,6 +155,25 @@ if(ARCH MATCHES i386)
arch/i386/xboxvideo.c
windows/i386/ntsetup.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()
#TBD
endif()

View file

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

View file

@ -27,7 +27,6 @@ extern ULONG_PTR KernelBase;
ULONG_PTR GdtBase, IdtBase, TssBase;
extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint;
PPAGE_DIRECTORY_AMD64 pPML4;
PVOID pIdt, pGdt;
/* 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
PUBLIC _BootPartition
_BootPartition:
PUBLIC _BootDrive
_BootDrive:
PUBLIC _FrldrBootPartition
_FrldrBootPartition:
PUBLIC _FrldrBootDrive
_FrldrBootDrive:
PUBLIC _PageDirectoryStart
_PageDirectoryStart:

View file

@ -132,14 +132,17 @@ DiskGetBootPath(char *BootPath, unsigned Size)
/* FIXME */
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");
return FALSE;
}
FrldrBootPartition = BootPartition;
if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition))
{
return FALSE;

View file

@ -11,6 +11,33 @@
#include <stdio.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
#include <debug.h>

View file

@ -54,17 +54,6 @@ VOID BootMain(LPSTR CmdLine)
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
int __cdecl wctomb(char *mbchar, wchar_t wchar)
{

View file

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

View file

@ -49,6 +49,7 @@ VOID PcPrepareForReactOS(IN BOOLEAN Setup);
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 PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
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 DiskIsDriveRemovable(ULONG DriveNumber);
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
#ifndef _M_AMD64
extern ULONG FrldrBootDrive;
extern ULONG FrldrBootPartition;
#endif
BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size);

View file

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