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 #define TBUF_SZ (1024 * 1024)
25 
26 struct cpu_thread;
27 
28 /* Here's one we prepared earlier. */
29 void init_boot_tracebuf(struct cpu_thread *boot_cpu);
30 
31 struct trace_info {
32 	/* Lock for writers. */
33 	struct lock lock;
34 	/* Exposed to kernel. */
35 	struct tracebuf tb;
36 };
37 
38 /* Allocate trace buffers once we know memory topology */
39 void init_trace_buffers(void);
40 
41 /* This will fill in timestamp and cpu; you must do type and len. */
42 void trace_add(union trace *trace, u8 type, u16 len);
43 
44 /* Put trace node into dt. */
45 void trace_add_node(void);
46 #endif /* __TRACE_H */
47