blob: a528d646ea745e7505cdf1cfbf6aded7aa74a94b [file] [log] [blame]
Hesham Almatary181e7362016-06-08 12:12:20 +10001/*
Anna Lyons92143412017-06-05 08:29:55 +10002 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
Hesham Almatary181e7362016-06-08 12:12:20 +10005 *
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 *
Anna Lyons92143412017-06-05 08:29:55 +100010 * @TAG(DATA61_BSD)
Hesham Almatary181e7362016-06-08 12:12:20 +100011 */
12#pragma once
13#include <autoconf.h>
14#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
15
16#include <stdio.h>
17#include <sel4/types.h>
18#include <sel4/benchmark_track_types.h>
19
20/* Print out a summary of what has been tracked */
21static inline void
Hesham Almataryaf3391d2016-08-19 15:59:44 +100022seL4_BenchmarkTrackDumpSummary(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
Hesham Almatary181e7362016-06-08 12:12:20 +100023{
Hesham Almataryaf3391d2016-08-19 15:59:44 +100024 seL4_Word index = 0;
Hesham Almatary181e7362016-06-08 12:12:20 +100025 seL4_Word syscall_entries = 0;
26 seL4_Word interrupt_entries = 0;
27 seL4_Word userlevelfault_entries = 0;
28 seL4_Word vmfault_entries = 0;
29
30 /* Default driver to use for output now is serial.
31 * Change this to use other drivers than serial, i.e ethernet
32 */
33 FILE *fd = stdout;
34
Hesham Almatary33bc1752016-08-25 15:59:38 +100035 while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) {
Hesham Almataryaf3391d2016-08-19 15:59:44 +100036 if (logBuffer[index].entry.path == Entry_Syscall) {
37 syscall_entries++;
38 } else if (logBuffer[index].entry.path == Entry_Interrupt) {
39 interrupt_entries++;
40 } else if (logBuffer[index].entry.path == Entry_UserLevelFault) {
41 userlevelfault_entries++;
42 } else if (logBuffer[index].entry.path == Entry_VMFault) {
43 vmfault_entries++;
Hesham Almatary181e7362016-06-08 12:12:20 +100044 }
Hesham Almataryaf3391d2016-08-19 15:59:44 +100045 index++;
46 }
Hesham Almatary181e7362016-06-08 12:12:20 +100047
48 fprintf(fd, "Number of system call invocations %d\n", syscall_entries);
49 fprintf(fd, "Number of interrupt invocations %d\n", interrupt_entries);
50 fprintf(fd, "Number of user-level faults %d\n", userlevelfault_entries);
51 fprintf(fd, "Number of VM faults %d\n", vmfault_entries);
Hesham Almatary181e7362016-06-08 12:12:20 +100052}
53
54/* Print out logged system call invocations */
55static inline void
Hesham Almataryaf3391d2016-08-19 15:59:44 +100056seL4_BenchmarkTrackDumpFullSyscallLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
Hesham Almatary181e7362016-06-08 12:12:20 +100057{
Hesham Almataryaf3391d2016-08-19 15:59:44 +100058 seL4_Word index = 0;
Hesham Almatary181e7362016-06-08 12:12:20 +100059 FILE *fd = stdout;
60
Hesham Almatary181e7362016-06-08 12:12:20 +100061 /* Get details of each system call invocation */
62 fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
63 fprintf(fd, "| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s|\n",
64 "Log ID", "System Call ID", "Start Time", "Duration", "Capability Type",
65 "Invocation Tag", "Fastpath?");
66 fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
67
Hesham Almatary33bc1752016-08-25 15:59:38 +100068 while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) {
Hesham Almataryaf3391d2016-08-19 15:59:44 +100069 if (logBuffer[index].entry.path == Entry_Syscall) {
70 fprintf(fd, "| %-15d| %-15d| %-15llu| %-15d| %-15d| %-15d| %-15d|\n",
71 index,
72 logBuffer[index].entry.syscall_no,
73 (uint64_t ) logBuffer[index].start_time,
74 logBuffer[index].duration,
75 logBuffer[index].entry.cap_type,
76 logBuffer[index].entry.invocation_tag,
77 logBuffer[index].entry.is_fastpath);
Hesham Almatary181e7362016-06-08 12:12:20 +100078 }
Hesham Almataryaf3391d2016-08-19 15:59:44 +100079 index++;
80 }
Hesham Almatary181e7362016-06-08 12:12:20 +100081}
82
83/* Print out logged interrupt invocations */
84static inline void
Hesham Almataryaf3391d2016-08-19 15:59:44 +100085seL4_BenchmarkTrackDumpFullInterruptLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
Hesham Almatary181e7362016-06-08 12:12:20 +100086{
Hesham Almataryaf3391d2016-08-19 15:59:44 +100087 seL4_Word index = 0;
Hesham Almatary181e7362016-06-08 12:12:20 +100088 FILE *fd = stdout;
89
Hesham Almatary181e7362016-06-08 12:12:20 +100090 /* Get details of each invocation */
91 fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
92 fprintf(fd, "| %-15s| %-15s| %-15s| %-15s|\n", "Log ID", "IRQ", "Start Time",
93 "Duration");
94 fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
95
Hesham Almatary33bc1752016-08-25 15:59:38 +100096 while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) {
Hesham Almataryaf3391d2016-08-19 15:59:44 +100097 if (logBuffer[index].entry.path == Entry_Interrupt) {
98 fprintf(fd, "| %-15d| %-15d| %-15llu| %-15d|\n", \
99 index,
100 logBuffer[index].entry.word,
101 logBuffer[index].start_time,
102 logBuffer[index].duration);
Hesham Almatary181e7362016-06-08 12:12:20 +1000103 }
Hesham Almataryaf3391d2016-08-19 15:59:44 +1000104 index++;
105 }
Hesham Almatary181e7362016-06-08 12:12:20 +1000106}
107#endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES */