1/* 2 * Copyright (c) 2016 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9#ifndef DESCQ_H_ 10#define DESCQ_H_ 1 11 12 13#include <barrelfish/barrelfish.h> 14 15#define DESCQ_DEFAULT_SIZE 2048 16#define DESCQ_ALIGNMENT 64 17 18struct descq; 19 20typedef errval_t (*descq_create_t) (struct descq *q, uint64_t *queue_id); 21typedef errval_t (*descq_destroy_t) (struct descq *q); 22typedef errval_t (*descq_notify_t) (struct descq *q); 23typedef errval_t (*descq_register_t)(struct descq *q, struct capref cap, 24 regionid_t region_id); 25typedef errval_t (*descq_deregister_t)(struct descq *q, regionid_t region_id); 26typedef errval_t (*descq_control_t)(struct descq *q, 27 uint64_t request, 28 uint64_t value, 29 uint64_t *result); 30typedef errval_t (*descq_enqueued_t)(struct descq* q); 31 32struct descq_func_pointer { 33 descq_create_t create; 34 descq_destroy_t destroy; 35 descq_notify_t notify; 36 descq_register_t reg; 37 descq_deregister_t dereg; 38 descq_control_t control; 39}; 40 41 42/** 43 * @brief initialized a descriptor queue 44 * 45 * @param q Return pointer to the descriptor queue 46 * @param slots Number of slots in the queue 47 * @param name Name of the exported/connected to channel 48 * @param exp Export desq_ctrl/descq_data flounder interface 49 * (At least one of the sides of the channel hast to do so) 50 * @param queue_id queue id 51 * @param f Function pointers to be called on message recv 52 * 53 * @returns error on failure or SYS_ERR_OK on success 54 */ 55errval_t descq_create(struct descq** q, 56 size_t slots, 57 char* name, 58 bool exp, 59 uint64_t *queue_id, 60 struct descq_func_pointer* f); 61 62/** 63 * @brief initialized a descriptor queue 64 * 65 * @param q Return pointer to the descriptor queue 66 * @param slots Number of slots in the queue 67 * @param ep Endpoint to connect to 68 * @param exp Export desq_ctrl/descq_data flounder interface 69 * (At least one of the sides of the channel hast to do so) 70 * @param queue_id queue id 71 * @param f Function pointers to be called on message recv 72 * 73 * @returns error on failure or SYS_ERR_OK on success 74 */ 75errval_t descq_create_with_ep(struct descq** q, 76 size_t slots, 77 struct capref ep, 78 uint64_t *queue_id, 79 struct descq_func_pointer* f); 80 81/** 82 * @brief Create an endpoint from an exporting queue. If the queue is not exporting, 83 * the call will fail. 84 * 85 * @param q Pointer to the descriptor queue 86 * @param slots Core on which the other EP will be used 87 * @param ep Returned endpoint 88 * @param exp Export desq_ctrl/descq_data flounder interface 89 * (At least one of the sides of the channel hast to do so) 90 * @param queue_id queue id 91 * @param f Function pointers to be called on message recv 92 * 93 * @returns error on failure or SYS_ERR_OK on success 94 */ 95errval_t descq_create_ep(struct descq* queue, 96 coreid_t core, 97 struct capref* ep); 98 99#endif /* DESCQ_H_ */ 100