コード例 #1
0
ファイル: tpm_cmd_handler.c プロジェクト: johnxn/rockey-tpm
static TPM_RESULT execute_TPM_Startup(TPM_REQUEST *req, TPM_RESPONSE *rsp)
{
    BYTE *ptr;
    UINT32 len;
    TPM_STARTUP_TYPE startupType;
    /* unmarshal input */
    ptr = req->param;
    len = req->paramSize;
    if (tpm_unmarshal_TPM_STARTUP_TYPE(&ptr, &len, &startupType)
            || len != 0) return TPM_BAD_PARAMETER;
    /* execute command */
    return TPM_Startup(startupType);
}
コード例 #2
0
ファイル: tpmbios.c プロジェクト: P1119r1m/opentpm
int main(int argc, char *argv[])
{
   int 			ret = 0;
   int			i;			/* argc iterator */
   int			do_more = 1;
   unsigned char        startupparm = 0x1;      /* parameter for TPM_Startup(); */
   TPM_BOOL 		physicalPresenceCMDEnable = FALSE;
   
   TPM_setlog(0);      /* turn off verbose output */
   /* command line argument defaults */
   
   for (i=1 ; (i<argc) && (ret == 0) ; i++) {
       if (strcmp(argv[i],"-c") == 0) {
           startupparm = 0x01;
	   do_more = 1;
       }
       else if (strcmp(argv[i],"-d") == 0) {
	   do_more = 0;
           startupparm = 0x03;
       }
       else if (strcmp(argv[i],"-h") == 0) {
	   ret = ERR_BAD_ARG;
	   print_usage();
       }
       else if (strcmp(argv[i],"-v") == 0) {
	   TPM_setlog(1);
       }
       else if (strcmp(argv[i],"-n") == 0) {
	   startupparm = 0xff; 
	   do_more = 1;
       }
       else if (strcmp(argv[i],"-s") == 0) {
           startupparm = 0x2;
	   do_more = 1;
       }
       else if (strcmp(argv[i],"-o") == 0) {
	   do_more = 0;
       }
       else {
	   printf("\n%s is not a valid option\n", argv[i]);
	   ret = ERR_BAD_ARG;
	   print_usage();
       }
   }
   if (ret == 0) {
       if (0xff != startupparm) {
	   ret = TPM_Startup(startupparm);
	   if (ret != 0) {
	       printf("Error %s from TPM_Startup\n", 
		      TPM_GetErrMsg(ret));
	   }
       }
   }
   /* check to see if physicalPresenceCMDEnable is already set.  If it is, don't try to send it
      again as the command will fail if the lifetime lock is set. */
   if ((ret == 0) && do_more) {
       ret = getPhysicalCMDEnable(&physicalPresenceCMDEnable);
   }
   /* Sends the TSC_PhysicalPresence command to turn on physicalPresenceCMDEnable */
   if ((ret == 0) && do_more && !physicalPresenceCMDEnable) {
       ret = TSC_PhysicalPresence(0x20);
       if (ret != 0) {
	   printf("Error %s from TSC_PhysicalPresence\n",
		  TPM_GetErrMsg(ret));
       }
   }
   /* Sends the TSC_PhysicalPresence command to turn on physicalPresence */
   if ((ret == 0) && do_more) {
       ret = TSC_PhysicalPresence(0x08);
       if (ret != 0) {
	   printf("Error %s from TSC_PhysicalPresence\n",
		  TPM_GetErrMsg(ret));
       }
   }
   /* Sends the TPM_Process_PhysicalEnable command to clear disabled */
   if ((ret == 0) && do_more) {
       ret = TPM_PhysicalEnable();
       if (ret != 0) {
	   printf("Error %s from TPM_PhysicalEnable\n",
		  TPM_GetErrMsg(ret));
       }
   }
   /* Sends the TPM_Process_PhysicalSetDeactivated command to clear deactivated */
   if ((ret == 0) && do_more) {
       ret = TPM_PhysicalSetDeactivated(FALSE);
       if (ret != 0) {
	   printf("Error %s from TPM_PhysicalSetDeactivated\n",
		  TPM_GetErrMsg(ret));
       }
   }
   return ret;
}