2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
39 query_fpswa(VOID **fpswa)
41 EFI_HANDLE fpswa_image;
44 EFI_GUID FpswaProtocol = FPSWA_PROTOCOL;
46 DBG_PRT((L"Querying FpswaProtocol"));
48 size = sizeof(EFI_HANDLE);
50 status = BS->LocateHandle(ByProtocol, &FpswaProtocol, NULL, &size, &fpswa_image);
51 if (EFI_ERROR(status)) {
52 ERR_PRT((L"boot_params could not locate FPSWA driver", status));
55 status = BS->HandleProtocol(fpswa_image, &FpswaProtocol, fpswa);
56 if (EFI_ERROR(status)) {
57 ERR_PRT((L"boot_params FpswaProtocol not able find the interface"));
60 VERB_PRT(3, Print(L"FpswaProtocol = 0x%lx revision=%x\n", *fpswa,
61 ((fpswa_interface_t *)*fpswa)->revision));
67 do_check_fpswa(EFI_HANDLE image, EFI_HANDLE dev, CHAR16 *fpswa_file)
74 dp = FileDevicePath(dev, fpswa_file);
76 ERR_PRT((L"Cannot create FilePath for %s", fpswa_file));
79 status = BS->LoadImage(0, image, dp, NULL, 0, &handle);
80 if (EFI_ERROR(status)) {
81 VERB_PRT(3, Print(L"..not found\n"));
85 VERB_PRT(3, Print(L"..starting.."));
87 status = BS->StartImage(handle, 0, 0);
88 if (EFI_ERROR(status)) {
89 VERB_PRT(3, Print(L"failed (%r)\n", status));
91 * StartImage() automatically unloads if error
92 * FPSWA init code will automatically abort if newer revision
93 * is already installed
96 VERB_PRT(3, Print(L"..ok\n"));
104 * If the caller specifies a fpswa filename, then it used instead of the
107 * 0 : indicates that one fpswa driver was loaded, i.e. an update could be done
108 * -1: no update was found that would have a more recent version of the driver. This is
109 * not a fatal return value.
112 check_fpswa(EFI_HANDLE image, EFI_HANDLE dev, CHAR16 *fpswa_file)
115 * we must use \\ here as this is given to LoadImage() directly
117 * The FPSWA driver MUST be called fpswa.efi and the FPSWA document
118 * (see developer.intel.com/design/itanium) stipulates that the
119 * file must be placed in \EFI\Intel Firmware\ (no mention of which
120 * EFI system partition). So elilo will check on all accessible
121 * Fat32+ partition for the existence of this directory and file.
123 static CHAR16 *fpswa_filenames[] ={
124 L"\\efi\\intel firmware\\fpswa.efi",
129 L"\\efi\\tools\\fpswa.efi",
134 UINTN j, count = sizeof(fpswa_filenames)/sizeof(CHAR16 *);
136 CHAR16 devname[FILENAME_MAXLEN];
140 devname[0] = CHAR_NULL;
141 r = fops_split_path(fpswa_file, devname);
143 ERR_PRT((L"FPSWA driver filename too long %s", fpswa_file));
146 if (devname[0] != CHAR_NULL) {
147 if (fops_get_device_handle(devname, &dev) != EFI_SUCCESS) {
148 ERR_PRT((L"cannot find device %s for FPSWA driver", devname));
152 return do_check_fpswa(image, dev, fpswa_file);
156 while (fops_get_next_device(cookie, L"vfat", FILENAME_MAXLEN, &cookie, devname, &dev) == EFI_SUCCESS) {
157 for (j = 0; j < count; j++) {
158 VERB_PRT(3, Print(L"Trying FPSWA driver %s:%s..", devname, fpswa_filenames[j]));
160 * we need to do all choices to make sure we pickup
161 * the latest version.
163 do_check_fpswa(image, dev, fpswa_filenames[j]);