From owner-svn-src-head@freebsd.org Fri Jun 15 19:07:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0F7F1018D6A; Fri, 15 Jun 2018 19:07:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 661807EBDF; Fri, 15 Jun 2018 19:07:32 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4EC961B866; Fri, 15 Jun 2018 19:07:32 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5FJ7WW7096197; Fri, 15 Jun 2018 19:07:32 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5FJ7W9Z096196; Fri, 15 Jun 2018 19:07:32 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201806151907.w5FJ7W9Z096196@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 15 Jun 2018 19:07:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335230 - head/stand/efi/loader X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/stand/efi/loader X-SVN-Commit-Revision: 335230 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 19:07:35 -0000 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);