src/lib: Use tabs instead of spaces

Fix the following errors and warnings detected by checkpatch.pl:

ERROR: code indent should use tabs where possible
ERROR: switch and case should be at the same indent
WARNING: Statements should start on a tabstop
WARNING: please, no spaces at the start of a line
WARNING: please, no space before tabs
WARNING: suspect code indent for conditional statements
WARNING: labels should not be indented

TEST=Build and run on Galileo Gen2

Change-Id: Iebcff26ad41ab6eb0027b871a1c06f3b52dd207c
Signed-off-by: Lee Leahy <Leroy.P.Leahy@intel.com>
Reviewed-on: https://review.coreboot.org/18732
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Lee Leahy
2017-03-09 16:21:34 -08:00
committed by Martin Roth
parent cdd7686a9d
commit e20a3191f5
20 changed files with 1462 additions and 1527 deletions

View File

@ -875,11 +875,9 @@ parse_cea(struct edid *out, unsigned char *x, struct edid_context *c)
if (offset < 4) if (offset < 4)
break; break;
if (version < 3) { if (version < 3)
printk(BIOS_SPEW, "%d 8-byte timing descriptors\n", (offset - 4) / 8); printk(BIOS_SPEW, "%d 8-byte timing descriptors\n", (offset - 4) / 8);
if (offset - 4 > 0) else if (version == 3) {
/* do stuff */ ;
} else if (version == 3) {
int i; int i;
printk(BIOS_SPEW, "%d bytes of CEA data\n", offset - 4); printk(BIOS_SPEW, "%d bytes of CEA data\n", offset - 4);
for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) for (i = 4; i < offset; i += (x[i] & 0x1f) + 1)
@ -1188,7 +1186,7 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
break; break;
} }
extra_info.type = edid[0x14] & 0x0f; extra_info.type = edid[0x14] & 0x0f;
} else if (c.claims_one_point_two) { } else if (c.claims_one_point_two) {
conformance_mask = 0x7E; conformance_mask = 0x7E;
if (edid[0x14] & 0x01) if (edid[0x14] & 0x01)
printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n"); printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n");
@ -1273,18 +1271,18 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
/* FIXME: this is from 1.4 spec, check earlier */ /* FIXME: this is from 1.4 spec, check earlier */
if (analog) { if (analog) {
switch (edid[0x18] & 0x18) { switch (edid[0x18] & 0x18) {
case 0x00: case 0x00:
printk(BIOS_SPEW, "Monochrome or grayscale display\n"); printk(BIOS_SPEW, "Monochrome or grayscale display\n");
break; break;
case 0x08: case 0x08:
printk(BIOS_SPEW, "RGB color display\n"); printk(BIOS_SPEW, "RGB color display\n");
break; break;
case 0x10: case 0x10:
printk(BIOS_SPEW, "Non-RGB color display\n"); printk(BIOS_SPEW, "Non-RGB color display\n");
break; break;
case 0x18: case 0x18:
printk(BIOS_SPEW, "Undefined display color type\n"); printk(BIOS_SPEW, "Undefined display color type\n");
break; break;
} }
} else { } else {
printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4"); printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4");

View File

@ -36,13 +36,12 @@ static void gcov_allocate(unsigned int);
static inline gcov_unsigned_t from_file(gcov_unsigned_t value) static inline gcov_unsigned_t from_file(gcov_unsigned_t value)
{ {
#if !IN_LIBGCOV #if !IN_LIBGCOV
if (gcov_var.endian) if (gcov_var.endian) {
{ value = (value >> 16) | (value << 16);
value = (value >> 16) | (value << 16); value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff); }
}
#endif #endif
return value; return value;
} }
/* Open a gcov file. NAME is the name of the file to open and MODE /* Open a gcov file. NAME is the name of the file to open and MODE
@ -63,91 +62,83 @@ gcov_open(const char *name, int mode)
#endif #endif
{ {
#if IN_LIBGCOV #if IN_LIBGCOV
const int mode = 0; const int mode = 0;
#endif #endif
#if GCOV_LOCKED #if GCOV_LOCKED
struct flock s_flock; struct flock s_flock;
int fd; int fd;
s_flock.l_whence = SEEK_SET; s_flock.l_whence = SEEK_SET;
s_flock.l_start = 0; s_flock.l_start = 0;
s_flock.l_len = 0; /* Until EOF. */ s_flock.l_len = 0; /* Until EOF. */
s_flock.l_pid = getpid(); s_flock.l_pid = getpid();
#endif #endif
gcc_assert(!gcov_var.file); gcc_assert(!gcov_var.file);
gcov_var.start = 0; gcov_var.start = 0;
gcov_var.offset = gcov_var.length = 0; gcov_var.offset = gcov_var.length = 0;
gcov_var.overread = -1u; gcov_var.overread = -1u;
gcov_var.error = 0; gcov_var.error = 0;
#if !IN_LIBGCOV #if !IN_LIBGCOV
gcov_var.endian = 0; gcov_var.endian = 0;
#endif #endif
#if GCOV_LOCKED #if GCOV_LOCKED
if (mode > 0) if (mode > 0) {
{ /* Read-only mode - acquire a read-lock. */
/* Read-only mode - acquire a read-lock. */ s_flock.l_type = F_RDLCK;
s_flock.l_type = F_RDLCK; fd = open(name, O_RDONLY);
fd = open(name, O_RDONLY); } else {
} /* Write mode - acquire a write-lock. */
else s_flock.l_type = F_WRLCK;
{ fd = open(name, O_RDWR | O_CREAT, 0666);
/* Write mode - acquire a write-lock. */
s_flock.l_type = F_WRLCK;
fd = open(name, O_RDWR | O_CREAT, 0666);
}
if (fd < 0)
return 0;
while (fcntl(fd, F_SETLKW, &s_flock) && errno == EINTR)
continue;
gcov_var.file = fdopen(fd, (mode > 0) ? "rb" : "r+b");
if (!gcov_var.file)
{
close(fd);
return 0;
}
if (mode > 0)
gcov_var.mode = 1;
else if (mode == 0)
{
struct stat st;
if (fstat(fd, &st) < 0)
{
fclose(gcov_var.file);
gcov_var.file = 0;
return 0;
} }
if (st.st_size != 0) if (fd < 0)
gcov_var.mode = 1; return 0;
else
gcov_var.mode = mode * 2 + 1;
}
else
gcov_var.mode = mode * 2 + 1;
#else
if (mode >= 0)
gcov_var.file = fopen(name, (mode > 0) ? "rb" : "r+b");
if (gcov_var.file) while (fcntl(fd, F_SETLKW, &s_flock) && errno == EINTR)
gcov_var.mode = 1; continue;
else if (mode <= 0)
{ gcov_var.file = fdopen(fd, (mode > 0) ? "rb" : "r+b");
gcov_var.file = fopen(name, "w+b");
if (gcov_var.file) if (!gcov_var.file) {
gcov_var.mode = mode * 2 + 1; close(fd);
} return 0;
if (!gcov_var.file) }
return 0;
if (mode > 0)
gcov_var.mode = 1;
else if (mode == 0) {
struct stat st;
if (fstat(fd, &st) < 0) {
fclose(gcov_var.file);
gcov_var.file = 0;
return 0;
}
if (st.st_size != 0)
gcov_var.mode = 1;
else
gcov_var.mode = mode * 2 + 1;
} else
gcov_var.mode = mode * 2 + 1;
#else
if (mode >= 0)
gcov_var.file = fopen(name, (mode > 0) ? "rb" : "r+b");
if (gcov_var.file)
gcov_var.mode = 1;
else if (mode <= 0) {
gcov_var.file = fopen(name, "w+b");
if (gcov_var.file)
gcov_var.mode = mode * 2 + 1;
}
if (!gcov_var.file)
return 0;
#endif #endif
setbuf(gcov_var.file, (char *)0); setbuf(gcov_var.file, (char *)0);
return 1; return 1;
} }
/* Close the current gcov file. Flushes data to disk. Returns nonzero /* Close the current gcov file. Flushes data to disk. Returns nonzero
@ -156,23 +147,22 @@ gcov_open(const char *name, int mode)
GCOV_LINKAGE int GCOV_LINKAGE int
gcov_close(void) gcov_close(void)
{ {
if (gcov_var.file) if (gcov_var.file) {
{
#if !IN_GCOV #if !IN_GCOV
if (gcov_var.offset && gcov_var.mode < 0) if (gcov_var.offset && gcov_var.mode < 0)
gcov_write_block(gcov_var.offset); gcov_write_block(gcov_var.offset);
#endif #endif
fclose(gcov_var.file); fclose(gcov_var.file);
gcov_var.file = 0; gcov_var.file = 0;
gcov_var.length = 0; gcov_var.length = 0;
} }
#if !IN_LIBGCOV #if !IN_LIBGCOV
free(gcov_var.buffer); free(gcov_var.buffer);
gcov_var.alloc = 0; gcov_var.alloc = 0;
gcov_var.buffer = 0; gcov_var.buffer = 0;
#endif #endif
gcov_var.mode = 0; gcov_var.mode = 0;
return gcov_var.error; return gcov_var.error;
} }
#if !IN_LIBGCOV #if !IN_LIBGCOV
@ -183,16 +173,15 @@ gcov_close(void)
GCOV_LINKAGE int GCOV_LINKAGE int
gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected) gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected)
{ {
if (magic == expected) if (magic == expected)
return 1; return 1;
magic = (magic >> 16) | (magic << 16); magic = (magic >> 16) | (magic << 16);
magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff); magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
if (magic == expected) if (magic == expected) {
{ gcov_var.endian = 1;
gcov_var.endian = 1; return -1;
return -1; }
} return 0;
return 0;
} }
#endif #endif
@ -200,15 +189,16 @@ gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected)
static void static void
gcov_allocate(unsigned int length) gcov_allocate(unsigned int length)
{ {
size_t new_size = gcov_var.alloc; size_t new_size = gcov_var.alloc;
if (!new_size) if (!new_size)
new_size = GCOV_BLOCK_SIZE; new_size = GCOV_BLOCK_SIZE;
new_size += length; new_size += length;
new_size *= 2; new_size *= 2;
gcov_var.alloc = new_size; gcov_var.alloc = new_size;
gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer, new_size << 2); gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer,
new_size << 2);
} }
#endif #endif
@ -218,10 +208,10 @@ gcov_allocate(unsigned int length)
static void static void
gcov_write_block(unsigned int size) gcov_write_block(unsigned int size)
{ {
if (fwrite(gcov_var.buffer, size << 2, 1, gcov_var.file) != 1) if (fwrite(gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
gcov_var.error = 1; gcov_var.error = 1;
gcov_var.start += size; gcov_var.start += size;
gcov_var.offset -= size; gcov_var.offset -= size;
} }
/* Allocate space to write BYTES bytes to the gcov file. Return a /* Allocate space to write BYTES bytes to the gcov file. Return a
@ -230,27 +220,26 @@ gcov_write_block(unsigned int size)
static gcov_unsigned_t * static gcov_unsigned_t *
gcov_write_words(unsigned int words) gcov_write_words(unsigned int words)
{ {
gcov_unsigned_t *result; gcov_unsigned_t *result;
gcc_assert(gcov_var.mode < 0); gcc_assert(gcov_var.mode < 0);
#if IN_LIBGCOV #if IN_LIBGCOV
if (gcov_var.offset >= GCOV_BLOCK_SIZE) if (gcov_var.offset >= GCOV_BLOCK_SIZE) {
{ gcov_write_block(GCOV_BLOCK_SIZE);
gcov_write_block(GCOV_BLOCK_SIZE); if (gcov_var.offset) {
if (gcov_var.offset) gcc_assert(gcov_var.offset == 1);
{ memcpy(gcov_var.buffer, gcov_var.buffer
gcc_assert(gcov_var.offset == 1); + GCOV_BLOCK_SIZE, 4);
memcpy(gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4); }
} }
}
#else #else
if (gcov_var.offset + words > gcov_var.alloc) if (gcov_var.offset + words > gcov_var.alloc)
gcov_allocate(gcov_var.offset + words); gcov_allocate(gcov_var.offset + words);
#endif #endif
result = &gcov_var.buffer[gcov_var.offset]; result = &gcov_var.buffer[gcov_var.offset];
gcov_var.offset += words; gcov_var.offset += words;
return result; return result;
} }
/* Write unsigned VALUE to coverage file. Sets error flag /* Write unsigned VALUE to coverage file. Sets error flag
@ -259,9 +248,9 @@ gcov_write_words(unsigned int words)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_unsigned(gcov_unsigned_t value) gcov_write_unsigned(gcov_unsigned_t value)
{ {
gcov_unsigned_t *buffer = gcov_write_words(1); gcov_unsigned_t *buffer = gcov_write_words(1);
buffer[0] = value; buffer[0] = value;
} }
/* Write counter VALUE to coverage file. Sets error flag /* Write counter VALUE to coverage file. Sets error flag
@ -271,13 +260,13 @@ gcov_write_unsigned(gcov_unsigned_t value)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_counter(gcov_type value) gcov_write_counter(gcov_type value)
{ {
gcov_unsigned_t *buffer = gcov_write_words(2); gcov_unsigned_t *buffer = gcov_write_words(2);
buffer[0] = (gcov_unsigned_t) value; buffer[0] = (gcov_unsigned_t) value;
if (sizeof(value) > sizeof(gcov_unsigned_t)) if (sizeof(value) > sizeof(gcov_unsigned_t))
buffer[1] = (gcov_unsigned_t) (value >> 32); buffer[1] = (gcov_unsigned_t) (value >> 32);
else else
buffer[1] = 0; buffer[1] = 0;
} }
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
@ -288,21 +277,20 @@ gcov_write_counter(gcov_type value)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_string(const char *string) gcov_write_string(const char *string)
{ {
unsigned int length = 0; unsigned int length = 0;
unsigned int alloc = 0; unsigned int alloc = 0;
gcov_unsigned_t *buffer; gcov_unsigned_t *buffer;
if (string) if (string) {
{ length = strlen(string);
length = strlen(string); alloc = (length + 4) >> 2;
alloc = (length + 4) >> 2; }
}
buffer = gcov_write_words(1 + alloc); buffer = gcov_write_words(1 + alloc);
buffer[0] = alloc; buffer[0] = alloc;
buffer[alloc] = 0; buffer[alloc] = 0;
memcpy(&buffer[1], string, length); memcpy(&buffer[1], string, length);
} }
#endif #endif
@ -313,13 +301,13 @@ gcov_write_string(const char *string)
GCOV_LINKAGE gcov_position_t GCOV_LINKAGE gcov_position_t
gcov_write_tag(gcov_unsigned_t tag) gcov_write_tag(gcov_unsigned_t tag)
{ {
gcov_position_t result = gcov_var.start + gcov_var.offset; gcov_position_t result = gcov_var.start + gcov_var.offset;
gcov_unsigned_t *buffer = gcov_write_words(2); gcov_unsigned_t *buffer = gcov_write_words(2);
buffer[0] = tag; buffer[0] = tag;
buffer[1] = 0; buffer[1] = 0;
return result; return result;
} }
/* Write a record length using POSITION, which was returned by /* Write a record length using POSITION, which was returned by
@ -330,19 +318,19 @@ gcov_write_tag(gcov_unsigned_t tag)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_length(gcov_position_t position) gcov_write_length(gcov_position_t position)
{ {
unsigned int offset; unsigned int offset;
gcov_unsigned_t length; gcov_unsigned_t length;
gcov_unsigned_t *buffer; gcov_unsigned_t *buffer;
gcc_assert(gcov_var.mode < 0); gcc_assert(gcov_var.mode < 0);
gcc_assert(position + 2 <= gcov_var.start + gcov_var.offset); gcc_assert(position + 2 <= gcov_var.start + gcov_var.offset);
gcc_assert(position >= gcov_var.start); gcc_assert(position >= gcov_var.start);
offset = position - gcov_var.start; offset = position - gcov_var.start;
length = gcov_var.offset - offset - 2; length = gcov_var.offset - offset - 2;
buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset]; buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
buffer[1] = length; buffer[1] = length;
if (gcov_var.offset >= GCOV_BLOCK_SIZE) if (gcov_var.offset >= GCOV_BLOCK_SIZE)
gcov_write_block(gcov_var.offset); gcov_write_block(gcov_var.offset);
} }
#else /* IN_LIBGCOV */ #else /* IN_LIBGCOV */
@ -352,10 +340,10 @@ gcov_write_length(gcov_position_t position)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_tag_length(gcov_unsigned_t tag, gcov_unsigned_t length) gcov_write_tag_length(gcov_unsigned_t tag, gcov_unsigned_t length)
{ {
gcov_unsigned_t *buffer = gcov_write_words(2); gcov_unsigned_t *buffer = gcov_write_words(2);
buffer[0] = tag; buffer[0] = tag;
buffer[1] = length; buffer[1] = length;
} }
/* Write a summary structure to the gcov file. Return nonzero on /* Write a summary structure to the gcov file. Return nonzero on
@ -364,19 +352,18 @@ gcov_write_tag_length(gcov_unsigned_t tag, gcov_unsigned_t length)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary) gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary)
{ {
unsigned int ix; unsigned int ix;
const struct gcov_ctr_summary *csum; const struct gcov_ctr_summary *csum;
gcov_write_tag_length(tag, GCOV_TAG_SUMMARY_LENGTH); gcov_write_tag_length(tag, GCOV_TAG_SUMMARY_LENGTH);
gcov_write_unsigned(summary->checksum); gcov_write_unsigned(summary->checksum);
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) {
{ gcov_write_unsigned(csum->num);
gcov_write_unsigned(csum->num); gcov_write_unsigned(csum->runs);
gcov_write_unsigned(csum->runs); gcov_write_counter(csum->sum_all);
gcov_write_counter(csum->sum_all); gcov_write_counter(csum->run_max);
gcov_write_counter(csum->run_max); gcov_write_counter(csum->sum_max);
gcov_write_counter(csum->sum_max); }
}
} }
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
@ -388,45 +375,44 @@ gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary)
static const gcov_unsigned_t * static const gcov_unsigned_t *
gcov_read_words(unsigned int words) gcov_read_words(unsigned int words)
{ {
const gcov_unsigned_t *result; const gcov_unsigned_t *result;
unsigned int excess = gcov_var.length - gcov_var.offset; unsigned int excess = gcov_var.length - gcov_var.offset;
gcc_assert(gcov_var.mode > 0); gcc_assert(gcov_var.mode > 0);
if (excess < words) if (excess < words) {
{ gcov_var.start += gcov_var.offset;
gcov_var.start += gcov_var.offset;
#if IN_LIBGCOV #if IN_LIBGCOV
if (excess) if (excess) {
{ gcc_assert(excess == 1);
gcc_assert(excess == 1); memcpy(gcov_var.buffer, gcov_var.buffer
memcpy(gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4); + gcov_var.offset, 4);
} }
#else #else
memmove(gcov_var.buffer, gcov_var.buffer + gcov_var.offset, excess * 4); memmove(gcov_var.buffer, gcov_var.buffer
+ gcov_var.offset, excess * 4);
#endif #endif
gcov_var.offset = 0; gcov_var.offset = 0;
gcov_var.length = excess; gcov_var.length = excess;
#if IN_LIBGCOV #if IN_LIBGCOV
gcc_assert(!gcov_var.length || gcov_var.length == 1); gcc_assert(!gcov_var.length || gcov_var.length == 1);
excess = GCOV_BLOCK_SIZE; excess = GCOV_BLOCK_SIZE;
#else #else
if (gcov_var.length + words > gcov_var.alloc) if (gcov_var.length + words > gcov_var.alloc)
gcov_allocate(gcov_var.length + words); gcov_allocate(gcov_var.length + words);
excess = gcov_var.alloc - gcov_var.length; excess = gcov_var.alloc - gcov_var.length;
#endif #endif
excess = fread(gcov_var.buffer + gcov_var.length, excess = fread(gcov_var.buffer + gcov_var.length,
1, excess << 2, gcov_var.file) >> 2; 1, excess << 2, gcov_var.file) >> 2;
gcov_var.length += excess; gcov_var.length += excess;
if (gcov_var.length < words) if (gcov_var.length < words) {
{ gcov_var.overread += words - gcov_var.length;
gcov_var.overread += words - gcov_var.length; gcov_var.length = 0;
gcov_var.length = 0; return 0;
return 0; }
} }
} result = &gcov_var.buffer[gcov_var.offset];
result = &gcov_var.buffer[gcov_var.offset]; gcov_var.offset += words;
gcov_var.offset += words; return result;
return result;
} }
/* Read unsigned value from a coverage file. Sets error flag on file /* Read unsigned value from a coverage file. Sets error flag on file
@ -435,13 +421,13 @@ gcov_read_words(unsigned int words)
GCOV_LINKAGE gcov_unsigned_t GCOV_LINKAGE gcov_unsigned_t
gcov_read_unsigned(void) gcov_read_unsigned(void)
{ {
gcov_unsigned_t value; gcov_unsigned_t value;
const gcov_unsigned_t *buffer = gcov_read_words(1); const gcov_unsigned_t *buffer = gcov_read_words(1);
if (!buffer) if (!buffer)
return 0; return 0;
value = from_file(buffer[0]); value = from_file(buffer[0]);
return value; return value;
} }
/* Read counter value from a coverage file. Sets error flag on file /* Read counter value from a coverage file. Sets error flag on file
@ -450,18 +436,18 @@ gcov_read_unsigned(void)
GCOV_LINKAGE gcov_type GCOV_LINKAGE gcov_type
gcov_read_counter(void) gcov_read_counter(void)
{ {
gcov_type value; gcov_type value;
const gcov_unsigned_t *buffer = gcov_read_words(2); const gcov_unsigned_t *buffer = gcov_read_words(2);
if (!buffer) if (!buffer)
return 0; return 0;
value = from_file(buffer[0]); value = from_file(buffer[0]);
if (sizeof(value) > sizeof(gcov_unsigned_t)) if (sizeof(value) > sizeof(gcov_unsigned_t))
value |= ((gcov_type) from_file(buffer[1])) << 32; value |= ((gcov_type) from_file(buffer[1])) << 32;
else if (buffer[1]) else if (buffer[1])
gcov_var.error = -1; gcov_var.error = -1;
return value; return value;
} }
/* Read string from coverage file. Returns a pointer to a static /* Read string from coverage file. Returns a pointer to a static
@ -472,30 +458,29 @@ gcov_read_counter(void)
GCOV_LINKAGE const char * GCOV_LINKAGE const char *
gcov_read_string(void) gcov_read_string(void)
{ {
unsigned int length = gcov_read_unsigned(); unsigned int length = gcov_read_unsigned();
if (!length) if (!length)
return 0; return 0;
return (const char *) gcov_read_words(length); return (const char *) gcov_read_words(length);
} }
#endif #endif
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_read_summary(struct gcov_summary *summary) gcov_read_summary(struct gcov_summary *summary)
{ {
unsigned int ix; unsigned int ix;
struct gcov_ctr_summary *csum; struct gcov_ctr_summary *csum;
summary->checksum = gcov_read_unsigned(); summary->checksum = gcov_read_unsigned();
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) {
{ csum->num = gcov_read_unsigned();
csum->num = gcov_read_unsigned(); csum->runs = gcov_read_unsigned();
csum->runs = gcov_read_unsigned(); csum->sum_all = gcov_read_counter();
csum->sum_all = gcov_read_counter(); csum->run_max = gcov_read_counter();
csum->run_max = gcov_read_counter(); csum->sum_max = gcov_read_counter();
csum->sum_max = gcov_read_counter(); }
}
} }
#if !IN_LIBGCOV #if !IN_LIBGCOV
@ -505,16 +490,15 @@ gcov_read_summary(struct gcov_summary *summary)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_sync(gcov_position_t base, gcov_unsigned_t length) gcov_sync(gcov_position_t base, gcov_unsigned_t length)
{ {
gcc_assert(gcov_var.mode > 0); gcc_assert(gcov_var.mode > 0);
base += length; base += length;
if (base - gcov_var.start <= gcov_var.length) if (base - gcov_var.start <= gcov_var.length)
gcov_var.offset = base - gcov_var.start; gcov_var.offset = base - gcov_var.start;
else else {
{ gcov_var.offset = gcov_var.length = 0;
gcov_var.offset = gcov_var.length = 0; fseek(gcov_var.file, base << 2, SEEK_SET);
fseek(gcov_var.file, base << 2, SEEK_SET); gcov_var.start = ftell(gcov_var.file) >> 2;
gcov_var.start = ftell(gcov_var.file) >> 2; }
}
} }
#endif #endif
@ -524,11 +508,11 @@ gcov_sync(gcov_position_t base, gcov_unsigned_t length)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_seek(gcov_position_t base) gcov_seek(gcov_position_t base)
{ {
gcc_assert(gcov_var.mode < 0); gcc_assert(gcov_var.mode < 0);
if (gcov_var.offset) if (gcov_var.offset)
gcov_write_block(gcov_var.offset); gcov_write_block(gcov_var.offset);
fseek(gcov_var.file, base << 2, SEEK_SET); fseek(gcov_var.file, base << 2, SEEK_SET);
gcov_var.start = ftell(gcov_var.file) >> 2; gcov_var.start = ftell(gcov_var.file) >> 2;
} }
#endif #endif
@ -538,11 +522,11 @@ gcov_seek(gcov_position_t base)
GCOV_LINKAGE time_t GCOV_LINKAGE time_t
gcov_time(void) gcov_time(void)
{ {
struct stat status; struct stat status;
if (fstat(fileno(gcov_var.file), &status)) if (fstat(fileno(gcov_var.file), &status))
return 0; return 0;
else else
return status.st_mtime; return status.st_mtime;
} }
#endif /* IN_GCOV */ #endif /* IN_GCOV */

View File

@ -105,8 +105,8 @@ permissions described in the GCC Runtime Library Exception, version
basic_block: header int32:flags* basic_block: header int32:flags*
arcs: header int32:block_no arc* arcs: header int32:block_no arc*
arc: int32:dest_block int32:flags arc: int32:dest_block int32:flags
lines: header int32:block_no line* lines: header int32:block_no line*
int32:0 string:NULL int32:0 string:NULL
line: int32:line_no | int32:0 string:filename line: int32:line_no | int32:0 string:filename
The BASIC_BLOCK record holds per-bb flags. The number of blocks The BASIC_BLOCK record holds per-bb flags. The number of blocks
@ -126,9 +126,9 @@ permissions described in the GCC Runtime Library Exception, version
blocks they are for. blocks they are for.
The data file contains the following records. The data file contains the following records.
data: {unit summary:object summary:program* function-data*}* data: {unit summary:object summary:program* function-data*}*
unit: header int32:checksum unit: header int32:checksum
function-data: announce_function present counts function-data: announce_function present counts
announce_function: header int32:ident announce_function: header int32:ident
int32:lineno_checksum int32:cfg_checksum int32:lineno_checksum int32:cfg_checksum
present: header int32:present present: header int32:present
@ -301,10 +301,10 @@ typedef HOST_WIDEST_INT gcov_type;
/* Convert a magic or version number to a 4 character string. */ /* Convert a magic or version number to a 4 character string. */
#define GCOV_UNSIGNED2STRING(ARRAY,VALUE) \ #define GCOV_UNSIGNED2STRING(ARRAY,VALUE) \
((ARRAY)[0] = (char)((VALUE) >> 24), \ ((ARRAY)[0] = (char)((VALUE) >> 24), \
(ARRAY)[1] = (char)((VALUE) >> 16), \ (ARRAY)[1] = (char)((VALUE) >> 16), \
(ARRAY)[2] = (char)((VALUE) >> 8), \ (ARRAY)[2] = (char)((VALUE) >> 8), \
(ARRAY)[3] = (char)((VALUE) >> 0)) (ARRAY)[3] = (char)((VALUE) >> 0))
/* The record tags. Values [1..3f] are for tags which may be in either /* The record tags. Values [1..3f] are for tags which may be in either
file. Values [41..9f] for those in the note file and [a1..ff] for file. Values [41..9f] for those in the note file and [a1..ff] for
@ -320,7 +320,7 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_TAG_ARCS_LENGTH(NUM) (1 + (NUM) * 2) #define GCOV_TAG_ARCS_LENGTH(NUM) (1 + (NUM) * 2)
#define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2) #define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2)
#define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000) #define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000)
#define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000) #define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000)
#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2) #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2) #define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
#define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000) /* Obsolete */ #define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000) /* Obsolete */
@ -329,7 +329,7 @@ typedef HOST_WIDEST_INT gcov_type;
(1 + GCOV_COUNTERS_SUMMABLE * (2 + 3 * 2)) (1 + GCOV_COUNTERS_SUMMABLE * (2 + 3 * 2))
/* Counters that are collected. */ /* Counters that are collected. */
#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */ #define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
#define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be #define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be
summed. */ summed. */
#define GCOV_FIRST_VALUE_COUNTER 1 /* The first of counters used for value #define GCOV_FIRST_VALUE_COUNTER 1 /* The first of counters used for value
@ -355,7 +355,7 @@ typedef HOST_WIDEST_INT gcov_type;
/* Number of counters used for value profiling. */ /* Number of counters used for value profiling. */
#define GCOV_N_VALUE_COUNTERS \ #define GCOV_N_VALUE_COUNTERS \
(GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1) (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
/* A list of human readable names of the counters */ /* A list of human readable names of the counters */
#define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", \ #define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", \
@ -399,7 +399,7 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_BLOCK_UNEXPECTED (1 << 1) #define GCOV_BLOCK_UNEXPECTED (1 << 1)
/* Arc flags. */ /* Arc flags. */
#define GCOV_ARC_ON_TREE (1 << 0) #define GCOV_ARC_ON_TREE (1 << 0)
#define GCOV_ARC_FAKE (1 << 1) #define GCOV_ARC_FAKE (1 << 1)
#define GCOV_ARC_FALLTHROUGH (1 << 2) #define GCOV_ARC_FALLTHROUGH (1 << 2)
@ -408,18 +408,18 @@ typedef HOST_WIDEST_INT gcov_type;
/* Cumulative counter data. */ /* Cumulative counter data. */
struct gcov_ctr_summary struct gcov_ctr_summary
{ {
gcov_unsigned_t num; /* number of counters. */ gcov_unsigned_t num; /* number of counters. */
gcov_unsigned_t runs; /* number of program runs */ gcov_unsigned_t runs; /* number of program runs */
gcov_type sum_all; /* sum of all counters accumulated. */ gcov_type sum_all; /* sum of all counters accumulated. */
gcov_type run_max; /* maximum value on a single run. */ gcov_type run_max; /* maximum value on a single run. */
gcov_type sum_max; /* sum of individual run max values. */ gcov_type sum_max; /* sum of individual run max values. */
}; };
/* Object & program summary record. */ /* Object & program summary record. */
struct gcov_summary struct gcov_summary
{ {
gcov_unsigned_t checksum; /* checksum of program */ gcov_unsigned_t checksum; /* checksum of program */
struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE]; struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
}; };
/* Structures embedded in coverage program. The structures generated /* Structures embedded in coverage program. The structures generated
@ -429,8 +429,8 @@ struct gcov_summary
/* Information about counters for a single function. */ /* Information about counters for a single function. */
struct gcov_ctr_info struct gcov_ctr_info
{ {
gcov_unsigned_t num; /* number of counters. */ gcov_unsigned_t num; /* number of counters. */
gcov_type *values; /* their values. */ gcov_type *values; /* their values. */
}; };
/* Information about a single function. This uses the trailing array /* Information about a single function. This uses the trailing array
@ -441,11 +441,11 @@ struct gcov_ctr_info
struct gcov_fn_info struct gcov_fn_info
{ {
const struct gcov_info *key; /* comdat key */ const struct gcov_info *key; /* comdat key */
gcov_unsigned_t ident; /* unique ident of function */ gcov_unsigned_t ident; /* unique ident of function */
gcov_unsigned_t lineno_checksum; /* function lineo_checksum */ gcov_unsigned_t lineno_checksum; /* function lineo_checksum */
gcov_unsigned_t cfg_checksum; /* function cfg checksum */ gcov_unsigned_t cfg_checksum; /* function cfg checksum */
struct gcov_ctr_info ctrs[0]; /* instrumented counters */ struct gcov_ctr_info ctrs[0]; /* instrumented counters */
}; };
/* Type of function used to merge counters. */ /* Type of function used to merge counters. */
@ -454,18 +454,18 @@ typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
/* Information about a single object file. */ /* Information about a single object file. */
struct gcov_info struct gcov_info
{ {
gcov_unsigned_t version; /* expected version number */ gcov_unsigned_t version; /* expected version number */
struct gcov_info *next; /* link to next, used by libgcov */ struct gcov_info *next; /* link to next, used by libgcov */
gcov_unsigned_t stamp; /* uniquifying time stamp */ gcov_unsigned_t stamp; /* uniquifying time stamp */
const char *filename; /* output file name */ const char *filename; /* output file name */
gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for
unused) */ unused) */
unsigned int n_functions; /* number of functions */ unsigned int n_functions; /* number of functions */
const struct gcov_fn_info *const *functions; /* pointer to pointers const struct gcov_fn_info *const *functions; /* pointer to pointers to
to function information */ function information */
}; };
/* Register a new object file module. */ /* Register a new object file module. */
@ -506,7 +506,7 @@ extern int __gcov_execle(const char *, char *, ...) ATTRIBUTE_HIDDEN;
extern int __gcov_execv(const char *, char *const []) ATTRIBUTE_HIDDEN; extern int __gcov_execv(const char *, char *const []) ATTRIBUTE_HIDDEN;
extern int __gcov_execvp(const char *, char *const []) ATTRIBUTE_HIDDEN; extern int __gcov_execvp(const char *, char *const []) ATTRIBUTE_HIDDEN;
extern int __gcov_execve(const char *, char *const [], char *const []) extern int __gcov_execve(const char *, char *const [], char *const [])
ATTRIBUTE_HIDDEN; ATTRIBUTE_HIDDEN;
#endif #endif
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
@ -518,25 +518,27 @@ extern int __gcov_execve(const char *, char *const [], char *const [])
GCOV_LINKAGE struct gcov_var GCOV_LINKAGE struct gcov_var
{ {
FILE *file; FILE *file;
gcov_position_t start; /* Position of first byte of block */ gcov_position_t start; /* Position of first byte of block */
unsigned int offset; /* Read/write position within the block. */ unsigned int offset; /* Read/write position within the block. */
unsigned int length; /* Read limit in the block. */ unsigned int length; /* Read limit in the block. */
unsigned int overread; /* Number of words overread. */ unsigned int overread; /* Number of words overread. */
int error; /* < 0 overflow, > 0 disk error. */ int error; /* < 0 overflow, > 0 disk error. */
int mode; /* < 0 writing, > 0 reading */ int mode; /* < 0 writing, > 0 reading */
#if IN_LIBGCOV #if IN_LIBGCOV
/* Holds one block plus 4 bytes, thus all coverage reads & writes /* Holds one block plus 4 bytes, thus all coverage reads & writes
fit within this buffer and we always can transfer GCOV_BLOCK_SIZE * fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
to and from the disk. libgcov never backtracks and only writes 4 * to and from the disk. libgcov never backtracks and only writes 4
or 8 byte objects. */ * or 8 byte objects.
gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1]; */
gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
#else #else
int endian; /* Swap endianness. */ int endian; /* Swap endianness. */
/* Holds a variable length block, as the compiler can write /* Holds a variable length block, as the compiler can write
strings and needs to backtrack. */ * strings and needs to backtrack.
size_t alloc; */
gcov_unsigned_t *buffer; size_t alloc;
gcov_unsigned_t *buffer;
#endif #endif
} gcov_var ATTRIBUTE_HIDDEN; } gcov_var ATTRIBUTE_HIDDEN;
@ -569,10 +571,10 @@ GCOV_LINKAGE void gcov_read_summary(struct gcov_summary *) ATTRIBUTE_HIDDEN;
/* Available only in libgcov */ /* Available only in libgcov */
GCOV_LINKAGE void gcov_write_counter(gcov_type) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_write_counter(gcov_type) ATTRIBUTE_HIDDEN;
GCOV_LINKAGE void gcov_write_tag_length(gcov_unsigned_t, gcov_unsigned_t) GCOV_LINKAGE void gcov_write_tag_length(gcov_unsigned_t, gcov_unsigned_t)
ATTRIBUTE_HIDDEN; ATTRIBUTE_HIDDEN;
GCOV_LINKAGE void gcov_write_summary(gcov_unsigned_t /*tag*/, GCOV_LINKAGE void gcov_write_summary(gcov_unsigned_t /*tag*/,
const struct gcov_summary *) const struct gcov_summary *)
ATTRIBUTE_HIDDEN; ATTRIBUTE_HIDDEN;
static void gcov_rewrite(void); static void gcov_rewrite(void);
GCOV_LINKAGE void gcov_seek(gcov_position_t /*position*/) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_seek(gcov_position_t /*position*/) ATTRIBUTE_HIDDEN;
#else #else
@ -604,8 +606,8 @@ GCOV_LINKAGE time_t gcov_time(void);
static inline gcov_position_t static inline gcov_position_t
gcov_position(void) gcov_position(void)
{ {
gcc_assert(gcov_var.mode > 0); gcc_assert(gcov_var.mode > 0);
return gcov_var.start + gcov_var.offset; return gcov_var.start + gcov_var.offset;
} }
/* Return nonzero if the error flag is set. */ /* Return nonzero if the error flag is set. */
@ -613,7 +615,7 @@ gcov_position(void)
static inline int static inline int
gcov_is_error(void) gcov_is_error(void)
{ {
return gcov_var.file ? gcov_var.error : 1; return gcov_var.file ? gcov_var.error : 1;
} }
#if IN_LIBGCOV #if IN_LIBGCOV
@ -622,11 +624,11 @@ gcov_is_error(void)
static inline void static inline void
gcov_rewrite(void) gcov_rewrite(void)
{ {
gcc_assert(gcov_var.mode > 0); gcc_assert(gcov_var.mode > 0);
gcov_var.mode = -1; gcov_var.mode = -1;
gcov_var.start = 0; gcov_var.start = 0;
gcov_var.offset = 0; gcov_var.offset = 0;
fseek(gcov_var.file, 0L, SEEK_SET); fseek(gcov_var.file, 0L, SEEK_SET);
} }
#endif #endif

View File

@ -26,7 +26,7 @@ void sdram_initialize(int controllers, const struct mem_controller *ctrl)
#if CONFIG_RAMINIT_SYSINFO #if CONFIG_RAMINIT_SYSINFO
sdram_set_spd_registers(ctrl + i, sysinfo); sdram_set_spd_registers(ctrl + i, sysinfo);
#else #else
sdram_set_spd_registers(ctrl + i); sdram_set_spd_registers(ctrl + i);
#endif #endif
} }

View File

@ -283,7 +283,7 @@ static void bs_run_timers(int drain) {}
#endif #endif
static void bs_call_callbacks(struct boot_state *state, static void bs_call_callbacks(struct boot_state *state,
boot_state_sequence_t seq) boot_state_sequence_t seq)
{ {
struct boot_phase *phase = &state->phases[seq]; struct boot_phase *phase = &state->phases[seq];
@ -385,8 +385,8 @@ static void bs_walk_state_machine(void)
} }
static int boot_state_sched_callback(struct boot_state *state, static int boot_state_sched_callback(struct boot_state *state,
struct boot_state_callback *bscb, struct boot_state_callback *bscb,
boot_state_sequence_t seq) boot_state_sequence_t seq)
{ {
if (state->complete) { if (state->complete) {
printk(BIOS_WARNING, printk(BIOS_WARNING,
@ -403,7 +403,7 @@ static int boot_state_sched_callback(struct boot_state *state,
} }
int boot_state_sched_on_entry(struct boot_state_callback *bscb, int boot_state_sched_on_entry(struct boot_state_callback *bscb,
boot_state_t state_id) boot_state_t state_id)
{ {
struct boot_state *state = &boot_states[state_id]; struct boot_state *state = &boot_states[state_id];
@ -411,7 +411,7 @@ int boot_state_sched_on_entry(struct boot_state_callback *bscb,
} }
int boot_state_sched_on_exit(struct boot_state_callback *bscb, int boot_state_sched_on_exit(struct boot_state_callback *bscb,
boot_state_t state_id) boot_state_t state_id)
{ {
struct boot_state *state = &boot_states[state_id]; struct boot_state *state = &boot_states[state_id];

View File

@ -62,14 +62,14 @@ static inline const struct imd_entry *cbmem_to_imd(const struct cbmem_entry *e)
/* These are the different situations to handle: /* These are the different situations to handle:
* CONFIG_EARLY_CBMEM_INIT: * CONFIG_EARLY_CBMEM_INIT:
* In ramstage cbmem_initialize() attempts a recovery of the * In ramstage cbmem_initialize() attempts a recovery of the
* cbmem region set up by romstage. It uses cbmem_top() as the * cbmem region set up by romstage. It uses cbmem_top() as the
* starting point of recovery. * starting point of recovery.
* *
* In romstage, similar to ramstage, cbmem_initialize() needs to * In romstage, similar to ramstage, cbmem_initialize() needs to
* attempt recovery of the cbmem area using cbmem_top() as the limit. * attempt recovery of the cbmem area using cbmem_top() as the limit.
* cbmem_initialize_empty() initializes an empty cbmem area from * cbmem_initialize_empty() initializes an empty cbmem area from
* cbmem_top(); * cbmem_top();
* *
*/ */
static struct imd *imd_init_backing(struct imd *backing) static struct imd *imd_init_backing(struct imd *backing)

View File

@ -267,15 +267,15 @@ void jpeg_fetch_size(unsigned char *buf, int *width, int *height)
int jpeg_check_size(unsigned char *buf, int width, int height) int jpeg_check_size(unsigned char *buf, int width, int height)
{ {
datap = buf; datap = buf;
getbyte(); getbyte();
getbyte(); getbyte();
readtables(M_SOF0); readtables(M_SOF0);
getword(); getword();
getbyte(); getbyte();
if (height != getword() || width != getword()) if (height != getword() || width != getword())
return 0; return 0;
return 1; return 1;
} }
int jpeg_decode(unsigned char *buf, unsigned char *pic, int jpeg_decode(unsigned char *buf, unsigned char *pic,
@ -476,14 +476,14 @@ static int dec_readmarker(struct in *in)
#define LEBI_GET(in) (le = in->left, bi = in->bits) #define LEBI_GET(in) (le = in->left, bi = in->bits)
#define LEBI_PUT(in) (in->left = le, in->bits = bi) #define LEBI_PUT(in) (in->left = le, in->bits = bi)
#define GETBITS(in, n) ( \ #define GETBITS(in, n) ( \
(le < (n) ? le = fillbits(in, le, bi), bi = in->bits : 0), \ (le < (n) ? le = fillbits(in, le, bi), bi = in->bits : 0), \
(le -= (n)), \ (le -= (n)), \
bi >> le & ((1 << (n)) - 1) \ bi >> le & ((1 << (n)) - 1) \
) )
#define UNGETBITS(in, n) ( \ #define UNGETBITS(in, n) ( \
le += (n) \ le += (n) \
) )
@ -520,22 +520,22 @@ static int dec_rec2(struct in *in, struct dec_hufftbl *hu, int *runp, int c,
return c; return c;
} }
#define DEC_REC(in, hu, r, i) ( \ #define DEC_REC(in, hu, r, i) ( \
r = GETBITS(in, DECBITS), \ r = GETBITS(in, DECBITS), \
i = hu->llvals[r], \ i = hu->llvals[r], \
i & 128 ? \ i & 128 ? \
( \ ( \
UNGETBITS(in, i & 127), \ UNGETBITS(in, i & 127), \
r = i >> 8 & 15, \ r = i >> 8 & 15, \
i >> 16 \ i >> 16 \
) \ ) \
: \ : \
( \ ( \
LEBI_PUT(in), \ LEBI_PUT(in), \
i = dec_rec2(in, hu, &r, r, i), \ i = dec_rec2(in, hu, &r, r, i), \
LEBI_GET(in), \ LEBI_GET(in), \
i \ i \
) \ ) \
) )
static void decode_mcus(struct in *in, int *dct, int n, struct scan *sc, int *maxp) static void decode_mcus(struct in *in, int *dct, int n, struct scan *sc, int *maxp)
@ -604,7 +604,7 @@ static void dec_makehuff(struct dec_hufftbl *hu, int *hufflen, unsigned char *hu
(DECBITS - (i + 1 + v)) | 128; (DECBITS - (i + 1 + v)) | 128;
} else } else
x = v << 16 | (hu-> vals[k] & 0xf0) << 4 | x = v << 16 | (hu-> vals[k] & 0xf0) << 4 |
(DECBITS - (i + 1)); (DECBITS - (i + 1));
hu->llvals[c | d] = x; hu->llvals[c | d] = x;
} }
} }
@ -641,25 +641,25 @@ static void dec_makehuff(struct dec_hufftbl *hu, int *hufflen, unsigned char *hu
a = IMULT(a, c - s) + t, \ a = IMULT(a, c - s) + t, \
b = IMULT(b, c + s) - t) b = IMULT(b, c + s) - t)
#define IDCT \ #define IDCT \
( \ ( \
XPP(t0, t1), \ XPP(t0, t1), \
XMP(t2, t3), \ XMP(t2, t3), \
t2 = IMULT(t2, IC4) - t3, \ t2 = IMULT(t2, IC4) - t3, \
XPP(t0, t3), \ XPP(t0, t3), \
XPP(t1, t2), \ XPP(t1, t2), \
XMP(t4, t7), \ XMP(t4, t7), \
XPP(t5, t6), \ XPP(t5, t6), \
XMP(t5, t7), \ XMP(t5, t7), \
t5 = IMULT(t5, IC4), \ t5 = IMULT(t5, IC4), \
ROT(t4, t6, S22, C22),\ ROT(t4, t6, S22, C22), \
t6 -= t7, \ t6 -= t7, \
t5 -= t6, \ t5 -= t6, \
t4 -= t5, \ t4 -= t5, \
XPP(t0, t7), \ XPP(t0, t7), \
XPP(t1, t6), \ XPP(t1, t6), \
XPP(t2, t5), \ XPP(t2, t5), \
XPP(t3, t4) \ XPP(t3, t4) \
) )
static unsigned char zig2[64] = { static unsigned char zig2[64] = {
@ -765,7 +765,7 @@ static void idctqtab(unsigned char *qin, PREC *qout)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
qout[zig[i * 8 + j]] = qin[zig[i * 8 + j]] * qout[zig[i * 8 + j]] = qin[zig[i * 8 + j]] *
IMULT(aaidct[i], aaidct[j]); IMULT(aaidct[i], aaidct[j]);
} }
static void scaleidctqtab(PREC *q, PREC sc) static void scaleidctqtab(PREC *q, PREC sc)
@ -812,11 +812,11 @@ static void initcol(PREC q[][64])
/* This is optimized for the stupid sun SUNWspro compiler. */ /* This is optimized for the stupid sun SUNWspro compiler. */
#define STORECLAMP(a,x) \ #define STORECLAMP(a,x) \
( \ ( \
(a) = (x), \ (a) = (x), \
(unsigned int)(x) >= 256 ? \ (unsigned int)(x) >= 256 ? \
((a) = (x) < 0 ? 0 : 255) \ ((a) = (x) < 0 ? 0 : 255) \
: \ : \
0 \ 0 \
) )
#define CLAMP(x) ((unsigned int)(x) >= 256 ? ((x) < 0 ? 0 : 255) : (x)) #define CLAMP(x) ((unsigned int)(x) >= 256 ? ((x) < 0 ? 0 : 255) : (x))
@ -825,98 +825,98 @@ static void initcol(PREC q[][64])
#define CBCRCG(yin, xin) \ #define CBCRCG(yin, xin) \
( \ ( \
cb = outc[0 +yin*8+xin], \ cb = outc[0 +yin*8+xin], \
cr = outc[64+yin*8+xin], \ cr = outc[64+yin*8+xin], \
cg = (50 * cb + 130 * cr + 128) >> 8 \ cg = (50 * cb + 130 * cr + 128) >> 8 \
) )
#else #else
#define CBCRCG(yin, xin) \ #define CBCRCG(yin, xin) \
( \ ( \
cb = outc[0 +yin*8+xin], \ cb = outc[0 +yin*8+xin], \
cr = outc[64+yin*8+xin], \ cr = outc[64+yin*8+xin], \
cg = (3 * cb + 8 * cr) >> 4 \ cg = (3 * cb + 8 * cr) >> 4 \
) )
#endif #endif
#define PIC(yin, xin, p, xout) \ #define PIC(yin, xin, p, xout) \
( \ ( \
y = outy[(yin) * 8 + xin], \ y = outy[(yin) * 8 + xin], \
STORECLAMP(p[(xout) * 3 + 0], y + cr), \ STORECLAMP(p[(xout) * 3 + 0], y + cr), \
STORECLAMP(p[(xout) * 3 + 1], y - cg), \ STORECLAMP(p[(xout) * 3 + 1], y - cg), \
STORECLAMP(p[(xout) * 3 + 2], y + cb) \ STORECLAMP(p[(xout) * 3 + 2], y + cb) \
) )
#ifdef __LITTLE_ENDIAN #ifdef __LITTLE_ENDIAN
#define PIC_16(yin, xin, p, xout, add) \ #define PIC_16(yin, xin, p, xout, add) \
( \ ( \
y = outy[(yin) * 8 + xin], \ y = outy[(yin) * 8 + xin], \
y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
((CLAMP(y - cg + add) & 0xfc) << 3) | \ ((CLAMP(y - cg + add) & 0xfc) << 3) | \
((CLAMP(y + cb + add*2+1)) >> 3), \ ((CLAMP(y + cb + add*2+1)) >> 3), \
p[(xout) * 2 + 0] = y & 0xff, \ p[(xout) * 2 + 0] = y & 0xff, \
p[(xout) * 2 + 1] = y >> 8 \ p[(xout) * 2 + 1] = y >> 8 \
) )
#else #else
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
#define PIC_16(yin, xin, p, xout, add) \ #define PIC_16(yin, xin, p, xout, add) \
( \ ( \
y = outy[(yin) * 8 + xin], \ y = outy[(yin) * 8 + xin], \
y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 7) | \ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 7) | \
((CLAMP(y - cg + add*2+1) & 0xf8) << 2) | \ ((CLAMP(y - cg + add*2+1) & 0xf8) << 2) | \
((CLAMP(y + cb + add*2+1)) >> 3), \ ((CLAMP(y + cb + add*2+1)) >> 3), \
p[(xout) * 2 + 0] = y >> 8, \ p[(xout) * 2 + 0] = y >> 8, \
p[(xout) * 2 + 1] = y & 0xff \ p[(xout) * 2 + 1] = y & 0xff \
) )
#else #else
#define PIC_16(yin, xin, p, xout, add) \ #define PIC_16(yin, xin, p, xout, add) \
( \ ( \
y = outy[(yin) * 8 + xin], \ y = outy[(yin) * 8 + xin], \
y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
((CLAMP(y - cg + add) & 0xfc) << 3) | \ ((CLAMP(y - cg + add) & 0xfc) << 3) | \
((CLAMP(y + cb + add*2+1)) >> 3), \ ((CLAMP(y + cb + add*2+1)) >> 3), \
p[(xout) * 2 + 0] = y >> 8, \ p[(xout) * 2 + 0] = y >> 8, \
p[(xout) * 2 + 1] = y & 0xff \ p[(xout) * 2 + 1] = y & 0xff \
) )
#endif #endif
#endif #endif
#define PIC_32(yin, xin, p, xout) \ #define PIC_32(yin, xin, p, xout) \
( \ ( \
y = outy[(yin) * 8 + xin], \ y = outy[(yin) * 8 + xin], \
STORECLAMP(p[(xout) * 4 + 0], y + cr), \ STORECLAMP(p[(xout) * 4 + 0], y + cr), \
STORECLAMP(p[(xout) * 4 + 1], y - cg), \ STORECLAMP(p[(xout) * 4 + 1], y - cg), \
STORECLAMP(p[(xout) * 4 + 2], y + cb), \ STORECLAMP(p[(xout) * 4 + 2], y + cb), \
p[(xout) * 4 + 3] = 0 \ p[(xout) * 4 + 3] = 0 \
) )
#define PIC221111(xin) \ #define PIC221111(xin) \
( \ ( \
CBCRCG(0, xin), \ CBCRCG(0, xin), \
PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \ PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \
PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \ PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \
PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \ PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \
PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \ PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
) )
#define PIC221111_16(xin) \ #define PIC221111_16(xin) \
( \ ( \
CBCRCG(0, xin), \ CBCRCG(0, xin), \
PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0, 3), \ PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0, 3), \
PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1, 0), \ PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1, 0), \
PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0, 1), \ PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0, 1), \
PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1, 2) \ PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1, 2) \
) )
#define PIC221111_32(xin) \ #define PIC221111_32(xin) \
( \ ( \
CBCRCG(0, xin), \ CBCRCG(0, xin), \
PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0),\ PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \
PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1),\ PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \
PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0),\ PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \
PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \ PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
) )
static void col221111(int *out, unsigned char *pic, int width) static void col221111(int *out, unsigned char *pic, int width)
@ -957,7 +957,7 @@ static void col221111_16(int *out, unsigned char *pic, int width)
for (i = 2; i > 0; i--) { for (i = 2; i > 0; i--) {
for (j = 4; j > 0; j--) { for (j = 4; j > 0; j--) {
for (k = 0; k < 8; k++) for (k = 0; k < 8; k++)
PIC221111_16(k); PIC221111_16(k);
outc += 8; outc += 8;
outy += 16; outy += 16;
pic0 += 2 * width; pic0 += 2 * width;

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,8 @@
: ((look_ahead.dw = *(UInt32 *)Buffer), (Buffer += 4), (look_ahead_ptr = 1), look_ahead.raw[0]))) : ((look_ahead.dw = *(UInt32 *)Buffer), (Buffer += 4), (look_ahead_ptr = 1), look_ahead.raw[0])))
#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \ #define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
{ int i; for (i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }} { int i; for (i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) \
| RC_READ_BYTE; }}
#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; } #define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
@ -53,15 +54,22 @@
#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits; #define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \ #define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
{ UpdateBit0(p); mi <<= 1; A0; } else \ { UpdateBit0(p); mi <<= 1; A0; } else \
{ UpdateBit1(p); mi = (mi + mi) + 1; A1; } { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;) #define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
#define RangeDecoderBitTreeDecode(probs, numLevels, res) \ #define RangeDecoderBitTreeDecode(probs, numLevels, res) \
{ int i = numLevels; res = 1; \ { \
do { CProb *cp = probs + res; RC_GET_BIT(cp, res) } while (--i != 0); \ int i = numLevels; \
res -= (1 << numLevels); } \
res = 1; \
do { \
CProb *cp = probs + res; \
RC_GET_BIT(cp, res) \
} while (--i != 0); \
res -= (1 << numLevels); \
}
#define kNumPosBitsMax 4 #define kNumPosBitsMax 4
@ -116,301 +124,257 @@ StopCompilingDueBUG
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size) int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
{ {
unsigned char prop0; unsigned char prop0;
if (size < LZMA_PROPERTIES_SIZE) if (size < LZMA_PROPERTIES_SIZE)
return LZMA_RESULT_DATA_ERROR; return LZMA_RESULT_DATA_ERROR;
prop0 = propsData[0]; prop0 = propsData[0];
if (prop0 >= (9 * 5 * 5)) if (prop0 >= (9 * 5 * 5))
return LZMA_RESULT_DATA_ERROR; return LZMA_RESULT_DATA_ERROR;
{ {
for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)) for (propsRes->pb = 0; prop0 >= (9 * 5);
; propsRes->pb++, prop0 -= (9 * 5))
for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9) ;
; for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9)
propsRes->lc = prop0; ;
/* propsRes->lc = prop0;
unsigned char remainder = (unsigned char)(prop0 / 9); /*
propsRes->lc = prop0 % 9; * unsigned char remainder = (unsigned char)(prop0 / 9);
propsRes->pb = remainder / 5; * propsRes->lc = prop0 % 9;
propsRes->lp = remainder % 5; * propsRes->pb = remainder / 5;
*/ * propsRes->lp = remainder % 5;
} */
}
return LZMA_RESULT_OK; return LZMA_RESULT_OK;
} }
#define kLzmaStreamWasFinishedId (-1) #define kLzmaStreamWasFinishedId (-1)
int LzmaDecode(CLzmaDecoderState *vs, int LzmaDecode(CLzmaDecoderState *vs,
const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed) unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
{ {
CProb *p = vs->Probs; CProb *p = vs->Probs;
SizeT nowPos = 0; SizeT nowPos = 0;
Byte previousByte = 0; Byte previousByte = 0;
UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1; UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1; UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
int lc = vs->Properties.lc; int lc = vs->Properties.lc;
int state = 0; int state = 0;
UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
int len = 0; int len = 0;
const Byte *Buffer; const Byte *Buffer;
const Byte *BufferLim; const Byte *BufferLim;
int look_ahead_ptr = 4; int look_ahead_ptr = 4;
union union {
{ Byte raw[4];
Byte raw[4]; UInt32 dw;
UInt32 dw; } look_ahead;
} look_ahead; UInt32 Range;
UInt32 Range; UInt32 Code;
UInt32 Code;
*inSizeProcessed = 0; *inSizeProcessed = 0;
*outSizeProcessed = 0; *outSizeProcessed = 0;
{ {
UInt32 i; UInt32 i;
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc
for (i = 0; i < numProbs; i++) + vs->Properties.lp));
p[i] = kBitModelTotal >> 1; for (i = 0; i < numProbs; i++)
} p[i] = kBitModelTotal >> 1;
}
RC_INIT(inStream, inSize); RC_INIT(inStream, inSize);
while (nowPos < outSize) while (nowPos < outSize) {
{ CProb *prob;
CProb *prob; UInt32 bound;
UInt32 bound; int posState = (int)((nowPos)& posStateMask);
int posState = (int)(
(nowPos
)
& posStateMask);
prob = p + IsMatch + (state << kNumPosBitsMax) + posState; prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
IfBit0(prob) IfBit0(prob) {
{ int symbol = 1;
int symbol = 1; UpdateBit0(prob)
UpdateBit0(prob) prob = p + Literal + (LZMA_LIT_SIZE *
prob = p + Literal + (LZMA_LIT_SIZE * ((((nowPos) & literalPosMask) << lc)
((( + (previousByte >> (8 - lc))));
(nowPos
)
& literalPosMask) << lc) + (previousByte >> (8 - lc))));
if (state >= kNumLitStates) if (state >= kNumLitStates) {
{ int matchByte;
int matchByte; matchByte = outStream[nowPos - rep0];
matchByte = outStream[nowPos - rep0]; do {
do int bit;
{ CProb *probLit;
int bit; matchByte <<= 1;
CProb *probLit; bit = (matchByte & 0x100);
matchByte <<= 1; probLit = prob + 0x100 + bit + symbol;
bit = (matchByte & 0x100); RC_GET_BIT2(probLit, symbol,
probLit = prob + 0x100 + bit + symbol; if (bit != 0)
RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break) break,
} if (bit == 0)
while (symbol < 0x100); break)
} } while (symbol < 0x100);
while (symbol < 0x100) }
{ while (symbol < 0x100) {
CProb *probLit = prob + symbol; CProb *probLit = prob + symbol;
RC_GET_BIT(probLit, symbol) RC_GET_BIT(probLit, symbol)
} }
previousByte = (Byte)symbol; previousByte = (Byte)symbol;
outStream[nowPos++] = previousByte; outStream[nowPos++] = previousByte;
if (state < 4) if (state < 4)
state = 0; state = 0;
else if (state < 10) else if (state < 10)
state -= 3; state -= 3;
else else
state -= 6; state -= 6;
} } else {
else UpdateBit1(prob);
{ prob = p + IsRep + state;
UpdateBit1(prob); IfBit0(prob) {
prob = p + IsRep + state; UpdateBit0(prob);
IfBit0(prob) rep3 = rep2;
{ rep2 = rep1;
UpdateBit0(prob); rep1 = rep0;
rep3 = rep2; state = state < kNumLitStates ? 0 : 3;
rep2 = rep1; prob = p + LenCoder;
rep1 = rep0; } else {
state = state < kNumLitStates ? 0 : 3; UpdateBit1(prob);
prob = p + LenCoder; prob = p + IsRepG0 + state;
} IfBit0(prob) {
else UpdateBit0(prob);
{ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
UpdateBit1(prob); IfBit0(prob) {
prob = p + IsRepG0 + state; UpdateBit0(prob);
IfBit0(prob)
{
UpdateBit0(prob);
prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
IfBit0(prob)
{
UpdateBit0(prob);
if (nowPos == 0) if (nowPos == 0)
return LZMA_RESULT_DATA_ERROR; return LZMA_RESULT_DATA_ERROR;
state = state < kNumLitStates ? 9 : 11; state = state < kNumLitStates ? 9 : 11;
previousByte = outStream[nowPos - rep0]; previousByte = outStream[nowPos - rep0];
outStream[nowPos++] = previousByte; outStream[nowPos++] = previousByte;
continue; continue;
} } else
else UpdateBit1(prob);
{ } else {
UpdateBit1(prob); UInt32 distance;
} UpdateBit1(prob);
} prob = p + IsRepG1 + state;
else IfBit0(prob) {
{ UpdateBit0(prob);
UInt32 distance; distance = rep1;
UpdateBit1(prob); } else {
prob = p + IsRepG1 + state; UpdateBit1(prob);
IfBit0(prob) prob = p + IsRepG2 + state;
{ IfBit0(prob) {
UpdateBit0(prob); UpdateBit0(prob);
distance = rep1; distance = rep2;
} } else {
else UpdateBit1(prob);
{ distance = rep3;
UpdateBit1(prob); rep3 = rep2;
prob = p + IsRepG2 + state; }
IfBit0(prob) rep2 = rep1;
{ }
UpdateBit0(prob); rep1 = rep0;
distance = rep2; rep0 = distance;
} }
else state = state < kNumLitStates ? 8 : 11;
{ prob = p + RepLenCoder;
UpdateBit1(prob); }
distance = rep3; {
rep3 = rep2; int numBits, offset;
} CProb *probLen = prob + LenChoice;
rep2 = rep1; IfBit0(probLen) {
} UpdateBit0(probLen);
rep1 = rep0; probLen = prob + LenLow + (posState << kLenNumLowBits);
rep0 = distance; offset = 0;
} numBits = kLenNumLowBits;
state = state < kNumLitStates ? 8 : 11; } else {
prob = p + RepLenCoder; UpdateBit1(probLen);
} probLen = prob + LenChoice2;
{ IfBit0(probLen) {
int numBits, offset; UpdateBit0(probLen);
CProb *probLen = prob + LenChoice; probLen = prob + LenMid + (posState << kLenNumMidBits);
IfBit0(probLen) offset = kLenNumLowSymbols;
{ numBits = kLenNumMidBits;
UpdateBit0(probLen); } else {
probLen = prob + LenLow + (posState << kLenNumLowBits); UpdateBit1(probLen);
offset = 0; probLen = prob + LenHigh;
numBits = kLenNumLowBits; offset = kLenNumLowSymbols + kLenNumMidSymbols;
} numBits = kLenNumHighBits;
else }
{ }
UpdateBit1(probLen); RangeDecoderBitTreeDecode(probLen, numBits, len);
probLen = prob + LenChoice2; len += offset;
IfBit0(probLen) }
{
UpdateBit0(probLen);
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
numBits = kLenNumMidBits;
}
else
{
UpdateBit1(probLen);
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
numBits = kLenNumHighBits;
}
}
RangeDecoderBitTreeDecode(probLen, numBits, len);
len += offset;
}
if (state < 4) if (state < 4) {
{ int posSlot;
int posSlot; state += kNumLitStates;
state += kNumLitStates; prob = p + PosSlot +
prob = p + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
kNumPosSlotBits); RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot); if (posSlot >= kStartPosModelIndex) {
if (posSlot >= kStartPosModelIndex) int numDirectBits = ((posSlot >> 1) - 1);
{ rep0 = (2 | ((UInt32)posSlot & 1));
int numDirectBits = ((posSlot >> 1) - 1); if (posSlot < kEndPosModelIndex) {
rep0 = (2 | ((UInt32)posSlot & 1)); rep0 <<= numDirectBits;
if (posSlot < kEndPosModelIndex) prob = p + SpecPos + rep0 - posSlot - 1;
{ } else {
rep0 <<= numDirectBits; numDirectBits -= kNumAlignBits;
prob = p + SpecPos + rep0 - posSlot - 1; do {
} RC_NORMALIZE
else Range >>= 1;
{ rep0 <<= 1;
numDirectBits -= kNumAlignBits; if (Code >= Range) {
do Code -= Range;
{ rep0 |= 1;
RC_NORMALIZE }
Range >>= 1; } while (--numDirectBits != 0);
rep0 <<= 1; prob = p + Align;
if (Code >= Range) rep0 <<= kNumAlignBits;
{ numDirectBits = kNumAlignBits;
Code -= Range; }
rep0 |= 1; {
} int i = 1;
} int mi = 1;
while (--numDirectBits != 0); do {
prob = p + Align; CProb *prob3 = prob + mi;
rep0 <<= kNumAlignBits; RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
numDirectBits = kNumAlignBits; i <<= 1;
} } while (--numDirectBits != 0);
{ }
int i = 1; } else
int mi = 1; rep0 = posSlot;
do if (++rep0 == (UInt32)(0)) {
{ /* it's for stream version */
CProb *prob3 = prob + mi; len = kLzmaStreamWasFinishedId;
RC_GET_BIT2(prob3, mi, ; , rep0 |= i); break;
i <<= 1; }
} }
while (--numDirectBits != 0);
}
}
else
rep0 = posSlot;
if (++rep0 == (UInt32)(0))
{
/* it's for stream version */
len = kLzmaStreamWasFinishedId;
break;
}
}
len += kMatchMinLen; len += kMatchMinLen;
if (rep0 > nowPos) if (rep0 > nowPos)
return LZMA_RESULT_DATA_ERROR; return LZMA_RESULT_DATA_ERROR;
do do {
{ previousByte = outStream[nowPos - rep0];
previousByte = outStream[nowPos - rep0]; len--;
len--; outStream[nowPos++] = previousByte;
outStream[nowPos++] = previousByte; } while (len != 0 && nowPos < outSize);
} }
while (len != 0 && nowPos < outSize); }
} RC_NORMALIZE;
}
RC_NORMALIZE;
*inSizeProcessed = (SizeT)(Buffer - inStream); *inSizeProcessed = (SizeT)(Buffer - inStream);
*outSizeProcessed = nowPos; *outSizeProcessed = nowPos;
return LZMA_RESULT_OK; return LZMA_RESULT_OK;
} }

View File

@ -38,11 +38,10 @@ typedef UInt32 SizeT;
#define LZMA_PROPERTIES_SIZE 5 #define LZMA_PROPERTIES_SIZE 5
typedef struct _CLzmaProperties typedef struct _CLzmaProperties {
{ int lc;
int lc; int lp;
int lp; int pb;
int pb;
}CLzmaProperties; }CLzmaProperties;
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
@ -51,17 +50,14 @@ int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsDa
#define kLzmaNeedInitId (-2) #define kLzmaNeedInitId (-2)
typedef struct _CLzmaDecoderState typedef struct _CLzmaDecoderState {
{ CLzmaProperties Properties;
CLzmaProperties Properties; CProb *Probs;
CProb *Probs;
} CLzmaDecoderState; } CLzmaDecoderState;
int LzmaDecode(CLzmaDecoderState *vs, int LzmaDecode(CLzmaDecoderState *vs,
const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
#endif #endif

View File

@ -17,22 +17,22 @@
#include <memrange.h> #include <memrange.h>
static inline void range_entry_link(struct range_entry **prev_ptr, static inline void range_entry_link(struct range_entry **prev_ptr,
struct range_entry *r) struct range_entry *r)
{ {
r->next = *prev_ptr; r->next = *prev_ptr;
*prev_ptr = r; *prev_ptr = r;
} }
static inline void range_entry_unlink(struct range_entry **prev_ptr, static inline void range_entry_unlink(struct range_entry **prev_ptr,
struct range_entry *r) struct range_entry *r)
{ {
*prev_ptr = r->next; *prev_ptr = r->next;
r->next = NULL; r->next = NULL;
} }
static inline void range_entry_unlink_and_free(struct memranges *ranges, static inline void range_entry_unlink_and_free(struct memranges *ranges,
struct range_entry **prev_ptr, struct range_entry **prev_ptr,
struct range_entry *r) struct range_entry *r)
{ {
range_entry_unlink(prev_ptr, r); range_entry_unlink(prev_ptr, r);
range_entry_link(&ranges->free_list, r); range_entry_link(&ranges->free_list, r);
@ -54,7 +54,7 @@ static struct range_entry *alloc_range(struct memranges *ranges)
static inline struct range_entry * static inline struct range_entry *
range_list_add(struct memranges *ranges, struct range_entry **prev_ptr, range_list_add(struct memranges *ranges, struct range_entry **prev_ptr,
resource_t begin, resource_t end, unsigned long tag) resource_t begin, resource_t end, unsigned long tag)
{ {
struct range_entry *new_entry; struct range_entry *new_entry;
@ -102,8 +102,8 @@ static void merge_neighbor_entries(struct memranges *ranges)
} }
static void remove_memranges(struct memranges *ranges, static void remove_memranges(struct memranges *ranges,
resource_t begin, resource_t end, resource_t begin, resource_t end,
unsigned long unused) unsigned long unused)
{ {
struct range_entry *cur; struct range_entry *cur;
struct range_entry *next; struct range_entry *next;
@ -136,7 +136,7 @@ static void remove_memranges(struct memranges *ranges,
if (end >= cur->end) { if (end >= cur->end) {
begin = cur->end + 1; begin = cur->end + 1;
range_entry_unlink_and_free(ranges, prev_ptr, range_entry_unlink_and_free(ranges, prev_ptr,
cur); cur);
continue; continue;
} }
} }
@ -152,7 +152,7 @@ static void remove_memranges(struct memranges *ranges,
/* Hole punched in middle of entry. */ /* Hole punched in middle of entry. */
if (begin > cur->begin && tmp_end < cur->end) { if (begin > cur->begin && tmp_end < cur->end) {
range_list_add(ranges, &cur->next, end + 1, cur->end, range_list_add(ranges, &cur->next, end + 1, cur->end,
cur->tag); cur->tag);
cur->end = begin - 1; cur->end = begin - 1;
break; break;
} }
@ -168,8 +168,8 @@ static void remove_memranges(struct memranges *ranges,
} }
static void merge_add_memranges(struct memranges *ranges, static void merge_add_memranges(struct memranges *ranges,
resource_t begin, resource_t end, resource_t begin, resource_t end,
unsigned long tag) unsigned long tag)
{ {
struct range_entry *cur; struct range_entry *cur;
struct range_entry **prev_ptr; struct range_entry **prev_ptr;
@ -202,7 +202,7 @@ static void merge_add_memranges(struct memranges *ranges,
} }
void memranges_update_tag(struct memranges *ranges, unsigned long old_tag, void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
unsigned long new_tag) unsigned long new_tag)
{ {
struct range_entry *r; struct range_entry *r;
@ -215,12 +215,12 @@ void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
} }
typedef void (*range_action_t)(struct memranges *ranges, typedef void (*range_action_t)(struct memranges *ranges,
resource_t begin, resource_t end, resource_t begin, resource_t end,
unsigned long tag); unsigned long tag);
static void do_action(struct memranges *ranges, static void do_action(struct memranges *ranges,
resource_t base, resource_t size, unsigned long tag, resource_t base, resource_t size, unsigned long tag,
range_action_t action) range_action_t action)
{ {
resource_t end; resource_t end;
resource_t begin; resource_t begin;
@ -238,13 +238,13 @@ static void do_action(struct memranges *ranges,
} }
void memranges_create_hole(struct memranges *ranges, void memranges_create_hole(struct memranges *ranges,
resource_t base, resource_t size) resource_t base, resource_t size)
{ {
do_action(ranges, base, size, -1, remove_memranges); do_action(ranges, base, size, -1, remove_memranges);
} }
void memranges_insert(struct memranges *ranges, void memranges_insert(struct memranges *ranges,
resource_t base, resource_t size, unsigned long tag) resource_t base, resource_t size, unsigned long tag)
{ {
do_action(ranges, base, size, tag, merge_add_memranges); do_action(ranges, base, size, tag, merge_add_memranges);
} }
@ -267,9 +267,9 @@ static void collect_ranges(void *gp, struct device *dev, struct resource *res)
} }
void memranges_add_resources_filter(struct memranges *ranges, void memranges_add_resources_filter(struct memranges *ranges,
unsigned long mask, unsigned long match, unsigned long mask, unsigned long match,
unsigned long tag, unsigned long tag,
memrange_filter_t filter) memrange_filter_t filter)
{ {
struct collect_context context; struct collect_context context;
@ -284,14 +284,14 @@ void memranges_add_resources_filter(struct memranges *ranges,
} }
void memranges_add_resources(struct memranges *ranges, void memranges_add_resources(struct memranges *ranges,
unsigned long mask, unsigned long match, unsigned long mask, unsigned long match,
unsigned long tag) unsigned long tag)
{ {
memranges_add_resources_filter(ranges, mask, match, tag, NULL); memranges_add_resources_filter(ranges, mask, match, tag, NULL);
} }
void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free, void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
size_t num_free) size_t num_free)
{ {
size_t i; size_t i;
@ -303,8 +303,8 @@ void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
} }
void memranges_init(struct memranges *ranges, void memranges_init(struct memranges *ranges,
unsigned long mask, unsigned long match, unsigned long mask, unsigned long match,
unsigned long tag) unsigned long tag)
{ {
memranges_init_empty(ranges, NULL, 0); memranges_init_empty(ranges, NULL, 0);
memranges_add_resources(ranges, mask, match, tag); memranges_add_resources(ranges, mask, match, tag);
@ -314,12 +314,12 @@ void memranges_teardown(struct memranges *ranges)
{ {
while (ranges->entries != NULL) { while (ranges->entries != NULL) {
range_entry_unlink_and_free(ranges, &ranges->entries, range_entry_unlink_and_free(ranges, &ranges->entries,
ranges->entries); ranges->entries);
} }
} }
void memranges_fill_holes_up_to(struct memranges *ranges, void memranges_fill_holes_up_to(struct memranges *ranges,
resource_t limit, unsigned long tag) resource_t limit, unsigned long tag)
{ {
struct range_entry *cur; struct range_entry *cur;
struct range_entry *prev; struct range_entry *prev;
@ -341,7 +341,7 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
if (end >= limit) if (end >= limit)
end = limit - 1; end = limit - 1;
range_list_add(ranges, &prev->next, range_list_add(ranges, &prev->next,
range_entry_end(prev), end, tag); range_entry_end(prev), end, tag);
} }
prev = cur; prev = cur;
@ -356,14 +356,14 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
* to be added to cover the range up to the limit. */ * to be added to cover the range up to the limit. */
if (prev != NULL && range_entry_end(prev) < limit) if (prev != NULL && range_entry_end(prev) < limit)
range_list_add(ranges, &prev->next, range_entry_end(prev), range_list_add(ranges, &prev->next, range_entry_end(prev),
limit - 1, tag); limit - 1, tag);
/* Merge all entries that were newly added. */ /* Merge all entries that were newly added. */
merge_neighbor_entries(ranges); merge_neighbor_entries(ranges);
} }
struct range_entry *memranges_next_entry(struct memranges *ranges, struct range_entry *memranges_next_entry(struct memranges *ranges,
const struct range_entry *r) const struct range_entry *r)
{ {
return r->next; return r->next;
} }

View File

@ -112,7 +112,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
} }
uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
uint8_t *nvlocked) uint8_t *nvlocked)
{ {
VBDEBUG("MOCK_TPM: %s\n", __func__); VBDEBUG("MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE; return TPM_E_NO_DEVICE;
@ -125,7 +125,7 @@ uint32_t tlcl_set_global_lock(void)
} }
uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest, uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
uint8_t *out_digest) uint8_t *out_digest)
{ {
VBDEBUG("MOCK_TPM: %s\n", __func__); VBDEBUG("MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE; return TPM_E_NO_DEVICE;

View File

@ -41,14 +41,14 @@
#endif #endif
static inline void reg_script_set_dev(struct reg_script_context *ctx, static inline void reg_script_set_dev(struct reg_script_context *ctx,
device_t dev) device_t dev)
{ {
ctx->dev = dev; ctx->dev = dev;
ctx->res = NULL; ctx->res = NULL;
} }
static inline void reg_script_set_step(struct reg_script_context *ctx, static inline void reg_script_set_step(struct reg_script_context *ctx,
const struct reg_script *step) const struct reg_script *step)
{ {
ctx->step = step; ctx->step = step;
} }
@ -603,7 +603,7 @@ static void reg_script_rxw(struct reg_script_context *ctx)
* as the previous one. That will run to completion and then move on to the * as the previous one. That will run to completion and then move on to the
* next step of the previous context. */ * next step of the previous context. */
static void reg_script_run_next(struct reg_script_context *ctx, static void reg_script_run_next(struct reg_script_context *ctx,
const struct reg_script *step); const struct reg_script *step);
static void reg_script_run_step(struct reg_script_context *ctx, static void reg_script_run_step(struct reg_script_context *ctx,
@ -670,7 +670,7 @@ static void reg_script_run_with_context(struct reg_script_context *ctx)
} }
static void reg_script_run_next(struct reg_script_context *prev_ctx, static void reg_script_run_next(struct reg_script_context *prev_ctx,
const struct reg_script *step) const struct reg_script *step)
{ {
struct reg_script_context ctx; struct reg_script_context ctx;

View File

@ -33,7 +33,7 @@ static inline int rmodule_is_loaded(const struct rmodule *module)
/* Calculate a loaded program address based on the blob address. */ /* Calculate a loaded program address based on the blob address. */
static inline void *rmodule_load_addr(const struct rmodule *module, static inline void *rmodule_load_addr(const struct rmodule *module,
uintptr_t blob_addr) uintptr_t blob_addr)
{ {
char *loc = module->location; char *loc = module->location;
return &loc[blob_addr - module->header->module_link_start_address]; return &loc[blob_addr - module->header->module_link_start_address];
@ -66,7 +66,7 @@ int rmodule_parse(void *ptr, struct rmodule *module)
/* The payload lives after the header. */ /* The payload lives after the header. */
module->payload = &base[rhdr->payload_begin_offset]; module->payload = &base[rhdr->payload_begin_offset];
module->payload_size = rhdr->payload_end_offset - module->payload_size = rhdr->payload_end_offset -
rhdr->payload_begin_offset; rhdr->payload_begin_offset;
module->relocations = &base[rhdr->relocations_begin_offset]; module->relocations = &base[rhdr->relocations_begin_offset];
return 0; return 0;
@ -204,7 +204,7 @@ int rmodule_load(void *base, struct rmodule *module)
} }
int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size, int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
size_t *region_size, int *load_offset) size_t *region_size, int *load_offset)
{ {
/* region_alignment must be a power of 2. */ /* region_alignment must be a power of 2. */
if (region_alignment & (region_alignment - 1)) if (region_alignment & (region_alignment - 1))
@ -270,7 +270,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl)
rmodule_offset = rmodule_offset =
rmodule_calc_region(DYN_CBMEM_ALIGN_SIZE, rmodule_calc_region(DYN_CBMEM_ALIGN_SIZE,
stage.memlen, &region_size, &load_offset); stage.memlen, &region_size, &load_offset);
stage_region = cbmem_add(rsl->cbmem_id, region_size); stage_region = cbmem_add(rsl->cbmem_id, region_size);

View File

@ -416,32 +416,32 @@ static int load_self_segments(struct segment *head, struct prog *payload,
/* Copy data from the initial buffer */ /* Copy data from the initial buffer */
switch (ptr->compression) { switch (ptr->compression) {
case CBFS_COMPRESS_LZMA: { case CBFS_COMPRESS_LZMA: {
printk(BIOS_DEBUG, "using LZMA\n"); printk(BIOS_DEBUG, "using LZMA\n");
timestamp_add_now(TS_START_ULZMA); timestamp_add_now(TS_START_ULZMA);
len = ulzman(src, len, dest, memsz); len = ulzman(src, len, dest, memsz);
timestamp_add_now(TS_END_ULZMA); timestamp_add_now(TS_END_ULZMA);
if (!len) /* Decompression Error. */ if (!len) /* Decompression Error. */
return 0; return 0;
break; break;
} }
case CBFS_COMPRESS_LZ4: { case CBFS_COMPRESS_LZ4: {
printk(BIOS_DEBUG, "using LZ4\n"); printk(BIOS_DEBUG, "using LZ4\n");
timestamp_add_now(TS_START_ULZ4F); timestamp_add_now(TS_START_ULZ4F);
len = ulz4fn(src, len, dest, memsz); len = ulz4fn(src, len, dest, memsz);
timestamp_add_now(TS_END_ULZ4F); timestamp_add_now(TS_END_ULZ4F);
if (!len) /* Decompression Error. */ if (!len) /* Decompression Error. */
return 0; return 0;
break; break;
} }
case CBFS_COMPRESS_NONE: { case CBFS_COMPRESS_NONE: {
printk(BIOS_DEBUG, "it's not compressed!\n"); printk(BIOS_DEBUG, "it's not compressed!\n");
memcpy(dest, src, len); memcpy(dest, src, len);
break; break;
} }
default: default:
printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression); printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression);
return -1; return -1;
} }
/* Calculate middle after any changes to len. */ /* Calculate middle after any changes to len. */
middle = dest + len; middle = dest + len;

View File

@ -190,8 +190,8 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE); u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE);
if (((buf[SPD_CRC_LO] == 0) && (buf[SPD_CRC_HI] == 0)) if (((buf[SPD_CRC_LO] == 0) && (buf[SPD_CRC_HI] == 0))
|| (buf[SPD_CRC_LO] != (crc & 0xff)) || (buf[SPD_CRC_LO] != (crc & 0xff))
|| (buf[SPD_CRC_HI] != (crc >> 8))) { || (buf[SPD_CRC_HI] != (crc >> 8))) {
printk(BIOS_WARNING, "SPD CRC %02x%02x is invalid, should be %04x\n", printk(BIOS_WARNING, "SPD CRC %02x%02x is invalid, should be %04x\n",
buf[SPD_CRC_HI], buf[SPD_CRC_LO], crc); buf[SPD_CRC_HI], buf[SPD_CRC_LO], crc);
buf[SPD_CRC_LO] = crc & 0xff; buf[SPD_CRC_LO] = crc & 0xff;
@ -204,7 +204,7 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
printk(BIOS_WARNING, "%02x ", buf[i]); printk(BIOS_WARNING, "%02x ", buf[i]);
} }
printk(BIOS_WARNING, "\n"); printk(BIOS_WARNING, "\n");
} }
return 0; return 0;
} }
#endif #endif

View File

@ -186,8 +186,8 @@ static void asmlinkage call_wrapper_block_state(void *arg)
/* Prepare a thread so that it starts by executing thread_entry(thread_arg). /* Prepare a thread so that it starts by executing thread_entry(thread_arg).
* Within thread_entry() it will call func(arg). */ * Within thread_entry() it will call func(arg). */
static void prepare_thread(struct thread *t, void *func, void *arg, static void prepare_thread(struct thread *t, void *func, void *arg,
asmlinkage void(*thread_entry)(void *), asmlinkage void(*thread_entry)(void *),
void *thread_arg) void *thread_arg)
{ {
/* Stash the function and argument to run. */ /* Stash the function and argument to run. */
t->entry = func; t->entry = func;
@ -305,7 +305,7 @@ int thread_run(void (*func)(void *), void *arg)
} }
int thread_run_until(void (*func)(void *), void *arg, int thread_run_until(void (*func)(void *), void *arg,
boot_state_t state, boot_state_sequence_t seq) boot_state_t state, boot_state_sequence_t seq)
{ {
struct thread *current; struct thread *current;
struct thread *t; struct thread *t;

View File

@ -49,7 +49,7 @@ static inline struct timeout_callback *timer_queue_head(struct timer_queue *tq)
} }
static int timer_queue_insert(struct timer_queue *tq, static int timer_queue_insert(struct timer_queue *tq,
struct timeout_callback *tocb) struct timeout_callback *tocb)
{ {
int index; int index;
@ -99,7 +99,7 @@ static int timer_queue_min_child_index(struct timer_queue *tq, int index)
return left_child_index; return left_child_index;
if (mono_time_cmp(&tq->queue[left_child_index]->expiration, if (mono_time_cmp(&tq->queue[left_child_index]->expiration,
&tq->queue[right_child_index]->expiration) < 0) { &tq->queue[right_child_index]->expiration) < 0) {
return left_child_index; return left_child_index;
} }
return right_child_index; return right_child_index;

View File

@ -75,7 +75,7 @@ static inline int tpm_return_code(const uint8_t *buffer) {
* DOING_SELFTEST errors are returned. * DOING_SELFTEST errors are returned.
*/ */
static uint32_t tlcl_send_receive_no_retry(const uint8_t *request, static uint32_t tlcl_send_receive_no_retry(const uint8_t *request,
uint8_t *response, int max_length) { uint8_t *response, int max_length) {
uint32_t response_length = max_length; uint32_t response_length = max_length;
uint32_t result; uint32_t result;
@ -116,7 +116,7 @@ uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
#if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE) #if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
/* Retry only once */ /* Retry only once */
result = tlcl_send_receive_no_retry(request, response, result = tlcl_send_receive_no_retry(request, response,
max_length); max_length);
#else #else
/* This needs serious testing. The TPM specification says: "iii. /* This needs serious testing. The TPM specification says: "iii.
* The caller MUST wait for the actions of TPM_ContinueSelfTest * The caller MUST wait for the actions of TPM_ContinueSelfTest
@ -125,7 +125,7 @@ uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
* actions have completed other than trying again? */ * actions have completed other than trying again? */
do { do {
result = tlcl_send_receive_no_retry(request, response, result = tlcl_send_receive_no_retry(request, response,
max_length); max_length);
} while (result == TPM_E_DOING_SELFTEST); } while (result == TPM_E_DOING_SELFTEST);
#endif #endif
} }
@ -163,8 +163,8 @@ uint32_t tlcl_startup(void) {
} }
uint32_t tlcl_resume(void) { uint32_t tlcl_resume(void) {
VBDEBUG("TPM: Resume\n"); VBDEBUG("TPM: Resume\n");
return send(tpm_resume_cmd.buffer); return send(tpm_resume_cmd.buffer);
} }
uint32_t tlcl_self_test_full(void) uint32_t tlcl_self_test_full(void)
@ -179,7 +179,7 @@ uint32_t tlcl_continue_self_test(void)
VBDEBUG("TPM: Continue self test\n"); VBDEBUG("TPM: Continue self test\n");
/* Call the No Retry version of SendReceive to avoid recursion. */ /* Call the No Retry version of SendReceive to avoid recursion. */
return tlcl_send_receive_no_retry(tpm_continueselftest_cmd.buffer, return tlcl_send_receive_no_retry(tpm_continueselftest_cmd.buffer,
response, sizeof(response)); response, sizeof(response));
} }
uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size) uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
@ -280,7 +280,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t size; uint32_t size;
uint32_t result = tlcl_send_receive(tpm_getflags_cmd.buffer, response, uint32_t result = tlcl_send_receive(tpm_getflags_cmd.buffer, response,
sizeof(response)); sizeof(response));
if (result != TPM_SUCCESS) if (result != TPM_SUCCESS)
return result; return result;
from_tpm_uint32(response + kTpmResponseHeaderLength, &size); from_tpm_uint32(response + kTpmResponseHeaderLength, &size);
@ -291,7 +291,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
} }
uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
uint8_t *nvlocked) uint8_t *nvlocked)
{ {
TPM_PERMANENT_FLAGS pflags; TPM_PERMANENT_FLAGS pflags;
uint32_t result = tlcl_get_permanent_flags(&pflags); uint32_t result = tlcl_get_permanent_flags(&pflags);
@ -316,7 +316,7 @@ uint32_t tlcl_set_global_lock(void)
} }
uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest, uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
uint8_t *out_digest) uint8_t *out_digest)
{ {
struct s_tpm_extend_cmd cmd; struct s_tpm_extend_cmd cmd;
uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength]; uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];

View File

@ -1,136 +1,136 @@
/* This file is automatically generated */ /* This file is automatically generated */
const struct s_tpm_extend_cmd{ const struct s_tpm_extend_cmd{
uint8_t buffer[34]; uint8_t buffer[34];
uint16_t pcrNum; uint16_t pcrNum;
uint16_t inDigest; uint16_t inDigest;
} tpm_extend_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, }, } tpm_extend_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, },
10, 14, }; 10, 14, };
const struct s_tpm_get_random_cmd{ const struct s_tpm_get_random_cmd{
uint8_t buffer[14]; uint8_t buffer[14];
uint16_t bytesRequested; uint16_t bytesRequested;
} tpm_get_random_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, }, } tpm_get_random_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, },
10, }; 10, };
const struct s_tpm_getownership_cmd{ const struct s_tpm_getownership_cmd{
uint8_t buffer[22]; uint8_t buffer[22];
} tpm_getownership_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, }, } tpm_getownership_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, },
}; };
const struct s_tpm_getpermissions_cmd{ const struct s_tpm_getpermissions_cmd{
uint8_t buffer[22]; uint8_t buffer[22];
uint16_t index; uint16_t index;
} tpm_getpermissions_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, }, } tpm_getpermissions_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, },
18, }; 18, };
const struct s_tpm_getstclearflags_cmd{ const struct s_tpm_getstclearflags_cmd{
uint8_t buffer[22]; uint8_t buffer[22];
} tpm_getstclearflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, }, } tpm_getstclearflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, },
}; };
const struct s_tpm_getflags_cmd{ const struct s_tpm_getflags_cmd{
uint8_t buffer[22]; uint8_t buffer[22];
} tpm_getflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, }, } tpm_getflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, },
}; };
const struct s_tpm_physicalsetdeactivated_cmd{ const struct s_tpm_physicalsetdeactivated_cmd{
uint8_t buffer[11]; uint8_t buffer[11];
uint16_t deactivated; uint16_t deactivated;
} tpm_physicalsetdeactivated_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, }, } tpm_physicalsetdeactivated_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, },
10, }; 10, };
const struct s_tpm_physicalenable_cmd{ const struct s_tpm_physicalenable_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_physicalenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, }, } tpm_physicalenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, },
}; };
const struct s_tpm_physicaldisable_cmd{ const struct s_tpm_physicaldisable_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_physicaldisable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, }, } tpm_physicaldisable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, },
}; };
const struct s_tpm_forceclear_cmd{ const struct s_tpm_forceclear_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_forceclear_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, }, } tpm_forceclear_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, },
}; };
const struct s_tpm_readpubek_cmd{ const struct s_tpm_readpubek_cmd{
uint8_t buffer[30]; uint8_t buffer[30];
} tpm_readpubek_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, }, } tpm_readpubek_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, },
}; };
const struct s_tpm_continueselftest_cmd{ const struct s_tpm_continueselftest_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_continueselftest_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, }, } tpm_continueselftest_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, },
}; };
const struct s_tpm_selftestfull_cmd{ const struct s_tpm_selftestfull_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_selftestfull_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, }, } tpm_selftestfull_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, },
}; };
const struct s_tpm_resume_cmd{ const struct s_tpm_resume_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_resume_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, }, } tpm_resume_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, },
}; };
const struct s_tpm_savestate_cmd{ const struct s_tpm_savestate_cmd{
uint8_t buffer[10]; uint8_t buffer[10];
} tpm_savestate_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, }, } tpm_savestate_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, },
}; };
const struct s_tpm_startup_cmd{ const struct s_tpm_startup_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_startup_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, }, } tpm_startup_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, },
}; };
const struct s_tpm_finalizepp_cmd{ const struct s_tpm_finalizepp_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_finalizepp_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, }, } tpm_finalizepp_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, },
}; };
const struct s_tpm_pplock_cmd{ const struct s_tpm_pplock_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_pplock_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, }, } tpm_pplock_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, },
}; };
const struct s_tpm_ppenable_cmd{ const struct s_tpm_ppenable_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_ppenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, }, } tpm_ppenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, },
}; };
const struct s_tpm_ppassert_cmd{ const struct s_tpm_ppassert_cmd{
uint8_t buffer[12]; uint8_t buffer[12];
} tpm_ppassert_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, }, } tpm_ppassert_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, },
}; };
const struct s_tpm_pcr_read_cmd{ const struct s_tpm_pcr_read_cmd{
uint8_t buffer[14]; uint8_t buffer[14];
uint16_t pcrNum; uint16_t pcrNum;
} tpm_pcr_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15, }, } tpm_pcr_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15, },
10, }; 10, };
const struct s_tpm_nv_read_cmd{ const struct s_tpm_nv_read_cmd{
uint8_t buffer[22]; uint8_t buffer[22];
uint16_t index; uint16_t index;
uint16_t length; uint16_t length;
} tpm_nv_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, }, } tpm_nv_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, },
10, 18, }; 10, 18, };
const struct s_tpm_nv_write_cmd{ const struct s_tpm_nv_write_cmd{
uint8_t buffer[256]; uint8_t buffer[256];
uint16_t index; uint16_t index;
uint16_t length; uint16_t length;
uint16_t data; uint16_t data;
} tpm_nv_write_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, }, } tpm_nv_write_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, },
10, 18, 22, }; 10, 18, 22, };
const struct s_tpm_nv_definespace_cmd{ const struct s_tpm_nv_definespace_cmd{
uint8_t buffer[101]; uint8_t buffer[101];
uint16_t index; uint16_t index;
uint16_t perm; uint16_t perm;
uint16_t size; uint16_t size;
} tpm_nv_definespace_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x18, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x17, }, } tpm_nv_definespace_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x18, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x17, },
12, 70, 77, }; 12, 70, 77, };