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.

102 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. handle.c
  5. Abstract:
  6. Shell environment handle information management
  7. Revision History
  8. --*/
  9. #include "shelle.h"
  10. UINTN SEnvNoHandles;
  11. EFI_HANDLE *SEnvHandles;
  12. VOID
  13. INTERNAL
  14. SEnvInitHandleGlobals (
  15. VOID
  16. )
  17. {
  18. SEnvNoHandles = 0;
  19. SEnvHandles = NULL;
  20. }
  21. VOID
  22. INTERNAL
  23. SEnvLoadHandleTable (
  24. VOID
  25. )
  26. {
  27. /*
  28. * For ease of use the shell maps handle #'s to short numbers.
  29. *
  30. * This is only done on request for various internal commands and
  31. * the references are immediately freed when the internal command
  32. * completes.
  33. */
  34. /* Free any old info */
  35. SEnvFreeHandleTable();
  36. /* Load new info */
  37. SEnvHandles = NULL;
  38. LibLocateHandle (AllHandles, NULL, NULL, &SEnvNoHandles, &SEnvHandles);
  39. }
  40. VOID
  41. INTERNAL
  42. SEnvFreeHandleTable (
  43. VOID
  44. )
  45. {
  46. if (SEnvNoHandles) {
  47. SEnvFreeHandleProtocolInfo();
  48. FreePool (SEnvHandles);
  49. SEnvHandles = NULL;
  50. SEnvNoHandles = 0;
  51. }
  52. }
  53. UINTN
  54. SEnvHandleNoFromStr(
  55. IN CHAR16 *Str
  56. )
  57. {
  58. UINTN HandleNo;
  59. HandleNo = xtoi(Str);
  60. HandleNo = HandleNo > SEnvNoHandles ? 0 : HandleNo;
  61. return HandleNo;
  62. }
  63. EFI_HANDLE
  64. SEnvHandleFromStr(
  65. IN CHAR16 *Str
  66. )
  67. {
  68. UINTN HandleNo;
  69. EFI_HANDLE Handle;
  70. HandleNo = xtoi(Str) - 1;
  71. Handle = HandleNo > SEnvNoHandles ? NULL : SEnvHandles[HandleNo];
  72. return Handle;
  73. }