#\r
################################################################################\r
\r
-[PcdsDynamic.DEFAULT]\r
+[PcdsDynamic.common]\r
PcdFlashNvStorageFtwSpareBase|gEfiGenericPlatformTokenSpaceGuid|0x0\r
PcdFlashNvStorageVariableSize|gEfiGenericPlatformTokenSpaceGuid|0x0\r
PcdWinNtCpuSpeed|gEfiNt32PkgTokenSpaceGuid|L"3000"|8\r
$(WORKSPACE)\Nt32Pkg\WinNtThunkDxe\WinNtThunk.inf\r
$(WORKSPACE)\Nt32Pkg\WinNtThunkPPIToProtocolPeim\WinNtThunkPPIToProtocolPeim.inf\r
$(WORKSPACE)\Nt32Pkg\WinNtAutoScanPeim\WinNtAutoScan.inf\r
- $(WORKSPACE)\Nt32Pkg\WinNtBlockIoDxe\WinNtBlockIo.inf
\ No newline at end of file
+ $(WORKSPACE)\Nt32Pkg\WinNtBlockIoDxe\WinNtBlockIo.inf\r
+ $(WORKSPACE)\Nt32Pkg\WinNtBusDriverDxe\WinNtBusDriver.inf
\ No newline at end of file
#\r
################################################################################\r
\r
-[PcdFixedAtBuild.common]\r
+[PcdsFixedAtBuild.common]\r
PcdWinNtBootMode|0x00001006|gEfiNt32PkgTokenSpaceGuid|UINT32|1\r
PcdWinNtFirmwareVolume|0x00001009|gEfiNt32PkgTokenSpaceGuid|VOID*|L"..\\Fv\\Fv_Recovery.fd"\r
PcdWinNtMemorySizeForSecMain|0x0000100c|gEfiNt32PkgTokenSpaceGuid|VOID*|L"64!64"\r
\r
-[PcdDynamic.common]\r
+[PcdsDynamic.common]\r
PcdWinNtPhysicalDisk|0x00001000|gEfiNt32PkgTokenSpaceGuid|VOID*|L"E:RW;245760;512"\r
PcdWinNtVirtualDisk|0x00001001|gEfiNt32PkgTokenSpaceGuid|VOID*|L"FW;40960;512"\r
PcdWinNtSerialPort|0x00001002|gEfiNt32PkgTokenSpaceGuid|VOID*|L"COM1!COM2"\r
PcdWinNtConsole|0x0000100a|gEfiNt32PkgTokenSpaceGuid|VOID*|L"Bus Driver Console Window"\r
PcdWinNtGop|0x0000100d|gEfiNt32PkgTokenSpaceGuid|VOID*|L"UGA Window 1!UGA Window 2"\r
\r
-[PcdPatchableInModule.common]\r
+[PcdsPatchableInModule.common]\r
PcdWinNtBootMode|0x00001006|gEfiNt32PkgTokenSpaceGuid|UINT32|1\r
PcdWinNtFirmwareVolume|0x00001009|gEfiNt32PkgTokenSpaceGuid|VOID*|L"..\\Fv\\Fv_Recovery.fd"\r
PcdWinNtMemorySizeForSecMain|0x0000100c|gEfiNt32PkgTokenSpaceGuid|VOID*|L"64!64"
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+#include <WinNtDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/WinNtThunk.h>\r
+#include <Protocol/WinNtIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+\r
+#include "WinNtBusDriver.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName = {\r
+ WinNtBusDriverComponentNameGetDriverName,\r
+ WinNtBusDriverComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mWinNtBusDriverNameTable[] = {\r
+ { "eng", L"Windows Bus Driver" },\r
+ { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ Language - A pointer to a three character ISO 639-2 language identifier.\r
+ This is the language of the driver name that that the caller \r
+ is requesting, and it must match one of the languages specified\r
+ in SupportedLanguages. The number of languages supported by a \r
+ driver is up to the driver writer.\r
+ DriverName - A pointer to the Unicode string to return. This Unicode string\r
+ is the name of the driver specified by This in the language \r
+ specified by Language.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the Driver specified by This\r
+ and the language specified by Language was returned \r
+ in DriverName.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - DriverName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gWinNtBusDriverComponentName.SupportedLanguages,\r
+ mWinNtBusDriverNameTable,\r
+ DriverName\r
+ );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+/*++\r
+\r
+ Routine Description:\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by an EFI Driver.\r
+\r
+ Arguments:\r
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+ ControllerHandle - The handle of a controller that the driver specified by \r
+ This is managing. This handle specifies the controller \r
+ whose name is to be returned.\r
+ ChildHandle - The handle of the child controller to retrieve the name \r
+ of. This is an optional parameter that may be NULL. It \r
+ will be NULL for device drivers. It will also be NULL \r
+ for a bus drivers that wish to retrieve the name of the \r
+ bus controller. It will not be NULL for a bus driver \r
+ that wishes to retrieve the name of a child controller.\r
+ Language - A pointer to a three character ISO 639-2 language \r
+ identifier. This is the language of the controller name \r
+ that that the caller is requesting, and it must match one\r
+ of the languages specified in SupportedLanguages. The \r
+ number of languages supported by a driver is up to the \r
+ driver writer.\r
+ ControllerName - A pointer to the Unicode string to return. This Unicode\r
+ string is the name of the controller specified by \r
+ ControllerHandle and ChildHandle in the language specified\r
+ by Language from the point of view of the driver specified\r
+ by This. \r
+\r
+ Returns:\r
+ EFI_SUCCESS - The Unicode string for the user readable name in the \r
+ language specified by Language for the driver \r
+ specified by This was returned in DriverName.\r
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+ EFI_INVALID_PARAMETER - Language is NULL.\r
+ EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing \r
+ the controller specified by ControllerHandle and \r
+ ChildHandle.\r
+ EFI_UNSUPPORTED - The driver specified by This does not support the \r
+ language specified by Language.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_WIN_NT_IO_PROTOCOL *WinNtIo;\r
+ WIN_NT_IO_DEVICE *Private;\r
+\r
+ //\r
+ // Make sure this driver is currently managing ControllHandle\r
+ //\r
+ Status = EfiTestManagedDevice (\r
+ ControllerHandle,\r
+ gWinNtBusDriverBinding.DriverBindingHandle,\r
+ &gEfiWinNtThunkProtocolGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // This is a bus driver, so ChildHandle can not be NULL.\r
+ //\r
+ if (ChildHandle == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = EfiTestChildHandle (\r
+ ControllerHandle,\r
+ ChildHandle,\r
+ &gEfiWinNtThunkProtocolGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get our context back\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ChildHandle,\r
+ &gEfiWinNtIoProtocolGuid,\r
+ &WinNtIo,\r
+ gWinNtBusDriverBinding.DriverBindingHandle,\r
+ ChildHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Private = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo);\r
+\r
+ return LookupUnicodeString (\r
+ Language,\r
+ gWinNtBusDriverComponentName.SupportedLanguages,\r
+ Private->ControllerNameTable,\r
+ ControllerName\r
+ );\r
+}\r
--- /dev/null
+/*+++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+ WinNtBusDriver.c\r
+\r
+Abstract:\r
+\r
+This following section documents the envirnoment variables for the Win NT\r
+build. These variables are used to define the (virtual) hardware\r
+configuration of the NT environment\r
+\r
+A ! can be used to seperate multiple instances in a variable. Each\r
+instance represents a seperate hardware device.\r
+\r
+EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system\r
+EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file\r
+EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system\r
+EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!)\r
+EFI_WIN_NT_UGA - Builds UGA Windows of Width and Height\r
+EFI_WIN_NT_SERIAL_PORT - maps physical serial ports\r
+\r
+ <F>ixed - Fixed disk like a hard drive.\r
+ <R>emovable - Removable media like a floppy or CD-ROM.\r
+ Read <O>nly - Write protected device.\r
+ Read <W>rite - Read write device.\r
+ <block count> - Decimal number of blocks a device supports.\r
+ <block size> - Decimal number of bytes per block.\r
+\r
+ NT envirnonment variable contents. '<' and '>' are not part of the variable,\r
+ they are just used to make this help more readable. There should be no\r
+ spaces between the ';'. Extra spaces will break the variable. A '!' is\r
+ used to seperate multiple devices in a variable.\r
+\r
+ EFI_WIN_NT_VIRTUAL_DISKS =\r
+ <F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ EFI_WIN_NT_PHYSICAL_DISKS =\r
+ <drive letter>:<F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ Virtual Disks: These devices use a file to emulate a hard disk or removable\r
+ media device.\r
+\r
+ Thus a 20 MB emulated hard drive would look like:\r
+ EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512\r
+\r
+ A 1.44MB emulated floppy with a block size of 1024 would look like:\r
+ EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024\r
+\r
+ Physical Disks: These devices use NT to open a real device in your system\r
+\r
+ Thus a 120 MB floppy would look like:\r
+ EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512\r
+\r
+ Thus a standard CD-ROM floppy would look like:\r
+ EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048\r
+\r
+ EFI_WIN_NT_FILE_SYSTEM =\r
+ <directory path>[!...]\r
+\r
+ Mounting the two directories C:\FOO and C:\BAR would look like:\r
+ EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar\r
+\r
+ EFI_WIN_NT_CONSOLE =\r
+ <window title>\r
+\r
+ Declaring a text console window with the title "My EFI Console" woild look like:\r
+ EFI_WIN_NT_CONSOLE=My EFI Console\r
+\r
+ EFI_WIN_NT_UGA =\r
+ <width> <height>[!...]\r
+\r
+ Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:\r
+ Example : EFI_WIN_NT_UGA=800 600!1024 768\r
+\r
+ EFI_WIN_NT_SERIAL_PORT =\r
+ <port name>[!...]\r
+\r
+ Declaring two serial ports on COM1 and COM2 would look like:\r
+ Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2\r
+\r
+ EFI_WIN_NT_PASS_THROUGH =\r
+ <BaseAddress>;<Bus#>;<Device#>;<Function#>\r
+\r
+ Declaring a base address of 0xE0000000 (used for PCI Express devices)\r
+ and having NT32 talk to a device located at bus 0, device 1, function 0:\r
+ Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0\r
+\r
+---*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+#include <WinNtDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/WinNtThunk.h>\r
+#include <Protocol/WinNtIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include "WinNtBusDriver.h"\r
+\r
+extern EFI_GUID gWinNtBusDriverGuid;\r
+//\r
+// DriverBinding protocol global\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding = {\r
+ WinNtBusDriverBindingSupported,\r
+ WinNtBusDriverBindingStart,\r
+ WinNtBusDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+#define NT_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(NT_PCD_ENTRY))\r
+\r
+//\r
+// Table to map NT Environment variable to the GUID that should be in\r
+// device path.\r
+//\r
+static NT_PCD_ENTRY mPcdEnvironment[] = {\r
+ PcdToken(PcdWinNtConsole), &gEfiWinNtConsoleGuid,\r
+ PcdToken(PcdWinNtGop), &gEfiWinNtGopGuid,\r
+ PcdToken(PcdWinNtSerialPort), &gEfiWinNtSerialPortGuid,\r
+ PcdToken(PcdWinNtFileSystem), &gEfiWinNtFileSystemGuid,\r
+ PcdToken(PcdWinNtVirtualDisk), &gEfiWinNtVirtualDisksGuid,\r
+ PcdToken(PcdWinNtPhysicalDisk), &gEfiWinNtPhysicalDisksGuid,\r
+ PcdToken(PcdWinNtCpuModel), &gEfiWinNtCPUModelGuid,\r
+ PcdToken(PcdWinNtCpuSpeed), &gEfiWinNtCPUSpeedGuid,\r
+ PcdToken(PcdWinNtMemorySize), &gEfiWinNtMemoryGuid\r
+};\r
+\r
+/**\r
+ The user Entry Point for module WinNtBusDriver. The user code starts with this function.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeWinNtBusDriver(\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Install driver model protocol(s).\r
+ //\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gWinNtBusDriverBinding,\r
+ ImageHandle,\r
+ &gWinNtBusDriverComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
+\r
+VOID *\r
+AllocateMemory (\r
+ IN UINTN Size\r
+ )\r
+{\r
+ VOID *Buffer;\r
+\r
+ Buffer = AllocatePool (Size);\r
+ ASSERT (Buffer != NULL);\r
+\r
+ return Buffer;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+// TODO: This - add argument and description to function comment\r
+// TODO: ControllerHandle - add argument and description to function comment\r
+// TODO: RemainingDevicePath - add argument and description to function comment\r
+// TODO: EFI_UNSUPPORTED - add return value to function comment\r
+// TODO: EFI_UNSUPPORTED - add return value to function comment\r
+// TODO: EFI_SUCCESS - add return value to function comment\r
+// TODO: EFI_SUCCESS - add return value to function comment\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r
+ UINTN Index;\r
+\r
+ //\r
+ // Check the contents of the first Device Path Node of RemainingDevicePath to make sure\r
+ // it is a legal Device Path Node for this bus driver's children.\r
+ //\r
+ if (RemainingDevicePath != NULL) {\r
+ if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+ RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+ DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
+ if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (Index >= NT_PCD_ARRAY_SIZE) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Open the IO Abstraction(s) needed to perform the supported test\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ &WinNtThunk,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Since we call through WinNtThunk we need to make sure it's valid\r
+ //\r
+ Status = EFI_SUCCESS;\r
+ if (WinNtThunk->Signature != EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE) {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Close the I/O Abstraction(s) used to perform the supported test\r
+ //\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+// TODO: This - add argument and description to function comment\r
+// TODO: ControllerHandle - add argument and description to function comment\r
+// TODO: RemainingDevicePath - add argument and description to function comment\r
+// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
+// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
+// TODO: EFI_SUCCESS - add return value to function comment\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_STATUS InstallStatus;\r
+ EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ WIN_NT_BUS_DEVICE *WinNtBusDevice;\r
+ WIN_NT_IO_DEVICE *WinNtDevice;\r
+ UINTN Index;\r
+ CHAR16 *StartString;\r
+ CHAR16 *SubString;\r
+ UINT16 Count;\r
+ UINTN StringSize;\r
+ UINT16 ComponentName[MAX_NT_ENVIRNMENT_VARIABLE_LENGTH];\r
+ WIN_NT_VENDOR_DEVICE_PATH_NODE *Node;\r
+ BOOLEAN CreateDevice;\r
+ CHAR16 *TempStr;\r
+ CHAR16 *PcdTempStr;\r
+ UINTN TempStrSize;\r
+\r
+ Status = EFI_UNSUPPORTED;\r
+\r
+ //\r
+ // Grab the protocols we need\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ &WinNtThunk,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+ return Status;\r
+ }\r
+\r
+ if (Status != EFI_ALREADY_STARTED) {\r
+ WinNtBusDevice = AllocatePool (sizeof (WIN_NT_BUS_DEVICE));\r
+ if (WinNtBusDevice == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ WinNtBusDevice->Signature = WIN_NT_BUS_DEVICE_SIGNATURE;\r
+ WinNtBusDevice->ControllerNameTable = NULL;\r
+\r
+ AddUnicodeString (\r
+ "eng",\r
+ gWinNtBusDriverComponentName.SupportedLanguages,\r
+ &WinNtBusDevice->ControllerNameTable,\r
+ L"Windows Bus Controller"\r
+ );\r
+\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &ControllerHandle,\r
+ &gWinNtBusDriverGuid,\r
+ WinNtBusDevice,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable);\r
+ FreePool (WinNtBusDevice);\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Loop on the Variable list. Parse each variable to produce a set of handles that\r
+ // represent virtual hardware devices.\r
+ //\r
+ InstallStatus = EFI_NOT_FOUND;\r
+ for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
+ PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);\r
+ ASSERT (PcdTempStr != NULL);\r
+\r
+ TempStrSize = StrLen (PcdTempStr);\r
+ TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1);\r
+ StrCpy (TempStr, PcdTempStr);\r
+\r
+ StartString = TempStr;\r
+\r
+ //\r
+ // Parse the envirnment variable into sub strings using '!' as a delimator.\r
+ // Each substring needs it's own handle to be added to the system. This code\r
+ // does not understand the sub string. Thats the device drivers job.\r
+ //\r
+ Count = 0;\r
+ while (*StartString != '\0') {\r
+\r
+ //\r
+ // Find the end of the sub string\r
+ //\r
+ SubString = StartString;\r
+ while (*SubString != '\0' && *SubString != '!') {\r
+ SubString++;\r
+ }\r
+\r
+ if (*SubString == '!') {\r
+ //\r
+ // Replace token with '\0' to make sub strings. If this is the end\r
+ // of the string SubString will already point to NULL.\r
+ //\r
+ *SubString = '\0';\r
+ SubString++;\r
+ }\r
+\r
+ CreateDevice = TRUE;\r
+ if (RemainingDevicePath != NULL) {\r
+ CreateDevice = FALSE;\r
+ Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+ if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+ Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+ DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)\r
+ ) {\r
+ if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
+ Node->Instance == Count\r
+ ) {\r
+ CreateDevice = TRUE;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (CreateDevice) {\r
+\r
+ //\r
+ // Allocate instance structure, and fill in parent information.\r
+ //\r
+ WinNtDevice = AllocateMemory (sizeof (WIN_NT_IO_DEVICE));\r
+ if (WinNtDevice == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ WinNtDevice->Handle = NULL;\r
+ WinNtDevice->ControllerHandle = ControllerHandle;\r
+ WinNtDevice->ParentDevicePath = ParentDevicePath;\r
+\r
+ WinNtDevice->WinNtIo.WinNtThunk = WinNtThunk;\r
+\r
+ //\r
+ // Plus 2 to account for the NULL at the end of the Unicode string\r
+ //\r
+ StringSize = (UINTN) ((UINT8 *) SubString - (UINT8 *) StartString) + sizeof (CHAR16);\r
+ WinNtDevice->WinNtIo.EnvString = AllocateMemory (StringSize);\r
+ if (WinNtDevice->WinNtIo.EnvString != NULL) {\r
+ CopyMem (WinNtDevice->WinNtIo.EnvString, StartString, StringSize);\r
+ }\r
+\r
+ WinNtDevice->ControllerNameTable = NULL;\r
+\r
+ WinNtThunk->SPrintf (ComponentName, sizeof (ComponentName), L"%s", WinNtDevice->WinNtIo.EnvString);\r
+\r
+ WinNtDevice->DevicePath = WinNtBusCreateDevicePath (\r
+ ParentDevicePath,\r
+ mPcdEnvironment[Index].DevicePathGuid,\r
+ Count\r
+ );\r
+ if (WinNtDevice->DevicePath == NULL) {\r
+ FreePool (WinNtDevice);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ AddUnicodeString (\r
+ "eng",\r
+ gWinNtBusDriverComponentName.SupportedLanguages,\r
+ &WinNtDevice->ControllerNameTable,\r
+ ComponentName\r
+ );\r
+\r
+ WinNtDevice->WinNtIo.TypeGuid = mPcdEnvironment[Index].DevicePathGuid;\r
+ WinNtDevice->WinNtIo.InstanceNumber = Count;\r
+\r
+ WinNtDevice->Signature = WIN_NT_IO_DEVICE_SIGNATURE;\r
+\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &WinNtDevice->Handle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ WinNtDevice->DevicePath,\r
+ &gEfiWinNtIoProtocolGuid,\r
+ &WinNtDevice->WinNtIo,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ FreeUnicodeStringTable (WinNtDevice->ControllerNameTable);\r
+ FreePool (WinNtDevice);\r
+ } else {\r
+ //\r
+ // Open For Child Device\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ &WinNtThunk,\r
+ This->DriverBindingHandle,\r
+ WinNtDevice->Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ InstallStatus = EFI_SUCCESS;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // Parse Next sub string. This will point to '\0' if we are at the end.\r
+ //\r
+ Count++;\r
+ StartString = SubString;\r
+ }\r
+\r
+ FreePool (TempStr);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+// TODO: This - add argument and description to function comment\r
+// TODO: ControllerHandle - add argument and description to function comment\r
+// TODO: NumberOfChildren - add argument and description to function comment\r
+// TODO: ChildHandleBuffer - add argument and description to function comment\r
+// TODO: EFI_SUCCESS - add return value to function comment\r
+// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
+// TODO: EFI_SUCCESS - add return value to function comment\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ BOOLEAN AllChildrenStopped;\r
+ EFI_WIN_NT_IO_PROTOCOL *WinNtIo;\r
+ WIN_NT_BUS_DEVICE *WinNtBusDevice;\r
+ WIN_NT_IO_DEVICE *WinNtDevice;\r
+ EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r
+\r
+ //\r
+ // Complete all outstanding transactions to Controller.\r
+ // Don't allow any new transaction to Controller to be started.\r
+ //\r
+\r
+ if (NumberOfChildren == 0) {\r
+ //\r
+ // Close the bus driver\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gWinNtBusDriverGuid,\r
+ &WinNtBusDevice,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ ControllerHandle,\r
+ &gWinNtBusDriverGuid,\r
+ WinNtBusDevice,\r
+ NULL\r
+ );\r
+\r
+ FreeUnicodeStringTable (WinNtBusDevice->ControllerNameTable);\r
+\r
+ FreePool (WinNtBusDevice);\r
+\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ AllChildrenStopped = TRUE;\r
+\r
+ for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ChildHandleBuffer[Index],\r
+ &gEfiWinNtIoProtocolGuid,\r
+ &WinNtIo,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+\r
+ WinNtDevice = WIN_NT_IO_DEVICE_FROM_THIS (WinNtIo);\r
+\r
+ Status = gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ WinNtDevice->Handle\r
+ );\r
+\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ WinNtDevice->Handle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ WinNtDevice->DevicePath,\r
+ &gEfiWinNtIoProtocolGuid,\r
+ &WinNtDevice->WinNtIo,\r
+ NULL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiWinNtThunkProtocolGuid,\r
+ (VOID **) &WinNtThunk,\r
+ This->DriverBindingHandle,\r
+ WinNtDevice->Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ } else {\r
+ //\r
+ // Close the child handle\r
+ //\r
+ FreeUnicodeStringTable (WinNtDevice->ControllerNameTable);\r
+ FreePool (WinNtDevice);\r
+ }\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ AllChildrenStopped = FALSE;\r
+ }\r
+ }\r
+\r
+ if (!AllChildrenStopped) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+WinNtBusCreateDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath,\r
+ IN EFI_GUID *Guid,\r
+ IN UINT16 InstanceNumber\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Create a device path node using Guid and InstanceNumber and append it to\r
+ the passed in RootDevicePath\r
+\r
+Arguments:\r
+ RootDevicePath - Root of the device path to return.\r
+\r
+ Guid - GUID to use in vendor device path node.\r
+\r
+ InstanceNumber - Instance number to use in the vendor device path. This\r
+ argument is needed to make sure each device path is unique.\r
+\r
+Returns:\r
+\r
+ EFI_DEVICE_PATH_PROTOCOL\r
+\r
+--*/\r
+{\r
+ WIN_NT_VENDOR_DEVICE_PATH_NODE DevicePath;\r
+\r
+ DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH;\r
+ DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP;\r
+ SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE));\r
+\r
+ //\r
+ // The GUID defines the Class\r
+ //\r
+ CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));\r
+\r
+ //\r
+ // Add an instance number so we can make sure there are no Device Path\r
+ // duplication.\r
+ //\r
+ DevicePath.Instance = InstanceNumber;\r
+\r
+ return AppendDevicePathNode (\r
+ RootDevicePath,\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath\r
+ );\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ WinNtBusDriver.h\r
+\r
+Abstract:\r
+\r
+This following section documents the envirnoment variables for the Win NT \r
+build. These variables are used to define the (virtual) hardware \r
+configuration of the NT environment\r
+\r
+A ! can be used to seperate multiple instances in a variable. Each \r
+instance represents a seperate hardware device. \r
+\r
+EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system\r
+EFI_WIN_NT_VIRTUAL_DISKS - maps to a device emulated by a file\r
+EFI_WIN_NT_FILE_SYSTEM - mouts a directory as a file system\r
+EFI_WIN_NT_CONSOLE - make a logical comand line window (only one!)\r
+EFI_WIN_NT_UGA - Builds UGA Windows of Width and Height\r
+EFI_WIN_NT_SERIAL_PORT - maps physical serial ports\r
+EFI_WIN_NT_PASS_THRU - associates a device with our PCI support\r
+\r
+ <F>ixed - Fixed disk like a hard drive.\r
+ <R>emovable - Removable media like a floppy or CD-ROM.\r
+ Read <O>nly - Write protected device.\r
+ Read <W>rite - Read write device.\r
+ <block count> - Decimal number of blocks a device supports.\r
+ <block size> - Decimal number of bytes per block.\r
+\r
+ NT envirnonment variable contents. '<' and '>' are not part of the variable, \r
+ they are just used to make this help more readable. There should be no \r
+ spaces between the ';'. Extra spaces will break the variable. A '!' is \r
+ used to seperate multiple devices in a variable.\r
+\r
+ EFI_WIN_NT_VIRTUAL_DISKS = \r
+ <F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ EFI_WIN_NT_PHYSICAL_DISKS =\r
+ <drive letter>:<F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ Virtual Disks: These devices use a file to emulate a hard disk or removable\r
+ media device. \r
+ \r
+ Thus a 20 MB emulated hard drive would look like:\r
+ EFI_WIN_NT_VIRTUAL_DISKS=FW;40960;512\r
+\r
+ A 1.44MB emulated floppy with a block size of 1024 would look like:\r
+ EFI_WIN_NT_VIRTUAL_DISKS=RW;1440;1024\r
+\r
+ Physical Disks: These devices use NT to open a real device in your system\r
+\r
+ Thus a 120 MB floppy would look like:\r
+ EFI_WIN_NT_PHYSICAL_DISKS=B:RW;245760;512\r
+\r
+ Thus a standard CD-ROM floppy would look like:\r
+ EFI_WIN_NT_PHYSICAL_DISKS=Z:RO;307200;2048\r
+\r
+ EFI_WIN_NT_FILE_SYSTEM = \r
+ <directory path>[!...]\r
+\r
+ Mounting the two directories C:\FOO and C:\BAR would look like:\r
+ EFI_WIN_NT_FILE_SYSTEM=c:\foo!c:\bar\r
+\r
+ EFI_WIN_NT_CONSOLE = \r
+ <window title>\r
+\r
+ Declaring a text console window with the title "My EFI Console" woild look like:\r
+ EFI_WIN_NT_CONSOLE=My EFI Console\r
+\r
+ EFI_WIN_NT_UGA = \r
+ <width> <height>[!...]\r
+\r
+ Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:\r
+ Example : EFI_WIN_NT_UGA=800 600!1024 768\r
+\r
+ EFI_WIN_NT_SERIAL_PORT = \r
+ <port name>[!...]\r
+\r
+ Declaring two serial ports on COM1 and COM2 would look like:\r
+ Example : EFI_WIN_NT_SERIAL_PORT=COM1!COM2\r
+\r
+ EFI_WIN_NT_PASS_THROUGH =\r
+ <BaseAddress>;<Bus#>;<Device#>;<Function#>\r
+\r
+ Declaring a base address of 0xE0000000 (used for PCI Express devices)\r
+ and having NT32 talk to a device located at bus 0, device 1, function 0:\r
+ Example : EFI_WIN_NT_PASS_THROUGH=E000000;0;1;0\r
+\r
+---*/\r
+\r
+#ifndef __NT_BUS_DRIVER_H__\r
+#define __NT_BUS_DRIVER_H__\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+#include <WinNtDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/WinNtIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/WinNtThunk.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+//\r
+// WinNt Bus Driver Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBusDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBusDriverComponentName;\r
+\r
+//\r
+// WinNt Bus Controller Structure\r
+//\r
+#define WIN_NT_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'B', 'D')\r
+\r
+typedef struct {\r
+ UINT64 Signature;\r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+} WIN_NT_BUS_DEVICE;\r
+\r
+//\r
+// WinNt Child Device Controller Structure\r
+//\r
+#define WIN_NT_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'V', 'D')\r
+\r
+typedef struct {\r
+ UINT64 Signature;\r
+ EFI_HANDLE Handle;\r
+ EFI_WIN_NT_IO_PROTOCOL WinNtIo;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ //\r
+ // Private data about the parent\r
+ //\r
+ EFI_HANDLE ControllerHandle;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+\r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+\r
+} WIN_NT_IO_DEVICE;\r
+\r
+#define WIN_NT_IO_DEVICE_FROM_THIS(a) \\r
+ CR(a, WIN_NT_IO_DEVICE, WinNtIo, WIN_NT_IO_DEVICE_SIGNATURE)\r
+\r
+//\r
+// This is the largest env variable we can parse\r
+//\r
+#define MAX_NT_ENVIRNMENT_VARIABLE_LENGTH 512\r
+\r
+typedef struct {\r
+ UINTN Token;\r
+ EFI_GUID *DevicePathGuid;\r
+} NT_PCD_ENTRY;\r
+\r
+typedef struct {\r
+ VENDOR_DEVICE_PATH VendorDevicePath;\r
+ UINT32 Instance;\r
+} WIN_NT_VENDOR_DEVICE_PATH_NODE;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ ImageHandle - TODO: add argument description\r
+ SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Driver Binding Protocol function prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Handle - TODO: add argument description\r
+ RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ParentHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ ParentHandle - TODO: add argument description\r
+ RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtBusDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Handle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Handle - TODO: add argument description\r
+ NumberOfChildren - TODO: add argument description\r
+ ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// WinNt Bus Driver private worker functions\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+WinNtBusCreateDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath,\r
+ IN EFI_GUID *Guid,\r
+ IN UINT16 InstanceNumber\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ RootDevicePath - TODO: add argument description\r
+ Guid - TODO: add argument description\r
+ InstanceNumber - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Win NT Bus driver\r
+#\r
+# This following section documents the envirnoment variables for the Win NT\r
+# build. These variables are used to define the (virtual) hardware\r
+# configuration of the NT environment\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = WinNtBusDriver\r
+ FILE_GUID = BD7E9A27-D6C5-416a-B245-5F507D95B2BD\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeWinNtBusDriver\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32\r
+#\r
+# DRIVER_BINDING = gWinNtBusDriverBinding \r
+# COMPONENT_NAME = gWinNtBusDriverComponentName \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ WinNtBusDriver.c\r
+ WinNtBusDriver.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg/Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ Nt32Pkg/Nt32Pkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ MemoryAllocationLib\r
+ DevicePathLib\r
+ UefiBootServicesTableLib\r
+ BaseMemoryLib\r
+ PcdLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ BaseLib\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+ gEfiWinNtCPUSpeedGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtCPUModelGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtMemoryGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtConsoleGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtGopGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtSerialPortGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtFileSystemGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtPhysicalDisksGuid # ALWAYS_CONSUMED\r
+ gEfiWinNtVirtualDisksGuid # ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+# that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+ gWinNtBusDriverGuid # PROTOCOL BY_START\r
+ gEfiDevicePathProtocolGuid # PROTOCOL BY_START\r
+ gEfiWinNtThunkProtocolGuid # PROTOCOL TO_START\r
+ gEfiWinNtIoProtocolGuid # PROTOCOL BY_START\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+ PcdWinNtMemorySize|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtCpuSpeed|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtCpuModel|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtPhysicalDisk|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtVirtualDisk|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtFileSystem|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtSerialPort|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtGop|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtUga|gEfiNt32PkgTokenSpaceGuid\r
+ PcdWinNtConsole|gEfiNt32PkgTokenSpaceGuid\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>WinNtBusDriver</ModuleName>\r
+ <ModuleType>UEFI_DRIVER</ModuleType>\r
+ <GuidValue>BD7E9A27-D6C5-416a-B245-5F507D95B2BD</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Win NT Bus driver</Abstract>\r
+ <Description>This following section documents the envirnoment variables for the Win NT\r
+ build. These variables are used to define the (virtual) hardware\r
+ configuration of the NT environment</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>WinNtBusDriver</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverModelLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiDriverEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>UefiBootServicesTableLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DevicePathLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>MemoryAllocationLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>WinNtBusDriver.h</Filename>\r
+ <Filename>WinNtBusDriver.c</Filename>\r
+ <Filename>ComponentName.c</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>\r
+ </PackageDependencies>\r
+ <Protocols>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiWinNtIoProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="TO_START">\r
+ <ProtocolCName>gEfiWinNtThunkProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+ </Protocol>\r
+ <Protocol Usage="BY_START">\r
+ <ProtocolCName>gWinNtBusDriverGuid</ProtocolCName>\r
+ </Protocol>\r
+ </Protocols>\r
+ <Guids>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtVirtualDisksGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtPhysicalDisksGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtFileSystemGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtSerialPortGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtUgaGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtGopGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtConsoleGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtMemoryGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtCPUModelGuid</GuidCName>\r
+ </GuidCNames>\r
+ <GuidCNames Usage="ALWAYS_CONSUMED">\r
+ <GuidCName>gEfiWinNtCPUSpeedGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <DriverBinding>gWinNtBusDriverBinding</DriverBinding>\r
+ <ComponentName>gWinNtBusDriverComponentName</ComponentName>\r
+ </Extern>\r
+ </Externs>\r
+ <PcdCoded>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtConsole</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD declares the title string of the text console window.\r
+ such as "My EFI Console".\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtUga</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD declares the resolutions for the UGA windows.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtGop</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD declares the resolutions for the GOP windows.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtSerialPort</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This Pcd declares two serial port for simulated environment.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtFileSystem</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines the windows directory who will be mounted as\r
+ harddisk in simulator.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtVirtualDisk</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines the devices which use a file to emulate a hard disk or\r
+ removable media device\r
+ The item type if this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtPhysicalDisk</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines physical disk which will be simualted as a\r
+ harddisk in simulator.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtCpuModel</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines simulated CPU model string.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtCpuSpeed</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines simulated CPU speed string.</HelpText>\r
+ </PcdEntry>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdWinNtMemorySize</C_Name>\r
+ <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>This PCD defines the size of simulated memory size.\r
+ The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+ </PcdEntry>\r
+ </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file