diff options
author | Alex Shi <alex.shi@linaro.org> | 2013-10-15 10:35:02 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2013-10-15 10:35:02 +0800 |
commit | b660011c5c1066762b8d29e238a3a478b6f02bf4 (patch) | |
tree | a04058e9f6fcbdce048bbb662de8fb74972dfa92 /drivers/gator/gator_pack.c | |
parent | f85b6e7b8e12028219057306eaf24c8d77a5c0c3 (diff) | |
parent | 01239d6842a2e2653b7b42736cf2c10b69d0face (diff) |
Merge remote-tracking branch 'arm-landing/lsk-3.10-gator' into linux-linaro-lsk-android-testlsk-android-13.10
Diffstat (limited to 'drivers/gator/gator_pack.c')
-rw-r--r-- | drivers/gator/gator_pack.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/gator/gator_pack.c b/drivers/gator/gator_pack.c new file mode 100644 index 00000000000..2c082f283ad --- /dev/null +++ b/drivers/gator/gator_pack.c @@ -0,0 +1,58 @@ +/** + * Copyright (C) ARM Limited 2010-2013. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +static void gator_buffer_write_packed_int(int cpu, int buftype, int x) +{ + uint32_t write = per_cpu(gator_buffer_write, cpu)[buftype]; + uint32_t mask = gator_buffer_mask[buftype]; + char *buffer = per_cpu(gator_buffer, cpu)[buftype]; + int packedBytes = 0; + int more = true; + while (more) { + // low order 7 bits of x + char b = x & 0x7f; + x >>= 7; + + if ((x == 0 && (b & 0x40) == 0) || (x == -1 && (b & 0x40) != 0)) { + more = false; + } else { + b |= 0x80; + } + + buffer[(write + packedBytes) & mask] = b; + packedBytes++; + } + + per_cpu(gator_buffer_write, cpu)[buftype] = (write + packedBytes) & mask; +} + +static void gator_buffer_write_packed_int64(int cpu, int buftype, long long x) +{ + uint32_t write = per_cpu(gator_buffer_write, cpu)[buftype]; + uint32_t mask = gator_buffer_mask[buftype]; + char *buffer = per_cpu(gator_buffer, cpu)[buftype]; + int packedBytes = 0; + int more = true; + while (more) { + // low order 7 bits of x + char b = x & 0x7f; + x >>= 7; + + if ((x == 0 && (b & 0x40) == 0) || (x == -1 && (b & 0x40) != 0)) { + more = false; + } else { + b |= 0x80; + } + + buffer[(write + packedBytes) & mask] = b; + packedBytes++; + } + + per_cpu(gator_buffer_write, cpu)[buftype] = (write + packedBytes) & mask; +} |