]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/arm-ds5-gator.git/blob - driver/gator_annotate_kernel.c
gator-daemon: Fix sequence-point compile error
[android-sdk/arm-ds5-gator.git] / driver / gator_annotate_kernel.c
1 /**
2  * Copyright (C) ARM Limited 2012. All rights reserved.
3  *
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.
7  *
8  */
10 static void kannotate_write(char* ptr, unsigned int size)
11 {
12         int retval;
13         int pos = 0;
14         loff_t offset = 0;
15         while (pos < size) {
16                  retval = annotate_write(NULL, &ptr[pos], size - pos, &offset);
17                  if (retval < 0) {
18                          printk(KERN_WARNING "gator: kannotate_write failed with return value %d\n", retval);
19                          return;
20                  }
21                  pos += retval;
22         }
23 }
25 // String annotation
26 void gator_annotate(char* string)
27 {
28         kannotate_write(string, strlen(string) + 1);
29 }
30 EXPORT_SYMBOL(gator_annotate);
32 // String annotation with color
33 void gator_annotate_color(int color, char* string)
34 {
35         kannotate_write((char*)&color, sizeof(color));
36         kannotate_write(string, strlen(string) + 1);
37 }
38 EXPORT_SYMBOL(gator_annotate_color);
40 // Terminate an annotation
41 void gator_annotate_end(void)
42 {
43         char nul = 0;
44         kannotate_write(&nul, sizeof(nul));
45 }
46 EXPORT_SYMBOL(gator_annotate_end);
48 // Image annotation with optional string
49 void gator_annotate_visual(char* data, unsigned int length, char* string)
50 {
51         long long visual_annotation = 0x011c | (strlen(string) << 16) | ((long long)length << 32);
52         kannotate_write((char*)&visual_annotation, 8);
53         kannotate_write(string, strlen(string));
54         kannotate_write(data, length);
55 }
56 EXPORT_SYMBOL(gator_annotate_visual);
58 // Marker annotation
59 void gator_annotate_marker(void)
60 {
61         int marker_annotation = 0x00021c;
62         kannotate_write((char*)&marker_annotation, 3);
63 }
64 EXPORT_SYMBOL(gator_annotate_marker);
66 // Marker annotation with a string
67 void gator_annotate_marker_str(char* string)
68 {
69         int marker_annotation = 0x021c;
70         kannotate_write((char*)&marker_annotation, 2);
71         kannotate_write(string, strlen(string) + 1);
72 }
73 EXPORT_SYMBOL(gator_annotate_marker_str);
75 // Marker annotation with a color
76 void gator_annotate_marker_color(int color)
77 {
78         long long marker_annotation = (0x021c | ((long long)color << 16)) & 0x0000ffffffffffffLL;
79         kannotate_write((char*)&marker_annotation, 7);
80 }
81 EXPORT_SYMBOL(gator_annotate_marker_color);
83 // Marker annotationw ith a string and color
84 void gator_annotate_marker_color_str(int color, char* string)
85 {
86         long long marker_annotation = 0x021c | ((long long)color << 16);
87         kannotate_write((char*)&marker_annotation, 6);
88         kannotate_write(string, strlen(string) + 1);
89 }
90 EXPORT_SYMBOL(gator_annotate_marker_color_str);