| [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>
|
|---|
| [84afc7b] | 40 | #include <ddi.h>
|
|---|
| [d9fae235] | 41 | #include <errno.h>
|
|---|
| [b6a088f] | 42 | #include "../kbd_port.h"
|
|---|
| 43 | #include "../kbd.h"
|
|---|
| [f89979b] | 44 |
|
|---|
| [9be360ee] | 45 | static int msim_port_init(kbd_dev_t *);
|
|---|
| [b1bdc7a4] | 46 | static void msim_port_write(uint8_t data);
|
|---|
| 47 |
|
|---|
| 48 | kbd_port_ops_t msim_port = {
|
|---|
| 49 | .init = msim_port_init,
|
|---|
| 50 | .write = msim_port_write
|
|---|
| 51 | };
|
|---|
| 52 |
|
|---|
| [9be360ee] | 53 | static kbd_dev_t *kbd_dev;
|
|---|
| 54 |
|
|---|
| [27ed3edd] | 55 | static irq_pio_range_t msim_ranges[] = {
|
|---|
| 56 | {
|
|---|
| 57 | .base = 0,
|
|---|
| 58 | .size = 1
|
|---|
| 59 | }
|
|---|
| 60 | };
|
|---|
| 61 |
|
|---|
| [b1bdc7a4] | 62 | static irq_cmd_t msim_cmds[] = {
|
|---|
| [0c33687a] | 63 | {
|
|---|
| 64 | .cmd = CMD_PIO_READ_8,
|
|---|
| 65 | .addr = (void *) 0, /* will be patched in run-time */
|
|---|
| 66 | .dstarg = 2
|
|---|
| 67 | },
|
|---|
| 68 | {
|
|---|
| 69 | .cmd = CMD_ACCEPT
|
|---|
| 70 | }
|
|---|
| [f89979b] | 71 | };
|
|---|
| 72 |
|
|---|
| [b1bdc7a4] | 73 | static irq_code_t msim_kbd = {
|
|---|
| [27ed3edd] | 74 | sizeof(msim_ranges) / sizeof(irq_pio_range_t),
|
|---|
| 75 | msim_ranges,
|
|---|
| [0c33687a] | 76 | sizeof(msim_cmds) / sizeof(irq_cmd_t),
|
|---|
| [f89979b] | 77 | msim_cmds
|
|---|
| 78 | };
|
|---|
| 79 |
|
|---|
| [8820544] | 80 | static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call, void *arg)
|
|---|
| 81 | {
|
|---|
| 82 | kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
|
|---|
| 83 | }
|
|---|
| [f89979b] | 84 |
|
|---|
| [9be360ee] | 85 | static int msim_port_init(kbd_dev_t *kdev)
|
|---|
| [f89979b] | 86 | {
|
|---|
| [9be360ee] | 87 | kbd_dev = kdev;
|
|---|
| 88 |
|
|---|
| [27ed3edd] | 89 | sysarg_t paddr;
|
|---|
| 90 | if (sysinfo_get_value("kbd.address.physical", &paddr) != EOK)
|
|---|
| [d9fae235] | 91 | return -1;
|
|---|
| 92 |
|
|---|
| 93 | sysarg_t inr;
|
|---|
| 94 | if (sysinfo_get_value("kbd.inr", &inr) != EOK)
|
|---|
| 95 | return -1;
|
|---|
| 96 |
|
|---|
| [27ed3edd] | 97 | msim_ranges[0].base = paddr;
|
|---|
| 98 | msim_cmds[0].addr = (void *) paddr;
|
|---|
| [8820544] | 99 | async_irq_subscribe(inr, device_assign_devno(), msim_irq_handler, NULL,
|
|---|
| 100 | &msim_kbd);
|
|---|
| [d9fae235] | 101 |
|
|---|
| [f89979b] | 102 | return 0;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| [b1bdc7a4] | 105 | static void msim_port_write(uint8_t data)
|
|---|
| [c145bc2] | 106 | {
|
|---|
| 107 | (void) data;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| [f89979b] | 110 | /** @}
|
|---|
| [1875a0c] | 111 | */
|
|---|