1 /*
2  * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #pragma once
8 
9 #include <autoconf.h>
10 #include <stdint.h>
11 
12 #if (defined CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || defined CONFIG_DEBUG_BUILD)
13 
14 /* the following code can be used at any point in the kernel
15  * to determine detail about the kernel entry point */
16 typedef enum {
17     Entry_Interrupt,
18     Entry_UnknownSyscall,
19     Entry_UserLevelFault,
20     Entry_DebugFault,
21     Entry_VMFault,
22     Entry_Syscall,
23     Entry_UnimplementedDevice,
24 #ifdef CONFIG_ARCH_ARM
25     Entry_VCPUFault,
26 #endif
27 #ifdef CONFIG_ARCH_X86
28     Entry_VMExit,
29 #endif
30 } entry_type_t;
31 
32 /**
33  * @brief Kernel entry logging
34  *
35  * Encapsulates useful info about the cause of the kernel entry
36  */
37 typedef struct SEL4_PACKED kernel_entry {
38     seL4_Word path: 3;
39     union {
40         struct {
41             seL4_Word core: 3;
42             seL4_Word word: 26;
43         };
44         /* Tracked kernel entry info filled from outside this file */
45         struct {
46             seL4_Word syscall_no: 4;
47             seL4_Word cap_type: 5;
48             seL4_Word is_fastpath: 1;
49             seL4_Word invocation_tag: 19;
50         };
51     };
52 } kernel_entry_t;
53 
54 #endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || DEBUG */
55 
56 #ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
57 
58 typedef struct benchmark_syscall_log_entry {
59     uint64_t  start_time;
60     uint32_t  duration;
61     kernel_entry_t entry;
62 } benchmark_track_kernel_entry_t;
63 
64 #endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || CONFIG_DEBUG_BUILD */
65