1/** 2 * \file 3 * \brief continuation management 4 * 5 * This file provides a generic way of managing continuation for messages 6 * of different types 7 */ 8 9/* 10 * Copyright (c) 2007, 2008, 2009, ETH Zurich. 11 * All rights reserved. 12 * 13 * This file is distributed under the terms in the attached LICENSE file. 14 * If you do not find this file, copies can be found by writing to: 15 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 16 */ 17 18 19#ifndef CONTMNG_H_ 20#define CONTMNG_H_ 21 22#include <stdio.h> 23#include <sys/cdefs.h> 24 25__BEGIN_DECLS 26 27/*********************************************************************/ 28/* Implementation of generic queue */ 29 30/* !!!!!!!!!!!!! ASSUMPTIONS: READ THIS BEFORE USING IT !!!!!!!!!!!!!!!!!! 31 * 1. There are less than MAX_PARAMS no. of parameters. 32 * 2. All the data which is sent is of type uint64_t. 33 * 3. Only exception is struct cap, which is dealt separately. 34 * 4. The errval_t datatype is casted into uint64_t which is 35 * assumed to be lossless. 36 * 5. void * pointers are casted to uint64_t which is assumed to be lossless. 37 * */ 38 39#define MAX_QUEUE_SIZE 1024 40#define MAX_PARAMS 10 41 42struct q_entry { 43 void *binding_ptr; 44 uint64_t plist[MAX_PARAMS]; /* Assuming max parameters are MAX_PARAMS */ 45 struct capref cap; 46 struct capref cap2; 47 errval_t (*handler)(struct q_entry entry); 48 char *fname; 49 int state; 50}; 51 52struct cont_queue { 53 char name[64]; /* for debugging purposes */ 54 int running; 55 int head; 56 int tail; 57 struct q_entry qelist[MAX_QUEUE_SIZE]; 58 uint8_t debug; 59}; 60 61/***** helper functions *****/ 62/* create new queue */ 63struct cont_queue *create_cont_q(char *name); 64bool can_enqueue_cont_q(struct cont_queue *q); 65void enqueue_cont_q(struct cont_queue *q, struct q_entry *entry); 66void cont_queue_callback(void *arg); 67void cont_queue_show_queue(struct cont_queue *q); 68int queue_free_slots(struct cont_queue *q); 69int queue_used_slots(struct cont_queue *q); 70int is_enough_space_in_queue(struct cont_queue *q); 71 72void show_binary_blob (void *data, int len); 73 74__END_DECLS 75 76#endif // CONTMNG_H_ 77