OLD | NEW |
---|---|
(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 int load_kernel_wrapper(LoadKernelParams *params, uint64_t boot_flags) | |
23 { | |
24 int status = LOAD_KERNEL_NOT_FOUND; | |
25 firmware_storage_t file; | |
26 block_dev_desc_t *dev_desc; | |
27 VbNvContext vnc; | |
28 | |
29 memset(params, '\0', sizeof(*params)); | |
30 | |
31 if (init_firmware_storage(&file)) { | |
32 debug(PREFIX "init_firmware_storage fail\n"); | |
33 return LOAD_KERNEL_NOT_FOUND; | |
34 } | |
35 | |
36 dev_desc = get_bootdev(); | |
37 if (!dev_desc) { | |
38 debug(PREFIX "get_bootdev fail\n"); | |
39 goto EXIT; | |
40 } | |
41 | |
42 if (boot_flags | BOOT_FLAG_RECOVERY) { | |
Tom Wai-Hong Tam
2011/03/14 09:37:27
The condition should be "boot_flags & BOOT_FLAG_RE
Che-Liang Chiou
2011/03/14 10:39:35
You are right. My typo.
| |
43 params->shared_data_blob = NULL; | |
44 params->shared_data_size = 0; | |
45 } else { | |
46 params->shared_data_blob = | |
47 (uint8_t *) CONFIG_VB_SHARED_DATA_BLOB; | |
48 params->shared_data_size = CONFIG_VB_SHARED_DATA_SIZE; | |
49 } | |
50 | |
51 params->bytes_per_lba = (uint64_t) dev_desc->blksz; | |
52 params->ending_lba = (uint64_t) get_limit() - 1; | |
53 | |
54 params->kernel_buffer = (uint8_t *) CONFIG_LOADADDR; | |
55 params->kernel_buffer_size = CONFIG_MAX_KERNEL_SIZE; | |
56 | |
57 params->boot_flags = boot_flags; | |
58 | |
59 /* read gbb */ | |
60 params->gbb_size = CONFIG_LENGTH_GBB; | |
61 params->gbb_data = malloc(CONFIG_LENGTH_GBB); | |
62 if (!params->gbb_data) { | |
63 debug(PREFIX "cannot malloc gbb\n"); | |
64 goto EXIT; | |
65 } | |
66 if (read_firmware_device(&file, CONFIG_OFFSET_GBB, | |
67 params->gbb_data, | |
68 params->gbb_size)) { | |
69 debug(PREFIX "read gbb fail\n"); | |
70 goto EXIT; | |
71 } | |
72 | |
73 /* TODO: load vnc.raw from NV storage */ | |
74 params->nv_context = &vnc; | |
75 | |
76 debug(PREFIX "call LoadKernel() with parameters...\n"); | |
77 debug(PREFIX "header_sign_key_blob: 0x%p\n", | |
78 params.header_sign_key_blob); | |
79 debug(PREFIX "bytes_per_lba: %d\n", | |
80 (int) params.bytes_per_lba); | |
81 debug(PREFIX "ending_lba: 0x%08x\n", | |
82 (int) params.ending_lba); | |
83 debug(PREFIX "kernel_buffer: 0x%p\n", | |
84 params.kernel_buffer); | |
85 debug(PREFIX "kernel_buffer_size: 0x%08x\n", | |
86 (int) params.kernel_buffer_size); | |
87 debug(PREFIX "boot_flags: 0x%08x\n", | |
88 (int) params.boot_flags); | |
89 | |
90 status = LoadKernel(params); | |
91 | |
92 if (vnc.raw_changed) { | |
93 /* TODO: save vnc.raw to NV storage */ | |
94 } | |
95 | |
96 EXIT: | |
97 release_firmware_storage(&file); | |
98 | |
99 debug(PREFIX "LoadKernel status: %d\n", status); | |
100 if (status == LOAD_KERNEL_SUCCESS) { | |
101 debug(PREFIX "partition_number: 0x%08x\n", | |
102 (int) params->partition_number); | |
103 debug(PREFIX "bootloader_address: 0x%08x\n", | |
104 (int) params->bootloader_address); | |
105 debug(PREFIX "bootloader_size: 0x%08x\n", | |
106 (int) params->bootloader_size); | |
107 } else { | |
108 if (params->gbb_data) { | |
109 free(params->gbb_data); | |
110 params->gbb_data = NULL; | |
111 params->gbb_size = 0; | |
112 } | |
113 } | |
114 | |
115 return status; | |
116 } | |
OLD | NEW |