summaryrefslogtreecommitdiff
path: root/src/lib/romstage_handoff.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-11-29 21:37:42 -0600
committerAaron Durbin <adurbin@chromium.org>2016-12-01 08:16:47 +0100
commitafe8aeed81003e941d91e8733ea7459a58d1a4d7 (patch)
treed82bc279ae5fd5b64df1bedd13eada3316616440 /src/lib/romstage_handoff.c
parent6c191d8af41859dd94a01c6a868a9186d0120923 (diff)
downloadcoreboot-afe8aeed81003e941d91e8733ea7459a58d1a4d7.tar.xz
lib: put romstage_handoff implementation in own compilation unit
Instead of putting all the functions inline just put the current implementation into a C file. That way all the implementation innards are not exposed. Lastly, fix up the fallout of compilation units not including the headers they actually use. Change-Id: I01fd25d158c0d5016405b73a4d4df3721c281b04 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/17648 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/lib/romstage_handoff.c')
-rw-r--r--src/lib/romstage_handoff.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/lib/romstage_handoff.c b/src/lib/romstage_handoff.c
new file mode 100644
index 0000000000..bdfdb642b8
--- /dev/null
+++ b/src/lib/romstage_handoff.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <cbmem.h>
+#include <console/console.h>
+#include <romstage_handoff.h>
+#include <rules.h>
+
+struct romstage_handoff {
+ /* Indicate if the current boot is an S3 resume. If
+ * CONFIG_RELOCTABLE_RAMSTAGE is enabled the chipset code is
+ * responsible for initializing this variable. Otherwise, ramstage
+ * will be re-loaded from cbfs (which can be slower since it lives
+ * in flash). */
+ uint8_t s3_resume;
+ uint8_t reboot_required;
+ uint8_t reserved[2];
+};
+
+static struct romstage_handoff *romstage_handoff_find_or_add(void)
+{
+ struct romstage_handoff *handoff;
+
+ /* cbmem_add() first does a find and uses the old location before the
+ * real add. However, it is important to know when the structure is not
+ * found so it can be initialized to 0. */
+ handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
+
+ if (handoff)
+ return handoff;
+
+ handoff = cbmem_add(CBMEM_ID_ROMSTAGE_INFO, sizeof(*handoff));
+
+ if (handoff != NULL)
+ memset(handoff, 0, sizeof(*handoff));
+ else
+ printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
+
+ return handoff;
+}
+
+int romstage_handoff_init(int is_s3_resume)
+{
+ struct romstage_handoff *handoff;
+
+ handoff = romstage_handoff_find_or_add();
+
+ if (handoff == NULL)
+ return -1;
+
+ handoff->s3_resume = is_s3_resume;
+
+ return 0;
+}
+
+int romstage_handoff_is_resume(void)
+{
+ struct romstage_handoff *handoff;
+
+ handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
+
+ if (handoff == NULL)
+ return 0;
+
+ return handoff->s3_resume;
+}