Ejemplo n.º 1
0
int OpenHandle(struct cmd_desc *cmddint, struct atom *atoms) {

unsigned int arg;
char *cd = NULL, *cv = NULL;
SLbHandle hnd = NULL;
SLbErr err;

   arg = cmddint->pa + 1;

   if (atoms == (struct atom *) VERBOSE_HELP) {
      printf("OpenHandle:[<device name> <revision>]\n");
      return arg;
   }

   if ((cntoph == 0) && (curoph == 0)) {
      bzero((void *) handles, (MAX_HANDLES * sizeof(SLbHandle)));
   }

   if (getenv("LD_LIBRARY_PATH") == NULL) {
      printf("OpenHandle:Warning:LD_LIBRARY_PATH not set\n");
   }

   if ((++atoms)->type == String) {
      cd = atoms->text;

      if ((++atoms)->type == String) {
	 cv = atoms->text;

	 hnd = FindOpenHandle(cd,cv);
	 if (hnd == NULL) {
	    err = SLbOpenHandle(&hnd,cd,cv);
	    if (err) {
	       fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
	       return arg;
	    }
	    if (InsertHandle(hnd) == 0) {
	       err = SLbCloseHandle(hnd);
	       if (err == SLbErrSUCCESS) err = SLbErrMEMORY;
	       fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
	       return arg;
	    }
	 }
      } else {
	 fprintf(stderr,"OpenHandle:Missing version:%s\n",cd);
      }
   }
   ListHandles();
   return arg;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[], char *envp[])
{

	SLbHandle hnd = NULL;
	SLbErr err;

	printf("Opening:libvd80.so.1.0 by default\n");
	err = SLbOpenHandle(&hnd,"vd80","1.0");
	if (err) {
		fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
		exit(err);
	}
	if (InsertHandle(hnd) == 0) {
		err = SLbCloseHandle(hnd);
		if (err == SLbErrSUCCESS) err = SLbErrMEMORY;
		fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
		exit(err);
	}
	return extest_init(argc, argv, "vd80");
}
VOID
InsertChildHandles (
  IN OUT UINTN          *NoHandles,
  IN OUT EFI_HANDLE     *HandleBuffer,
  IN EFI_HANDLE         Handle,
  IN BOOLEAN            Recursive
  )
{
  EFI_STATUS                            Status;
  BOOLEAN                               Result;
  UINTN                                 Index1;
  UINTN                                 Index2;
  UINTN                                 ProtocolBufferCount;
  EFI_GUID                              **ProtocolBuffer;
  UINTN                                 EntryCount;
  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY   *EntryBuffer;

  //
  // Insert the handle itself
  //
  Result = InsertHandle (
             NoHandles,
             HandleBuffer,
             Handle
             );
  if (!Result) {
    //
    // Return if this handle already exists (stands for it has been processed.)
    //
    return;
  }

  //
  // Locate all protocols on the handle
  //
  Status = gtBS->ProtocolsPerHandle (
                   Handle,
                   &ProtocolBuffer,
                   &ProtocolBufferCount
                   );
  if (EFI_ERROR (Status)) {
    return;
  }

  //
  // Get the open protocol information for each protocol
  //
  for (Index1 = 0; Index1 < ProtocolBufferCount; Index1++) {
    //
    // Get the open protocol information
    //
    Status = gtBS->OpenProtocolInformation (
                     Handle,
                     ProtocolBuffer[Index1],
                     &EntryBuffer,
                     &EntryCount
                     );
    if (EFI_ERROR (Status)) {
      continue;
    }

    for (Index2 = 0; Index2 < EntryCount; Index2++) {
      //
      // Deal with the protocol opened by driver or by child controller
      //
      if ((EntryBuffer[Index2].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER          ) ||
          (EntryBuffer[Index2].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER)) {
        //
        // Insert the agent handle
        //
        InsertHandle (
          NoHandles,
          HandleBuffer,
          EntryBuffer[Index2].AgentHandle
          );

        //
        // Insert the controller handle
        //
        if (Recursive) {
          InsertChildHandles (
            NoHandles,
            HandleBuffer,
            EntryBuffer[Index2].ControllerHandle,
            Recursive
            );
        }
      }
    }

    gtBS->FreePool (EntryBuffer);
  }

  //
  // Free resources
  //
  gtBS->FreePool (ProtocolBuffer);
}