2013-12-03 20:13:35 +01:00
|
|
|
/*
|
|
|
|
* cbfstool, CLI utility for CBFS file manipulation
|
|
|
|
*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* Foundation, Inc.
|
2013-12-03 20:13:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
2014-03-10 20:13:27 +01:00
|
|
|
size_t bgets(struct buffer *input, void *output, size_t len)
|
2014-02-05 02:35:44 +01:00
|
|
|
{
|
|
|
|
len = input->size < len ? input->size : len;
|
|
|
|
memmove(output, input->data, len);
|
|
|
|
input->data += len;
|
|
|
|
input->size -= len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2014-03-10 20:13:27 +01:00
|
|
|
size_t bputs(struct buffer *b, const void *data, size_t len)
|
|
|
|
{
|
|
|
|
memmove(&b->data[b->size], data, len);
|
|
|
|
b->size += len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2013-12-03 20:13:35 +01:00
|
|
|
/* The assumption in all this code is that we're given a pointer to enough data.
|
|
|
|
* Hence, we do not check for underflow.
|
|
|
|
*/
|
|
|
|
static uint8_t get8(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint8_t ret = *input->data++;
|
|
|
|
input->size--;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t get16be(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint16_t ret;
|
|
|
|
ret = get8(input) << 8;
|
|
|
|
ret |= get8(input);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t get32be(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
ret = get16be(input) << 16;
|
|
|
|
ret |= get16be(input);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t get64be(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint64_t ret;
|
|
|
|
ret = get32be(input);
|
|
|
|
ret <<= 32;
|
|
|
|
ret |= get32be(input);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put8(struct buffer *input, uint8_t val)
|
|
|
|
{
|
|
|
|
input->data[input->size] = val;
|
|
|
|
input->size++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put16be(struct buffer *input, uint16_t val)
|
|
|
|
{
|
|
|
|
put8(input, val >> 8);
|
|
|
|
put8(input, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put32be(struct buffer *input, uint32_t val)
|
|
|
|
{
|
|
|
|
put16be(input, val >> 16);
|
|
|
|
put16be(input, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put64be(struct buffer *input, uint64_t val)
|
|
|
|
{
|
|
|
|
put32be(input, val >> 32);
|
|
|
|
put32be(input, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t get16le(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint16_t ret;
|
|
|
|
ret = get8(input);
|
|
|
|
ret |= get8(input) << 8;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t get32le(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
ret = get16le(input);
|
|
|
|
ret |= get16le(input) << 16;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t get64le(struct buffer *input)
|
|
|
|
{
|
|
|
|
uint64_t ret;
|
|
|
|
uint32_t low;
|
|
|
|
low = get32le(input);
|
|
|
|
ret = get32le(input);
|
|
|
|
ret <<= 32;
|
|
|
|
ret |= low;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put16le(struct buffer *input, uint16_t val)
|
|
|
|
{
|
|
|
|
put8(input, val);
|
|
|
|
put8(input, val >> 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put32le(struct buffer *input, uint32_t val)
|
|
|
|
{
|
|
|
|
put16le(input, val);
|
|
|
|
put16le(input, val >> 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void put64le(struct buffer *input, uint64_t val)
|
|
|
|
{
|
|
|
|
put32le(input, val);
|
|
|
|
put32le(input, val >> 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xdr xdr_be = {
|
2014-03-05 23:38:26 +01:00
|
|
|
get8, get16be, get32be, get64be,
|
|
|
|
put8, put16be, put32be, put64be
|
2013-12-03 20:13:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct xdr xdr_le = {
|
2014-03-05 23:38:26 +01:00
|
|
|
get8, get16le, get32le, get64le,
|
|
|
|
put8, put16le, put32le, put64le
|
2013-12-03 20:13:35 +01:00
|
|
|
};
|