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