source: svn/trunk/newcon3bcm2_21bu/BSEAV/lib/bfile/bfile_buffer.h @ 12

Last change on this file since 12 was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2007-2009, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bfile_buffer.h $
11 * $brcm_Revision: 6 $
12 * $brcm_Date: 6/2/09 7:38p $
13 *
14 * Module Description:
15 *
16 * Block based cached file I/O
17 *
18 * Revision History:
19 *
20 * $brcm_Log: /BSEAV/lib/bfile/bfile_buffer.h $
21 *
22 * 6   6/2/09 7:38p vsilyaev
23 * PR 55417: Added support for read method returning no data or completing
24 * with a partial read
25 *
26 * 5   12/18/08 7:04p vsilyaev
27 * PR 47854: Improved handling of conditions where asynchronous read
28 * exhaust allocated buffer
29 *
30 * 4   11/26/08 3:56p vsilyaev
31 * PR 47650: Added function to get bounds
32 *
33 * 3   9/18/08 3:27p vsilyaev
34 * PR 47105: Added support for layered buffer cache
35 *
36 * 2   6/14/07 12:49p vsilyaev
37 * PR 32162: Serializes async disk I/O for bfile_buffer. Fixed unitilized
38 * ref_cnt in bfile_buffer.c
39 *
40 * 1   5/16/07 9:53p vsilyaev
41 * PR 28631: Added block based file cache/buffer
42 *
43 *******************************************************************************/
44#ifndef _BFILE_BUFFER_H__
45#define _BFILE_BUFFER_H__
46
47#include "bfile_io.h"
48#include "bioatom.h"
49
50#ifdef __cplusplus
51extern "C"
52{
53#endif
54
55typedef struct bfile_buffer *bfile_buffer_t;
56
57typedef enum bfile_buffer_overflow_action {
58    bfile_buffer_overflow_action_wait,
59    bfile_buffer_overflow_action_abort
60} bfile_buffer_overflow_action;
61
62typedef struct bfile_buffer_cfg {
63        bool async;
64        unsigned nsegs;
65        size_t buf_len;
66        void *buf;
67        void *sync_cnxt;
68        bfile_io_read_t fd;
69        void (*async_read)(void *sync_cnxt, bfile_io_read_t fd, void *buf, size_t length, void (*read_cont)(void *cont, ssize_t size), void *cntx);
70    bfile_buffer_overflow_action (*async_overflow)(void *sync_cnxt);
71} bfile_buffer_cfg;
72
73typedef enum bfile_buffer_result {
74        bfile_buffer_result_ok,
75        bfile_buffer_result_read_error,
76        bfile_buffer_result_eof,
77    bfile_buffer_result_no_data, /* temporary no data in the file */
78        bfile_buffer_result_async,
79        bfile_buffer_result_buffer_overflow
80} bfile_buffer_result;
81
82void bfile_buffer_default_cfg(bfile_buffer_cfg *cfg);
83bfile_buffer_t bfile_buffer_create(batom_factory_t factory, bfile_buffer_cfg *cfg);
84void bfile_buffer_clear(bfile_buffer_t buf);
85void bfile_buffer_destroy(bfile_buffer_t buf);
86       
87batom_t bfile_buffer_async_read(bfile_buffer_t buf, off_t off, size_t length, bfile_buffer_result *result, void (*read_complete)(void *, batom_t, bfile_buffer_result ), void *cntx);
88batom_t bfile_buffer_read(bfile_buffer_t buf, off_t off, size_t length, bfile_buffer_result *result);
89int bfile_buffer_get_bounds(bfile_buffer_t buf, off_t *first, off_t *last);
90
91#ifdef __cplusplus
92}
93#endif
94
95
96#endif /* _BFILE_BUFFER_H__ */
97
98
Note: See TracBrowser for help on using the repository browser.