/*
 *  ======== main ========
 */
int main(int argc, char **argv)
{
	INT nStrmMode = 0;
	FILE *inFile = NULL;	/* Input file handle. */
	FILE *outFile = NULL;	/* Output file handle. */
	struct STRMCOPY_TASK strmcopyTask;
	int status = 0;

	DspManager_Open(argc, NULL);

	/* Process command line arguments, open data files: */
	status = ProcessArgs(argc, argv, &inFile, &outFile, &nStrmMode);
	strmcopyTask.hProcessor = NULL;
	strmcopyTask.hNode = NULL;
	strmcopyTask.hInStream = NULL;
	strmcopyTask.hOutStream = NULL;
	strmcopyTask.ppInBufs = NULL;
	strmcopyTask.ppOutBufs = NULL;
	strmcopyTask.nStrmMode = nStrmMode;
	if (DSP_SUCCEEDED(status)) {
		/* Perform processor level initialization. */
		status = InitializeProcessor(&strmcopyTask);
	}
	if (DSP_SUCCEEDED(status)) {
		/* Perform node level initialization. */
		status = InitializeNode(&strmcopyTask);
		if (DSP_SUCCEEDED(status)) {
			/* Perform stream level initialization. */
			status = InitializeStreams(&strmcopyTask);
			if (DSP_SUCCEEDED(status)) {
				/* Run task. */
				status = RunTask(&strmcopyTask, inFile, outFile);
				if (DSP_SUCCEEDED(status)) {
					fprintf(stdout, "RunTask succeeded.\n");
				} else {
					fprintf(stdout, "RunTask failed.\n");
				}
			}
		}
	}
	/* Close opened files. */
	if (inFile) {
		fclose(inFile);
	}
	if (outFile) {
		fclose(outFile);
	}
	CleanupStreams(&strmcopyTask);
	CleanupNode(&strmcopyTask);
	CleanupProcessor(&strmcopyTask);
	DspManager_Close(0, NULL);
	/*printf("Hit enter to exit:  ");
	   (void)getchar(); */
	return (DSP_SUCCEEDED(status) ? 0 : -1);
}
Beispiel #2
0
/*
 *  ======== main ========
 */
int
main(int argc, char **argv)
{
	struct SCALE_TASK scaleTask;
	int status = 0;

	status = (DBAPI)DspManager_Open(0, NULL);

	if (DSP_FAILED(status)) {
		printf("\nFATAL ERROR: Bridge Initialisation FAILED\n");
		return 0;
	}

	status = ProcessArgs(argc, argv, &scaleTask);

	/* initialize context object */
	scaleTask.hProcessor = NULL;
	scaleTask.hNode = NULL;
	scaleTask.hInStream = NULL;
	scaleTask.hOutStream = NULL;
	scaleTask.pInBuf = NULL;
	scaleTask.pOutBuf = NULL;

	if (DSP_SUCCEEDED(status)) {
		/* do processor level initialization */
		status = InitializeProcessor(&scaleTask);
		if (DSP_SUCCEEDED(status)) {
			/* do node level initialization */
			status = InitializeNode(&scaleTask);
			if (DSP_SUCCEEDED(status)) {
				/* do stream level initialization */
				status = InitializeStreams(&scaleTask);
				if (DSP_SUCCEEDED(status)) {
					/* do processing */
					status = RunTask(&scaleTask);
					if (DSP_SUCCEEDED(status)) {
						fprintf(stdout, "\nRunTask succeeded.\n");
					} else {
						fprintf(stdout, "\nRunTask failed.\n");
					}
				}
			}
		}
	}
	CleanupStreams(&scaleTask);
	CleanupNode(&scaleTask);
	CleanupProcessor(&scaleTask);
	status = DspManager_Close(0, NULL);
	if (DSP_FAILED(status)) {
		printf("\nERROR: Bridge Close FAILED\n");
	}
	return (DSP_SUCCEEDED(status) ? 0 : -1);
}
Beispiel #3
0
/**
  The user Entry Point for Application. The user code starts with this function
  as the real entry point for the image goes into a library that calls this
  function.

  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
  @param[in] SystemTable    A pointer to the EFI System Table.

  @retval EFI_SUCCESS       The entry point is executed successfully.
  @retval other             Some error occurs when executing this entry point.

**/
EFI_STATUS
EFIAPI
GdbStubEntry (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS                  Status;
  EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupport;
  UINTN                       HandleCount;
  EFI_HANDLE                  *Handles;
  UINTN                       Index;
  UINTN                       Processor;
  BOOLEAN                     IsaSupported;

  Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
  if (EFI_ERROR (Status)) {
    gDebugImageTableHeader = NULL;
  }

  Status = gBS->LocateHandleBuffer (
                  ByProtocol,
                  &gEfiDebugSupportProtocolGuid,
                  NULL,
                  &HandleCount,
                  &Handles
                  );
  if (EFI_ERROR (Status)) {
    DEBUG ((EFI_D_ERROR, "Debug Support Protocol not found\n"));

    return Status;
  }

  DebugSupport = NULL;
  IsaSupported = FALSE;
  do {
    HandleCount--;
    Status = gBS->HandleProtocol (
                    Handles[HandleCount],
                    &gEfiDebugSupportProtocolGuid,
                    (VOID **) &DebugSupport
                    );
    if (!EFI_ERROR (Status)) {
      if (CheckIsa (DebugSupport->Isa)) {
        // We found what we are looking for so break out of the loop
        IsaSupported = TRUE;
        break;
      }
    }
  } while (HandleCount > 0);
  FreePool (Handles);

  if (!IsaSupported) {
    DEBUG ((EFI_D_ERROR, "Debug Support Protocol does not support our ISA\n"));

    return EFI_NOT_FOUND;
  }

  Status = DebugSupport->GetMaximumProcessorIndex (DebugSupport, &gMaxProcessorIndex);
  ASSERT_EFI_ERROR (Status);

  DEBUG ((EFI_D_INFO, "Debug Support Protocol ISA %x\n", DebugSupport->Isa));
  DEBUG ((EFI_D_INFO, "Debug Support Protocol Processor Index %d\n", gMaxProcessorIndex));

  // Call processor-specific init routine
  InitializeProcessor ();

  for (Processor = 0; Processor <= gMaxProcessorIndex; Processor++) {
    for (Index = 0; Index < MaxEfiException (); Index++) {
      Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor,  GdbExceptionHandler, gExceptionType[Index].Exception);
      ASSERT_EFI_ERROR (Status);
    }
    //
    // Current edk2 DebugPort is not interrupt context safe so we can not use it
    //
    Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, Processor, GdbPeriodicCallBack);
    ASSERT_EFI_ERROR (Status);
  }

  //
  // This even fires every time an image is added. This allows the stub to know when gdb needs
  // to update the symbol table.
  //
  Status = gBS->CreateEvent (
                  EVT_NOTIFY_SIGNAL,
                  TPL_CALLBACK,
                  GdbSymbolEventHandler,
                  NULL,
                  &gEvent
                  );
  ASSERT_EFI_ERROR (Status);

  //
  // Register for protocol notifications on this event
  //
  Status = gBS->RegisterProtocolNotify (
                  &gEfiLoadedImageProtocolGuid,
                  gEvent,
                  &gGdbSymbolEventHandlerRegistration
                  );
  ASSERT_EFI_ERROR (Status);


 if (PcdGetBool (PcdGdbSerial)) {
   GdbInitializeSerialConsole ();
 }

  return EFI_SUCCESS;
}