Merge pull request #2001 from armink/fix_rbb

[DeviceDriver][rbb] Add some comments and rt_rbb_blk_size/rt_rbb_blk_…
This commit is contained in:
Bernard Xiong 2018-11-23 17:17:46 +08:00 committed by GitHub
commit 70bfe427e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 3 deletions

View File

@ -84,6 +84,8 @@ rt_size_t rt_rbb_get_buf_size(rt_rbb_t rbb);
rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size); rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size);
void rt_rbb_blk_put(rt_rbb_blk_t block); void rt_rbb_blk_put(rt_rbb_blk_t block);
rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb); rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb);
rt_size_t rt_rbb_blk_size(rt_rbb_blk_t block);
rt_uint8_t *rt_rbb_blk_buf(rt_rbb_blk_t block);
void rt_rbb_blk_free(rt_rbb_t rbb, rt_rbb_blk_t block); void rt_rbb_blk_free(rt_rbb_t rbb, rt_rbb_blk_t block);
/* rbb block queue API */ /* rbb block queue API */

View File

@ -18,8 +18,10 @@
* @param rbb ring block buffer object * @param rbb ring block buffer object
* @param buf buffer * @param buf buffer
* @param buf_size buffer size * @param buf_size buffer size
* @param block_set * @param block_set block set
* @param blk_max_num * @param blk_max_num max block number
*
* @note When your application need align access, please make the buffer address is aligned.
*/ */
void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num) void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num)
{ {
@ -123,6 +125,8 @@ static rt_rbb_blk_t find_empty_blk_in_set(rt_rbb_t rbb)
* @param rbb ring block buffer object * @param rbb ring block buffer object
* @param blk_size block size * @param blk_size block size
* *
* @note When your application need align access, please make the blk_szie is aligned.
*
* @return != NULL: allocated block * @return != NULL: allocated block
* NULL: allocate failed * NULL: allocate failed
*/ */
@ -133,7 +137,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
rt_rbb_blk_t head, tail, new = NULL; rt_rbb_blk_t head, tail, new = NULL;
RT_ASSERT(rbb); RT_ASSERT(rbb);
RT_ASSERT(blk_size < 1L << 24); RT_ASSERT(blk_size < (1L << 24));
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
@ -277,6 +281,36 @@ __exit:
} }
RTM_EXPORT(rt_rbb_blk_get); RTM_EXPORT(rt_rbb_blk_get);
/**
* return the block size
*
* @param block the block
*
* @return block size
*/
rt_size_t rt_rbb_blk_size(rt_rbb_blk_t block)
{
RT_ASSERT(block);
return block->size;
}
RTM_EXPORT(rt_rbb_blk_size);
/**
* return the block buffer
*
* @param block the block
*
* @return block buffer
*/
rt_uint8_t *rt_rbb_blk_buf(rt_rbb_blk_t block)
{
RT_ASSERT(block);
return block->buf;
}
RTM_EXPORT(rt_rbb_blk_buf);
/** /**
* free the block * free the block
* *