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

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

Issue 6650024: Factor out read_firmware_device() (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: 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 | « include/chromeos/firmware_storage.h ('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
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 void GetFirmwareBody_dispose(firmware_storage_t *f) 32 void GetFirmwareBody_dispose(firmware_storage_t *f)
33 { 33 {
34 int i; 34 int i;
35 for (i = 0; i < 2; i ++) 35 for (i = 0; i < 2; i ++)
36 if (f->firmware_body[i]) 36 if (f->firmware_body[i])
37 free(f->firmware_body[i]); 37 free(f->firmware_body[i]);
38 } 38 }
39 39
40 int read_firmware_device(firmware_storage_t *file, off_t offset, void *buf,
41 size_t count)
42 {
43 ssize_t size;
44
45 if (file->seek(file->context, offset, SEEK_SET) < 0) {
46 debug(PREFIX "seek to address 0x%08x fail\n", offset);
47 return -1;
48 }
49
50 size = 0;
51 while (count > 0 &&
52 (size = file->read(file->context, buf, count)) > 0) {
53 count -= size;
54 buf += size;
55 }
56
57 if (size < 0) {
58 debug(PREFIX "an error occur when read firmware: %d\n", size);
59 return -1;
60 }
61
62 if (count > 0) {
63 debug(PREFIX "cannot read all data: %d\n", count);
64 return -1;
65 }
66
67 return 0;
68 }
69
40 /* 70 /*
41 * See vboot_reference/firmware/include/load_firmware_fw.h for documentation of 71 * See vboot_reference/firmware/include/load_firmware_fw.h for documentation of
42 * this function. 72 * this function.
43 */ 73 */
44 int GetFirmwareBody(LoadFirmwareParams *params, uint64_t index) 74 int GetFirmwareBody(LoadFirmwareParams *params, uint64_t index)
45 { 75 {
46 firmware_storage_t *f; 76 firmware_storage_t *f;
47 void *block; 77 void *block;
48 VbKeyBlockHeader *kbh; 78 VbKeyBlockHeader *kbh;
49 VbFirmwarePreambleHeader *fph; 79 VbFirmwarePreambleHeader *fph;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 /* 133 /*
104 * See vboot_reference/firmware/include/load_firmware_fw.h for 134 * See vboot_reference/firmware/include/load_firmware_fw.h for
105 * documentation of this function. 135 * documentation of this function.
106 */ 136 */
107 UpdateFirmwareBodyHash(params, firmware_body, n); 137 UpdateFirmwareBodyHash(params, firmware_body, n);
108 firmware_body += n; 138 firmware_body += n;
109 } 139 }
110 140
111 return 0; 141 return 0;
112 } 142 }
OLDNEW
« no previous file with comments | « include/chromeos/firmware_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698