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#pragma once
13
14#include <stdint.h>
15
16#include <sel4/sel4.h>
17#include <sel4test/test.h>
18#include <sel4utils/elf.h>
19
20#define TEST_PROCESS_CSPACE_SIZE_BITS 17
21/* Init data shared between sel4test-driver and the sel4test-tests app -- the
22 * sel4test-driver creates a shmem page to be shared between the driver and the
23 * test child processes, and uses this struct to pass the data in the shmem
24 * page.
25 *
26 * This file is symlinked from the sel4test-driver into the sel4test child
27 * process.
28 *
29 * all caps are in the sel4test-tests process' cspace */
30typedef struct {
31    /* page directory of the test process */
32    seL4_CPtr page_directory;
33    /* root cnode of the test process */
34    seL4_CPtr root_cnode;
35    /* tcb of the test process */
36    seL4_CPtr tcb;
37    /* the domain cap */
38    seL4_CPtr domain;
39    /* asid pool cap for the test process to use when creating new processes */
40    seL4_CPtr asid_pool;
41    seL4_CPtr asid_ctrl;
42#ifdef CONFIG_IOMMU
43    seL4_CPtr io_space;
44#endif /* CONFIG_IOMMU */
45#ifdef CONFIG_TK1_SMMU
46    seL4_SlotRegion io_space_caps;
47#endif
48
49    /* copied (by sel4test-driver) notification cap that tests can wait
50     * on when requesting a time service from sel4test-driver (e.g. sleep),
51     * and expecting a signal and/or notification.
52     */
53    seL4_CPtr timer_ntfn;
54
55    /* size of the test processes cspace */
56    seL4_Word cspace_size_bits;
57    /* range of free slots in the cspace */
58    seL4_SlotRegion free_slots;
59
60    /* range of untyped memory in the cspace */
61    seL4_SlotRegion untypeds;
62    /* size of untyped that each untyped cap corresponds to
63     * (size of the cap at untypeds.start is untyped_size_bits_lits[0]) */
64    uint8_t untyped_size_bits_list[CONFIG_MAX_NUM_BOOTINFO_UNTYPED_CAPS];
65    /* name of the test to run */
66    char name[TEST_NAME_MAX];
67    /* priority the test process is running at */
68    int priority;
69
70    /* sched control cap */
71    seL4_CPtr sched_ctrl;
72
73    /* device frame cap */
74    seL4_CPtr device_frame_cap;
75
76    /* List of elf regions in the test process image, this
77     * is provided so the test process can launch copies of itself.
78     *
79     * Note: copies should not rely on state from the current process
80     * or the image. Only use copies to run code functions, pass all
81     * required state as arguments. */
82    sel4utils_elf_region_t elf_regions[MAX_REGIONS];
83
84    /* the number of elf regions */
85    int num_elf_regions;
86
87    /* the number of pages in the stack */
88    int stack_pages;
89
90    /* address of the stack */
91    void *stack;
92
93    /* freq of the tsc (for x86) */
94    uint32_t tsc_freq;
95
96    /* number of available cores */
97    seL4_Word cores;
98
99} test_init_data_t;
100
101compile_time_assert(init_data_fits_in_ipc_buffer, sizeof(test_init_data_t) < PAGE_SIZE_4K);
102