1*03335d0bStsutsui /* $NetBSD: dtvar.h,v 1.6 2011/06/04 01:37:36 tsutsui Exp $ */ 29aa9b8ebSad 39aa9b8ebSad /*- 49aa9b8ebSad * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. 59aa9b8ebSad * All rights reserved. 69aa9b8ebSad * 79aa9b8ebSad * This code is derived from software contributed to The NetBSD Foundation 89aa9b8ebSad * by Andrew Doran. 99aa9b8ebSad * 109aa9b8ebSad * Redistribution and use in source and binary forms, with or without 119aa9b8ebSad * modification, are permitted provided that the following conditions 129aa9b8ebSad * are met: 139aa9b8ebSad * 1. Redistributions of source code must retain the above copyright 149aa9b8ebSad * notice, this list of conditions and the following disclaimer. 159aa9b8ebSad * 2. Redistributions in binary form must reproduce the above copyright 169aa9b8ebSad * notice, this list of conditions and the following disclaimer in the 179aa9b8ebSad * documentation and/or other materials provided with the distribution. 189aa9b8ebSad * 199aa9b8ebSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 209aa9b8ebSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 219aa9b8ebSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 229aa9b8ebSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 239aa9b8ebSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 249aa9b8ebSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 259aa9b8ebSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 269aa9b8ebSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 279aa9b8ebSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 289aa9b8ebSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 299aa9b8ebSad * POSSIBILITY OF SUCH DAMAGE. 309aa9b8ebSad */ 319aa9b8ebSad 329aa9b8ebSad #ifndef _DTVAR_H_ 339aa9b8ebSad #define _DTVAR_H_ 349aa9b8ebSad 359aa9b8ebSad #define DT_DEVICE_NO(a) (((a) - DT_ADDR_FIRST) >> 1) 36520489e1Sad #define DT_GET_SHORT(b0, b1) (((b0) << 8) | (b1)) 379aa9b8ebSad 389aa9b8ebSad struct dt_msg { 399aa9b8ebSad uint8_t dst; 409aa9b8ebSad uint8_t src; 41520489e1Sad uint8_t ctl; 429aa9b8ebSad 439aa9b8ebSad /* varzise, checksum byte at end */ 449aa9b8ebSad uint8_t body[DT_MAX_MSG_SIZE-3]; 459aa9b8ebSad 469aa9b8ebSad union { 479aa9b8ebSad SLIST_ENTRY(dt_msg) slist; 489aa9b8ebSad SIMPLEQ_ENTRY(dt_msg) simpleq; 499aa9b8ebSad } chain; 509aa9b8ebSad }; 519aa9b8ebSad 52520489e1Sad #define DT_CTL(l, s, p) \ 53520489e1Sad ((l & 0x1f) | ((s & 0x03) << 5) | ((p & 0x01) << 7)) 54520489e1Sad #define DT_CTL_P(c) ((c >> 7) & 0x01) 55520489e1Sad #define DT_CTL_SUBADDR(c) ((c >> 5) & 0x03) 56520489e1Sad #define DT_CTL_LEN(c) (c & 0x1f) 57520489e1Sad 589aa9b8ebSad struct dt_device { 59*03335d0bStsutsui void *dtdv_arg; 60520489e1Sad void (*dtdv_handler)(void *, struct dt_msg *); 619aa9b8ebSad }; 629aa9b8ebSad 639aa9b8ebSad struct dt_state { 649aa9b8ebSad volatile u_int *ds_data; 659aa9b8ebSad volatile u_int *ds_poll; 669aa9b8ebSad int ds_bad_pkts; 679aa9b8ebSad int ds_state; 689aa9b8ebSad int ds_escaped; 699aa9b8ebSad int ds_len; 709aa9b8ebSad int ds_ptr; 719aa9b8ebSad }; 729aa9b8ebSad 739aa9b8ebSad struct dt_softc { 74*03335d0bStsutsui device_t sc_dev; 759aa9b8ebSad struct dt_msg sc_msg; 76520489e1Sad void *sc_sih; 779aa9b8ebSad SLIST_HEAD(, dt_msg) sc_free; 78520489e1Sad SIMPLEQ_HEAD(, dt_msg) sc_queue; 799aa9b8ebSad }; 809aa9b8ebSad 819aa9b8ebSad struct dt_attach_args { 829aa9b8ebSad int dta_addr; 839aa9b8ebSad }; 849aa9b8ebSad 859aa9b8ebSad #define DT_GET_ERROR -1 869aa9b8ebSad #define DT_GET_DONE 0 879aa9b8ebSad #define DT_GET_NOTYET 1 889aa9b8ebSad 899aa9b8ebSad void dt_cninit(void); 909aa9b8ebSad int dt_identify(int, struct dt_ident *); 919aa9b8ebSad int dt_msg_get(struct dt_msg *, int); 92520489e1Sad void dt_msg_dump(struct dt_msg *); 93520489e1Sad int dt_establish_handler(struct dt_softc *, struct dt_device *, 94*03335d0bStsutsui void *, void (*)(void *, struct dt_msg *)); 959aa9b8ebSad 969aa9b8ebSad extern int dt_kbd_addr; 97520489e1Sad extern struct dt_device dt_kbd_dv; 98520489e1Sad extern int dt_ms_addr; 99520489e1Sad extern struct dt_device dt_ms_dv; 1009aa9b8ebSad extern struct dt_state dt_state; 1019aa9b8ebSad 1029aa9b8ebSad #endif /* !_DTVAR_H_ */ 103