OpenCore.h 6.8 KB
Newer Older
V
vit9696 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/** @file
  Copyright (C) 2018, vit9696. All rights reserved.

  All rights reserved.

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/

#ifndef OPEN_CORE_H
#define OPEN_CORE_H

V
vit9696 已提交
18
#include <Library/OcBootManagementLib.h>
19
#include <Library/OcConfigurationLib.h>
V
vit9696 已提交
20
#include <Library/OcCpuLib.h>
V
vit9696 已提交
21
#include <Library/OcCryptoLib.h>
V
vit9696 已提交
22
#include <Library/OcGuardLib.h>
23
#include <Library/OcMiscLib.h>
V
vit9696 已提交
24
#include <Library/OcStringLib.h>
25
#include <Library/OcStorageLib.h>
V
vit9696 已提交
26

V
vit9696 已提交
27 28
#include <Protocol/OcBootstrap.h>

V
vit9696 已提交
29 30 31 32
/**
  OpenCore version reported to log and NVRAM.
  OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits.
**/
A
Andrey1970AppleLife 已提交
33
#define OPEN_CORE_VERSION          "0.5.9"
V
vit9696 已提交
34 35 36 37

/**
  OpenCore build type reported to log and NVRAM.
**/
38
#if defined (OC_TARGET_RELEASE)
V
vit9696 已提交
39
#define OPEN_CORE_TARGET           "REL" ///< Release.
40
#elif defined (OC_TARGET_DEBUG)
V
vit9696 已提交
41
#define OPEN_CORE_TARGET           "DBG" ///< Debug with compiler optimisations.
42
#elif defined (OC_TARGET_NOOPT)
V
vit9696 已提交
43 44
#define OPEN_CORE_TARGET           "NPT" ///< Debug with no compiler optimisations.
#else
45
#error "Unknown target definition"
V
vit9696 已提交
46
#endif
V
vit9696 已提交
47

48
#define OPEN_CORE_BOOTSTRAP_PATH   L"EFI\\OC\\Bootstrap\\Bootstrap.efi"
49

V
vit9696 已提交
50
#define OPEN_CORE_DRIVER_PATH      L"EFI\\OC\\OpenCore.efi"
V
vit9696 已提交
51

52
#define OPEN_CORE_ROOT_PATH        L"EFI\\OC"
53 54 55

#define OPEN_CORE_CONFIG_PATH      L"config.plist"

56
#define OPEN_CORE_LOG_PREFIX_PATH  L"opencore"
V
vit9696 已提交
57

58 59
#define OPEN_CORE_NVRAM_PATH       L"nvram.plist"

60
#define OPEN_CORE_ACPI_PATH        L"ACPI\\"
61

62 63
#define OPEN_CORE_UEFI_DRIVER_PATH L"Drivers\\"

V
vit9696 已提交
64 65
#define OPEN_CORE_KEXT_PATH        L"Kexts\\"

V
vit9696 已提交
66 67
#define OPEN_CORE_TOOL_PATH        L"Tools\\"

68 69
#define OPEN_CORE_NVRAM_ATTR       (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)

70 71
#define OPEN_CORE_NVRAM_NV_ATTR    (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)

72 73
#define OPEN_CORE_INT_NVRAM_ATTR   EFI_VARIABLE_BOOTSERVICE_ACCESS

V
vit9696 已提交
74 75 76 77 78 79 80
/**
  Obtain cryptographic key if it was installed.

  @param[in]  Bootstrap  bootstrap protocol.

  @return public key or NULL.
**/
81
OC_RSA_PUBLIC_KEY *
V
vit9696 已提交
82 83 84 85
OcGetVaultKey (
  IN  OC_BOOTSTRAP_PROTOCOL *Bootstrap
  );

86 87 88 89 90 91 92 93 94 95 96 97
/**
  Load ACPI compatibility support like custom tables.

  @param[in]  Storage   OpenCore storage.
  @param[in]  Config    OpenCore configuration.
**/
VOID
OcLoadAcpiSupport (
  IN OC_STORAGE_CONTEXT  *Storage,
  IN OC_GLOBAL_CONFIG    *Config
  );

V
vit9696 已提交
98 99 100 101 102 103 104 105 106 107
/**
  Load device properties compatibility support.

  @param[in]  Config    OpenCore configuration.
**/
VOID
OcLoadDevPropsSupport (
  IN OC_GLOBAL_CONFIG    *Config
  );

V
vit9696 已提交
108 109 110 111 112
/**
  Load Kernel compatibility support like kexts.

  @param[in]  Storage   OpenCore storage.
  @param[in]  Config    OpenCore configuration.
113
  @param[in]  CpuInfo   CPU information.
V
vit9696 已提交
114 115 116 117
**/
VOID
OcLoadKernelSupport (
  IN OC_STORAGE_CONTEXT  *Storage,
118 119
  IN OC_GLOBAL_CONFIG    *Config,
  IN OC_CPU_INFO         *CpuInfo
V
vit9696 已提交
120 121 122 123 124 125 126 127 128
  );

/**
  Cleanup Kernel compatibility support on failure.
**/
VOID
OcUnloadKernelSupport (
  VOID
  );
129

V
vit9696 已提交
130 131 132
/**
  Load NVRAM compatibility support.

133
  @param[in]  Storage   OpenCore storage.
V
vit9696 已提交
134 135 136 137
  @param[in]  Config    OpenCore configuration.
**/
VOID
OcLoadNvramSupport (
138
  IN OC_STORAGE_CONTEXT  *Storage,
V
vit9696 已提交
139 140 141
  IN OC_GLOBAL_CONFIG    *Config
  );

142 143 144 145 146 147 148 149 150 151 152 153
/**
  Load platform compatibility support like DataHub or SMBIOS.

  @param[in]  Config    OpenCore configuration.
  @param[in]  CpuInfo   CPU information.
**/
VOID
OcLoadPlatformSupport (
  IN OC_GLOBAL_CONFIG    *Config,
  IN OC_CPU_INFO         *CpuInfo
  );

154 155 156 157 158
/**
  Load UEFI compatibility support like drivers.

  @param[in]  Storage   OpenCore storage.
  @param[in]  Config    OpenCore configuration.
V
vit9696 已提交
159
  @param[in]  CpuInfo   CPU information.
160 161 162 163
**/
VOID
OcLoadUefiSupport (
  IN OC_STORAGE_CONTEXT  *Storage,
V
vit9696 已提交
164 165
  IN OC_GLOBAL_CONFIG    *Config,
  IN OC_CPU_INFO         *CpuInfo
166
  );
V
vit9696 已提交
167

V
vit9696 已提交
168 169 170 171 172
/**
  Load UEFI input compatibility support.

  @param[out] Config    OpenCore configuration.
**/
V
vit9696 已提交
173
VOID
V
vit9696 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
OcLoadUefiInputSupport (
  IN OC_GLOBAL_CONFIG  *Config
  );

/**
  Load UEFI output compatibility support.

  @param[out] Config    OpenCore configuration.
**/
VOID
OcLoadUefiOutputSupport (
  IN OC_GLOBAL_CONFIG  *Config
  );

/**
  Load UEFI audio compatibility support.

  @param[in]  Storage   OpenCore storage.
  @param[out] Config    OpenCore configuration.
**/
V
vit9696 已提交
194
VOID
V
vit9696 已提交
195 196 197 198 199 200
OcLoadUefiAudioSupport (
  IN OC_STORAGE_CONTEXT  *Storage,
  IN OC_GLOBAL_CONFIG    *Config
  );

/**
V
vit9696 已提交
201 202 203 204
  Schedule Exit Boot Services event in TPL_APPLICATION mode.

  @param[in]  Handler   Handler function to invoke.
  @param[in]  Context   Handler function context.
V
vit9696 已提交
205 206
**/
VOID
V
vit9696 已提交
207 208 209
OcScheduleExitBootServices (
  IN EFI_EVENT_NOTIFY   Handler,
  IN VOID               *Context
V
vit9696 已提交
210 211
  );

212 213 214 215 216 217 218 219 220 221
/**
  Get human readable version string.

  @retval null-terminated 7-bit ASCII version string.
**/
CONST CHAR8 *
OcMiscGetVersionString (
  VOID
  );

V
vit9696 已提交
222 223 224 225 226 227 228 229 230 231 232 233 234
/**
  Load early miscellaneous support like configuration.

  @param[in]  Storage   OpenCore storage.
  @param[out] Config    OpenCore configuration.
  @param[in]  VaultKey  Vault key.

  @retval EFI_SUCCESS when allowed to continue.
**/
EFI_STATUS
OcMiscEarlyInit (
  IN  OC_STORAGE_CONTEXT *Storage,
  OUT OC_GLOBAL_CONFIG   *Config,
235
  IN  OC_RSA_PUBLIC_KEY  *VaultKey  OPTIONAL
V
vit9696 已提交
236 237 238 239 240
  );

/**
  Load late miscellaneous support like boot screen config.

241
  @param[in]  Storage    OpenCore storage.
V
vit9696 已提交
242 243 244 245 246 247 248 249
  @param[in]  Config     OpenCore configuration.
  @param[in]  LoadPath   OpenCore loading path.
  @param[out] LoadHandle OpenCore loading handle.

  @retval EFI_SUCCESS on success, informational.
**/
EFI_STATUS
OcMiscLateInit (
250
  IN  OC_STORAGE_CONTEXT        *Storage,
V
vit9696 已提交
251 252
  IN  OC_GLOBAL_CONFIG          *Config,
  IN  EFI_DEVICE_PATH_PROTOCOL  *LoadPath  OPTIONAL,
253
  OUT EFI_HANDLE                *LoadHandle
V
vit9696 已提交
254 255
  );

256 257 258
/**
  Load late miscellaneous support like boot screen config.

V
vit9696 已提交
259
  @param[in]  Storage         OpenCore storage.
260
  @param[in]  Config          OpenCore configuration.
261
  @param[in]  Privilege       OpenCore privilege context.
262 263 264 265 266 267 268 269
  @param[in]  StartImage      Image starting routine used.
  @param[in]  LoadHandle      OpenCore loading handle.
  @param[in]  CustomBootGuid  Use custom (gOcVendorVariableGuid) for Boot#### variables.
**/
VOID
OcMiscBoot (
  IN  OC_STORAGE_CONTEXT        *Storage,
  IN  OC_GLOBAL_CONFIG          *Config,
270
  IN  OC_PRIVILEGE_CONTEXT      *Privilege OPTIONAL,
271 272
  IN  OC_IMAGE_START            StartImage,
  IN  BOOLEAN                   CustomBootGuid,
273
  IN  EFI_HANDLE                LoadHandle
274 275
  );

276 277 278 279 280 281 282 283 284 285
/**
  Load miscellaneous support after UEFI quirks.

  @param[in]  Config     OpenCore configuration.
**/
VOID
OcMiscUefiQuirksLoaded (
  IN OC_GLOBAL_CONFIG   *Config
  );

V
vit9696 已提交
286
#endif // OPEN_CORE_H