1a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato * Use of this source code is governed by a BSD-style license that can be 3a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato * found in the LICENSE file. 4a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato */ 5a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 6a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato/* Create two spaces for uses in tests. OK if they already exist. 7a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato */ 8a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 9a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include <stdio.h> 10a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include <stdint.h> 11a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include <stdlib.h> 12a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 13a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include "tlcl.h" 14a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include "tlcl_tests.h" 15a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato#include "utility.h" 16a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 17a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzatoint main(int argc, char** argv) { 18a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato uint32_t perm; 19a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato uint32_t result; 20a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato uint32_t x; 21a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 22a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato TlclLibInit(); 23a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 24a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato TPM_CHECK(TlclStartupIfNeeded()); 25a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato TPM_CHECK(TlclSelfTestFull()); 26a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato TPM_CHECK(TlclAssertPhysicalPresence()); 279565edc4c967682809eccbe9c93960a365e6353dLuigi Semenzato TPM_CHECK(TlclForceClear()); 289565edc4c967682809eccbe9c93960a365e6353dLuigi Semenzato TPM_CHECK(TlclSetEnable()); 299565edc4c967682809eccbe9c93960a365e6353dLuigi Semenzato TPM_CHECK(TlclSetDeactivated(0)); 30a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 31a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)); 32a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato if (result == TPM_E_BADINDEX) { 33a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK; 34a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t))); 35a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato } 36a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 37a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato result = TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)); 38a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato if (result == TPM_E_BADINDEX) { 39a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato perm = TPM_NV_PER_PPWRITE; 409565edc4c967682809eccbe9c93960a365e6353dLuigi Semenzato TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t))); 41a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato } 42a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato 43a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato printf("TEST SUCCEEDED\n"); 44a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato exit(0); 45a7e19cffbee540a130d16b3b93ebfe250a774358Luigi Semenzato} 46