Deleted Added
full compact
main.c (332128) main.c (332154)
1/*-
2 * Copyright (c) 2008-2010 Rui Paulo
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:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008-2010 Rui Paulo
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:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: stable/11/stand/efi/loader/main.c 332128 2018-04-06 18:40:24Z kevans $");
29__FBSDID("$FreeBSD: stable/11/stand/efi/loader/main.c 332154 2018-04-06 21:37:25Z kevans $");
30
31#include <sys/disk.h>
32#include <sys/param.h>
33#include <sys/reboot.h>
34#include <sys/boot.h>
35#include <stdint.h>
36#include <stand.h>
37#include <string.h>

--- 132 unchanged lines hidden (view full) ---

170
171static void
172set_devdesc_currdev(struct devsw *dev, int unit)
173{
174 struct devdesc currdev;
175 char *devname;
176
177 currdev.d_dev = dev;
30
31#include <sys/disk.h>
32#include <sys/param.h>
33#include <sys/reboot.h>
34#include <sys/boot.h>
35#include <stdint.h>
36#include <stand.h>
37#include <string.h>

--- 132 unchanged lines hidden (view full) ---

170
171static void
172set_devdesc_currdev(struct devsw *dev, int unit)
173{
174 struct devdesc currdev;
175 char *devname;
176
177 currdev.d_dev = dev;
178 currdev.d_type = currdev.d_dev->dv_type;
179 currdev.d_unit = unit;
178 currdev.d_unit = unit;
180 currdev.d_opendata = NULL;
181 devname = efi_fmtdev(&currdev);
182
183 env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
184 env_nounset);
185 env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset);
186}
187
188static int

--- 8 unchanged lines hidden (view full) ---

197 int unit;
198 uint64_t extra;
199
200#ifdef EFI_ZFS_BOOT
201 /* Did efi_zfs_probe() detect the boot pool? */
202 if (pool_guid != 0) {
203 struct zfs_devdesc currdev;
204
179 devname = efi_fmtdev(&currdev);
180
181 env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
182 env_nounset);
183 env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset);
184}
185
186static int

--- 8 unchanged lines hidden (view full) ---

195 int unit;
196 uint64_t extra;
197
198#ifdef EFI_ZFS_BOOT
199 /* Did efi_zfs_probe() detect the boot pool? */
200 if (pool_guid != 0) {
201 struct zfs_devdesc currdev;
202
205 currdev.d_dev = &zfs_dev;
206 currdev.d_unit = 0;
207 currdev.d_type = currdev.d_dev->dv_type;
208 currdev.d_opendata = NULL;
203 currdev.dd.d_dev = &zfs_dev;
204 currdev.dd.d_unit = 0;
209 currdev.pool_guid = pool_guid;
210 currdev.root_guid = 0;
211 devname = efi_fmtdev(&currdev);
212
213 env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
214 env_nounset);
215 env_setenv("loaddev", EV_VOLATILE, devname, env_noset,
216 env_nounset);
217 init_zfs_bootenv(devname);
218 return (0);
219 }
220#endif /* EFI_ZFS_BOOT */
221
222 /* We have device lists for hd, cd, fd, walk them all. */
223 pdi_list = efiblk_get_pdinfo_list(&efipart_hddev);
224 STAILQ_FOREACH(dp, pdi_list, pd_link) {
225 struct disk_devdesc currdev;
226
205 currdev.pool_guid = pool_guid;
206 currdev.root_guid = 0;
207 devname = efi_fmtdev(&currdev);
208
209 env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
210 env_nounset);
211 env_setenv("loaddev", EV_VOLATILE, devname, env_noset,
212 env_nounset);
213 init_zfs_bootenv(devname);
214 return (0);
215 }
216#endif /* EFI_ZFS_BOOT */
217
218 /* We have device lists for hd, cd, fd, walk them all. */
219 pdi_list = efiblk_get_pdinfo_list(&efipart_hddev);
220 STAILQ_FOREACH(dp, pdi_list, pd_link) {
221 struct disk_devdesc currdev;
222
227 currdev.d_dev = &efipart_hddev;
228 currdev.d_type = currdev.d_dev->dv_type;
229 currdev.d_unit = dp->pd_unit;
230 currdev.d_opendata = NULL;
223 currdev.dd.d_dev = &efipart_hddev;
224 currdev.dd.d_unit = dp->pd_unit;
231 currdev.d_slice = -1;
232 currdev.d_partition = -1;
233
234 if (dp->pd_handle == img->DeviceHandle) {
235 devname = efi_fmtdev(&currdev);
236
237 env_setenv("currdev", EV_VOLATILE, devname,
238 efi_setcurrdev, env_nounset);

--- 74 unchanged lines hidden (view full) ---

313EFI_STATUS
314main(int argc, CHAR16 *argv[])
315{
316 char var[128];
317 EFI_GUID *guid;
318 int i, j, vargood, howto;
319 UINTN k;
320 int has_kbd;
225 currdev.d_slice = -1;
226 currdev.d_partition = -1;
227
228 if (dp->pd_handle == img->DeviceHandle) {
229 devname = efi_fmtdev(&currdev);
230
231 env_setenv("currdev", EV_VOLATILE, devname,
232 efi_setcurrdev, env_nounset);

--- 74 unchanged lines hidden (view full) ---

307EFI_STATUS
308main(int argc, CHAR16 *argv[])
309{
310 char var[128];
311 EFI_GUID *guid;
312 int i, j, vargood, howto;
313 UINTN k;
314 int has_kbd;
315 CHAR16 *text;
316 UINT16 boot_current;
317 size_t sz;
318 UINT16 boot_order[100];
319 EFI_DEVICE_PATH *imgpath;
320 EFI_STATUS status;
321#if !defined(__arm__)
322 char buf[40];
323#endif
324
325 archsw.arch_autoload = efi_autoload;
326 archsw.arch_getdev = efi_getdev;
327 archsw.arch_copyin = efi_copyin;
328 archsw.arch_copyout = efi_copyout;

--- 145 unchanged lines hidden (view full) ---

474 printf("Image base: 0x%lx\n", (u_long)img->ImageBase);
475 printf("EFI version: %d.%02d\n", ST->Hdr.Revision >> 16,
476 ST->Hdr.Revision & 0xffff);
477 printf("EFI Firmware: %S (rev %d.%02d)\n", ST->FirmwareVendor,
478 ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
479
480 printf("\n%s", bootprog_info);
481
321#if !defined(__arm__)
322 char buf[40];
323#endif
324
325 archsw.arch_autoload = efi_autoload;
326 archsw.arch_getdev = efi_getdev;
327 archsw.arch_copyin = efi_copyin;
328 archsw.arch_copyout = efi_copyout;

--- 145 unchanged lines hidden (view full) ---

474 printf("Image base: 0x%lx\n", (u_long)img->ImageBase);
475 printf("EFI version: %d.%02d\n", ST->Hdr.Revision >> 16,
476 ST->Hdr.Revision & 0xffff);
477 printf("EFI Firmware: %S (rev %d.%02d)\n", ST->FirmwareVendor,
478 ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
479
480 printf("\n%s", bootprog_info);
481
482 text = efi_devpath_name(img->FilePath);
483 if (text != NULL) {
484 printf(" Load Path: %S\n", text);
485 efi_setenv_freebsd_wcs("LoaderPath", text);
486 efi_free_devpath_name(text);
487 }
488
489 status = BS->HandleProtocol(img->DeviceHandle, &devid, (void **)&imgpath);
490 if (status == EFI_SUCCESS) {
491 text = efi_devpath_name(imgpath);
492 if (text != NULL) {
493 printf(" Load Device: %S\n", text);
494 efi_setenv_freebsd_wcs("LoaderDev", text);
495 efi_free_devpath_name(text);
496 }
497 }
498
499 boot_current = 0;
500 sz = sizeof(boot_current);
501 efi_global_getenv("BootCurrent", &boot_current, &sz);
502 printf(" BootCurrent: %04x\n", boot_current);
503
504 sz = sizeof(boot_order);
505 efi_global_getenv("BootOrder", &boot_order, &sz);
506 printf(" BootOrder:");
507 for (i = 0; i < sz / sizeof(boot_order[0]); i++)
508 printf(" %04x%s", boot_order[i],
509 boot_order[i] == boot_current ? "[*]" : "");
510 printf("\n");
511
482 /*
483 * Disable the watchdog timer. By default the boot manager sets
484 * the timer to 5 minutes before invoking a boot option. If we
485 * want to return to the boot manager, we have to disable the
486 * watchdog timer and since we're an interactive program, we don't
487 * want to wait until the user types "quit". The timer may have
488 * fired by then. We don't care if this fails. It does not prevent
489 * normal functioning in any way...

--- 353 unchanged lines hidden (view full) ---

843
844 if (efi_getdev((void **)&dev, name, (const char **)&path) == 0) {
845#ifdef EFI_ZFS_BOOT
846 struct zfs_devdesc *z_dev;
847#endif
848 struct disk_devdesc *d_dev;
849 pdinfo_t *hd, *pd;
850
512 /*
513 * Disable the watchdog timer. By default the boot manager sets
514 * the timer to 5 minutes before invoking a boot option. If we
515 * want to return to the boot manager, we have to disable the
516 * watchdog timer and since we're an interactive program, we don't
517 * want to wait until the user types "quit". The timer may have
518 * fired by then. We don't care if this fails. It does not prevent
519 * normal functioning in any way...

--- 353 unchanged lines hidden (view full) ---

873
874 if (efi_getdev((void **)&dev, name, (const char **)&path) == 0) {
875#ifdef EFI_ZFS_BOOT
876 struct zfs_devdesc *z_dev;
877#endif
878 struct disk_devdesc *d_dev;
879 pdinfo_t *hd, *pd;
880
851 switch (dev->d_type) {
881 switch (dev->d_dev->dv_type) {
852#ifdef EFI_ZFS_BOOT
853 case DEVT_ZFS:
854 z_dev = (struct zfs_devdesc *)dev;
855 loaded_image->DeviceHandle =
856 efizfs_get_handle_by_guid(z_dev->pool_guid);
857 break;
858#endif
859 case DEVT_NET:

--- 38 unchanged lines hidden ---
882#ifdef EFI_ZFS_BOOT
883 case DEVT_ZFS:
884 z_dev = (struct zfs_devdesc *)dev;
885 loaded_image->DeviceHandle =
886 efizfs_get_handle_by_guid(z_dev->pool_guid);
887 break;
888#endif
889 case DEVT_NET:

--- 38 unchanged lines hidden ---