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

Side by Side Diff: lib/chromeos/os_storage.c

Issue 6804009: HACK: Pass data from firmware to kernel (Closed) Base URL: ssh://gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Fill-in details Created 9 years, 8 months 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
« arch/arm/lib/bootm.c ('K') | « arch/arm/lib/bootm.c ('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 /* 1 /*
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2 * Copyright (c) 2011 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 * Alternatively, this software may be distributed under the terms of the 6 * Alternatively, this software may be distributed under the terms of the
7 * GNU General Public License ("GPL") version 2 as published by the Free 7 * GNU General Public License ("GPL") version 2 as published by the Free
8 * Software Foundation. 8 * Software Foundation.
9 */ 9 */
10 10
11 #include <common.h> 11 #include <common.h>
12 #include <malloc.h> 12 #include <malloc.h>
13 #include <part.h> 13 #include <part.h>
14 #include <chromeos/os_storage.h> 14 #include <chromeos/os_storage.h>
15 15
16 /* TODO For load fmap; remove when not used */
17 #include <chromeos/firmware_storage.h>
18
19 /* TODO For strcpy; remove when not used */
20 #include <linux/string.h>
21
16 #include <boot_device.h> 22 #include <boot_device.h>
17 #include <load_kernel_fw.h> 23 #include <load_kernel_fw.h>
18 #include <vboot_nvstorage.h> 24 #include <vboot_nvstorage.h>
19 #include <vboot_struct.h> 25 #include <vboot_struct.h>
20 26
21 #define PREFIX "boot_device: " 27 #define PREFIX "boot_device: "
22 28
23 #define BACKUP_LBA_OFFSET 0x20 29 #define BACKUP_LBA_OFFSET 0x20
24 30
25 static struct { 31 static struct {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 debug(PREFIX "LoadKernel status: %d\n", status); 213 debug(PREFIX "LoadKernel status: %d\n", status);
208 if (status == LOAD_KERNEL_SUCCESS) { 214 if (status == LOAD_KERNEL_SUCCESS) {
209 debug(PREFIX "partition_number: 0x%08x\n", 215 debug(PREFIX "partition_number: 0x%08x\n",
210 (int) params->partition_number); 216 (int) params->partition_number);
211 debug(PREFIX "bootloader_address: 0x%08x\n", 217 debug(PREFIX "bootloader_address: 0x%08x\n",
212 (int) params->bootloader_address); 218 (int) params->bootloader_address);
213 debug(PREFIX "bootloader_size: 0x%08x\n", 219 debug(PREFIX "bootloader_size: 0x%08x\n",
214 (int) params->bootloader_size); 220 (int) params->bootloader_size);
215 } 221 }
216 222
223 /*
224 * TODO(clchiou): This is an urgent hack for bringing up factory. We
225 * fill in data that will be used by kernel at last 1MB space.
226 *
227 * Rewrite this part after the protocol specification between
228 * Chrome OS firmware and kernel is finalized.
229 */
230 if (status == LOAD_KERNEL_SUCCESS) {
231 DECLARE_GLOBAL_DATA_PTR;
232
233 void *kernel_shared_data = (void*)
234 gd->bd->bi_dram[CONFIG_NR_DRAM_BANKS-1].start +
235 gd->bd->bi_dram[CONFIG_NR_DRAM_BANKS-1].size - SZ_1M;
236
237 struct {
238 uint32_t chsw;
239 uint8_t hwid[256];
240 uint8_t fwid[256];
241 uint8_t frid[256];
242 uint32_t binf[5];
243 uint32_t gpio[11];
244 uint32_t vbnv[2];
245 uint64_t fmap_start_address;
246 } __attribute__((packed)) *sd = kernel_shared_data;
247
248 void *kernel_shared_data_body =
249 kernel_shared_data + sizeof(*sd);
250
251 debug(PREFIX "kernel shared data at %p\n", kernel_shared_data);
252
253 memset(sd, '\0', sizeof(*sd));
254
255 /*
256 * chsw bit value
257 * bit 0x00000002 : recovery button pressed
258 * bit 0x00000020 : developer mode enabled
259 * bit 0x00000200 : firmware write protect disabled
260 */
261 if (params->boot_flags & BOOT_FLAG_RECOVERY)
262 sd->chsw |= 0x002;
263 if (params->boot_flags & BOOT_FLAG_DEVELOPER)
264 sd->chsw |= 0x020;
265 sd->chsw |= 0x200; /* so far write protect is disabled */
266
267 strcpy((char*) sd->hwid, CONFIG_CHROMEOS_HWID);
268 strcpy((char*) sd->fwid, "ARM Firmware ID");
269 strcpy((char*) sd->frid, "ARM Read-Only Firmware ID");
270
271 sd->binf[0] = 0; /* boot reason; always 0 */
272 if (params->boot_flags & BOOT_FLAG_RECOVERY) {
273 sd->binf[1] = 0; /* active main firmware */
274 sd->binf[3] = 0; /* active firmware type */
275 } else {
276 sd->binf[1] = 1; /* active main firmware */
277 sd->binf[3] = 1; /* active firmware type */
278 }
279 sd->binf[2] = 0; /* active EC firmware */
280 VbNvGet(params->nv_context, VBNV_RECOVERY_REQUEST, sd->binf+4);
281
282 /* sd->gpio[i] == 1 if is active high */
283 sd->gpio[1] = 1; /* only developer mode gpio is active high */
284
285 sd->vbnv[0] = kernel_shared_data_body;
286 sd->vbnv[1] = VBNV_BLOCK_SIZE;
287 memcpy(kernel_shared_data_body, params->nv_context->raw,
288 VBNV_BLOCK_SIZE);
289 kernel_shared_data_body += VBNV_BLOCK_SIZE;
290
291 firmware_storage_t file;
292 firmware_storage_init(&file);
293 firmware_storage_read(&file,
294 CONFIG_OFFSET_FMAP, CONFIG_LENGTH_FMAP,
295 kernel_shared_data_body);
296 file.close(file.context);
297 sd->fmap_start_address = (uint64_t) kernel_shared_data_body;
298 kernel_shared_data_body += CONFIG_LENGTH_FMAP;
299 }
300
217 return status; 301 return status;
218 } 302 }
OLDNEW
« arch/arm/lib/bootm.c ('K') | « arch/arm/lib/bootm.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698