Leaked source code of windows server 2003
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.

130 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. init.c
  5. Abstract:
  6. Shell Environment driver
  7. Revision History
  8. --*/
  9. #include "shelle.h"
  10. /*
  11. *
  12. */
  13. EFI_STATUS
  14. InitializeShellEnvironment (
  15. IN EFI_HANDLE ImageHandle,
  16. IN EFI_SYSTEM_TABLE *SystemTable
  17. );
  18. /*
  19. *
  20. */
  21. EFI_DRIVER_ENTRY_POINT(InitializeShellEnvironment)
  22. EFI_STATUS
  23. InitializeShellEnvironment (
  24. IN EFI_HANDLE ImageHandle,
  25. IN EFI_SYSTEM_TABLE *SystemTable
  26. )
  27. /*++
  28. Routine Description:
  29. Arguments:
  30. ImageHandle - The handle for this driver
  31. SystemTable - The system table
  32. Returns:
  33. EFI file system driver is enabled
  34. --*/
  35. {
  36. EFI_HANDLE Handle;
  37. UINTN BufferSize;
  38. EFI_STATUS Status;
  39. /*
  40. * Initialize EFI library
  41. */
  42. InitializeLib (ImageHandle, SystemTable);
  43. /*
  44. * If we are already installed, don't install again
  45. */
  46. BufferSize = sizeof(Handle);
  47. Status = BS->LocateHandle(ByProtocol, &ShellEnvProtocol, NULL, &BufferSize, &Handle);
  48. if (!EFI_ERROR(Status)) {
  49. return EFI_LOAD_ERROR;
  50. }
  51. /*
  52. * Initialize globals
  53. */
  54. InitializeLock (&SEnvLock, TPL_APPLICATION);
  55. InitializeLock (&SEnvGuidLock, TPL_NOTIFY);
  56. SEnvInitCommandTable();
  57. SEnvInitProtocolInfo();
  58. SEnvInitVariables();
  59. SEnvInitHandleGlobals();
  60. SEnvInitMap();
  61. SEnvLoadInternalProtInfo();
  62. SEnvConIoInitDosKey();
  63. SEnvInitBatch();
  64. /*
  65. * Install our handle (or override the existing one)
  66. */
  67. BufferSize = sizeof(Handle);
  68. Handle = ImageHandle;
  69. BS->LocateHandle(ByProtocol, &ShellEnvProtocol, NULL, &BufferSize, &Handle);
  70. LibInstallProtocolInterfaces (&Handle, &ShellEnvProtocol, &SEnvInterface, NULL);
  71. return EFI_SUCCESS;
  72. }
  73. EFI_SHELL_INTERFACE *
  74. SEnvNewShell (
  75. IN EFI_HANDLE ImageHandle
  76. )
  77. {
  78. EFI_SHELL_INTERFACE *ShellInt;
  79. /* Allocate a new structure */
  80. ShellInt = AllocateZeroPool (sizeof(EFI_SHELL_INTERFACE));
  81. ASSERT (ShellInt);
  82. /* Fill in the SI pointer */
  83. BS->HandleProtocol (ImageHandle, &LoadedImageProtocol, (VOID*)&ShellInt->Info);
  84. /* Fill in the std file handles */
  85. ShellInt->ImageHandle = ImageHandle;
  86. ShellInt->StdIn = &SEnvIOFromCon;
  87. ShellInt->StdOut = &SEnvIOFromCon;
  88. ShellInt->StdErr = &SEnvErrIOFromCon;
  89. return ShellInt;
  90. }