1/* 2 * Copyright 2020, 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 14#include <stdint.h> 15#include <sel4/sel4.h> 16#include <platsupport/io.h> 17 18#define ENCODE_DMA_ADDRESS(buf) ({ \ 19 dataport_ptr_t wrapped_ptr = dataport_wrap_ptr(buf); \ 20 void *new_buf = (void *)(((uintptr_t)wrapped_ptr.id << 32) | ((uintptr_t)wrapped_ptr.offset)); \ 21 new_buf; }) 22 23#define DECODE_DMA_ADDRESS(buf) ({\ 24 dataport_ptr_t wrapped_ptr = {.id = ((uintptr_t)buf >> 32), .offset = (uintptr_t)buf & MASK(32)}; \ 25 void *ptr = dataport_unwrap_ptr(wrapped_ptr); \ 26 ptr; }) 27 28 29typedef void(*get_mac_server_fn_t)(uint8_t *b1, uint8_t *b2, uint8_t *b3, uint8_t *b4, uint8_t *b5, uint8_t *b6, 30 void *cookie); 31typedef void(*get_mac_client_fn_t)(uint8_t *b1, uint8_t *b2, uint8_t *b3, uint8_t *b4, uint8_t *b5, uint8_t *b6); 32 33 34typedef int (*register_callback_handler_fn_t)(seL4_Word badge, const char *, 35 void (*callback_handler)(seL4_Word, void *), void *cookie); 36typedef void (*register_get_mac_server_fn)(get_mac_server_fn_t get_mac, void *cookie); 37 38 39 40int picotcp_ethernet_async_client_init(ps_io_ops_t *io_ops, const char *tx_virtqueue, const char *rx_virtqueue, 41 register_callback_handler_fn_t register_handler, get_mac_client_fn_t get_mac, void **cookie); 42int picotcp_ethernet_async_client_init_late(void *cookie, register_callback_handler_fn_t register_handler); 43 44 45int picotcp_ethernet_async_server_init(ps_io_ops_t *io_ops, const char *tx_virtqueue, const char *rx_virtqueue, 46 register_callback_handler_fn_t register_handler, register_get_mac_server_fn register_get_mac_fn); 47