Skip to content
Draft
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
258 changes: 187 additions & 71 deletions dcu

Large diffs are not rendered by default.

90 changes: 78 additions & 12 deletions src/variable_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@ LIST_SUPPORTED="${args[--list-supported]}"
supported_variables=$(echo "LockBios NetworkBoot UsbDriverStack SmmBwp"\
"Ps2Controller BootManagerEnabled PCIeResizeableBarsEnabled"\
"EnableCamera EnableWifiBt SerialRedirection SerialRedirection2"\
"MeMode FanCurveOption CpuThrottlingThreshold DGPUEnabled")
"MeMode FanCurveOption CpuThrottlingThreshold"\
"UsbMassStorage QuietBoot FastBoot UsbPortPower DescriptorWriteable"\
"PowerFailureState SleepType CpuThrottlingOffset DGPUState"\
"SecureBootEnable BatteryConfig")

guidof()
{
case $1 in
SecureBootEnable)
echo "f0a30bc7-af08-4556-99c4001009c93a44"
;;
*)
echo "dasharo"
;;
esac
}

typeof()
{
Expand All @@ -32,7 +47,12 @@ typeof()
|EnableCamera \
|EnableWifiBt \
|SerialRedirection \
|SerialRedirection2)
|SerialRedirection2 \
|QuietBoot \
|FastBoot \
|UsbPortPower \
|DescriptorWriteable \
|SecureBootEnable)
echo "enum_bool"
;;
MeMode)
Expand All @@ -41,12 +61,22 @@ typeof()
FanCurveOption)
echo "enum_fancurve"
;;
CpuThrottlingThreshold)
CpuThrottlingThreshold \
|CpuThrottlingOffset)
echo "uint8"
;;
DGPUEnabled)
DGPUState)
echo "enum_dgpuenabled"
;;
PowerFailureState)
echo "enum_powerfailure"
;;
SleepType)
echo "enum_sleeptype"
;;
BatteryConfig)
echo "uint16"
;;
*)
echo "unknown"
;;
Expand All @@ -57,7 +87,7 @@ valueof()
{
case `typeof $1` in
enum_bool)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g dasharo -n $1 -t bool)"
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t bool)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
if [ "${_result}" = "false" ]; then
echo "Disabled"
Expand All @@ -69,7 +99,7 @@ valueof()
fi
;;
enum_memode)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g dasharo -n $1 -t uint8)"
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
if [ "${_result}" = "0" ]; then
echo "Enabled"
Expand All @@ -83,7 +113,7 @@ valueof()
fi
;;
enum_fancurve)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g dasharo -n $1 -t uint8)"
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
if [ "${_result}" = "0" ]; then
echo "Silent"
Expand All @@ -95,7 +125,7 @@ valueof()
fi
;;
enum_dgpuenabled)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g dasharo -n $1 -t uint8)"
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
case $_result in
0) echo "iGPU Only";;
Expand All @@ -104,8 +134,32 @@ valueof()
*) echo "Error!"; exit 18;;
esac
;;
enum_powerfailure)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
case $_result in
0) echo "Powered Off";;
1) echo "Powered On";;
2) echo "The state at the moment of power failure";;
*) echo "Error!"; exit 18;;
esac
;;
enum_sleeptype)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
case $_result in
0) echo "Suspend to Idle (S0ix)";;
1) echo "Suspend to RAM (S3)";;
*) echo "Error!"; exit 18;;
esac
;;
uint8)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g dasharo -n $1 -t uint8)"
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint8)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
echo ${_result}
;;
uint16)
_result="$(${SMMSTORETOOL} "${DASHARO_ROM}" get -g $(guidof $1) -n $1 -t uint16)"
error_check "Variable store was not initialized yet. You need to set some variable first via --set option." 17
echo ${_result}
;;
Expand All @@ -131,9 +185,18 @@ acceptedvaluesfor()
enum_dgpuenabled)
echo "iGPU Only / NVIDIA Optimus / dGPU Only"
;;
enum_powerfailure)
echo "Powered Off / Powered On / The state at the moment of power failure"
;;
enum_sleeptype)
echo "Suspend to Idle (S0ix) / Suspend to RAM (S3)"
;;
uint8)
echo "0-255 (Actual supported values may vary)"
;;
uint16)
echo "0-65535 (Actual supported values may vary)"
;;
*)
;;
esac
Expand Down Expand Up @@ -188,14 +251,14 @@ set_variable()
set_type=$(typeof ${SET})
fi

${SMMSTORETOOL} "${DASHARO_ROM}" set -g dasharo -n ${SET} -t ${set_type} -v ${set_value}
${SMMSTORETOOL} "${DASHARO_ROM}" set -g $(guidof ${SET}) -n ${SET} -t ${set_type} -v ${set_value}
echo "Successfully set variable ${SET} in the variable store."
}

list_variables()
{
echo "Settings in ${DASHARO_ROM}:"
variables=$(${SMMSTORETOOL} "${DASHARO_ROM}" list | grep "dasharo" | sed 's/.*://; s/(.*//')
variables=$(${SMMSTORETOOL} "${DASHARO_ROM}" list | grep -E "dasharo|f0a30bc7-af08-4556" | sed 's/.*://; s/(.*//')
tabs 30
echo -e "NAME\tVALUE\tACCEPTED VALUES"
for var in $variables; do
Expand All @@ -204,7 +267,10 @@ list_variables()
|enum_memode \
|enum_fancurve \
|enum_dgpuenabled \
|uint8)
|enum_powerfailure \
|enum_sleeptype \
|uint8 \
|uint16)
echo -e "$var\t$(valueof $var)\t$(acceptedvaluesfor $var)"
;;
*)
Expand Down
1 change: 1 addition & 0 deletions test/approvals/_dcuc_help
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Examples:
dcu smbios coreboot.rom -u 96bcfa1a-42b4-6717-a44c-d8bbc18cbea4 -s D07229051
dcu logo coreboot.rom -l bootsplash.bmp
dcu variable coreboot.rom --get EnableWifiBt

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4200
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable BatteryConfig in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable CpuThrottlingOffset in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NVIDIA Optimus
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable DGPUState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dGPU Only
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable DGPUState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iGPU Only
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: iGPU Only / NVIDIA Optimus / dGPU Only)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable DGPUState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable DescriptorWriteable in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable DescriptorWriteable in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable FastBoot in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable FastBoot in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The state at the moment of power failure
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidMode is out of range (expected one of: Powered Off / Powered On / The state at the moment of power failure)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable PowerFailureState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Powered Off
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable PowerFailureState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Powered On
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable PowerFailureState in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable QuietBoot in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable QuietBoot in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable SecureBootEnable in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable SecureBootEnable in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Suspend to Idle (S0ix)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable SleepType in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Suspend to RAM (S3)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidMode is out of range (expected one of: Suspend to Idle (S0ix) / Suspend to RAM (S3))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable SleepType in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable UsbMassStorage in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable UsbMassStorage in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable UsbPortPower in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Successfully set variable UsbPortPower in the variable store.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value InvalidValue is out of range (expected one of: Disabled / Enabled)
Loading