diff options
Diffstat (limited to 'driver/gator_annotate_kernel.c')
-rw-r--r-- | driver/gator_annotate_kernel.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/driver/gator_annotate_kernel.c b/driver/gator_annotate_kernel.c new file mode 100644 index 0000000..4f690e8 --- /dev/null +++ b/driver/gator_annotate_kernel.c | |||
@@ -0,0 +1,91 @@ | |||
1 | /** | ||
2 | * Copyright (C) ARM Limited 2011. 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 | */ | ||
9 | |||
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 | } | ||
24 | |||
25 | // String annotation | ||
26 | void gator_annotate(char* string) | ||
27 | { | ||
28 | printk(KERN_ERR "module: %s\n", string); | ||
29 | kannotate_write(string, strlen(string) + 1); | ||
30 | } | ||
31 | EXPORT_SYMBOL(gator_annotate); | ||
32 | |||
33 | // String annotation with color | ||
34 | void gator_annotate_color(int color, char* string) | ||
35 | { | ||
36 | kannotate_write((char*)&color, sizeof(color)); | ||
37 | kannotate_write(string, strlen(string) + 1); | ||
38 | } | ||
39 | EXPORT_SYMBOL(gator_annotate_color); | ||
40 | |||
41 | // Terminate an annotation | ||
42 | void gator_annotate_end(void) | ||
43 | { | ||
44 | char nul = 0; | ||
45 | kannotate_write(&nul, sizeof(nul)); | ||
46 | } | ||
47 | EXPORT_SYMBOL(gator_annotate_end); | ||
48 | |||
49 | // Image annotation with optional string | ||
50 | void gator_annotate_visual(char* data, unsigned int length, char* string) | ||
51 | { | ||
52 | long long visual_annotation = 0x011c | (strlen(string) << 16) | ((long long)length << 32); | ||
53 | kannotate_write((char*)&visual_annotation, 8); | ||
54 | kannotate_write(string, strlen(string)); | ||
55 | kannotate_write(data, length); | ||
56 | } | ||
57 | EXPORT_SYMBOL(gator_annotate_visual); | ||
58 | |||
59 | // Marker annotation | ||
60 | void gator_annotate_marker(void) | ||
61 | { | ||
62 | int marker_annotation = 0x00021c; | ||
63 | kannotate_write((char*)&marker_annotation, 3); | ||
64 | } | ||
65 | EXPORT_SYMBOL(gator_annotate_marker); | ||
66 | |||
67 | // Marker annotation with a string | ||
68 | void gator_annotate_marker_str(char* string) | ||
69 | { | ||
70 | int marker_annotation = 0x021c; | ||
71 | kannotate_write((char*)&marker_annotation, 2); | ||
72 | kannotate_write(string, strlen(string) + 1); | ||
73 | } | ||
74 | EXPORT_SYMBOL(gator_annotate_marker_str); | ||
75 | |||
76 | // Marker annotation with a color | ||
77 | void gator_annotate_marker_color(int color) | ||
78 | { | ||
79 | long long marker_annotation = (0x021c | ((long long)color << 16)) & 0x0000ffffffffffffLL; | ||
80 | kannotate_write((char*)&marker_annotation, 7); | ||
81 | } | ||
82 | EXPORT_SYMBOL(gator_annotate_marker_color); | ||
83 | |||
84 | // Marker annotationw ith a string and color | ||
85 | void gator_annotate_marker_color_str(int color, char* string) | ||
86 | { | ||
87 | long long marker_annotation = 0x021c | ((long long)color << 16); | ||
88 | kannotate_write((char*)&marker_annotation, 6); | ||
89 | kannotate_write(string, strlen(string) + 1); | ||
90 | } | ||
91 | EXPORT_SYMBOL(gator_annotate_marker_color_str); | ||