mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
- mark special pages
- move some definitions to arch/amd64.h svn path=/branches/ros-amd64-bringup/; revision=34735
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
.text
|
||||
.code16
|
||||
|
||||
//.org 0x8000
|
||||
#define ASM
|
||||
#include <arch.h>
|
||||
|
||||
#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 */
|
||||
//.org 0x8000
|
||||
|
||||
.global RealEntryPoint
|
||||
RealEntryPoint:
|
||||
@@ -95,16 +95,6 @@ x86_16_EnableA20:
|
||||
* 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 @@ x86_16_BuildPageTables:
|
||||
/* 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
|
||||
@@ -149,11 +139,6 @@ Bpt2:
|
||||
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:
|
||||
cli
|
||||
|
||||
@@ -21,6 +21,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 */
|
||||
#define PMODE_CS 0x08 /* PMode code selector, base 0 limit 4g */
|
||||
@@ -55,35 +59,6 @@ extern PVOID FsStaticBufferDisk, FsStaticBufferData;
|
||||
#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;
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ BOOLEAN MmInitializeMemoryManager(VOID)
|
||||
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 @@ BOOLEAN MmInitializeMemoryManager(VOID)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user