aboutsummaryrefslogtreecommitdiff
path: root/board-qemu/slof/vtpm-sml.fs
blob: 865db062cbd94564190e77fceb45c464281e9e4e (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
\ *****************************************************************************
\ * 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
\ ****************************************************************************/

" /" find-device

new-device

false VALUE    vtpm-debug?

\ create /ibm,vtpm
s" ibm,vtpm" 2dup device-name device-type

\
\ only internal API calls
\

: separator-event ( start-pcr end-pcr -- )
    tpm-add-event-separators                   ( errcode )
    ?dup IF
        ." VTPM: Error code from tpm-add-event-separators: " . cr
    THEN
;

80 CONSTANT BCV_DEVICE_HDD

: measure-hdd-mbr ( addr length -- )
    0 7 separator-event
    BCV_DEVICE_HDD                             ( addr length bootdrv )
    -rot                                       ( bootdrv addr length )
    tpm-measure-bcv-mbr                        ( errcode )
    ?dup IF
        ." VTPM: Error code from tpm-measure-hdd: " . cr
    THEN
;

: measure-gpt ( )
    0 7 separator-event
    tpm-measure-gpt
    ?dup IF
        ." VTPM: Error code from tpm-measure-gpt: " . cr
    THEN
;

: leave-firmware ( -- )
    tpm-leave-firmware                         ( errcode )
    ?dup IF
        ." VTPM: Error code from tpm-leave-firmware: " . cr
    THEN
;

: measure-scrtm ( -- )
    tpm-measure-scrtm                          ( errcode )
    ?dup IF
        ." VTPM: Error code from tpm-measure-scrtm: " . cr
    THEN
;

: vtpm-menu
    tpm-is-working IF
        tpm20-menu
    THEN
;

: open  true ;
: close ;

finish-device
device-end

s" /ibm,vtpm" find-node ?dup IF
  s" measure-scrtm" rot $call-static
THEN