Esempio n. 1
0
EFI_STATUS
StslWriteLogFileName (
  IN STANDARD_TEST_PRIVATE_DATA   *Private
  )
{
  EFI_STATUS                        Status;
  EFI_TEST_OUTPUT_LIBRARY_PROTOCOL  *Output;
  EFI_FILE_HANDLE                   FileHandle;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL      *ConOut;
  CHAR16                            String[EFI_MAX_PRINT_BUFFER];

  Output = Private->OutputProtocol;
  ConOut = gST->ConOut;

  Status = EFI_SUCCESS;

  //
  // System log file
  //
  SPrint (String, EFI_MAX_PRINT_BUFFER, L"Logfile: \"%s\"\n",
          Private->SystemLogFile.FileName);
  if (Private->SystemLogFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->SystemLogFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  //
  // Case log file
  //
  SPrint (String, EFI_MAX_PRINT_BUFFER, L"Logfile: \"%s\"\n",
          Private->CaseLogFile.FileName);
  if (Private->CaseLogFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->CaseLogFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
  }

  return Status;
}
Esempio n. 2
0
EFI_STATUS
StslWriteKeyFile (
  IN STANDARD_TEST_PRIVATE_DATA   *Private,
  IN CHAR16                       *String
  )
{
  EFI_STATUS                        Status;
  EFI_TEST_OUTPUT_LIBRARY_PROTOCOL  *Output;
  EFI_FILE_HANDLE                   FileHandle;
  EFI_SIMPLE_TEXT_OUT_PROTOCOL      *ConOut;

  Output = Private->OutputProtocol;
  ConOut = gST->ConOut;

  Status = EFI_SUCCESS;

  //
  // System key file
  //
  if (Private->SystemKeyFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->SystemKeyFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  //
  // Case key file
  //
  if (Private->CaseKeyFile.EnableScreenOutput) {
    Status = ConOut->OutputString (ConOut, String);
    if ( EFI_ERROR (Status) ) {
      return Status;
    }
  }

  FileHandle = Private->CaseKeyFile.FileHandle;
  if (FileHandle != NULL) {
    Status = Output->Write (Output, FileHandle, String);
  }

  return Status;
}
Esempio n. 3
0
static void
draw_password_box (EFI_SYSTEM_TABLE *systab, struct password_box *pwd_box,
		   CHAR16 *hint_txt)
{
	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;

	int i;
	for (i = 0; i < pwd_box->cols; i++) {
		line[i] = ' ';
	}

	for (i = 0; i < PASS_FIELD_COLS; i++) {
		input_line[i] = ' ';
	}

	/* Draw box */
	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset);

	conout->SetAttribute (conout, BOX_BACKGROUND);

	UINTN row;
	for (row = 0; row < pwd_box->rows; row++) {
		conout->OutputString (conout, line);

		UINTN new_row = pwd_box->row_offset + row;
		conout->SetCursorPosition (conout,
					   pwd_box->col_offset,
					   new_row);
	}

	/* Print box title */
	conout->SetAttribute (conout, BOX_TEXT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset + 1);

	conout->OutputString (conout, TXT_HEAD);

	/* Print hint */
	conout->SetCursorPosition (conout,
				   pwd_box->col_offset,
				   pwd_box->row_offset + 5);

	conout->OutputString (conout, hint_txt);

	/* Print input field */
	conout->SetAttribute (conout, BOX_INPUT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset + 2,
				   pwd_box->row_offset + 3);

	conout->OutputString (conout, input_line);

	/* Move cursor to the first input position */
	conout->SetAttribute (conout, BOX_INPUT_TEXT);

	conout->SetCursorPosition (conout,
				   pwd_box->col_offset + 2,
				   pwd_box->row_offset + 3);

	conout->EnableCursor(conout, 1);
}
Esempio n. 4
0
void
get_password (EFI_SYSTEM_TABLE *systab, struct password_box *pwd_box,
	      uint8_t *pass_buf, UINTN buf_nbytes, UINTN *n_chars)
{
	*n_chars = 0;

	EFI_SIMPLE_TEXT_OUT_PROTOCOL *conout = systab->ConOut;
	EFI_SIMPLE_TEXT_IN_PROTOCOL  *conin  = systab->ConIn;

	EFI_INPUT_KEY input_key;
	UINTN event_idx;

	UINTN count = 0;
	EFI_STATUS error;

get_input:
	conout->EnableCursor(conout, count < PASS_FIELD_COLS);

	systab->BootServices->WaitForEvent (1, &conin->WaitForKey, &event_idx);

	error = conin->ReadKeyStroke (conin, &input_key);
	randseed_event (systab);

	if (error) {
		goto get_input;
	}

	switch (input_key.UnicodeChar) {
	case 0x0000:
	case 0x0009:
		goto get_input;
	case 0x0008: /* BS */
		pass_buf[count] = 0x00;
		if (count > 0) {
			count--;
			if (count < PASS_FIELD_COLS) {
				conout->SetAttribute (conout, BOX_INPUT);
				conout->OutputString (conout, CHAR_REMOVE);
				conout->SetAttribute (conout, BOX_INPUT_TEXT);
				/* Make sure that the cursor appears */
				conout->OutputString (conout, L"");
			}
		}

		goto get_input;
	default:
		if (count < (PASS_N_CHARS - 1)) {
			pass_buf[count] = input_key.UnicodeChar;
			if (count < PASS_FIELD_COLS) {
				conout->OutputString (conout, L"*");
			}
			count++;
		}

		if (count + 1 != buf_nbytes) {
			goto get_input;
		}
		/* Fallthrough */
	case 0x000A:
	case 0x000D:
		pass_buf[count + 1] = '\0';
		*n_chars = count;
		break;
	}
}