11#include "EmuBusDriverDxe.h"
17 EmuBusDriverBindingSupported,
18 EmuBusDriverBindingStart,
19 EmuBusDriverBindingStop,
27EmuBusDriverBindingSupported (
41 if (RemainingDevicePath !=
NULL) {
55 return EFI_UNSUPPORTED;
63 Status =
gBS->OpenProtocol (
65 &gEmuThunkProtocolGuid,
67 This->DriverBindingHandle,
69 EFI_OPEN_PROTOCOL_BY_DRIVER
71 if (Status == EFI_ALREADY_STARTED) {
75 if (EFI_ERROR (Status)) {
84 &gEmuThunkProtocolGuid,
85 This->DriverBindingHandle,
92 Status =
gBS->OpenProtocol (
94 &gEfiDevicePathProtocolGuid,
95 (VOID **)&ParentDevicePath,
96 This->DriverBindingHandle,
98 EFI_OPEN_PROTOCOL_BY_DRIVER
100 if (Status == EFI_ALREADY_STARTED) {
104 if (EFI_ERROR (Status)) {
113 &gEfiDevicePathProtocolGuid,
114 This->DriverBindingHandle,
123EmuBusDriverBindingStart (
136 UINT16 ComponentName[512];
138 BOOLEAN CreateDevice;
140 InstallStatus = EFI_UNSUPPORTED;
141 Status = EFI_UNSUPPORTED;
146 Status =
gBS->OpenProtocol (
148 &gEfiDevicePathProtocolGuid,
149 (VOID **)&ParentDevicePath,
150 This->DriverBindingHandle,
152 EFI_OPEN_PROTOCOL_BY_DRIVER
154 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
158 Status =
gBS->OpenProtocol (
160 &gEmuThunkProtocolGuid,
162 This->DriverBindingHandle,
164 EFI_OPEN_PROTOCOL_BY_DRIVER
166 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
170 if (Status != EFI_ALREADY_STARTED) {
172 if (EmuBusDevice ==
NULL) {
173 return EFI_OUT_OF_RESOURCES;
176 EmuBusDevice->Signature = EMU_BUS_DEVICE_SIGNATURE;
177 EmuBusDevice->ControllerNameTable =
NULL;
182 &EmuBusDevice->ControllerNameTable,
183 L
"Emulator Bus Controller",
189 &EmuBusDevice->ControllerNameTable,
190 L
"Emulator Bus Controller",
194 Status =
gBS->InstallMultipleProtocolInterfaces (
200 if (EFI_ERROR (Status)) {
202 gBS->FreePool (EmuBusDevice);
208 Status = EmuThunk->GetNextProtocol (
TRUE, &EmuIoThunk);
209 if (EFI_ERROR (Status)) {
214 if (RemainingDevicePath !=
NULL) {
215 CreateDevice =
FALSE;
231 if (
CompareGuid (&Node->VendorDevicePath.
Guid, EmuIoThunk->Protocol) && (Node->Instance == EmuIoThunk->Instance)) {
243 if (EmuDevice ==
NULL) {
244 return EFI_OUT_OF_RESOURCES;
247 EmuDevice->Handle =
NULL;
248 EmuDevice->ControllerHandle = ControllerHandle;
249 EmuDevice->ParentDevicePath = ParentDevicePath;
252 EmuDevice->ControllerNameTable =
NULL;
256 sizeof (ComponentName) /
sizeof (CHAR16),
258 sizeof (ComponentName) /
sizeof (CHAR16)
261 EmuDevice->DevicePath = EmuBusCreateDevicePath (
263 EmuIoThunk->Protocol,
266 if (EmuDevice->DevicePath ==
NULL) {
267 gBS->FreePool (EmuDevice);
268 return EFI_OUT_OF_RESOURCES;
274 &EmuDevice->ControllerNameTable,
278 EmuDevice->Signature = EMU_IO_DEVICE_SIGNATURE;
280 InstallStatus =
gBS->InstallMultipleProtocolInterfaces (
282 &gEfiDevicePathProtocolGuid,
283 EmuDevice->DevicePath,
284 &gEmuIoThunkProtocolGuid,
285 &EmuDevice->EmuIoThunk,
288 if (EFI_ERROR (InstallStatus)) {
290 gBS->FreePool (EmuDevice);
295 Status =
gBS->OpenProtocol (
297 &gEmuThunkProtocolGuid,
299 This->DriverBindingHandle,
301 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
303 if (!EFI_ERROR (Status)) {
310 return InstallStatus;
315EmuBusDriverBindingStop (
324 BOOLEAN AllChildrenStopped;
335 if (NumberOfChildren == 0) {
339 Status =
gBS->OpenProtocol (
342 (VOID **)&EmuBusDevice,
343 This->DriverBindingHandle,
345 EFI_OPEN_PROTOCOL_GET_PROTOCOL
347 if (EFI_ERROR (Status)) {
351 gBS->UninstallMultipleProtocolInterfaces (
360 gBS->FreePool (EmuBusDevice);
364 &gEmuThunkProtocolGuid,
365 This->DriverBindingHandle,
371 &gEfiDevicePathProtocolGuid,
372 This->DriverBindingHandle,
378 AllChildrenStopped =
TRUE;
380 for (Index = 0; Index < NumberOfChildren; Index++) {
381 Status =
gBS->OpenProtocol (
382 ChildHandleBuffer[Index],
383 &gEmuIoThunkProtocolGuid,
384 (VOID **)&EmuIoThunk,
385 This->DriverBindingHandle,
387 EFI_OPEN_PROTOCOL_GET_PROTOCOL
389 if (!EFI_ERROR (Status)) {
390 EmuDevice = EMU_IO_DEVICE_FROM_THIS (EmuIoThunk);
392 Status =
gBS->CloseProtocol (
394 &gEmuThunkProtocolGuid,
395 This->DriverBindingHandle,
399 Status =
gBS->UninstallMultipleProtocolInterfaces (
401 &gEfiDevicePathProtocolGuid,
402 EmuDevice->DevicePath,
403 &gEmuIoThunkProtocolGuid,
404 &EmuDevice->EmuIoThunk,
408 if (EFI_ERROR (Status)) {
411 &gEmuThunkProtocolGuid,
413 This->DriverBindingHandle,
415 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
426 if (EFI_ERROR (Status)) {
427 AllChildrenStopped =
FALSE;
431 if (!AllChildrenStopped) {
432 return EFI_DEVICE_ERROR;
458EmuBusCreateDevicePath (
461 IN UINT16 InstanceNumber
479 DevicePath.Instance = InstanceNumber;
509 &gEmuBusDriverBinding,
511 &gEmuBusDriverComponentName,
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
#define HARDWARE_DEVICE_PATH
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI InitializeEmuBusDriver(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define ASSERT_EFI_ERROR(StatusParameter)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
EFI_STATUS EFIAPI EfiLibInstallAllDriverProtocols(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration OPTIONAL, IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL)
EFI_STATUS EFIAPI AddUnicodeString(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
CHAR16 * ConfigString
Only be valid after Open() is called.