1 /* Copyright 2013-2014 IBM Corp.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * 	http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __TRACE_H
18 #define __TRACE_H
19 #include <ccan/short_types/short_types.h>
20 #include <stddef.h>
21 #include <lock.h>
22 #include <trace_types.h>
23 
24 
25 struct cpu_thread;
26 
27 /* Here's one we prepared earlier. */
28 void init_boot_tracebuf(struct cpu_thread *boot_cpu);
29 
30 struct trace_info {
31 	/* Lock for writers. Exposed to kernel. */
32 	struct lock lock;
33 	/* Exposed to kernel. */
34 	struct tracebuf tb;
35 };
36 
37 #define TBUF_SZ ((1024 * 1024) - sizeof(struct trace_info) - sizeof(union trace))
38 
39 /* Allocate trace buffers once we know memory topology */
40 void init_trace_buffers(void);
41 
42 /* This will fill in timestamp and cpu; you must do type and len. */
43 void trace_add(union trace *trace, u8 type, u16 len);
44 
45 /* Put trace node into dt. */
46 void trace_add_node(void);
47 #endif /* __TRACE_H */
48