1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #include <sys/stropts.h> 29*0Sstevel@tonic-gate #include <sys/devops.h> 30*0Sstevel@tonic-gate #include <sys/modctl.h> 31*0Sstevel@tonic-gate #include <sys/ddi.h> 32*0Sstevel@tonic-gate #include <sys/sunddi.h> 33*0Sstevel@tonic-gate #include <sys/promif.h> 34*0Sstevel@tonic-gate #include <sys/note.h> 35*0Sstevel@tonic-gate #include <sys/consdev.h> 36*0Sstevel@tonic-gate #include <sys/polled_io.h> 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate /* 39*0Sstevel@tonic-gate * consconfig is aware of which devices are the stdin and stout. The 40*0Sstevel@tonic-gate * post-attach/pre-detach functions are an extension of consconfig because 41*0Sstevel@tonic-gate * they know about the dynamic changes to the stdin device. Neither an 42*0Sstevel@tonic-gate * individual driver nor the DDI framework knows what device is really the 43*0Sstevel@tonic-gate * stdin. 44*0Sstevel@tonic-gate */ 45*0Sstevel@tonic-gate /* 46*0Sstevel@tonic-gate * Issues: 47*0Sstevel@tonic-gate * o There are probably race conditions between vx_handler for "read" 48*0Sstevel@tonic-gate * being called by OBP and the update of the polled_input_t 49*0Sstevel@tonic-gate * structure. We need to be careful how the structure is updated. 50*0Sstevel@tonic-gate * 51*0Sstevel@tonic-gate * Solaris/Intel note: While OBP is not in the picture, there are probably 52*0Sstevel@tonic-gate * similar issues with kmdb. 53*0Sstevel@tonic-gate */ 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #if defined(MAYBE_SOMETIME) 56*0Sstevel@tonic-gate static void polled_give_input(void); 57*0Sstevel@tonic-gate static void polled_take_input(void); 58*0Sstevel@tonic-gate static void polled_give_output(void); 59*0Sstevel@tonic-gate static void polled_take_output(void); 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate static void polled_io_register(cons_polledio_t *, 62*0Sstevel@tonic-gate polled_io_console_type_t, int); 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate static void polled_io_unregister(polled_io_console_type_t, int); 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* 68*0Sstevel@tonic-gate * Make the registered device become the console for OBP 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate static int polled_io_take_console(polled_io_console_type_t, int); 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate /* 73*0Sstevel@tonic-gate * Restore the old console device for OBP. 74*0Sstevel@tonic-gate */ 75*0Sstevel@tonic-gate static int polled_io_release_console(polled_io_console_type_t, int); 76*0Sstevel@tonic-gate #endif /* MAYBE_SOMETIME */ 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate static polled_device_t polled_input_device; 79*0Sstevel@tonic-gate static polled_device_t polled_output_device; 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* 82*0Sstevel@tonic-gate * This routine is called to initialize polled I/O. We insert our entry 83*0Sstevel@tonic-gate * points so that OBP will call into this code when the switch is thrown 84*0Sstevel@tonic-gate * in polled_io_take_console(). 85*0Sstevel@tonic-gate */ 86*0Sstevel@tonic-gate void 87*0Sstevel@tonic-gate polled_io_init(void) 88*0Sstevel@tonic-gate { 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * Initialize lock to protect multiple thread access to the 91*0Sstevel@tonic-gate * polled_input_device structure. This does not protect 92*0Sstevel@tonic-gate * us from access in OBP mode. 93*0Sstevel@tonic-gate */ 94*0Sstevel@tonic-gate mutex_init(&polled_input_device.polled_device_lock, 95*0Sstevel@tonic-gate NULL, MUTEX_DRIVER, NULL); 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate /* 98*0Sstevel@tonic-gate * Initialize lock to protect multiple thread access to the 99*0Sstevel@tonic-gate * polled_output_device structure. This does not protect 100*0Sstevel@tonic-gate * us from access in OBP mode. 101*0Sstevel@tonic-gate */ 102*0Sstevel@tonic-gate mutex_init(&polled_output_device.polled_device_lock, 103*0Sstevel@tonic-gate NULL, MUTEX_DRIVER, NULL); 104*0Sstevel@tonic-gate } 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate /* 107*0Sstevel@tonic-gate * Register a device for input or output. The polled_io structure 108*0Sstevel@tonic-gate * will be filled in with the callbacks that are appropriate for 109*0Sstevel@tonic-gate * that device. 110*0Sstevel@tonic-gate */ 111*0Sstevel@tonic-gate int 112*0Sstevel@tonic-gate polled_io_register_callbacks( 113*0Sstevel@tonic-gate cons_polledio_t *polled_io, 114*0Sstevel@tonic-gate int flags 115*0Sstevel@tonic-gate ) 116*0Sstevel@tonic-gate { 117*0Sstevel@tonic-gate #if defined(MAYBE_SOMETIME) 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * If the input structure entries are filled in, then register this 120*0Sstevel@tonic-gate * structure as an input device. 121*0Sstevel@tonic-gate */ 122*0Sstevel@tonic-gate if ((polled_io->cons_polledio_getchar != NULL) && 123*0Sstevel@tonic-gate (polled_io->cons_polledio_ischar != NULL)) { 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate polled_io_register(polled_io, 126*0Sstevel@tonic-gate POLLED_IO_CONSOLE_INPUT, flags); 127*0Sstevel@tonic-gate } 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate /* 130*0Sstevel@tonic-gate * If the output structure entries are filled in, then register this 131*0Sstevel@tonic-gate * structure as an output device. 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate if (polled_io->cons_polledio_putchar != NULL) { 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate polled_io_register(polled_io, 136*0Sstevel@tonic-gate POLLED_IO_CONSOLE_OUTPUT, flags); 137*0Sstevel@tonic-gate } 138*0Sstevel@tonic-gate #else 139*0Sstevel@tonic-gate _NOTE(ARGUNUSED(flags)) 140*0Sstevel@tonic-gate cons_polledio = polled_io; 141*0Sstevel@tonic-gate #endif 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate return (DDI_SUCCESS); 144*0Sstevel@tonic-gate } 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate /* 147*0Sstevel@tonic-gate * Unregister a device for console input/output. 148*0Sstevel@tonic-gate */ 149*0Sstevel@tonic-gate int 150*0Sstevel@tonic-gate polled_io_unregister_callbacks( 151*0Sstevel@tonic-gate cons_polledio_t *polled_io, 152*0Sstevel@tonic-gate int flags 153*0Sstevel@tonic-gate ) 154*0Sstevel@tonic-gate { 155*0Sstevel@tonic-gate #if defined(MAYBE_SOMETIME) 156*0Sstevel@tonic-gate /* 157*0Sstevel@tonic-gate * If polled_io is being used for input, then unregister it. 158*0Sstevel@tonic-gate */ 159*0Sstevel@tonic-gate if (polled_io == polled_input_device.polled_io) { 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate polled_io_unregister( 162*0Sstevel@tonic-gate POLLED_IO_CONSOLE_INPUT, flags); 163*0Sstevel@tonic-gate } 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* 166*0Sstevel@tonic-gate * If polled_io is being used for output, then unregister it. 167*0Sstevel@tonic-gate */ 168*0Sstevel@tonic-gate if (polled_io == polled_output_device.polled_io) { 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate polled_io_unregister( 171*0Sstevel@tonic-gate POLLED_IO_CONSOLE_OUTPUT, flags); 172*0Sstevel@tonic-gate } 173*0Sstevel@tonic-gate #else 174*0Sstevel@tonic-gate _NOTE(ARGUNUSED(polled_io,flags)) 175*0Sstevel@tonic-gate #endif /* MAYBE_SOMETIME */ 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate return (DDI_SUCCESS); 178*0Sstevel@tonic-gate } 179*0Sstevel@tonic-gate 180*0Sstevel@tonic-gate /* 181*0Sstevel@tonic-gate * This routine is called when we are done handling polled io. We will 182*0Sstevel@tonic-gate * remove all of our handlers and destroy any memory that we have allocated. 183*0Sstevel@tonic-gate */ 184*0Sstevel@tonic-gate void 185*0Sstevel@tonic-gate polled_io_fini() 186*0Sstevel@tonic-gate { 187*0Sstevel@tonic-gate /* 188*0Sstevel@tonic-gate * Destroy the mutexes, we will not need them anymore. 189*0Sstevel@tonic-gate */ 190*0Sstevel@tonic-gate mutex_destroy(&polled_input_device.polled_device_lock); 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate mutex_destroy(&polled_output_device.polled_device_lock); 193*0Sstevel@tonic-gate } 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate #if defined(MAYBE_SOMETIME) 196*0Sstevel@tonic-gate /* 197*0Sstevel@tonic-gate * Generic internal routine for registering a polled input or output device. 198*0Sstevel@tonic-gate */ 199*0Sstevel@tonic-gate /* ARGSUSED */ 200*0Sstevel@tonic-gate static void 201*0Sstevel@tonic-gate polled_io_register( 202*0Sstevel@tonic-gate cons_polledio_t *polled_io, 203*0Sstevel@tonic-gate polled_io_console_type_t type, 204*0Sstevel@tonic-gate int flags 205*0Sstevel@tonic-gate ) 206*0Sstevel@tonic-gate { 207*0Sstevel@tonic-gate switch (type) { 208*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_INPUT: 209*0Sstevel@tonic-gate /* 210*0Sstevel@tonic-gate * Grab the device lock, because we are going to access 211*0Sstevel@tonic-gate * protected structure entries. We do this before the 212*0Sstevel@tonic-gate * POLLED_IO_CONSOLE_OPEN_INPUT so that we serialize 213*0Sstevel@tonic-gate * registration. 214*0Sstevel@tonic-gate */ 215*0Sstevel@tonic-gate mutex_enter(&polled_input_device.polled_device_lock); 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate /* 218*0Sstevel@tonic-gate * Save the polled_io pointers so that we can access 219*0Sstevel@tonic-gate * them later. 220*0Sstevel@tonic-gate */ 221*0Sstevel@tonic-gate polled_input_device.polled_io = polled_io; 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gate mutex_exit(&polled_input_device.polled_device_lock); 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate /* 226*0Sstevel@tonic-gate * Tell the generic console framework to 227*0Sstevel@tonic-gate * repoint OBP's stdin to this keyboard device. 228*0Sstevel@tonic-gate */ 229*0Sstevel@tonic-gate (void) polled_io_take_console(type, 0); 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate break; 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_OUTPUT: 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * Grab the device lock, because we are going to access 236*0Sstevel@tonic-gate * protected structure entries. We do this before the 237*0Sstevel@tonic-gate * POLLED_IO_CONSOLE_OPEN_OUTPUT so that we serialize 238*0Sstevel@tonic-gate * registration. 239*0Sstevel@tonic-gate */ 240*0Sstevel@tonic-gate mutex_enter(&polled_output_device.polled_device_lock); 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate /* 243*0Sstevel@tonic-gate * Save the polled_io pointers so that we can access 244*0Sstevel@tonic-gate * them later. 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate polled_input_device.polled_io = polled_io; 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate mutex_exit(&polled_output_device.polled_device_lock); 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate break; 251*0Sstevel@tonic-gate } 252*0Sstevel@tonic-gate } 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate /* 255*0Sstevel@tonic-gate * Generic internal routine for unregistering a polled input or output device. 256*0Sstevel@tonic-gate */ 257*0Sstevel@tonic-gate /* ARGSUSED */ 258*0Sstevel@tonic-gate static void 259*0Sstevel@tonic-gate polled_io_unregister( 260*0Sstevel@tonic-gate polled_io_console_type_t type, 261*0Sstevel@tonic-gate int flags 262*0Sstevel@tonic-gate ) 263*0Sstevel@tonic-gate { 264*0Sstevel@tonic-gate switch (type) { 265*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_INPUT: 266*0Sstevel@tonic-gate /* 267*0Sstevel@tonic-gate * Tell the generic console framework to restore OBP's 268*0Sstevel@tonic-gate * old stdin pointers. 269*0Sstevel@tonic-gate */ 270*0Sstevel@tonic-gate (void) polled_io_release_console(type, 0); 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate /* 273*0Sstevel@tonic-gate * Grab the device lock, because we are going to access 274*0Sstevel@tonic-gate * protected structure entries. 275*0Sstevel@tonic-gate */ 276*0Sstevel@tonic-gate mutex_enter(&polled_input_device.polled_device_lock); 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate /* 279*0Sstevel@tonic-gate * We are closing the device, so get the value for the op 280*0Sstevel@tonic-gate * pointer. We use the polled_io structure to determine if 281*0Sstevel@tonic-gate * there is a device registered, so null the dev_ops 282*0Sstevel@tonic-gate * structure. 283*0Sstevel@tonic-gate */ 284*0Sstevel@tonic-gate polled_input_device.polled_io = NULL; 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate mutex_exit(&polled_input_device.polled_device_lock); 287*0Sstevel@tonic-gate 288*0Sstevel@tonic-gate break; 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_OUTPUT: 291*0Sstevel@tonic-gate /* 292*0Sstevel@tonic-gate * Grab the device lock, because we are going to access 293*0Sstevel@tonic-gate * protected structure entries. 294*0Sstevel@tonic-gate */ 295*0Sstevel@tonic-gate mutex_enter(&polled_output_device.polled_device_lock); 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate /* 298*0Sstevel@tonic-gate * We are closing the device, so get the value for the op 299*0Sstevel@tonic-gate * pointer. We use the polled_io structure to determine if 300*0Sstevel@tonic-gate * there is a device registered. 301*0Sstevel@tonic-gate */ 302*0Sstevel@tonic-gate polled_output_device.polled_io = NULL; 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate mutex_exit(&polled_output_device.polled_device_lock); 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate break; 307*0Sstevel@tonic-gate } 308*0Sstevel@tonic-gate } 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate /* 311*0Sstevel@tonic-gate * This is the routine that is called to throw the switch from boot 312*0Sstevel@tonic-gate * ownership of stdout/stdin to the kernel. 313*0Sstevel@tonic-gate */ 314*0Sstevel@tonic-gate /* ARGSUSED */ 315*0Sstevel@tonic-gate static int 316*0Sstevel@tonic-gate polled_io_take_console( 317*0Sstevel@tonic-gate polled_io_console_type_t type, 318*0Sstevel@tonic-gate int flags 319*0Sstevel@tonic-gate ) 320*0Sstevel@tonic-gate { 321*0Sstevel@tonic-gate switch (type) { 322*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_INPUT: 323*0Sstevel@tonic-gate /* 324*0Sstevel@tonic-gate * Perhaps this should be where we switch *sysp 325*0Sstevel@tonic-gate */ 326*0Sstevel@tonic-gate break; 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate case POLLED_IO_CONSOLE_OUTPUT: 329*0Sstevel@tonic-gate /* 330*0Sstevel@tonic-gate * Perhaps this should be where we switch *sysp 331*0Sstevel@tonic-gate */ 332*0Sstevel@tonic-gate break; 333*0Sstevel@tonic-gate } 334*0Sstevel@tonic-gate 335*0Sstevel@tonic-gate return (DDI_SUCCESS); 336*0Sstevel@tonic-gate } 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate /* 339*0Sstevel@tonic-gate * This routine gives control of console input/output back to ???. 340*0Sstevel@tonic-gate * 341*0Sstevel@tonic-gate * Solaris/Intel has nobody to give it back to. Hope we don't get here! 342*0Sstevel@tonic-gate */ 343*0Sstevel@tonic-gate /* ARGSUSED */ 344*0Sstevel@tonic-gate static int 345*0Sstevel@tonic-gate polled_io_release_console( 346*0Sstevel@tonic-gate polled_io_console_type_t type, 347*0Sstevel@tonic-gate int flags 348*0Sstevel@tonic-gate ) 349*0Sstevel@tonic-gate { 350*0Sstevel@tonic-gate cmn_err(CE_WARN, 351*0Sstevel@tonic-gate "polled_io_release_console: nobody to hand console back to"); 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate return (DDI_SUCCESS); 354*0Sstevel@tonic-gate } 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate /* 357*0Sstevel@tonic-gate * This is the routine that kmdb calls to save any state information 358*0Sstevel@tonic-gate * before using the input device. This routine, and all of the 359*0Sstevel@tonic-gate * routines that it calls, are responsible for saving any state 360*0Sstevel@tonic-gate * information so that it can be restored when polled mode is over. 361*0Sstevel@tonic-gate */ 362*0Sstevel@tonic-gate static void 363*0Sstevel@tonic-gate polled_give_input(void) 364*0Sstevel@tonic-gate { 365*0Sstevel@tonic-gate cons_polledio_t *polled_io; 366*0Sstevel@tonic-gate 367*0Sstevel@tonic-gate /* 368*0Sstevel@tonic-gate * We check the dev_ops pointer to see if there is an 369*0Sstevel@tonic-gate * input device that has been registered. 370*0Sstevel@tonic-gate */ 371*0Sstevel@tonic-gate polled_io = polled_input_device.polled_io; 372*0Sstevel@tonic-gate 373*0Sstevel@tonic-gate if (polled_io == NULL || polled_io->cons_polledio_enter == NULL) { 374*0Sstevel@tonic-gate return; 375*0Sstevel@tonic-gate } 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate /* 378*0Sstevel@tonic-gate * Call down to the lower layers to save the state. 379*0Sstevel@tonic-gate */ 380*0Sstevel@tonic-gate polled_io->cons_polledio_enter( 381*0Sstevel@tonic-gate polled_io->cons_polledio_argument); 382*0Sstevel@tonic-gate } 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate /* 385*0Sstevel@tonic-gate * This is the routine that kmdb calls when it is giving up control of the 386*0Sstevel@tonic-gate * input device. This routine, and the lower layer routines that it calls, 387*0Sstevel@tonic-gate * are responsible for restoring the controller state to the state it was 388*0Sstevel@tonic-gate * in before kmdb took control. 389*0Sstevel@tonic-gate */ 390*0Sstevel@tonic-gate static void 391*0Sstevel@tonic-gate polled_take_input(void) 392*0Sstevel@tonic-gate { 393*0Sstevel@tonic-gate cons_polledio_t *polled_io; 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate /* 396*0Sstevel@tonic-gate * We check the dev_ops pointer to see if there is an 397*0Sstevel@tonic-gate * input device that has been registered. 398*0Sstevel@tonic-gate */ 399*0Sstevel@tonic-gate polled_io = polled_input_device.polled_io; 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gate if (polled_io == NULL || polled_io->cons_polledio_exit == NULL) { 402*0Sstevel@tonic-gate return; 403*0Sstevel@tonic-gate } 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate /* 406*0Sstevel@tonic-gate * Call down to the lower layers to save the state. 407*0Sstevel@tonic-gate */ 408*0Sstevel@tonic-gate polled_io->cons_polledio_exit( 409*0Sstevel@tonic-gate polled_io->cons_polledio_argument); 410*0Sstevel@tonic-gate } 411*0Sstevel@tonic-gate 412*0Sstevel@tonic-gate /* 413*0Sstevel@tonic-gate * This is the routine that kmdb calls to save any state information 414*0Sstevel@tonic-gate * before using the output device. This routine, and all of the 415*0Sstevel@tonic-gate * routines that it calls, are responsible for saving any state 416*0Sstevel@tonic-gate * information so that it can be restored when polled mode is over. 417*0Sstevel@tonic-gate */ 418*0Sstevel@tonic-gate static void 419*0Sstevel@tonic-gate polled_give_output() 420*0Sstevel@tonic-gate { 421*0Sstevel@tonic-gate cons_polledio_t *polled_io; 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate /* 424*0Sstevel@tonic-gate * We check the dev_ops pointer to see if there is an 425*0Sstevel@tonic-gate * output device that has been registered. 426*0Sstevel@tonic-gate */ 427*0Sstevel@tonic-gate polled_io = polled_output_device.polled_io; 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate if (polled_io == NULL || polled_io->cons_polledio_enter == NULL) { 430*0Sstevel@tonic-gate return; 431*0Sstevel@tonic-gate } 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gate /* 434*0Sstevel@tonic-gate * Call down to the lower layers to save the state. 435*0Sstevel@tonic-gate */ 436*0Sstevel@tonic-gate polled_io->cons_polledio_enter( 437*0Sstevel@tonic-gate polled_io->cons_polledio_argument); 438*0Sstevel@tonic-gate } 439*0Sstevel@tonic-gate 440*0Sstevel@tonic-gate /* 441*0Sstevel@tonic-gate * This is the routine that kmdb calls when it is giving up control of the 442*0Sstevel@tonic-gate * output device. This routine, and the lower layer routines that it calls, 443*0Sstevel@tonic-gate * are responsible for restoring the controller state to the state it was 444*0Sstevel@tonic-gate * in before kmdb took control. 445*0Sstevel@tonic-gate */ 446*0Sstevel@tonic-gate static void 447*0Sstevel@tonic-gate polled_take_output(void) 448*0Sstevel@tonic-gate { 449*0Sstevel@tonic-gate cons_polledio_t *polled_io; 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate /* 452*0Sstevel@tonic-gate * We check the dev_ops pointer to see if there is an 453*0Sstevel@tonic-gate * output device that has been registered. 454*0Sstevel@tonic-gate */ 455*0Sstevel@tonic-gate polled_io = polled_output_device.polled_io; 456*0Sstevel@tonic-gate 457*0Sstevel@tonic-gate if (polled_io == NULL || polled_io->cons_polledio_exit == NULL) { 458*0Sstevel@tonic-gate return; 459*0Sstevel@tonic-gate } 460*0Sstevel@tonic-gate 461*0Sstevel@tonic-gate /* 462*0Sstevel@tonic-gate * Call down to the lower layers to save the state. 463*0Sstevel@tonic-gate */ 464*0Sstevel@tonic-gate polled_io->cons_polledio_exit( 465*0Sstevel@tonic-gate polled_io->cons_polledio_argument); 466*0Sstevel@tonic-gate } 467*0Sstevel@tonic-gate #endif /* MAYBE_SOMETIME */ 468