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

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

Issue 6628009: Add a wrapper function of LoadKernel() (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Code review Created 9 years, 9 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
« no previous file with comments | « lib/chromeos/Makefile ('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
(Empty)
1 /*
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
4 * found in the LICENSE file.
5 *
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
8 * Software Foundation.
9 */
10
11 #include <common.h>
12 #include <malloc.h>
13 #include <chromeos/boot_device_impl.h>
14 #include <chromeos/firmware_storage.h>
15 #include <chromeos/load_util.h>
16
17 /* vboot_reference interface */
18 #include <vboot_struct.h>
19
20 #define PREFIX "load_kernel_wrapper: "
21
22 void *load_gbb(firmware_storage_t *file, uint64_t *gbb_size_ptr)
23 {
24 void *gbb_data;
25 uint64_t gbb_size;
26
27 gbb_size = CONFIG_LENGTH_GBB;
28 gbb_data = malloc(CONFIG_LENGTH_GBB);
29 if (gbb_data) {
30 debug(PREFIX "cannot malloc gbb\n");
31 return NULL;
32 }
33
34 if (read_firmware_device(file, CONFIG_OFFSET_GBB, gbb_data, gbb_size)) {
35 debug(PREFIX "read gbb fail\n");
36 free(gbb_data);
37 return NULL;
38 }
39
40 *gbb_size_ptr = gbb_size;
41 return gbb_data;
42 }
43
44 int load_kernel_wrapper(LoadKernelParams *params,
45 void *gbb_data, uint64_t gbb_size, uint64_t boot_flags)
46 {
47 int status = LOAD_KERNEL_NOT_FOUND;
48 block_dev_desc_t *dev_desc;
49 VbNvContext vnc;
50
51 memset(params, '\0', sizeof(*params));
52
53 dev_desc = get_bootdev();
54 if (!dev_desc) {
55 debug(PREFIX "get_bootdev fail\n");
56 goto EXIT;
57 }
58
59 params->gbb_data = gbb_data;
60 params->gbb_size = gbb_size;
61
62 params->boot_flags = boot_flags;
63
64 if (boot_flags & BOOT_FLAG_RECOVERY) {
65 params->shared_data_blob = NULL;
66 params->shared_data_size = 0;
67 } else {
68 params->shared_data_blob =
69 (uint8_t *) CONFIG_VB_SHARED_DATA_BLOB;
70 params->shared_data_size = CONFIG_VB_SHARED_DATA_SIZE;
71 }
72
73 params->bytes_per_lba = (uint64_t) dev_desc->blksz;
74 params->ending_lba = (uint64_t) get_limit() - 1;
75
76 params->kernel_buffer = (uint8_t *) CONFIG_LOADADDR;
77 params->kernel_buffer_size = CONFIG_MAX_KERNEL_SIZE;
78
79 /* TODO: load vnc.raw from NV storage */
80 params->nv_context = &vnc;
81
82 debug(PREFIX "call LoadKernel() with parameters...\n");
83 debug(PREFIX "header_sign_key_blob: 0x%p\n",
84 params.header_sign_key_blob);
85 debug(PREFIX "bytes_per_lba: %d\n",
86 (int) params.bytes_per_lba);
87 debug(PREFIX "ending_lba: 0x%08x\n",
88 (int) params.ending_lba);
89 debug(PREFIX "kernel_buffer: 0x%p\n",
90 params.kernel_buffer);
91 debug(PREFIX "kernel_buffer_size: 0x%08x\n",
92 (int) params.kernel_buffer_size);
93 debug(PREFIX "boot_flags: 0x%08x\n",
94 (int) params.boot_flags);
95
96 status = LoadKernel(params);
97
98 if (vnc.raw_changed) {
99 /* TODO: save vnc.raw to NV storage */
100 }
101
102 EXIT:
103 debug(PREFIX "LoadKernel status: %d\n", status);
104 if (status == LOAD_KERNEL_SUCCESS) {
105 debug(PREFIX "partition_number: 0x%08x\n",
106 (int) params->partition_number);
107 debug(PREFIX "bootloader_address: 0x%08x\n",
108 (int) params->bootloader_address);
109 debug(PREFIX "bootloader_size: 0x%08x\n",
110 (int) params->bootloader_size);
111 }
112
113 return status;
114 }
OLDNEW
« no previous file with comments | « lib/chromeos/Makefile ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698