]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * HISTORY | |
30 | * | |
31 | * Revision 1.1.1.1 1998/09/22 21:05:34 wsanchez | |
32 | * Import of Mac OS X kernel (~semeria) | |
33 | * | |
34 | * Revision 1.1.1.1 1998/03/07 02:25:54 wsanchez | |
35 | * Import of OSF Mach kernel (~mburg) | |
36 | * | |
37 | * Revision 1.1.6.1 1996/09/17 16:26:58 bruel | |
38 | * use standalone includes only | |
39 | * [1996/09/17 15:38:08 bruel] | |
40 | * | |
41 | * Revision 1.1.4.1 1996/02/02 12:16:40 emcmanus | |
42 | * Copied from nmk20b5_shared. | |
43 | * [1996/02/01 16:56:11 emcmanus] | |
44 | * | |
45 | * Revision 1.1.2.1 1995/12/30 17:12:07 emcmanus | |
46 | * Renamed from i386/etap_map.c and made this file machine-independent. | |
47 | * Delete declarations of event_table and subs_table, now declared with | |
48 | * different types in etap_macros.h. | |
49 | * [1995/12/30 17:03:55 emcmanus] | |
50 | * | |
51 | * Revision 1.1.2.4 1995/10/09 17:07:21 devrcs | |
52 | * Merged in RT3_SHARED ETAP code. | |
53 | * [1995/09/13 18:48:15 joe] | |
54 | * | |
55 | * Revision 1.1.2.3 1995/09/18 19:10:05 devrcs | |
56 | * Merged in RT3_SHARED ETAP code. | |
57 | * [1995/09/13 18:48:15 joe] | |
58 | * | |
59 | * Revision 1.1.2.2 1995/01/10 04:51:59 devrcs | |
60 | * mk6 CR801 - merge up from nmk18b4 to nmk18b7 | |
61 | * tweak signatures, a la osc1.3b26 | |
62 | * [1994/12/09 20:38:32 dwm] | |
63 | * | |
64 | * mk6 CR801 - new file for mk6_shared from cnmk_shared. | |
65 | * [1994/12/01 21:11:35 dwm] | |
66 | * | |
67 | * Revision 1.1.2.1 1994/10/21 18:35:57 joe | |
68 | * Initial ETAP submission | |
69 | * [1994/10/20 19:21:39 joe] | |
70 | * | |
71 | * $EndLog$ | |
72 | */ | |
73 | /* | |
74 | * File : etap_map.c | |
75 | * | |
76 | * Pseudo-device driver to calculate the virtual addresses | |
77 | * of all mappable ETAP buffers and tables: event table, | |
78 | * subsystem table, cumulative buffer and monitor buffers. | |
79 | * | |
80 | */ | |
81 | /* | |
82 | * Minor device number representation: | |
83 | * | |
84 | * 0 = ETAP_TABLE_EVENT | |
85 | * 1 = ETAP_TABLE_SUBSYSTEM | |
86 | * 2 = ETAP_BUFFER_CUMULATIVE | |
87 | * 3 & up = a specific monitor buffer | |
88 | * | |
89 | */ | |
90 | ||
91 | #include <types.h> | |
92 | ||
93 | #include <mach/vm_prot.h> | |
94 | #include <mach/vm_param.h> | |
95 | #include <mach/kern_return.h> | |
96 | #include <vm/pmap.h> | |
97 | #include <device/io_req.h> | |
98 | #include <device/dev_hdr.h> | |
99 | ||
100 | #include <cpus.h> | |
101 | #include <kern/etap_options.h> | |
102 | #include <mach/etap.h> | |
103 | #include <kern/etap_map.h> | |
104 | ||
105 | ||
106 | #if ETAP_LOCK_ACCUMULATE | |
107 | extern cumulative_buffer_t cbuff; | |
108 | #endif /* ETAP_LOCK_ACCUMULATE */ | |
109 | ||
110 | #if ETAP_MONITOR | |
111 | extern monitor_buffer_t mbuff[]; | |
112 | #endif /* ETAP_MONITOR */ | |
113 | ||
114 | ||
115 | /* | |
116 | * etap_map_open - Check for valid minor device | |
117 | */ | |
118 | ||
119 | io_return_t | |
120 | etap_map_open( | |
121 | dev_t dev, | |
122 | dev_mode_t flags, | |
123 | io_req_t ior) | |
124 | { | |
125 | int buffer = minor(dev); | |
126 | ||
127 | if (buffer >= ETAP_MAX_DEVICES) | |
128 | return(D_NO_SUCH_DEVICE); | |
129 | ||
130 | return(D_SUCCESS); | |
131 | } | |
132 | ||
133 | vm_offset_t | |
134 | etap_map_mmap ( | |
135 | dev_t dev, | |
136 | vm_offset_t off, | |
137 | vm_prot_t prot) | |
138 | { | |
139 | int buffer = minor(dev); | |
140 | vm_offset_t addr; | |
141 | ||
142 | /* | |
143 | * Check request validity | |
144 | */ | |
145 | ||
146 | if (prot & VM_PROT_WRITE) | |
147 | return(KERN_PROTECTION_FAILURE); | |
148 | ||
149 | if (buffer < 0 || buffer >= ETAP_MAX_DEVICES) | |
150 | return(KERN_INVALID_ARGUMENT); | |
151 | ||
152 | switch(buffer) { | |
153 | case ETAP_TABLE_EVENT : | |
154 | addr = trunc_page((char *) event_table) + off; | |
155 | break; | |
156 | case ETAP_TABLE_SUBSYSTEM : | |
157 | addr = trunc_page((char *) subs_table) + off; | |
158 | break; | |
159 | case ETAP_BUFFER_CUMULATIVE : | |
160 | #if ETAP_LOCK_ACCUMULATE | |
161 | addr = (vm_offset_t) cbuff + off; | |
162 | break; | |
163 | #else /* ETAP_LOCK_ACCUMULATE */ | |
164 | return(KERN_INVALID_ARGUMENT); | |
165 | #endif /* ETAP_LOCK_ACCUMULATE */ | |
166 | ||
167 | default : | |
168 | #if ETAP_MONITOR | |
169 | addr = (vm_offset_t) mbuff[buffer - 3] + off; | |
170 | break; | |
171 | #else /* ETAP_MONITOR */ | |
172 | return(KERN_INVALID_ARGUMENT); | |
173 | #endif /* ETAP_MONITOR */ | |
174 | ||
175 | } | |
176 | return machine_btop(pmap_extract(pmap_kernel(), addr)); | |
177 | } |