Author: tkreuzer
Date: Thu Jul 24 06:32:40 2008
New Revision: 34735
URL:
http://svn.reactos.org/svn/reactos?rev=34735&view=rev
Log:
- mark special pages
- move some definitions to arch/amd64.h
Modified:
branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/arch.S
branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch.h
branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/mm/meminit.c
Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/arch.S
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/…
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1]
Thu Jul 24 06:32:40 2008
@@ -2,10 +2,10 @@
.text
.code16
+#define ASM
+#include <arch.h>
+
//.org 0x8000
-
-#define STACK16ADDR 0x7000 /* The 16-bit stack top will be at 0000:7000 */
-#define STACK64ADDR 0x74000 /* The 64-bit stack top will be at 0x74000 */
.global RealEntryPoint
RealEntryPoint:
@@ -95,16 +95,6 @@
* We define 512 2MB pages at the start of memory, so we can access the first
* 1 GB as if paging was disabled
*/
-
-#define PML4_PAGENUM 60 // Put it high enough so it doesn't interfere with freeldr
-
-#define PAGESIZE 4096
-#define PDP_PAGENUM (PML4_PAGENUM + 1)
-#define PD_PAGENUM (PDP_PAGENUM + 1)
-#define PML4_ADDRESS (PML4_PAGENUM * PAGESIZE)
-#define PDP_ADDRESS (PDP_PAGENUM * PAGESIZE)
-#define PML4_SEG (PML4_ADDRESS / 16)
-
x86_16_BuildPageTables:
pusha
push es
@@ -117,9 +107,9 @@
/* One entry in the PML4 pointing to PDP */
mov eax, (PDP_PAGENUM << 12) | 0x00f
stosd
- xor ax,ax
- mov cx, 0x07fe
- rep stosw
+ xor eax, eax
+ mov cx, 0x03ff
+ rep stosd
/* One entry in the PDP pointing to PD */
mov eax, (PD_PAGENUM << 12) | 0x00f
@@ -148,11 +138,6 @@
popa
ret
-
-#define LMODE_CS 0x08
-#define LMODE_DS 0x10
-#define RMODE_CS 0x18 /* RMode code selector, base 0 limit 64k */
-#define RMODE_DS 0x20 /* RMode data selector, base 0 limit 64k */
//.global x86_16_SwitchToLong
x86_16_SwitchToLong:
Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/…
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch.h [iso-8859-1]
Thu Jul 24 06:32:40 2008
@@ -20,6 +20,10 @@
#ifndef __ARCH_H
#define __ARCH_H
+
+#ifdef _M_AMD64
+#include <arch/amd64/amd64.h>
+#endif
/* Defines needed for switching between real and protected mode */
#define NULL_DESC 0x00 /* NULL descriptor */
@@ -55,35 +59,6 @@
#ifndef ASM
#include <pshpack1.h>
-#ifdef _M_AMD64
-typedef struct
-{
- unsigned long rax;
- unsigned long rbx;
- unsigned long rcx;
- unsigned long rdx;
-
- unsigned long rsi;
- unsigned long rdi;
-
- unsigned long r8;
- unsigned long r9;
- unsigned long r10;
- unsigned long r11;
- unsigned long r12;
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
-
- unsigned short ds;
- unsigned short es;
- unsigned short fs;
- unsigned short gs;
-
- unsigned long rflags;
-
-} QWORDREGS;
-#endif
typedef struct
{
unsigned long eax;
Modified:
branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/…
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
[iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h
[iso-8859-1] Thu Jul 24 06:32:40 2008
@@ -21,7 +21,54 @@
#ifndef __AMD64_AMD64_H_
#define __AMD64_AMD64_H_
+#define STACK64ADDR 0x74000 /* The 64-bit stack top will be at 0x74000 */
+#define LMODE_CS 0x08
+#define LMODE_DS 0x10
+
+/* Where we put out initial page tables */
+#define PML4_PAGENUM 60 // Put it high enough so it doesn't interfere with freeldr
+
+#define PAGESIZE 4096
+#define PDP_PAGENUM (PML4_PAGENUM + 1)
+#define PD_PAGENUM (PDP_PAGENUM + 1)
+#define PML4_ADDRESS (PML4_PAGENUM * PAGESIZE)
+#define PDP_ADDRESS (PDP_PAGENUM * PAGESIZE)
+#define PML4_SEG (PML4_ADDRESS / 16)
+#define PML4_PAGES 3
+#define PAGETABLE_SIZE PML4_PAGES * PAGESIZE
+
+#if 0
+#ifndef ASM
+typedef struct
+{
+ unsigned long long rax;
+ unsigned long long rbx;
+ unsigned long long rcx;
+ unsigned long long rdx;
+
+ unsigned long long rsi;
+ unsigned long long rdi;
+
+ unsigned long long r8;
+ unsigned long long r9;
+ unsigned long long r10;
+ unsigned long long r11;
+ unsigned long long r12;
+ unsigned long long r13;
+ unsigned long long r14;
+ unsigned long long r15;
+
+ unsigned short ds;
+ unsigned short es;
+ unsigned short fs;
+ unsigned short gs;
+
+ unsigned long long rflags;
+
+} QWORDREGS;
+#endif /* ! ASM */
+#endif
#endif /* __AMD64_AMD64_H_ */
Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/mm/meminit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/…
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1] Thu
Jul 24 06:32:40 2008
@@ -97,7 +97,7 @@
MmUpdateLastFreePageHint(PageLookupTableAddress, TotalPagesInLookupTable);
// Add machine-dependent stuff
-#ifdef __i386__
+#if defined (__i386__) || defined (_M_AMD64)
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x00, 1, LoaderFirmwarePermanent); //
realmode int vectors
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x01, 7, LoaderFirmwareTemporary); //
freeldr stack + cmdline
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x08, 0x70, LoaderLoadedProgram); //
freeldr image (roughly max. 0x64 pages)
@@ -106,6 +106,9 @@
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x90, 0x10, LoaderOsloaderHeap); //
Disk read buffer for int 13h. DISKREADBUFFER
MmMarkPagesInLookupTable(PageLookupTableAddress, 0xA0, 0x60, LoaderFirmwarePermanent);
// ROM / Video
MmMarkPagesInLookupTable(PageLookupTableAddress, 0xFFF, 1, LoaderSpecialMemory); //
unusable memory
+#if defined (_M_AMD64)
+ MmMarkPagesInLookupTable(PageLookupTableAddress, PML4_PAGENUM, PML4_PAGES,
LoaderSpecialMemory); // the page table
+#endif
#elif __arm__
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x00, 1, LoaderFirmwarePermanent); //
arm exception handlers
MmMarkPagesInLookupTable(PageLookupTableAddress, 0x01, 7, LoaderFirmwareTemporary); //
arm board block + freeldr stack + cmdline