Changeset 65ffec3 in mainline
- Timestamp:
- 2011-12-26T22:40:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ff60d1
- Parents:
- e67e1be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/buffer.h
re67e1be r65ffec3 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup kbd_port29 * @ ingroupkbd28 /** 29 * @addtogroup kbd 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief i8042 port driver.33 * @brief Cyclic buffer structure. 34 34 */ 35 35 … … 40 40 #include <fibril_synch.h> 41 41 42 /** Cyclic buffer that blocks on full/empty. 43 * 44 * read_head == write_head means that the buffer is empty. 45 * write_head + 1 == read_head means that the buffer is full. 46 * Attempt to insert byte into the full buffer will block until it can succeed. 47 * Attempt to read from empty buffer will block until it can succeed. 48 */ 42 49 typedef struct { 43 uint8_t *buffer; 44 uint8_t *buffer_end; 45 fibril_mutex_t guard; 46 fibril_condvar_t change; 47 uint8_t *read_head; 48 uint8_t *write_head; 50 uint8_t *buffer; /**< Storage space. */ 51 uint8_t *buffer_end; /**< End of storage place. */ 52 fibril_mutex_t guard; /**< Protects buffer structures. */ 53 fibril_condvar_t change; /**< Indicates change (empty/full). */ 54 uint8_t *read_head; /**< Place of the next readable element. */ 55 uint8_t *write_head; /**< Pointer to the next writable place. */ 49 56 } buffer_t; 50 57 58 /** Initialize cyclic buffer using provided memory space. 59 * @param buffer Cyclic buffer structure to initialize. 60 * @param data Memory space to use. 61 * @param size Size of the memory place. 62 */ 51 63 static inline void buffer_init(buffer_t *buffer, uint8_t *data, size_t size) 52 64 { … … 61 73 } 62 74 75 /** Write byte to cyclic buffer. 76 * @param buffer Cyclic buffer to write to. 77 * @param data Data to write. 78 */ 63 79 static inline void buffer_write(buffer_t *buffer, uint8_t data) 64 80 { … … 86 102 } 87 103 104 /** Read byte from cyclic buffer. 105 * @param buffer Cyclic buffer to read from. 106 * @return Byte read. 107 */ 88 108 static inline uint8_t buffer_read(buffer_t *buffer) 89 109 { … … 114 134 return data; 115 135 } 116 117 118 136 #endif 119 137 /**
Note:
See TracChangeset
for help on using the changeset viewer.