1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#ifndef BENCHMARK_TRACK_TYPES_H
14#define BENCHMARK_TRACK_TYPES_H
15
16#ifdef HAVE_AUTOCONF
17#include <autoconf.h>
18#endif
19
20#if (defined CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || defined CONFIG_DEBUG_BUILD)
21
22/* the following code can be used at any point in the kernel
23 * to determine detail about the kernel entry point */
24typedef enum {
25    Entry_Interrupt,
26    Entry_UnknownSyscall,
27    Entry_UserLevelFault,
28    Entry_DebugFault,
29    Entry_VMFault,
30    Entry_Syscall,
31    Entry_UnimplementedDevice,
32#ifdef CONFIG_ARCH_ARM
33    Entry_VCPUFault,
34#endif
35#ifdef CONFIG_ARCH_X86
36    Entry_VMExit,
37#endif
38} entry_type_t;
39
40/**
41 * @brief Kernel entry logging
42 *
43 * Encapsulates useful info about the cause of the kernel entry
44 */
45typedef struct PACKED kernel_entry {
46    seL4_Word path: 3;
47    union {
48        struct {
49            seL4_Word word: 29;
50        };
51        /* Tracked kernel entry info filled from outside this file */
52        struct {
53            seL4_Word syscall_no: 4;
54            seL4_Word cap_type: 5;
55            seL4_Word is_fastpath: 1;
56            seL4_Word invocation_tag: 19;
57        };
58    };
59} kernel_entry_t;
60
61#endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || DEBUG */
62
63#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
64
65typedef struct benchmark_syscall_log_entry {
66    uint64_t  start_time;
67    uint32_t  duration;
68    kernel_entry_t entry;
69} benchmark_track_kernel_entry_t;
70
71#endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES || CONFIG_DEBUG_BUILD */
72
73#endif /* BENCHMARK_TRACK_TYPES_H */
74