source: mainline/uspace/srv/hid/input/port/msim.c@ a996ae31

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a996ae31 was a996ae31, checked in by Jakub Jermar <jakub@…>, 13 years ago

Userspace IRQ pseudocode is expected to use physical addresses from now.
The kernel creates kernel mappings for those and adjusts the pseudocode
accordingly.

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[f89979b]1/*
2 * Copyright (c) 2006 Josef Cejka
[9be360ee]3 * Copyright (c) 2011 Jiri Svoboda
[f89979b]4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
[24ff4df]30/** @addtogroup kbd_port
31 * @ingroup kbd
[f89979b]32 * @{
[d9fae235]33 */
[f89979b]34/** @file
[d9fae235]35 * @brief Msim keyboard port driver.
[f89979b]36 */
37
38#include <async.h>
39#include <sysinfo.h>
40#include <kbd_port.h>
41#include <kbd.h>
[84afc7b]42#include <ddi.h>
[d9fae235]43#include <errno.h>
[f89979b]44
[9be360ee]45static int msim_port_init(kbd_dev_t *);
[b1bdc7a4]46static void msim_port_yield(void);
47static void msim_port_reclaim(void);
48static void msim_port_write(uint8_t data);
49
50kbd_port_ops_t msim_port = {
51 .init = msim_port_init,
52 .yield = msim_port_yield,
53 .reclaim = msim_port_reclaim,
54 .write = msim_port_write
55};
56
[9be360ee]57static kbd_dev_t *kbd_dev;
58
[b1bdc7a4]59static irq_cmd_t msim_cmds[] = {
[0c33687a]60 {
61 .cmd = CMD_PIO_READ_8,
62 .addr = (void *) 0, /* will be patched in run-time */
63 .dstarg = 2
64 },
65 {
66 .cmd = CMD_ACCEPT
67 }
[f89979b]68};
69
[b1bdc7a4]70static irq_code_t msim_kbd = {
[a996ae31]71 0, // FIXME
72 NULL, // FIXME
[0c33687a]73 sizeof(msim_cmds) / sizeof(irq_cmd_t),
[f89979b]74 msim_cmds
75};
76
77static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call);
78
[9be360ee]79static int msim_port_init(kbd_dev_t *kdev)
[f89979b]80{
[9be360ee]81 kbd_dev = kdev;
82
[d9fae235]83 sysarg_t vaddr;
84 if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK)
85 return -1;
86
87 sysarg_t inr;
88 if (sysinfo_get_value("kbd.inr", &inr) != EOK)
89 return -1;
90
91 msim_cmds[0].addr = (void *) vaddr;
[f89979b]92 async_set_interrupt_received(msim_irq_handler);
[f044e96]93 irq_register(inr, device_assign_devno(), 0, &msim_kbd);
[d9fae235]94
[f89979b]95 return 0;
96}
97
[b1bdc7a4]98static void msim_port_yield(void)
[f89979b]99{
[ccd1a14]100}
[f89979b]101
[b1bdc7a4]102static void msim_port_reclaim(void)
[ccd1a14]103{
104}
[f89979b]105
[b1bdc7a4]106static void msim_port_write(uint8_t data)
[c145bc2]107{
108 (void) data;
109}
110
[ccd1a14]111static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call)
112{
[1875a0c]113 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
[f89979b]114}
115
116/** @}
[1875a0c]117 */
Note: See TracBrowser for help on using the repository browser.