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#pragma once 14#include <autoconf.h> 15#include <rumprun/gen_config.h> 16#include <vka/vka.h> 17#include <vspace/vspace.h> 18#include <sel4utils/thread.h> 19#include <sel4utils/process.h> 20#include <sel4utils/mapping.h> 21#include <serial_server/client.h> 22#include <sync/bin_sem.h> 23 24#include <sel4platsupport/timer.h> 25#include <platsupport/timer.h> 26 27#include <sel4/kernel.h> 28#include <sel4platsupport/pmem.h> 29#include <rumprun/custom_simple.h> 30#include <sel4runtime.h> 31 32struct env { 33 /* An initialised vka that may be used by the test. */ 34 vka_t vka; 35 /* virtual memory management interface */ 36 vspace_t vspace; 37 /* initialised timer */ 38 ltimer_t ltimer; 39 size_t rump_mapping_page_size_bits; 40 seL4_Word rump_mapping_page_type; 41 /* abstract interface over application init */ 42 simple_t simple; 43 custom_simple_t custom_simple; 44 45 vka_object_t pci_notification; 46 vka_object_t spl_notification; 47 sel4utils_thread_t pci_thread; 48 sel4utils_thread_t stdio_thread; 49 50 sync_bin_sem_t spl_semaphore; 51 /* IO Ops */ 52 ps_io_ops_t io_ops; 53 /* Irq Handler caps for PCI devices */ 54 seL4_CPtr caps[BMK_MAXINTR]; 55 /* Thread local storage base ptr */ 56 void *tls_base_ptr; 57 /* Rumprun cmdline */ 58 // char cmdline[4096]; 59 /* Priority level for disabling interrupt thread */ 60 volatile int spldepth; 61 /* Guard from preventing interrupt thread from disabling itsel4 */ 62 volatile int mask_the_mask; 63 /* The PCI interrupt handler thread should wake up the runner thread */ 64 volatile bool should_wakeup; 65 66}; 67typedef struct env *env_t; 68 69extern struct env env; 70 71static inline void arch_cpu_sched_settls(unsigned long btcb_tp) 72{ 73 sel4runtime_set_tls_base(btcb_tp); 74} 75 76int arch_init_clocks(env_t env); 77bmk_time_t arch_cpu_clock_monotonic(void); 78bmk_time_t arch_cpu_clock_epochoffset(void); 79 80void simple_init_rumprun(custom_simple_t *custom_simple, seL4_CPtr endpoint); 81