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))
58 TRACE(
"GetExtendedMemoryConfiguration()\n");
61 *pMemoryAtSixteenMB = 0;
75 Int386(0x15, &RegsIn, &RegsOut);
77 TRACE(
"Int15h AX=E801h\n");
87 if (RegsOut.
w.
ax == 0)
90 *pMemoryAtSixteenMB = RegsOut.
w.
dx;
91 *pMemoryAtOneMB = RegsOut.
w.
cx;
97 *pMemoryAtSixteenMB = RegsOut.
w.
bx;
98 *pMemoryAtOneMB = RegsOut.
w.
ax;
117 Int386(0x15, &RegsIn, &RegsOut);
119 TRACE(
"Int15h AH=88h\n");
125 *pMemoryAtOneMB = RegsOut.
w.
ax;
133 *pMemoryAtOneMB = (*pMemoryAtOneMB & 0xFFFF);
134 *pMemoryAtOneMB = (*pMemoryAtOneMB << 8);
136 TRACE(
"Int15h Failed\n");
137 TRACE(
"CMOS reports: 0x%lx\n", *pMemoryAtOneMB);
139 if (*pMemoryAtOneMB != 0)
153 TRACE(
"PcMemGetConventionalMemorySize()\n");
165 Int386(0x12, &Regs, &Regs);
181 TRACE(
"GetEbdaLocation()\n");
192 Regs.
x.
eax = 0x0000C100;
193 Int386(0x15, &Regs, &Regs);
213 TRACE(
"PcMemCheckUsableMemorySize()\n");
226 "The BIOS reported a usable memory range up to 0x%lx, which is too small!\n"
227 "Required size is 0x%lx\n\n"
228 "If you see this, please report to the ReactOS team!",
238 ULONGLONG RealBaseAddress, EndAddress, RealSize;
243 TRACE(
"PcMemGetBiosMemoryMap()\n");
263 Regs.
x.
ebx = 0x00000000;
272 Regs.
x.
eax = 0x0000E820;
273 Regs.
x.
edx = 0x534D4150;
278 Int386(0x15, &Regs, &Regs);
281 TRACE(
"Int15h AX=E820h\n");
289 if (Regs.
x.
eax != 0x534D4150)
291 WARN(
"BIOS doesn't support Int15h AX=E820h!\n");
299 TRACE(
"End of System Memory Map! (Past last)\n");
305 TRACE(
"Discarding empty entry. (would-be-PcBiosMapCount = %lu)\n",
317 ERR(
"Int 15h AX=E820h returned an invalid entry length! (would-be-PcBiosMapCount = %lu, Entry length = (%Iu <=) %lu (<= %Iu))\n",
322 ASSERTMSG(
"Int 15h AX=E820h returned an invalid entry length!\n",
FALSE);
335 WARN(
"Discarding disabled/invalid entry. (would-be-PcBiosMapCount = %lu)\n",
358 FIXME(
"EA.ErrorLog = 1. Please report this to CORE-14150. "
359 "(PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx, Type = 0x%lx, ExtendedAttributesAsULONG = 0x%08lx)\n",
370 TRACE(
"Discarding empty range. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0)\n",
391 if (EndAddress <= RealBaseAddress)
394 TRACE(
"Skipping aligned range < PAGE_SIZE. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
402 RealSize = EndAddress - RealBaseAddress;
427 if (RealSize < MM_PAGE_SIZE)
429 TRACE(
"Skipping aligned range < MM_PAGE_SIZE. (PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
436 ERR(
"PcMemoryMap is already full! (PcBiosMapCount = %lu, PcMapCount = %lu (>= %lu))\n",
460 if (Regs.
x.
ebx == 0x00000000)
462 TRACE(
"End of System Memory Map! (Reset)\n");
469 ERR(
"PcBiosMemoryMap is already full! (PcBiosMapCount = %lu (>= %lu), PcMapCount = %lu)\n",
500 if ((
MemoryMap[
i].BasePage < BasePage + PageCount) &&
510 "Failed to reserve memory in the range 0x%Ix - 0x%Ix for %s",
575 TRACE(
"DiskReadBuffer=0x%p, DiskReadBufferSize=0x%lx\n",
587 TRACE(
"Dumping resulting memory map:\n");
590 TRACE(
"BasePage=0x%lx, PageCount=0x%lx, Type=%s\n",
593 MmGetSystemMemoryMapTypeString(
MemoryMap[
i].MemoryType));
602 ULONG ExtendedMemorySizeAtOneMB;
603 ULONG ExtendedMemorySizeAtSixteenMB;
604 ULONG EbdaBase, EbdaSize;
606 TRACE(
"PcMemGetMemoryMap()\n");
616 &ExtendedMemorySizeAtSixteenMB);
629 ExtendedMemorySizeAtOneMB * 1024 /
PAGE_SIZE,
632 if (ExtendedMemorySizeAtSixteenMB != 0)
638 ExtendedMemorySizeAtSixteenMB * 64 * 1024 /
PAGE_SIZE,
#define ALIGN_UP_BY(size, align)
BIOS_MEMORY_MAP MemoryMap[32]
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
_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)
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)