Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. vm.c
  5. Abstract:
  6. Very hard to remap runtime address into the new virual address space
  7. that was registered by the OS for RT calls.
  8. So the code image needs to be relocated. All pointers need to be
  9. manually fixed up since the address map changes.
  10. GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE
  11. EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN
  12. YOU TEST.
  13. Revision History
  14. --*/
  15. #include "lib.h"
  16. #pragma RUNTIME_CODE(RtLibEnableVirtualMappings)
  17. VOID
  18. RUNTIMEFUNCTION
  19. RtLibEnableVirtualMappings (
  20. VOID
  21. )
  22. {
  23. EFI_CONVERT_POINTER ConvertPointer;
  24. /*
  25. * If this copy of the lib is linked into the firmware, then
  26. * do not update the pointers yet.
  27. */
  28. if (!LibFwInstance) {
  29. /*
  30. * Different components are updating to the new virtual
  31. * mappings at differnt times. The only function that
  32. * is safe to call at this notification is ConvertAddress
  33. */
  34. ConvertPointer = RT->ConvertPointer;
  35. /*
  36. * Fix any pointers that the lib created, that may be needed
  37. * during runtime.
  38. */
  39. ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT);
  40. ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut);
  41. ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL);
  42. ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL);
  43. /* that was it :^) */
  44. }
  45. }
  46. #pragma RUNTIME_CODE(RtConvertList)
  47. VOID
  48. RUNTIMEFUNCTION
  49. RtConvertList (
  50. IN UINTN DebugDisposition,
  51. IN OUT LIST_ENTRY *ListHead
  52. )
  53. {
  54. LIST_ENTRY *Link;
  55. LIST_ENTRY *NextLink;
  56. EFI_CONVERT_POINTER ConvertPointer;
  57. ConvertPointer = RT->ConvertPointer;
  58. /*
  59. * Convert all the Flink & Blink pointers in the list
  60. */
  61. Link = ListHead;
  62. do {
  63. NextLink = Link->Flink;
  64. ConvertPointer (
  65. Link->Flink == ListHead ? DebugDisposition : 0,
  66. (VOID **)&Link->Flink
  67. );
  68. ConvertPointer (
  69. Link->Blink == ListHead ? DebugDisposition : 0,
  70. (VOID **)&Link->Blink
  71. );
  72. Link = NextLink;
  73. } while (Link != ListHead);
  74. }