Home | History | Annotate | Line # | Download | only in efiboot
efiboot.h revision 1.21
      1 /*	$NetBSD: efiboot.h,v 1.21 2024/08/15 05:59:49 skrll Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2016 Kimihiro Nonaka <nonaka (at) netbsd.org>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #include <efi.h>
     30 #include <efilib.h>
     31 
     32 #include <lib/libsa/stand.h>
     33 #include <lib/libkern/libkern.h>
     34 
     35 #include <loadfile.h>
     36 #include <net.h>
     37 
     38 #include "efiboot_machdep.h"
     39 
     40 struct boot_command {
     41 	const char *c_name;
     42 	void (*c_fn)(char *);
     43 	const char *c_help;
     44 };
     45 
     46 /* conf.c */
     47 extern struct fs_ops null_fs_ops;
     48 extern struct fs_ops tftp_fs_ops;
     49 extern struct fs_ops nfs_fs_ops;
     50 
     51 /* boot.c */
     52 void boot(void);
     53 void clearit(void);
     54 extern const struct boot_command commands[];
     55 void command_help(char *);
     56 void command_printtab(const char *, const char *, ...);
     57 int set_default_device(const char *);
     58 char *get_default_device(void);
     59 void set_default_fstype(int);
     60 int get_default_fstype(void);
     61 int set_initrd_path(const char *);
     62 char *get_initrd_path(void);
     63 int set_dtb_path(const char *);
     64 char *get_dtb_path(void);
     65 int set_rndseed_path(const char *);
     66 char *get_rndseed_path(void);
     67 
     68 /* console.c */
     69 int ischar(void);
     70 
     71 /* efiboot.c */
     72 extern EFI_HANDLE IH;
     73 extern EFI_DEVICE_PATH *efi_bootdp;
     74 extern EFI_LOADED_IMAGE *efi_li;
     75 void efi_cleanup(void);
     76 void efi_exit(void);
     77 void efi_delay(int);
     78 void efi_reboot(void);
     79 void efi_progress(const char *, ...);
     80 extern int howto;
     81 
     82 /* efichar.c */
     83 size_t ucs2len(const CHAR16 *);
     84 int ucs2_to_utf8(const CHAR16 *, char **);
     85 int utf8_to_ucs2(const char *, CHAR16 **, size_t *);
     86 
     87 /* efidev.c */
     88 int efi_device_path_depth(EFI_DEVICE_PATH *, int);
     89 int efi_device_path_count(EFI_DEVICE_PATH *);
     90 int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int);
     91 
     92 /* efifdt.c */
     93 int efi_fdt_prepare_boot(const char *, const char *, u_long *);
     94 void efi_fdt_cleanup_boot(void);
     95 size_t efi_fdt_alloc_size(void);
     96 void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32);
     97 
     98 /* efinet.c */
     99 struct efi_net_if {
    100 	const char *if_name;
    101 	uint8_t if_mac[6];
    102 };
    103 int efi_net_open(struct open_file *, ...);
    104 void efi_net_probe(void);
    105 void efi_net_show(void);
    106 int efi_net_get_booted_interface_unit(void);
    107 int efi_net_get_booted_macaddr(uint8_t *);
    108 extern struct netif_driver efinetif;
    109 
    110 /* efipxe.c */
    111 void efi_pxe_probe(void);
    112 bool efi_pxe_match_booted_interface(const EFI_MAC_ADDRESS *, UINT32);
    113 
    114 /* efiwatchdog.c */
    115 void efi_set_watchdog(uint32_t, uint64_t);
    116 
    117 /* efigop.c */
    118 void efi_gop_probe(void);
    119 void efi_gop_show(void);
    120 void efi_gop_dump(void);
    121 void efi_gop_setmode(UINT32);
    122 
    123 /* exec.c */
    124 int load_file(const char *, u_long, bool, EFI_PHYSICAL_ADDRESS *, u_long *);
    125 int exec_netbsd(const char *, const char *);
    126 
    127 /* panic.c */
    128 __dead VOID Panic(IN CHAR16 *, ...);
    129 __dead void reboot(void);
    130 
    131 /* prompt.c */
    132 char *gettrailer(char *);
    133 void docommand(char *);
    134 char awaitkey(int, int);
    135 __dead void bootprompt(void);
    136 
    137 /* userconf.c */
    138 void userconf_add(const char *);
    139 void userconf_foreach(void (*)(const char *));
    140