Author: tkreuzer
Date: Fri Jun 10 12:55:14 2011
New Revision: 52172
URL:
http://svn.reactos.org/svn/reactos?rev=52172&view=rev
Log:
[FREELDR]
Fix MSVC and amd64 build
Added:
trunk/reactos/boot/freeldr/freeldr/arch/amd64/stubs.S (with props)
trunk/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h (with props)
Modified:
trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S
trunk/reactos/boot/freeldr/freeldr/arch/amd64/loader.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/realmode.S
trunk/reactos/boot/freeldr/freeldr/disk/disk.c
trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c
trunk/reactos/boot/freeldr/freeldr/freeldr.c
trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h
trunk/reactos/boot/freeldr/freeldr/include/disk.h
trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMake…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -18,9 +18,14 @@
arch/i386/arch.S)
endif()
elseif(ARCH MATCHES amd64)
- list(APPEND FREELDR_STARTUP_SOURCE
- arch/i386/fathelp.S
- arch/amd64/arch.S)
+ 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)
@@ -39,12 +44,14 @@
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
arch/i386/i386idt.S
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 @@
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 @@
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()
Modified: trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -25,21 +25,21 @@
/* checkPoint Charlie - where it all began... */
mov si, offset CheckPoint0
- call writestr
+ call writestr
/* Setup a real mode stack */
mov sp, stack16
/* 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
@@ -50,16 +50,16 @@
/* checkPoint Charlie - where it all began... */
mov si, offset CheckPoint1
- call writestr
-
+ call writestr
+
call x86_16_BuildPageTables
-
+
/* checkPoint Charlie - where it all began... */
mov si, offset CheckPoint2
- call writestr
+ call writestr
/* Check if CPU supports CPUID */
-
+
pushfd
pop eax
mov ebx, eax
@@ -70,8 +70,8 @@
pop eax
cmp eax,ebx
jz NO_CPUID_SUPPORT_DETECTED
-
- /* CPUID support detected - getting the PAE/PGE */
+
+ /* CPUID support detected - getting the PAE/PGE */
mov eax,1 // Fn0000_0001 - PAE in EDX[6]
cpuid
@@ -79,24 +79,24 @@
and edx,0x00a0
test edx,edx // are PAE and PGE bits set?
jz NO_X64_SUPPORT_DETECTED
-
+
/* PAE and PGE are here */
-
+
xor edx, edx
mov eax, 0x80000001
cpuid
and edx, 0x20000000
test edx,edx
jz NO_X64_SUPPORT_DETECTED
-
+
/* X64 Processor */
-
+
/* checkPoint Charlie - where it all began... */
mov si, offset CheckPoint3
- call writestr
+ call writestr
jmp switch64
-
+
NO_X64_SUPPORT_DETECTED:
mov si, offset NotAnX64Processor // Loading message
call writestr
@@ -129,7 +129,7 @@
// mov ds, ax
// mov word ptr ds:[0xb8002], 0x0e02 + '2'
-
+
/* Return into real mode */
call x86_64_SwitchToReal
.code16
@@ -169,7 +169,7 @@
ret
/*
- * We define 512 2MB pages at the start of memory, so we can access the first
+ * We define 512 2MB pages at the start of memory, so we can access the first
* 1 GB as if paging was disabled
*/
x86_16_BuildPageTables:
@@ -238,7 +238,7 @@
popad
popfd
ret
-
+
writechr:
pushf
@@ -252,7 +252,7 @@
//.global x86_16_SwitchToLong
x86_16_SwitchToLong:
-
+
cli
xor ax,ax
@@ -332,7 +332,7 @@
/* Step 2 - disable long mode in EFER MSR */
// mov ecx, 0xC0000080 // Specify EFER MSR
-// rdmsr
+// rdmsr
// and eax, ~0x00000100 // Disable EFER.LME
// wrmsr
@@ -408,12 +408,12 @@
.long gdt /* Base Address */
-.global BootDrive
-BootDrive:
+.global FrldrBootDrive
+FrldrBootDrive:
.long 0
-
-.global BootPartition
-BootPartition:
+
+.global FrldrBootPartition
+FrldrBootPartition:
.long 0
.global NotAnX64Processor
@@ -431,12 +431,12 @@
CheckPoint0:
.ascii "Starting FreeLoader..."
.byte 0x0d, 0x0a, 0
-
+
.global CheckPoint1
CheckPoint1:
.ascii "FreeLoader[16-bit]: building page tables..."
.byte 0x0d, 0x0a, 0
-
+
.global CheckPoint2
CheckPoint2:
.ascii "FreeLoader[16-bit]: checking CPU for x64 long mode..."
Modified: trunk/reactos/boot/freeldr/freeldr/arch/amd64/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/loader.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/loader.c [iso-8859-1] Fri Jun 10
12:55:14 2011
@@ -27,7 +27,6 @@
ULONG_PTR GdtBase, IdtBase, TssBase;
extern ROS_KERNEL_ENTRY_POINT KernelEntryPoint;
-PPAGE_DIRECTORY_AMD64 pPML4;
PVOID pIdt, pGdt;
/* FUNCTIONS *****************************************************************/
Added: trunk/reactos/boot/freeldr/freeldr/arch/amd64/stubs.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/amd64/stubs.S (added)
+++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/stubs.S [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -1,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
Propchange: trunk/reactos/boot/freeldr/freeldr/arch/amd64/stubs.S
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/realmode.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/realmode.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/realmode.S [iso-8859-1] Fri Jun 10
12:55:14 2011
@@ -14,10 +14,10 @@
// globals
-PUBLIC _BootPartition
-_BootPartition:
-PUBLIC _BootDrive
-_BootDrive:
+PUBLIC _FrldrBootPartition
+_FrldrBootPartition:
+PUBLIC _FrldrBootDrive
+_FrldrBootDrive:
PUBLIC _PageDirectoryStart
_PageDirectoryStart:
Modified: trunk/reactos/boot/freeldr/freeldr/disk/disk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] Fri Jun 10 12:55:14 2011
@@ -132,18 +132,21 @@
/* FIXME */
else if (DiskReadBootRecord(FrldrBootDrive, 0, &MasterBootRecord))
{
+ ULONG BootPartition;
+
/* This is a hard disk */
-
- if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry,
&FrldrBootPartition))
+ if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry,
&BootPartition))
{
DbgPrint("Invalid active partition information\n");
return FALSE;
}
- if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition))
- {
- return FALSE;
- }
+ FrldrBootPartition = BootPartition;
+
+ if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition))
+ {
+ return FALSE;
+ }
strcpy(BootPath, Path);
@@ -158,7 +161,7 @@
strcat(BootPath, "partition(");
strcat(BootPath, Partition);
strcat(BootPath, ")");
- }
+ }
else
{
/* This is a CD-ROM drive */
Modified: trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -10,6 +10,33 @@
#include <ntdddisk.h>
#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>
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr.c [iso-8859-1] Fri Jun 10 12:55:14 2011
@@ -54,17 +54,6 @@
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)
{
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h [iso-8859-1] Fri Jun 10
12:55:14 2011
@@ -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
@@ -49,16 +51,15 @@
#define APIC_PHYS_BASE 0xfee00000
-#define NUM_PAGES_KERNEL
+#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
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h [iso-8859-1]
(original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h [iso-8859-1] Fri Jun 10
12:55:14 2011
@@ -49,6 +49,7 @@
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);
Added: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h (added)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h [iso-8859-1] Fri Jun
10 12:55:14 2011
@@ -1,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
Propchange: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/freeldr/freeldr/include/disk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -123,8 +123,10 @@
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);
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] Fri Jun 10 12:55:14
2011
@@ -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 */