5 * Copyright (c) 2006-2009 Christoph Pfisterer
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
20 * * Neither the name of Christoph Pfisterer nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Modifications copyright (c) 2012 Roderick W. Smith
39 * Modifications distributed under the terms of the GNU General Public
40 * License (GPL) version 3 (GPLv3), a copy of which must be distributed
41 * with this source code or binaries made from it.
48 #ifdef __MAKEWITH_GNUEFI
52 #include "../include/tiano_includes.h"
66 EFI_STATUS LastStatus
;
67 EFI_FILE_HANDLE DirHandle
;
68 BOOLEAN CloseDirHandle
;
69 EFI_FILE_INFO
*LastFileInfo
;
72 #define DISK_KIND_INTERNAL (0)
73 #define DISK_KIND_EXTERNAL (1)
74 #define DISK_KIND_OPTICAL (2)
76 #define VOL_DONTSCAN 998
77 #define VOL_UNREADABLE 999
79 #define IS_EXTENDED_PART_TYPE(type) ((type) == 0x05 || (type) == 0x0f || (type) == 0x85)
81 EFI_STATUS
InitRefitLib(IN EFI_HANDLE ImageHandle
);
82 VOID
UninitRefitLib(VOID
);
83 EFI_STATUS
ReinitRefitLib(VOID
);
85 VOID
CleanUpPathNameSlashes(IN OUT CHAR16
*PathName
);
86 VOID
CreateList(OUT VOID
***ListPtr
, OUT UINTN
*ElementCount
, IN UINTN InitialElementCount
);
87 VOID
AddListElement(IN OUT VOID
***ListPtr
, IN OUT UINTN
*ElementCount
, IN VOID
*NewElement
);
88 VOID
FreeList(IN OUT VOID
***ListPtr
, IN OUT UINTN
*ElementCount
);
90 VOID
ExtractLegacyLoaderPaths(EFI_DEVICE_PATH
**PathList
, UINTN MaxPaths
, EFI_DEVICE_PATH
**HardcodedPathList
);
92 VOID
ScanVolumes(VOID
);
94 BOOLEAN
FileExists(IN EFI_FILE
*BaseDir
, IN CHAR16
*RelativePath
);
95 BOOLEAN
DirectoryExists(IN EFI_FILE
*BaseDir
, IN CHAR16
*RelativePath
);
97 EFI_STATUS
DirNextEntry(IN EFI_FILE
*Directory
, IN OUT EFI_FILE_INFO
**DirEntry
, IN UINTN FilterMode
);
99 VOID
DirIterOpen(IN EFI_FILE
*BaseDir
, IN CHAR16
*RelativePath OPTIONAL
, OUT REFIT_DIR_ITER
*DirIter
);
100 BOOLEAN
DirIterNext(IN OUT REFIT_DIR_ITER
*DirIter
, IN UINTN FilterMode
, IN CHAR16
*FilePattern OPTIONAL
, OUT EFI_FILE_INFO
**DirEntry
);
101 EFI_STATUS
DirIterClose(IN OUT REFIT_DIR_ITER
*DirIter
);
103 CHAR16
* Basename(IN CHAR16
*Path
);
104 CHAR16
* StripEfiExtension(CHAR16
*FileName
);
106 INTN
FindMem(IN VOID
*Buffer
, IN UINTN BufferLength
, IN VOID
*SearchString
, IN UINTN SearchStringLength
);
107 VOID
ReinitVolumes(VOID
);
109 BOOLEAN
StriSubCmp(IN CHAR16
*TargetStr
, IN CHAR16
*BigStr
);
110 VOID
MergeStrings(IN OUT CHAR16
**First
, IN CHAR16
*Second
, CHAR16 AddChar
);
111 CHAR16
*FindExtension(IN CHAR16
*Path
);
112 CHAR16
*FindLastDirName(IN CHAR16
*Path
);
113 CHAR16
*FindPath(IN CHAR16
* FullPath
);
114 VOID
FindVolumeAndFilename(IN EFI_DEVICE_PATH
*loadpath
, OUT REFIT_VOLUME
**DeviceVolume
, OUT CHAR16
**loader
);
115 BOOLEAN
SplitVolumeAndFilename(IN OUT CHAR16
**Path
, OUT CHAR16
**VolName
);
116 CHAR16
*FindNumbers(IN CHAR16
*InString
);
117 CHAR16
*FindCommaDelimited(IN CHAR16
*InString
, IN UINTN Index
);
118 BOOLEAN
IsIn(IN CHAR16
*SmallString
, IN CHAR16
*List
);
119 VOID
MyFreePool(IN OUT VOID
*Pointer
);
121 BOOLEAN
EjectMedia(VOID
);
123 CHAR16
* GuidAsString(EFI_GUID
*GuidData
);