8 * Copyright (c) 2008 Atheros Communications Inc.
16 #include <Magpie_api.h>
20 #define VBUF_SIZE sizeof(VBUF)
22 struct VBUF_CONTEXT g_vbufCtx;
24 void _vbuf_init(int nBuf);
25 VBUF* _vbuf_alloc_vbuf(void);
26 void _vbuf_free_vbuf(VBUF *buf);
28 void _vbuf_init(int nBuf)
33 //vbuf = (VBUF*)dataAddr;
34 vbuf = (VBUF*)A_ALLOCRAM(VBUF_SIZE);
35 vbuf->next_buf = NULL;
36 vbuf->desc_list = NULL;
38 g_vbufCtx.free_buf_head = vbuf;
42 //vbuf = (VBUF*)(dataAddr + i*VBUF_SIZE);
43 vbuf = (VBUF*)A_ALLOCRAM(VBUF_SIZE);
45 vbuf->desc_list = NULL;
46 vbuf->next_buf = g_vbufCtx.free_buf_head;
47 g_vbufCtx.free_buf_head = vbuf;
50 g_vbufCtx.nVbufNum = nBuf;
51 //return (dataAddr + nBuf*VBUF_SIZE);
55 VBUF* _vbuf_alloc_vbuf(void)
57 VBUF *allocBuf = NULL;
59 if ( g_vbufCtx.free_buf_head != NULL )
61 allocBuf = g_vbufCtx.free_buf_head;
64 g_vbufCtx.free_buf_head = allocBuf->next_buf;
65 allocBuf->next_buf = NULL;
71 void _vbuf_free_vbuf(VBUF *buf)
75 buf->next_buf = g_vbufCtx.free_buf_head;
76 g_vbufCtx.free_buf_head = buf;
81 /* the exported entry point into this module. All apis are accessed through
82 * function pointers */
83 void vbuf_module_install(struct vbuf_api *apis)
86 apis->_init = _vbuf_init;
87 apis->_alloc_vbuf = _vbuf_alloc_vbuf;
88 apis->_free_vbuf = _vbuf_free_vbuf;
90 /* save ptr to the ptr to the context for external code to inspect/modify internal module state */
91 //apis->pReserved = &g_pMboxHWContext;