This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ut_release_owner_id
1
2
3
4
5
6
7
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acnamesp.h"
11
12 #define _COMPONENT ACPI_UTILITIES
13 ACPI_MODULE_NAME("utownerid")
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id)
29 {
30 u32 i;
31 u32 j;
32 u32 k;
33 acpi_status status;
34
35 ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
36
37
38
39 if (*owner_id) {
40 ACPI_ERROR((AE_INFO,
41 "Owner ID [0x%3.3X] already exists", *owner_id));
42 return_ACPI_STATUS(AE_ALREADY_EXISTS);
43 }
44
45
46
47 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
48 if (ACPI_FAILURE(status)) {
49 return_ACPI_STATUS(status);
50 }
51
52
53
54
55
56
57 for (i = 0, j = acpi_gbl_last_owner_id_index;
58 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
59 if (j >= ACPI_NUM_OWNERID_MASKS) {
60 j = 0;
61 }
62
63 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
64 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
65
66
67
68 break;
69 }
70
71
72
73
74
75
76
77 if (!(acpi_gbl_owner_id_mask[j] & ((u32)1 << k))) {
78
79
80
81
82
83 acpi_gbl_owner_id_mask[j] |= ((u32)1 << k);
84
85 acpi_gbl_last_owner_id_index = (u8)j;
86 acpi_gbl_next_owner_id_offset = (u8)(k + 1);
87
88
89
90
91
92
93
94 *owner_id =
95 (acpi_owner_id)((k + 1) + ACPI_MUL_32(j));
96
97 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
98 "Allocated OwnerId: 0x%3.3X\n",
99 (unsigned int)*owner_id));
100 goto exit;
101 }
102 }
103
104 acpi_gbl_next_owner_id_offset = 0;
105 }
106
107
108
109
110
111
112
113
114
115
116
117 status = AE_OWNER_ID_LIMIT;
118 ACPI_ERROR((AE_INFO,
119 "Could not allocate new OwnerId (4095 max), AE_OWNER_ID_LIMIT"));
120
121 exit:
122 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
123 return_ACPI_STATUS(status);
124 }
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 void acpi_ut_release_owner_id(acpi_owner_id *owner_id_ptr)
141 {
142 acpi_owner_id owner_id = *owner_id_ptr;
143 acpi_status status;
144 u32 index;
145 u32 bit;
146
147 ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
148
149
150
151 *owner_id_ptr = 0;
152
153
154
155 if (owner_id == 0) {
156 ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%3.3X", owner_id));
157 return_VOID;
158 }
159
160
161
162 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
163 if (ACPI_FAILURE(status)) {
164 return_VOID;
165 }
166
167
168
169 owner_id--;
170
171
172
173 index = ACPI_DIV_32(owner_id);
174 bit = (u32)1 << ACPI_MOD_32(owner_id);
175
176
177
178 if (acpi_gbl_owner_id_mask[index] & bit) {
179 acpi_gbl_owner_id_mask[index] ^= bit;
180 } else {
181 ACPI_ERROR((AE_INFO,
182 "Attempted release of non-allocated OwnerId: 0x%3.3X",
183 owner_id + 1));
184 }
185
186 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
187 return_VOID;
188 }