1/* 2 * Copyright 2017, 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#pragma once 14 15#include <platsupport/io.h> 16#include <stdint.h> 17#include <sys/types.h> 18#include <utils/util.h> 19 20/** \brief A convenience type for CAmkES dataports. 21 * 22 * The default dataport type in CAmkES is `Buf`, a generic type for a 23 * page-sized shared memory region. While the user is provided with a typed 24 * pointer, this should never be directly dereferenced. The only legal things 25 * to do with a `Buf` are to call `sizeof` or cast a pointer to one to a 26 * pointer of another type. E.g. 27 * 28 * char my_buffer[sizeof(Buf)]; 29 * strncpy(my_char, buf_ptr, sizeof(Buf)); 30 */ 31typedef struct Buf_ { 32 char content[PAGE_SIZE_4K] DEPRECATED("Buf type incorrectly accessed directly"); 33} Buf; 34 35/* This type is intended to be used opaquely by a user. */ 36typedef struct dataport_ptr_ { 37 int32_t id; 38 off_t offset; 39} dataport_ptr_t; 40 41struct dataport_frame { 42 uintptr_t paddr; 43 uintptr_t cap; 44 uintptr_t size; 45 uintptr_t vaddr; 46}; 47typedef struct dataport_frame dataport_frame_t; 48 49/* These functions are generated by the CAmkES platform compilation, but are 50 * intended to be invoked by the user. 51 */ 52dataport_ptr_t dataport_wrap_ptr(void *ptr); 53void *dataport_unwrap_ptr(dataport_ptr_t ptr); 54 55int camkes_dataport_flush_cache(size_t start_offset, size_t size, 56 uintptr_t dataport_start, size_t dataport_size, 57 dma_cache_op_t cache_op); 58