Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DasharoModulePkg: Add USB port power feature #196

Open
wants to merge 2 commits into
base: dasharo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DasharoModulePkg/DasharoModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
gDasharoSystemFeaturesTokenSpaceGuid.PcdCpuHyperThreadingDefault|TRUE|BOOLEAN|0x000000028
gDasharoSystemFeaturesTokenSpaceGuid.PcdCpuThrottlingOffsetDefault|20|UINT8|0x00000029
gDasharoSystemFeaturesTokenSpaceGuid.PcdPowerMenuShowFanCurveOffOption|FALSE|BOOLEAN|0x00000002A
gDasharoSystemFeaturesTokenSpaceGuid.PcdPowerMenuShowUsbPowerOption|FALSE|BOOLEAN|0x00000002B

[PcdsFixedAtBuild,PcdsPatchableInModule,PcdsDynamic,PcdsDynamicEx]
## Indicate whether the password is cleared.
Expand Down
5 changes: 5 additions & 0 deletions DasharoModulePkg/Include/DasharoOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define DASHARO_VAR_SMALL_CORE_ACTIVE_COUNT L"SmallCoreActiveCount"
#define DASHARO_VAR_CORE_ACTIVE_COUNT L"CoreActiveCount"
#define DASHARO_VAR_HYPER_THREADING L"HyperThreading"
#define DASHARO_VAR_USB_PORT_POWER L"UsbPortPower"

// Other
#define DASHARO_VAR_SMBIOS_UUID L"Type1UUID"
Expand Down Expand Up @@ -72,6 +73,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define DASHARO_POWER_FAILURE_STATE_KEEP 2
#define DASHARO_POWER_FAILURE_STATE_HIDDEN 0xff

#define DASHARO_USB_POWER_ON_WHEN_POWERED 0
#define DASHARO_USB_POWER_ALWAYS_ON 1
#define DASHARO_USB_POWER_ON_WHEN_AC 2

// The values aren't random, they match FSP_M_CONFIG::SpdProfileSelected
#define DASHARO_MEMORY_PROFILE_JEDEC 0
#define DASHARO_MEMORY_PROFILE_XMP1 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ DasharoSystemFeaturesUiLibConstructor (
PRIVATE_DATA(WatchdogAvailable) = FixedPcdGetBool (PcdShowOcWdtOptions);
PRIVATE_DATA(ShowPowerFailureState) = FixedPcdGet8 (PcdDefaultPowerFailureState) != POWER_FAILURE_STATE_HIDDEN;
PRIVATE_DATA(HideFanCurveOff) = !FixedPcdGetBool (PcdPowerMenuShowFanCurveOffOption);
PRIVATE_DATA(PowerMenuShowUsbPower) = FixedPcdGetBool (PcdPowerMenuShowUsbPowerOption);

// Ensure at least one option is visible in given menu (if enabled), otherwise hide it
if (PRIVATE_DATA(ShowSecurityMenu))
Expand All @@ -218,6 +219,7 @@ DasharoSystemFeaturesUiLibConstructor (
FixedPcdGetBool (PcdPowerMenuShowSleepType) ||
FixedPcdGetBool (PcdPowerMenuShowBatteryThresholds) ||
FixedPcdGetBool (PcdShowCpuThrottlingThreshold) ||
FixedPcdGetBool (PcdPowerMenuShowUsbPowerOption) ||
(FixedPcdGet8 (PcdDefaultPowerFailureState) != POWER_FAILURE_STATE_HIDDEN);

if (PRIVATE_DATA(ShowCpuMenu))
Expand Down Expand Up @@ -276,6 +278,7 @@ DasharoSystemFeaturesUiLibConstructor (
LOAD_VAR (DASHARO_VAR_CORE_ACTIVE_COUNT, BigCoreActiveCount);
LOAD_VAR (DASHARO_VAR_CORE_ACTIVE_COUNT, CoreActiveCount);
LOAD_VAR (DASHARO_VAR_HYPER_THREADING, HyperThreading);
LOAD_VAR (DASHARO_VAR_USB_PORT_POWER, UsbPortPower);

#undef LOAD_VAR

Expand Down Expand Up @@ -549,6 +552,7 @@ DasharoSystemFeaturesRouteConfig (
STORE_VAR_IF (DASHARO_VAR_FAN_CURVE_OPTION, FanCurveOption, FixedPcdGetBool (PcdPowerMenuShowFanCurve));
STORE_VAR_IF (DASHARO_VAR_BATTERY_CONFIG, BatteryConfig, FixedPcdGetBool (PcdPowerMenuShowBatteryThresholds));
STORE_VAR_IF (DASHARO_VAR_CPU_THROTTLING_OFFSET, CpuThrottlingOffset, FixedPcdGetBool (PcdShowCpuThrottlingThreshold));
STORE_VAR_IF (DASHARO_VAR_USB_PORT_POWER, UsbPortPower, FixedPcdGetBool (PcdPowerMenuShowUsbPowerOption));
}

if (FixedPcdGetBool (PcdShowPciMenu)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef struct {
BOOLEAN PowerMenuShowFanCurve;
BOOLEAN PowerMenuShowSleepType;
BOOLEAN PowerMenuShowBatteryThresholds;
BOOLEAN PowerMenuShowUsbPower;
BOOLEAN DasharoEnterprise;
BOOLEAN SecurityMenuShowIommu;
BOOLEAN PciMenuShowResizeableBars;
Expand Down Expand Up @@ -95,6 +96,7 @@ typedef struct {
UINT8 SmallCoreMaxCount;
UINT8 CoreActiveCount;
UINT8 CoreMaxCount;
UINT8 UsbPortPower;
} DASHARO_FEATURES_DATA;

//
Expand Down Expand Up @@ -132,6 +134,10 @@ typedef struct {

#define CPU_CORES_ENABLE_ALL DASHARO_CPU_CORES_ENABLE_ALL

#define USB_POWER_ON_WHEN_POWERED DASHARO_USB_POWER_ON_WHEN_POWERED
#define USB_POWER_ALWAYS_ON DASHARO_USB_POWER_ALWAYS_ON
#define USB_POWER_ON_WHEN_AC DASHARO_USB_POWER_ON_WHEN_AC

//
// Question IDs are used in VFR file to let the code in
// DasharoSystemFeaturesCallback() know what form element caused
Expand All @@ -152,5 +158,6 @@ typedef struct {
#define SERIAL_PORT2_REDIR_QUESTION_ID 0x800B
#define HYPER_THREADING_QUESTION_ID 0x800C
#define CPU_THROTTLING_OFFSET_QUESTION_ID 0x800D
#define USB_PORTS_POWER_QUESTION_ID 0x800E

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@

#string STR_BATTERY_THRESHOLD_RANGE_ERROR #language en-US "The battery stop threshold must be greater than the start threshold!"

#string STR_USB_PORTS_POWER_PROMPT #language en-US "USB ports power and charging"
#string STR_USB_PORTS_POWER_HELP #language en-US "Controls the USB port power and charging capabilities of the device.\n\n"
"On When Device Is Powered On - USB ports supply power only when the device is powered on\n"
"Always On - USB ports always supply power, even when device is powered off. WARNING: when device is left unattended it will drain the battery.\n"
"On When On AC - USB ports supply power only when the device is powered on or when the device is powered off but plugged to AC.\n"

#string STR_USB_PORTS_POWER_ON_WHEN_POWERED #language en-US "On When Device Is Powered On"
#string STR_USB_PORTS_POWER_ALWAYS_ON #language en-US "Always On"
#string STR_USB_PORTS_POWER_ON_AC #language en-US "On When On AC"

#string STR_MEMORY_PROFILE_PROMPT #language en-US "Memory SPD Profile"
#string STR_MEMORY_PROFILE_HELP #language en-US "This option selects memory profile applied to RAM modules.\n\n"
"Selecting an XMP profile may result in unstable memory modules and even prevent system from booting.\n\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@
gDasharoSystemFeaturesTokenSpaceGuid.PcdShowCpuHyperThreading
gDasharoSystemFeaturesTokenSpaceGuid.PcdCpuMaxTemperature
gDasharoSystemFeaturesTokenSpaceGuid.PcdPowerMenuShowFanCurveOffOption
gDasharoSystemFeaturesTokenSpaceGuid.PcdPowerMenuShowUsbPowerOption
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,19 @@ formset
endif;
endif;

disableif ideqval FeaturesData.PowerMenuShowUsbPower == 0;
oneof varid = FeaturesData.UsbPortPower,
questionid = USB_PORTS_POWER_QUESTION_ID,
prompt = STRING_TOKEN(STR_USB_PORTS_POWER_PROMPT),
help = STRING_TOKEN(STR_USB_PORTS_POWER_HELP),
flags = RESET_REQUIRED,

option text = STRING_TOKEN(STR_USB_PORTS_POWER_ON_WHEN_POWERED), value = USB_POWER_ON_WHEN_POWERED, flags = DEFAULT;
option text = STRING_TOKEN(STR_USB_PORTS_POWER_ALWAYS_ON), value = USB_POWER_ALWAYS_ON, flags = 0;
option text = STRING_TOKEN(STR_USB_PORTS_POWER_ON_AC), value = USB_POWER_ON_WHEN_AC, flags = 0;
endoneof;
endif;

subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_EXIT_STRING);
Expand Down
Loading