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
|
title "CAT Bus Lock Routines"
;++
;
; Module Name:
;
; ncrcatlk.asm
;
; Abstract:
;
; Procedures necessary to lock CAT bus.
;
; Author:
;
; Rick Ulmer (rick.ulmer@columbiasc.ncr.com) 29 Apr 1993
;
; Revision History:
;
;
;--
.386p
.xlist
include hal386.inc
include callconv.inc ; calling convention macros
include mac386.inc
.list
extrn _HalpCatBusLock:DWORD
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
;
; Hold the value of the eflags register before a CAT bus spinlock is
; acquired (used in HalpAcquire/ReleaseCatBusSpinLock().
;
_HalpCatBusFlags dd 0
_DATA ends
subttl "HalpAcquireCatBusSpinLock"
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
;++
;
; Routine Description:
;
; Acquires a spinlock to access the CAT bus. The CAT bus is
; accessed at different irql levels, so to be safe, we 'cli'.
; We could replace that to raise irql to PROFILE_LEVEL, but that's
; a lot of code.
;
; Arguments:
;
; None
;
; Return Value:
;
; Interrupt is disabled.
; Irql level not affected.
; Flags saved in _HalpCatBusLockFlags.
;--
cPublicProc _HalpAcquireCatBusSpinLock ,0
push eax
align 4
HArsl01:
pushfd
cli
lea eax, _HalpCatBusLock
ACQUIRE_SPINLOCK eax, HArsl90
pop _HalpCatBusFlags ; save flags for release S.L.
pop eax
stdRET _HalpAcquireCatBusSpinLock
align 4
HArsl90:
popfd
SPIN_ON_SPINLOCK eax, <HArsl01>
stdENDP _HalpAcquireCatBusSpinLock
subttl "HalpReleaseCatBusSpinLock"
;++
;
; Routine Description:
;
; Release spinlock, and restore flags to the state it was before
; acquiring the spinlock.
;
; Arguments:
;
; None
;
; Return Value:
;
; Interrupts restored to their state before acquiring spinlock.
; Irql level not affected.
;
;--
cPublicProc _HalpReleaseCatBusSpinLock ,0
push eax
;
; restore eflags as it was before acquiring spinlock. Put it on
; stack before releasing spinlock (so other cpus cannot overwrite
; it with their own eflags).
;
push _HalpCatBusFlags ; old eflags on stack.
lea eax, _HalpCatBusLock
RELEASE_SPINLOCK eax
popfd ; restore eflags.
pop eax
stdRET _HalpReleaseCatBusSpinLock
stdENDP _HalpReleaseCatBusSpinLock
_TEXT ends
end
|