summaryrefslogtreecommitdiff
path: root/Core/EM/ACPI/RbRes.asl
blob: b2b8d6a4a53789f8a6e538152e19ff78ee67996f (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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
//****************************************************************************
//****************************************************************************
//**                                                                        **
//**         (C)Copyright 1985-2010, American Megatrends, Inc.              **
//**                                                                        **
//**                          All Rights Reserved.                          **
//**                                                                        **
//**          5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093          **
//**                                                                        **
//**                          Phone (770)-246-8600                          **
//**                                                                        **
//****************************************************************************
//****************************************************************************

//<AMI_FHDR_START>
//----------------------------------------------------------------------------
//
// Name:		NBRes.ASL
//
// Description:	PCI Root Bridge resources buffer and CRS Method
// MUST be included from NB.ASL directly using "include" ASL term
// Suppose to be already in ROOT BRIDGE Device ASL Scope.
//
// NOTE: NO Porting needed 
//
//----------------------------------------------------------------------------
//<AMI_FHDR_END>


//Defining some place holders, we need to updte at runtime.
        Name(CPRB, 0x0)         //BOOLEAN  Compatible Root Bridge if !=0
        Name(LVGA, 0x55)        //BOOLEAN  Legacy Video Present if !=0
        Name(STAV,0x0F)
//Information Provided in RootBridgeIo->Configuration() function.
        Name(BRB, 0x0100)       //Bus Range Base 
        Name(BRL, 0x0100)       //Bus Range Length

        Name(IOB, 0x0100)       //IO Range BASE (16bit resource)
        Name(IOL, 0x0100)       //IO Range LENGTH

        Name(MBB, 0x10000)      //Memory Range Below 4G BASE (32bit resource)
        Name(MBL, 0x10000)      //Memory Range Below 4G LENGTH (32bit resource)

        Name(MABL, 0x10000)     //Memory Range Above 4G BASE LSDW (32bit resource)
        Name(MABH, 0x10000)     //Memory Range Above 4G BASE MSDW (32bit resource)
                                
        Name(MALL, 0x10000)     //Memory Range Above 4G LENGTH LSDW (32bit resource)
        Name(MALH, 0x10000)     //Memory Range Above 4G LENGTH LSDW (32bit resource)
        
        Name(MAML, 0x10000)     //Memory Range Above 4G LENGTH LSDW (32bit resource)
        Name(MAMH, 0x10000)     //Memory Range Above 4G LENGTH LSDW (32bit resource)

//---------------------------------------------------------------------------
    //Resource buffer to be used for COMPATIBILITY ROOT BRIDGE (one that decodes ISA resources)
    Name(CRS1, ResourceTemplate() {
        WORDBusNumber(	        //Bus number resource (0); the bridge produces bus numbers for its subsequent buses
            ResourceProducer,      // bit 0 of general flags is 1
            MinFixed,	        // Range is not fixed
            MaxFixed,	        // Range is not fixed
            PosDecode,	        // PosDecode
            0x0000,		// Granularity
            0x0000,		// Min
            0x007f,		// Max; half of the available bus numbers are reserved for this root bus
            0x0000,		// Translation
            0x0080,      // Range Length
            ,,
            BUS1
        )

		// CF8 - CFC
		IO(			//Consumed resource for 1st root bus(CF8-CFF)
            Decode16,
            0x0cf8,
            0xcf8,
            1,
            8
        )

		// All IO below 3B0
		WORDIO(			//Consumed-and-produced resource (all I/O below 3B0 is assigned to this root bus)
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x0000,		// Min
            0x03af,		// Max
            0x0000,		// Translation
            0x03b0		// Range Length
        )

		// 3E0 - CF7
		WORDIO(			//Consumed-and-produced resource (all I/O between 3E0 and CF8 is assigned to this root bus)
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x03e0,		// Min
            0x0cf7,		// Max
            0x0000,		// Translation
            0x0918		// Range Length
        )

		// For Legacy Video IO (3B0 - 3DF)
		WORDIO(			//Consumed-and-produced resource (Used for legacy video)
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x0000,		// Min
            0x0000,		// Max
            0x0000,		// Translation
            0x0000,		// Range Length
            ,,
            VIO1
        )

		// Other IO used by this root bridge
		WORDIO(			//Consumed-and-produced resource
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x0d00,		// Min
            0x0fff,		// Max
            0x0000,		// Translation
            0x0300,		// Range Length
            ,,
            IOW2
        )

		// For Legacy Video Memory (A000 - BFFF)
		DWORDMEMORY(			// descriptor for video RAM behind ISA bus
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        Cacheable,
	        ReadWrite,
	        0x00000000,		// Granularity
	        0x00000000,		// Min
	        0x00000000,		// Max
	        0x00000000,		// Translation
	        0x00000000,		// Range Length
			,,
			VGA1
	    )

		// ISA Option ROMs
		DWORDMEMORY(		// for device ROMs for ISA plugins devices
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        NonCacheable,
	        ReadWrite,
	        0x00000000,		// Granularity
	        0x000c0000,		// Min
            0x000dffff,		// Max
        	0x00000000,		// Translation
	        0x00020000		// Range Length
	    )

		// Memory < 4GB
		DWORDMEMORY(		// Consumed-and-produced resource(all of memory space)
            ResourceProducer, 	// bit 0 of general flags is 0
            PosDecode,		// positive Decode
            MinFixed,		// Range is fixed
            MaxFixed,		// Range is fixed
            Cacheable,
            ReadWrite,
            0x00000000,		// Granularity
            0x02000000,		// Min (calculated dynamically)
            0xffdfffff,		// Max = 4GB - 2MB
            0x00000000,		// Translation
            0xfdfc0000,		// Range Length (calculated dynamically)
            ,               // Optional field left blank
	        ,               // Optional field left blank
    	    MEM3            // Name declaration for this descriptor
            )

		// Memory > 4GB
        QWORDMEMORY(			// descriptor for MMIO ABOVE 4G
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        Cacheable,
	        ReadWrite,
	        0x00000000,	    // Granularity
	        0x00000000,	    // Min
	        0x00000000,	    // Max
	        0x00000000,	    // Translation
	        0x00000000,	    // Range Length
            ,,
            MEM8
	    )

    })//End resource template Name CRS1


    //Resource buffer to be used for NONE COMPATIBILITY ROOT BRIDGE
    Name(CRS2, ResourceTemplate() {
        WORDBusNumber(	        //Bus number resource (0); the bridge produces bus numbers for its subsequent buses
            ResourceProducer,      // bit 0 of general flags is 1
            MinFixed,	        // Range is not fixed
            MaxFixed,	        // Range is not fixed
            PosDecode,	        // PosDecode
            0x0000,		// Granularity
            0x0080,		// Min
            0x00ff,		// Max; half of the available bus numbers are reserved for this root bus
            0x0000,		// Translation
            0x0080,     // Range Length
            ,,
            BUS2
        )

		// For Legacy Video IO (3B0 - 3DF)
        WORDIO(			//Consumed-and-produced resource (Used for legacy video)
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x0000,		// Min
            0x0000,		// Max
            0x0000,		// Translation
            0x0000,		// Range Length
            ,,
            VIO2
        )

		// Other IO used by this root bridge
        WORDIO(			//Consumed-and-produced resource
            ResourceProducer, 	// bit 0 of general flags is 0
            MinFixed,	        // Range is fixed
            MaxFixed,		// Range is fixed
            PosDecode,
            EntireRange,
            0x0000,		// Granularity
            0x0000,		// Min
            0x0000,		// Max
            0x0000,		// Translation
            0x0000,		// Range Length
            ,,
            IOW3
        )

		// For Legacy Video Memory (A000 - BFFF)
        DWORDMEMORY(			// descriptor for video RAM behind ISA bus
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        Cacheable,
	        ReadWrite,
	        0x00000000,		// Granularity
	        0x00000000,		// Min
	        0x00000000,		// Max
	        0x00000000,		// Translation
	        0x00000000,		// Range Length
			,,
			VGA2
	    )

		// Memory < 4GB
        DWORDMEMORY(			// descriptor for video RAM behind ISA bus
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        Cacheable,
	        ReadWrite,
	        0x00000000,	    // Granularity
	        0x80000000,	    // Min
	        0xffffffff,	    // Max
	        0x00000000,	    // Translation
	        0x80000000,	    // Range Length
            ,,
            MEM1
	    )

		// Memory > 4GB
        QWORDMEMORY(			// descriptor for MMIO ABOVE 4G
	        ResourceProducer,	// bit 0 of general flags is 0
            PosDecode,
	        MinFixed,		// Range is fixed
	        MaxFixed,		// Range is Fixed
	        Cacheable,
	        ReadWrite,
	        0x00000000,	    // Granularity
	        0x00000000,	    // Min
	        0x00000000,	    // Max
	        0x00000000,	    // Translation
	        0x00000000,	    // Range Length
            ,,
            MEM9
	    )
    } ) //End resource template Name CRS2

    Method(_STA, 0){
        Return(STAV)
    }

    Method(_CRS, 0) {

            //breakpoint


            //This is for compatibility bridges
            If(CPRB){

                //Bus Range
                CreateWordField(CRS1, ^BUS1._MIN, MIN0)	// Min
                CreateWordField(CRS1, ^BUS1._MAX, MAX0)	// Max
                CreateWordField(CRS1, ^BUS1._LEN, LEN0)	// Length

                Store(BRB, MIN0)
                Store(BRL, LEN0)
                Store(LEN0,Local0)
                Add(MIN0, Decrement(Local0), MAX0)

                //Update Upper IO from 0x0D00 up to IOB+IOL
		        CreateWordField(CRS1, ^IOW2._MIN, MIN1)	// Min
		        CreateWordField(CRS1, ^IOW2._MAX, MAX1)	// Max
        		CreateWordField(CRS1, ^IOW2._LEN, LEN1)	// Length


                If(LEqual(IOB, 0x1000)){
                    Store(IOL, Local0)
                    Add(IOB, Decrement(Local0), MAX1)
                    Subtract(MAX1,MIN1,Local0)
                    Add(Local0,1,LEN1)
                } else {
                    Store(IOB, MIN1)
                    Store(IOL, LEN1)
                    Store(LEN1,Local0)
                    Add(MIN1, Decrement(Local0), MAX1)
                }

                If(LOr(LEqual(LVGA,1),LEqual(LVGA,0x55))){
                    if(VGAF){//will update this only once.
                        CreateWordField(CRS1, ^VIO1._MIN, IMN1)	// Min
                        CreateWordField(CRS1, ^VIO1._MAX, IMX1)	// Max
                        CreateWordField(CRS1, ^VIO1._LEN, ILN1)	// Length
    
                        Store(0x03b0, IMN1)
                        Store(0x03df, IMX1)
                        Store(0x0030, ILN1)
    
                        CreateDWordField(CRS1, ^VGA1._MIN, VMN1)	// Min
                        CreateDWordField(CRS1, ^VGA1._MAX, VMX1)	// Max
                        CreateDWordField(CRS1, ^VGA1._LEN, VLN1)	// Length
    
                        Store(0x000a0000, VMN1)
                        Store(0x000bffff, VMX1)
                        Store(0x00020000, VLN1)
                        Store(0, VGAF)
                    }
                }

                //Update MMIO Below 4G
		        CreateDWordField(CRS1, ^MEM3._MIN, MIN3)	// Min
		        CreateDWordField(CRS1, ^MEM3._MAX, MAX3)	// Max
        		CreateDWordField(CRS1, ^MEM3._LEN, LEN3)	// Length

                Store(MBB, MIN3)
                Store(MBL, LEN3)
                Store(LEN3,Local0)
                Add(MIN3, Decrement(Local0), MAX3)

                If(LOr(MALH,MALL)){
            		CreateDWordField(CRS1, ^MEM8._MIN, MN8L)	// Min_LO
                    Add(^MEM8._MIN,4,Local0)
            		CreateDWordField(CRS1, Local0, MN8H)	    // Min_HI
                    Store(MABL, MN8L)
                    Store(MABH, MN8H)

		            CreateDwordField(CRS1, ^MEM8._MAX, MX8L)	// Max_LO
                    Add(^MEM8._MAX,4,Local1)
            		CreateDWordField(CRS1, Local1, MX8H)	    // Max_HI

                    CreateDwordField(CRS1, ^MEM8._LEN, LN8L)	// Len_LO
                    Add(^MEM8._LEN,4,Local2)
                    CreateDWordField(CRS1, Local2, LN8H)	    // Len_HI

                    //Update fields.
                    //1. _MIN 64bits...
                    Store(MABL, MN8L)
                    Store(MABH, MN8H)
                    //2. _LEN 64Bits
                    Store(MALL, LN8L)
                    Store(MALH, LN8H)
                    //2. _MAX 64Bits
                    Store(MAML, MX8L)
                    Store(MAMH, MX8H)
                }

                Return(CRS1)
            } else {
                //Bus Range
                CreateWordField(CRS2, ^BUS2._MIN, MIN2)	// Min
                CreateWordField(CRS2, ^BUS2._MAX, MAX2)	// Max
                CreateWordField(CRS2, ^BUS2._LEN, LEN2)	// Length

                Store(BRB, MIN2)
                Store(BRL, LEN2)
                Store(LEN2,Local1)
                Add(MIN2, Decrement(Local1), MAX2)

                //Update Upper IO from IOB up to IOB+IOL
		        CreateWordField(CRS2, ^IOW3._MIN, MIN4)	// Min
		        CreateWordField(CRS2, ^IOW3._MAX, MAX4)	// Max
        		CreateWordField(CRS2, ^IOW3._LEN, LEN4)	// Length

                Store(IOB, MIN4)
                Store(IOL, LEN4)
                Store(LEN4,Local1)
                Add(MIN4, Decrement(Local1), MAX4)

				If(LVGA){
		        	CreateWordField(CRS2, ^VIO2._MIN, IMN2)	// Min
		        	CreateWordField(CRS2, ^VIO2._MAX, IMX2)	// Max
        			CreateWordField(CRS2, ^VIO2._LEN, ILN2)	// Length

                	Store(0x03b0, IMN2)
                	Store(0x03df, IMX2)
                	Store(0x0030, ILN2)

		        	CreateDWordField(CRS2, ^VGA2._MIN, VMN2)	// Min
		        	CreateDWordField(CRS2, ^VGA2._MAX, VMX2)	// Max
        			CreateDWordField(CRS2, ^VGA2._LEN, VLN2)	// Length

                	Store(0x000a0000, VMN2)
                	Store(0x000bffff, VMX2)
                	Store(0x00020000, VLN2)
				}

                //Update MMIO Below 4G
		        CreateDWordField(CRS2, ^MEM1._MIN, MIN5)	// Min
		        CreateDWordField(CRS2, ^MEM1._MAX, MAX5)	// Max
        		CreateDWordField(CRS2, ^MEM1._LEN, LEN5)	// Length

                Store(MBB, MIN5)
                Store(MBL, LEN5)
                Store(LEN5,Local1)
                Add(MIN5, Decrement(Local1), MAX5)

                //Update Above 4G memory space if any
                If(LOr(MALH, MALL)){
            		CreateDWordField(CRS2, ^MEM9._MIN, MN9L)	// Min_LO
                    Add(^MEM9._MIN,4,Local0)
            		CreateDWordField(CRS2, Local0, MN9H)	    // Min_HI

		            CreateDwordField(CRS2, ^MEM9._MAX, MX9L)	// Max_LO
                    Add(^MEM9._MAX,4,Local1)
            		CreateDWordField(CRS2, Local1, MX9H)	    // Max_HI

                    CreateDwordField(CRS2, ^MEM9._LEN, LN9L)	// Len_LO
                    Add(^MEM9._LEN,4,Local2)
                    CreateDWordField(CRS2, Local2, LN9H)	    // Len_HI

                    //Update fields.
                    //1. _MIN 64bits...
                    Store(MABL, MN9L)
                    Store(MABH, MN9H)
                    //2. _LEN 64Bits
                    Store(MALL, LN9L)
                    Store(MALH, LN9H)
                    //2. _MAX 64Bits
                    Store(MAML, MX9L)
                    Store(MAMH, MX9H)
                }

                Return(CRS2)
            }

	} // end ROOT BRIDGE PCIx._CRS Method
//----------------------------------------------------------------------------

//****************************************************************************
//****************************************************************************
//**                                                                        **
//**         (C)Copyright 1985-2010, American Megatrends, Inc.              **
//**                                                                        **
//**                          All Rights Reserved.                          **
//**                                                                        **
//**          5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093          **
//**                                                                        **
//**                          Phone (770)-246-8600                          **
//**                                                                        **
//****************************************************************************
//****************************************************************************