diff options
author | Randall Spangler <rspangler@chromium.org> | 2010-06-17 14:45:22 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2010-06-17 14:45:22 -0700 |
commit | 620c38cf34eadcd222535b01fb71c5e9fbc1cb80 (patch) | |
tree | 55c883fd01447b0ffdf6c121f4b7c6817cbc53b0 /firmware/lib/stateful_util.c | |
parent | d52030f340d14f8039360a39ec6a938d31e083d0 (diff) | |
download | vboot-620c38cf34eadcd222535b01fb71c5e9fbc1cb80.tar.gz |
Remove unused files, and tidy the directory structure of the remaining ones.
Review URL: http://codereview.chromium.org/2815011
Diffstat (limited to 'firmware/lib/stateful_util.c')
-rw-r--r-- | firmware/lib/stateful_util.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/firmware/lib/stateful_util.c b/firmware/lib/stateful_util.c new file mode 100644 index 00000000..137ea77a --- /dev/null +++ b/firmware/lib/stateful_util.c @@ -0,0 +1,65 @@ +/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Stub implementations of utility functions which call their linux-specific + * equivalents. + */ + +#include "stateful_util.h" + +#include "utility.h" + +void* StatefulSkip(MemcpyState* state, uint64_t len) { + if (state->overrun) + return NULL; + if (len > state->remaining_len) { + state->overrun = 1; + return NULL; + } + state->remaining_buf += len; + state->remaining_len -= len; + return state; // have to return something non-NULL +} + +void* StatefulMemcpy(MemcpyState* state, void* dst, + uint64_t len) { + if (state->overrun) + return NULL; + if (len > state->remaining_len) { + state->overrun = 1; + return NULL; + } + Memcpy(dst, state->remaining_buf, len); + state->remaining_buf += len; + state->remaining_len -= len; + return dst; +} + +const void* StatefulMemcpy_r(MemcpyState* state, const void* src, + uint64_t len) { + if (state->overrun) + return NULL; + if (len > state->remaining_len) { + state->overrun = 1; + return NULL; + } + Memcpy(state->remaining_buf, src, len); + state->remaining_buf += len; + state->remaining_len -= len; + return src; +} + +const void* StatefulMemset_r(MemcpyState* state, const uint8_t val, + uint64_t len) { + if (state->overrun) + return NULL; + if (len > state->remaining_len) { + state->overrun = 1; + return NULL; + } + Memset(state->remaining_buf, val, len); + state->remaining_buf += len; + state->remaining_len -= len; + return state; // have to return something non-NULL +} |