2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ke/freeldr.c
5 * PURPOSE: FreeLDR Bootstrap Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES *****************************************************************/
16 #include <ppcmmu/mmu.h>
17 #define KERNEL_RVA(x) RVA(x,0x80800000)
18 #define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x + KernelBase) >> PAGE_SHIFT)
20 #define KERNEL_RVA(x) RVA(x,KSEG0_BASE)
21 #define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x &~ KSEG0_BASE) >> PAGE_SHIFT)
24 typedef struct _BIOS_MEMORY_DESCRIPTOR
28 } BIOS_MEMORY_DESCRIPTOR
, *PBIOS_MEMORY_DESCRIPTOR
;
30 /* GLOBALS *******************************************************************/
32 /* FreeLDR Loader Data */
33 PROS_LOADER_PARAMETER_BLOCK KeRosLoaderBlock
;
34 BOOLEAN AcpiTableDetected
= FALSE
;
35 ADDRESS_RANGE KeMemoryMap
[64];
36 ULONG KeMemoryMapRangeCount
;
38 /* NT Loader Module/Descriptor Count */
42 /* NT Loader Data. Eats up about 100KB! */
43 LOADER_PARAMETER_BLOCK BldrLoaderBlock
; // 0x0000
44 LOADER_PARAMETER_EXTENSION BldrExtensionBlock
; // 0x0060
45 CHAR BldrCommandLine
[256]; // 0x00DC
46 CHAR BldrArcBootPath
[64]; // 0x01DC
47 CHAR BldrArcHalPath
[64]; // 0x021C
48 CHAR BldrNtHalPath
[64]; // 0x025C
49 CHAR BldrNtBootPath
[64]; // 0x029C
50 LDR_DATA_TABLE_ENTRY BldrModules
[64]; // 0x02DC
51 MEMORY_ALLOCATION_DESCRIPTOR BldrMemoryDescriptors
[60]; // 0x14DC
52 WCHAR BldrModuleStrings
[64][260]; // 0x19DC
53 WCHAR BldrModuleStringsFull
[64][260]; // 0x9BDC
54 NLS_DATA_BLOCK BldrNlsDataBlock
; // 0x11DDC
55 SETUP_LOADER_BLOCK BldrSetupBlock
; // 0x11DE8
56 ARC_DISK_INFORMATION BldrArcDiskInfo
; // 0x12134
57 CHAR BldrArcNames
[32][256]; // 0x1213C
58 ARC_DISK_SIGNATURE BldrDiskInfo
[32]; // 0x1413C
59 CHAR BldrArcHwBuffer
[16 * 1024]; // 0x1843C
62 BIOS_MEMORY_DESCRIPTOR BiosMemoryDescriptors
[16] = {{0}};
63 PBIOS_MEMORY_DESCRIPTOR BiosMemoryDescriptorList
= BiosMemoryDescriptors
;
66 ULONG NumberDescriptors
= 0;
67 MEMORY_DESCRIPTOR MDArray
[60] = {{0}};
69 /* FUNCTIONS *****************************************************************/
71 PMEMORY_ALLOCATION_DESCRIPTOR
73 KiRosGetMdFromArray(VOID
)
75 /* Return the next MD from the list, but make sure we don't overflow */
76 if (BldrCurrentMd
> 60) ASSERT(FALSE
);
77 return &BldrMemoryDescriptors
[BldrCurrentMd
++];
82 KiRosAddBiosBlock(ULONG Address
,
85 PBIOS_MEMORY_DESCRIPTOR BiosBlock
= BiosMemoryDescriptorList
;
87 /* Loop our BIOS Memory Descriptor List */
88 while (BiosBlock
->BlockSize
> 0)
90 /* Check if we've found a matching head block */
91 if (Address
+ Size
== BiosBlock
->BlockBase
)
93 /* Simply enlarge and rebase it */
94 BiosBlock
->BlockBase
= Address
;
95 BiosBlock
->BlockSize
+= Size
;
99 /* Check if we've found a matching tail block */
100 if (Address
== (BiosBlock
->BlockBase
+ BiosBlock
->BlockSize
))
102 /* Simply enlarge it */
103 BiosBlock
->BlockSize
+= Size
;
107 /* Nothing suitable found, try the next block */
111 /* No usable blocks found, found a free block instead */
112 if (!BiosBlock
->BlockSize
)
115 BiosBlock
->BlockBase
= Address
;
116 BiosBlock
->BlockSize
= Size
;
118 /* Create a new block and mark it as the end of the array */
120 BiosBlock
->BlockBase
= BiosBlock
->BlockSize
= 0L;
126 KiRosBuildBiosMemoryMap(VOID
)
128 ULONG BlockBegin
, BlockEnd
;
131 /* Loop the BIOS Memory Map */
132 for (j
= 0; j
< KeMemoryMapRangeCount
; j
++)
134 /* Get the start and end addresses */
135 BlockBegin
= KeMemoryMap
[j
].BaseAddrLow
;
136 BlockEnd
= KeMemoryMap
[j
].BaseAddrLow
+ KeMemoryMap
[j
].LengthLow
- 1;
138 /* Make sure this isn't a > 4GB descriptor */
139 if (!KeMemoryMap
[j
].BaseAddrHigh
)
141 /* Make sure we don't overflow */
142 if (BlockEnd
< BlockBegin
) BlockEnd
= 0xFFFFFFFF;
144 /* Check if this is free memory */
145 if (KeMemoryMap
[j
].Type
== 1)
147 /* Add it to our BIOS descriptors */
148 KiRosAddBiosBlock(BlockBegin
, BlockEnd
- BlockBegin
+ 1);
156 KiRosAllocateArcDescriptor(IN ULONG PageBegin
,
158 IN MEMORY_TYPE MemoryType
)
162 /* Loop all our descriptors */
163 for (i
= 0; i
< NumberDescriptors
; i
++)
165 /* Attempt to fing a free block that describes our region */
166 if ((MDArray
[i
].MemoryType
== MemoryFree
) &&
167 (MDArray
[i
].BasePage
<= PageBegin
) &&
168 (MDArray
[i
].BasePage
+ MDArray
[i
].PageCount
> PageBegin
) &&
169 (MDArray
[i
].BasePage
+ MDArray
[i
].PageCount
>= PageEnd
))
176 /* Check if we found no free blocks, and fail if so */
177 if (i
== NumberDescriptors
) return ENOMEM
;
179 /* Check if the block has our base address */
180 if (MDArray
[i
].BasePage
== PageBegin
)
182 /* Check if it also has our ending address */
183 if ((MDArray
[i
].BasePage
+ MDArray
[i
].PageCount
) == PageEnd
)
185 /* Then convert this region into our new memory type */
186 MDArray
[i
].MemoryType
= MemoryType
;
190 /* Otherwise, make sure we have enough descriptors */
191 if (NumberDescriptors
== 60) return ENOMEM
;
193 /* Cut this descriptor short */
194 MDArray
[i
].BasePage
= PageEnd
;
195 MDArray
[i
].PageCount
-= (PageEnd
- PageBegin
);
197 /* And allocate a new descriptor for our memory range */
198 MDArray
[NumberDescriptors
].BasePage
= PageBegin
;
199 MDArray
[NumberDescriptors
].PageCount
= PageEnd
- PageBegin
;
200 MDArray
[NumberDescriptors
].MemoryType
= MemoryType
;
204 else if ((MDArray
[i
].BasePage
+ MDArray
[i
].PageCount
) == PageEnd
)
206 /* This block has our end address, make sure we have a free block */
207 if (NumberDescriptors
== 60) return ENOMEM
;
209 /* Rebase this descriptor */
210 MDArray
[i
].PageCount
= PageBegin
- MDArray
[i
].BasePage
;
212 /* And allocate a new descriptor for our memory range */
213 MDArray
[NumberDescriptors
].BasePage
= PageBegin
;
214 MDArray
[NumberDescriptors
].PageCount
= PageEnd
- PageBegin
;
215 MDArray
[NumberDescriptors
].MemoryType
= MemoryType
;
220 /* We'll need two descriptors, make sure they're available */
221 if ((NumberDescriptors
+ 1) >= 60) return ENOMEM
;
223 /* Allocate a free memory descriptor for what follows us */
224 MDArray
[NumberDescriptors
].BasePage
= PageEnd
;
225 MDArray
[NumberDescriptors
].PageCount
= MDArray
[i
].PageCount
-
226 (PageEnd
- MDArray
[i
].BasePage
);
227 MDArray
[NumberDescriptors
].MemoryType
= MemoryFree
;
230 /* Cut down the current free descriptor */
231 MDArray
[i
].PageCount
= PageBegin
- MDArray
[i
].BasePage
;
233 /* Allocate a new memory descriptor for our memory range */
234 MDArray
[NumberDescriptors
].BasePage
= PageBegin
;
235 MDArray
[NumberDescriptors
].PageCount
= PageEnd
- PageBegin
;
236 MDArray
[NumberDescriptors
].MemoryType
= MemoryType
;
240 /* Everything went well */
241 return STATUS_SUCCESS
;
246 KiRosConfigureArcDescriptor(IN ULONG PageBegin
,
248 IN TYPE_OF_MEMORY MemoryType
)
251 ULONG BlockBegin
, BlockEnd
;
252 MEMORY_TYPE BlockType
;
253 BOOLEAN Combined
= FALSE
;
255 /* If this descriptor seems bogus, just return */
256 if (PageEnd
<= PageBegin
) return STATUS_SUCCESS
;
258 /* Loop every ARC descriptor, trying to find one we can modify */
259 for (i
= 0; i
< NumberDescriptors
; i
++)
261 /* Get its settings */
262 BlockBegin
= MDArray
[i
].BasePage
;
263 BlockEnd
= MDArray
[i
].BasePage
+ MDArray
[i
].PageCount
;
264 BlockType
= MDArray
[i
].MemoryType
;
266 /* Check if we can fit inside this block */
267 if (BlockBegin
< PageBegin
)
269 /* Check if we are larger then it */
270 if ((BlockEnd
> PageBegin
) && (BlockEnd
<= PageEnd
))
272 /* Make it end where we start */
273 BlockEnd
= PageBegin
;
276 /* Check if it ends after we do */
277 if (BlockEnd
> PageEnd
)
279 /* Make sure we can allocate a descriptor */
280 if (NumberDescriptors
== 60) return ENOMEM
;
282 /* Create a descriptor for whatever memory we're not part of */
283 MDArray
[NumberDescriptors
].MemoryType
= BlockType
;
284 MDArray
[NumberDescriptors
].BasePage
= PageEnd
;
285 MDArray
[NumberDescriptors
].PageCount
= BlockEnd
- PageEnd
;
288 /* The next block ending is now where we begin */
289 BlockEnd
= PageBegin
;
294 /* Check if the blog begins inside our range */
295 if (BlockBegin
< PageEnd
)
297 /* Check if it ends before we do */
298 if (BlockEnd
< PageEnd
)
300 /* Then make it disappear */
301 BlockEnd
= BlockBegin
;
305 /* Otherwise make it start where we end */
306 BlockBegin
= PageEnd
;
311 /* Check if the block matches us, and we haven't tried combining yet */
312 if ((BlockType
== MemoryType
) && !(Combined
))
314 /* Check if it starts where we end */
315 if (BlockBegin
== PageEnd
)
317 /* Make it start with us, and combine us */
318 BlockBegin
= PageBegin
;
321 else if (BlockEnd
== PageBegin
)
323 /* Otherwise, it ends where we begin, combine its ending */
329 /* Check the original block data matches with what we came up with */
330 if ((MDArray
[i
].BasePage
== BlockBegin
) &&
331 (MDArray
[i
].PageCount
== BlockEnd
- BlockBegin
))
337 /* Otherwise, set our new settings for this block */
338 MDArray
[i
].BasePage
= BlockBegin
;
339 MDArray
[i
].PageCount
= BlockEnd
- BlockBegin
;
341 /* Check if we are killing the block */
342 if (BlockBegin
== BlockEnd
)
344 /* Delete this block and restart the loop properly */
346 if (i
< NumberDescriptors
) MDArray
[i
] = MDArray
[NumberDescriptors
];
351 /* If we got here without combining, we need to allocate a new block */
352 if (!(Combined
) && (MemoryType
< LoaderMaximum
))
354 /* Make sure there's enough descriptors */
355 if (NumberDescriptors
== 60) return ENOMEM
;
357 /* Allocate a new block with our data */
358 MDArray
[NumberDescriptors
].MemoryType
= MemoryType
;
359 MDArray
[NumberDescriptors
].BasePage
= PageBegin
;
360 MDArray
[NumberDescriptors
].PageCount
= PageEnd
- PageBegin
;
364 /* Changes complete, return success */
365 return STATUS_SUCCESS
;
370 KiRosBuildOsMemoryMap(VOID
)
372 PBIOS_MEMORY_DESCRIPTOR MdBlock
;
373 ULONG BlockStart
, BlockEnd
, BiasedStart
, BiasedEnd
, PageStart
, PageEnd
;
374 NTSTATUS Status
= STATUS_SUCCESS
;
375 ULONG BiosPage
= 0xA0;
377 /* Loop the BIOS Memory Descriptor List */
378 MdBlock
= BiosMemoryDescriptorList
;
379 while (MdBlock
->BlockSize
)
381 /* Get the statrt and end addresses */
382 BlockStart
= MdBlock
->BlockBase
;
383 BlockEnd
= BlockStart
+ MdBlock
->BlockSize
- 1;
385 /* Align them to page boundaries */
386 BiasedStart
= BlockStart
& (PAGE_SIZE
- 1);
387 if (BiasedStart
) BlockStart
= BlockStart
+ PAGE_SIZE
- BiasedStart
;
388 BiasedEnd
= (BlockEnd
+ 1) & (ULONG
)(PAGE_SIZE
- 1);
389 if (BiasedEnd
) BlockEnd
-= BiasedEnd
;
391 /* Get the actual page numbers */
392 PageStart
= BlockStart
>> PAGE_SHIFT
;
393 PageEnd
= (BlockEnd
+ 1) >> PAGE_SHIFT
;
395 /* If we're starting at page 0, then put the BIOS page at the end */
396 if (!PageStart
) BiosPage
= PageEnd
;
398 /* Check if we did any alignment */
401 /* Mark that region as reserved */
402 Status
= KiRosConfigureArcDescriptor(PageStart
- 1,
404 MemorySpecialMemory
);
405 if (Status
!= STATUS_SUCCESS
) break;
408 /* Check if we did any alignment */
411 /* Mark that region as reserved */
412 Status
= KiRosConfigureArcDescriptor(PageEnd
- 1,
414 MemorySpecialMemory
);
415 if (Status
!= STATUS_SUCCESS
) break;
417 /* If the bios page was the last page, use the next one instead */
418 if (BiosPage
== PageEnd
) BiosPage
+= 1;
421 /* Check if the page is below the 16MB Memory hole */
422 if (PageEnd
<= 0xFC0)
424 /* It is, mark the memory a free */
425 Status
= KiRosConfigureArcDescriptor(PageStart
,
429 else if (PageStart
>= 0x1000)
431 /* It's over 16MB, so that memory gets marked as reserve */
432 Status
= KiRosConfigureArcDescriptor(PageStart
,
438 /* Check if it starts below the memory hole */
439 if (PageStart
< 0xFC0)
441 /* Mark that part as free */
442 Status
= KiRosConfigureArcDescriptor(PageStart
,
445 if (Status
!= STATUS_SUCCESS
) break;
447 /* And update the page start for the code below */
451 /* Any code in the memory hole region ends up as reserve */
452 Status
= KiRosConfigureArcDescriptor(PageStart
,
457 /* If we failed, break out, otherwise, go to the next BIOS block */
458 if (Status
!= STATUS_SUCCESS
) break;
462 /* If anything failed until now, return error code */
463 if (Status
!= STATUS_SUCCESS
) return Status
;
466 /* Set the top 16MB region as reserved */
467 Status
= KiRosConfigureArcDescriptor(0xFC0, 0x1000, MemorySpecialMemory
);
468 if (Status
!= STATUS_SUCCESS
) return Status
;
470 /* Setup the BIOS region as reserved */
471 KiRosConfigureArcDescriptor(0xA0, 0x100, LoaderMaximum
);
472 KiRosConfigureArcDescriptor(BiosPage
, 0x100, MemoryFirmwarePermanent
);
474 /* Build an entry for the IVT */
475 Status
= KiRosAllocateArcDescriptor(0, 1, MemoryFirmwarePermanent
);
476 if (Status
!= STATUS_SUCCESS
) return Status
;
479 /* Build an entry for the KPCR and KUSER_SHARED_DATA */
480 Status
= KiRosAllocateArcDescriptor(1, 3, LoaderStartupPcrPage
);
481 if (Status
!= STATUS_SUCCESS
) return Status
;
483 /* Build an entry for the PDE and return the status */
484 Status
= KiRosAllocateArcDescriptor(KeRosLoaderBlock
->
485 PageDirectoryStart
>> PAGE_SHIFT
,
487 PageDirectoryEnd
>> PAGE_SHIFT
,
494 KiRosBuildReservedMemoryMap(VOID
)
497 ULONG BlockBegin
, BlockEnd
, BiasedPage
;
499 /* Loop the BIOS Memory Map */
500 for (j
= 0; j
< KeMemoryMapRangeCount
; j
++)
502 /* Get the start and end addresses */
503 BlockBegin
= KeMemoryMap
[j
].BaseAddrLow
;
504 BlockEnd
= BlockBegin
+ KeMemoryMap
[j
].LengthLow
- 1;
506 /* Make sure it wasn't a > 4GB descriptor */
507 if (!KeMemoryMap
[j
].BaseAddrHigh
)
509 /* Make sure it doesn't overflow */
510 if (BlockEnd
< BlockBegin
) BlockEnd
= 0xFFFFFFFF;
512 /* Check if this was free memory */
513 if (KeMemoryMap
[j
].Type
== 1)
515 /* Get the page-aligned addresses */
516 BiasedPage
= BlockBegin
& (PAGE_SIZE
- 1);
517 BlockBegin
>>= PAGE_SHIFT
;
518 if (BiasedPage
) BlockBegin
++;
519 BlockEnd
= (BlockEnd
>> PAGE_SHIFT
) + 1;
521 /* Check if the block is within the 16MB memory hole */
522 if ((BlockBegin
< 0xFC0) && (BlockEnd
>= 0xFC0))
524 /* Don't allow it to cross this boundary */
528 /* Check if the boundary is across 16MB */
529 if ((BlockEnd
> 0xFFF) && (BlockBegin
<= 0xFFF))
531 /* Don't let it cross */
535 /* Check if the block describes the memory hole */
536 if ((BlockBegin
>= 0xFC0) && (BlockEnd
<= 0xFFF))
538 /* Set this region as temporary */
539 KiRosConfigureArcDescriptor(BlockBegin
,
541 MemoryFirmwareTemporary
);
546 /* Get the page-aligned addresses */
547 BlockBegin
>>= PAGE_SHIFT
;
548 BiasedPage
= (BlockEnd
+ 1) & (PAGE_SIZE
- 1);
549 BlockEnd
>>= PAGE_SHIFT
;
550 if (BiasedPage
) BlockEnd
++;
552 /* Set this memory as reserved */
553 KiRosConfigureArcDescriptor(BlockBegin
,
555 MemorySpecialMemory
);
563 KiRosInsertNtDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor
)
565 PLIST_ENTRY ListHead
, PreviousEntry
, NextEntry
;
566 PMEMORY_ALLOCATION_DESCRIPTOR Descriptor
= NULL
, NextDescriptor
= NULL
;
568 /* Loop the memory descriptor list */
569 ListHead
= &KeLoaderBlock
->MemoryDescriptorListHead
;
570 PreviousEntry
= ListHead
;
571 NextEntry
= ListHead
->Flink
;
572 while (NextEntry
!= ListHead
)
574 /* Get the current descriptor and check if it's below ours */
575 NextDescriptor
= CONTAINING_RECORD(NextEntry
,
576 MEMORY_ALLOCATION_DESCRIPTOR
,
578 if (NewDescriptor
->BasePage
< NextDescriptor
->BasePage
) break;
580 /* It isn't, save the previous entry and descriptor, and try again */
581 PreviousEntry
= NextEntry
;
582 Descriptor
= NextDescriptor
;
583 NextEntry
= NextEntry
->Flink
;
586 /* So we found the right spot to insert. Is this free memory? */
587 if (NewDescriptor
->MemoryType
!= LoaderFree
)
589 /* It isn't, so insert us before the last descriptor */
590 InsertHeadList(PreviousEntry
, &NewDescriptor
->ListEntry
);
594 /* We're free memory. Check if the entry we found is also free memory */
595 if ((PreviousEntry
!= ListHead
) &&
596 ((Descriptor
->MemoryType
== LoaderFree
) ||
597 (Descriptor
->MemoryType
== LoaderReserve
)) &&
598 ((Descriptor
->BasePage
+ Descriptor
->PageCount
) ==
599 NewDescriptor
->BasePage
))
601 /* It's free memory, and we're right after it. Enlarge that block */
602 Descriptor
->PageCount
+= NewDescriptor
->PageCount
;
603 NewDescriptor
= Descriptor
;
607 /* Our range scan't be combined, so just insert us separately */
608 InsertHeadList(PreviousEntry
, &NewDescriptor
->ListEntry
);
611 /* Check if we merged with an existing free memory block */
612 if ((NextEntry
!= ListHead
) &&
613 ((NextDescriptor
->MemoryType
== LoaderFree
) ||
614 (NextDescriptor
->MemoryType
== LoaderReserve
)) &&
615 ((NewDescriptor
->BasePage
+ NewDescriptor
->PageCount
) ==
616 NextDescriptor
->BasePage
))
618 /* Update our own block */
619 NewDescriptor
->PageCount
+= NextDescriptor
->PageCount
;
621 /* Remove the next block */
622 RemoveEntryList(&NextDescriptor
->ListEntry
);
629 KiRosBuildNtDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor
,
630 IN MEMORY_TYPE MemoryType
,
634 PMEMORY_ALLOCATION_DESCRIPTOR Descriptor
, NextDescriptor
= NULL
;
636 TYPE_OF_MEMORY CurrentType
;
639 /* Check how many pages we'll be consuming */
640 Delta
= BasePage
- MemoryDescriptor
->BasePage
;
641 if (!(Delta
) && (PageCount
== MemoryDescriptor
->PageCount
))
643 /* We can simply convert the current descriptor into our new type */
644 MemoryDescriptor
->MemoryType
= MemoryType
;
648 /* Get the current memory type of the descriptor, and reserve it */
649 CurrentType
= MemoryDescriptor
->MemoryType
;
650 MemoryDescriptor
->MemoryType
= LoaderSpecialMemory
;
652 /* Check if we'll need another descriptor for what's left of memory */
653 UseNext
= ((BasePage
!= MemoryDescriptor
->BasePage
) &&
654 (Delta
+ PageCount
!= MemoryDescriptor
->PageCount
));
656 /* Get a descriptor */
657 Descriptor
= KiRosGetMdFromArray();
658 if (!Descriptor
) return STATUS_INSUFFICIENT_RESOURCES
;
660 /* Check if we are using another descriptor */
663 /* Allocate that one too */
664 NextDescriptor
= KiRosGetMdFromArray();
665 if (!NextDescriptor
) return STATUS_INSUFFICIENT_RESOURCES
;
668 /* Build the descriptor we got */
669 Descriptor
->MemoryType
= MemoryType
;
670 Descriptor
->BasePage
= BasePage
;
671 Descriptor
->PageCount
= PageCount
;
673 /* Check if we're starting at the same place as the old one */
674 if (BasePage
== MemoryDescriptor
->BasePage
)
676 /* Simply decrease the old descriptor and rebase it */
677 MemoryDescriptor
->BasePage
+= PageCount
;
678 MemoryDescriptor
->PageCount
-= PageCount
;
679 MemoryDescriptor
->MemoryType
= CurrentType
;
681 else if (Delta
+ PageCount
== MemoryDescriptor
->PageCount
)
683 /* We finish where the old one did, shorten it */
684 MemoryDescriptor
->PageCount
-= PageCount
;
685 MemoryDescriptor
->MemoryType
= CurrentType
;
689 /* We're inside the current block, mark our free region */
690 NextDescriptor
->MemoryType
= LoaderFree
;
691 NextDescriptor
->BasePage
= BasePage
+ PageCount
;
692 NextDescriptor
->PageCount
= MemoryDescriptor
->PageCount
-
695 /* And cut down the current descriptor */
696 MemoryDescriptor
->PageCount
= Delta
;
697 MemoryDescriptor
->MemoryType
= CurrentType
;
699 /* Finally, insert our new free descriptor into the list */
700 KiRosInsertNtDescriptor(NextDescriptor
);
703 /* Insert the descriptor we allocated */
704 KiRosInsertNtDescriptor(Descriptor
);
708 return STATUS_SUCCESS
;
711 PMEMORY_ALLOCATION_DESCRIPTOR
713 KiRosFindNtDescriptor(IN ULONG BasePage
)
715 PMEMORY_ALLOCATION_DESCRIPTOR MdBlock
= NULL
;
716 PLIST_ENTRY NextEntry
, ListHead
;
718 /* Scan the memory descriptor list */
719 ListHead
= &KeLoaderBlock
->MemoryDescriptorListHead
;
720 NextEntry
= ListHead
->Flink
;
721 while (NextEntry
!= ListHead
)
723 /* Get the current descriptor */
724 MdBlock
= CONTAINING_RECORD(NextEntry
,
725 MEMORY_ALLOCATION_DESCRIPTOR
,
728 /* Check if it can contain our memory range */
729 if ((MdBlock
->BasePage
<= BasePage
) &&
730 (MdBlock
->BasePage
+ MdBlock
->PageCount
> BasePage
))
732 /* It can, break out */
736 /* Go to the next descriptor */
737 NextEntry
= NextEntry
->Flink
;
740 /* Return the descriptor we found, if any */
746 KiRosAllocateNtDescriptor(IN TYPE_OF_MEMORY MemoryType
,
750 OUT PULONG ReturnedBase
)
752 PMEMORY_ALLOCATION_DESCRIPTOR MdBlock
;
753 ULONG AlignedBase
, AlignedLimit
;
754 PMEMORY_ALLOCATION_DESCRIPTOR ActiveMdBlock
;
755 ULONG ActiveAlignedBase
= 0;
756 PLIST_ENTRY NextEntry
, ListHead
;
758 /* If no information was given, make some assumptions */
759 if (!Alignment
) Alignment
= 1;
760 if (!PageCount
) PageCount
= 1;
762 /* Start looking for a matching descvriptor */
765 /* Calculate the limit of the range */
766 AlignedLimit
= PageCount
+ BasePage
;
768 /* Find a descriptor that already contains our base address */
769 MdBlock
= KiRosFindNtDescriptor(BasePage
);
773 /* If it contains our limit as well, break out early */
774 if ((MdBlock
->PageCount
+ MdBlock
->BasePage
) >= AlignedLimit
) break;
777 /* Loop the memory list */
778 ActiveMdBlock
= NULL
;
779 ListHead
= &KeLoaderBlock
->MemoryDescriptorListHead
;
780 NextEntry
= ListHead
->Flink
;
781 while (NextEntry
!= ListHead
)
783 /* Get the current descriptors */
784 MdBlock
= CONTAINING_RECORD(NextEntry
,
785 MEMORY_ALLOCATION_DESCRIPTOR
,
788 /* Align the base address and our limit */
789 AlignedBase
= (MdBlock
->BasePage
+ (Alignment
- 1)) &~ Alignment
;
790 AlignedLimit
= MdBlock
->PageCount
-
794 /* Check if this is a free block that can satisfy us */
795 if ((MdBlock
->MemoryType
== LoaderFree
) &&
796 (AlignedLimit
<= MdBlock
->PageCount
) &&
797 (PageCount
<= AlignedLimit
))
799 /* It is, stop searching */
800 ActiveMdBlock
= MdBlock
;
801 ActiveAlignedBase
= AlignedBase
;
805 /* Try the next block */
806 NextEntry
= NextEntry
->Flink
;
809 /* See if we came up with an adequate block */
812 /* Generate a descriptor in it */
813 *ReturnedBase
= AlignedBase
;
814 return KiRosBuildNtDescriptor(ActiveMdBlock
,
821 /* We found a matching block, generate a descriptor with it */
822 *ReturnedBase
= BasePage
;
823 return KiRosBuildNtDescriptor(MdBlock
, MemoryType
, BasePage
, PageCount
);
828 KiRosBuildArcMemoryList(VOID
)
830 PMEMORY_ALLOCATION_DESCRIPTOR Descriptor
;
831 MEMORY_DESCRIPTOR
*Memory
;
834 /* Loop all BIOS Memory Descriptors */
835 for (i
= 0; i
< NumberDescriptors
; i
++)
837 /* Get the current descriptor */
838 Memory
= &MDArray
[i
];
840 /* Allocate an NT Memory Descriptor */
841 Descriptor
= KiRosGetMdFromArray();
842 if (!Descriptor
) return ENOMEM
;
844 /* Copy the memory type */
845 Descriptor
->MemoryType
= Memory
->MemoryType
;
846 if (Memory
->MemoryType
== MemoryFreeContiguous
)
848 /* Convert this to free */
849 Descriptor
->MemoryType
= LoaderFree
;
851 else if (Memory
->MemoryType
== MemorySpecialMemory
)
853 /* Convert this to special memory */
854 Descriptor
->MemoryType
= LoaderSpecialMemory
;
857 /* Copy the range data */
858 Descriptor
->BasePage
= Memory
->BasePage
;
859 Descriptor
->PageCount
= Memory
->PageCount
;
861 /* Insert the descriptor */
862 if (Descriptor
->PageCount
) KiRosInsertNtDescriptor(Descriptor
);
866 return STATUS_SUCCESS
;
871 KiRosFixupComponentTree(IN PCONFIGURATION_COMPONENT_DATA p
,
874 PCONFIGURATION_COMPONENT pp
;
876 /* Loop each entry */
879 /* Grab the component entry */
880 pp
= &p
->ComponentEntry
;
882 /* Fixup the pointers */
883 if (pp
->Identifier
) pp
->Identifier
= (PVOID
)((ULONG_PTR
)pp
->Identifier
+ i
);
884 if (p
->ConfigurationData
) p
->ConfigurationData
= (PVOID
)((ULONG_PTR
)p
->ConfigurationData
+ i
);
885 if (p
->Parent
) p
->Parent
= (PVOID
)((ULONG_PTR
)p
->Parent
+ i
);
886 if (p
->Sibling
) p
->Sibling
= (PVOID
)((ULONG_PTR
)p
->Sibling
+ i
);
887 if (p
->Child
) p
->Child
= (PVOID
)((ULONG_PTR
)p
->Child
+ i
);
889 /* Check if we have a child */
890 if (p
->Child
) KiRosFixupComponentTree(p
->Child
, i
);
892 /* Get to the next entry */
899 KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock
,
900 IN PLOADER_PARAMETER_BLOCK
*NtLoaderBlock
)
902 PLOADER_PARAMETER_BLOCK LoaderBlock
;
903 PLDR_DATA_TABLE_ENTRY LdrEntry
;
904 PLOADER_MODULE RosEntry
= NULL
;
908 PCHAR BootPath
, HalPath
;
909 CHAR CommandLine
[256];
910 PARC_DISK_SIGNATURE RosDiskInfo
, ArcDiskInfo
;
911 PIMAGE_NT_HEADERS NtHeader
;
912 WCHAR PathToDrivers
[] = L
"\\SystemRoot\\System32\\drivers\\";
913 WCHAR PathToSystem32
[] = L
"\\SystemRoot\\System32\\";
914 WCHAR PathSetup
[] = L
"\\SystemRoot\\";
915 CHAR DriverNameLow
[256];
918 ULONG KernelBase
= RosLoaderBlock
->ModsAddr
[0].ModStart
;
921 /* First get some kernel-loader globals */
922 AcpiTableDetected
= (RosLoaderBlock
->Flags
& MB_FLAGS_ACPI_TABLE
) ? TRUE
: FALSE
;
924 /* Set the NT Loader block and initialize it */
925 *NtLoaderBlock
= KeLoaderBlock
= LoaderBlock
= &BldrLoaderBlock
;
926 RtlZeroMemory(LoaderBlock
, sizeof(LOADER_PARAMETER_BLOCK
));
928 /* Set the NLS Data block */
929 LoaderBlock
->NlsData
= &BldrNlsDataBlock
;
931 /* Set the ARC Data block */
932 LoaderBlock
->ArcDiskInformation
= &BldrArcDiskInfo
;
934 /* Assume this is from FreeLDR's SetupLdr */
935 LoaderBlock
->SetupLdrBlock
= &BldrSetupBlock
;
937 /* Setup the list heads */
938 InitializeListHead(&LoaderBlock
->LoadOrderListHead
);
939 InitializeListHead(&LoaderBlock
->MemoryDescriptorListHead
);
940 InitializeListHead(&LoaderBlock
->BootDriverListHead
);
941 InitializeListHead(&LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
);
943 /* Build the free memory map, which uses BIOS Descriptors */
944 KiRosBuildBiosMemoryMap();
946 /* Build entries for ReactOS memory ranges, which uses ARC Descriptors */
947 KiRosBuildOsMemoryMap();
950 /* Build entries for the reserved map, which uses ARC Descriptors */
951 KiRosBuildReservedMemoryMap();
954 /* Now convert the BIOS and ARC Descriptors into NT Memory Descirptors */
955 KiRosBuildArcMemoryList();
957 /* Loop boot driver list */
958 for (i
= 0; i
< RosLoaderBlock
->ModsCount
; i
++)
960 /* Get the ROS loader entry */
961 RosEntry
= &RosLoaderBlock
->ModsAddr
[i
];
962 DriverName
= (PCHAR
)RosEntry
->String
;
963 ModStart
= (PVOID
)RosEntry
->ModStart
;
964 ModSize
= RosEntry
->ModEnd
- (ULONG_PTR
)ModStart
;
967 ModStart
-= KernelBase
;
970 /* Check if this is any of the NLS files */
971 if (!_stricmp(DriverName
, "ansi.nls"))
974 LoaderBlock
->NlsData
->AnsiCodePageData
= KERNEL_RVA(ModStart
);
976 /* Create an MD for it */
977 KiRosAllocateNtDescriptor(LoaderNlsData
,
978 KERNEL_DESCRIPTOR_PAGE(ModStart
),
979 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
984 else if (!_stricmp(DriverName
, "oem.nls"))
987 LoaderBlock
->NlsData
->OemCodePageData
= KERNEL_RVA(ModStart
);
989 /* Create an MD for it */
990 KiRosAllocateNtDescriptor(LoaderNlsData
,
991 KERNEL_DESCRIPTOR_PAGE(ModStart
),
992 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
997 else if (!_stricmp(DriverName
, "casemap.nls"))
999 /* Unicode Code page */
1000 LoaderBlock
->NlsData
->UnicodeCodePageData
= KERNEL_RVA(ModStart
);
1002 /* Create an MD for it */
1003 KiRosAllocateNtDescriptor(LoaderNlsData
,
1004 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1005 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1011 /* Check if this is the SYSTEM hive */
1012 if (!(_stricmp(DriverName
, "system")) ||
1013 !(_stricmp(DriverName
, "system.hiv")))
1015 /* Save registry data */
1016 LoaderBlock
->RegistryBase
= KERNEL_RVA(ModStart
);
1017 LoaderBlock
->RegistryLength
= ModSize
;
1019 /* Disable setup mode */
1020 LoaderBlock
->SetupLdrBlock
= NULL
;
1022 /* Create an MD for it */
1023 KiRosAllocateNtDescriptor(LoaderRegistryData
,
1024 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1025 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1031 /* Check if this is the HARDWARE hive */
1032 if (!(_stricmp(DriverName
, "hardware")) ||
1033 !(_stricmp(DriverName
, "hardware.hiv")))
1035 /* Create an MD for it */
1036 KiRosAllocateNtDescriptor(LoaderRegistryData
,
1037 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1038 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1044 /* Check if this is the kernel */
1045 if (!(_stricmp(DriverName
, "ntoskrnl.exe")))
1047 /* Create an MD for it */
1048 KiRosAllocateNtDescriptor(LoaderSystemCode
,
1049 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1050 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1054 else if (!(_stricmp(DriverName
, "hal.dll")))
1056 /* Create an MD for the HAL */
1057 KiRosAllocateNtDescriptor(LoaderHalCode
,
1058 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1059 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1065 /* Create an MD for any driver */
1066 KiRosAllocateNtDescriptor(LoaderBootDriver
,
1067 KERNEL_DESCRIPTOR_PAGE(ModStart
),
1068 (ModSize
+ PAGE_SIZE
- 1)>> PAGE_SHIFT
,
1074 ModStart
+= 0x80800000;
1077 /* Lowercase the drivername so we can check its extension later */
1078 strcpy(DriverNameLow
, DriverName
);
1079 _strlwr(DriverNameLow
);
1081 /* Setup the loader entry */
1082 LdrEntry
= &BldrModules
[i
];
1083 RtlZeroMemory(LdrEntry
, sizeof(LDR_DATA_TABLE_ENTRY
));
1085 /* Convert driver name from ANSI to Unicode */
1086 for (j
= 0; j
< strlen(DriverName
); j
++)
1088 BldrModuleStrings
[i
][j
] = DriverName
[j
];
1091 /* Setup driver name */
1092 RtlInitUnicodeString(&LdrEntry
->BaseDllName
, BldrModuleStrings
[i
]);
1094 /* Construct a correct full name */
1095 BldrModuleStringsFull
[i
][0] = 0;
1096 LdrEntry
->FullDllName
.MaximumLength
= 260 * sizeof(WCHAR
);
1097 LdrEntry
->FullDllName
.Length
= 0;
1098 LdrEntry
->FullDllName
.Buffer
= BldrModuleStringsFull
[i
];
1100 /* Guess the path */
1101 if (LoaderBlock
->SetupLdrBlock
)
1103 UNICODE_STRING TempString
;
1104 RtlInitUnicodeString(&TempString
, PathSetup
);
1105 RtlAppendUnicodeStringToString(&LdrEntry
->FullDllName
, &TempString
);
1107 else if (strstr(DriverNameLow
, ".dll") || strstr(DriverNameLow
, ".exe"))
1109 UNICODE_STRING TempString
;
1110 RtlInitUnicodeString(&TempString
, PathToSystem32
);
1111 RtlAppendUnicodeStringToString(&LdrEntry
->FullDllName
, &TempString
);
1115 UNICODE_STRING TempString
;
1116 RtlInitUnicodeString(&TempString
, PathToDrivers
);
1117 RtlAppendUnicodeStringToString(&LdrEntry
->FullDllName
, &TempString
);
1120 /* Append base name of the driver */
1121 RtlAppendUnicodeStringToString(&LdrEntry
->FullDllName
, &LdrEntry
->BaseDllName
);
1123 /* Copy data from Freeldr Module Entry */
1124 LdrEntry
->DllBase
= ModStart
;
1125 LdrEntry
->SizeOfImage
= ModSize
;
1127 /* Copy additional data */
1128 NtHeader
= RtlImageNtHeader(ModStart
);
1129 LdrEntry
->EntryPoint
= RVA(ModStart
,
1131 OptionalHeader
.AddressOfEntryPoint
);
1133 /* Initialize other data */
1134 LdrEntry
->LoadCount
= 1;
1135 LdrEntry
->Flags
= LDRP_IMAGE_DLL
|
1136 LDRP_ENTRY_PROCESSED
;
1137 if (RosEntry
->Reserved
) LdrEntry
->Flags
|= LDRP_ENTRY_INSERTED
;
1139 /* Insert it into the loader block */
1140 InsertTailList(&LoaderBlock
->LoadOrderListHead
,
1141 &LdrEntry
->InLoadOrderLinks
);
1144 /* Now mark the remainder of the FreeLDR 6MB area as "in use" */
1145 KiRosAllocateNtDescriptor(LoaderMemoryData
,
1146 KERNEL_DESCRIPTOR_PAGE(RosEntry
->ModEnd
),
1147 KERNEL_DESCRIPTOR_PAGE((0x80800000 + 0x600000)) -
1148 KERNEL_DESCRIPTOR_PAGE(RosEntry
->ModEnd
),
1153 // Check if we have a ramdisk
1155 if ((RosLoaderBlock
->RdAddr
) && (RosLoaderBlock
->RdLength
))
1158 // Build a descriptor for it
1160 KiRosAllocateNtDescriptor(LoaderXIPRom
,
1161 KERNEL_DESCRIPTOR_PAGE(RosLoaderBlock
->RdAddr
),
1162 (RosLoaderBlock
->RdLength
+ PAGE_SIZE
- 1) >> PAGE_SHIFT
,
1167 /* Setup command line */
1168 LoaderBlock
->LoadOptions
= BldrCommandLine
;
1169 strcpy(BldrCommandLine
, RosLoaderBlock
->CommandLine
);
1171 /* Setup the extension block */
1172 LoaderBlock
->Extension
= &BldrExtensionBlock
;
1173 LoaderBlock
->Extension
->Size
= sizeof(LOADER_PARAMETER_EXTENSION
);
1174 LoaderBlock
->Extension
->MajorVersion
= 5;
1175 LoaderBlock
->Extension
->MinorVersion
= 2;
1177 /* FreeLDR hackllocates 1536 static pages for the initial boot images */
1178 LoaderBlock
->Extension
->LoaderPagesSpanned
= 1536 * PAGE_SIZE
;
1180 /* ReactOS always boots the kernel at 0x80800000 (just like NT 5.2) */
1181 LoaderBlock
->Extension
->LoaderPagesSpanned
+= 0x80800000 - KSEG0_BASE
;
1183 /* Now convert to pages */
1184 LoaderBlock
->Extension
->LoaderPagesSpanned
/= PAGE_SIZE
;
1186 /* Now setup the setup block if we have one */
1187 if (LoaderBlock
->SetupLdrBlock
)
1189 /* All we'll setup right now is the flag for text-mode setup */
1190 LoaderBlock
->SetupLdrBlock
->Flags
= SETUPLDR_TEXT_MODE
;
1193 /* Make a copy of the command line */
1194 strcpy(CommandLine
, LoaderBlock
->LoadOptions
);
1196 /* Find the first \, separating the ARC path from NT path */
1197 BootPath
= strchr(CommandLine
, '\\');
1198 *BootPath
= ANSI_NULL
;
1199 strncpy(BldrArcBootPath
, CommandLine
, 63);
1200 LoaderBlock
->ArcBootDeviceName
= BldrArcBootPath
;
1202 /* The rest of the string is the NT path */
1203 HalPath
= strchr(BootPath
+ 1, ' ');
1204 *HalPath
= ANSI_NULL
;
1205 BldrNtBootPath
[0] = '\\';
1206 strncat(BldrNtBootPath
, BootPath
+ 1, 63);
1207 strcat(BldrNtBootPath
,"\\");
1208 LoaderBlock
->NtBootPathName
= BldrNtBootPath
;
1210 /* Set the HAL paths */
1211 strncpy(BldrArcHalPath
, BldrArcBootPath
, 63);
1212 LoaderBlock
->ArcHalDeviceName
= BldrArcHalPath
;
1213 strcpy(BldrNtHalPath
, "\\");
1214 LoaderBlock
->NtHalPathName
= BldrNtHalPath
;
1216 /* Use this new command line */
1217 strncpy(LoaderBlock
->LoadOptions
, HalPath
+ 2, 255);
1219 /* Parse it and change every slash to a space */
1220 BootPath
= LoaderBlock
->LoadOptions
;
1221 do {if (*BootPath
== '/') *BootPath
= ' ';} while (*BootPath
++);
1223 /* Now let's loop ARC disk information */
1224 for (i
= 0; i
< RosLoaderBlock
->DrivesCount
; i
++)
1226 /* Get the ROS loader entry */
1227 RosDiskInfo
= &RosLoaderBlock
->DrivesAddr
[i
];
1229 /* Get the ARC structure */
1230 ArcDiskInfo
= &BldrDiskInfo
[i
];
1232 /* Copy the data over */
1233 ArcDiskInfo
->Signature
= RosDiskInfo
->Signature
;
1234 ArcDiskInfo
->CheckSum
= RosDiskInfo
->CheckSum
;
1236 /* Copy the ARC Name */
1237 strcpy(BldrArcNames
[i
], RosDiskInfo
->ArcName
);
1238 ArcDiskInfo
->ArcName
= BldrArcNames
[i
];
1240 /* Insert into the list */
1241 InsertTailList(&LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
,
1242 &ArcDiskInfo
->ListEntry
);
1245 /* Copy the ARC Hardware Tree */
1246 RtlCopyMemory(BldrArcHwBuffer
, (PVOID
)RosLoaderBlock
->ArchExtra
, 16 * 1024);
1247 LoaderBlock
->ConfigurationRoot
= (PVOID
)BldrArcHwBuffer
;
1250 KiRosFixupComponentTree(LoaderBlock
->ConfigurationRoot
,
1251 (ULONG_PTR
)BldrArcHwBuffer
-
1252 RosLoaderBlock
->ArchExtra
);
1257 KiSetupSyscallHandler();
1261 KiRosPrepareForSystemStartup(IN ULONG Dummy
,
1262 IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock
)
1264 PLOADER_PARAMETER_BLOCK NtLoaderBlock
;
1265 ULONG size
, i
= 0, *ent
;
1266 #if defined(_M_IX86)
1268 PKGDTENTRY TssEntry
;
1270 /* Load the GDT and IDT */
1271 Ke386SetGlobalDescriptorTable(*(PKDESCRIPTOR
)&KiGdtDescriptor
.Limit
);
1272 Ke386SetInterruptDescriptorTable(*(PKDESCRIPTOR
)&KiIdtDescriptor
.Limit
);
1274 /* Initialize the boot TSS */
1276 TssEntry
= &KiBootGdt
[KGDT_TSS
/ sizeof(KGDTENTRY
)];
1277 TssEntry
->HighWord
.Bits
.Type
= I386_TSS
;
1278 TssEntry
->HighWord
.Bits
.Pres
= 1;
1279 TssEntry
->HighWord
.Bits
.Dpl
= 0;
1280 TssEntry
->BaseLow
= (USHORT
)((ULONG_PTR
)Tss
& 0xFFFF);
1281 TssEntry
->HighWord
.Bytes
.BaseMid
= (UCHAR
)((ULONG_PTR
)Tss
>> 16);
1282 TssEntry
->HighWord
.Bytes
.BaseHi
= (UCHAR
)((ULONG_PTR
)Tss
>> 24);
1286 // Zero bats. We might have residual bats set that will interfere with
1287 // our mapping of ofwldr.
1288 for (i
= 0; i
< 4; i
++)
1290 SetBat(i
, 0, 0, 0); SetBat(i
, 1, 0, 0);
1292 KiSetupSyscallHandler();
1293 DbgPrint("Kernel Power (%08x)\n", LoaderBlock
);
1294 DbgPrint("ArchExtra (%08x)!\n", LoaderBlock
->ArchExtra
);
1297 /* Save pointer to ROS Block */
1298 KeRosLoaderBlock
= LoaderBlock
;
1300 /* Save memory manager data */
1301 KeMemoryMapRangeCount
= 0;
1302 if (LoaderBlock
->Flags
& MB_FLAGS_MMAP_INFO
)
1304 /* We have a memory map from the nice BIOS */
1305 ent
= ((PULONG
)(LoaderBlock
->MmapAddr
- sizeof(ULONG
)));
1309 /* Map it until we run out of size */
1310 while (i
< LoaderBlock
->MmapLength
)
1312 /* Copy into the Kernel Memory Map */
1313 memcpy (&KeMemoryMap
[KeMemoryMapRangeCount
],
1314 (PVOID
)(LoaderBlock
->MmapAddr
+ i
),
1315 sizeof(ADDRESS_RANGE
));
1317 /* Increase Memory Map Count */
1318 KeMemoryMapRangeCount
++;
1325 LoaderBlock
->MmapLength
= KeMemoryMapRangeCount
* sizeof(ADDRESS_RANGE
);
1326 LoaderBlock
->MmapAddr
= (ULONG
)KeMemoryMap
;
1330 /* Nothing from BIOS */
1331 LoaderBlock
->MmapLength
= 0;
1332 LoaderBlock
->MmapAddr
= (ULONG
)KeMemoryMap
;
1335 /* Convert the loader block */
1336 KiRosFrldrLpbToNtLpb(KeRosLoaderBlock
, &NtLoaderBlock
);
1339 DbgPrint("Finished KiRosFrldrLpbToNtLpb\n");
1342 /* Do general System Startup */
1343 KiSystemStartupReal(NtLoaderBlock
);