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