| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Contains the implementation of class TpmInit | 5 // Contains the implementation of class TpmInit |
| 6 | 6 |
| 7 #include "tpm_init.h" | 7 #include "tpm_init.h" |
| 8 | 8 |
| 9 #include <base/logging.h> | 9 #include <base/logging.h> |
| 10 #include <base/platform_thread.h> | 10 #include <base/platform_thread.h> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 bool TpmInit::StartInitializeTpm() { | 76 bool TpmInit::StartInitializeTpm() { |
| 77 initialize_called_ = true; | 77 initialize_called_ = true; |
| 78 if (!PlatformThread::CreateNonJoinable(0, tpm_init_task_.get())) { | 78 if (!PlatformThread::CreateNonJoinable(0, tpm_init_task_.get())) { |
| 79 LOG(ERROR) << "Unable to create TPM initialization background thread."; | 79 LOG(ERROR) << "Unable to create TPM initialization background thread."; |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool TpmInit::IsTpmReady() { | 85 bool TpmInit::IsTpmReady() { |
| 86 // The TPM is not "ready" if the init call has not completed. It may be in | 86 // The TPM is "ready" if it is enabled, owned, and not being owned. |
| 87 // the middle of taking ownership. | |
| 88 if (!task_done_) { | |
| 89 return false; | |
| 90 } | |
| 91 // If initialize_took_ownership_ is true, then the TPM went through a full | |
| 92 // succesful ownership cycle in InitializeTpm() | |
| 93 if (initialize_took_ownership_) { | |
| 94 return true; | |
| 95 } | |
| 96 // If we get here, then the call to InitializeTpm() is complete and it | |
| 97 // returned false. That merely means that it did not successfully take | |
| 98 // ownership, which is the common case after ownership is established on OOBE. | |
| 99 // In that case, the TPM is ready if it is enabled and owned. | |
| 100 return (tpm_init_task_->get_tpm()->IsEnabled() && | 87 return (tpm_init_task_->get_tpm()->IsEnabled() && |
| 101 tpm_init_task_->get_tpm()->IsOwned()); | 88 tpm_init_task_->get_tpm()->IsOwned() && |
| 89 !tpm_init_task_->get_tpm()->IsBeingOwned()); |
| 102 } | 90 } |
| 103 | 91 |
| 104 bool TpmInit::IsTpmEnabled() { | 92 bool TpmInit::IsTpmEnabled() { |
| 105 return tpm_init_task_->get_tpm()->IsEnabled(); | 93 return tpm_init_task_->get_tpm()->IsEnabled(); |
| 106 } | 94 } |
| 107 | 95 |
| 108 bool TpmInit::IsTpmOwned() { | 96 bool TpmInit::IsTpmOwned() { |
| 109 return tpm_init_task_->get_tpm()->IsOwned(); | 97 return tpm_init_task_->get_tpm()->IsOwned(); |
| 110 } | 98 } |
| 111 | 99 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 139 LOG(ERROR) << "TPM initialization took " << initialization_time_ << "ms"; | 127 LOG(ERROR) << "TPM initialization took " << initialization_time_ << "ms"; |
| 140 } | 128 } |
| 141 task_done_ = true; | 129 task_done_ = true; |
| 142 if (notify_callback_) { | 130 if (notify_callback_) { |
| 143 notify_callback_->InitializeTpmComplete(initialize_result, | 131 notify_callback_->InitializeTpmComplete(initialize_result, |
| 144 initialize_took_ownership_); | 132 initialize_took_ownership_); |
| 145 } | 133 } |
| 146 } | 134 } |
| 147 | 135 |
| 148 } // namespace tpm_init | 136 } // namespace tpm_init |
| OLD | NEW |