source: mainline/kernel/generic/include/console/chardev.h@ 44a7ee5

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 44a7ee5 was 7ddc2c7, checked in by Martin Decky <martin@…>, 11 years ago

add support for framebuffer history paging (using Page Up and Page Down keys), inspiration taken from the code by Sebastian Köln
add support for input device out-of-band signalling

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2005 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup genericconsole
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_CHARDEV_H_
36#define KERN_CHARDEV_H_
37
38#include <adt/list.h>
39#include <typedefs.h>
40#include <synch/waitq.h>
41#include <synch/spinlock.h>
42
43#define INDEV_BUFLEN 512
44
45/** Input character device out-of-band signal type. */
46typedef enum {
47 INDEV_SIGNAL_SCROLL_UP = 0,
48 INDEV_SIGNAL_SCROLL_DOWN
49} indev_signal_t;
50
51struct indev;
52
53/** Input character device operations interface. */
54typedef struct {
55 /** Read character directly from device, assume interrupts disabled. */
56 wchar_t (* poll)(struct indev *);
57
58 /** Signal out-of-band condition. */
59 void (* signal)(struct indev *, indev_signal_t);
60} indev_operations_t;
61
62/** Character input device. */
63typedef struct indev {
64 const char *name;
65 waitq_t wq;
66
67 /** Protects everything below. */
68 IRQ_SPINLOCK_DECLARE(lock);
69 wchar_t buffer[INDEV_BUFLEN];
70 size_t counter;
71
72 /** Implementation of indev operations. */
73 indev_operations_t *op;
74 size_t index;
75 void *data;
76} indev_t;
77
78struct outdev;
79
80/** Output character device operations interface. */
81typedef struct {
82 /** Write character to output. */
83 void (* write)(struct outdev *, wchar_t);
84
85 /** Redraw any previously cached characters. */
86 void (* redraw)(struct outdev *);
87
88 /** Scroll up in the device cache. */
89 void (* scroll_up)(struct outdev *);
90
91 /** Scroll down in the device cache. */
92 void (* scroll_down)(struct outdev *);
93} outdev_operations_t;
94
95/** Character output device. */
96typedef struct outdev {
97 const char *name;
98
99 /** Protects everything below. */
100 SPINLOCK_DECLARE(lock);
101
102 /** Fields suitable for multiplexing. */
103 link_t link;
104 list_t list;
105
106 /** Implementation of outdev operations. */
107 outdev_operations_t *op;
108 void *data;
109} outdev_t;
110
111extern void indev_initialize(const char *, indev_t *,
112 indev_operations_t *);
113extern void indev_push_character(indev_t *, wchar_t);
114extern wchar_t indev_pop_character(indev_t *);
115extern void indev_signal(indev_t *, indev_signal_t);
116
117extern void outdev_initialize(const char *, outdev_t *,
118 outdev_operations_t *);
119
120extern bool check_poll(indev_t *);
121
122#endif /* KERN_CHARDEV_H_ */
123
124/** @}
125 */
Note: See TracBrowser for help on using the repository browser.