source: trunk/packages/xen-common/xen-common/tools/vtpm_manager/manager/tpmpassthrough.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/cpp
File size: 3.7 KB
Line 
1// ===================================================================
2//
3// Copyright (c) 2005, Intel Corp.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions
8// are met:
9//
10//   * Redistributions of source code must retain the above copyright
11//     notice, this list of conditions and the following disclaimer.
12//   * Redistributions in binary form must reproduce the above
13//     copyright notice, this list of conditions and the following
14//     disclaimer in the documentation and/or other materials provided
15//     with the distribution.
16//   * Neither the name of Intel Corporation nor the names of its
17//     contributors may be used to endorse or promote products derived
18//     from this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31// OF THE POSSIBILITY OF SUCH DAMAGE.
32// ===================================================================
33//
34// tpmpassthrough.c
35//
36//  Functions regarding passing DMI requests to HWTPM
37//
38// ==================================================================
39
40#include "tcg.h"
41#include "vtpm_manager.h"
42#include "vtpmpriv.h"
43#include "vtsp.h"
44#include "log.h"
45
46TPM_RESULT VTPM_Handle_TPM_Command( VTPM_DMI_RESOURCE *dmi,
47                                    buffer_t *inbuf, 
48                                    buffer_t *outbuf) {
49 
50  TPM_RESULT status = TPM_SUCCESS;
51  TPM_COMMAND_CODE *ord;               
52 
53  ord = (TPM_COMMAND_CODE *) (inbuf->bytes + sizeof(TPM_TAG) + sizeof(UINT32));
54 
55  switch (*ord) {
56   
57    // Forbidden for DMI use
58  case TPM_ORD_TakeOwnership:
59  case TPM_ORD_ChangeAuthOwner:
60  case TPM_ORD_DirWriteAuth:
61  case TPM_ORD_DirRead:
62  case TPM_ORD_AuthorizeMigrationKey:
63  case TPM_ORD_CreateMaintenanceArchive:
64  case TPM_ORD_LoadMaintenanceArchive:
65  case TPM_ORD_KillMaintenanceFeature:
66  case TPM_ORD_LoadManuMaintPub:
67  case TPM_ORD_ReadManuMaintPub:
68  case TPM_ORD_SelfTestFull:
69  case TPM_ORD_SelfTestStartup:
70  case TPM_ORD_CertifySelfTest:
71  case TPM_ORD_ContinueSelfTest:
72  case TPM_ORD_GetTestResult:
73  case TPM_ORD_Reset:
74  case TPM_ORD_OwnerClear:
75  case TPM_ORD_DisableOwnerClear:
76  case TPM_ORD_ForceClear:
77  case TPM_ORD_DisableForceClear:
78  case TPM_ORD_GetCapabilityOwner:
79  case TPM_ORD_OwnerSetDisable:
80  case TPM_ORD_PhysicalEnable:
81  case TPM_ORD_PhysicalDisable:
82  case TPM_ORD_SetOwnerInstall:
83  case TPM_ORD_PhysicalSetDeactivated:
84  case TPM_ORD_SetTempDeactivated:
85  case TPM_ORD_CreateEndorsementKeyPair:
86  case TPM_ORD_GetAuditEvent:
87  case TPM_ORD_GetAuditEventSigned:
88  case TPM_ORD_GetOrdinalAuditStatus:
89  case TPM_ORD_SetOrdinalAuditStatus:
90  case TPM_ORD_SetRedirection:
91  case TPM_ORD_FieldUpgrade:
92  case TSC_ORD_PhysicalPresence:
93    status = TPM_DISABLED_CMD;
94    goto abort_egress;
95    break;
96   
97  } // End ORD Switch
98 
99  // Call TCS with command
100 
101  TPMTRY(TPM_IOERROR, VTSP_RawTransmit( dmi->TCSContext,inbuf, outbuf) );
102 
103  goto egress;
104 
105 abort_egress:
106  vtpmloginfo(VTPM_LOG_VTPM, "TPM Command Failed in tpmpassthrough.\n");
107 egress:
108 
109  return status;
110}
Note: See TracBrowser for help on using the repository browser.