1 2/* 3 * Licensed Materials - Property of IBM 4 * 5 * trousers - An open source TCG Software Stack 6 * 7 * (C) Copyright International Business Machines Corp. 2004-2006 8 * 9 */ 10 11#include <stdlib.h> 12#include <stdio.h> 13#include <string.h> 14#include <assert.h> 15 16#include "trousers/tss.h" 17#include "trousers/trousers.h" 18#include "trousers_types.h" 19#include "spi_utils.h" 20#include "capabilities.h" 21#include "tsplog.h" 22#include "hosttable.h" 23#include "tcsd_wrap.h" 24#include "obj.h" 25#include "rpc_tcstp_tsp.h" 26 27 28TSS_RESULT 29RPC_GetCapability_TP(struct host_table_entry *hte, 30 TCPA_CAPABILITY_AREA capArea, /* in */ 31 UINT32 subCapSize, /* in */ 32 BYTE * subCap, /* in */ 33 UINT32 * respSize, /* out */ 34 BYTE ** resp) /* out */ 35{ 36 TSS_RESULT result; 37 38 initData(&hte->comm, 4); 39 hte->comm.hdr.u.ordinal = TCSD_ORD_TCSGETCAPABILITY; 40 LogDebugFn("TCS Context: 0x%x", hte->tcsContext); 41 42 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm)) 43 return TSPERR(TSS_E_INTERNAL_ERROR); 44 if (setData(TCSD_PACKET_TYPE_UINT32, 1, &capArea, 0, &hte->comm)) 45 return TSPERR(TSS_E_INTERNAL_ERROR); 46 if (setData(TCSD_PACKET_TYPE_UINT32, 2, &subCapSize, 0, &hte->comm)) 47 return TSPERR(TSS_E_INTERNAL_ERROR); 48 if (setData(TCSD_PACKET_TYPE_PBYTE, 3, subCap, subCapSize, &hte->comm)) 49 return TSPERR(TSS_E_INTERNAL_ERROR); 50 51 result = sendTCSDPacket(hte); 52 53 if (result == TSS_SUCCESS) 54 result = hte->comm.hdr.u.result; 55 56 if (result == TSS_SUCCESS) { 57 if (getData(TCSD_PACKET_TYPE_UINT32, 0, respSize, 0, &hte->comm)) { 58 result = TSPERR(TSS_E_INTERNAL_ERROR); 59 goto done; 60 } 61 62 *resp = (BYTE *) calloc_tspi(hte->tspContext, *respSize); 63 if (*resp == NULL) { 64 LogError("malloc of %u bytes failed.", *respSize); 65 result = TSPERR(TSS_E_OUTOFMEMORY); 66 goto done; 67 } 68 if (getData(TCSD_PACKET_TYPE_PBYTE, 1, *resp, *respSize, &hte->comm)) { 69 free_tspi(hte->tspContext, *resp); 70 result = TSPERR(TSS_E_INTERNAL_ERROR); 71 } 72 } 73 74done: 75 return result; 76} 77