1\ ***************************************************************************** 2\ * Copyright (c) 2015-2020 IBM Corporation 3\ * All rights reserved. 4\ * This program and the accompanying materials 5\ * are made available under the terms of the BSD License 6\ * which accompanies this distribution, and is available at 7\ * http://www.opensource.org/licenses/bsd-license.php 8\ * 9\ * Contributors: 10\ * IBM Corporation - initial implementation 11\ ****************************************************************************/ 12 13." Populating " pwd cr 14 15false VALUE vtpm-debug? 160 VALUE vtpm-unit 17 180 VALUE log-base 1940000 CONSTANT LOG-SIZE \ 256k per VTPM FW spec. 20 21e CONSTANT VTPM_DRV_ERROR_SML_HANDED_OVER 22 23LOG-SIZE BUFFER: log-base 24 25\ firmware API call 26: sml-get-allocated-size ( -- buffer-size) 27 LOG-SIZE 28; 29 30\ firmware API call 31: sml-get-handover-size ( -- size) 32 tpm-get-logsize 33; 34 35\ firmware API call 36: sml-handover ( dest size -- ) 37 log-base ( dest size src ) 38 -rot ( src dest size ) 39 move 40 41 VTPM_DRV_ERROR_SML_HANDED_OVER tpm-driver-set-failure-reason 42; 43 44\ firmware API call 45: get-failure-reason ( -- reason ) 46 tpm-driver-get-failure-reason ( reason ) 47; 48 490 0 s" ibm,sml-efi-reformat-supported" property 50 51\ firmware API call 52: reformat-sml-to-efi-alignment ( -- success ) 53 true 54; 55 56: open true ; 57: close ; 58 59: vtpm-cleanup ( -- ) 60 vtpm-debug? IF ." VTPM: Disabling RTAS bypass" cr THEN 61 tpm-finalize 62 \ Disable TCE bypass 63 vtpm-unit 0 rtas-set-tce-bypass 64; 65 66: vtpm-init ( -- success ) 67 0 0 get-node open-node ?dup 0= IF false EXIT THEN 68 my-self >r 69 dup to my-self 70 71 vtpm-debug? IF ." VTPM: Initializing for c-driver" cr THEN 72 73 my-unit to vtpm-unit 74 75 \ Enable TCE bypass special qemu feature 76 vtpm-unit 1 rtas-set-tce-bypass 77 78 \ Have TCE bypass cleaned up 79 ['] vtpm-cleanup add-quiesce-xt 80 81 \ close temporary node 82 close-node 83 r> to my-self 84 85 tpm-start ?dup 0= IF 86 vtpm-debug? IF ." VTPM: Success from tpm-start" cr THEN 87 true 88 ELSE 89 ." VTPM: Error code from tpm-start: " . cr 90 false 91 THEN 92; 93 94\ inititialize unit and set RTAS bypass 95vtpm-init IF 96 \ pass logbase and size to the C driver; we may only do this after 97 \ init of the lower levels since this calls needs to know the PCR banks 98 \ when setting up the log 99 log-base LOG-SIZE tpm-set-log-parameters 100 s" vtpm-sml.fs" included 101ELSE 102 ." VTPM: vtpm-init failed" cr 103THEN 104