aboutsummaryrefslogtreecommitdiff
path: root/board-qemu/slof/vio-vtpm-cdriver.fs
blob: 51b3b9fbc853dbf41ee5b71309c51c53cec4896b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
\ *****************************************************************************
\ * Copyright (c) 2015-2020 IBM Corporation
\ * All rights reserved.
\ * This program and the accompanying materials
\ * are made available under the terms of the BSD License
\ * which accompanies this distribution, and is available at
\ * http://www.opensource.org/licenses/bsd-license.php
\ *
\ * Contributors:
\ *     IBM Corporation - initial implementation
\ ****************************************************************************/

." Populating " pwd cr

false VALUE vtpm-debug?
0     VALUE vtpm-unit

0     VALUE    log-base
40000 CONSTANT LOG-SIZE   \ 256k per VTPM FW spec.

e     CONSTANT VTPM_DRV_ERROR_SML_HANDED_OVER

LOG-SIZE BUFFER: log-base

\ firmware API call
: sml-get-allocated-size ( -- buffer-size)
   LOG-SIZE
;

\ firmware API call
: sml-get-handover-size ( -- size)
   tpm-get-logsize
;

\ firmware API call
: sml-handover ( dest size -- )
   log-base    ( dest size src )
   -rot        ( src dest size )
   move

   VTPM_DRV_ERROR_SML_HANDED_OVER tpm-driver-set-failure-reason
;

\ firmware API call
: get-failure-reason ( -- reason )
   tpm-driver-get-failure-reason           ( reason )
;

0 0 s" ibm,sml-efi-reformat-supported" property

\ firmware API call
: reformat-sml-to-efi-alignment ( -- success )
   true
;

: open true ;
: close ;

: vtpm-cleanup ( -- )
   vtpm-debug? IF ." VTPM: Disabling RTAS bypass" cr THEN
   tpm-finalize
   \ Disable TCE bypass
   vtpm-unit 0 rtas-set-tce-bypass
;

: vtpm-init ( -- success )
   0 0 get-node open-node ?dup 0= IF false EXIT THEN
   my-self >r
   dup to my-self

   vtpm-debug? IF ." VTPM: Initializing for c-driver" cr THEN

   my-unit to vtpm-unit

   \ Enable TCE bypass special qemu feature
   vtpm-unit 1 rtas-set-tce-bypass

   \ Have TCE bypass cleaned up
   ['] vtpm-cleanup add-quiesce-xt

   \ close temporary node
   close-node
   r> to my-self

   tpm-start ?dup 0= IF
      vtpm-debug? IF ." VTPM: Success from tpm-start" cr THEN
      true
   ELSE
      ." VTPM: Error code from tpm-start: " . cr
      false
   THEN
;

\ inititialize unit and set RTAS bypass
vtpm-init IF
   \ pass logbase and size to the C driver; we may only do this after
   \ init of the lower levels since this calls needs to know the PCR banks
   \ when setting up the log
   log-base LOG-SIZE tpm-set-log-parameters
   s" vtpm-sml.fs" included
ELSE
   ." VTPM: vtpm-init failed" cr
THEN