Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156603207
D11852.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D11852.diff
View Options
Index: head/sys/boot/efi/include/efi_driver_utils.h
===================================================================
--- head/sys/boot/efi/include/efi_driver_utils.h
+++ head/sys/boot/efi/include/efi_driver_utils.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2017 Eric McCorkle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _EFI_DRIVER_UTILS_H_
+#define _EFI_DRIVER_UTILS_H_
+
+#include <efi.h>
+#include <efiprot.h>
+
+extern EFI_STATUS install_driver(EFI_DRIVER_BINDING *driver);
+extern EFI_STATUS connect_controllers(EFI_GUID *filter);
+
+#endif
Index: head/sys/boot/efi/include/efi_drivers.h
===================================================================
--- head/sys/boot/efi/include/efi_drivers.h
+++ head/sys/boot/efi/include/efi_drivers.h
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2016 Eric McCorkle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _EFI_DRIVERS_H_
+#define _EFI_DRIVERS_H_
+
+#include <bootstrap.h>
+
+typedef struct efi_driver_t {
+ const char *name;
+ void (*init)(void);
+} efi_driver_t;
+
+extern struct devsw efipart_dev;
+extern int efipart_getdesc(struct devdesc *dev, char **out);
+
+/* EFI drivers. */
+extern const efi_driver_t fs_driver;
+
+#endif
Index: head/sys/boot/efi/include/efiprot.h
===================================================================
--- head/sys/boot/efi/include/efiprot.h
+++ head/sys/boot/efi/include/efiprot.h
@@ -27,6 +27,8 @@
--*/
+#include <efidef.h>
+
//
// Device Path protocol
//
@@ -554,5 +556,81 @@
CHAR8 *SupportedLanguages;
} EFI_UNICODE_COLLATION_INTERFACE;
+
+//
+// Driver Binding protocol
+//
+
+#define DRIVER_BINDING_PROTOCOL \
+ { 0x18a031ab, 0xb443, 0x4d1a, {0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71} }
+
+INTERFACE_DECL(_EFI_DRIVER_BINDING);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_SUPPORTED) (
+ IN struct _EFI_DRIVER_BINDING *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingPath
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_START) (
+ IN struct _EFI_DRIVER_BINDING *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingPath
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_STOP) (
+ IN struct _EFI_DRIVER_BINDING *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+typedef struct _EFI_DRIVER_BINDING {
+ EFI_DRIVER_BINDING_SUPPORTED Supported;
+ EFI_DRIVER_BINDING_START Start;
+ EFI_DRIVER_BINDING_STOP Stop;
+ UINT32 Version;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DriverBindingHandle;
+} EFI_DRIVER_BINDING;
+
+//
+// Component Name Protocol 2
+//
+
+#define COMPONENT_NAME2_PROTOCOL \
+ { 0x6a7a5cff, 0xe8d9, 0x4f70, {0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14 } }
+
+INTERFACE_DECL(_EFI_COMPONENT_NAME2);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) (
+ IN struct _EFI_COMPONENT_NAME2 *This,
+ IN CHAR8 * Language,
+ OUT CHAR16 **DriverName
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) (
+ IN struct _EFI_COMPONENT_NAME2 *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+typedef struct _EFI_COMPONENT_NAME2 {
+ EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName;
+ EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName;
+ CHAR8 **SupportedLanguages;
+} EFI_COMPONENT_NAME2;
#endif
Index: head/sys/boot/efi/libefi/Makefile
===================================================================
--- head/sys/boot/efi/libefi/Makefile
+++ head/sys/boot/efi/libefi/Makefile
@@ -12,7 +12,7 @@
WARNS?= 2
SRCS= delay.c devpath.c efi_console.c efinet.c efipart.c env.c errno.c \
- handles.c wchar.c libefi.c
+ handles.c wchar.c libefi.c efi_driver_utils.c
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
SRCS+= time.c
Index: head/sys/boot/efi/libefi/efi_driver_utils.c
===================================================================
--- head/sys/boot/efi/libefi/efi_driver_utils.c
+++ head/sys/boot/efi/libefi/efi_driver_utils.c
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2017 Eric McCorkle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdbool.h>
+
+#include <efi.h>
+#include <efilib.h>
+
+#include "efi_driver_utils.h"
+
+static EFI_GUID DriverBindingProtocolGUID = DRIVER_BINDING_PROTOCOL;
+
+EFI_STATUS
+connect_controllers(EFI_GUID *filter)
+{
+ EFI_STATUS status;
+ EFI_HANDLE *handles;
+ UINTN nhandles, i, hsize;
+
+ nhandles = 0;
+ hsize = 0;
+ status = BS->LocateHandle(ByProtocol, filter, NULL,
+ &hsize, NULL);
+
+ if(status != EFI_BUFFER_TOO_SMALL) {
+ return (status);
+ }
+
+ handles = malloc(hsize);
+ nhandles = hsize / sizeof(EFI_HANDLE);
+
+ status = BS->LocateHandle(ByProtocol, filter, NULL,
+ &hsize, handles);
+
+ if(EFI_ERROR(status)) {
+ return (status);
+ }
+
+ for(i = 0; i < nhandles; i++) {
+ BS->ConnectController(handles[i], NULL, NULL, true);
+ }
+
+ free(handles);
+
+ return (status);
+}
+
+EFI_STATUS
+install_driver(EFI_DRIVER_BINDING *driver)
+{
+ EFI_STATUS status;
+
+ driver->ImageHandle = IH;
+ driver->DriverBindingHandle = NULL;
+ status = BS->InstallMultipleProtocolInterfaces(
+ &(driver->DriverBindingHandle),
+ &DriverBindingProtocolGUID, driver,
+ NULL);
+
+ if (EFI_ERROR(status)) {
+ printf("Failed to install driver (%ld)!\n",
+ EFI_ERROR_CODE(status));
+ }
+
+ return (status);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 16, 1:19 AM (3 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33105261
Default Alt Text
D11852.diff (9 KB)
Attached To
Mode
D11852: Add definitions and utilities for EFI drivers
Attached
Detach File
Event Timeline
Log In to Comment