Exemple #1
0
void CHPGLParser::Parse()
{
	if (IsToken(F("SP"), false, false) || IsToken(F("LT"), false, false))	{ IgnoreCommand();		return; }
	if (IsToken(F("IN"), false, false))										{ InitCommand();		return; }
	if (IsToken(F("PD"), false, false))										{ PenMoveCommand(PD);	return; }
	if (IsToken(F("PU"), false, false))										{ PenMoveCommand(PU);	return; }
	if (IsToken(F("PA"), false, false))										{ PenMoveCommand(PA);	return; }
	if (IsToken(F("PR"), false, false))										{ PenMoveCommand(PR);	return; }

	// command escape to "own" extension

	CHelpParser mycommand(GetReader(),GetOutput());
	mycommand.ParseCommand();

	if (mycommand.IsError()) Error(mycommand.GetError());
	_OkMessage = mycommand.GetOkMessage();
}
Exemple #2
0
EFI_STATUS
MMCSendCommand (
  IN EFI_MMC_HOST_PROTOCOL     *This,
  IN MMC_CMD                   MmcCmd,
  IN UINT32                    Argument
  )
{
  UINTN MmcStatus;
  UINTN RetryCount = 0;

  if (IgnoreCommand(MmcCmd))
    return EFI_SUCCESS;

  MmcCmd = TranslateCommand(MmcCmd);

  //DEBUG ((EFI_D_ERROR, "MMCSendCommand(%d)\n", MmcCmd));

  // Check if command line is in use or not. Poll till command line is available.
  while ((MmioRead32 (MMCHS_PSTATE) & DATI_MASK) == DATI_NOT_ALLOWED);

  // Provide the block size.
  MmioWrite32 (MMCHS_BLK, BLEN_512BYTES);

  // Setting Data timeout counter value to max value.
  MmioAndThenOr32 (MMCHS_SYSCTL, ~DTO_MASK, DTO_VAL);

  // Clear Status register.
  MmioWrite32 (MMCHS_STAT, 0xFFFFFFFF);

  // Set command argument register
  MmioWrite32 (MMCHS_ARG, Argument);

  //TODO: fix this
  //Enable interrupt enable events to occur
  //MmioWrite32 (MMCHS_IE, CmdInterruptEnableVal);

  // Send a command
  MmioWrite32 (MMCHS_CMD, MmcCmd);

  // Check for the command status.
  while (RetryCount < MAX_RETRY_COUNT) {
    do {
      MmcStatus = MmioRead32 (MMCHS_STAT);
    } while (MmcStatus == 0);

    // Read status of command response
    if ((MmcStatus & ERRI) != 0) {

      // Perform soft-reset for mmci_cmd line.
      MmioOr32 (MMCHS_SYSCTL, SRC);
      while ((MmioRead32 (MMCHS_SYSCTL) & SRC));

      //DEBUG ((EFI_D_INFO, "MmcStatus: 0x%x\n", MmcStatus));
      return EFI_DEVICE_ERROR;
    }

    // Check if command is completed.
    if ((MmcStatus & CC) == CC) {
      MmioWrite32 (MMCHS_STAT, CC);
      break;
    }

    RetryCount++;
  }

  if (RetryCount == MAX_RETRY_COUNT) {
    DEBUG ((DEBUG_BLKIO, "MMCSendCommand: Timeout\n"));
    return EFI_TIMEOUT;
  }

  return EFI_SUCCESS;
}
HRESULT RunCommandLoop(_In_ ISpellChecker* spellChecker)
{
    wprintf(L"Commands:\n");
    wprintf(L"quit - Quit\n");
    wprintf(L"add <word> - Add word\n");
    wprintf(L"ac <word> <word> - Add autocorrect pair\n");
    wprintf(L"ign <word> - Ignore word\n");
    wprintf(L"chkb <text> - Check text (batch - pasted text or file open)\n");
    wprintf(L"chk <text> - Check text (as you type)\n");

    HRESULT hr = S_OK;
    while (SUCCEEDED(hr))
    {
        wprintf(L"> ");
        wchar_t line[MAX_PATH];
        hr = StringCchGets(line, ARRAYSIZE(line));
        
        if (SUCCEEDED(hr))
        {
            wchar_t command[MAX_PATH];
            int count = swscanf_s(line, L"%s", command, static_cast<unsigned int>(ARRAYSIZE(command)));
            hr = (count == 1) ? hr : E_FAIL;
            if (SUCCEEDED(hr))
            {
                _Analysis_assume_nullterminated_(command);
                const size_t lineSize = wcslen(line);
                const size_t cmdSize = wcslen(command);
                if (cmdSize == lineSize)
                {
                    if (wcscmp(L"quit", command) == 0)
                    {
                        break;
                    }
                    else
                    {
                        wprintf(L"Invalid command\n");
                    }
                }
                else
                {
                    PCWSTR buffer = line + wcslen(command);

                    if (wcscmp(L"add", command) == 0)
                    {
                        hr = AddCommand(spellChecker, buffer);
                    }
                    else if (wcscmp(L"ac", command) == 0)
                    {
                        hr = AutoCorrectCommand(spellChecker, buffer);
                    }
                    else if (wcscmp(L"ign", command) == 0)
                    {
                        hr = IgnoreCommand(spellChecker, buffer);
                    }
                    else if (wcscmp(L"chkb", command) == 0)
                    {
                        hr = CheckCommand(spellChecker, buffer);
                    }
                    else if (wcscmp(L"chk", command) == 0)
                    {
                        hr = CheckAsYouTypeCommand(spellChecker, buffer);
                    }
                    else
                    {
                        wprintf(L"Invalid command\n");
                    }
                }
            }
        }
    }

    PrintErrorIfFailed(L"RunCommandLoop", hr);
    return hr;
}