From owner-p4-projects Sun Dec 8 20:28:34 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 76B2E37B401; Sun, 8 Dec 2002 20:28:31 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D58C37B404 for ; Sun, 8 Dec 2002 20:28:31 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 164E743ED1 for ; Sun, 8 Dec 2002 20:28:29 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gB94NomV008086 for ; Sun, 8 Dec 2002 20:23:50 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gB94Nnnm008083 for perforce@freebsd.org; Sun, 8 Dec 2002 20:23:49 -0800 (PST) Date: Sun, 8 Dec 2002 20:23:49 -0800 (PST) Message-Id: <200212090423.gB94Nnnm008083@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 22096 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=22096 Change 22096 by marcel@marcel_nfs on 2002/12/08 20:22:56 Tune the argument handling: apparently, the EFI shell passes the command as the first word in the option string. This is like Unix, but unlike the EFI boot manager. Thus, we need a way to determine if we're run from the EFI shell so that we can avoid adding the program name. This, however, is not a trivial thing to get right. The current change will make most of the cases work. One particular case that we miss is a boot option that loads an EFI image from disk and has options (arguments). This looks pretty much like how the shell would call us. At this time the first argument will not be our program name. There's a bug in the HP EFI implementation: when a program is run from the shell prompt (ie Shell>), the option list has some garbage at the end. For example: Shell> fs0:\boot\loader The Itaniium shell does not allow this (read: has a bug that causes it to not find the program). Affected files ... .. //depot/projects/ia64/sys/boot/efi/libefi/libefi.c#4 edit Differences ... ==== //depot/projects/ia64/sys/boot/efi/libefi/libefi.c#4 (text+ko) ==== @@ -87,7 +87,7 @@ EFI_LOADED_IMAGE *img; CHAR16 *argp, *args, **argv; EFI_STATUS status; - int argc; + int argc, addprog; IH = image_handle; ST = system_table; @@ -137,9 +137,28 @@ * first count the number of words. Then, after allocating the * vector, we split the string up. We don't deal with quotes or * other more advanced shell features. + * The EFI shell will pas the name of the image as the first + * word in the argument list. This does not happen if we're + * loaded by the boot manager. This is not so easy to figure + * out though. The ParentHandle is not always NULL, because + * there can be a function (=image) that will perform the task + * for the boot manager. */ - /* Part 1: count words. */ - argc = 1; /* The EFI program name. */ + /* Part 1: Figure out if we need to add our program name. */ + addprog = (args == NULL || img->ParentHandle == NULL || + img->FilePath == NULL) ? 1 : 0; + if (!addprog) { + addprog = + (DevicePathType(img->FilePath) != MEDIA_DEVICE_PATH || + DevicePathSubType(img->FilePath) != MEDIA_FILEPATH_DP || + DevicePathNodeLength(img->FilePath) <= + sizeof(FILEPATH_DEVICE_PATH)) ? 1 : 0; + if (!addprog) { + /* XXX todo. */ + } + } + /* Part 2: count words. */ + argc = (addprog) ? 1 : 0; argp = args; while (argp != NULL && *argp != 0) { argp = arg_skipsep(argp); @@ -148,10 +167,11 @@ argc++; argp = arg_skipword(argp); } - /* Part 2: build vector. */ + /* Part 3: build vector. */ argv = malloc((argc + 1) * sizeof(CHAR16*)); - argv[0] = L"loader.efi"; /* XXX kludge. */ - argc = 1; + argc = 0; + if (addprog) + argv[argc++] = L"loader.efi"; argp = args; while (argp != NULL && *argp != 0) { argp = arg_skipsep(argp); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message