2 * Copyright (C) ARM Limited 2010-2014. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
10 static void gator_buffer_write_packed_int(int cpu, int buftype, int x)
12 uint32_t write = per_cpu(gator_buffer_write, cpu)[buftype];
13 uint32_t mask = gator_buffer_mask[buftype];
14 char *buffer = per_cpu(gator_buffer, cpu)[buftype];
19 /* low order 7 bits of x */
24 if ((x == 0 && (b & 0x40) == 0) || (x == -1 && (b & 0x40) != 0))
29 buffer[(write + packedBytes) & mask] = b;
33 per_cpu(gator_buffer_write, cpu)[buftype] = (write + packedBytes) & mask;
36 static void gator_buffer_write_packed_int64(int cpu, int buftype, long long x)
38 uint32_t write = per_cpu(gator_buffer_write, cpu)[buftype];
39 uint32_t mask = gator_buffer_mask[buftype];
40 char *buffer = per_cpu(gator_buffer, cpu)[buftype];
45 /* low order 7 bits of x */
50 if ((x == 0 && (b & 0x40) == 0) || (x == -1 && (b & 0x40) != 0))
55 buffer[(write + packedBytes) & mask] = b;
59 per_cpu(gator_buffer_write, cpu)[buftype] = (write + packedBytes) & mask;
62 static void gator_buffer_write_bytes(int cpu, int buftype, const char *x, int len)
65 u32 write = per_cpu(gator_buffer_write, cpu)[buftype];
66 u32 mask = gator_buffer_mask[buftype];
67 char *buffer = per_cpu(gator_buffer, cpu)[buftype];
69 for (i = 0; i < len; i++) {
71 write = (write + 1) & mask;
74 per_cpu(gator_buffer_write, cpu)[buftype] = write;
77 static void gator_buffer_write_string(int cpu, int buftype, const char *x)
81 gator_buffer_write_packed_int(cpu, buftype, len);
82 gator_buffer_write_bytes(cpu, buftype, x, len);