31#define ULONGLONG_ALIGN_DOWN_BY(size, align) \
32 ((ULONGLONG)(size) & ~((ULONGLONG)(align) - 1))
34#define ULONGLONG_ALIGN_UP_BY(size, align) \
35 (ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align))
40#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
54#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
63 TRACE(
"GetExtendedMemoryConfiguration()\n");
66 *pMemoryAtSixteenMB = 0;
80 Int386(0x15, &RegsIn, &RegsOut);
82 TRACE(
"Int15h AX=E801h\n");
92 if (RegsOut.
w.
ax == 0)
95 *pMemoryAtSixteenMB = RegsOut.
w.
dx;
96 *pMemoryAtOneMB = RegsOut.
w.
cx;
102 *pMemoryAtSixteenMB = RegsOut.
w.
bx;
103 *pMemoryAtOneMB = RegsOut.
w.
ax;
122 Int386(0x15, &RegsIn, &RegsOut);
124 TRACE(
"Int15h AH=88h\n");
130 *pMemoryAtOneMB = RegsOut.
w.
ax;
138 *pMemoryAtOneMB = (*pMemoryAtOneMB & 0xFFFF);
139 *pMemoryAtOneMB = (*pMemoryAtOneMB << 8);
141 TRACE(
"Int15h Failed\n");
142 TRACE(
"CMOS reports: 0x%lx\n", *pMemoryAtOneMB);
144 if (*pMemoryAtOneMB != 0)
158 TRACE(
"PcMemGetConventionalMemorySize()\n");
170 Int386(0x12, &Regs, &Regs);
186 TRACE(
"GetEbdaLocation()\n");
197 Regs.
x.
eax = 0x0000C100;
198 Int386(0x15, &Regs, &Regs);
218 TRACE(
"PcMemCheckUsableMemorySize()\n");
231 "The BIOS reported a usable memory range up to 0x%lx, which is too small!\n"
232 "Required size is 0x%lx\n\n"
233 "If you see this, please report to the ReactOS team!",
243 ULONGLONG RealBaseAddress, EndAddress, RealSize;
248 TRACE(
"PcMemGetBiosMemoryMap()\n");
268 Regs.
x.
ebx = 0x00000000;
277 Regs.
x.
eax = 0x0000E820;
278 Regs.
x.
edx = 0x534D4150;
283 Int386(0x15, &Regs, &Regs);
286 TRACE(
"Int15h AX=E820h\n");
294 if (Regs.
x.
eax != 0x534D4150)
296 WARN(
"BIOS doesn't support Int15h AX=E820h!\n");
304 TRACE(
"End of System Memory Map! (Past last)\n");
310 TRACE(
"Discarding empty entry. (would-be-PcBiosMapCount = %lu)\n",
322 ERR(
"Int 15h AX=E820h returned an invalid entry length! (would-be-PcBiosMapCount = %lu, Entry length = (%Iu <=) %lu (<= %Iu))\n",
327 ASSERTMSG(
"Int 15h AX=E820h returned an invalid entry length!\n",
FALSE);
340 WARN(
"Discarding disabled/invalid entry. (would-be-PcBiosMapCount = %lu)\n",
363 FIXME(
"EA.ErrorLog = 1. Please report this to CORE-14150. "
364 "(PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx, Type = 0x%lx, ExtendedAttributesAsULONG = 0x%08lx)\n",
375 TRACE(
"Discarding empty range. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0)\n",
396 if (EndAddress <= RealBaseAddress)
399 TRACE(
"Skipping aligned range < PAGE_SIZE. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
407 RealSize = EndAddress - RealBaseAddress;
432 if (RealSize < MM_PAGE_SIZE)
434 TRACE(
"Skipping aligned range < MM_PAGE_SIZE. (PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
441 ERR(
"PcMemoryMap is already full! (PcBiosMapCount = %lu, PcMapCount = %lu (>= %lu))\n",
465 if (Regs.
x.
ebx == 0x00000000)
467 TRACE(
"End of System Memory Map! (Reset)\n");
474 ERR(
"PcBiosMemoryMap is already full! (PcBiosMapCount = %lu (>= %lu), PcMapCount = %lu)\n",
507 if ((
MemoryMap[
i].BasePage < BasePage + PageCount) &&
517 "Failed to reserve memory in the range 0x%Ix - 0x%Ix for %s",
582 TRACE(
"DiskReadBuffer=0x%p, DiskReadBufferSize=0x%lx\n",
594 TRACE(
"Dumping resulting memory map:\n");
597 TRACE(
"BasePage=0x%lx, PageCount=0x%lx, Type=%s\n",
606#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
612 ULONG ExtendedMemorySizeAtOneMB;
613 ULONG ExtendedMemorySizeAtSixteenMB;
614 ULONG EbdaBase, EbdaSize;
616 TRACE(
"PcMemGetMemoryMap()\n");
626 &ExtendedMemorySizeAtSixteenMB);
639 ExtendedMemorySizeAtOneMB * 1024 /
PAGE_SIZE,
642 if (ExtendedMemorySizeAtSixteenMB != 0)
648 ExtendedMemorySizeAtSixteenMB * 64 * 1024 /
PAGE_SIZE,
#define ALIGN_UP_BY(size, align)
BIOS_MEMORY_MAP MemoryMap[32]
DECLSPEC_NORETURN VOID FrLdrBugCheckWithMessage(ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
#define DBG_DEFAULT_CHANNEL(ch)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
SIZE_T DiskReadBufferSize
PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
#define ASSERTMSG(msg, exp)
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
_In_ ULONG _In_ ULONG _In_ ULONG Length
struct BIOS_MEMORY_MAP * PBIOS_MEMORY_MAP
#define READ_PORT_UCHAR(p)
#define WRITE_PORT_UCHAR(p, d)
#define INT386_SUCCESS(regs)
#define MAX_BIOS_DESCRIPTORS
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define ULONGLONG_ALIGN_UP_BY(size, align)
static FREELDR_MEMORY_DESCRIPTOR PcMemoryMap[MAX_BIOS_DESCRIPTORS+1]
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
ULONG PcMemFinalizeMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap)
static VOID PcMemCheckUsableMemorySize(VOID)
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS]
#define ULONGLONG_ALIGN_DOWN_BY(size, align)
VOID ReserveMemory(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG_PTR BaseAddress, SIZE_T Size, TYPE_OF_MEMORY MemoryType, PCHAR Usage)
static BOOLEAN GetExtendedMemoryConfiguration(ULONG *pMemoryAtOneMB, ULONG *pMemoryAtSixteenMB)
static ULONG PcMemGetConventionalMemorySize(VOID)
ULONG AddMemoryDescriptor(IN OUT PFREELDR_MEMORY_DESCRIPTOR List, IN ULONG MaxCount, IN PFN_NUMBER BasePage, IN PFN_NUMBER PageCount, IN TYPE_OF_MEMORY MemoryType)
static ULONG PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSize)
VOID SetMemory(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG_PTR BaseAddress, SIZE_T Size, TYPE_OF_MEMORY MemoryType)
static BOOLEAN GetEbdaLocation(PULONG BaseAddress, PULONG Size)
@ LoaderFirmwareTemporary
@ LoaderFirmwarePermanent
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
#define RtlCopyMemory(Destination, Source, Length)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
_Must_inspect_result_ _In_ WDFCMRESLIST List
#define MAX_DISKREADBUFFER_SIZE
#define BIOSCALLBUFSEGMENT
#define BIOSCALLBUFOFFSET
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)