17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*fea9cb91Slq150181 * Common Development and Distribution License (the "License"). 6*fea9cb91Slq150181 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*fea9cb91Slq150181 227c478bd9Sstevel@tonic-gate /* 23*fea9cb91Slq150181 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*fea9cb91Slq150181 * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_POLLED_IO_H 287c478bd9Sstevel@tonic-gate #define _SYS_POLLED_IO_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate typedef struct polled_device { 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * This lock is only used to lock writing from 397c478bd9Sstevel@tonic-gate * the fields on the structure. The values in the 407c478bd9Sstevel@tonic-gate * structure can be read under obp, so the lock 417c478bd9Sstevel@tonic-gate * isn't valid then. 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate kmutex_t polled_device_lock; 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * When we switch over the console, this is the old value 477c478bd9Sstevel@tonic-gate * so that we can restore it later. 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate uint64_t polled_old_handle; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Pointer to registerd polled I/O callbacks. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate cons_polledio_t *polled_io; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate } polled_device_t; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(polled_device_t::polled_device_lock, 597c478bd9Sstevel@tonic-gate polled_device_t)) 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #define CIF_SUCCESS ((uint_t)0) 627c478bd9Sstevel@tonic-gate #define CIF_FAILURE ((uint_t)-1) 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * The lower layers did not find any characters. 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define CIF_NO_CHARACTERS ((uint_t)-2) 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* 707c478bd9Sstevel@tonic-gate * Every CIF has at least 3 arguments: 0 (name), 1 (in args), and 2 (out args). 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define CIF_MIN_SIZE 3 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define CIF_NAME 0 /* name of function */ 757c478bd9Sstevel@tonic-gate #define CIF_NUMBER_IN_ARGS 1 /* number of arguments passed in */ 767c478bd9Sstevel@tonic-gate #define CIF_NUMBER_OUT_ARGS 2 /* number of arguments for return */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * These are the types of polled I/O that this module handles. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate typedef enum polled_io_console_type { 827c478bd9Sstevel@tonic-gate POLLED_IO_CONSOLE_INPUT = 0, 837c478bd9Sstevel@tonic-gate POLLED_IO_CONSOLE_OUTPUT = 1 847c478bd9Sstevel@tonic-gate } polled_io_console_type_t; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * Initialize the polled I/O kernel structures 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate void polled_io_init(void); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * De-initialize the polled I/O kernel structures 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate void polled_io_fini(void); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Register a device to be used as a console for OBP. 987c478bd9Sstevel@tonic-gate */ 997c478bd9Sstevel@tonic-gate int polled_io_register_callbacks(cons_polledio_t *, int); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * Unregister a device to be used as a console for OBP. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate int polled_io_unregister_callbacks(cons_polledio_t *, int); 1057c478bd9Sstevel@tonic-gate 106*fea9cb91Slq150181 void polled_io_cons_write(uchar_t *, size_t); 107*fea9cb91Slq150181 1087c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate #endif 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #endif /* _SYS_POLLED_IO_H */ 113