Disable ICANON for now. Use standardized fixed-size ring buffer inside the keyboard drivers.
This commit is contained in:
@@ -26,19 +26,18 @@ typedef struct termios {
|
||||
speed_t c_ospeed; ///< output speed
|
||||
} termios_t;
|
||||
|
||||
/// @brief These flags generally control higher-level aspects of input processing than the input
|
||||
/// modes flags described in Input Modes, such as echoing, signals, and the choice of canonical
|
||||
/// or noncanonical input.
|
||||
enum {
|
||||
ISIG = 000001U, ///< Controls whether the INTR, QUIT, and SUSP characters are recognized.
|
||||
ICANON = 000002U, ///< Enables canonical input processing mode.
|
||||
ECHO = 000010U, ///< Echo input characters.
|
||||
ECHOE = 000020U, ///< If ICANON is set, the ERASE character erases the preceding character.
|
||||
ECHOK = 000040U, ///< If ICANON is set, the KILL character erases the current line.
|
||||
ECHONL = 000100U, ///< If ICANON is set, echo the NL character even if ECHO is not set.
|
||||
NOFLSH = 000200U, ///< Do not clear in/out queues when receiving INTR, QUIT, and SUSP.
|
||||
TOSTOP = 000400U, ///< Allows SIGTTOU signals generated by background processes.
|
||||
ECHOCTL = 001000U, ///< If this and ECHO are set, control characters with ‘^’ are echoed.
|
||||
ECHOKE = 004000U, ///< If ICANON is set, KILL is echoed by erasing each character on the line.
|
||||
IEXTEN = 100000U, ///< Enables implementation-defined input processing.
|
||||
};
|
||||
//These flags generally control higher-level aspects of input processing than
|
||||
// the input modes flags described in Input Modes, such as echoing, signals, and
|
||||
// the choice of canonical or noncanonical input.
|
||||
|
||||
#define ISIG 0x00000080 ///< Controls whether the INTR, QUIT, and SUSP characters are recognized.
|
||||
#define ICANON 0x00000100 ///< Enables canonical input processing mode.
|
||||
#define ECHO 0x00000008 ///< Echo input characters.
|
||||
#define ECHOE 0x00000002 ///< If ICANON is set, the ERASE character erases the preceding character.
|
||||
#define ECHOK 0x00000004 ///< If ICANON is set, the KILL character erases the current line.
|
||||
#define ECHONL 0x00000010 ///< If ICANON is set, echo the NL character even if ECHO is not set.
|
||||
#define NOFLSH 0x80000000 ///< Do not clear in/out queues when receiving INTR, QUIT, and SUSP.
|
||||
#define TOSTOP 0x00400000 ///< Allows SIGTTOU signals generated by background processes.
|
||||
#define ECHOCTL 0x00000040 ///< If this and ECHO are set, control characters with ‘^’ are echoed.
|
||||
#define ECHOKE 0x00000001 ///< If ICANON is set, KILL is echoed by erasing each character on the line.
|
||||
#define IEXTEN 0x00000400 ///< Enables implementation-defined input processing.
|
||||
+41
-39
@@ -5,45 +5,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define DECLARE_FS_RING_BUFFER(type, name, length, init) \
|
||||
typedef struct rb_##name##_t { \
|
||||
unsigned size, read, write; \
|
||||
type buffer[length]; \
|
||||
} rb_##name##_t; \
|
||||
static inline void init_rb_##name(rb_##name##_t *rb) \
|
||||
{ \
|
||||
rb->size = length; \
|
||||
rb->read = rb->write = 0; \
|
||||
memset(rb->buffer, init, sizeof(type) * length); \
|
||||
} \
|
||||
static inline void free_rb_##name(rb_##name##_t *rb) \
|
||||
{ \
|
||||
kfree(rb->buffer); \
|
||||
} \
|
||||
static inline unsigned step_rb_##name(rb_##name##_t *rb, unsigned index) \
|
||||
{ \
|
||||
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||
} \
|
||||
static inline void push_rb_##name(rb_##name##_t *rb, type item) \
|
||||
{ \
|
||||
if (step_rb_##name(rb, rb->write) == rb->read) \
|
||||
rb->read = step_rb_##name(rb, rb->read); \
|
||||
rb->buffer[rb->write] = item; \
|
||||
rb->write = step_rb_##name(rb, rb->write); \
|
||||
} \
|
||||
static inline type pop_rb_##name(rb_##name##_t *rb) \
|
||||
{ \
|
||||
type item = init; \
|
||||
if (rb->write != rb->read) { \
|
||||
item = rb->buffer[rb->read]; \
|
||||
rb->read = step_rb_##name(rb, rb->read); \
|
||||
} \
|
||||
return item; \
|
||||
} \
|
||||
static inline void get_rb_##name(rb_##name##_t *rb, unsigned index, type *item) \
|
||||
{ \
|
||||
if (index < rb->size) \
|
||||
*item = rb->buffer[index]; \
|
||||
#define DECLARE_FIXED_SIZE_RING_BUFFER(type, name, length, init) \
|
||||
typedef struct fs_rb_##name##_t { \
|
||||
unsigned size, read, write; \
|
||||
type buffer[length]; \
|
||||
} fs_rb_##name##_t; \
|
||||
static inline void fs_rb_##name##_init(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
rb->size = length; \
|
||||
rb->read = rb->write = 0; \
|
||||
char *dst = (char *)rb->buffer; \
|
||||
long num = sizeof(type) * length; \
|
||||
while (num--) *dst++ = (char)(init & 0xFF); \
|
||||
} \
|
||||
static inline unsigned fs_rb_##name##_step(fs_rb_##name##_t *rb, unsigned index) \
|
||||
{ \
|
||||
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||
} \
|
||||
static inline void fs_rb_##name##_push(fs_rb_##name##_t *rb, type item) \
|
||||
{ \
|
||||
if (fs_rb_##name##_step(rb, rb->write) == rb->read) \
|
||||
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||
rb->buffer[rb->write] = item; \
|
||||
rb->write = fs_rb_##name##_step(rb, rb->write); \
|
||||
} \
|
||||
static inline type fs_rb_##name##_empty(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
return rb->write == rb->read; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_pop(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
type item = init; \
|
||||
if (rb->write != rb->read) { \
|
||||
item = rb->buffer[rb->read]; \
|
||||
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||
} \
|
||||
return item; \
|
||||
} \
|
||||
static inline void fs_rb_##name##_get(fs_rb_##name##_t *rb, unsigned index, type *item) \
|
||||
{ \
|
||||
if (index < rb->size) \
|
||||
*item = rb->buffer[index]; \
|
||||
}
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
Reference in New Issue
Block a user