On 02/19/2013 05:04 PM, Corey Bryant wrote:
diff --git a/tpm/tpm.c b/tpm/tpm.c
new file mode 100644
index 0000000..51eaf7e
--- /dev/null
+++ b/tpm/tpm.c
@@ -0,0 +1,345 @@
+/*
+ * TPM configuration
+ *
+ * Copyright (C) 2011-2013 IBM Corporation
+ *
+ * Authors:
+ * Stefan Berger <stef...@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2
or later.
+ * See the COPYING file in the top-level directory.
+ *
+ * Based on net.c
+ */
+#include "config-host.h"
+
+#include "monitor/monitor.h"
+#include "qapi/qmp/qerror.h"
+#include "tpm_int.h"
+#include "tpm/tpm.h"
+#include "qemu/config-file.h"
+#include "qmp-commands.h"
+
+static QLIST_HEAD(, TPMBackend) tpm_backends =
+ QLIST_HEAD_INITIALIZER(tpm_backends);
+
+
+#define TPM_MAX_MODELS 1
+#define TPM_MAX_DRIVERS 2
+
+static TPMDriverOps const *be_drivers[TPM_MAX_DRIVERS] = {
+ NULL,
+};
+
+static enum TpmModel tpm_models[TPM_MAX_MODELS] = {
+ -1,
+};
+
+int tpm_register_model(enum TpmModel model)
It seems like there is inconsistency with the functions that are
#ifdef'd.
One example is that tpm_register_model() isn't surrounded by #ifdef
CONFIG_TPM..
+{
+ int i;
+
+ for (i = 0; i < TPM_MAX_MODELS; i++) {
+ if (tpm_models[i] == -1) {
+ tpm_models[i] = model;
+ return 0;
+ }
+ }
+ error_report("Could not register TPM model");
+ return 1;
+}
+
+static bool tpm_model_is_registered(enum TpmModel model)
+{
+ int i;
+
+ for (i = 0; i < TPM_MAX_MODELS; i++) {
+ if (tpm_models[i] == model) {
+ return true;
+ }
+ }
+ return false;
+}
+
+const TPMDriverOps *tpm_get_backend_driver(const char *type)
+{
+ int i;
+
+ for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {
+ if (!strcmp(TpmType_lookup[be_drivers[i]->type], type)) {
+ return be_drivers[i];
+ }
+ }
+
+ return NULL;
+}
+
+#ifdef CONFIG_TPM
+
+int tpm_register_driver(const TPMDriverOps *tdo)
..but tpm_register_driver() is surrounded by #ifdef CONFIG_TPM.
and? there's a stub function further below ...