Example #1
0
EFI_STATUS
SpecShellModeCheckFun (
  IN CHAR16                                *Value,
  IN BOOLEAN                               Delete,
  IN BOOLEAN                               Volatile
  )
{
  UINTN Index;
  if (Delete || !Volatile) {
    PrintToken (STRING_TOKEN (STR_SHELLENV_VAR_RESERVED), HiiEnvHandle, L"set", L"efishellmode");
    return EFI_INVALID_PARAMETER;
  }

  for (Index = 0; mShellMode[Index] != NULL; Index++) {
    if (StrCmp (mShellMode[Index], Value) == 0) {
      return EFI_SUCCESS;
    }
  }

  PrintToken (STRING_TOKEN (STR_SHELLENV_VAR_MODE_OPTIONS), HiiEnvHandle);
  for (Index = 0; mShellMode[Index] != NULL; Index++) {
    Print (mShellMode[Index]);
    Print (L"\n");
  }

  return EFI_INVALID_PARAMETER;
}
Example #2
0
VOID
EFIAPI
SEnvTextOut (
  IN EFI_HANDLE   h,
  IN VOID         *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Dev;
  INTN                          Index;
  UINTN                         Col;
  UINTN                         Row;
  EFI_STATUS                    Status;

  Dev = Interface;

  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_ATTRIB_X),
    HiiEnvHandle,
    Dev->Mode->Attribute
    );

  //
  // Dump TextOut Info
  //
  for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {
    Status = Dev->QueryMode (Dev, Index, &Col, &Row);
    PrintToken (
      STRING_TOKEN (STR_SHELLENV_DPROT_MODE),
      HiiEnvHandle,
      Index == Dev->Mode->Mode ? '*' : ' ',
      Index
      );

    if (EFI_ERROR (Status)) {
      PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_ERROR), HiiEnvHandle, Status);
    } else {
      PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_COL_ROW), HiiEnvHandle, Col, Row);
    }
  }
}
Example #3
0
VOID
EFIAPI
SEnvUsbIo (
  IN EFI_HANDLE       h,
  IN VOID             *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_USB_IO_PROTOCOL           *UsbIo;
  EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDesc;

  UsbIo = Interface;

  UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);

  //
  // Dump UsbIo Info
  //
  Print (L"\n");
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_INTERFACE_NUMBER),
    HiiEnvHandle,
    InterfaceDesc.InterfaceNumber
    );
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_INTERFACE_CLASS),
    HiiEnvHandle,
    InterfaceDesc.InterfaceClass
    );
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_INTERFACE_SUBCLASS),
    HiiEnvHandle,
    InterfaceDesc.InterfaceSubClass
    );
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_DPROT_INTERFACE_PROTOCOL),
    HiiEnvHandle,
    InterfaceDesc.InterfaceProtocol
    );
}
Example #4
0
VOID
SEnvPrintDevicePathEntry (
  IN EFI_DEVICE_PATH_PROTOCOL     *DevicePath,
  IN BOOLEAN                      Verbose
  )
/*++

Routine Description:

Arguments:

  DevicePath - The device path
  Verbose    - Verbose
Returns:

--*/
{
  UINT8 Type;
  UINT8 SubType;
  INTN  Index;

  //
  // Process print device path entry
  //
  Type    = (UINT8) DevicePathType (DevicePath);
  SubType = DevicePathSubType (DevicePath);

  for (Index = 0; SEnvDP_Strings[Index].Type != END_DEVICE_PATH_TYPE; Index++) {
    if (Type == SEnvDP_Strings[Index].Type) {
      if (SubType > SEnvDP_Strings[Index].MaxSubType) {
        SubType = 0;
      }

      PrintToken (
        STRING_TOKEN (STR_SHELLENV_DPROT_DEVICE_PATH_FOR),
        HiiEnvHandle,
        SEnvDP_Strings[Index].TypeString,
        SEnvDP_Strings[Index].SubTypeStr[SubType]
        );
      if (Verbose) {
        if (SEnvDP_Strings[Index].Function != NULL) {
          SEnvDP_Strings[Index].Function (DevicePath);
        }
      }

      return ;
    }
  }

  PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_DEVICE_PATH_ERROR), HiiEnvHandle);
}
Example #5
0
STATIC
VOID
PrintHelpInfo (
  VOID
  )
/*++

Routine Description:

  Print out help information.

Arguments:

  None.

Returns:

  None.

--*/
{
  PrintToken (STRING_TOKEN (STR_FWUPDATE_FIRMWARE_VOL_UPDATE), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_VERSION), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_COPYRIGHT), HiiHandle);

  Print (L"\n");
  PrintToken (STRING_TOKEN (STR_FWUPDATE_USAGE), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_USAGE_1), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_USAGE_2), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_USAGE_3), HiiHandle);
  PrintToken (STRING_TOKEN (STR_FWUPDATE_USAGE_4), HiiHandle);

  Print (L"\n");
}
Example #6
0
EFI_STATUS
LibSmbiosInit (
  VOID
  )
/*++

Routine Description:
    Init the SMBIOS VIEW API's environment.

  Arguments:
    None
  
Returns:
    EFI_SUCCESS       - Successful to init the SMBIOS VIEW Lib
    Others            - Cannot get SMBIOS Table   

--*/
{
  EFI_STATUS  Status;

  //
  // Init only once
  //
  if (mInit == 1) {
    return EFI_SUCCESS;
  }
  //
  // Get SMBIOS table from System Configure table
  //
  Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &mSmbiosTable);

  if (mSmbiosTable == NULL) {
    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), HiiHandle);
    return EFI_NOT_FOUND;
  }

  if (EFI_ERROR (Status)) {
    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), HiiHandle, Status);
    return Status;
  }
  //
  // Init SMBIOS structure table address
  //
  mSmbiosStruct->Raw  = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress);

  mInit               = 1;
  return EFI_SUCCESS;
}
Example #7
0
std::string PrintTokens( const TokenSet& setTokens )
{
	std::string strTokens( " " );
	for ( TokenSet::const_iterator i = setTokens.begin() ; i != setTokens.end() ; i++ )
		strTokens += PrintToken( *i, true ) + " ";
	return strTokens;
}
void
PrintIdentifier(const CodeSource &src, const IdentifierNode *node, Printer pr,
                int tabDepth)
{
    pr("ID:");
    PrintToken(src, node->token(), pr);
}
Example #9
0
VOID
SEnvPrintLabelNotFound (
  VOID
  )
/*++

Routine Description:

  Print an error message when a label referenced by a GOTO is not
  found in the script file..

Arguments:

Returns:

--*/
{
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_GOTO_TARGET_LABEL),
    HiiEnvHandle,
    TargetLabel,
    SEnvGetLineNumber ()
    );
  return ;
}
void
PrintStringLiteral(const CodeSource &src, const StringLiteralNode *node,
                   Printer pr, int tabDepth)
{
    pr("STR:");
    PrintToken(src, node->value(), pr);
}
Example #11
0
static int ListenUsingGCD(size_t noteCount, const char **noteNames)
{
    int         retVal;
    uint32_t    noteErr;
    size_t      noteIndex;
    int         noteTokens[noteCount];
    const int * noteTokensPtr;

    // We need to capture the base of the noteTokens array, but the compiler won't let us do that
    // because it's of variable size.  In our specific case this isn't a problem because, if things
    // go well, we never leave this routine but rather block forever in dispatch_main().  In a real
    // program you'd have to be a bit more careful (but then again, in a real program you wouldn't be
    // registering for an unbounded number of arbitrary notifications :-).
    
    noteTokensPtr = &noteTokens[0];

    noteErr = NOTIFY_STATUS_OK;
    for (noteIndex = 0; noteIndex < noteCount; noteIndex++) {
        noteErr = notify_register_dispatch(noteNames[noteIndex], &noteTokens[noteIndex], dispatch_get_main_queue(), ^(int token) {
            PrintToken(
                token,
                noteCount,
                noteTokensPtr, 
                noteNames
            );
        });
        if (noteErr != NOTIFY_STATUS_OK) {
            break;
        }
    }
void
PrintNumericLiteral(const CodeSource &src, const NumericLiteralNode *node,
                    Printer pr, int tabDepth)
{
    pr("NUM:");
    PrintToken(src, node->value(), pr);
}
void
PrintRegularExpressionLiteral(const CodeSource &src,
                              const RegularExpressionLiteralNode *node,
                              Printer pr, int tabDepth)
{
    pr("RE:");
    PrintToken(src, node->value(), pr);
}
void
PrintGetPropertyExpression(const CodeSource &src,
                           const GetPropertyExpressionNode *node,
                           Printer pr, int tabDepth)
{
    PrintNode(src, node->object(), pr, tabDepth);
    pr(".");
    PrintToken(src, node->property(), pr);
}
Example #15
0
static int ListenUsingMach(size_t noteCount, const char **noteNames)
    // Implements the "listenMach" command.  Register for the noteCount 
    // notifications whose names are in the noteNames array.  Then read 
    // the notification Mach port, printing information about any 
    // notifications that arrive.
{
    int         retVal;
    uint32_t    noteErr;
    size_t      noteIndex;
    int         noteTokens[noteCount];
    mach_port_t port = MACH_PORT_NULL;
    
    // Register.  The first time around this loop fd == -1 and so we don't 
    // specify NOTIFY_REUSE.  notify_register_mach_port then allocates 
    // a Mach port and returns it in port.  For subsequent iterations 
    // we /do/ specify NOTIFY_REUSE and notify_register_mach_port just 
    // reuses the existing port.

    noteErr = NOTIFY_STATUS_OK;
    for (noteIndex = 0; noteIndex < noteCount; noteIndex++) {
        noteErr = notify_register_mach_port(
            noteNames[noteIndex], 
            &port, 
            (port == MACH_PORT_NULL) ? 0 : NOTIFY_REUSE, 
            &noteTokens[noteIndex]
        );
        if (noteErr != NOTIFY_STATUS_OK) {
            break;
        }
    }
    if (noteErr != NOTIFY_STATUS_OK) {
        PrintNotifyError("registration failed", noteNames[noteIndex], noteErr);
        retVal = EXIT_FAILURE;
    } else {
        kern_return_t           kr;
        mach_msg_empty_rcv_t    msg;

        // Listen for and print any incoming notifications.
        
        fprintf(stdout, "Listening using Mach:\n");
        fflush(stdout);
        do {
            msg.header.msgh_local_port = port;
            msg.header.msgh_size = sizeof(msg);
            kr = mach_msg_receive(&msg.header);
            if (kr == KERN_SUCCESS) {
                PrintToken(msg.header.msgh_id, noteCount, noteTokens, noteNames);
            }
        } while (kr == KERN_SUCCESS);
        
        fprintf(stderr, "error reading Mach message: %s (0x%x)\n", mach_error_string(kr), kr);
        retVal = EXIT_FAILURE;
    }
    
    return retVal;
}
void
PrintLabelledStatement(const CodeSource &src,
                       const LabelledStatementNode *node,
                       Printer pr, int tabDepth)
{
    PrintToken(src, node->label(), pr);
    pr(":\n");
    PrintTabDepth(tabDepth, pr);
    PrintNode(src, node->statement(), pr, tabDepth);
}
Example #17
0
/**
  Gather and print cumulative data.

  Traverse the measurement records and:<BR>
  For each record with a Token listed in the CumData array:<BR>
     - Update the instance count and the total, minimum, and maximum durations.
  Finally, print the gathered cumulative statistics.

**/
VOID
ProcessCumulative(
  VOID
)
{
  UINT64                    AvgDur;         // the computed average duration
  UINT64                    Dur;
  UINT64                    MinDur;
  UINT64                    MaxDur;
  EFI_STRING                StringPtr;
  UINTN                     TIndex;
  EFI_STRING                StringPtrUnknown;

  StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
  StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
  PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER),
              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
  FreePool (StringPtr);
  FreePool (StringPtrUnknown);

  PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1));
  PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2));
  PrintToken (STRING_TOKEN (STR_DP_DASHES));

  for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
    if (CumData[TIndex].Count != 0) {
      AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
      AvgDur = DurationInMicroSeconds(AvgDur);
      Dur    = DurationInMicroSeconds(CumData[TIndex].Duration);
      MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
      MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);

      PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
                  CumData[TIndex].Name,
                  CumData[TIndex].Count,
                  Dur,
                  AvgDur,
                  MinDur,
                  MaxDur
                 );
    }
  }
}
/* El main solo define las variables necesarias para la funcion
 * PrintToken, crea el archivo de errores y por medio del loop 
 * se toma cada token y su salida es por el stdout si no hay errores
 * o por stderr si los hay.
*/
int main()
{

    TokenType token;
    OpenErrorFile();
    while ((token = (TokenType)yylex()) != 0) 
        PrintToken(token, yytext, yylval);
    CloseErrorFile();
    return 0;
}
void
PrintBreakStatement(const CodeSource &src, const BreakStatementNode *node,
                    Printer pr, int tabDepth)
{
    pr("break");
    if (node->label()) {
        pr(" ");
        PrintToken(src, *node->label(), pr);
    }
    pr(";\n");
}
void
PrintFunctionExpression(const CodeSource &src,
                        const FunctionExpressionNode *node,
                        Printer pr, int tabDepth)
{
    pr("function ");
    if (node->name())
        PrintToken(src, *node->name(), pr);
    pr("(");
    bool first = true;
    for (auto arg : node->formalParameters()) {
        if (!first)
            pr(",");
        PrintToken(src, arg, pr);
        first = false;
    }
    pr(") {\n");
    PrintSourceElementList(src, node->functionBody(), pr, tabDepth+1);
    PrintTabDepth(tabDepth, pr);
    pr("}");
}
void
PrintForInVarStatement(const CodeSource &src,
                       const ForInVarStatementNode *node,
                       Printer pr, int tabDepth)
{
    pr("for (var ");
    PrintToken(src, node->name(), pr);
    pr(" in ");
    PrintNode(src, node->object(), pr, tabDepth);
    pr(")\n");
    PrintTabDepth(tabDepth+1, pr);
    PrintNode(src, node->body(), pr, tabDepth+1);
}
void
PrintObjectSlotName(const CodeSource &src,
                    const ObjectLiteralNode::PropertyDefinition *defn,
                    Printer pr)
{
    if (defn->hasIdentifierName())
        pr("ID:");
    else if (defn->hasStringName())
        pr("STR:");
    else if (defn->hasNumericName())
        pr("NUM:");
    PrintToken(src, defn->name(), pr);
}
void
PrintTryCatchStatement(const CodeSource &src,
                       const TryCatchStatementNode *node,
                       Printer pr, int tabDepth)
{
    pr("try ");
    PrintBlock(src, node->tryBlock(), pr, tabDepth + 1);
    PrintTabDepth(tabDepth, pr);
    pr("catch (");
    PrintToken(src, node->catchName(), pr);
    pr(") ");
    PrintBlock(src, node->catchBlock(), pr, tabDepth + 1);
}
Example #24
0
void DwRfc1521Tokenizer::ParseToken()
{
    // Assume the field body has already been extracted.  That is, we don't
    // have to watch for the end of the field body or folding.  We just
    // treat any CRs or LFs as white space.
    mTokenStart = mNextStart;
    mTokenLength = 0;
    mTkType = eTkNull;
    if (mTokenStart >= mString.length()) {
        return;
    }
    // Skip leading space.  Also, since control chars are not permitted
    // in atoms, skip these, too.
    while (1) {
        if (mTokenStart >= mString.length()) {
            return;
        }
        if (!isspace(mString[mTokenStart]) && !iscntrl(mString[mTokenStart]))
            break;
        ++mTokenStart;
    }
    char ch = mString[mTokenStart];
    // Quoted string
    if (ch == '"') {
        mTkType = eTkQuotedString;
        ParseQuotedString();
    }
    // Comment
    else if (ch == '(') {
        mTkType = eTkComment;
        ParseComment();
    }
    // Domain literal
    else if (ch == '[') {
        mTkType = eTkDomainLiteral;
        ParseDomainLiteral();
    }
    // Special
    else if (istspecial(ch)) {
        mTkType = eTkTspecial;
        mTokenLength = 1;
        mToken = mString.substr(mTokenStart, 1);
        mNextStart = mTokenStart + 1;
    }
    // Atom
    else {
        mTkType = eTkToken;
        ParseAtom();
    }
    if (mDebugOut) PrintToken(mDebugOut);
}
Example #25
0
VOID
EFIAPI
SEnvImageTok (
  IN EFI_HANDLE       h,
  IN VOID             *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_LOADED_IMAGE_PROTOCOL *Image;
  CHAR16                    *ImageName;

  CHAR16                    *Tok;

  Image     = Interface;
  ImageName = LibGetImageName (Image);
  if (ImageName != NULL) {
    PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_IMAGE_2), HiiEnvHandle);
    Print (ImageName);
    Print (L") ");
    FreePool (ImageName);
  } else {
    Tok = LibDevicePathToStr (Image->FilePath);
    PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_IMAGE), HiiEnvHandle, Tok);
    FreePool (Tok);
  }
}
void
PrintDeclarationList(const CodeSource &src, const DeclarationList &decls,
                     Printer pr, int tabDepth)
{
    bool first = true;
    for (auto decl : decls) {
        if (!first)
            pr(", ");
        PrintToken(src, decl.name(), pr);
        if (decl.initialiser()) {
            pr(" = ");
            PrintNode(src, decl.initialiser(), pr, tabDepth);
        }
    };
}
Example #27
0
VOID
EFIAPI
SEnvBusSpecificDriverOverride (
  IN EFI_HANDLE       h,
  IN VOID             *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_STATUS                                Status;
  EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
  EFI_HANDLE                                ImageHandle;
  EFI_LOADED_IMAGE_PROTOCOL                 *Image;

  Print (L"\n");
  BusSpecificDriverOverride = Interface;
  do {
    Status = BusSpecificDriverOverride->GetDriver (
                                          BusSpecificDriverOverride,
                                          &ImageHandle
                                          );
    if (!EFI_ERROR (Status)) {
      Status = BS->HandleProtocol (
                    ImageHandle,
                    &gEfiLoadedImageProtocolGuid,
                    (VOID **) &Image
                    );
      if (!EFI_ERROR (Status)) {
        PrintToken (
          STRING_TOKEN (STR_SHELLENV_DPROT_DRV_FILE),
          HiiEnvHandle,
          SEnvHandleToNumber (ImageHandle),
          LibDevicePathToStr (Image->FilePath)
          );
      }
    }
  } while (!EFI_ERROR (Status));
}
Example #28
0
VOID
EFIAPI
SEnvDriverEFIVersionTok (
  IN EFI_HANDLE      h,
  IN VOID            *Interface
  )
{
  EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;

  DriverEfiVersion = (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *) Interface;
  PrintToken (
    STRING_TOKEN (STR_SHELLENV_PROTID_DRV_EFI_VER_TOK),
    HiiEnvHandle,
    DriverEfiVersion->FirmwareVersion
    );
}
Example #29
0
VOID
EFIAPI
SEnvImageDPathTok (
  IN EFI_HANDLE   h,
  IN VOID         *Interface
  )
/*++

Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
  CHAR16                    *Str;
  CHAR16                    *Disp;
  UINTN                     Len;

  DevicePath  = Interface;
  Str         = LibDevicePathToStr (DevicePath);
  Disp        = L"";

  //
  // Print device path token
  //
  if (Str) {
    Len   = StrLen (Str);
    Disp  = Str;
    if (Len > 30) {
      Disp    = Str + Len - 30;
      Disp[0] = '.';
      Disp[1] = '.';
    }
  }

  PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_IMAGE_DEVPATH), HiiEnvHandle, Disp);

  if (Str) {
    FreePool (Str);
  }
}
Example #30
0
VOID
EFIAPI
SEnvDebugSupport (
  IN EFI_HANDLE       h,
  IN VOID             *Interface
  )
/*++
Routine Description:

Arguments:

  h         - An EFI handle
  Interface - The interface

Returns:

--*/
{
  EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupport;

  DebugSupport = Interface;

  //
  // Dump Debug support info
  //
  Print (L"\n");
  Print (L"Isa = ");
  switch (DebugSupport->Isa) {
  case (IsaIa32):
    Print (L"IA-32");
    break;

  case (IsaIpf):
    Print (L"IPF");
    break;

  case (IsaEbc):
    Print (L"EBC");
    break;

  default:
    PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_UNKNOWN), HiiEnvHandle, DebugSupport->Isa);
    break;
  }
}