From 027ab3fdf923d6b9da85bf5f97db8d1af32a653b Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 6 Apr 2019 15:40:48 +0300 Subject: [PATCH] OcConfigurationLib: Partially expanded UEFI and kext configuration --- Include/Library/OcConfigurationLib.h | 71 ++++++++++++++++++- .../OcConfigurationLib/OcConfigurationLib.c | 53 +++++++++++++- OcSupportPkg.dec | 3 - 3 files changed, 122 insertions(+), 5 deletions(-) diff --git a/Include/Library/OcConfigurationLib.h b/Include/Library/OcConfigurationLib.h index fa424473..8d380a00 100644 --- a/Include/Library/OcConfigurationLib.h +++ b/Include/Library/OcConfigurationLib.h @@ -28,6 +28,62 @@ OC_MAP (OC_STRING, OC_ASSOC, _, __) OC_DECLARE (OC_DEVICE_PROP_MAP) +/** + KernelSpace section +**/ + +/// +/// KernelSpace kext adds. +/// + +#define OC_KERNEL_ADD_ENTRY_FIELDS(_, __) \ + _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) + OC_DECLARE (OC_KERNEL_ADD_ENTRY) + +#define OC_KERNEL_ADD_ARRAY_FIELDS(_, __) \ + OC_ARRAY (OC_KERNEL_ADD_ENTRY, _, __) + OC_DECLARE (OC_KERNEL_ADD_ARRAY) + +/// +/// KernelSpace kext blocks. +/// + +#define OC_KERNEL_BLOCK_ENTRY_FIELDS(_, __) \ + _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) + OC_DECLARE (OC_KERNEL_BLOCK_ENTRY) + +#define OC_KERNEL_BLOCK_ARRAY_FIELDS(_, __) \ + OC_ARRAY (OC_KERNEL_BLOCK_ENTRY, _, __) + OC_DECLARE (OC_KERNEL_BLOCK_ARRAY) + +/// +/// KernelSpace patches. +/// + +#define OC_KERNEL_PATCH_ENTRY_FIELDS(_, __) \ + _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) + OC_DECLARE (OC_KERNEL_PATCH_ENTRY) + +#define OC_KERNEL_PATCH_ARRAY_FIELDS(_, __) \ + OC_ARRAY (OC_KERNEL_PATCH_ENTRY, _, __) + OC_DECLARE (OC_KERNEL_PATCH_ARRAY) + +/// +/// KernelSpace quirks. +/// +#define OC_KERNEL_QUIRKS_FIELDS(_, __) \ + _(BOOLEAN , AppleCpuPmCfgLock , , FALSE , ()) \ + _(BOOLEAN , XhciPortLimit , , FALSE , ()) \ + _(BOOLEAN , ThirdPartyTrim , , FALSE , ()) + OC_DECLARE (OC_KERNEL_QUIRKS) + +#define OC_KERNEL_CONFIG_FIELDS(_, __) \ + _(OC_KERNEL_ADD_ARRAY , Add , , OC_CONSTR2 (OC_KERNEL_ADD_ARRAY, _, __) , OC_DESTR (OC_KERNEL_ADD_ARRAY)) \ + _(OC_KERNEL_BLOCK_ARRAY , Block , , OC_CONSTR2 (OC_KERNEL_BLOCK_ARRAY, _, __) , OC_DESTR (OC_KERNEL_BLOCK_ARRAY)) \ + _(OC_KERNEL_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_KERNEL_PATCH_ARRAY, _, __) , OC_DESTR (OC_KERNEL_PATCH_ARRAY)) \ + _(OC_KERNEL_QUIRKS , Quirks , , OC_CONSTR2 (OC_KERNEL_QUIRKS, _, __) , OC_DESTR (OC_KERNEL_QUIRKS)) + OC_DECLARE (OC_KERNEL_CONFIG) + /** Uefi section **/ @@ -39,11 +95,23 @@ OC_ARRAY (OC_STRING, _, __) OC_DECLARE (OC_UEFI_DRIVER_ARRAY) +/// +/// Quirks is a set of hacks for different firmwares. +/// +#define OC_UEFI_QUIRKS_FIELDS(_, __) \ + _(BOOLEAN , DisableWatchDog , , FALSE , ()) \ + _(BOOLEAN , IgnoreInvalidFlexRatio , , FALSE , ()) \ + _(BOOLEAN , ProvideConsoleGop , , FALSE , ()) + OC_DECLARE (OC_UEFI_QUIRKS) + + /// /// Uefi contains firmware tweaks and extra drivers. /// #define OC_UEFI_CONFIG_FIELDS(_, __) \ - _(OC_UEFI_DRIVER_ARRAY , Drivers , , OC_CONSTR2 (OC_UEFI_DRIVER_ARRAY, _, __) , OC_DESTR (OC_UEFI_DRIVER_ARRAY)) + _(BOOLEAN , ConnectDrivers , , FALSE , ()) \ + _(OC_UEFI_DRIVER_ARRAY , Drivers , , OC_CONSTR2 (OC_UEFI_DRIVER_ARRAY, _, __) , OC_DESTR (OC_UEFI_DRIVER_ARRAY)) \ + _(OC_UEFI_QUIRKS , Quirks , , OC_CONSTR2 (OC_UEFI_QUIRKS, _, __) , OC_DESTR (OC_UEFI_QUIRKS)) OC_DECLARE (OC_UEFI_CONFIG) /** @@ -52,6 +120,7 @@ #define OC_GLOBAL_CONFIG_FIELDS(_, __) \ _(OC_DEVICE_PROP_MAP , DeviceProperties , , OC_CONSTR1 (OC_DEVICE_PROP_MAP, _, __) , OC_DESTR (OC_DEVICE_PROP_MAP)) \ + _(OC_KERNEL_CONFIG , Kernel , , OC_CONSTR1 (OC_KERNEL_CONFIG, _, __) , OC_DESTR (OC_KERNEL_CONFIG)) \ _(OC_UEFI_CONFIG , Uefi , , OC_CONSTR1 (OC_UEFI_CONFIG, _, __) , OC_DESTR (OC_UEFI_CONFIG)) OC_DECLARE (OC_GLOBAL_CONFIG) diff --git a/Library/OcConfigurationLib/OcConfigurationLib.c b/Library/OcConfigurationLib/OcConfigurationLib.c index 65f413fe..fccebb87 100644 --- a/Library/OcConfigurationLib/OcConfigurationLib.c +++ b/Library/OcConfigurationLib/OcConfigurationLib.c @@ -15,7 +15,16 @@ #include OC_MAP_STRUCTORS (OC_DEVICE_PROP_MAP) +OC_STRUCTORS (OC_KERNEL_ADD_ENTRY, ()) +OC_ARRAY_STRUCTORS (OC_KERNEL_ADD_ARRAY) +OC_STRUCTORS (OC_KERNEL_BLOCK_ENTRY, ()) +OC_ARRAY_STRUCTORS (OC_KERNEL_BLOCK_ARRAY) +OC_STRUCTORS (OC_KERNEL_PATCH_ENTRY, ()) +OC_ARRAY_STRUCTORS (OC_KERNEL_PATCH_ARRAY) +OC_STRUCTORS (OC_KERNEL_QUIRKS, ()) +OC_STRUCTORS (OC_KERNEL_CONFIG, ()) OC_ARRAY_STRUCTORS (OC_UEFI_DRIVER_ARRAY) +OC_STRUCTORS (OC_UEFI_QUIRKS, ()) OC_STRUCTORS (OC_UEFI_CONFIG, ()) OC_STRUCTORS (OC_GLOBAL_CONFIG, ()) @@ -32,6 +41,37 @@ STATIC OC_SCHEMA mDevicePropertiesSchema = OC_SCHEMA_MAP (NULL, OC_ASSOC, &mDevicePropertiesEntrySchema); + +// +// Kernel space configuration support +// + +STATIC +OC_SCHEMA +mKernelAddSchema[] = { + OC_SCHEMA_STRING_IN ("Identifier", OC_KERNEL_ADD_ENTRY, Identifier), +}; + +STATIC +OC_SCHEMA +mKernelBlockSchema[] = { + OC_SCHEMA_STRING_IN ("Identifier", OC_KERNEL_BLOCK_ENTRY, Identifier), +}; + +STATIC +OC_SCHEMA +mKernelPatchSchema[] = { + OC_SCHEMA_STRING_IN ("Identifier", OC_KERNEL_PATCH_ENTRY, Identifier), +}; + +STATIC +OC_SCHEMA +mKernelConfigurationSchema[] = { + OC_SCHEMA_ARRAY_IN ("Add", OC_GLOBAL_CONFIG, Kernel.Add, mKernelAddSchema), + OC_SCHEMA_ARRAY_IN ("Block", OC_GLOBAL_CONFIG, Kernel.Block, mKernelBlockSchema), + OC_SCHEMA_ARRAY_IN ("Patch", OC_GLOBAL_CONFIG, Kernel.Patch, mKernelPatchSchema), +}; + // // Uefi configuration support // @@ -40,10 +80,20 @@ STATIC OC_SCHEMA mUefiDriversSchema = OC_SCHEMA_STRING (NULL); +STATIC +OC_SCHEMA +mUefiQuirksSchema[] = { + OC_SCHEMA_BOOLEAN_IN ("DisableWatchDog", OC_GLOBAL_CONFIG, Uefi.Quirks.DisableWatchDog), + OC_SCHEMA_BOOLEAN_IN ("IgnoreInvalidFlexRatio", OC_GLOBAL_CONFIG, Uefi.Quirks.IgnoreInvalidFlexRatio), + OC_SCHEMA_BOOLEAN_IN ("ProvideConsoleGop", OC_GLOBAL_CONFIG, Uefi.Quirks.ProvideConsoleGop) +}; + STATIC OC_SCHEMA mUefiConfigurationSchema[] = { - OC_SCHEMA_ARRAY_IN ("Drivers", OC_GLOBAL_CONFIG, Uefi.Drivers, &mUefiDriversSchema) + OC_SCHEMA_BOOLEAN_IN ("ConnectDrivers", OC_GLOBAL_CONFIG, Uefi.ConnectDrivers), + OC_SCHEMA_ARRAY_IN ("Drivers", OC_GLOBAL_CONFIG, Uefi.Drivers, &mUefiDriversSchema), + OC_SCHEMA_DICT ("Quirks", mUefiQuirksSchema) }; // @@ -54,6 +104,7 @@ STATIC OC_SCHEMA mRootConfigurationNodes[] = { OC_SCHEMA_MAP_IN ("DeviceProperties", OC_GLOBAL_CONFIG, DeviceProperties, &mDevicePropertiesSchema), + OC_SCHEMA_DICT ("KernelSpace", mKernelConfigurationSchema), OC_SCHEMA_DICT ("UEFI", mUefiConfigurationSchema) }; diff --git a/OcSupportPkg.dec b/OcSupportPkg.dec index 3d32fb18..24fbbdf9 100644 --- a/OcSupportPkg.dec +++ b/OcSupportPkg.dec @@ -110,9 +110,6 @@ ## @libraryclass OcPngLib|Include/Library/OcPngLib.h - ## @libraryclass - OcProtocolLib|Include/Library/OcProtocolLib.h - ## @libraryclass OcSerializeLib|Include/Library/OcSerializeLib.h