]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DebugPortDxe/DebugPort.h
Add DebugPort & DebugSupport drivers
[mirror_edk2.git] / MdeModulePkg / Universal / DebugPortDxe / DebugPort.h
diff --git a/MdeModulePkg/Universal/DebugPortDxe/DebugPort.h b/MdeModulePkg/Universal/DebugPortDxe/DebugPort.h
new file mode 100644 (file)
index 0000000..58a1629
--- /dev/null
@@ -0,0 +1,201 @@
+/*++\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
+  DebugPort.h\r
+\r
+Abstract:\r
+  Definitions and prototypes for DebugPort driver\r
+\r
+--*/\r
+\r
+#ifndef __DEBUGPORT_H__\r
+#define __DEBUGPORT_H__\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/SerialIo.h>\r
+#include <Protocol/DebugPort.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+//\r
+// Driver Binding Externs\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gDebugPortComponentName;\r
+\r
+//\r
+// local type definitions\r
+//\r
+#define DEBUGPORT_DEVICE_SIGNATURE  EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')\r
+\r
+//\r
+// Device structure used by driver\r
+//\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_HANDLE                  DriverBindingHandle;\r
+  EFI_HANDLE                  DebugPortDeviceHandle;\r
+  VOID                        *DebugPortVariable;\r
+\r
+  EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface;\r
+  EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface;\r
+  EFI_DEVICE_PATH_PROTOCOL    *DebugPortDevicePath;\r
+  EFI_DEBUGPORT_PROTOCOL      DebugPortInterface;\r
+\r
+  EFI_HANDLE                  SerialIoDeviceHandle;\r
+  EFI_SERIAL_IO_PROTOCOL      *SerialIoBinding;\r
+  UINT64                      BaudRate;\r
+  UINT32                      ReceiveFifoDepth;\r
+  UINT32                      Timeout;\r
+  EFI_PARITY_TYPE             Parity;\r
+  UINT8                       DataBits;\r
+  EFI_STOP_BITS_TYPE          StopBits;\r
+} DEBUGPORT_DEVICE;\r
+\r
+#define DEBUGPORT_DEVICE_FROM_THIS(a)     CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)\r
+\r
+#define EFI_ACPI_PC_COMPORT_HID           EISA_PNP_ID (0x0500)\r
+#define EFI_ACPI_16550UART_HID            EISA_PNP_ID (0x0501)\r
+\r
+#define DEBUGPORT_UART_DEFAULT_BAUDRATE   115200\r
+#define DEBUGPORT_UART_DEFAULT_PARITY     0\r
+#define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16\r
+#define DEBUGPORT_UART_DEFAULT_TIMEOUT    50000 // 5 ms\r
+#define DEBUGPORT_UART_DEFAULT_DATA_BITS  8\r
+#define DEBUGPORT_UART_DEFAULT_STOP_BITS  1\r
+\r
+#define DEBUGPORT_DRIVER_VERSION          1\r
+\r
+#define EfiIsUartDevicePath(dp)           (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)\r
+\r
+//\r
+// globals\r
+//\r
+extern DEBUGPORT_DEVICE *gDebugPortDevice;\r
+\r
+//\r
+// Driver binding interface functions...\r
+//\r
+EFI_STATUS\r
+DebugPortEntryPoint (\r
+  IN EFI_HANDLE                     ImageHandle,\r
+  IN EFI_SYSTEM_TABLE               *SystemTable\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN  EFI_HANDLE                     Controller,\r
+  IN  UINTN                          NumberOfChildren,\r
+  IN  EFI_HANDLE                     *ChildHandleBuffer\r
+  )\r
+;\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL   *This,\r
+  IN  CHAR8                         *Language,\r
+  OUT CHAR16                        **DriverName\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortComponentNameGetControllerName (\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
+//\r
+// DebugPort member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortReset (\r
+  IN EFI_DEBUGPORT_PROTOCOL         *This\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortRead (\r
+  IN EFI_DEBUGPORT_PROTOCOL         *This,\r
+  IN UINT32                         Timeout,\r
+  IN OUT UINTN                      *BufferSize,\r
+  IN VOID                           *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortWrite (\r
+  IN EFI_DEBUGPORT_PROTOCOL         *This,\r
+  IN UINT32                         Timeout,\r
+  IN OUT UINTN                      *BufferSize,\r
+  OUT VOID                          *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DebugPortPoll (\r
+  IN EFI_DEBUGPORT_PROTOCOL         *This\r
+  )\r
+;\r
+\r
+#endif\r