From owner-svn-src-projects@FreeBSD.ORG Wed Feb 27 04:50:28 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E3D7A24F; Wed, 27 Feb 2013 04:50:28 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D0F2E930; Wed, 27 Feb 2013 04:50:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1R4oSAf006861; Wed, 27 Feb 2013 04:50:28 GMT (envelope-from benno@svn.freebsd.org) Received: (from benno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1R4oSnP006858; Wed, 27 Feb 2013 04:50:28 GMT (envelope-from benno@svn.freebsd.org) Message-Id: <201302270450.r1R4oSnP006858@svn.freebsd.org> From: Benno Rice Date: Wed, 27 Feb 2013 04:50:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r247378 - in projects/uefi/sys/boot/efi: include libefi X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2013 04:50:29 -0000 Author: benno Date: Wed Feb 27 04:50:27 2013 New Revision: 247378 URL: http://svnweb.freebsd.org/changeset/base/247378 Log: Add the ability for a device to have an "alias" handle. Modified: projects/uefi/sys/boot/efi/include/efilib.h projects/uefi/sys/boot/efi/libefi/efipart.c projects/uefi/sys/boot/efi/libefi/handles.c Modified: projects/uefi/sys/boot/efi/include/efilib.h ============================================================================== --- projects/uefi/sys/boot/efi/include/efilib.h Wed Feb 27 04:44:48 2013 (r247377) +++ projects/uefi/sys/boot/efi/include/efilib.h Wed Feb 27 04:50:27 2013 (r247378) @@ -41,7 +41,7 @@ extern struct netif_driver efinetif; void *efi_get_table(EFI_GUID *tbl); void efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table); -int efi_register_handles(struct devsw *, EFI_HANDLE *, int); +int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int); EFI_HANDLE efi_find_handle(struct devsw *, int); int efi_handle_lookup(EFI_HANDLE, struct devsw **, int *); Modified: projects/uefi/sys/boot/efi/libefi/efipart.c ============================================================================== --- projects/uefi/sys/boot/efi/libefi/efipart.c Wed Feb 27 04:44:48 2013 (r247377) +++ projects/uefi/sys/boot/efi/libefi/efipart.c Wed Feb 27 04:50:27 2013 (r247378) @@ -62,7 +62,7 @@ static int efipart_init(void) { EFI_BLOCK_IO *blkio; - EFI_HANDLE *hin, *hout; + EFI_HANDLE *hin, *hout, *aliases; EFI_STATUS status; UINTN sz; u_int n, nin, nout; @@ -72,7 +72,7 @@ efipart_init(void) hin = NULL; status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, 0); if (status == EFI_BUFFER_TOO_SMALL) { - hin = (EFI_HANDLE *)malloc(sz * 2); + hin = (EFI_HANDLE *)malloc(sz * 3); status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin); if (EFI_ERROR(status)) @@ -84,8 +84,11 @@ efipart_init(void) /* Filter handles to only include FreeBSD partitions. */ nin = sz / sizeof(EFI_HANDLE); hout = hin + nin; + aliases = hout + nin; nout = 0; + bzero(aliases, nin * sizeof(EFI_HANDLE)); + for (n = 0; n < nin; n++) { status = BS->HandleProtocol(hin[n], &blkio_guid, &blkio); if (EFI_ERROR(status)) @@ -96,7 +99,7 @@ efipart_init(void) nout++; } - err = efi_register_handles(&efipart_dev, hout, nout); + err = efi_register_handles(&efipart_dev, hout, aliases, nout); free(hin); return (err); } Modified: projects/uefi/sys/boot/efi/libefi/handles.c ============================================================================== --- projects/uefi/sys/boot/efi/libefi/handles.c Wed Feb 27 04:44:48 2013 (r247377) +++ projects/uefi/sys/boot/efi/libefi/handles.c Wed Feb 27 04:50:27 2013 (r247378) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); struct entry { EFI_HANDLE handle; + EFI_HANDLE alias; struct devsw *dev; int unit; }; @@ -40,7 +41,8 @@ struct entry *entry; int nentries; int -efi_register_handles(struct devsw *sw, EFI_HANDLE *handles, int count) +efi_register_handles(struct devsw *sw, EFI_HANDLE *handles, + EFI_HANDLE *aliases, int count) { size_t sz; int idx, unit; @@ -51,6 +53,7 @@ efi_register_handles(struct devsw *sw, E entry = (entry == NULL) ? malloc(sz) : realloc(entry, sz); for (unit = 0; idx < nentries; idx++, unit++) { entry[idx].handle = handles[unit]; + entry[idx].alias = aliases[unit]; entry[idx].dev = sw; entry[idx].unit = unit; } @@ -78,7 +81,7 @@ efi_handle_lookup(EFI_HANDLE h, struct d int idx; for (idx = 0; idx < nentries; idx++) { - if (entry[idx].handle != h) + if (entry[idx].handle != h && entry[idx].alias != h) continue; if (dev != NULL) *dev = entry[idx].dev;