Hopefully create a branch and not destroy the svn repository.
[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 XIPpFindMemoryDescriptor(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
21 {
22 PLIST_ENTRY NextEntry;
23 PMEMORY_ALLOCATION_DESCRIPTOR Descriptor = NULL;
24
25 /* Loop the memory descriptors */
26 for (NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
27 NextEntry != &LoaderBlock->MemoryDescriptorListHead;
28 NextEntry = NextEntry->Flink)
29 {
30 /* Get the current descriptor and check if it's the XIP ROM */
31 Descriptor = CONTAINING_RECORD(NextEntry,
32 MEMORY_ALLOCATION_DESCRIPTOR,
33 ListEntry);
34 if (Descriptor->MemoryType == LoaderXIPRom) return Descriptor;
35 }
36
37 /* Nothing found if we got here */
38 return NULL;
39 }
40
41 VOID
42 NTAPI
43 XIPInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
44 {
45 PCHAR CommandLine, XipBoot, XipRom, XipMegs, XipVerbose, XipRam;
46 PMEMORY_ALLOCATION_DESCRIPTOR XipDescriptor;
47
48 /* Get the command line */
49 CommandLine = LoaderBlock->LoadOptions;
50 if (!CommandLine) return;
51
52 /* Get XIP settings */
53 XipBoot = strstr(CommandLine, "XIPBOOT");
54 XipRam = strstr(CommandLine, "XIPRAM=");
55 XipRom = strstr(CommandLine, "XIPROM=");
56 XipMegs = strstr(CommandLine, "XIPMEGS=");
57 XipVerbose = strstr(CommandLine, "XIPVERBOSE");
58
59 /* Check if this is a verbose boot */
60 if (XipVerbose)
61 {
62 /* Print out our header */
63 DbgPrint("\n\nXIP: debug timestamp at line %d in %s: <<<%s %s>>>\n\n",
64 __LINE__,
65 __FILE__,
66 __DATE__,
67 __TIME__);
68 }
69
70 /* Find the XIP memory descriptor */
71 XipDescriptor = XIPpFindMemoryDescriptor(LoaderBlock);
72 if (!XipDescriptor) return;
73
74 //
75 // Make sure this is really XIP, and not RAM Disk -- also validate XIP
76 // Basically, either this is a ROM boot or a RAM boot, but not both nor none
77 //
78 if (!((ULONG_PTR)XipRom ^ (ULONG_PTR)XipRam)) return;
79
80 /* FIXME: TODO */
81 DPRINT1("ReactOS does not yet support eXecute In Place boot technology\n");
82 }
83
84 /* EOF */