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

Side by Side Diff: src/platform/vboot_reference/include/utility.h

Issue 1599001: VBoot Reference: Refactor Pass 1: Split {firmware|kernel}_image (Closed)
Patch Set: Created 10 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
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Helper functions/wrappers for memory allocations, manipulation and 6 /* Helper functions/wrappers for memory allocations, manipulation and
7 * comparison. 7 * comparison.
8 */ 8 */
9 9
10 #ifndef VBOOT_REFERENCE_UTILITY_H_ 10 #ifndef VBOOT_REFERENCE_UTILITY_H_
11 #define VBOOT_REFERENCE_UTILITY_H_ 11 #define VBOOT_REFERENCE_UTILITY_H_
12 12
13 #include <inttypes.h> 13 #include <stdint.h>
14 #include <string.h> 14 #include <string.h>
15 15
16 /* Outputs an error message and quits. */
17 void error(const char *format, ...);
18
19 /* Outputs debug/warning messages. */
20 void debug(const char *format, ...);
21
22
23 #define assert(expr) do { if (!(expr)) { \
24 error("assert fail: %s at %s:%d\n", \
25 #expr, __FILE__, __LINE__); }} while(0)
26
16 /* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and 27 /* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and
17 * [lsw] forming the most and least signficant 16-bit words. 28 * [lsw] forming the most and least signficant 16-bit words.
18 */ 29 */
19 #define CombineUint16Pair(msw,lsw) (((msw) << 16) | \ 30 #define CombineUint16Pair(msw,lsw) (((msw) << 16) | \
20 (((lsw)) & 0xFFFF)) 31 (((lsw)) & 0xFFFF))
21 /* Return the minimum of (a) or (b). */ 32 /* Return the minimum of (a) or (b). */
22 #define Min(a, b) (((a) < (b)) ? (a) : (b)) 33 #define Min(a, b) (((a) < (b)) ? (a) : (b))
23 34
24 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort 35 /* Allocate [size] bytes and return a pointer to the allocated memory. Abort
25 * on error. 36 * on error.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 * data from [src] into the buffer encapsulated in state [state]. 73 * data from [src] into the buffer encapsulated in state [state].
63 * On success, return [src] and update [state]. 74 * On success, return [src] and update [state].
64 * On failure, return NULL, set remaining_len in state to -1. 75 * On failure, return NULL, set remaining_len in state to -1.
65 * 76 *
66 * Useful for iterating through a structure to populate a binary blob. After the 77 * Useful for iterating through a structure to populate a binary blob. After the
67 * first failure (buffer overrun), successive calls will always fail. 78 * first failure (buffer overrun), successive calls will always fail.
68 */ 79 */
69 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, uint64_t len); 80 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, uint64_t len);
70 81
71 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ 82 #endif /* VBOOT_REFERENCE_UTILITY_H_ */
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/include/tlcl.h ('k') | src/platform/vboot_reference/tests/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698