1/*
2 * Copyright 2016, 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(D61_BSD)
11 */
12
13#ifndef _TIMER_SERVER_STATE_H_
14#define _TIMER_SERVER_STATE_H_
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <stdint.h>
19#include <stdbool.h>
20#include <assert.h>
21#include <sel4/sel4.h>
22#include <refos/vmlayout.h>
23#include <refos-rpc/rpc.h>
24
25#include <platsupport/chardev.h>
26#include <platsupport/serial.h>
27#include "device_timer.h"
28#include "badge.h"
29
30#include <data_struct/cvector.h>
31#include <refos-util/serv_connect.h>
32#include <refos-util/serv_common.h>
33#include <refos-util/cspace.h>
34#include <refos-util/device_io.h>
35#include <refos-util/device_irq.h>
36#include <refos-rpc/data_client.h>
37#include <refos-rpc/data_client_helper.h>
38#include <refos/refos.h>
39
40/*! @file
41    @brief timer server global state & helper functions. */
42
43// Debug printing.
44#include <refos-util/dprintf.h>
45
46#ifndef CONFIG_REFOS_DEBUG
47    #define printf(x,...)
48#endif /* CONFIG_REFOS_DEBUG */
49
50#define TIMESERV_MMAP_REGION_SIZE 0x64000
51#define TIMESERV_MOUNTPOINT "dev_timer"
52#define TIMESERV_CLIENT_MAGIC 0xEE340912
53
54/*! @brief timer server global state. */
55struct timeserv_state {
56    srv_common_t commonState;
57    dev_irq_state_t irqState;
58
59    dev_io_ops_t devIO;
60    struct device_timer_state devTimer;
61    seL4_CPtr timerBadgeEP;
62};
63
64extern struct timeserv_state timeServ;
65extern srv_common_t *timeServCommon;
66
67/*! @brief Initialise timer server state. */
68void timeserv_init(void);
69
70#endif /* _TIMER_SERVER_STATE_H_ */
71