ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

conversion.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         EFI Windows Loader
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            freeldr/winldr/conversion.c
00005  * PURPOSE:         Physical <-> Virtual addressing mode conversions
00006  * PROGRAMMERS:     Aleksey Bragin (aleksey@reactos.org)
00007  */
00008 
00009 /* INCLUDES ***************************************************************/
00010 
00011 #include <freeldr.h>
00012 
00013 //#include <ndk/ldrtypes.h>
00014 #include <debug.h>
00015 
00016 DBG_DEFAULT_CHANNEL(WINDOWS);
00017 
00018 /* FUNCTIONS **************************************************************/
00019 
00020 #ifndef _ZOOM2_
00021 /* Arch-specific addresses translation implementation */
00022 PVOID
00023 VaToPa(PVOID Va)
00024 {
00025     return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE);
00026 }
00027 
00028 PVOID
00029 PaToVa(PVOID Pa)
00030 {
00031     return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
00032 }
00033 #else
00034 PVOID
00035 VaToPa(PVOID Va)
00036 {
00037     return Va;
00038 }
00039 
00040 PVOID
00041 PaToVa(PVOID Pa)
00042 {
00043     return Pa;
00044 }
00045 #endif
00046 
00047 VOID
00048 List_PaToVa(PLIST_ENTRY ListHeadPa)
00049 {
00050     PLIST_ENTRY EntryPa, NextPa;
00051 
00052     /* List must be properly initialized */
00053     ASSERT(ListHeadPa->Flink != 0);
00054     ASSERT(ListHeadPa->Blink != 0);
00055 
00056     /* Loop the list in physical address space */
00057     EntryPa = ListHeadPa->Flink;
00058     while (EntryPa != ListHeadPa)
00059     {
00060         /* Save the physical address of the next entry */
00061         NextPa = EntryPa->Flink;
00062 
00063         /* Convert the addresses of this entry */
00064         EntryPa->Flink = PaToVa(EntryPa->Flink);
00065         EntryPa->Blink = PaToVa(EntryPa->Blink);
00066 
00067         /* Go to the next entry */
00068         EntryPa = NextPa;
00069     }
00070 
00071     /* Finally convert the list head */
00072     ListHeadPa->Flink = PaToVa(ListHeadPa->Flink);
00073     ListHeadPa->Blink = PaToVa(ListHeadPa->Blink);
00074 }
00075 
00076 // This function converts only Child->Child, and calls itself for each Sibling
00077 VOID
00078 ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
00079 {
00080     PCONFIGURATION_COMPONENT_DATA Child;
00081     PCONFIGURATION_COMPONENT_DATA Sibling;
00082 
00083     TRACE("ConvertConfigToVA(Start 0x%X)\n", Start);
00084     Child = Start;
00085 
00086     while (Child != NULL)
00087     {
00088         if (Child->ConfigurationData)
00089             Child->ConfigurationData = PaToVa(Child->ConfigurationData);
00090 
00091         if (Child->Child)
00092             Child->Child = PaToVa(Child->Child);
00093 
00094         if (Child->Parent)
00095             Child->Parent = PaToVa(Child->Parent);
00096 
00097         if (Child->Sibling)
00098             Child->Sibling = PaToVa(Child->Sibling);
00099 
00100         if (Child->ComponentEntry.Identifier)
00101             Child->ComponentEntry.Identifier = PaToVa(Child->ComponentEntry.Identifier);
00102 
00103         TRACE("Device 0x%X class %d type %d id '%s', parent %p\n", Child,
00104             Child->ComponentEntry.Class, Child->ComponentEntry.Type, VaToPa(Child->ComponentEntry.Identifier), Child->Parent);
00105 
00106         // Go through siblings list
00107         Sibling = VaToPa(Child->Sibling);
00108         while (Sibling != NULL)
00109         {
00110             if (Sibling->ConfigurationData)
00111                 Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData);
00112 
00113             if (Sibling->Child)
00114                 Sibling->Child = PaToVa(Sibling->Child);
00115 
00116             if (Sibling->Parent)
00117                 Sibling->Parent = PaToVa(Sibling->Parent);
00118 
00119             if (Sibling->Sibling)
00120                 Sibling->Sibling = PaToVa(Sibling->Sibling);
00121 
00122             if (Sibling->ComponentEntry.Identifier)
00123                 Sibling->ComponentEntry.Identifier = PaToVa(Sibling->ComponentEntry.Identifier);
00124 
00125             TRACE("Device 0x%X class %d type %d id '%s', parent %p\n", Sibling,
00126                 Sibling->ComponentEntry.Class, Sibling->ComponentEntry.Type, VaToPa(Sibling->ComponentEntry.Identifier), Sibling->Parent);
00127 
00128             // Recurse into the Child tree
00129             if (VaToPa(Sibling->Child) != NULL)
00130                 ConvertConfigToVA(VaToPa(Sibling->Child));
00131 
00132             Sibling = VaToPa(Sibling->Sibling);
00133         }
00134 
00135         // Go to the next child
00136         Child = VaToPa(Child->Child);
00137     }
00138 }

Generated on Sat May 26 2012 04:18:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.