Deleted Added
full compact
subr_hal.c (128447) subr_hal.c (132973)
1/*
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_hal.c 128447 2004-04-19 22:39:04Z wpaul $");
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_hal.c 132973 2004-08-01 20:04:31Z wpaul $");
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/errno.h>
39
40#include <sys/callout.h>
41#include <sys/kernel.h>
42#include <sys/lock.h>

--- 6 unchanged lines hidden (view full) ---

49#include <machine/bus_memio.h>
50#include <machine/bus_pio.h>
51#include <machine/bus.h>
52
53#include <sys/bus.h>
54#include <sys/rman.h>
55
56#include <compat/ndis/pe_var.h>
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/errno.h>
39
40#include <sys/callout.h>
41#include <sys/kernel.h>
42#include <sys/lock.h>

--- 6 unchanged lines hidden (view full) ---

49#include <machine/bus_memio.h>
50#include <machine/bus_pio.h>
51#include <machine/bus.h>
52
53#include <sys/bus.h>
54#include <sys/rman.h>
55
56#include <compat/ndis/pe_var.h>
57#include <compat/ndis/hal_var.h>
58#include <compat/ndis/ntoskrnl_var.h>
57#include <compat/ndis/ntoskrnl_var.h>
58#include <compat/ndis/hal_var.h>
59
60#define FUNC void(*)(void)
61
62__stdcall static void hal_stall_exec_cpu(uint32_t);
63__stdcall static void hal_writeport_buf_ulong(uint32_t *,
64 uint32_t *, uint32_t);
65__stdcall static void hal_writeport_buf_ushort(uint16_t *,
66 uint16_t *, uint32_t);

--- 180 unchanged lines hidden (view full) ---

247 * DISPATCH_LEVEL. Make sense? Good.
248 *
249 * According to the Microsoft documentation, any thread that calls
250 * KeAcquireSpinLock() must be running at IRQL <= DISPATCH_LEVEL. If
251 * we detect someone trying to acquire a spinlock from DEVICE_LEVEL
252 * or HIGH_LEVEL, we panic.
253 */
254
59
60#define FUNC void(*)(void)
61
62__stdcall static void hal_stall_exec_cpu(uint32_t);
63__stdcall static void hal_writeport_buf_ulong(uint32_t *,
64 uint32_t *, uint32_t);
65__stdcall static void hal_writeport_buf_ushort(uint16_t *,
66 uint16_t *, uint32_t);

--- 180 unchanged lines hidden (view full) ---

247 * DISPATCH_LEVEL. Make sense? Good.
248 *
249 * According to the Microsoft documentation, any thread that calls
250 * KeAcquireSpinLock() must be running at IRQL <= DISPATCH_LEVEL. If
251 * we detect someone trying to acquire a spinlock from DEVICE_LEVEL
252 * or HIGH_LEVEL, we panic.
253 */
254
255__stdcall uint8_t
256hal_lock(/*lock*/void)
255__fastcall uint8_t
256hal_lock(REGARGS1(kspin_lock *lock))
257{
257{
258 kspin_lock *lock;
259 uint8_t oldirql;
260
258 uint8_t oldirql;
259
261 __asm__ __volatile__ ("" : "=c" (lock));
262
263 /* I am so going to hell for this. */
264 if (hal_irql() > DISPATCH_LEVEL)
265 panic("IRQL_NOT_LESS_THAN_OR_EQUAL");
266
267 oldirql = FASTCALL1(hal_raise_irql, DISPATCH_LEVEL);
268 FASTCALL1(ntoskrnl_lock_dpc, lock);
269
270 return(oldirql);
271}
272
260 /* I am so going to hell for this. */
261 if (hal_irql() > DISPATCH_LEVEL)
262 panic("IRQL_NOT_LESS_THAN_OR_EQUAL");
263
264 oldirql = FASTCALL1(hal_raise_irql, DISPATCH_LEVEL);
265 FASTCALL1(ntoskrnl_lock_dpc, lock);
266
267 return(oldirql);
268}
269
273__stdcall void
274hal_unlock(/*lock, newirql*/void)
270__fastcall void
271hal_unlock(REGARGS2(kspin_lock *lock, uint8_t newirql))
275{
272{
276 kspin_lock *lock;
277 uint8_t newirql;
278
279 __asm__ __volatile__ ("" : "=c" (lock), "=d" (newirql));
280
281 FASTCALL1(ntoskrnl_unlock_dpc, lock);
282 FASTCALL1(hal_lower_irql, newirql);
283
284 return;
285}
286
287__stdcall uint8_t
288hal_irql(void)

--- 8 unchanged lines hidden (view full) ---

297 uint64_t *freq;
298{
299 if (freq != NULL)
300 *freq = hz;
301
302 return((uint64_t)ticks);
303}
304
273 FASTCALL1(ntoskrnl_unlock_dpc, lock);
274 FASTCALL1(hal_lower_irql, newirql);
275
276 return;
277}
278
279__stdcall uint8_t
280hal_irql(void)

--- 8 unchanged lines hidden (view full) ---

289 uint64_t *freq;
290{
291 if (freq != NULL)
292 *freq = hz;
293
294 return((uint64_t)ticks);
295}
296
305__stdcall uint8_t
306hal_raise_irql(/*irql*/ void)
297__fastcall uint8_t
298hal_raise_irql(REGARGS1(uint8_t irql))
307{
299{
308 uint8_t irql;
309 uint8_t oldirql;
310
300 uint8_t oldirql;
301
311 __asm__ __volatile__ ("" : "=c" (irql));
312
313 if (irql < hal_irql())
314 panic("IRQL_NOT_LESS_THAN");
315
316 if (hal_irql() == DISPATCH_LEVEL)
317 return(DISPATCH_LEVEL);
318
319 mtx_lock_spin(&sched_lock);
320 oldirql = curthread->td_base_pri;
321 sched_prio(curthread, PI_REALTIME);
322 curthread->td_base_pri = PI_REALTIME;
323 mtx_unlock_spin(&sched_lock);
324
325 return(oldirql);
326}
327
302 if (irql < hal_irql())
303 panic("IRQL_NOT_LESS_THAN");
304
305 if (hal_irql() == DISPATCH_LEVEL)
306 return(DISPATCH_LEVEL);
307
308 mtx_lock_spin(&sched_lock);
309 oldirql = curthread->td_base_pri;
310 sched_prio(curthread, PI_REALTIME);
311 curthread->td_base_pri = PI_REALTIME;
312 mtx_unlock_spin(&sched_lock);
313
314 return(oldirql);
315}
316
328__stdcall void
329hal_lower_irql(/*oldirql*/ void)
317__fastcall void
318hal_lower_irql(REGARGS1(uint8_t oldirql))
330{
319{
331 uint8_t oldirql;
332
333 __asm__ __volatile__ ("" : "=c" (oldirql));
334
335 if (oldirql == DISPATCH_LEVEL)
336 return;
337
338 if (hal_irql() != DISPATCH_LEVEL)
339 panic("IRQL_NOT_GREATER_THAN");
340
341 mtx_lock_spin(&sched_lock);
342 curthread->td_base_pri = oldirql;

--- 47 unchanged lines hidden ---
320 if (oldirql == DISPATCH_LEVEL)
321 return;
322
323 if (hal_irql() != DISPATCH_LEVEL)
324 panic("IRQL_NOT_GREATER_THAN");
325
326 mtx_lock_spin(&sched_lock);
327 curthread->td_base_pri = oldirql;

--- 47 unchanged lines hidden ---