This patch mostly documents the functionality of amdk8_util.asl.  It
also fixes a couple of logical errors that were corrupting the
resources returned from _CRS.

Fixes:
1. When adding a MMIO region to the southbridge, the previous region
was corrupted.
        - Save previous region before checking if you're handling the
southbridge.
        - Make sure you're on node 0 before adding the TOM region.
        - Add in a MMAX value of 0xFFDFFFFF (See the ACPI question at the end.)
        - Store resulting region with the saved region.
        - Move increment of Local 4 so it's more obvious what it refers to.
    Before: [TOM - 0xBFFFF] added to every node with Link 0 enabled
    After: [0xA0000-0xBFFFF] and [TOM-0xFFDFFFFF] only once
2. Missing RTAG call corrupted return value when there was no resource
for the link
        - Add RTAG (BUF0)

Signed-off-by: Myles Watson <[email protected]>

But the question is:

Why is this logic here?  Why do you want a region from TOM-(4G-2M)*
when you explicitly have all the regions that are reachable from the
HT links in other resources?

* I got 4G-2M from the ACPI FAQ.

Thanks,
Myles
Index: svn/src/northbridge/amd/amdk8/amdk8_util.asl
===================================================================
--- svn.orig/src/northbridge/amd/amdk8/amdk8_util.asl
+++ svn/src/northbridge/amd/amdk8/amdk8_util.asl
@@ -84,6 +84,7 @@
                 Return (Local0)
         }
 
+        /*GetBus (Node, Link) */
         Method (GBUS, 2, NotSerialized)
         {
             Store (0x00, Local0)
@@ -107,6 +108,7 @@
             Return (0x00)
         }
 
+        /*GetBusResources (Node, Link) */
         Method (GWBN, 2, NotSerialized)
         {
             Name (BUF0, ResourceTemplate ()
@@ -146,6 +148,7 @@
             Return (RTAG (BUF0))
         }
 
+        /*GetMemoryResources (Node, Link) */
         Method (GMEM, 2, NotSerialized)
         {
             Name (BUF0, ResourceTemplate ()
@@ -166,20 +169,24 @@
             Store (0x00, Local3)
             While (LLess (Local0, 0x10))
             {
+                /* Get first register pair of MMIO values from the SSDT table. */
                 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local1)
                 Increment (Local0)
                 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local2)
-                If (LEqual (And (Local1, 0x03), 0x03))
+                If (LEqual (And (Local1, 0x03), 0x03)) /* Pair enabled. */
                 {
-                    If (LEqual (Arg0, And (Local2, 0x07)))
+                    If (LEqual (Arg0, And (Local2, 0x07))) /* Check to see if the node number matches. */
                     {
+                        /* If we got passed 0xFF for the Link or this is the Link. */
                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local2, 0x30), 0x04))))
                         {
+                            /* Extract the Base and Limit from the register.*/
                             Store (ShiftLeft (And (Local1, 0xFFFFFF00), 0x08), MMIN)
                             Store (ShiftLeft (And (Local2, 0xFFFFFF00), 0x08), MMAX)
                             Or (MMAX, 0xFFFF, MMAX)
                             Subtract (MMAX, MMIN, MLEN)
 
+                            /* If I've already done this once. */
                             If (Local4)
                             {
                                 Concatenate (RTAG (BUF0), Local3, Local5)
@@ -187,17 +194,27 @@
                             }
                             Else
                             {
-                                If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
+                                /* Save the one I've been working on */
+                                Store (RTAG (BUF0), Local3)
+
+                                /* If this is the SouthBridge node and link, add the region above DRAM. */
+                                If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)),
+                                         LAnd (LEqual (Arg1, \_SB.PCI0.SBLK), LEqual (Arg0, 0x00))))
                                 {
+                                    Store ("ADD All IO space above DRAM (MMIN,MMAX,MLEN)=", Debug)
                                     Store (\_SB.PCI0.TOM1, MMIN)
+                                    Store (0xFFDFFFFF, MMAX)
                                     Subtract (MMAX, MMIN, MLEN)
                                     Increment (MLEN)
+
+                                    /* Add the MMIO region above DRAM. */
+                                    Concatenate (Local3, RTAG (BUF0), Local5)
+                                    Store (Local5, Local3)
                                 }
 
-                                Store (RTAG (BUF0), Local3)
+                                Increment (Local4)
                             }
 
-                            Increment (Local4)
                         }
                     }
                 }
@@ -205,14 +222,15 @@
                 Increment (Local0)
             }
 
-            If (LNot (Local4))
+            If (LNot (Local4)) /* No resources for this node and link. */
             {
-                Store (BUF0, Local3)
+                Store (RTAG (BUF0), Local3)
             }
 
             Return (Local3)
         }
 
+        /*GetIOResources (Node, Link) */
         Method (GIOR, 2, NotSerialized)
         {
             Name (BUF0, ResourceTemplate ()
@@ -236,18 +254,21 @@
                 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local1)
                 Increment (Local0)
                 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local2)
-                If (LEqual (And (Local1, 0x03), 0x03))
+                If (LEqual (And (Local1, 0x03), 0x03)) /* Pair enabled. */
                 {
-                    If (LEqual (Arg0, And (Local2, 0x07)))
+                    If (LEqual (Arg0, And (Local2, 0x07))) /* Check to see if the node number matches. */
                     {
+                        /* If we got passed 0xFF for the Link or this is the Link. */
                         If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local2, 0x30), 0x04))))
                         {
+                            /* Extract the Base and Limit from the register.*/
                             Store (And (Local1, 0x01FFF000), PMIN)
                             Store (And (Local2, 0x01FFF000), PMAX)
                             Or (PMAX, 0x0FFF, PMAX)
                             Subtract (PMAX, PMIN, PLEN)
                             Increment (PLEN)
 
+                            /* If I've already done this once. */
                             If (Local4)
                             {
                                 Concatenate (RTAG (BUF0), Local3, Local5)
@@ -293,7 +314,7 @@
                 Increment (Local0)
             }
 
-            If (LNot (Local4))
+            If (LNot (Local4)) /* No resources for this node and link. */
             {
                 Store (RTAG (BUF0), Local3)
             }
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to