102 IN EFI_HANDLE ImageHandle,
103 IN EFI_SYSTEM_TABLE *SystemTable
106 EFI_STATUS OldStatus;
117 if (EFI_ERROR (Status)) {
118 Print (L
"GetArguments - %r\n", Status);
124 #ifdef PRINT_ARGUMENTS
125 if (!EFI_ERROR (Status)) {
126 PrintArguments (Argc, Argv);
131 if (EFI_ERROR (Status) || (Argc < 2)) {
139 Status = StrHexToUintnS (Argv[2], &EndPtr, &Data);
141 Status = StrDecimalToUintnS (Argv[2], &EndPtr, &Data);
144 if (!EFI_ERROR (Status) && ((EndPtr != &Argv[2][StrLen (Argv[2])]) || ((Data & MAX_UINT32) != Data))) {
145 Status = EFI_UNSUPPORTED;
149 if (EFI_ERROR (Status)) {
154 if ((Argc == 2) && (StrCmp (Argv[1], L
"status") == 0)) {
158 Print (L
"System Integrity Protection status: ");
164 Status =
OcGetSip (&CsrConfig, &Attributes);
166 if ((Status != EFI_NOT_FOUND) && EFI_ERROR (Status)) {
167 Print (L
"Error getting SIP status - %r\n", Status);
171 if (Status == EFI_NOT_FOUND) {
181 if ((Argc == 2) && (StrCmp (Argv[1], L
"clear") == 0)) {
187 Status =
OcSetSip (NULL, Attributes);
189 if (EFI_ERROR (Status) && !((OldStatus == EFI_NOT_FOUND) && (Status == EFI_NOT_FOUND))) {
190 Print (L
"Error clearing SIP - r\n", Status);
194 Print (L
"Successfully cleared system integrity configuration: ");
195 }
else if ((Argc <= 3) && (StrCmp (Argv[1], L
"disable") == 0)) {
203 Print (L
"Illegal value for %s\n", L
"disable");
204 return EFI_UNSUPPORTED;
207 CsrConfig = (UINT32)Data;
210 Status =
OcSetSip (&CsrConfig, Attributes);
212 if (EFI_ERROR (Status)) {
213 Print (L
"Error disabling SIP - r\n", Status);
217 Print (L
"System Integrity Protection is ");
218 }
else if ((Argc <= 3) && (StrCmp (Argv[1], L
"enable") == 0)) {
226 Print (L
"Illegal value for %s\n", L
"enable");
227 return EFI_UNSUPPORTED;
230 CsrConfig = (UINT32)Data;
233 Status =
OcSetSip (&CsrConfig, Attributes);
235 if (EFI_ERROR (Status)) {
236 Print (L
"Error enabling SIP - r\n", Status);
240 Print (L
"System Integrity Protection is ");
241 }
else if ((Argc <= 3) && (StrCmp (Argv[1], L
"toggle") == 0)) {
249 Print (L
"Illegal value for %s\n", L
"toggle");
250 return EFI_UNSUPPORTED;
253 CsrConfig = (UINT32)Data;
258 if (EFI_ERROR (Status)) {
259 Print (L
"Error toggling SIP - r\n", Status);
263 Print (L
"System Integrity Protection value was toggled to ");
269 return EFI_UNSUPPORTED;
276 Status =
OcGetSip (&CsrConfig, &Attributes);
278 if ((Status != EFI_NOT_FOUND) && EFI_ERROR (Status)) {
279 Print (L
"error getting SIP status - %r\n", Status);
283 if (Status != EFI_NOT_FOUND) {
287 Print (L
"%sd (",
OcIsSipEnabled (Status, CsrConfig) ? L
"enable" : L
"disable");
288 if (Status == EFI_NOT_FOUND) {
289 Print (L
"nvram var not set");
291 Print (L
"0x%x", CsrConfig);
293 Print (L
", UNKNOWN: 0x%x", Attributes);
294 }
else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
295 Print (L
", volatile");
301 if (StrCmp (Argv[0], L
"Self") == 0) {