aboutsummaryrefslogtreecommitdiff
path: root/resources/depthcharge/patch/0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch
blob: 890791b2971b25c1c97d04944492a2c566a9852d (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 5ad9900434045ea97c536c98cb514bdb43114c12 Mon Sep 17 00:00:00 2001
From: Paul Kocialkowski <contact@paulk.fr>
Date: Sun, 9 Aug 2015 12:09:35 +0200
Subject: [PATCH 4/7] Adaptation for a read-only boot path when no vboot
 handoff data is found

When no vboot handoff data is found, this makes the unified depthcharge build
attempt to follow the read-only boot path.

vboot_select_firmware is called to grab the kernel key from the firmware header,
but it won't actually jump to a RW version of depthcharge.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 src/image/Makefile.inc                |  1 +
 src/image/startrw_stub.c              | 34 ++++++++++++++++++++++++++++++++++
 src/vboot/main.c                      | 17 ++++++++++++++++-
 src/vboot/util/commonparams-unified.c | 11 +++++++++--
 4 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100644 src/image/startrw_stub.c

diff --git a/src/image/Makefile.inc b/src/image/Makefile.inc
index 95aeda1..4b74c11 100644
--- a/src/image/Makefile.inc
+++ b/src/image/Makefile.inc
@@ -18,6 +18,7 @@
 depthcharge-y += fmap.c
 depthcharge-y += index.c
 readonly-y += startrw.c
+unified-y += startrw_stub.c
 
 trampoline-y += load_elf.c
 
diff --git a/src/image/startrw_stub.c b/src/image/startrw_stub.c
new file mode 100644
index 0000000..8e40302
--- /dev/null
+++ b/src/image/startrw_stub.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <libpayload.h>
+#include <lzma.h>
+
+#include "base/elf.h"
+#include "image/enter_trampoline.h"
+#include "image/startrw.h"
+#include "image/symbols.h"
+
+int start_rw_firmware(const void *compressed_image, uint32_t size)
+{
+	return 0;
+}
diff --git a/src/vboot/main.c b/src/vboot/main.c
index 7dc05f5..97a218d 100644
--- a/src/vboot/main.c
+++ b/src/vboot/main.c
@@ -82,6 +82,20 @@ static int vboot_init_handoff()
 	return vboot_do_init_out_flags(vboot_handoff->init_params.out_flags);
 }
 
+static int vboot_init_ro()
+{
+	// Set up the common param structure, clearing shared data.
+	if (common_params_init(1))
+		return 1;
+
+	// Initialize vboot.
+	if (vboot_init())
+		return 1;
+
+	// Select firmware.
+	return vboot_select_firmware();
+}
+
 int main(void)
 {
 	// Let the world know we're alive.
@@ -108,7 +122,8 @@ int main(void)
 
 	// Set up the common param structure, not clearing shared data.
 	if (vboot_init_handoff())
-		halt();
+		if (vboot_init_ro())
+			halt();
 
 	/* Fastboot is only entered in recovery path */
 	if (vboot_in_recovery())
diff --git a/src/vboot/util/commonparams-unified.c b/src/vboot/util/commonparams-unified.c
index 10fcb93..575dcfd 100644
--- a/src/vboot/util/commonparams-unified.c
+++ b/src/vboot/util/commonparams-unified.c
@@ -28,7 +28,14 @@
 int find_common_params(void **blob, int *size)
 {
 	struct vboot_handoff *vboot_handoff = lib_sysinfo.vboot_handoff;
-	*blob = &vboot_handoff->shared_data[0];
-	*size = ARRAY_SIZE(vboot_handoff->shared_data);
+
+	if (vboot_handoff != NULL) {
+		*blob = &vboot_handoff->shared_data[0];
+		*size = ARRAY_SIZE(vboot_handoff->shared_data);
+	} else {
+		*blob = shared_data_blob;
+		*size = sizeof(shared_data_blob);
+	}
+
 	return 0;
 }
-- 
1.9.1