1/*
2 * Copyright 2019, 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 GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13#pragma once
14
15#include <camkes/dataport.h>
16
17typedef struct picoserver_event {
18    int socket_fd;
19    uint16_t events;
20    int num_events_left;
21} picoserver_event_t;
22#define ENCODE_DMA_ADDRESS(buf) ({ \
23    dataport_ptr_t wrapped_ptr = dataport_wrap_ptr(buf); \
24    void *new_buf = (void *)(((uintptr_t)wrapped_ptr.id << 32) | ((uintptr_t)wrapped_ptr.offset)); \
25    new_buf; })
26
27#define DECODE_DMA_ADDRESS(buf) ({\
28        dataport_ptr_t wrapped_ptr = {.id = ((uintptr_t)buf >> 32), .offset = (uintptr_t)buf & MASK(32)}; \
29        void *ptr = dataport_unwrap_ptr(wrapped_ptr); \
30        ptr; })
31
32typedef struct tx_msg tx_msg_t;
33struct tx_msg {
34    int socket_fd;
35    size_t total_len;
36    size_t done_len;
37    uint32_t src_addr;
38    uint16_t remote_port;
39    tx_msg_t *next;
40    void *cookie_save;
41    void *client_cookie;
42    char buf[];
43};
44