]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/km.c
e04d3a636d7486957782b9b497538889507a59f4
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
24 * km.m - kernel keyboard/monitor module, procedural interface.
29 #include <sys/param.h>
32 #include <dev/ppc/cons.h>
34 #include <sys/systm.h>
36 #include <sys/fcntl.h> /* for kmopen */
37 #include <sys/errno.h>
38 #include <sys/proc.h> /* for kmopen */
39 #include <sys/msgbuf.h>
41 #include <dev/kmreg_com.h>
42 #include <pexpert/pexpert.h>
45 * 'Global' variables, shared only by this file and conf.c.
47 extern struct tty cons
;
48 struct tty
*km_tty
[1] = { &cons
};
51 * this works early on, after initialize_screen() but before autoconf (and thus
52 * before we have a kmDevice).
54 int disableConsoleOutput
;
57 * 'Global' variables, shared only by this file and kmDevice.m.
61 static int kmoutput(struct tty
*tp
);
62 static void kmtimeout(struct tty
*tp
);
63 static void kmstart(struct tty
*tp
);
65 extern void KeyboardOpen(void);
69 cons
.t_dev
= makedev(12, 0);
73 * cdevsw interface to km driver.
92 tp
= (struct tty
*)&cons
;
93 tp
->t_oproc
= kmstart
;
97 if ( !(tp
->t_state
& TS_ISOPEN
) ) {
98 tp
->t_iflag
= TTYDEF_IFLAG
;
99 tp
->t_oflag
= TTYDEF_OFLAG
;
100 tp
->t_cflag
= (CREAD
| CS8
| CLOCAL
);
101 tp
->t_lflag
= TTYDEF_LFLAG
;
102 tp
->t_ispeed
= tp
->t_ospeed
= TTYDEF_SPEED
;
103 termioschars(&tp
->t_termios
);
105 } else if ((tp
->t_state
& TS_XCLUDE
) && pp
->p_ucred
->cr_uid
!= 0)
108 tp
->t_state
|= TS_CARR_ON
; /* lie and say carrier exists and is on. */
109 ret
= ((*linesw
[tp
->t_line
].l_open
)(dev
, tp
));
113 /* Magic numbers. These are CHARWIDTH and CHARHEIGHT
114 * from osfmk/ppc/POWERMAC/video_console.c
120 PE_initialize_console(0, kPETextScreen
);
122 bzero(&video
, sizeof(video
));
123 PE_current_console(&video
);
124 if( video
.v_width
!= 0 && video
.v_height
!= 0 ) {
125 wp
->ws_col
= video
.v_width
/ wp
->ws_xpixel
;
126 wp
->ws_row
= video
.v_height
/ wp
->ws_ypixel
;
146 (*linesw
[tp
->t_line
].l_close
)(tp
,flag
);
157 register struct tty
*tp
;
160 return ((*linesw
[tp
->t_line
].l_read
)(tp
, uio
, ioflag
));
169 register struct tty
*tp
;
172 return ((*linesw
[tp
->t_line
].l_write
)(tp
, uio
, ioflag
));
184 struct tty
*tp
= &cons
;
192 wp
= (struct winsize
*)data
;
197 /* Prevent changing of console size --
198 * this ensures that login doesn't revert to the
199 * termcap-defined size
203 /* Bodge in the CLOCAL flag as the km device is always local */
207 register struct termios
*t
= (struct termios
*)data
;
208 t
->c_cflag
|= CLOCAL
;
212 error
= (*linesw
[tp
->t_line
].l_ioctl
)(tp
, cmd
, data
, flag
, p
);
216 error
= ttioctl (tp
, cmd
, data
, flag
, p
);
231 if( disableConsoleOutput
)
274 * Callouts from linesw.
277 #define KM_LOWAT_DELAY ((ns_time_t)1000)
284 if (tp
->t_state
& (TS_TIMEOUT
| TS_BUSY
| TS_TTSTOP
))
286 if (tp
->t_outq
.c_cc
== 0)
288 tp
->t_state
|= TS_BUSY
;
289 if (tp
->t_outq
.c_cc
> tp
->t_lowat
) {
301 timeout(kmtimeout
, tp
, hz
);
311 kmtimeout( struct tty
*tp
)
313 boolean_t funnel_state
;
315 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
317 (void) thread_funnel_set(kernel_flock
, FALSE
);
326 * FIXME - to be grokked...copied from m68k km.c.
334 while (tp
->t_outq
.c_cc
> 0) {
335 cc
= ndqb(&tp
->t_outq
, 0);
338 cc
= min(cc
, sizeof buf
);
339 (void) q_to_b(&tp
->t_outq
, buf
, cc
);
340 for (cp
= buf
; cp
< &buf
[cc
]; cp
++) {
344 if (tp
->t_outq
.c_cc
> 0) {
345 timeout(kmtimeout
, tp
, hz
);
347 tp
->t_state
&= ~TS_BUSY
;
354 struct tty
*tp
= &cons
;
355 boolean_t funnel_state
;
358 (*linesw
[tp
->t_line
].l_rint
) (ch
, tp
);