Annotation of sys/arch/hppa/stand/libsa/itecons.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: itecons.c,v 1.9 2005/04/07 00:21:51 mickey Exp $ */
2:
3: /*
4: * Copyright (c) 1998-2004 Michael Shalayeff
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: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. 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: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22: * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25: * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26: * THE POSSIBILITY OF SUCH DAMAGE.
27: */
28: /*
29: * Copyright 1996 1995 by Open Software Foundation, Inc.
30: * All Rights Reserved
31: *
32: * Permission to use, copy, modify, and distribute this software and
33: * its documentation for any purpose and without fee is hereby granted,
34: * provided that the above copyright notice appears in all copies and
35: * that both the copyright notice and this permission notice appear in
36: * supporting documentation.
37: *
38: * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
39: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
40: * FOR A PARTICULAR PURPOSE.
41: *
42: * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
43: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
44: * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
45: * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
46: * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
47: *
48: */
49:
50: #include "libsa.h"
51:
52: #include <sys/param.h>
53: #include <sys/disklabel.h>
54: #include <machine/pdc.h>
55: #include <machine/iomod.h>
56: #include <dev/cons.h>
57:
58: #include "dev_hppa.h"
59:
60: iodcio_t cniodc; /* console IODC entry point */
61: iodcio_t kyiodc; /* keyboard IODC entry point */
62: pz_device_t *cons_pzdev, *kbd_pzdev;
63:
64: /*
65: * Console.
66: */
67:
68: char cnbuf[IODC_MINIOSIZ] __attribute__ ((aligned (IODC_MINIOSIZ)));
69: int kycode[IODC_MAXSIZE/sizeof(int)];
70:
71: int
72: cnspeed(dev, sp)
73: dev_t dev;
74: int sp;
75: {
76: return 9600;
77: }
78:
79: void
80: ite_probe(cn)
81: struct consdev *cn;
82: {
83: cniodc = (iodcio_t)PAGE0->mem_free;
84: cons_pzdev = &PAGE0->mem_cons;
85: kbd_pzdev = &PAGE0->mem_kbd;
86:
87: if ((*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, cons_pzdev->pz_hpa,
88: IODC_INIT, cniodc, IODC_MAXSIZE) < 0 ||
89: (*cniodc)(cons_pzdev->pz_hpa,
90: (cons_pzdev->pz_hpa==PAGE0->mem_boot.pz_hpa)?
91: IODC_INIT_DEV: IODC_INIT_ALL, cons_pzdev->pz_spa,
92: cons_pzdev->pz_layers, pdcbuf, 0,0,0,0) < 0 ||
93: (*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, cons_pzdev->pz_hpa,
94: IODC_IO, cniodc, IODC_MAXSIZE) < 0) {
95: /* morse code with the LED's?!! */
96: cons_pzdev->pz_iodc_io = kbd_pzdev->pz_iodc_io = NULL;
97: } else {
98: cn->cn_pri = CN_INTERNAL;
99: cn->cn_dev = makedev(0, 0);
100: }
101: }
102:
103: void
104: ite_init(cn)
105: struct consdev *cn;
106: {
107: /*
108: * If the keyboard is separate from the console output device,
109: * we load the keyboard code at `kycode'.
110: *
111: * N.B. In this case, since the keyboard code is part of the
112: * boot code, it will be overwritten when we load a kernel.
113: */
114: if (cons_pzdev->pz_class != PCL_DUPLEX ||
115: kbd_pzdev->pz_class == PCL_KEYBD) {
116:
117: kyiodc = (iodcio_t)kycode;
118:
119: if ((*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, kbd_pzdev->pz_hpa,
120: IODC_INIT, kyiodc, IODC_MAXSIZE) < 0 ||
121: (*kyiodc)(kbd_pzdev->pz_hpa,
122: (kbd_pzdev->pz_hpa == PAGE0->mem_boot.pz_hpa ||
123: kbd_pzdev->pz_hpa == cons_pzdev->pz_hpa)?
124: IODC_INIT_DEV: IODC_INIT_ALL, kbd_pzdev->pz_spa,
125: kbd_pzdev->pz_layers, pdcbuf, 0, 0, 0, 0) < 0 ||
126: (*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, kbd_pzdev->pz_hpa,
127: IODC_IO, kyiodc, IODC_MAXSIZE))
128: kyiodc = NULL;
129: } else {
130: kyiodc = cniodc;
131:
132: bcopy((char *)&PAGE0->mem_cons, (char *)&PAGE0->mem_kbd,
133: sizeof(struct pz_device));
134: }
135:
136: cons_pzdev->pz_iodc_io = (u_int)cniodc;
137: kbd_pzdev->pz_iodc_io = (u_int)kyiodc;
138: #ifdef DEBUG
139: if (!kyiodc)
140: printf("ite_init: no kbd\n");
141: #endif
142: }
143:
144: void
145: ite_putc(dev, c)
146: dev_t dev;
147: int c;
148: {
149: if (cniodc == NULL)
150: return;
151:
152: *cnbuf = c;
153:
154: (*cniodc)(cons_pzdev->pz_hpa, IODC_IO_CONSOUT, cons_pzdev->pz_spa,
155: cons_pzdev->pz_layers, pdcbuf, 0, cnbuf, 1, 0);
156: }
157:
158: /*
159: * since i don't know how to 'just check the char available'
160: * i store the key into the stash removing on read op later;
161: */
162: int
163: ite_getc(dev)
164: dev_t dev;
165: {
166: static int stash = 0;
167: int err, c, l, i;
168:
169: if (kyiodc == NULL)
170: return(0x100);
171:
172: if (stash) {
173: c = stash;
174: if (!(dev & 0x80))
175: stash = 0;
176: return c;
177: }
178:
179: i = 16;
180: do {
181: err = (*kyiodc)(kbd_pzdev->pz_hpa, IODC_IO_CONSIN,
182: kbd_pzdev->pz_spa, kbd_pzdev->pz_layers,
183: pdcbuf, 0, cnbuf, 1, 0);
184: l = pdcbuf[0];
185: c = cnbuf[0];
186: #ifdef DEBUG
187: if (debug && err < 0)
188: printf("KBD input error: %d", err);
189: #endif
190:
191: /* if we are doing ischar() report immidiatelly */
192: if (!i-- && (dev & 0x80) && l == 0) {
193: #ifdef DEBUG
194: if (debug > 2)
195: printf("ite_getc(0x%x): no char %d(%x)\n",
196: dev, l, c);
197: #endif
198: return (0);
199: }
200: } while(!l);
201:
202: #if DEBUG
203: if (debug && l > 1)
204: printf("KBD input got too much (%d)\n", l);
205:
206: if (debug > 3)
207: printf("kbd: \'%c\' (0x%x)\n", c, c);
208: #endif
209: if (dev & 0x80)
210: stash = c;
211:
212: return (c);
213: }
214:
215: void
216: ite_pollc(dev, on)
217: dev_t dev;
218: int on;
219: {
220:
221: }
CVSweb