aboutsummaryrefslogtreecommitdiff
path: root/driver/gator_annotate_kernel.c
diff options
context:
space:
mode:
authorDrew Richardson <drew.richardson@arm.com>2012-10-13 12:00:00 -0700
committerDrew Richardson <drew.richardson@arm.com>2014-12-19 15:31:23 -0800
commitb04e8aefeed42f23955e88c7aa1611e49bdf5909 (patch)
treeeeee0f97880889c93457dfe96bdc96e487864506 /driver/gator_annotate_kernel.c
parent5f9955b9c65967a7a62f7860295d8ac187c9ec11 (diff)
gator: Version 5.125.12
Signed-off-by: Drew Richardson <drew.richardson@arm.com>
Diffstat (limited to 'driver/gator_annotate_kernel.c')
-rw-r--r--driver/gator_annotate_kernel.c89
1 files changed, 58 insertions, 31 deletions
diff --git a/driver/gator_annotate_kernel.c b/driver/gator_annotate_kernel.c
index ffab087..bc68fa8 100644
--- a/driver/gator_annotate_kernel.c
+++ b/driver/gator_annotate_kernel.c
@@ -7,50 +7,83 @@
*
*/
-static void kannotate_write(char* ptr, unsigned int size)
+#define ESCAPE_CODE 0x1c
+#define STRING_ANNOTATION 0x03
+#define VISUAL_ANNOTATION 0x04
+#define MARKER_ANNOTATION 0x05
+
+static void kannotate_write(const char* ptr, unsigned int size)
{
int retval;
int pos = 0;
loff_t offset = 0;
while (pos < size) {
- retval = annotate_write(NULL, &ptr[pos], size - pos, &offset);
- if (retval < 0) {
- printk(KERN_WARNING "gator: kannotate_write failed with return value %d\n", retval);
- return;
- }
- pos += retval;
+ retval = annotate_write(NULL, &ptr[pos], size - pos, &offset);
+ if (retval < 0) {
+ printk(KERN_WARNING "gator: kannotate_write failed with return value %d\n", retval);
+ return;
+ }
+ pos += retval;
}
}
+static void gator_annotate_code(char code)
+{
+ int header = ESCAPE_CODE | (code << 8);
+ kannotate_write((char*)&header, sizeof(header));
+}
+
+static void gator_annotate_code_str(char code, const char* string)
+{
+ int str_size = strlen(string) & 0xffff;
+ int header = ESCAPE_CODE | (code << 8) | (str_size << 16);
+ kannotate_write((char*)&header, sizeof(header));
+ kannotate_write(string, str_size);
+}
+
+static void gator_annotate_code_color(char code, int color)
+{
+ long long header = (ESCAPE_CODE | (code << 8) | 0x00040000 | ((long long)color << 32));
+ kannotate_write((char*)&header, sizeof(header));
+}
+
+static void gator_annotate_code_color_str(char code, int color, const char* string)
+{
+ int str_size = (strlen(string) + 4) & 0xffff;
+ long long header = ESCAPE_CODE | (code << 8) | (str_size << 16) | ((long long)color << 32);
+ kannotate_write((char*)&header, sizeof(header));
+ kannotate_write(string, str_size - 4);
+}
+
// String annotation
-void gator_annotate(char* string)
+void gator_annotate(const char* string)
{
- kannotate_write(string, strlen(string) + 1);
+ gator_annotate_code_str(STRING_ANNOTATION, string);
}
EXPORT_SYMBOL(gator_annotate);
// String annotation with color
-void gator_annotate_color(int color, char* string)
+void gator_annotate_color(int color, const char* string)
{
- kannotate_write((char*)&color, sizeof(color));
- kannotate_write(string, strlen(string) + 1);
+ gator_annotate_code_color_str(STRING_ANNOTATION, color, string);
}
EXPORT_SYMBOL(gator_annotate_color);
// Terminate an annotation
void gator_annotate_end(void)
{
- char nul = 0;
- kannotate_write(&nul, sizeof(nul));
+ gator_annotate_code(STRING_ANNOTATION);
}
EXPORT_SYMBOL(gator_annotate_end);
// Image annotation with optional string
-void gator_annotate_visual(char* data, unsigned int length, char* string)
+void gator_annotate_visual(const char* data, unsigned int length, const char* string)
{
- long long visual_annotation = 0x011c | (strlen(string) << 16) | ((long long)length << 32);
- kannotate_write((char*)&visual_annotation, 8);
- kannotate_write(string, strlen(string));
+ int str_size = strlen(string) & 0xffff;
+ int visual_annotation = ESCAPE_CODE | (VISUAL_ANNOTATION << 8) | (str_size << 16);
+ kannotate_write((char*)&visual_annotation, sizeof(visual_annotation));
+ kannotate_write(string, str_size);
+ kannotate_write((char*)&length, sizeof(length));
kannotate_write(data, length);
}
EXPORT_SYMBOL(gator_annotate_visual);
@@ -58,33 +91,27 @@ EXPORT_SYMBOL(gator_annotate_visual);
// Marker annotation
void gator_annotate_marker(void)
{
- int marker_annotation = 0x00021c;
- kannotate_write((char*)&marker_annotation, 3);
+ gator_annotate_code(MARKER_ANNOTATION);
}
EXPORT_SYMBOL(gator_annotate_marker);
// Marker annotation with a string
-void gator_annotate_marker_str(char* string)
+void gator_annotate_marker_str(const char* string)
{
- int marker_annotation = 0x021c;
- kannotate_write((char*)&marker_annotation, 2);
- kannotate_write(string, strlen(string) + 1);
+ gator_annotate_code_str(MARKER_ANNOTATION, string);
}
EXPORT_SYMBOL(gator_annotate_marker_str);
// Marker annotation with a color
void gator_annotate_marker_color(int color)
{
- long long marker_annotation = (0x021c | ((long long)color << 16)) & 0x0000ffffffffffffLL;
- kannotate_write((char*)&marker_annotation, 7);
+ gator_annotate_code_color(MARKER_ANNOTATION, color);
}
EXPORT_SYMBOL(gator_annotate_marker_color);
-// Marker annotationw ith a string and color
-void gator_annotate_marker_color_str(int color, char* string)
+// Marker annotation with a string and color
+void gator_annotate_marker_color_str(int color, const char* string)
{
- long long marker_annotation = 0x021c | ((long long)color << 16);
- kannotate_write((char*)&marker_annotation, 6);
- kannotate_write(string, strlen(string) + 1);
+ gator_annotate_code_color_str(MARKER_ANNOTATION, color, string);
}
EXPORT_SYMBOL(gator_annotate_marker_color_str);