Branching for 0.3.15 release after two days of no response from a certain sphere...
[reactos.git] / ntoskrnl / ex / xipdisp.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ex/xipdisp.c
5 * PURPOSE: eXecute In Place (XIP) Support.
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <ntoskrnl.h>
12 #include <debug.h>
13
14 /* GLOBALS *******************************************************************/
15
16 /* FUNCTIONS *****************************************************************/
17
18 PMEMORY_ALLOCATION_DESCRIPTOR
19 NTAPI
20 INIT_FUNCTION
21 XIPpFindMemoryDescriptor(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
22 {
23 PLIST_ENTRY NextEntry;
24 PMEMORY_ALLOCATION_DESCRIPTOR Descriptor = NULL;
25
26 /* Loop the memory descriptors */
27 for (NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
28 NextEntry != &LoaderBlock->MemoryDescriptorListHead;
29 NextEntry = NextEntry->Flink)
30 {
31 /* Get the current descriptor and check if it's the XIP ROM */
32 Descriptor = CONTAINING_RECORD(NextEntry,
33 MEMORY_ALLOCATION_DESCRIPTOR,
34 ListEntry);
35 if (Descriptor->MemoryType == LoaderXIPRom) return Descriptor;
36 }
37
38 /* Nothing found if we got here */
39 return NULL;
40 }
41
42 VOID
43 NTAPI
44 INIT_FUNCTION
45 XIPInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
46 {
47 PCHAR CommandLine, XipBoot, XipRom, XipMegs, XipVerbose, XipRam;
48 PMEMORY_ALLOCATION_DESCRIPTOR XipDescriptor;
49
50 /* Get the command line */
51 CommandLine = LoaderBlock->LoadOptions;
52 if (!CommandLine) return;
53
54 /* Get XIP settings */
55 XipBoot = strstr(CommandLine, "XIPBOOT");
56 XipRam = strstr(CommandLine, "XIPRAM=");
57 XipRom = strstr(CommandLine, "XIPROM=");
58 XipMegs = strstr(CommandLine, "XIPMEGS=");
59 XipVerbose = strstr(CommandLine, "XIPVERBOSE");
60
61 /* Check if this is a verbose boot */
62 if (XipVerbose)
63 {
64 /* Print out our header */
65 DbgPrint("\n\nXIP: debug timestamp at line %d in %s: <<<%s %s>>>\n\n",
66 __LINE__,
67 __FILE__,
68 __DATE__,
69 __TIME__);
70 }
71
72 /* Find the XIP memory descriptor */
73 XipDescriptor = XIPpFindMemoryDescriptor(LoaderBlock);
74 if (!XipDescriptor) return;
75
76 //
77 // Make sure this is really XIP, and not RAM Disk -- also validate XIP
78 // Basically, either this is a ROM boot or a RAM boot, but not both nor none
79 //
80 if (!((ULONG_PTR)XipRom ^ (ULONG_PTR)XipRam)) return;
81
82 /* FIXME: TODO */
83 DPRINT1("ReactOS does not yet support eXecute In Place boot technology\n");
84 DPRINT("%s MB requested (XIP = %s)\n", XipMegs, XipBoot);
85 }
86
87 /* EOF */