ReactOS 0.4.16-dev-2104-gb84fa49
pcmem.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 *
4 * Copyright ... ... (See below.)
5 * Copyright 2017 Serge Gautherie <reactos-git_serge_171003@gautherie.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Note: Most of this code comes from the old file "i386mem.c", which
22 * was Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
23 */
24
25#include <freeldr.h>
26#include <arch/pc/x86common.h>
27
28#include <debug.h>
30
31#define ULONGLONG_ALIGN_DOWN_BY(size, align) \
32 ((ULONGLONG)(size) & ~((ULONGLONG)(align) - 1))
33
34#define ULONGLONG_ALIGN_UP_BY(size, align) \
35 (ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align))
36
39
40#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
42#endif
44
48 IN ULONG MaxCount,
49 IN PFN_NUMBER BasePage,
50 IN PFN_NUMBER PageCount,
51 IN TYPE_OF_MEMORY MemoryType);
52
53/* FIXME: Abstract things better so we don't need to place define here */
54#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
55
56static
58GetExtendedMemoryConfiguration(ULONG* pMemoryAtOneMB /* in KB */, ULONG* pMemoryAtSixteenMB /* in 64KB */)
59{
60 REGS RegsIn;
61 REGS RegsOut;
62
63 TRACE("GetExtendedMemoryConfiguration()\n");
64
65 *pMemoryAtOneMB = 0;
66 *pMemoryAtSixteenMB = 0;
67
68 // Int 15h AX=E801h
69 // Phoenix BIOS v4.0 - GET MEMORY SIZE FOR >64M CONFIGURATIONS
70 //
71 // AX = E801h
72 // Return:
73 // CF clear if successful
74 // AX = extended memory between 1M and 16M, in K (max 3C00h = 15MB)
75 // BX = extended memory above 16M, in 64K blocks
76 // CX = configured memory 1M to 16M, in K
77 // DX = configured memory above 16M, in 64K blocks
78 // CF set on error
79 RegsIn.w.ax = 0xE801;
80 Int386(0x15, &RegsIn, &RegsOut);
81
82 TRACE("Int15h AX=E801h\n");
83 TRACE("AX = 0x%x\n", RegsOut.w.ax);
84 TRACE("BX = 0x%x\n", RegsOut.w.bx);
85 TRACE("CX = 0x%x\n", RegsOut.w.cx);
86 TRACE("DX = 0x%x\n", RegsOut.w.dx);
87 TRACE("CF set = %s\n", (RegsOut.x.eflags & EFLAGS_CF) ? "TRUE" : "FALSE");
88
89 if (INT386_SUCCESS(RegsOut))
90 {
91 // If AX=BX=0000h the use CX and DX
92 if (RegsOut.w.ax == 0)
93 {
94 // Return extended memory size in K
95 *pMemoryAtSixteenMB = RegsOut.w.dx;
96 *pMemoryAtOneMB = RegsOut.w.cx;
97 return TRUE;
98 }
99 else
100 {
101 // Return extended memory size in K
102 *pMemoryAtSixteenMB = RegsOut.w.bx;
103 *pMemoryAtOneMB = RegsOut.w.ax;
104 return TRUE;
105 }
106 }
107
108 // If we get here then Int15 Func E801h didn't work
109 // So try Int15 Func 88h
110 // Int 15h AH=88h
111 // SYSTEM - GET EXTENDED MEMORY SIZE (286+)
112 //
113 // AH = 88h
114 // Return:
115 // CF clear if successful
116 // AX = number of contiguous KB starting at absolute address 100000h
117 // CF set on error
118 // AH = status
119 // 80h invalid command (PC,PCjr)
120 // 86h unsupported function (XT,PS30)
121 RegsIn.b.ah = 0x88;
122 Int386(0x15, &RegsIn, &RegsOut);
123
124 TRACE("Int15h AH=88h\n");
125 TRACE("AX = 0x%x\n", RegsOut.w.ax);
126 TRACE("CF set = %s\n", (RegsOut.x.eflags & EFLAGS_CF) ? "TRUE" : "FALSE");
127
128 if (INT386_SUCCESS(RegsOut) && RegsOut.w.ax != 0)
129 {
130 *pMemoryAtOneMB = RegsOut.w.ax;
131 return TRUE;
132 }
133
134 // If we get here then Int15 Func 88h didn't work
135 // So try reading the CMOS
136 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x31);
137 *pMemoryAtOneMB = READ_PORT_UCHAR((PUCHAR)0x71);
138 *pMemoryAtOneMB = (*pMemoryAtOneMB & 0xFFFF);
139 *pMemoryAtOneMB = (*pMemoryAtOneMB << 8);
140
141 TRACE("Int15h Failed\n");
142 TRACE("CMOS reports: 0x%lx\n", *pMemoryAtOneMB);
143
144 if (*pMemoryAtOneMB != 0)
145 {
146 return TRUE;
147 }
148
149 return FALSE;
150}
151
152static
153ULONG
155{
156 REGS Regs;
157
158 TRACE("PcMemGetConventionalMemorySize()\n");
159
160 /* Int 12h
161 * BIOS - GET MEMORY SIZE
162 *
163 * Return:
164 * AX = kilobytes of contiguous memory starting at absolute address 00000h
165 *
166 * This call returns the contents of the word at 0040h:0013h;
167 * in PC and XT, this value is set from the switches on the motherboard
168 */
169 Regs.w.ax = 0;
170 Int386(0x12, &Regs, &Regs);
171
172 TRACE("Int12h\n");
173 TRACE("AX = 0x%x\n", Regs.w.ax);
174
175 return (ULONG)Regs.w.ax;
176}
177
178static
182 PULONG Size)
183{
184 REGS Regs;
185
186 TRACE("GetEbdaLocation()\n");
187
188 /* Get the address of the Extended BIOS Data Area (EBDA).
189 * Int 15h, AH=C1h
190 * SYSTEM - RETURN EXTENDED-BIOS DATA-AREA SEGMENT ADDRESS (PS)
191 *
192 * Return:
193 * CF set on error
194 * CF clear if successful
195 * ES = segment of data area
196 */
197 Regs.x.eax = 0x0000C100;
198 Int386(0x15, &Regs, &Regs);
199
200 /* If the function fails, there is no EBDA */
201 if (!INT386_SUCCESS(Regs))
202 {
203 return FALSE;
204 }
205
206 /* Get Base address and (maximum) size */
207 *BaseAddress = (ULONG)Regs.w.es << 4;
208 *Size = 0xA0000 - *BaseAddress;
209 return TRUE;
210}
211
212static
213VOID
215{
217
218 TRACE("PcMemCheckUsableMemorySize()\n");
219
220 /* Make sure the usable memory is large enough. To do this we check the 16
221 bit value at address 0x413 inside the BDA, which gives us the usable size
222 in KB */
223 Size = (*(PUSHORT)(ULONG_PTR)0x413) * 1024;
225 if (Size < RequiredSize)
226 {
229 __FILE__,
230 __LINE__,
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!",
235 }
236}
237
238static
239ULONG
241{
242 REGS Regs;
243 ULONGLONG RealBaseAddress, EndAddress, RealSize;
244 TYPE_OF_MEMORY MemoryType;
245
247
248 TRACE("PcMemGetBiosMemoryMap()\n");
249
250 /* Int 15h AX=E820h
251 * Newer BIOSes - GET SYSTEM MEMORY MAP
252 *
253 * AX = E820h
254 * EAX = 0000E820h
255 * EDX = 534D4150h ('SMAP')
256 * EBX = continuation value or 00000000h to start at beginning of map
257 * ECX = size of buffer for result, in bytes (should be >= 20 bytes)
258 * ES:DI -> buffer for result
259 * Return:
260 * CF clear if successful
261 * EAX = 534D4150h ('SMAP')
262 * ES:DI buffer filled
263 * EBX = next offset from which to copy or 00000000h if all done
264 * ECX = actual length returned in bytes
265 * CF set on error
266 * AH = error code (86h)
267 */
268 Regs.x.ebx = 0x00000000;
269
271 {
272 /* ACPI 3.0/4.0: Set Extended Attributes to enabled/valid by default, in case entry has no E.A.. */
273 ((PBIOS_MEMORY_MAP)BIOSCALLBUFFER)->ExtendedAttributesAsULONG = 0;
274 ((PBIOS_MEMORY_MAP)BIOSCALLBUFFER)->ExtendedAttributes.Enabled_Reserved = 1;
275
276 /* Setup the registers for the BIOS call */
277 Regs.x.eax = 0x0000E820;
278 Regs.x.edx = 0x534D4150; /* ('SMAP') */
279 /* Regs.x.ebx = 0x00000001; Continuation value already set */
280 Regs.x.ecx = sizeof(BIOS_MEMORY_MAP);
281 Regs.w.es = BIOSCALLBUFSEGMENT;
282 Regs.w.di = BIOSCALLBUFOFFSET;
283 Int386(0x15, &Regs, &Regs);
284
285 TRACE("Memory Map Entry %lu\n", PcBiosMapCount);
286 TRACE("Int15h AX=E820h\n");
287 TRACE("EAX = 0x%lx\n", Regs.x.eax);
288 TRACE("EBX = 0x%lx\n", Regs.x.ebx);
289 TRACE("ECX = %lu\n", Regs.x.ecx);
290 TRACE("CF set = %s\n", (Regs.x.eflags & EFLAGS_CF) ? "TRUE" : "FALSE");
291
292 /* If the BIOS didn't return 'SMAP' in EAX then
293 * it doesn't support this call. */
294 if (Regs.x.eax != 0x534D4150)
295 {
296 WARN("BIOS doesn't support Int15h AX=E820h!\n");
297 break;
298 }
299
300 /* If the carry flag is set,
301 * then this call was past the last entry, so we're done. */
302 if (!INT386_SUCCESS(Regs))
303 {
304 TRACE("End of System Memory Map! (Past last)\n");
305 break;
306 }
307
308 if (Regs.x.ecx == 0)
309 {
310 TRACE("Discarding empty entry. (would-be-PcBiosMapCount = %lu)\n",
312 goto nextRange;
313 }
314
315 /* Extra safety: unexpected entry length.
316 * All in-between values are valid too, as x86 is little-indian
317 * and only lower byte is used per ACPI 6.2-A.
318 */
320 Regs.x.ecx > sizeof(BIOS_MEMORY_MAP))
321 {
322 ERR("Int 15h AX=E820h returned an invalid entry length! (would-be-PcBiosMapCount = %lu, Entry length = (%Iu <=) %lu (<= %Iu))\n",
324 /* Warn user, unless wrong case is "first and not too big entry", which is otherwise harmless. */
325 if (PcBiosMapCount > 0 || Regs.x.ecx > sizeof(BIOS_MEMORY_MAP))
326 {
327 ASSERTMSG("Int 15h AX=E820h returned an invalid entry length!\n", FALSE);
328 }
329 /* We keep previous entries (if any), but do not dare trying next entries.
330 * We assume these entries are good to use as is. If they are not, we are in trouble...
331 * (And don't ask what happens if BIOS actually overflowed our entry buffer...)
332 *
333 * FIXME: Safer = revert previous entries, Safest = blacklist this BIOS.
334 */
335 break;
336 }
337
338 if (((PBIOS_MEMORY_MAP)BIOSCALLBUFFER)->ExtendedAttributes.Enabled_Reserved == 0)
339 {
340 WARN("Discarding disabled/invalid entry. (would-be-PcBiosMapCount = %lu)\n",
342 /* This unlikely case was correct between ACPI 3.0 and 4.0, so assume all is fine.
343 * Unless we would be ready to drop ACPI 3.0 compatibility.
344 */
345 goto nextRange;
346 }
347
348 /*
349 * Other deprecated ExtendedAttributes flags such as NonVolatile_Deprecated_Reserved
350 * or SlowAccess_Deprecated_Reserved are simply ignored.
351 */
352
353 /* Copy data to global buffer */
355
356 TRACE("BaseAddress: 0x%llx\n", PcBiosMemoryMap[PcBiosMapCount].BaseAddress);
357 TRACE("Length: 0x%llx\n", PcBiosMemoryMap[PcBiosMapCount].Length);
358 TRACE("Type: 0x%lx\n", PcBiosMemoryMap[PcBiosMapCount].Type);
359 TRACE("ExtendedAttributesAsULONG: 0x%08lx\n", PcBiosMemoryMap[PcBiosMapCount].ExtendedAttributesAsULONG);
360
361 if (PcBiosMemoryMap[PcBiosMapCount].ExtendedAttributes.ErrorLog == 1)
362 {
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",
369 PcBiosMemoryMap[PcBiosMapCount].ExtendedAttributesAsULONG);
370 // NotWantedForPublicBuilds: ASSERTMSG("EA.ErrorLog = 1. Check/Report then CONTinue.\n", FALSE);
371 }
372
374 {
375 TRACE("Discarding empty range. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0)\n",
377 goto nextRange;
378 }
379
380 /* Check if this is free memory */
382 {
383 MemoryType = LoaderFree;
384
385 /* Align up base of memory range */
386 RealBaseAddress = ULONGLONG_ALIGN_UP_BY(
388 PAGE_SIZE);
389
390 /* Calculate aligned EndAddress */
393 EndAddress = ULONGLONG_ALIGN_DOWN_BY(EndAddress, PAGE_SIZE);
394
395 /* Check if there is anything left */
396 if (EndAddress <= RealBaseAddress)
397 {
398 /* This doesn't span any page, so continue with next range */
399 TRACE("Skipping aligned range < PAGE_SIZE. (would-be-PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
403 goto nextRange;
404 }
405
406 /* Calculate the length of the aligned range */
407 RealSize = EndAddress - RealBaseAddress;
408 }
409 else
410 {
412 {
413 MemoryType = LoaderFirmwarePermanent;
414 }
415 else
416 {
417 MemoryType = LoaderSpecialMemory;
418 }
419
420 /* Align down base of memory area */
421 RealBaseAddress = ULONGLONG_ALIGN_DOWN_BY(
423 PAGE_SIZE);
424
425 /* Calculate the length after aligning the base */
427 PcBiosMemoryMap[PcBiosMapCount].Length - RealBaseAddress;
428 RealSize = ULONGLONG_ALIGN_UP_BY(RealSize, PAGE_SIZE);
429 }
430
431 /* Check if we can add this descriptor */
432 if (RealSize < MM_PAGE_SIZE)
433 {
434 TRACE("Skipping aligned range < MM_PAGE_SIZE. (PcBiosMapCount = %lu, BaseAddress = 0x%llx, Length = 0x%llx)\n",
438 }
439 else if (PcMapCount >= MaxMemoryMapSize)
440 {
441 ERR("PcMemoryMap is already full! (PcBiosMapCount = %lu, PcMapCount = %lu (>= %lu))\n",
442 PcBiosMapCount, PcMapCount, MaxMemoryMapSize);
443 // NotWantedForPublicBuilds: ASSERTMSG("PcMemoryMap is already full!\n", FALSE);
444 /* We keep previous entries, and half-retrieve current/next entries.
445 * We assume all these entries are good to use as is. If they are not, we are in trouble...
446 *
447 * FIXME: Safer = revert (half-)retrieved entries, Safest = increase MaxMemoryMapSize.
448 */
449 }
450 else
451 {
452 /* Add the descriptor */
455 (PFN_NUMBER)(RealBaseAddress / MM_PAGE_SIZE),
456 (PFN_NUMBER)(RealSize / MM_PAGE_SIZE),
457 MemoryType);
458 }
459
461
462nextRange:
463 /* If the continuation value is zero,
464 * then this was the last entry, so we're done. */
465 if (Regs.x.ebx == 0x00000000)
466 {
467 TRACE("End of System Memory Map! (Reset)\n");
468 break;
469 }
470 }
471 /* Check whether there would be more entries to process. */
472 if (PcBiosMapCount >= MAX_BIOS_DESCRIPTORS && Regs.x.ebx != 0x00000000)
473 {
474 ERR("PcBiosMemoryMap is already full! (PcBiosMapCount = %lu (>= %lu), PcMapCount = %lu)\n",
476 // NotWantedForPublicBuilds: ASSERTMSG("PcBiosMemoryMap is already full!\n", FALSE);
477 /* We keep retrieved entries, but ignore next entries.
478 * We assume these entries are good to use as is. If they are not, we are in trouble...
479 *
480 * FIXME: Safer = revert retrieved entries, Safest = increase MAX_BIOS_DESCRIPTORS.
481 */
482 }
483
484 TRACE("PcMemGetBiosMemoryMap end: PcBiosMapCount = %lu\n", PcBiosMapCount);
485 return PcBiosMapCount;
486}
487
488#endif // !SARCH_XBOX && !SARCH_PC98
489
490VOID
494 SIZE_T Size,
495 TYPE_OF_MEMORY MemoryType,
496 PCHAR Usage)
497{
498 ULONG_PTR BasePage, PageCount;
499 ULONG i;
500
501 BasePage = BaseAddress / PAGE_SIZE;
503
504 for (i = 0; i < PcMapCount; i++)
505 {
506 /* Check for conflicting descriptor */
507 if ((MemoryMap[i].BasePage < BasePage + PageCount) &&
508 (MemoryMap[i].BasePage + MemoryMap[i].PageCount > BasePage))
509 {
510 /* Check if the memory is free */
511 if (MemoryMap[i].MemoryType != LoaderFree)
512 {
515 __FILE__,
516 __LINE__,
517 "Failed to reserve memory in the range 0x%Ix - 0x%Ix for %s",
519 Size,
520 Usage);
521 }
522 }
523 }
524
525 /* Add the memory descriptor */
528 BasePage,
529 PageCount,
530 MemoryType);
531}
532
533VOID
537 SIZE_T Size,
538 TYPE_OF_MEMORY MemoryType)
539{
540 ULONG_PTR BasePage, PageCount;
541
542 BasePage = BaseAddress / PAGE_SIZE;
544
545 /* Add the memory descriptor */
548 BasePage,
549 PageCount,
550 MemoryType);
551}
552
553ULONG
556{
557 ULONG i;
558
559 /* Reserve some static ranges for freeldr */
560 ReserveMemory(MemoryMap, 0x1000, STACKLOW - 0x1000, LoaderFirmwareTemporary, "BIOS area");
563
564 /* Default to 1 page above freeldr for the disk read buffer */
567
568 /* Scan for free range above freeldr image */
569 for (i = 0; i < PcMapCount; i++)
570 {
571 if ((MemoryMap[i].BasePage > (FREELDR_BASE / PAGE_SIZE)) &&
572 (MemoryMap[i].MemoryType == LoaderFree))
573 {
574 /* Use this range for the disk read buffer */
575 DiskReadBuffer = (PVOID)(MemoryMap[i].BasePage * PAGE_SIZE);
578 break;
579 }
580 }
581
582 TRACE("DiskReadBuffer=0x%p, DiskReadBufferSize=0x%lx\n",
584
586
587 /* Now reserve the range for the disk read buffer */
592 "Disk read buffer");
593
594 TRACE("Dumping resulting memory map:\n");
595 for (i = 0; i < PcMapCount; i++)
596 {
597 TRACE("BasePage=0x%lx, PageCount=0x%lx, Type=%s\n",
598 MemoryMap[i].BasePage,
599 MemoryMap[i].PageCount,
601 }
602 return PcMapCount;
603}
604
605/* FIXME: Abstract things better so we don't need to place define here */
606#if !defined(SARCH_XBOX) && !defined(SARCH_PC98)
607
610{
611 ULONG EntryCount;
612 ULONG ExtendedMemorySizeAtOneMB;
613 ULONG ExtendedMemorySizeAtSixteenMB;
614 ULONG EbdaBase, EbdaSize;
615
616 TRACE("PcMemGetMemoryMap()\n");
617
619
621
622 /* If the BIOS didn't provide a memory map, synthesize one */
623 if (EntryCount == 0)
624 {
625 GetExtendedMemoryConfiguration(&ExtendedMemorySizeAtOneMB,
626 &ExtendedMemorySizeAtSixteenMB);
627
628 /* Conventional memory */
631 0,
633 LoaderFree);
634
635 /* Extended memory */
638 1024 * 1024 / PAGE_SIZE,
639 ExtendedMemorySizeAtOneMB * 1024 / PAGE_SIZE,
640 LoaderFree);
641
642 if (ExtendedMemorySizeAtSixteenMB != 0)
643 {
644 /* Extended memory at 16MB */
647 0x1000000 / PAGE_SIZE,
648 ExtendedMemorySizeAtSixteenMB * 64 * 1024 / PAGE_SIZE,
649 LoaderFree);
650 }
651
652 /* Check if we have an EBDA and get it's location */
653 if (GetEbdaLocation(&EbdaBase, &EbdaSize))
654 {
655 /* Add the descriptor */
658 (EbdaBase / PAGE_SIZE),
659 ADDRESS_AND_SIZE_TO_SPAN_PAGES(EbdaBase, EbdaSize),
661 }
662 }
663
664 /* Setup some protected ranges */
665 SetMemory(PcMemoryMap, 0x000000, 0x01000, LoaderFirmwarePermanent); // Realmode IVT / BDA
666 SetMemory(PcMemoryMap, 0x0A0000, 0x50000, LoaderFirmwarePermanent); // Video memory
667 SetMemory(PcMemoryMap, 0x0F0000, 0x10000, LoaderSpecialMemory); // ROM
668 SetMemory(PcMemoryMap, 0xFFF000, 0x01000, LoaderSpecialMemory); // unusable memory (do we really need this?)
669
670 *MemoryMapSize = PcMemFinalizeMemoryMap(PcMemoryMap);
671 return PcMemoryMap;
672}
673
674#endif // !SARCH_XBOX && !SARCH_PC98
675
676/* EOF */
#define ALIGN_UP_BY(size, align)
ULONG_PTR PFN_NUMBER
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
DECLSPEC_NORETURN VOID FrLdrBugCheckWithMessage(ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
Definition: debug.c:29
#define DiskReadBuffer
Definition: hardware.h:33
#define FREELDR_BASE
Definition: hardware.h:18
@ MEMORY_INIT_FAILURE
Definition: debug.h:148
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
SIZE_T FrLdrImageSize
Definition: meminit.c:35
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define PAGE_SIZE
Definition: env_spec_w32.h:49
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
Definition: glfuncs.h:248
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
SIZE_T DiskReadBufferSize
Definition: hwdisk.c:51
PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type)
Definition: meminit.c:115
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
#define EFLAGS_CF
Definition: ketypes.h:193
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ BiosMemoryUsable
Definition: osloader.h:22
@ BiosMemoryReserved
Definition: osloader.h:25
struct BIOS_MEMORY_MAP * PBIOS_MEMORY_MAP
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define INT386_SUCCESS(regs)
Definition: pcbios.h:181
#define MAX_BIOS_DESCRIPTORS
Definition: pcbios.h:12
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define ULONGLONG_ALIGN_UP_BY(size, align)
Definition: pcmem.c:34
static FREELDR_MEMORY_DESCRIPTOR PcMemoryMap[MAX_BIOS_DESCRIPTORS+1]
Definition: pcmem.c:41
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:609
ULONG PcMemFinalizeMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap)
Definition: pcmem.c:554
ULONG PcBiosMapCount
Definition: pcmem.c:38
static VOID PcMemCheckUsableMemorySize(VOID)
Definition: pcmem.c:214
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS]
Definition: pcmem.c:37
#define ULONGLONG_ALIGN_DOWN_BY(size, align)
Definition: pcmem.c:31
VOID ReserveMemory(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG_PTR BaseAddress, SIZE_T Size, TYPE_OF_MEMORY MemoryType, PCHAR Usage)
Definition: pcmem.c:491
static BOOLEAN GetExtendedMemoryConfiguration(ULONG *pMemoryAtOneMB, ULONG *pMemoryAtSixteenMB)
Definition: pcmem.c:58
static ULONG PcMemGetConventionalMemorySize(VOID)
Definition: pcmem.c:154
ULONG AddMemoryDescriptor(IN OUT PFREELDR_MEMORY_DESCRIPTOR List, IN ULONG MaxCount, IN PFN_NUMBER BasePage, IN PFN_NUMBER PageCount, IN TYPE_OF_MEMORY MemoryType)
Definition: meminit.c:123
ULONG PcMapCount
Definition: pcmem.c:43
static ULONG PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSize)
Definition: pcmem.c:240
VOID SetMemory(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG_PTR BaseAddress, SIZE_T Size, TYPE_OF_MEMORY MemoryType)
Definition: pcmem.c:534
static BOOLEAN GetEbdaLocation(PULONG BaseAddress, PULONG Size)
Definition: pcmem.c:180
@ LoaderFree
Definition: arc.h:295
@ LoaderFirmwareTemporary
Definition: arc.h:298
@ LoaderLoadedProgram
Definition: arc.h:297
@ LoaderFirmwarePermanent
Definition: arc.h:299
@ LoaderOsloaderStack
Definition: arc.h:301
@ LoaderSpecialMemory
Definition: arc.h:315
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
#define TRACE(s)
Definition: solgame.cpp:4
LONGLONG BaseAddress
Definition: osloader.h:33
LONGLONG Length
Definition: osloader.h:34
ULONG ErrorLog
Definition: pcbios.h:62
unsigned char ah
Definition: pcbios.h:134
unsigned long ebx
Definition: pcbios.h:94
unsigned long eflags
Definition: pcbios.h:107
unsigned long edx
Definition: pcbios.h:96
unsigned long eax
Definition: pcbios.h:93
unsigned long ecx
Definition: pcbios.h:95
unsigned short es
Definition: pcbios.h:123
unsigned short di
Definition: pcbios.h:119
unsigned short cx
Definition: pcbios.h:115
unsigned short dx
Definition: pcbios.h:116
unsigned short bx
Definition: pcbios.h:114
unsigned short ax
Definition: pcbios.h:113
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
Definition: pcbios.h:161
DWORDREGS x
Definition: pcbios.h:162
BYTEREGS b
Definition: pcbios.h:165
WORDREGS w
Definition: pcbios.h:164
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4445
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define STACKLOW
Definition: x86common.h:15
#define STACKADDR
Definition: x86common.h:16
#define MAX_DISKREADBUFFER_SIZE
Definition: x86common.h:33
#define BIOSCALLBUFSEGMENT
Definition: x86common.h:24
#define BIOSCALLBUFOFFSET
Definition: x86common.h:25
#define BIOSCALLBUFFER
Definition: x86common.h:12
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)