xref: /dragonfly/stand/boot/efi/include/efilib.h (revision 655933d6)
1 /*-
2  * Copyright (c) 2000 Doug Rabson
3  * Copyright (c) 2006 Marcel Moolenaar
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD: head/sys/boot/efi/include/efilib.h 295869 2016-02-21 21:20:23Z andrew $
28  */
29 
30 #include <stand.h>
31 
32 extern EFI_HANDLE		IH;
33 extern EFI_SYSTEM_TABLE		*ST;
34 extern EFI_BOOT_SERVICES	*BS;
35 extern EFI_RUNTIME_SERVICES	*RS;
36 
37 extern struct devsw efipart_dev;
38 extern struct devsw efinet_dev;
39 extern struct netif_driver efinetif;
40 
41 struct efi_devdesc
42 {
43     struct devsw	*d_dev;
44     int			d_type;
45     union
46     {
47 	struct
48 	{
49 	    int		unit;
50 	    int		slice;
51 	    int		partition;
52 	    void	*data;
53 	    u_int64_t	label_offset;
54 	} efidisk;
55 	struct
56 	{
57 	    int		unit;
58 	    void	*data;
59 	} eficd;
60 	struct
61 	{
62 	    int		unit;		/* XXX net layer lives over these? */
63 	} netif;
64     } d_kind;
65 };
66 
67 void *efi_get_table(EFI_GUID *tbl);
68 
69 int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int);
70 EFI_HANDLE efi_find_handle(struct devsw *, int);
71 int efi_handle_lookup(EFI_HANDLE, struct devsw **, int *,  uint64_t *);
72 int efi_handle_update_dev(EFI_HANDLE, struct devsw *, int, uint64_t);
73 
74 int efi_status_to_errno(EFI_STATUS);
75 
76 EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table);
77 void efi_exit(EFI_STATUS status); /* should be __dead2 */
78 EFI_STATUS main(int argc, CHAR16 *argv[]);
79 void delay(int usecs);
80 
81 EFI_STATUS OpenProtocolByHandle(EFI_HANDLE, EFI_GUID *, void **);
82