summaryrefslogtreecommitdiff
path: root/usr/src/uts/i86pc/sys/acpidev_impl.h
blob: c01ea9f5cb68dfa6ef6fac90a93522ed180d3a99 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (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) 2009-2010, Intel Corporation.
 * All rights reserved.
 */

#ifndef	_SYS_ACPIDEV_IMPL_H
#define	_SYS_ACPIDEV_IMPL_H
#include <sys/types.h>
#include <sys/cmn_err.h>
#include <sys/bitmap.h>
#include <sys/synch.h>
#include <sys/sunddi.h>
#include <sys/acpi/acpi.h>
#include <sys/acpica.h>
#include <sys/acpidev.h>
#include <sys/acpidev_dr.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef	_KERNEL

#define	ACPIDEV_ARRAY_PARAM(a)		(a), (sizeof (a) / sizeof ((a)[0]))

/* Debug support facilities. */
extern int acpidev_debug;
#define	ACPIDEV_DEBUG(lvl, ...)	if (acpidev_debug) cmn_err((lvl), __VA_ARGS__)

/* Data attached to an ACPI object to maintain device status information. */
struct acpidev_data_impl {
	uint32_t			aod_eflag;	/* External flags */
	uint32_t			aod_iflag;	/* Internal flags */
	uint32_t			aod_level;
	int				aod_status;	/* Cached _STA value */
	ACPI_HANDLE			*aod_hdl;
	dev_info_t			*aod_dip;
	acpidev_class_t			*aod_class;
	acpidev_class_list_t		**aod_class_list;
	acpidev_board_type_t		aod_bdtype;	/* Type of board. */
	uint32_t			aod_bdnum;	/* Board # for DR. */
	uint32_t			aod_portid;	/* Port id for DR. */
	uint32_t			aod_bdidx;	/* Index # of AP */
	volatile uint32_t		aod_chidx;	/* Index # of child */
	uint32_t			aod_memidx;	/* Index # of memory */
	acpidev_class_id_t		aod_class_id;	/* Dev type for DR. */
};

#define	ACPIDEV_ODF_STATUS_VALID	0x1
#define	ACPIDEV_ODF_DEVINFO_CREATED	0x2
#define	ACPIDEV_ODF_DEVINFO_TAGGED	0x4
#define	ACPIDEV_ODF_HOTPLUG_CAPABLE	0x100
#define	ACPIDEV_ODF_HOTPLUG_READY	0x200
#define	ACPIDEV_ODF_HOTPLUG_FAILED	0x400

#define	ACPIDEV_DR_IS_BOARD(hdl)	\
	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_CAPABLE)

#define	ACPIDEV_DR_SET_BOARD(hdl)	\
	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_CAPABLE

#define	ACPIDEV_DR_IS_READY(hdl)	\
	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_READY)

#define	ACPIDEV_DR_SET_READY(hdl)	\
	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_READY

#define	ACPIDEV_DR_IS_FAILED(hdl)	\
	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_FAILED)

#define	ACPIDEV_DR_SET_FAILED(hdl)	\
	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_FAILED

#define	ACPIDEV_DR_IS_WORKING(hdl)	\
	(((hdl)->aod_iflag & (ACPIDEV_ODF_HOTPLUG_READY | \
	ACPIDEV_ODF_HOTPLUG_FAILED)) == ACPIDEV_ODF_HOTPLUG_READY)

#define	ACPIDEV_DR_IS_PROCESSED(hdl)	\
	((hdl)->aod_iflag & (ACPIDEV_ODF_HOTPLUG_READY | \
	ACPIDEV_ODF_HOTPLUG_FAILED | ACPIDEV_ODF_HOTPLUG_CAPABLE))

#define	ACPIDEV_DR_BOARD_READY(hdl)	\
	(((hdl)->aod_iflag & \
	(ACPIDEV_ODF_HOTPLUG_READY | ACPIDEV_ODF_HOTPLUG_CAPABLE)) == \
	(ACPIDEV_ODF_HOTPLUG_READY | ACPIDEV_ODF_HOTPLUG_CAPABLE))

/*
 * List of registered device class drivers.
 * Class drivers on the same list will be called from head to tail in turn.
 */
struct acpidev_class_list {
	acpidev_class_list_t		*acl_next;
	acpidev_class_t			*acl_class;
};

typedef struct acpidev_pseudo_uid {
	struct acpidev_pseudo_uid	*apu_next;
	char				*apu_uid;
	acpidev_class_id_t		apu_cid;
	uint_t				apu_nid;
} acpidev_pseudo_uid_t;

typedef struct acpidev_pseudo_uid_head {
	kmutex_t			apuh_lock;
	uint32_t			apuh_id;
	acpidev_pseudo_uid_t		*apuh_first;
} acpidev_pseudo_uid_head_t;

typedef struct acpidev_dr_capacity {
	uint_t				cpu_vendor;
	uint_t				cpu_family;
	uint_t				cpu_model_min;
	uint_t				cpu_model_max;
	uint_t				cpu_step_min;
	uint_t				cpu_step_max;
	boolean_t			hotplug_supported;
	uint64_t			memory_alignment;
} acpidev_dr_capacity_t;

extern int acpidev_dr_enable;
extern krwlock_t acpidev_class_lock;
extern ulong_t acpidev_object_type_mask[BT_BITOUL(ACPI_TYPE_NS_NODE_MAX + 1)];
extern ACPI_TABLE_SRAT *acpidev_srat_tbl_ptr;
extern ACPI_TABLE_SLIT *acpidev_slit_tbl_ptr;

#endif	/* _KERNEL */

#ifdef __cplusplus
}
#endif

#endif	/* _SYS_ACPIDEV_IMPL_H */