summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/sys/polled_io.h
blob: 71bcbdc59d8431bb264a96fed62c77d4fd5c87a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _SYS_POLLED_IO_H
#define	_SYS_POLLED_IO_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct polled_device {
	/*
	 * This lock is only used to lock writing from
	 * the fields on the structure.  The values in the
	 * structure can be read under obp, so the lock
	 * isn't valid then.
	 */
	kmutex_t	polled_device_lock;

	/*
	 * When we switch over the console, this is the old value
	 * so that we can restore it later.
	 */
	uint64_t	polled_old_handle;

	/*
	 * Pointer to registerd polled I/O callbacks.
	 */
	cons_polledio_t	*polled_io;

} polled_device_t;

_NOTE(MUTEX_PROTECTS_DATA(polled_device_t::polled_device_lock,
	polled_device_t))

/*
 * The lower layers did not find any characters.
 */
#define	CIF_NO_CHARACTERS	((uint_t)-2)

/*
 * Every CIF has at least 3 arguments:  0 (name), 1 (in args), and 2 (out args).
 */
#define	CIF_MIN_SIZE		3

#define	CIF_NAME		0	/* name of function */
#define	CIF_NUMBER_IN_ARGS	1	/* number of arguments passed in */
#define	CIF_NUMBER_OUT_ARGS	2	/* number of arguments for return */
#define	CIF_BUFFER_ADDRESS	3	/* address to write data */
#define	CIF_BUFFER_LENGTH	4	/* length of BUFFER_ADDRESS */
#define	CIF_RETURN_VALUE	5	/* return status of operation */


/*
 * This is the size of the structure that we are expecting to be passed
 * in.  This is based on CIF_MIN_SIZE + address + length + value (see above)
 */
#define	CIF_SIZE		6	/* size of cif structure */

/*
 * These are the types of polled I/O that this module handles.
 */
typedef enum polled_io_console_type {
	POLLED_IO_CONSOLE_INPUT = 0,
	POLLED_IO_CONSOLE_OUTPUT = 1
} polled_io_console_type_t;

/*
 * Initialize the polled I/O kernel structures
 */
void	polled_io_init(void);

/*
 * De-initialize the polled I/O kernel structures
 */
void	polled_io_fini(void);

/*
 * Register a device to be used as a console for OBP.
 */
int	polled_io_register_callbacks(cons_polledio_t *, int);

/*
 * Unregister a device to be used as a console for OBP.
 */
int	polled_io_unregister_callbacks(cons_polledio_t *, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_POLLED_IO_H */