1203181Smarcel/*- 2203181Smarcel * Copyright (c) 2010 Marcel Moolenaar 3203181Smarcel * All rights reserved. 4203181Smarcel * 5203181Smarcel * Redistribution and use in source and binary forms, with or without 6203181Smarcel * modification, are permitted provided that the following conditions 7203181Smarcel * are met: 8203181Smarcel * 1. Redistributions of source code must retain the above copyright 9203181Smarcel * notice, this list of conditions and the following disclaimer. 10203181Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11203181Smarcel * notice, this list of conditions and the following disclaimer in the 12203181Smarcel * documentation and/or other materials provided with the distribution. 13203181Smarcel * 14203181Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15203181Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16203181Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17203181Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18203181Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19203181Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20203181Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21203181Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22203181Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23203181Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24203181Smarcel * SUCH DAMAGE. 25203181Smarcel */ 26203181Smarcel 27203181Smarcel#include <sys/cdefs.h> 28203181Smarcel__FBSDID("$FreeBSD$"); 29203181Smarcel 30203181Smarcel#include <libefi.h> 31203181Smarcel#include <stdlib.h> 32203181Smarcel 33203181Smarcel#include "libefi_int.h" 34203181Smarcel 35203181Smarcel/* 36203181Smarcel * EFI_STATUS 37203181Smarcel * GetNextVariableName( 38203181Smarcel * IN OUT UINTN *VariableNameSize, 39203181Smarcel * IN OUT CHAR16 *VariableName, 40203181Smarcel * IN OUT EFI_GUID *VendorGuid 41203181Smarcel * ); 42203181Smarcel */ 43203181Smarcel 44203181Smarcelint 45203181Smarcelefi_nextvarname(size_t *namesize, char *name, uuid_t *vendor) 46203181Smarcel{ 47203181Smarcel struct iodev_efivar_req req; 48203181Smarcel int error; 49203181Smarcel 50203181Smarcel req.namesize = *namesize; 51203181Smarcel error = libefi_utf8_to_ucs2(name, &req.namesize, &req.name); 52203181Smarcel if (error) 53203181Smarcel return (error); 54203181Smarcel 55203181Smarcel req.vendor = *vendor; 56203181Smarcel req.access = IODEV_EFIVAR_NEXTNAME; 57203181Smarcel error = libefi_efivar(&req); 58203181Smarcel *namesize = req.namesize; 59203181Smarcel if (!error) { 60203181Smarcel error = libefi_ucs2_to_utf8(req.name, namesize, name); 61203181Smarcel if (!error) 62203181Smarcel *vendor = req.vendor; 63203181Smarcel } 64203181Smarcel free(req.name); 65203181Smarcel return (error); 66203181Smarcel} 67