ReactOS
0.4.16-dev-340-g0540c21
conversion.c
Go to the documentation of this file.
1
/*
2
* PROJECT: EFI Windows Loader
3
* LICENSE: GPL - See COPYING in the top level directory
4
* FILE: boot/freeldr/freeldr/windows/conversion.c
5
* PURPOSE: Physical <-> Virtual addressing mode conversions
6
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
7
*/
8
9
/* INCLUDES ***************************************************************/
10
11
#include <
freeldr.h
>
12
13
//#include <ndk/ldrtypes.h>
14
#include <debug.h>
15
16
DBG_DEFAULT_CHANNEL
(WINDOWS);
17
18
/* FUNCTIONS **************************************************************/
19
20
VOID
21
List_PaToVa
(
_In_
PLIST_ENTRY
ListHeadPa)
22
{
23
PLIST_ENTRY
EntryPa, NextPa;
24
25
/* List must be properly initialized */
26
ASSERT
(ListHeadPa->Flink != 0);
27
ASSERT
(ListHeadPa->Blink != 0);
28
29
/* Loop the list in physical address space */
30
EntryPa = ListHeadPa->
Flink
;
31
while
(EntryPa != ListHeadPa)
32
{
33
/* Save the physical address of the next entry */
34
NextPa = EntryPa->
Flink
;
35
36
/* Convert the addresses of this entry */
37
EntryPa->
Flink
=
PaToVa
(EntryPa->
Flink
);
38
EntryPa->
Blink
=
PaToVa
(EntryPa->
Blink
);
39
40
/* Go to the next entry */
41
EntryPa = NextPa;
42
}
43
44
/* Finally convert the list head */
45
ListHeadPa->
Flink
=
PaToVa
(ListHeadPa->Flink);
46
ListHeadPa->Blink =
PaToVa
(ListHeadPa->Blink);
47
}
48
49
// This function converts only Child->Child, and calls itself for each Sibling
50
VOID
51
ConvertConfigToVA
(
PCONFIGURATION_COMPONENT_DATA
Start
)
52
{
53
PCONFIGURATION_COMPONENT_DATA
Child
;
54
PCONFIGURATION_COMPONENT_DATA
Sibling;
55
56
TRACE
(
"ConvertConfigToVA(Start 0x%X)\n"
,
Start
);
57
Child
=
Start
;
58
59
while
(
Child
!=
NULL
)
60
{
61
if
(
Child
->ConfigurationData)
62
Child
->ConfigurationData =
PaToVa
(
Child
->ConfigurationData);
63
64
if
(
Child
->Child)
65
Child
->Child =
PaToVa
(
Child
->Child);
66
67
if
(
Child
->Parent)
68
Child
->Parent =
PaToVa
(
Child
->Parent);
69
70
if
(
Child
->Sibling)
71
Child
->Sibling =
PaToVa
(
Child
->Sibling);
72
73
if
(
Child
->ComponentEntry.Identifier)
74
Child
->ComponentEntry.Identifier =
PaToVa
(
Child
->ComponentEntry.Identifier);
75
76
TRACE
(
"Device 0x%X class %d type %d id '%s', parent %p\n"
,
Child
,
77
Child
->ComponentEntry.Class,
Child
->ComponentEntry.Type,
VaToPa
(
Child
->ComponentEntry.Identifier),
Child
->Parent);
78
79
// Go through siblings list
80
Sibling =
VaToPa
(
Child
->Sibling);
81
while
(Sibling !=
NULL
)
82
{
83
if
(Sibling->
ConfigurationData
)
84
Sibling->
ConfigurationData
=
PaToVa
(Sibling->
ConfigurationData
);
85
86
if
(Sibling->
Child
)
87
Sibling->
Child
=
PaToVa
(Sibling->
Child
);
88
89
if
(Sibling->
Parent
)
90
Sibling->
Parent
=
PaToVa
(Sibling->
Parent
);
91
92
if
(Sibling->
Sibling
)
93
Sibling->
Sibling
=
PaToVa
(Sibling->
Sibling
);
94
95
if
(Sibling->
ComponentEntry
.
Identifier
)
96
Sibling->
ComponentEntry
.
Identifier
=
PaToVa
(Sibling->
ComponentEntry
.
Identifier
);
97
98
TRACE
(
"Device 0x%X class %d type %d id '%s', parent %p\n"
, Sibling,
99
Sibling->
ComponentEntry
.
Class
, Sibling->
ComponentEntry
.
Type
,
VaToPa
(Sibling->
ComponentEntry
.
Identifier
), Sibling->
Parent
);
100
101
// Recurse into the Child tree
102
if
(
VaToPa
(Sibling->
Child
) !=
NULL
)
103
ConvertConfigToVA
(
VaToPa
(Sibling->
Child
));
104
105
Sibling =
VaToPa
(Sibling->
Sibling
);
106
}
107
108
// Go to the next child
109
Child
=
VaToPa
(
Child
->Child);
110
}
111
}
DBG_DEFAULT_CHANNEL
#define DBG_DEFAULT_CHANNEL(ch)
Definition:
debug.h:106
ConvertConfigToVA
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition:
conversion.c:51
List_PaToVa
VOID List_PaToVa(_In_ PLIST_ENTRY ListHeadPa)
Definition:
conversion.c:21
VaToPa
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition:
conversion.h:15
PaToVa
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition:
conversion.h:22
NULL
#define NULL
Definition:
types.h:112
freeldr.h
Start
return pTarget Start()
void
Definition:
nsiface.idl:2307
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
_In_
#define _In_
Definition:
no_sal2.h:158
TRACE
#define TRACE(s)
Definition:
solgame.cpp:4
_CONFIGURATION_COMPONENT_DATA
Definition:
arc.h:164
_CONFIGURATION_COMPONENT_DATA::ComponentEntry
CONFIGURATION_COMPONENT ComponentEntry
Definition:
arc.h:168
_CONFIGURATION_COMPONENT_DATA::Sibling
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition:
arc.h:167
_CONFIGURATION_COMPONENT_DATA::Child
struct _CONFIGURATION_COMPONENT_DATA * Child
Definition:
arc.h:166
_CONFIGURATION_COMPONENT_DATA::Parent
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition:
arc.h:165
_CONFIGURATION_COMPONENT_DATA::ConfigurationData
PVOID ConfigurationData
Definition:
arc.h:169
_CONFIGURATION_COMPONENT::Type
CONFIGURATION_TYPE Type
Definition:
arc.h:152
_CONFIGURATION_COMPONENT::Identifier
PCHAR Identifier
Definition:
arc.h:160
_CONFIGURATION_COMPONENT::Class
CONFIGURATION_CLASS Class
Definition:
arc.h:151
_LIST_ENTRY
Definition:
typedefs.h:120
_LIST_ENTRY::Blink
struct _LIST_ENTRY * Blink
Definition:
typedefs.h:122
_LIST_ENTRY::Flink
struct _LIST_ENTRY * Flink
Definition:
typedefs.h:121
Child
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition:
wdffdo.h:536
boot
freeldr
freeldr
ntldr
conversion.c
Generated on Thu Dec 12 2024 06:02:32 for ReactOS by
1.9.6