Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: utility/tpm-nvsize

Issue 4087012: Test the tpm recovery script with a real TPM. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git
Patch Set: cleanup Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utility/chromeos_tpm_recovery_test ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /bin/sh -e 1 #! /bin/sh -e
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 # 5 #
6 # Finds the largest NV space that can be defined on the TPM in this state 6 # Finds the largest NV space that can be defined on the TPM in this state
7 # (i.e. without removing existing spaces). 7 # (i.e. without removing existing spaces).
8 # 8 #
9 # The TPM must be unowned, and physical presence must be on. 9 # The TPM must be unowned, and physical presence must be on.
10 10
11 low=1 11 low=1
12 high=1500 12 high=1500
13 try=$high 13 try=$high
14 14
15 # Binary search with no upper bound 15 # Binary search with no upper bound
16 while true; do 16 while true; do
17 ## echo trying $try [ $low $high ] 17 ## echo trying $try [ $low $high ]
18 if /usr/bin/tpmc definespace 0xf004 $(printf "0x%x" $try) 0x1 \ 18 if /usr/bin/tpmc definespace 0xf004 $(printf "0x%x" $try) 0x1 \
19 > dev/null 2>&1; then 19 > /dev/null 2>&1; then
20 # definespace success: end, or $try must grow 20 # definespace success: end, or $try must grow
21 if [ $try -eq $low ]; then 21 if [ $try -eq $low ]; then
22 echo $low 22 echo $low
23 exit 0 23 exit 0
24 elif [ $try -lt $high ]; then 24 elif [ $try -lt $high ]; then
25 low=$try 25 low=$try
26 try=$(( ( $high + $low ) / 2 )) 26 try=$(( ( $high + $low ) / 2 ))
27 else 27 else
28 # special case: when try == high, expand the search 28 # special case: when try == high, expand the search
29 low=$try 29 low=$try
(...skipping 11 matching lines...) Expand all
41 fi 41 fi
42 # definespace failure: end, or $try must shrink 42 # definespace failure: end, or $try must shrink
43 if [ $try -eq $low ]; then 43 if [ $try -eq $low ]; then
44 echo 0 44 echo 0
45 exit 0 45 exit 0
46 fi 46 fi
47 high=$try 47 high=$try
48 try=$(( ( $high + $low ) / 2 )) 48 try=$(( ( $high + $low ) / 2 ))
49 fi 49 fi
50 done 50 done
OLDNEW
« no previous file with comments | « utility/chromeos_tpm_recovery_test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698