source: mainline/uspace/drv/char/i8042/i8042.h@ 5b320ac

Last change on this file since 5b320ac was 60744cb, checked in by Jiri Svoboda <jiri@…>, 15 months ago

Let driver specify any argument to IRQ handler

This allows the driver to register a single handler for multiple
interrupts and still distinguish between them. It also removes
the extra step of having to get softstate from ddf_dev_t.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2024 Jiri Svoboda
3 * Copyright (c) 2006 Josef Cejka
4 * Copyright (c) 2011 Jan Vesely
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @addtogroup i8042
32 * @{
33 */
34
35/** @file
36 * @brief i8042 port driver.
37 */
38
39#ifndef i8042_H_
40#define i8042_H_
41
42#include <adt/circ_buf.h>
43#include <io/chardev_srv.h>
44#include <ddi.h>
45#include <fibril_synch.h>
46#include <ddf/driver.h>
47
48#define NAME "i8042"
49
50/** Buffer needs to be large enough for rate at which keyboard or mouse
51 * produces data (mouse produces data at faster rate).
52 */
53#define BUFFER_SIZE 64
54
55/** i8042 HW I/O interface */
56typedef struct {
57 ioport8_t data;
58 uint8_t pad[3];
59 ioport8_t status;
60} __attribute__((packed)) i8042_regs_t;
61
62/** i8042 Port. */
63typedef struct {
64 /** Controller */
65 struct i8042 *ctl;
66 /** Device function */
67 ddf_fun_t *fun;
68 /** Character device server data */
69 chardev_srvs_t cds;
70 /** Circular buffer */
71 circ_buf_t cbuf;
72 /** Buffer data space */
73 uint8_t buf_data[BUFFER_SIZE];
74 /** Protect buffer */
75 fibril_mutex_t buf_lock;
76 /** Signal new data in buffer */
77 fibril_condvar_t buf_cv;
78 /** Interrupt number */
79 int irq;
80} i8042_port_t;
81
82/** i8042 Controller. */
83typedef struct i8042 {
84 /** DDF device */
85 ddf_dev_t *dev;
86 /** I/O registers. */
87 i8042_regs_t *regs;
88 /** Keyboard port */
89 i8042_port_t *kbd;
90 /** AUX port */
91 i8042_port_t *aux;
92 /** Prevents simultanous port writes. */
93 fibril_mutex_t write_guard;
94} i8042_t;
95
96extern errno_t i8042_init(i8042_t *, addr_range_t *, int, int, ddf_dev_t *);
97
98#endif
99
100/**
101 * @}
102 */
Note: See TracBrowser for help on using the repository browser.