summaryrefslogtreecommitdiff
path: root/tests/aapits/asl/init1065.asl
blob: 3e901f4464bf40068f7a2a58166ad727d01d887a (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
DefinitionBlock(
	"init1065.aml",   // Output filename
	"DSDT",     // Signature
	0x02,       // DSDT Revision
	"Intel",    // OEMID
	"Many",     // TABLE ID
	0x00000001  // OEM Revision
	) {

	/*
	 * ACPICA API Test Suite
	 * Init tests 0038 and 0039 supporting code
	 */

	// Integer
	Name(INT0, 0)
	Name(INT1, 0xfedcba9876543211)
	Name(INT2, 257)
	Name(INT3, 65)

	// String
	Name(STR0, "source string")
	Name(STR1, "target string")
	Name(STR2, "string")

	// Buffer
	Name(BUF0, Buffer(9){9,8,7,6,5,4,3,2,1})
	Name(BUF1, Buffer(17){0xc3})

	// Initializer of Fields
	Name(BUF2, Buffer(9){0x95,0x85,0x75,0x65,0x55,0x45,0x35,0x25,0x15})

	// Base of Buffer Fields
	Name(BUFY, Buffer(INT2){})
	Name(BUFZ, Buffer(9){0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88})

	// Package
	Name(PAC0, Package(3) {
		0xfedcba987654321f,
		"test package",
		Buffer(9){19,18,17,16,15,14,13,12,11},
	})

	Name(PAC1, Package(1) {"target package"})

	Name(PACO, Package(2) {"OPR0", "OPR1"})
	Name(PACB, Package(4) {"BFL0", "BFL2", "BFL4", "BFL6"})

	// Field Unit
	Field(OPR0, ByteAcc, NoLock, Preserve) {
		FLU0, 69,
		FLU2, 64,
		FLU4, 32,
	}

	// Device

	Name(INVC, 0)	// Counter of Devices' _INI and _STA methods invocations
	Name(INVM, 0)	// Mask of Devices' _INI and _STA methods invocations

	// Without the _STA or _INI methods
	Device(DEV0) {Name(s000, "DEV0")}

	// With the _INI method only (default _STA)
	Device(DEV1) {
		Name(s000, "DEV1")
		Method(_INI) {
			Increment(INVC)
			Or(INVM, 0x01, INVM)
		}
	}

	// With the _STA method only
	Device(\_SB.DEV2) {
		Name(s000, "DEV2")
		Method(_STA) {
			Increment(INVC)
			Or(INVM, 0x02, INVM)
			Return(0xf)
		}
	}

	// With the both _INI and _STA methods
	Device(\DEV0.DEV3) {
		Name(s000, "DEV3")
		Method(_INI) {
			Increment(INVC)
			Or(INVM, 0x04, INVM)
		}
		Method(_STA) {
			Increment(INVC)
			Or(INVM, 0x08, INVM)
			Return(0xf)
		}
	}

	// With the both _INI and _STA methods
	Device(\DEV0.DEV3.DEV4) {
		Name(s000, "DEV4")
		Method(_INI) {
			Increment(INVC)
			Or(INVM, 0x10, INVM)
		}
		Method(_STA) {
			Increment(INVC)
			Or(INVM, 0x20, INVM)
			Return(0xf)
		}
	}

	// With the both _INI and _STA methods
	Device(\DEV0.DEV5) {
		Name(s000, "DEV5")
		Method(_INI) {
			Increment(INVC)
			Or(INVM, 0x40, INVM)
		}
		Method(_STA) {
			Increment(INVC)
			Or(INVM, 0x80, INVM)
			Return(0xf)
		}
	}

	// With the both _INI and _STA methods,
	// but the last indicates that device:
	// - is not present,
	// - is not enabled.
	Device(\DEV0.DEV6) {
		Name(s000, "DEV6")
		Method(_INI) {
			Increment(INVC)
			Or(INVM, 0x100, INVM)
		}
		Method(_STA) {
			Increment(INVC)
			Or(INVM, 0x200, INVM)
			Return(0xc)
		}
	}

	// Event
	Event(EVE0)
	Event(EVE1)

	// Method
	Name(MM00, "ff0X")	// Value, returned from MMMX
	Name(MM01, "ff1Y")	// Value, returned from MMMY
	Name(MMM0, 0)	// Method as Source Object
	Name(MMM1, 0)	// Method as Target Object
	Method(MMMX) {Return (MM00)}
	Method(MMMY) {Return (MM01)}

	// Mutex
	Mutex(MTX0, 0)
	Mutex(MTX1, 0)

	// Operation Region
	OperationRegion(OPR0, SystemMemory, 0, 48)
	OperationRegion(OPR1, SystemMemory, 0, 24)

	// Power Resource
	PowerResource(PWR0, 0, 0) {Name(s000, "PWR0")}
	PowerResource(PWR1, 0, 0) {Name(s000, "PWR1")}

	// Processor
	Processor(CPU0, 0x0, 0xFFFFFFFF, 0x0) {Name(s000, "CPU0")}
	Processor(CPU1, 0x0, 0xFFFFFFFF, 0x0) {Name(s000, "CPU1")}

	// Thermal Zone
	ThermalZone(TZN0) {Name(s000, "TZN0")}
	ThermalZone(TZN1) {Name(s000, "TZN1")}

	// Buffer Field
	Createfield(BUFZ,   0, 69, BFL0)

	Method(M000, 7)
	{
		Increment(INT0)
	}

	Method(M001)
	{
		Return(BFL0)
	}

	Name (POUT, Package(1) {})
	Name (IMAX, 0)
	Name (IOUT, 0)

	// Useful for indirect storing

	Method(RSTO, 2) {Store(arg0, arg1)}

	Method(DSTO, 2) {Store(Derefof(arg0), arg1)}

	// Init the output package data
	Method(INIP, 2)
	{
		Store (0, IOUT)
		Store (arg0, IMAX)

		if (LLess(IMAX, 1)) {
			Store (1, IMAX)
		}

		if (LGreater(IMAX, 16)) {
			Store (16, IMAX)
		}

		Switch (IMAX) {
			Case (1) {RSTO(Package(1){}, Refof(POUT))}
			Case (2) {RSTO(Package(2){}, Refof(POUT))}
			Case (3) {RSTO(Package(3){}, Refof(POUT))}
			Case (4) {RSTO(Package(4){}, Refof(POUT))}
			Case (5) {RSTO(Package(5){}, Refof(POUT))}
			Case (6) {RSTO(Package(6){}, Refof(POUT))}
			Case (7) {RSTO(Package(7){}, Refof(POUT))}
			Case (8) {RSTO(Package(8){}, Refof(POUT))}
			Case (9) {RSTO(Package(9){}, Refof(POUT))}
			Case (10) {RSTO(Package(10){}, Refof(POUT))}
			Case (11) {RSTO(Package(11){}, Refof(POUT))}
			Case (12) {RSTO(Package(12){}, Refof(POUT))}
			Case (13) {RSTO(Package(13){}, Refof(POUT))}
			Case (14) {RSTO(Package(14){}, Refof(POUT))}
			Case (15) {RSTO(Package(15){}, Refof(POUT))}
			Case (16) {RSTO(Package(16){}, Refof(POUT))}
			Default   {RSTO(Package(32){}, Refof(POUT))}
		}

		OUTP(arg1)
	}

	Method(OUTP, 1)
	{
		if (LLess(IOUT, IMAX)) {
			Store (arg0, Index(POUT, IOUT))
			Increment(IOUT)
		}
	}

	Method(m134, 1)
	{
		Name(i000, 0x11)
		Name(i001, 0x22)
		Name(i002, 0x33)
		Name(i003, 0x44)
		Name(i004, 0x55)
		Name(i005, 0x66)
		Name(i006, 0x77)

		Method(m000, 7)
		{
			OUTP("LocalX case of Method started:")
	
			Store(RefOf(i000), Local0)
			Store(Local0, Local1)
			Store(Local1, Local2)
			Store(Local2, Local3)
			Store(Local3, Local4)
			Store(Local4, Local5)
			Store(Local5, Local6)

			Store(0x88, Local6)

			if (LNotEqual(i000, 0x11)) {
				OUTP("Error 0:")
				OUTP(i000)
			} else {
				if (LNotEqual(Local6, 0x88)) {
					OUTP("Error 10:")
				} else {
					OUTP("Ok 0:")
				}
				OUTP(Local6)
			}

			OUTP("LocalX case of Method finished")
		}

		Method(m001, 7)
		{
			OUTP("ArgX case of Method started:")

			Store(RefOf(i000), arg0)
			Store(arg0, arg1)
			Store(arg1, arg2)
			Store(arg2, arg3)
			Store(arg3, arg4)
			Store(arg4, arg5)
			Store(arg5, arg6)

			Store(0x88, arg6)

			if (LNotEqual(i000, 0x11)) {
				OUTP("Error 1:")
				OUTP(i000)
			} else {
				if (LNotEqual(arg6, 0x88)) {
					OUTP("Error 11:")
				} else {
					OUTP("Ok 1:")
				}
				OUTP(arg6)
			}

			OUTP("ArgX case of Method finished")
		}

		Method(m002, 7)
		{
			OUTP("references in ArgX case of Method started:")

//			Store(RefOf(i000), arg0)
			Store(arg0, arg1)
			Store(arg1, arg2)
			Store(arg2, arg3)
			Store(arg3, arg4)
			Store(arg4, arg5)
			Store(arg5, arg6)

			Store(0x88, arg6)

			if (LNotEqual(i000, 0x11)) {
				OUTP("Error 1:")
				OUTP(i000)
			} else {
				if (LNotEqual(arg6, 0x88)) {
					OUTP("Error 11:")
				} else {
					OUTP("Ok 1:")
				}
				OUTP(arg6)
			}

			OUTP("ArgX case of Method finished")
		}

		INIP(5, "Bug 134: ArgX term effectively becomes a LocalX term")

		if (LEqual(arg0, 0)) {
			m000(i000,i001,i002,i003,i004,i005,i006)
		} elseif (LEqual(arg0, 1)) {
			m001(i000,i001,i002,i003,i004,i005,i006)
		} elseif (LEqual(arg0, 2)) {
			m002(Refof(i000),Refof(i001),Refof(i002),Refof(i003),Refof(i004),
				Refof(i005),Refof(i006))
		}

		Return (POUT)
	}

	Method(fact, 1)
	{
		if (Arg0) {
			Subtract(Arg0, 1, Local0)
			if (Local0) {
				Store (fact(Local0), Local1)
				Return (Multiply(Arg0, Local1))
			} else {
				Return (1)
			}
		} else {
			Return (1)
		}

	}

	Method(MAIN)
	{
		Return (fact(6))
	}
}