Date: Fri, 15 Jun 2018 19:07:32 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335230 - head/stand/efi/loader Message-ID: <201806151907.w5FJ7W9Z096196@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Fri Jun 15 19:07:31 2018 New Revision: 335230 URL: https://svnweb.freebsd.org/changeset/base/335230 Log: Move arg parsing into its own routine for possible later reuse. Modified: head/stand/efi/loader/main.c Modified: head/stand/efi/loader/main.c ============================================================================== --- head/stand/efi/loader/main.c Fri Jun 15 19:07:26 2018 (r335229) +++ head/stand/efi/loader/main.c Fri Jun 15 19:07:31 2018 (r335230) @@ -397,63 +397,14 @@ interactive_interrupt(const char *msg) return (false); } -EFI_STATUS -main(int argc, CHAR16 *argv[]) +int +parse_args(int argc, CHAR16 *argv[], bool has_kbd) { - char var[128]; - EFI_GUID *guid; int i, j, howto; bool vargood; - UINTN k; - bool has_kbd; - char *s; - EFI_DEVICE_PATH *imgpath; - CHAR16 *text; - EFI_STATUS status; - UINT16 boot_current; - size_t sz; - UINT16 boot_order[100]; - EFI_LOADED_IMAGE *img; -#if !defined(__arm__) - char buf[40]; -#endif + char var[128]; - archsw.arch_autoload = efi_autoload; - archsw.arch_getdev = efi_getdev; - archsw.arch_copyin = efi_copyin; - archsw.arch_copyout = efi_copyout; - archsw.arch_readin = efi_readin; -#ifdef EFI_ZFS_BOOT - /* Note this needs to be set before ZFS init. */ - archsw.arch_zfs_probe = efi_zfs_probe; -#endif - - /* Get our loaded image protocol interface structure. */ - BS->HandleProtocol(IH, &imgid, (VOID**)&img); - -#ifdef EFI_ZFS_BOOT - /* Tell ZFS probe code where we booted from */ - efizfs_set_preferred(img->DeviceHandle); -#endif - /* Init the time source */ - efi_time_init(); - - has_kbd = has_keyboard(); - /* - * XXX Chicken-and-egg problem; we want to have console output - * early, but some console attributes may depend on reading from - * eg. the boot device, which we can't do yet. We can use - * printf() etc. once this is done. - */ - cons_probe(); - - /* - * Initialise the block cache. Set the upper limit. - */ - bcache_init(32768, 512); - - /* * Parse the args to set the console settings, etc * boot1.efi passes these in, if it can read /boot.config or /boot/config * or iPXE may be setup to pass these in. Or the optional argument in the @@ -541,6 +492,65 @@ main(int argc, CHAR16 *argv[]) } } } + return (howto); +} + + +EFI_STATUS +main(int argc, CHAR16 *argv[]) +{ + EFI_GUID *guid; + int howto, i; + UINTN k; + bool has_kbd; + char *s; + EFI_DEVICE_PATH *imgpath; + CHAR16 *text; + EFI_STATUS status; + UINT16 boot_current; + size_t sz; + UINT16 boot_order[100]; + EFI_LOADED_IMAGE *img; +#if !defined(__arm__) + char buf[40]; +#endif + + archsw.arch_autoload = efi_autoload; + archsw.arch_getdev = efi_getdev; + archsw.arch_copyin = efi_copyin; + archsw.arch_copyout = efi_copyout; + archsw.arch_readin = efi_readin; +#ifdef EFI_ZFS_BOOT + /* Note this needs to be set before ZFS init. */ + archsw.arch_zfs_probe = efi_zfs_probe; +#endif + + /* Get our loaded image protocol interface structure. */ + BS->HandleProtocol(IH, &imgid, (VOID**)&img); + +#ifdef EFI_ZFS_BOOT + /* Tell ZFS probe code where we booted from */ + efizfs_set_preferred(img->DeviceHandle); +#endif + /* Init the time source */ + efi_time_init(); + + has_kbd = has_keyboard(); + + /* + * XXX Chicken-and-egg problem; we want to have console output + * early, but some console attributes may depend on reading from + * eg. the boot device, which we can't do yet. We can use + * printf() etc. once this is done. + */ + cons_probe(); + + /* + * Initialise the block cache. Set the upper limit. + */ + bcache_init(32768, 512); + + howto = parse_args(argc, argv, has_kbd); bootenv_set(howto);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806151907.w5FJ7W9Z096196>