1*7b161854Stsutsui /* $NetBSD: pcconsvar.h,v 1.5 2008/09/13 16:02:17 tsutsui Exp $ */ 2b7abba77Ssoda /* $OpenBSD: pccons.c,v 1.22 1999/01/30 22:39:37 imp Exp $ */ 3b7abba77Ssoda /* NetBSD: pccons.c,v 1.89 1995/05/04 19:35:20 cgd Exp */ 4b7abba77Ssoda 5b7abba77Ssoda /*- 6b7abba77Ssoda * Copyright (c) 1990 The Regents of the University of California. 7b7abba77Ssoda * All rights reserved. 8b7abba77Ssoda * 9b7abba77Ssoda * This code is derived from software contributed to Berkeley by 10b7abba77Ssoda * William Jolitz and Don Ahn. 11b7abba77Ssoda * 12aad01611Sagc * Redistribution and use in source and binary forms, with or without 13aad01611Sagc * modification, are permitted provided that the following conditions 14aad01611Sagc * are met: 15aad01611Sagc * 1. Redistributions of source code must retain the above copyright 16aad01611Sagc * notice, this list of conditions and the following disclaimer. 17aad01611Sagc * 2. Redistributions in binary form must reproduce the above copyright 18aad01611Sagc * notice, this list of conditions and the following disclaimer in the 19aad01611Sagc * documentation and/or other materials provided with the distribution. 20aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 21aad01611Sagc * may be used to endorse or promote products derived from this software 22aad01611Sagc * without specific prior written permission. 23aad01611Sagc * 24aad01611Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25aad01611Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26aad01611Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27aad01611Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28aad01611Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29aad01611Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30aad01611Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31aad01611Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32aad01611Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33aad01611Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34aad01611Sagc * SUCH DAMAGE. 35aad01611Sagc * 36aad01611Sagc * @(#)pccons.c 5.11 (Berkeley) 5/21/91 37aad01611Sagc */ 38aad01611Sagc 39aad01611Sagc /*- 40aad01611Sagc * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. 41aad01611Sagc * 42aad01611Sagc * This code is derived from software contributed to Berkeley by 43aad01611Sagc * William Jolitz and Don Ahn. 44aad01611Sagc * 45b7abba77Ssoda * Copyright (c) 1994 Charles M. Hannum. 46b7abba77Ssoda * Copyright (c) 1992, 1993 Erik Forsberg. 47b7abba77Ssoda * 48b7abba77Ssoda * Redistribution and use in source and binary forms, with or without 49b7abba77Ssoda * modification, are permitted provided that the following conditions 50b7abba77Ssoda * are met: 51b7abba77Ssoda * 1. Redistributions of source code must retain the above copyright 52b7abba77Ssoda * notice, this list of conditions and the following disclaimer. 53b7abba77Ssoda * 2. Redistributions in binary form must reproduce the above copyright 54b7abba77Ssoda * notice, this list of conditions and the following disclaimer in the 55b7abba77Ssoda * documentation and/or other materials provided with the distribution. 56b7abba77Ssoda * 3. All advertising materials mentioning features or use of this software 57b7abba77Ssoda * must display the following acknowledgement: 58b7abba77Ssoda * This product includes software developed by the University of 59b7abba77Ssoda * California, Berkeley and its contributors. 60b7abba77Ssoda * 4. Neither the name of the University nor the names of its contributors 61b7abba77Ssoda * may be used to endorse or promote products derived from this software 62b7abba77Ssoda * without specific prior written permission. 63b7abba77Ssoda * 64b7abba77Ssoda * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 65b7abba77Ssoda * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 66b7abba77Ssoda * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 67b7abba77Ssoda * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 68b7abba77Ssoda * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 69b7abba77Ssoda * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 70b7abba77Ssoda * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 71b7abba77Ssoda * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 72b7abba77Ssoda * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 73b7abba77Ssoda * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 74b7abba77Ssoda * SUCH DAMAGE. 75b7abba77Ssoda * 76b7abba77Ssoda * @(#)pccons.c 5.11 (Berkeley) 5/21/91 77b7abba77Ssoda */ 78b7abba77Ssoda 79b7abba77Ssoda struct pccons_config { 80b7abba77Ssoda bus_addr_t pc_mono_iobase, pc_mono_memaddr; 81b7abba77Ssoda bus_addr_t pc_cga_iobase, pc_cga_memaddr; 82b7abba77Ssoda bus_addr_t pc_kbd_cmdp, pc_kbd_datap; 83b7abba77Ssoda 847fe2a5a0Stsutsui void (*pc_init)(void); 85b7abba77Ssoda }; 86b7abba77Ssoda 87b7abba77Ssoda struct pccons_kbd_context { 88b7abba77Ssoda bus_space_tag_t pkc_iot; 89b7abba77Ssoda bus_space_handle_t pkc_cmd_ioh, pkc_data_ioh; 90b7abba77Ssoda 91b7abba77Ssoda int pkc_initialized; 92b7abba77Ssoda }; 93b7abba77Ssoda 94b7abba77Ssoda struct pccons_context { 95b7abba77Ssoda struct pccons_kbd_context pc_pkc; 96b7abba77Ssoda 97b7abba77Ssoda bus_space_tag_t pc_crt_iot, pc_crt_memt; 98b7abba77Ssoda 99b7abba77Ssoda bus_space_handle_t pc_6845_ioh, pc_crt_memh; 100b7abba77Ssoda 101b7abba77Ssoda bus_space_handle_t pc_mono_ioh, pc_mono_memh; 102b7abba77Ssoda bus_space_handle_t pc_cga_ioh, pc_cga_memh; 103b7abba77Ssoda 104b7abba77Ssoda struct pccons_config *pc_config; 105b7abba77Ssoda 106b7abba77Ssoda int pc_initialized; 107b7abba77Ssoda }; 108b7abba77Ssoda 109b7abba77Ssoda struct tty; 110b7abba77Ssoda 111b7abba77Ssoda struct pc_softc { 112*7b161854Stsutsui device_t sc_dev; 113b7abba77Ssoda struct tty *sc_tty; 114b7abba77Ssoda 115b7abba77Ssoda #if 0 116b7abba77Ssoda struct pccons_context *sc_pc; /* pccons device software context */ 117b7abba77Ssoda #endif 118b7abba77Ssoda }; 119b7abba77Ssoda 120b7abba77Ssoda #define kbd_cmd_read_1() \ 121b7abba77Ssoda bus_space_read_1(pccons_console_context.pc_pkc.pkc_iot, \ 122b7abba77Ssoda pccons_console_context.pc_pkc.pkc_cmd_ioh, 0) 123b7abba77Ssoda #define kbd_data_read_1() \ 124b7abba77Ssoda bus_space_read_1(pccons_console_context.pc_pkc.pkc_iot, \ 125b7abba77Ssoda pccons_console_context.pc_pkc.pkc_data_ioh, 0) 126b7abba77Ssoda #define kbd_cmd_write_1(cmd) \ 127b7abba77Ssoda bus_space_write_1(pccons_console_context.pc_pkc.pkc_iot, \ 128b7abba77Ssoda pccons_console_context.pc_pkc.pkc_cmd_ioh, 0, cmd) 129b7abba77Ssoda #define kbd_data_write_1(data) \ 130b7abba77Ssoda bus_space_write_1(pccons_console_context.pc_pkc.pkc_iot, \ 131b7abba77Ssoda pccons_console_context.pc_pkc.pkc_data_ioh, 0, data) 132b7abba77Ssoda 133b7abba77Ssoda extern struct pccons_context pccons_console_context; 134b7abba77Ssoda 1357fe2a5a0Stsutsui void kbd_context_init(bus_space_tag_t, struct pccons_config *); 1367fe2a5a0Stsutsui int kbc_put8042cmd(u_char); 1377fe2a5a0Stsutsui void kbd_flush_input(void); 138b7abba77Ssoda 1397fe2a5a0Stsutsui int pccons_common_match(bus_space_tag_t, 1407fe2a5a0Stsutsui bus_space_tag_t, bus_space_tag_t, struct pccons_config *); 1417fe2a5a0Stsutsui void pccons_common_attach(struct pc_softc *, bus_space_tag_t, 1427fe2a5a0Stsutsui bus_space_tag_t, bus_space_tag_t, struct pccons_config *); 1437fe2a5a0Stsutsui void pccons_common_cnattach(bus_space_tag_t, bus_space_tag_t, 1447fe2a5a0Stsutsui bus_space_tag_t, struct pccons_config *); 1457fe2a5a0Stsutsui int pcintr(void *); 146