1/**
2 * \file
3 * \brief RCCE library
4 */
5
6/*
7 * Copyright (c) 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef INTERNAL_H
16#define INTERNAL_H
17
18#include <stdlib.h>
19#include <stdio.h>
20#include <barrelfish/barrelfish.h>
21#include <barrelfish/dispatch.h>
22#include <barrelfish/bulk_transfer.h>
23#include <if/rcce_defs.h>
24#include <if/monitor_defs.h>
25
26//#define DEBUG_ENABLED
27
28#ifdef DEBUG_ENABLED
29#       define dprintf  printf
30#else
31#       define dprintf(...)
32#endif
33
34#ifdef BULK_TRANSFER_ENABLED
35/* #       define BULK_SIZE       (1 << 19) */
36/* #       define BLOCK_SIZE      (1 << 18) */
37#       define BULK_SIZE       (1 << 13)
38#       define BLOCK_SIZE      (1 << 13)
39#else
40#       define BULK_SIZE       (1 << 12)
41#       define BLOCK_SIZE      (1 << 12)
42#endif
43
44#define BULK_PAGE_MAP VREGION_FLAGS_READ_WRITE_MPB
45//#define BULK_PAGE_MAP VREGION_FLAGS_READ_WRITE_NOCACHE
46
47struct msg_buf {
48    char *msg;
49    size_t length, current;
50    bool pending;
51    uintptr_t id, bulk;
52#ifdef BULK_TRANSFER_ENABLED
53    bool bulk_ready;
54#endif
55};
56
57struct rcce_state {
58    coreid_t index;
59    bool request_done, waitmsg, recv_ready, bulk_waitmsg;
60    struct bulk_transfer bt;
61    struct bulk_transfer_slave btr;
62};
63
64extern struct msg_buf msgbuf[MAX_CPUS];
65extern struct rcce_binding *barray[MAX_CPUS];
66extern coreid_t my_core_id, num_cores, bsp_id;
67
68void barrier_wait(void);
69errval_t send_message(char *msg, size_t size, coreid_t dest);
70void barriers_init(coreid_t max_cpus);
71void barrier_binding_init(struct rcce_binding * binding);
72void setup_routes(int argc, char **argv);
73
74#endif
75