1#ifndef    _BF_SUPPORT_SF__H
2#define    _BF_SUPPORT_SF__H
3
4#include <barrelfish/barrelfish.h>
5#include <stdio.h>
6
7#include <sys/endian.h>  // to find out endianess of machine
8#include <sys/times.h>
9#include <string.h>  // for memcpy, memset
10
11#include "error_list.h"
12
13// FIXME: added for compilation purpose.  Replace by using appropriate
14// Barrelfish constants for them.
15#define FALSE (0)
16#define TRUE (1)
17
18// FIXME: may be I should replace all boolean_t with bool
19typedef bool boolean_t;
20typedef char *caddr_t;
21
22// **********************************************************
23// bus related data-types
24// **********************************************************
25
26typedef int bus_space_tag_t;
27typedef unsigned long bus_space_handle_t;
28typedef unsigned long bus_size_t;
29typedef unsigned long bus_addr_t;
30
31uint32_t bus_space_read_4(bus_space_tag_t bst, bus_space_handle_t bsh,
32        bus_size_t ofs);
33
34void bus_space_write_4(bus_space_tag_t bst, bus_space_handle_t bsh,
35        bus_size_t ofs, uint8_t val);
36
37// **********************************************************
38// basic locking data-structure
39// **********************************************************
40
41struct mtx {
42    int state; // 0: unlocked, 1: locked
43};
44
45void mtx_lock(struct mtx *mp);
46void mtx_unlock(struct mtx *mp);
47
48// *****************************************************************
49// ASSERT
50// *****************************************************************
51
52#define panic(x...)    do {                                             \
53                            printf("panic:sf: " x);                     \
54                            abort();                                    \
55                    } while(0)
56
57//#define    myKASRT(_exp, msg) do {
58#define    KASSERT(_exp, msg) do {                                      \
59        if (!(_exp)) {                                                  \
60            printf(msg);                                                \
61            printf("\n");                                               \
62            abort();                                                    \
63        }                                                               \
64    } while (0)
65
66
67#define    EFSYS_ASSERT(_exp) do {                                      \
68    if (!(_exp))                                                        \
69        panic(#_exp);                                                   \
70    } while (0)
71
72#define EFSYS_ASSERT3(_x, _op, _y, _t) do {                             \
73    const _t __x = (_t)(_x);                                            \
74    const _t __y = (_t)(_y);                                            \
75    if (!(__x _op __y))                                                 \
76          panic("assertion failed at %s:%u", __FILE__, __LINE__);       \
77    } while(0)
78
79#define DELAY(_us)      do {                                            \
80         (void) (_us);                                                  \
81        assert(!"NYI");                                                 \
82    } while(0)
83
84
85#endif //   _BF_SUPPORT_SF__H
86