]> code.delx.au - refind/blob - refind/lib.h
Improved submenu and information menu appearance over a full-screen
[refind] / refind / lib.h
1 /*
2 * refit/lib.h
3 * General header file
4 *
5 * Copyright (c) 2006-2009 Christoph Pfisterer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
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
18 * distribution.
19 *
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.
23 *
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.
35 */
36 /*
37 * Modifications copyright (c) 2012 Roderick W. Smith
38 *
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.
42 *
43 */
44
45 #ifndef __LIB_H_
46 #define __LIB_H_
47
48 #ifdef __MAKEWITH_GNUEFI
49 #include "efi.h"
50 #include "efilib.h"
51 #else
52 #include "../include/tiano_includes.h"
53 #endif
54
55 #include "global.h"
56
57 #include "libeg.h"
58
59 //
60 // lib module
61 //
62
63 // types
64
65 typedef struct {
66 EFI_STATUS LastStatus;
67 EFI_FILE_HANDLE DirHandle;
68 BOOLEAN CloseDirHandle;
69 EFI_FILE_INFO *LastFileInfo;
70 } REFIT_DIR_ITER;
71
72 #define DISK_KIND_INTERNAL (0)
73 #define DISK_KIND_EXTERNAL (1)
74 #define DISK_KIND_OPTICAL (2)
75
76 #define VOL_DONTSCAN 998
77 #define VOL_UNREADABLE 999
78
79 #define IS_EXTENDED_PART_TYPE(type) ((type) == 0x05 || (type) == 0x0f || (type) == 0x85)
80
81 EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle);
82 VOID UninitRefitLib(VOID);
83 EFI_STATUS ReinitRefitLib(VOID);
84
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);
89
90 VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DEVICE_PATH **HardcodedPathList);
91
92 VOID ScanVolumes(VOID);
93
94 BOOLEAN FileExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath);
95 BOOLEAN DirectoryExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath);
96
97 EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, IN UINTN FilterMode);
98
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);
102
103 CHAR16 * Basename(IN CHAR16 *Path);
104 CHAR16 * StripEfiExtension(CHAR16 *FileName);
105
106 INTN FindMem(IN VOID *Buffer, IN UINTN BufferLength, IN VOID *SearchString, IN UINTN SearchStringLength);
107 VOID ReinitVolumes(VOID);
108
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);
120
121 BOOLEAN EjectMedia(VOID);
122
123 CHAR16 * GuidAsString(EFI_GUID *GuidData);
124
125 #endif