summaryrefslogtreecommitdiffstats
path: root/private/ntos/ke/alpha/byteme.s
blob: 67c934d4b8fcc3db6512a710331a1e1ab461c4de (plain) (blame)
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
//  TITLE("Byte and Short Emulation")
//++
//
//
// Copyright (c) 1995  Digital Equipment Corporation
//
// Module Name:
//
//    byteme.s
//
// Abstract:
//
//    This module implements the code to perform atomic store operations
//    on bytes and shorts (words). 
//
//    Atomic byte and short opcodes have been added into the Alpha
//    architecture as of Alpha 21164A or EV56. In chips 21164 and prior,
//    an illegal instruction will occur and an exception will lead them here.
//
// Author:
//
//    Wim Colgate, May 18th, 1995
//    Tom Van Baak, May 18th, 1995
//
// Environment:
//
//    Kernel mode only.
//
// Revision History:
//
//--

#include "ksalpha.h"

//++
//
// VOID
// KiInterlockedStoreByte(
//    IN PUCHAR Address,
//    IN UCHAR  Data
//    )
//
// Routine Description:
//
//    This routine stores the data byte specified by Data to the location
//    specified by Address. The architecture requires byte granularity,
//    so locking is necessary.
//
// Arguments:
//
//    Address(a0) - Supplies a pointer to byte data value.
//    Data(a1) - Supplied the byte data value to store.
//
// Return Value:
//
//    None
//
//--

        LEAF_ENTRY(KiInterlockedStoreByte)

        bic     a0, 3, t0               // clear low 3 bits
        and     a0, 3, t1               // mask of three low bits
10:
        ldl_l   t2, 0(t0)               // load locked full longword
        insbl   a1, t1, t3              // insert byte low
        mskbl   t2, t1, t2              // mask byte low
        bis     t2, t3, t2              // merge data
        stl_c   t2, 0(t0)               // store conditional
        beq     t2, 20f                 // failed to store, retry, forward
                                        // branch for optimistic prediction

        ret     zero, (ra), 1           // return

20:
        br      zero, 10b               // try again


        .end    KiInterlockedStoreByte




//++
//
// VOID
// KiInterlockedStoreWord(
//    IN PUSHORT Address,
//    IN USHORT Data
//    )
//
// Routine Description:
//
//    This routine stores the short data specified by Data to the aligned 
//    location specified by Address. The architecture requires word granularity,
//    so locking is necessary.
//
// Arguments:
//
//    Address(a0) - Supplies a pointer to an aligned short data value.
//    Data(a1) - Supplied the short data value to store.
//
// Return Value:
//
//    None
//
//--

        LEAF_ENTRY(KiInterlockedStoreWord)

        bic     a0, 2, t0               // clear low short address bit 
        and     a0, 2, t1               // mask of low short address bit
10:
        ldl_l   t2, 0(t0)               // load locked full longword
        inswl   a1, t1, t3              // insert word low
        mskwl   t2, t1, t2              // mask word low
        bis     t2, t3, t2              // merge data
        stl_c   t2, 0(t0)               // store conditional
        beq     t2, 20f                 // failed to store, retry, forward
                                        // branch for optimistic prediction

        ret     zero, (ra), 1           // return

20:
        br      zero, 10b               // try again

        .end    KiInterlockedStoreWord