132 Commits

Author SHA1 Message Date
Sergii Dmytruk
c4c2c97dc2 DasharoModulePkg/DasharoVariablesLib: fix build due to QuickSort()
The change ported from a newer EDK version used QuickSort() which
doesn't exist in this one.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-19 17:49:11 +03:00
Sergii Dmytruk
48b377528a DasharoVariablesLib: fix non-deterministic measurements
This fixes "SecurityPkg: measure Dasharo variables before boot".

gRT->GetNextVariableName() doesn't return variables in any fixed order.
Seems like the order matches order in SMMSTORE.  This means that
measuring variables while enumerating them will produce different
results depending on which variables were update last (setting a
variable in SMMSTORE is marking old entry as deleted and appending of a
new one).  Sort list of variables that share the same GUID before
measuring any of them to impose a fixed order.

Also fix spacing in several places.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-18 20:30:26 +03:00
Michał Żygowski
aa11fcec8d Update Library/DasharoVariablesLib/DasharoVariablesLib.c
Co-authored-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2024-06-26 17:48:15 +02:00
Michał Żygowski
f9dc3ce784 DasharoSystemFeaturesUiLib,DasharoVariablesLib: Use FixedPcdGetBool
Use FixedPcdGetBool to emphasize the use of immutable FixedAtBuild PCD.
It will also prevent changing the PCD type later and possibly alter the
behavior of the menu by other modules if something was to change the
PCD type.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-26 10:53:13 +02:00
Michał Żygowski
6fb943d315 Library/DasharoVariablesLib: Autocreate variables only for enabled options
Add list of conditions under which the variable should be created.
We only want to create variables for options that are enabled in the
given project/build.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-26 10:52:56 +02:00
Michał Żygowski
539d52fdc5 Library/DasharoSystemFeaturesUiLib: Use disableif for options
Use disableif, which is more convenient for turning off the options
entirely, as it will disable the IFR logic for everything nested under
the disableif. Unlike supressif, disableif is evaluated only once. It
saves time for the processing and will prevent some undesired behavior
from occurring, such as a default value not correctly set for the
hidden option and causing an IFR logic to fail in bounds check, etc.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-26 10:50:07 +02:00
Michał Żygowski
49f52026fa Library/DasharoSystemFeaturesUiLib: Write variables only for enabled options
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-26 10:49:24 +02:00
Michał Żygowski
1a488a4da5 Rework the CPU throttling variables and setup UI management
The CPU throttling used an excessive number of variables. The allowed
range of values should be fixed at build, saving it as a NV variable
makes no sense.

Simplify the logic of the CPU throttling range, gaining a better UX
than some error popups. Instead of setting the temperature, set the
offset which has a fixed allowed range. Display the current threshold
temperatue as grayed out fields instead.

Also add PCD to control the default value of the throttling offset.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-20 14:38:26 +02:00
Sergii Dmytruk
740ada43f6 DasharoModulePkg/DasharoVariablesLib: do not create FUM variable
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-19 17:15:54 +03:00
Michał Żygowski
56fdb7be4e DasharoSystemFeaturesUiLib: Add options for downcoring and HT
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-18 14:07:00 +02:00
Michał Żygowski
613d290179 Library/DasharoSystemFeaturesUiLib: Change serial port option prompts
Use the IBM PC serial port naming in the option prompts.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2024-06-14 17:02:45 +02:00
Sergii Dmytruk
2bf3125371 DasharoModulePkg: document how to add a new setting
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:19 +03:00
Sergii Dmytruk
df259adcbe DasharoSystemFeaturesUiLib: fix watchdog not being reset to default
Combination of `RESET_REQUIRED` flag and set `questionid` isn't enough
to get callback call, `INTERACTIVE` flag is required as well.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:19 +03:00
Sergii Dmytruk
6f3eb21c4c DasharoVariablesLib: add API for measuring Dasharo variables
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:19 +03:00
Sergii Dmytruk
658985549b DasharoSystemFeaturesUiLib: reduce boilerplate in RouteConfig
The code is highly repetitive, use a macro to shorten it by a lot.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:19 +03:00
Sergii Dmytruk
84ee5859f9 DasharoModulePkg: reset to defaults maintained by DasharoVariablesLib
From now on default values are maintained only in DasharoVariablesLib
and can be queried from it to avoid code duplication and bugs which
arise from it.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:19 +03:00
Sergii Dmytruk
6d3f57218c DasharoSystemFeaturesUiLib: reduce boilerplate in constructor
Use a macro to get rid of repeated code for loading data from variables.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-11 00:11:17 +03:00
Sergii Dmytruk
8ecc6874ad DasharoModulePkg: move variable creation to DasharoVariablesLib
Create a separate library for managing values of variables and create
them in the constructor of the new library.  This gets rid of the
defaults in Library/DasharoSystemFeaturesUiLib/DasharoSystemFeatures.c

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-10 19:52:46 +03:00
Sergii Dmytruk
6caa9c0b20 DasharoSystemFeaturesUiLib: fix initializing SleepType
PcdSleepTypeDefaultS3 wasn't taken into account.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-10 19:44:54 +03:00
Sergii Dmytruk
8b763c5888 DasharoSystemFeaturesUiLib/DasharoSystemFeaturesHii.h: cleanup
1. Remove excessive indentation from some fields of
   DASHARO_FEATURES_DATA.
2. Add a comment explaining question IDs.
3. Drop gDasharoSystemFeaturesGuid declaration which should be provided
   by build system.
4. Fix formatting of WATCHDOG_ENABLE_QUESTION_ID.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-10 19:44:51 +03:00
Sergii Dmytruk
1acd95498b DasharoModulePkg: move more declarations to DasharoOptions.h
To have all of them collected in one place and have no need to reach
into HII-related header from unrelated parts of the code.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-10 19:44:25 +03:00
Sergii Dmytruk
b646ad16e8 DasharoModulePkg: #define variable names and use consistently
This is somewhat then using string literals as making a typo in a macro
name will cause a compilation error.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-06-10 19:42:51 +03:00
Michał Kopeć
6e30d147a2 Library/DasharoSystemFeaturesUiLib/DasharoSystemFeatures.c: remove unused EFI vars
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2024-06-05 12:08:08 +02:00
Filip Lewiński
4f702c25a2 Add CPU throttling threshold option support
Signed-off-by: Filip Lewiński <filip.lewinski@3mdeb.com>
2024-05-28 18:54:13 +02:00
Michał Kopeć
ccc1e2ebff Decouple watchdog enablement and visibility from each other
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2024-03-15 17:08:39 +01:00