#ifndef bufmgr_bufmgr_h #define bufmgr_bufmgr_h /* Cesar project {{{ * * Copyright (C) 2012 Spidcom * * <<>> * * }}} */ /** * \file bufmgr/bufmgr.h * \brief Public interfaces for buffer manager. * \ingroup bufmgr * * The buffer manager is responsible for passing empty buffers coming from * Linux to other cesar components and returning used buffers from those * components to Linux. * * Buffer manager is responsible for informing clients after a try get that * new buffers are available. For that, clients must register. */ #include "hal/ipmbox/ipmbox.h" /* Forward declaration. */ typedef struct bufmgr_t bufmgr_t; /** * Callback prototype. * \param user_data the user_data to give with the callback */ typedef void (*bufmgr_callback_t) (void *user_data); BEGIN_DECLS /** * Get a buffer from the buffer manager. * \param ctx module context * \return a buffer, NULL if none available */ u8 * bufmgr_get (bufmgr_t *ctx); /** * Get a buffer from the buffer manager and wait it for a certain delay or * until it gets it. * \param ctx module context * \param delay_ms delay of wait in ms, 0 if client wants to wait forever * \return a buffer, NULL if no buffer available and the delay expired */ u8 * bufmgr_get_wait (bufmgr_t *ctx, uint delay_rtc); /** * Give back a buffer. * \param ctx module context * \param buffer buffer to return */ void bufmgr_give_back (bufmgr_t *ctx, u8 *buffer); /** * Give the buffer to buffer manager to keep it. * \param ctx module context * \param buffer buffer to return */ void bufmgr_keep_buffer (bufmgr_t *ctx, u8 *buffer); /** * Register a client to the buffer manager. * \param ctx module context * \param cb the callback to call * \param user_data the user data to provide */ void bufmgr_client_register (bufmgr_t *ctx, bufmgr_callback_t cb, void *user_data); /** * Initialise the module. * \param ipmbox the ipmbox context * \return buffer manager context */ bufmgr_t * bufmgr_init (ipmbox_t *ipmbox); /** * Uninitialise the module. * \param ctx module context */ void bufmgr_uninit (bufmgr_t *ctx); END_DECLS #endif /* bufmgr_bufmgr_h */