]> code.delx.au - refind/blob - refind/lib.h
17af8bd21e0fa7addcf156ebcf64d2cb40db68ce
[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 #include "efi.h"
49 #include "efilib.h"
50
51 #include "libeg.h"
52
53 //
54 // lib module
55 //
56
57 // types
58
59 typedef struct {
60 EFI_STATUS LastStatus;
61 EFI_FILE_HANDLE DirHandle;
62 BOOLEAN CloseDirHandle;
63 EFI_FILE_INFO *LastFileInfo;
64 } REFIT_DIR_ITER;
65
66 #define DISK_KIND_INTERNAL (0)
67 #define DISK_KIND_EXTERNAL (1)
68 #define DISK_KIND_OPTICAL (2)
69
70 #define IS_EXTENDED_PART_TYPE(type) ((type) == 0x05 || (type) == 0x0f || (type) == 0x85)
71
72 EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle);
73 VOID UninitRefitLib(VOID);
74 EFI_STATUS ReinitRefitLib(VOID);
75
76 VOID CleanUpPathNameSlashes(IN OUT CHAR16 *PathName);
77 VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount);
78 VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement);
79 VOID FreeList(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount);
80
81 VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DEVICE_PATH **HardcodedPathList);
82
83 VOID ScanVolumes(VOID);
84
85 BOOLEAN FileExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath);
86 BOOLEAN DirectoryExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath);
87
88 EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, IN UINTN FilterMode);
89
90 VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath OPTIONAL, OUT REFIT_DIR_ITER *DirIter);
91 BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL, OUT EFI_FILE_INFO **DirEntry);
92 EFI_STATUS DirIterClose(IN OUT REFIT_DIR_ITER *DirIter);
93
94 CHAR16 * Basename(IN CHAR16 *Path);
95 VOID ReplaceEfiExtension(IN OUT CHAR16 *Path, IN CHAR16 *Extension);
96
97 INTN FindMem(IN VOID *Buffer, IN UINTN BufferLength, IN VOID *SearchString, IN UINTN SearchStringLength);
98 VOID ReinitVolumes(VOID);
99
100 BOOLEAN StriSubCmp(IN CHAR16 *TargetStr, IN CHAR16 *BigStr);
101 VOID MergeStrings(IN OUT CHAR16 **First, IN CHAR16 *Second, CHAR16 AddChar);
102 CHAR16 *FindExtension(IN CHAR16 *Path);
103 CHAR16 *FindLastDirName(IN CHAR16 *Path);
104 CHAR16 *FindPath(IN CHAR16* FullPath);
105 CHAR16 *FindNumbers(IN CHAR16 *InString);
106 CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index);
107 BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List);
108
109 BOOLEAN EjectMedia(VOID);
110
111 #endif