Patchwork SECC Pentium 2/3 users are gonna love this

login
register
about
Submitter Keith Hui
Date 2011-01-12 04:17:17
Message ID <AANLkTik+kysDgBtXjBtKbjS=LKc+M2FSp3ASnNHS3qAR@mail.gmail.com>
Download mbox | patch
Permalink /patch/2507/
State New
Headers show

Comments

Keith Hui - 2011-01-12 04:17:17
Hi all,

Here is the new L2 cache patch. Sign-off in the patch itself. Still
very juicy and tasty at 25k. :D

Also done is including cpu/intel/model_68x again in slot_1. Otherwise
it will die with a Coppermine P3 installed.

My boot log on P2B-LS and a Katmai 600MHz attached.

I have optimized it some more, and added more information and
meaningful constants as I cross checked the code with Intel's
documentation. Some debugging messages are different too. Give this a
good workout.

Cheers
Keith

ps. Copying people who have sent me reports. :)

On Fri, Jan 7, 2011 at 3:45 PM, Jouni Mettälä <jtmettala@gmail.com> wrote:
> Hi
> Parts of original patch are already in coreboot. This version made cache
> work in my board now. It might need work so it doesn't break others. Here is
> part of serial capture. Rest is attached
> Initializing CPU #0
> CPU: vendor Intel device 673
> CPU: family 06, model 07, stepping 03
> microcode_info: sig = 0x00000673 pf=0x00000001 rev = 0x00000000
> microcode updated to revision: 0000000e from revision 00000000
> Configuring L2 cache... rdmsr(IA32_PLATFORM_ID) = 0, 11020000
> L2 Cache latency is 8
> Sending 0 to set_l2_register4
> L2 ECC Checking is enabled
> L2 Physical Address Range is 4096M
> Maximum cache mask is 20000
> L2 Cache Mask is 4000
> read_l2(2) = 8
> write_l2(2) = 8
> L2 Cache size is 512K
> L2 Cache lines initialized
> Signed-off-by: Jouni Mettälä <jtmettala@gmail.com>
coreboot-4.0-r5917:6247M Tue Jan 11 20:56:00 EST 2011 starting...
Loading image.
Check CBFS header at fffffc9e
magic is 4f524243
Found CBFS header at fffffc9e
Check fallback/romstage
CBFS: follow chain: fffc0000 + 38 + 2c48 + align -> fffc2c80
Check fallback/coreboot_ram
Stage: loading fallback/coreboot_ram @ 0x100000 (278528 bytes), entry @ 0x100000
Stage: done loading.
Jumping to image.
coreboot-4.0-r5917:6247M Tue Jan 11 20:56:00 EST 2011 booting...
clocks_per_usec: 602
Enumerating buses...
Show all devs...Before device enumeration.
Root Device: enabled 1
APIC_CLUSTER: 0: enabled 1
APIC: 00: enabled 1
PCI_DOMAIN: 0000: enabled 1
PCI: 00:00.0: enabled 1
PCI: 00:01.0: enabled 1
PCI: 00:04.0: enabled 1
PNP: 03f0.0: enabled 1
PNP: 03f0.1: enabled 1
PNP: 03f0.2: enabled 1
PNP: 03f0.3: enabled 1
PNP: 03f0.5: enabled 1
PNP: 03f0.7: enabled 1
PNP: 03f0.8: enabled 1
PNP: 03f0.a: enabled 1
PCI: 00:04.1: enabled 1
PCI: 00:04.2: enabled 1
PCI: 00:04.3: enabled 1
Compare with tree...
Root Device: enabled 1
 APIC_CLUSTER: 0: enabled 1
  APIC: 00: enabled 1
 PCI_DOMAIN: 0000: enabled 1
  PCI: 00:00.0: enabled 1
  PCI: 00:01.0: enabled 1
  PCI: 00:04.0: enabled 1
   PNP: 03f0.0: enabled 1
   PNP: 03f0.1: enabled 1
   PNP: 03f0.2: enabled 1
   PNP: 03f0.3: enabled 1
   PNP: 03f0.5: enabled 1
   PNP: 03f0.7: enabled 1
   PNP: 03f0.8: enabled 1
   PNP: 03f0.a: enabled 1
  PCI: 00:04.1: enabled 1
  PCI: 00:04.2: enabled 1
  PCI: 00:04.3: enabled 1
scan_static_bus for Root Device
APIC_CLUSTER: 0 enabled
Finding PCI configuration type.
PCI: Using configuration type 1
PCI_DOMAIN: 0000 enabled
PCI_DOMAIN: 0000 scanning...
PCI: pci_scan_bus for bus 00
PCI: 00:00.0 [8086/7190] ops
PCI: 00:00.0 [8086/7190] enabled
PCI: 00:01.0 [8086/7191] enabled
PCI: 00:04.0 [8086/7110] bus ops
PCI: 00:04.0 [8086/7110] enabled
PCI: 00:04.1 [8086/7111] ops
PCI: 00:04.1 [8086/7111] enabled
PCI: 00:04.2 [8086/7112] ops
PCI: 00:04.2 [8086/7112] enabled
PCI: 00:04.3 [8086/7113] bus ops
PCI: 00:04.3 [8086/7113] enabled
PCI: 00:06.0 [9005/001f] ops
PCI: 00:06.0 [9005/001f] enabled
PCI: 00:07.0 [8086/1229] enabled
do_pci_scan_bridge for PCI: 00:01.0
PCI: pci_scan_bus for bus 01
PCI: 01:00.0 [1002/475a] enabled
PCI: pci_scan_bus returning with max=001
do_pci_scan_bridge returns max 1
scan_static_bus for PCI: 00:04.0
PNP: 03f0.0 enabled
PNP: 03f0.1 enabled
PNP: 03f0.2 enabled
PNP: 03f0.3 enabled
PNP: 03f0.5 enabled
PNP: 03f0.7 enabled
PNP: 03f0.8 enabled
PNP: 03f0.a enabled
PNP: 03f0.6 enabled
scan_static_bus for PCI: 00:04.0 done
scan_static_bus for PCI: 00:04.3
scan_static_bus for PCI: 00:04.3 done
PCI: pci_scan_bus returning with max=001
scan_static_bus for Root Device done
done
Setting up VGA for PCI: 01:00.0
Setting PCI_BRIDGE_CTL_VGA for bridge PCI: 00:01.0
Setting PCI_BRIDGE_CTL_VGA for bridge PCI_DOMAIN: 0000
Setting PCI_BRIDGE_CTL_VGA for bridge Root Device
Allocating resources...
Reading resources...
Root Device read_resources bus 0 link: 0
APIC_CLUSTER: 0 read_resources bus 0 link: 0
APIC: 00 missing read_resources
APIC_CLUSTER: 0 read_resources bus 0 link: 0 done
PCI_DOMAIN: 0000 read_resources bus 0 link: 0
PCI: 00:01.0 read_resources bus 1 link: 0
PCI: 00:01.0 read_resources bus 1 link: 0 done
PCI: 00:04.0 read_resources bus 0 link: 0
PNP: 03f0.8 missing read_resources
PCI: 00:04.0 read_resources bus 0 link: 0 done
PCI_DOMAIN: 0000 read_resources bus 0 link: 0 done
Root Device read_resources bus 0 link: 0 done
Done reading resources.
Show resources in subtree (Root Device)...After reading.
 Root Device child on link 0 APIC_CLUSTER: 0
  APIC_CLUSTER: 0 child on link 0 APIC: 00
   APIC: 00
  PCI_DOMAIN: 0000 child on link 0 PCI: 00:00.0
  PCI_DOMAIN: 0000 resource base 0 size 0 align 0 gran 0 limit ffff flags 40040100 index 10000000
  PCI_DOMAIN: 0000 resource base 0 size 0 align 0 gran 0 limit ffffffff flags 40040200 index 10000100
   PCI: 00:00.0
   PCI: 00:00.0 resource base 0 size 10000000 align 28 gran 28 limit ffffffff flags 1200 index 10
   PCI: 00:01.0 child on link 0 PCI: 01:00.0
   PCI: 00:01.0 resource base 0 size 0 align 12 gran 12 limit ffff flags 80102 index 1c
   PCI: 00:01.0 resource base 0 size 0 align 20 gran 20 limit ffffffff flags 81202 index 24
   PCI: 00:01.0 resource base 0 size 0 align 20 gran 20 limit ffffffff flags 80202 index 20
    PCI: 01:00.0
    PCI: 01:00.0 resource base 0 size 1000000 align 24 gran 24 limit ffffffff flags 1200 index 10
    PCI: 01:00.0 resource base 0 size 100 align 8 gran 8 limit ffff flags 100 index 14
    PCI: 01:00.0 resource base 0 size 1000 align 12 gran 12 limit ffffffff flags 200 index 18
    PCI: 01:00.0 resource base 0 size 20000 align 17 gran 17 limit ffffffff flags 2200 index 30
   PCI: 00:04.0 child on link 0 PNP: 03f0.0
   PCI: 00:04.0 resource base 0 size 1000 align 0 gran 0 limit ffff flags c0000100 index 1
   PCI: 00:04.0 resource base ff800000 size 800000 align 0 gran 0 limit 0 flags d0000200 index 2
    PNP: 03f0.0
    PNP: 03f0.0 resource base 3f0 size 8 align 3 gran 3 limit 7ff flags c0000100 index 60
    PNP: 03f0.0 resource base 6 size 1 align 0 gran 0 limit 0 flags c0000400 index 70
    PNP: 03f0.0 resource base 2 size 1 align 0 gran 0 limit 0 flags c0000800 index 74
    PNP: 03f0.1
    PNP: 03f0.1 resource base 378 size 8 align 3 gran 3 limit 7ff flags c0000100 index 60
    PNP: 03f0.1 resource base 7 size 1 align 0 gran 0 limit 0 flags c0000400 index 70
    PNP: 03f0.1 resource base 0 size 1 align 0 gran 0 limit 0 flags 800 index 74
    PNP: 03f0.2
    PNP: 03f0.2 resource base 3f8 size 8 align 3 gran 3 limit 7ff flags c0000100 index 60
    PNP: 03f0.2 resource base 4 size 1 align 0 gran 0 limit 0 flags c0000400 index 70
    PNP: 03f0.3
    PNP: 03f0.3 resource base 2f8 size 8 align 3 gran 3 limit 7ff flags c0000100 index 60
    PNP: 03f0.3 resource base 3 size 1 align 0 gran 0 limit 0 flags c0000400 index 70
    PNP: 03f0.5
    PNP: 03f0.5 resource base 60 size 1 align 0 gran 0 limit ffffffff flags c0000100 index 60
    PNP: 03f0.5 resource base 64 size 1 align 0 gran 0 limit ffffffff flags c0000100 index 62
    PNP: 03f0.5 resource base 1 size 1 align 0 gran 0 limit 0 flags c0000400 index 70
    PNP: 03f0.5 resource base c size 1 align 0 gran 0 limit 0 flags c0000400 index 72
    PNP: 03f0.7
    PNP: 03f0.7 resource base 0 size 1 align 0 gran 0 limit ffffffff flags 100 index 60
    PNP: 03f0.7 resource base 0 size 2 align 1 gran 1 limit 7ff flags 100 index 62
    PNP: 03f0.7 resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
    PNP: 03f0.8
    PNP: 03f0.a
    PNP: 03f0.a resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
    PNP: 03f0.6
    PNP: 03f0.6 resource base 0 size 8 align 3 gran 3 limit 7ff flags 100 index 60
    PNP: 03f0.6 resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
   PCI: 00:04.1
   PCI: 00:04.1 resource base 0 size 10 align 4 gran 4 limit ffff flags 100 index 20
   PCI: 00:04.2
   PCI: 00:04.2 resource base 0 size 20 align 5 gran 5 limit ffff flags 100 index 20
   PCI: 00:04.3
   PCI: 00:04.3 resource base e400 size 40 align 0 gran 0 limit ffff flags d0000100 index 1
   PCI: 00:04.3 resource base f00 size 10 align 0 gran 0 limit ffff flags d0000100 index 2
   PCI: 00:06.0
   PCI: 00:06.0 resource base 0 size 100 align 8 gran 8 limit ffff flags 100 index 10
   PCI: 00:06.0 resource base 0 size 1000 align 12 gran 12 limit ffffffffffffffff flags 201 index 14
   PCI: 00:06.0 resource base 0 size 20000 align 17 gran 17 limit ffffffff flags 2200 index 30
   PCI: 00:07.0
   PCI: 00:07.0 resource base 0 size 1000 align 12 gran 12 limit ffffffff flags 1200 index 10
   PCI: 00:07.0 resource base 0 size 20 align 5 gran 5 limit ffff flags 100 index 14
   PCI: 00:07.0 resource base 0 size 100000 align 20 gran 20 limit ffffffff flags 200 index 18
   PCI: 00:07.0 resource base 0 size 100000 align 20 gran 20 limit ffffffff flags 2200 index 30
PCI_DOMAIN: 0000 compute_resources_io: base: 0 size: 0 align: 0 gran: 0 limit: ffff
PCI: 00:01.0 compute_resources_io: base: 0 size: 0 align: 12 gran: 12 limit: ffff
PCI: 01:00.0 14 *  [0x0 - 0xff] io
PCI: 00:01.0 compute_resources_io: base: 100 size: 1000 align: 12 gran: 12 limit: ffff done
PCI: 00:01.0 1c *  [0x0 - 0xfff] io
PCI: 00:06.0 10 *  [0x1000 - 0x10ff] io
PCI: 00:04.2 20 *  [0x1400 - 0x141f] io
PCI: 00:07.0 14 *  [0x1420 - 0x143f] io
PCI: 00:04.1 20 *  [0x1440 - 0x144f] io
PCI_DOMAIN: 0000 compute_resources_io: base: 1450 size: 1450 align: 12 gran: 0 limit: ffff done
PCI_DOMAIN: 0000 compute_resources_mem: base: 0 size: 0 align: 0 gran: 0 limit: ffffffff
PCI: 00:01.0 compute_resources_prefmem: base: 0 size: 0 align: 20 gran: 20 limit: ffffffff
PCI: 01:00.0 10 *  [0x0 - 0xffffff] prefmem
PCI: 00:01.0 compute_resources_prefmem: base: 1000000 size: 1000000 align: 24 gran: 20 limit: ffffffff done
PCI: 00:01.0 compute_resources_mem: base: 0 size: 0 align: 20 gran: 20 limit: ffffffff
PCI: 01:00.0 30 *  [0x0 - 0x1ffff] mem
PCI: 01:00.0 18 *  [0x20000 - 0x20fff] mem
PCI: 00:01.0 compute_resources_mem: base: 21000 size: 100000 align: 20 gran: 20 limit: ffffffff done
PCI: 00:00.0 10 *  [0x0 - 0xfffffff] prefmem
PCI: 00:01.0 24 *  [0x10000000 - 0x10ffffff] prefmem
PCI: 00:01.0 20 *  [0x11000000 - 0x110fffff] mem
PCI: 00:07.0 18 *  [0x11100000 - 0x111fffff] mem
PCI: 00:07.0 30 *  [0x11200000 - 0x112fffff] mem
PCI: 00:06.0 30 *  [0x11300000 - 0x1131ffff] mem
PCI: 00:06.0 14 *  [0x11320000 - 0x11320fff] mem
PCI: 00:07.0 10 *  [0x11321000 - 0x11321fff] prefmem
PCI_DOMAIN: 0000 compute_resources_mem: base: 11322000 size: 11322000 align: 28 gran: 0 limit: ffffffff done
avoid_fixed_resources: PCI_DOMAIN: 0000
avoid_fixed_resources:@PCI_DOMAIN: 0000 10000000 limit 0000ffff
avoid_fixed_resources:@PCI_DOMAIN: 0000 10000100 limit ffffffff
constrain_resources: PCI_DOMAIN: 0000
constrain_resources: PCI: 00:00.0
constrain_resources: PCI: 00:01.0
constrain_resources: PCI: 01:00.0
constrain_resources: PCI: 00:04.0
constrain_resources: PNP: 03f0.0
constrain_resources: PNP: 03f0.1
constrain_resources: PNP: 03f0.2
constrain_resources: PNP: 03f0.3
constrain_resources: PNP: 03f0.5
constrain_resources: PNP: 03f0.7
constrain_resources: PNP: 03f0.8
constrain_resources: PNP: 03f0.a
constrain_resources: PNP: 03f0.6
constrain_resources: PCI: 00:04.1
constrain_resources: PCI: 00:04.2
constrain_resources: PCI: 00:04.3
constrain_resources: PCI: 00:06.0
constrain_resources: PCI: 00:07.0
avoid_fixed_resources2: PCI_DOMAIN: 0000@10000000 limit 0000ffff
        lim->base 00001000 lim->limit 0000e3ff
avoid_fixed_resources2: PCI_DOMAIN: 0000@10000100 limit ffffffff
        lim->base 00000000 lim->limit ff7fffff
Setting resources...
PCI_DOMAIN: 0000 allocate_resources_io: base:1000 size:1450 align:12 gran:0 limit:e3ff
Assigned: PCI: 00:01.0 1c *  [0x1000 - 0x1fff] io
Assigned: PCI: 00:06.0 10 *  [0x2000 - 0x20ff] io
Assigned: PCI: 00:04.2 20 *  [0x2400 - 0x241f] io
Assigned: PCI: 00:07.0 14 *  [0x2420 - 0x243f] io
Assigned: PCI: 00:04.1 20 *  [0x2440 - 0x244f] io
PCI_DOMAIN: 0000 allocate_resources_io: next_base: 2450 size: 1450 align: 12 gran: 0 done
PCI: 00:01.0 allocate_resources_io: base:1000 size:1000 align:12 gran:12 limit:e3ff
Assigned: PCI: 01:00.0 14 *  [0x1000 - 0x10ff] io
PCI: 00:01.0 allocate_resources_io: next_base: 1100 size: 1000 align: 12 gran: 12 done
PCI_DOMAIN: 0000 allocate_resources_mem: base:e0000000 size:11322000 align:28 gran:0 limit:ff7fffff
Assigned: PCI: 00:00.0 10 *  [0xe0000000 - 0xefffffff] prefmem
Assigned: PCI: 00:01.0 24 *  [0xf0000000 - 0xf0ffffff] prefmem
Assigned: PCI: 00:01.0 20 *  [0xf1000000 - 0xf10fffff] mem
Assigned: PCI: 00:07.0 18 *  [0xf1100000 - 0xf11fffff] mem
Assigned: PCI: 00:07.0 30 *  [0xf1200000 - 0xf12fffff] mem
Assigned: PCI: 00:06.0 30 *  [0xf1300000 - 0xf131ffff] mem
Assigned: PCI: 00:06.0 14 *  [0xf1320000 - 0xf1320fff] mem
Assigned: PCI: 00:07.0 10 *  [0xf1321000 - 0xf1321fff] prefmem
PCI_DOMAIN: 0000 allocate_resources_mem: next_base: f1322000 size: 11322000 align: 28 gran: 0 done
PCI: 00:01.0 allocate_resources_prefmem: base:f0000000 size:1000000 align:24 gran:20 limit:ff7fffff
Assigned: PCI: 01:00.0 10 *  [0xf0000000 - 0xf0ffffff] prefmem
PCI: 00:01.0 allocate_resources_prefmem: next_base: f1000000 size: 1000000 align: 24 gran: 20 done
PCI: 00:01.0 allocate_resources_mem: base:f1000000 size:100000 align:20 gran:20 limit:ff7fffff
Assigned: PCI: 01:00.0 30 *  [0xf1000000 - 0xf101ffff] mem
Assigned: PCI: 01:00.0 18 *  [0xf1020000 - 0xf1020fff] mem
PCI: 00:01.0 allocate_resources_mem: next_base: f1021000 size: 100000 align: 20 gran: 20 done
Root Device assign_resources, bus 0 link: 0
Setting RAM size to 384 MB
PCI_DOMAIN: 0000 assign_resources, bus 0 link: 0
PCI: 00:00.0 10 <- [0x00e0000000 - 0x00efffffff] size 0x10000000 gran 0x1c prefmem
PCI: 00:01.0 1c <- [0x0000001000 - 0x0000001fff] size 0x00001000 gran 0x0c bus 01 io
PCI: 00:01.0 24 <- [0x00f0000000 - 0x00f0ffffff] size 0x01000000 gran 0x14 bus 01 prefmem
PCI: 00:01.0 20 <- [0x00f1000000 - 0x00f10fffff] size 0x00100000 gran 0x14 bus 01 mem
PCI: 00:01.0 assign_resources, bus 1 link: 0
PCI: 01:00.0 10 <- [0x00f0000000 - 0x00f0ffffff] size 0x01000000 gran 0x18 prefmem
PCI: 01:00.0 14 <- [0x0000001000 - 0x00000010ff] size 0x00000100 gran 0x08 io
PCI: 01:00.0 18 <- [0x00f1020000 - 0x00f1020fff] size 0x00001000 gran 0x0c mem
PCI: 01:00.0 30 <- [0x00f1000000 - 0x00f101ffff] size 0x00020000 gran 0x11 romem
PCI: 00:01.0 assign_resources, bus 1 link: 0
PCI: 00:04.0 assign_resources, bus 0 link: 0
PNP: 03f0.0 60 <- [0x00000003f0 - 0x00000003f7] size 0x00000008 gran 0x03 io
PNP: 03f0.0 70 <- [0x0000000006 - 0x0000000006] size 0x00000001 gran 0x00 irq
PNP: 03f0.0 74 <- [0x0000000002 - 0x0000000002] size 0x00000001 gran 0x00 drq
PNP: 03f0.1 60 <- [0x0000000378 - 0x000000037f] size 0x00000008 gran 0x03 io
PNP: 03f0.1 70 <- [0x0000000007 - 0x0000000007] size 0x00000001 gran 0x00 irq
ERROR: PNP: 03f0.1 74 drq size: 0x0000000001 not assigned
PNP: 03f0.2 60 <- [0x00000003f8 - 0x00000003ff] size 0x00000008 gran 0x03 io
PNP: 03f0.2 70 <- [0x0000000004 - 0x0000000004] size 0x00000001 gran 0x00 irq
PNP: 03f0.3 60 <- [0x00000002f8 - 0x00000002ff] size 0x00000008 gran 0x03 io
PNP: 03f0.3 70 <- [0x0000000003 - 0x0000000003] size 0x00000001 gran 0x00 irq
PNP: 03f0.5 60 <- [0x0000000060 - 0x0000000060] size 0x00000001 gran 0x00 io
PNP: 03f0.5 62 <- [0x0000000064 - 0x0000000064] size 0x00000001 gran 0x00 io
PNP: 03f0.5 70 <- [0x0000000001 - 0x0000000001] size 0x00000001 gran 0x00 irq
PNP: 03f0.5 72 <- [0x000000000c - 0x000000000c] size 0x00000001 gran 0x00 irq
ERROR: PNP: 03f0.7 60 io size: 0x0000000001 not assigned
ERROR: PNP: 03f0.7 62 io size: 0x0000000002 not assigned
ERROR: PNP: 03f0.7 70 irq size: 0x0000000001 not assigned
ERROR: PNP: 03f0.a 70 irq size: 0x0000000001 not assigned
ERROR: PNP: 03f0.6 60 io size: 0x0000000008 not assigned
ERROR: PNP: 03f0.6 70 irq size: 0x0000000001 not assigned
PCI: 00:04.0 assign_resources, bus 0 link: 0
PCI: 00:04.1 20 <- [0x0000002440 - 0x000000244f] size 0x00000010 gran 0x04 io
PCI: 00:04.2 20 <- [0x0000002400 - 0x000000241f] size 0x00000020 gran 0x05 io
PCI: 00:06.0 10 <- [0x0000002000 - 0x00000020ff] size 0x00000100 gran 0x08 io
PCI: 00:06.0 14 <- [0x00f1320000 - 0x00f1320fff] size 0x00001000 gran 0x0c mem64
PCI: 00:06.0 30 <- [0x00f1300000 - 0x00f131ffff] size 0x00020000 gran 0x11 romem
PCI: 00:07.0 10 <- [0x00f1321000 - 0x00f1321fff] size 0x00001000 gran 0x0c prefmem
PCI: 00:07.0 14 <- [0x0000002420 - 0x000000243f] size 0x00000020 gran 0x05 io
PCI: 00:07.0 18 <- [0x00f1100000 - 0x00f11fffff] size 0x00100000 gran 0x14 mem
PCI: 00:07.0 30 <- [0x00f1200000 - 0x00f12fffff] size 0x00100000 gran 0x14 romem
PCI_DOMAIN: 0000 assign_resources, bus 0 link: 0
Root Device assign_resources, bus 0 link: 0
Done setting resources.
Show resources in subtree (Root Device)...After assigning values.
 Root Device child on link 0 APIC_CLUSTER: 0
  APIC_CLUSTER: 0 child on link 0 APIC: 00
   APIC: 00
  PCI_DOMAIN: 0000 child on link 0 PCI: 00:00.0
  PCI_DOMAIN: 0000 resource base 1000 size 1450 align 12 gran 0 limit e3ff flags 40040100 index 10000000
  PCI_DOMAIN: 0000 resource base e0000000 size 11322000 align 28 gran 0 limit ff7fffff flags 40040200 index 10000100
  PCI_DOMAIN: 0000 resource base 0 size a0000 align 0 gran 0 limit 0 flags e0004200 index a
  PCI_DOMAIN: 0000 resource base c0000 size 17f40000 align 0 gran 0 limit 0 flags e0004200 index b
   PCI: 00:00.0
   PCI: 00:00.0 resource base e0000000 size 10000000 align 28 gran 28 limit ff7fffff flags 60001200 index 10
   PCI: 00:01.0 child on link 0 PCI: 01:00.0
   PCI: 00:01.0 resource base 1000 size 1000 align 12 gran 12 limit e3ff flags 60080102 index 1c
   PCI: 00:01.0 resource base f0000000 size 1000000 align 24 gran 20 limit ff7fffff flags 60081202 index 24
   PCI: 00:01.0 resource base f1000000 size 100000 align 20 gran 20 limit ff7fffff flags 60080202 index 20
    PCI: 01:00.0
    PCI: 01:00.0 resource base f0000000 size 1000000 align 24 gran 24 limit ff7fffff flags 60001200 index 10
    PCI: 01:00.0 resource base 1000 size 100 align 8 gran 8 limit e3ff flags 60000100 index 14
    PCI: 01:00.0 resource base f1020000 size 1000 align 12 gran 12 limit ff7fffff flags 60000200 index 18
    PCI: 01:00.0 resource base f1000000 size 20000 align 17 gran 17 limit ff7fffff flags 60002200 index 30
   PCI: 00:04.0 child on link 0 PNP: 03f0.0
   PCI: 00:04.0 resource base 0 size 1000 align 0 gran 0 limit ffff flags c0000100 index 1
   PCI: 00:04.0 resource base ff800000 size 800000 align 0 gran 0 limit 0 flags d0000200 index 2
    PNP: 03f0.0
    PNP: 03f0.0 resource base 3f0 size 8 align 3 gran 3 limit 7ff flags e0000100 index 60
    PNP: 03f0.0 resource base 6 size 1 align 0 gran 0 limit 0 flags e0000400 index 70
    PNP: 03f0.0 resource base 2 size 1 align 0 gran 0 limit 0 flags e0000800 index 74
    PNP: 03f0.1
    PNP: 03f0.1 resource base 378 size 8 align 3 gran 3 limit 7ff flags e0000100 index 60
    PNP: 03f0.1 resource base 7 size 1 align 0 gran 0 limit 0 flags e0000400 index 70
    PNP: 03f0.1 resource base 0 size 1 align 0 gran 0 limit 0 flags 800 index 74
    PNP: 03f0.2
    PNP: 03f0.2 resource base 3f8 size 8 align 3 gran 3 limit 7ff flags e0000100 index 60
    PNP: 03f0.2 resource base 4 size 1 align 0 gran 0 limit 0 flags e0000400 index 70
    PNP: 03f0.3
    PNP: 03f0.3 resource base 2f8 size 8 align 3 gran 3 limit 7ff flags e0000100 index 60
    PNP: 03f0.3 resource base 3 size 1 align 0 gran 0 limit 0 flags e0000400 index 70
    PNP: 03f0.5
    PNP: 03f0.5 resource base 60 size 1 align 0 gran 0 limit ffffffff flags e0000100 index 60
    PNP: 03f0.5 resource base 64 size 1 align 0 gran 0 limit ffffffff flags e0000100 index 62
    PNP: 03f0.5 resource base 1 size 1 align 0 gran 0 limit 0 flags e0000400 index 70
    PNP: 03f0.5 resource base c size 1 align 0 gran 0 limit 0 flags e0000400 index 72
    PNP: 03f0.7
    PNP: 03f0.7 resource base 0 size 1 align 0 gran 0 limit ffffffff flags 100 index 60
    PNP: 03f0.7 resource base 0 size 2 align 1 gran 1 limit 7ff flags 100 index 62
    PNP: 03f0.7 resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
    PNP: 03f0.8
    PNP: 03f0.a
    PNP: 03f0.a resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
    PNP: 03f0.6
    PNP: 03f0.6 resource base 0 size 8 align 3 gran 3 limit 7ff flags 100 index 60
    PNP: 03f0.6 resource base 0 size 1 align 0 gran 0 limit 0 flags 400 index 70
   PCI: 00:04.1
   PCI: 00:04.1 resource base 2440 size 10 align 4 gran 4 limit e3ff flags 60000100 index 20
   PCI: 00:04.2
   PCI: 00:04.2 resource base 2400 size 20 align 5 gran 5 limit e3ff flags 60000100 index 20
   PCI: 00:04.3
   PCI: 00:04.3 resource base e400 size 40 align 0 gran 0 limit ffff flags d0000100 index 1
   PCI: 00:04.3 resource base f00 size 10 align 0 gran 0 limit ffff flags d0000100 index 2
   PCI: 00:06.0
   PCI: 00:06.0 resource base 2000 size 100 align 8 gran 8 limit e3ff flags 60000100 index 10
   PCI: 00:06.0 resource base f1320000 size 1000 align 12 gran 12 limit ff7fffff flags 60000201 index 14
   PCI: 00:06.0 resource base f1300000 size 20000 align 17 gran 17 limit ff7fffff flags 60002200 index 30
   PCI: 00:07.0
   PCI: 00:07.0 resource base f1321000 size 1000 align 12 gran 12 limit ff7fffff flags 60001200 index 10
   PCI: 00:07.0 resource base 2420 size 20 align 5 gran 5 limit e3ff flags 60000100 index 14
   PCI: 00:07.0 resource base f1100000 size 100000 align 20 gran 20 limit ff7fffff flags 60000200 index 18
   PCI: 00:07.0 resource base f1200000 size 100000 align 20 gran 20 limit ff7fffff flags 60002200 index 30
Done allocating resources.
Enabling resources...
PCI: 00:00.0 cmd <- 06
PCI: 00:01.0 bridge ctrl <- 008b
PCI: 00:01.0 cmd <- 07
PCI: 00:04.0 cmd <- 07
PCI: 00:04.1 cmd <- 01
PCI: 00:04.2 cmd <- 01
PCI: 00:04.3 cmd <- 01
PCI: 00:06.0 cmd <- 03
PCI: 00:07.0 cmd <- 03
PCI: 01:00.0 cmd <- 83
done.
Initializing devices...
Root Device init
APIC_CLUSTER: 0 init
Initializing CPU #0
CPU: vendor Intel device 673
CPU: family 06, model 07, stepping 03
microcode_info: sig = 0x00000673 pf=0x00000001 rev = 0x00000000
microcode updated to revision: 0000000e from revision 00000000
Configuring L2 cache... rdmsr(IA32_PLATFORM_ID) = 40210000:0
L2 Cache latency is 1
write_l2(4, 0)
L2 ECC Checking is enabled
L2 Physical Address Range is 4096M
Maximum cache mask is 20000
L2 Cache Mask is 4000
L2(2): 8 -> 8
size 512K... L2 Cache lines initialized
done.
Enabling cache

Setting fixed MTRRs(0-88) Type: UC
Setting fixed MTRRs(0-16) Type: WB
Setting fixed MTRRs(24-88) Type: WB
DONE fixed MTRRs
call enable_fixed_mtrr()
Setting variable MTRR 0, base:    0MB, range:  256MB, type WB
ADDRESS_MASK_HIGH=0xf
Setting variable MTRR 1, base:  256MB, range:  128MB, type WB
ADDRESS_MASK_HIGH=0xf
Zero-sized MTRR range @0KB
DONE variable MTRRs
Clear out the extra MTRR's
call enable_var_mtrr()
Leave x86_setup_var_mtrrs

MTRR check
Fixed MTRRs   : Enabled
Variable MTRRs: Enabled

Disabling local apic...done.
CPU #0 initialized
PCI: 00:00.0 init
Northbridge Init
PCI: 00:04.0 init
RTC Init
PCI: 00:04.1 init
IDE: Primary IDE interface: on
IDE: Secondary IDE interface: on
IDE: Access to legacy IDE ports: on
IDE: Primary IDE interface, drive 0: UDMA/33: off
IDE: Primary IDE interface, drive 1: UDMA/33: off
IDE: Secondary IDE interface, drive 0: UDMA/33: off
IDE: Secondary IDE interface, drive 1: UDMA/33: off
PCI: 00:04.2 init
PCI: 00:06.0 init
AIC7890 LVD termination = 1
AIC7890 SE termination  = 1
PCI: 00:07.0 init
PCI: 01:00.0 init
PNP: 03f0.0 init
PNP: 03f0.1 init
PNP: 03f0.2 init
PNP: 03f0.3 init
PNP: 03f0.5 init
PNP: 03f0.7 init
PNP: 03f0.a init
PNP: 03f0.6 init
Devices initialized
Show all devs...After init.
Root Device: enabled 1
APIC_CLUSTER: 0: enabled 1
APIC: 00: enabled 1
PCI_DOMAIN: 0000: enabled 1
PCI: 00:00.0: enabled 1
PCI: 00:01.0: enabled 1
PCI: 00:04.0: enabled 1
PNP: 03f0.0: enabled 1
PNP: 03f0.1: enabled 1
PNP: 03f0.2: enabled 1
PNP: 03f0.3: enabled 1
PNP: 03f0.5: enabled 1
PNP: 03f0.7: enabled 1
PNP: 03f0.8: enabled 1
PNP: 03f0.a: enabled 1
PCI: 00:04.1: enabled 1
PCI: 00:04.2: enabled 1
PCI: 00:04.3: enabled 1
PCI: 00:06.0: enabled 1
PCI: 00:07.0: enabled 1
PCI: 01:00.0: enabled 1
PNP: 03f0.6: enabled 1
CPU: 00: enabled 1
Initializing CBMEM area to 0x17ff0000 (65536 bytes)
Adding CBMEM entry as no. 1
Moving GDT to 17ff0200...ok
High Tables Base is 17ff0000.
Copying Interrupt Routing Table to 0x000f0000... done.
Adding CBMEM entry as no. 2
Copying Interrupt Routing Table to 0x17ff0400... done.
PIRQ table: 160 bytes.
Adding CBMEM entry as no. 3
ACPI: Writing ACPI tables at 17ff1400...
ACPI:     * FACS
ACPI:     * DSDT @ 17ff1540 Length 6a4
ACPI:     * FADT
ACPI: added table 1/32, length now 40
ACPI:    * MADT
ACPI:    * SSDT
Found 1 CPU(s).
ACPI: added table 2/32, length now 44
ACPI: done.
ACPI tables: 2387 bytes.
Adding CBMEM entry as no. 4
Writing high table forward entry at 0x00000500
Wrote coreboot table at: 00000500 - 00000518  checksum 17df
New low_table_end: 0x00000518
Now going to write high coreboot table at 0x17ffd000
rom_table_end = 0x17ffd000
Adjust low_table_end from 0x00000518 to 0x00001000
Adjust rom_table_end from 0x17ffd000 to 0x18000000
Adding high table area
coreboot memory table:
 0. 0000000000000000-0000000000000fff: CONFIGURATION TABLES
 1. 0000000000001000-000000000009ffff: RAM
 2. 00000000000c0000-0000000017feffff: RAM
 3. 0000000017ff0000-0000000017ffffff: CONFIGURATION TABLES
 4. 00000000ff800000-00000000ffffffff: RESERVED
Wrote coreboot table at: 17ffd000 - 17ffd1c0  checksum 9e74
coreboot table: 448 bytes.
Multiboot Information structure has been written.
 0. FREE SPACE 17fff000 00001000
 1. GDT        17ff0200 00000200
 2. IRQ TABLE  17ff0400 00001000
 3. ACPI       17ff1400 0000bc00
 4. COREBOOT   17ffd000 00002000
Check CBFS header at fffffc9e
magic is 4f524243
Found CBFS header at fffffc9e
Check fallback/romstage
CBFS: follow chain: fffc0000 + 38 + 2c48 + align -> fffc2c80
Check fallback/coreboot_ram
CBFS: follow chain: fffc2c80 + 38 + 18d68 + align -> fffdba40
Check fallback/payload
Got a payload
Loading segment from rom address 0xfffdba78
  data (compression=1)
  New segment dstaddr 0xe9590 memsize 0x16a70 srcaddr 0xfffdbab0 filesize 0xb6b1
  (cleaned up) New segment addr 0xe9590 size 0x16a70 offset 0xfffdbab0 filesize 0xb6b1
Loading segment from rom address 0xfffdba94
  Entry Point 0x000fc4fe
Loading Segment: addr: 0x00000000000e9590 memsz: 0x0000000000016a70 filesz: 0x000000000000b6b1
lb: [0x0000000000100000, 0x0000000000144000)
Post relocation: addr: 0x00000000000e9590 memsz: 0x0000000000016a70 filesz: 0x000000000000b6b1
using LZMA
[ 0x000e9590, 00100000, 0x00100000) <- fffdbab0
dest 000e9590, end 00100000, bouncebuffer 17f68000
Loaded segments
Jumping to boot code at fc4fe
entry    = 0x000fc4fe
lb_start = 0x00100000
lb_size  = 0x00044000
adjust   = 0x17eac000
buffer   = 0x17f68000
     elf_boot_notes = 0x00136088
adjusted_boot_notes = 0x17fe2088
Start bios (version 0.6.1.2-20110102_010818-tonchan.tondebuurincentral.com)
Found mainboard ASUS P2B-LS
Found CBFS header at 0xfffffc9e
Ram Size=0x17ff0000 (0x0000000000000000 high)
CPU Mhz=601
No apic - only the main cpu is present.
Copying PIR from 0x17ff0400 to 0x000fd7f0
Copying ACPI RSDP from 0x17ff1400 to 0x000fd7d0
SMBIOS ptr=0x000fd7b0 table=0x17fefef0
Scan for VGA option rom
Running option rom at c000:0003
Turning on vga text mode console
SeaBIOS (version 0.6.1.2-20110102_010818-tonchan.tondebuurincentral.com)

UHCI init on dev 00:04.2 (io=2400)
All threads complete.
Found 1 lpt ports
Found 2 serial ports
ATA controller 0 at 1f0/3f4/0 (irq 14 dev 21)
ATA controller 1 at 170/374/0 (irq 15 dev 21)
ata0-0: MAXTOR 6L080J4 ATA-5 Hard-Disk (74 GiBytes)
drive 0x000fd760: PCHS=16383/16/63 translation=lba LCHS=1024/255/63 s=156355584
ata0-1: HL-DT-ST DVDRAM GSA-4120B ATAPI-5 DVD/CD
PS2 keyboard initialized
All threads complete.
Scan for option roms
Press F12 for boot menu.

ebda moved from 9fc00 to 9f400
Returned 61440 bytes of ZoneHigh
e820 map has 6 items:
  0: 0000000000000000 - 000000000009f400 = 1
  1: 000000000009f400 - 00000000000a0000 = 2
  2: 00000000000f0000 - 0000000000100000 = 2
  3: 0000000000100000 - 0000000017fef000 = 1
  4: 0000000017fef000 - 0000000018000000 = 2
  5: 00000000ff800000 - 0000000100000000 = 2
enter handle_19:
  NULL
Booting from Floppy...
Boot failed: could not read the boot disk

enter handle_18:
  NULL
Booting from DVD/CD...
Device reports MEDIUM NOT PRESENT
atapi_is_ready returned -1
Boot failed: Could not read from CDROM (code 0003)
enter handle_18:
  NULL
Booting from Hard Disk...
Booting from 0000:7c00
Bring from coreboot v1 support for initializing L2 cache on Slot 1
Pentium II/III CPUs, code names Klamath, Deschutes and Katmai.

Build tested on ASUS P2B-LS and P3B-F. Boot tested on P2B-LS with 
Pentium III 600MHz, Katmai core.

Also add missing include of model_68x in slot_1, to address a
similar problem seen before r5945.

Signed-off-by: Keith Hui <buurin@gmail.com>
---
Roger - 2011-01-12 05:37:44
On Tue, Jan 11, 2011 at 11:17:17PM -0500, Keith Hui wrote:
>Hi all,
>
>Here is the new L2 cache patch. Sign-off in the patch itself. Still
>very juicy and tasty at 25k. :D
>
>Also done is including cpu/intel/model_68x again in slot_1. Otherwise
>it will die with a Coppermine P3 installed.

ug. I'm jealous.  What's the catch with Coppermine (for my CPU)?
marc bertens - 2011-01-12 23:04:40
Hi i have a question about this L2 cache, can it also be used for the P3
socket PGA370.

My nokia Ip530 has that type of CPU and as far as i know L2 cache is
disabled 

Regards,
Marc


-----Original Message-----
From: Keith Hui <buurin@gmail.com>
To: coreboot@coreboot.org
Cc: Jouni Mettälä <jtmettala@gmail.com>, Idwer Vollering
<vidwer@gmail.com>, Roger <rogerx.oss@gmail.com>
Subject: Re: [coreboot] [PATCH] SECC Pentium 2/3 users are gonna love
this
Date: Tue, 11 Jan 2011 23:17:17 -0500


Hi all,

Here is the new L2 cache patch. Sign-off in the patch itself. Still
very juicy and tasty at 25k. :D

Also done is including cpu/intel/model_68x again in slot_1. Otherwise
it will die with a Coppermine P3 installed.

My boot log on P2B-LS and a Katmai 600MHz attached.

I have optimized it some more, and added more information and
meaningful constants as I cross checked the code with Intel's
documentation. Some debugging messages are different too. Give this a
good workout.

Cheers
Keith

ps. Copying people who have sent me reports. :)

On Fri, Jan 7, 2011 at 3:45 PM, Jouni Mettälä <jtmettala@gmail.com> wrote:
> Hi
> Parts of original patch are already in coreboot. This version made cache
> work in my board now. It might need work so it doesn't break others. Here is
> part of serial capture. Rest is attached
> Initializing CPU #0
> CPU: vendor Intel device 673
> CPU: family 06, model 07, stepping 03
> microcode_info: sig = 0x00000673 pf=0x00000001 rev = 0x00000000
> microcode updated to revision: 0000000e from revision 00000000
> Configuring L2 cache... rdmsr(IA32_PLATFORM_ID) = 0, 11020000
> L2 Cache latency is 8
> Sending 0 to set_l2_register4
> L2 ECC Checking is enabled
> L2 Physical Address Range is 4096M
> Maximum cache mask is 20000
> L2 Cache Mask is 4000
> read_l2(2) = 8
> write_l2(2) = 8
> L2 Cache size is 512K
> L2 Cache lines initialized
> Signed-off-by: Jouni Mettälä <jtmettala@gmail.com>
Keith Hui - 2011-01-13 03:55:37
The L2 cache on a Coppermine doesn't need any special enabling
sequence. I just put a 1GHz Coppermine into my board and it boots fine
showing the full 256k cache. This patch doesn't even apply to them
anyway.

Cheers
Keith

On Wed, Jan 12, 2011 at 6:04 PM, Marc Bertens <mbertens@xs4all.nl> wrote:
> Hi i have a question about this L2 cache, can it also be used for the P3
> socket PGA370.
>
> My nokia Ip530 has that type of CPU and as far as i know L2 cache is
> disabled
>
> Regards,
> Marc
>
>
> -----Original Message-----
> From: Keith Hui <buurin@gmail.com>
> To: coreboot@coreboot.org
> Cc: Jouni Mettälä <jtmettala@gmail.com>, Idwer Vollering <vidwer@gmail.com>,
> Roger <rogerx.oss@gmail.com>
> Subject: Re: [coreboot] [PATCH] SECC Pentium 2/3 users are gonna love this
> Date: Tue, 11 Jan 2011 23:17:17 -0500
>
>
> Hi all,
>
> Here is the new L2 cache patch. Sign-off in the patch itself. Still
> very juicy and tasty at 25k. :D
>
> Also done is including cpu/intel/model_68x again in slot_1. Otherwise
> it will die with a Coppermine P3 installed.
>
> My boot log on P2B-LS and a Katmai 600MHz attached.
>
> I have optimized it some more, and added more information and
> meaningful constants as I cross checked the code with Intel's
> documentation. Some debugging messages are different too. Give this a
> good workout.
>
> Cheers
> Keith
>
> ps. Copying people who have sent me reports. :)
>
> On Fri, Jan 7, 2011 at 3:45 PM, Jouni Mettälä <jtmettala@gmail.com> wrote:
>> Hi
>> Parts of original patch are already in coreboot. This version made cache
>> work in my board now. It might need work so it doesn't break others. Here
>> is
>> part of serial capture. Rest is attached
>> Initializing CPU #0
>> CPU: vendor Intel device 673
>> CPU: family 06, model 07, stepping 03
>> microcode_info: sig = 0x00000673 pf=0x00000001 rev = 0x00000000
>> microcode updated to revision: 0000000e from revision 00000000
>> Configuring L2 cache... rdmsr(IA32_PLATFORM_ID) = 0, 11020000
>> L2 Cache latency is 8
>> Sending 0 to set_l2_register4
>> L2 ECC Checking is enabled
>> L2 Physical Address Range is 4096M
>> Maximum cache mask is 20000
>> L2 Cache Mask is 4000
>> read_l2(2) = 8
>> write_l2(2) = 8
>> L2 Cache size is 512K
>> L2 Cache lines initialized
>> Signed-off-by: Jouni Mettälä <jtmettala@gmail.com
>>
> --
> coreboot mailing list: coreboot@coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot
>
>
Roger - 2011-01-13 05:33:37
On Wed, Jan 12, 2011 at 10:55:37PM -0500, Keith Hui wrote:
>The L2 cache on a Coppermine doesn't need any special enabling
>sequence. I just put a 1GHz Coppermine into my board and it boots fine
>showing the full 256k cache. This patch doesn't even apply to them
>anyway.

FYI: Have 450P3 and 2x750P3's here and none of my coreboot logs state anything
about L2 being activated.  From what you're saying, the L2 cache is entirely
automatically activated on Coppermines.

Cheers.
Roger - 2011-01-13 09:37:05
On Tue, Jan 11, 2011 at 11:17:17PM -0500, Keith Hui wrote:
>Hi all,
>
>Here is the new L2 cache patch. Sign-off in the patch itself. Still
>very juicy and tasty at 25k. :D
>
>Also done is including cpu/intel/model_68x again in slot_1. Otherwise
>it will die with a Coppermine P3 installed.
>
>My boot log on P2B-LS and a Katmai 600MHz attached.
>
>I have optimized it some more, and added more information and
>meaningful constants as I cross checked the code with Intel's
>documentation. Some debugging messages are different too. Give this a
>good workout.
>
>Cheers
>Keith

I applied this patch as well here, and compiles fine.

NOTE: Although I tested execution and it doesn't appear to break anything, I
have the Coppermine CPU's and not these specific CPU's.
Keith Hui - 2011-01-31 17:53:05
On Fri, Jan 14, 2011 at 3:47 AM, Roger <rogerx.oss@gmail.com> wrote:
> On Tue, Jan 11, 2011 at 11:17:17PM -0500, Keith Hui wrote:
>>Hi all,
>>
>>Here is the new L2 cache patch. Sign-off in the patch itself. Still
>>very juicy and tasty at 25k. :D
>>
>>Also done is including cpu/intel/model_68x again in slot_1. Otherwise
>>it will die with a Coppermine P3 installed.
>>
>>My boot log on P2B-LS and a Katmai 600MHz attached.
>>
>>I have optimized it some more, and added more information and
>>meaningful constants as I cross checked the code with Intel's
>>documentation. Some debugging messages are different too. Give this a
>>good workout.
>
> Acked-by: Roger Zauner <rogerx.oss@gmail.com>
>
> Wondering if people are still waiting for acked-by. ... acked it, code compiles
> for my "Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host
> bridge", but have Coppermine CPU's so the code is ignored.

Also wondering the status of this.
Keith Hui - 2011-03-02 21:33:16
ping3?

On Mon, Jan 31, 2011 at 12:53 PM, Keith Hui <buurin@gmail.com> wrote:
> On Fri, Jan 14, 2011 at 3:47 AM, Roger <rogerx.oss@gmail.com> wrote:
>> On Tue, Jan 11, 2011 at 11:17:17PM -0500, Keith Hui wrote:
>>>Hi all,
>>>
>>>Here is the new L2 cache patch. Sign-off in the patch itself. Still
>>>very juicy and tasty at 25k. :D
>>>
>>>Also done is including cpu/intel/model_68x again in slot_1. Otherwise
>>>it will die with a Coppermine P3 installed.
>>>
>>>My boot log on P2B-LS and a Katmai 600MHz attached.
>>>
>>>I have optimized it some more, and added more information and
>>>meaningful constants as I cross checked the code with Intel's
>>>documentation. Some debugging messages are different too. Give this a
>>>good workout.
>>
>> Acked-by: Roger Zauner <rogerx.oss@gmail.com>
>>
>> Wondering if people are still waiting for acked-by. ... acked it, code compiles
>> for my "Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host
>> bridge", but have Coppermine CPU's so the code is ignored.
>
> Also wondering the status of this.
>

Patch

Index: src/include/cpu/intel/l2_cache.h
===================================================================
--- src/include/cpu/intel/l2_cache.h	(revision 0)
+++ src/include/cpu/intel/l2_cache.h	(revision 0)
@@ -0,0 +1,102 @@ 
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2010 Keith Hui <buurin@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* The L2 cache definitions here only apply to SECC/SECC2 P6 family CPUs
+ * with Klamath (63x), Deschutes (65x) and Katmai (67x) cores.
+ * It is not required for Coppermine (68x) and Tualatin (6bx) cores.
+ * It is currently not known if Celerons with Mendocino core require
+ * the special initialization.
+ * Covington-core Celerons do not have L2 cache.
+ */
+ 
+/* This is a straight port from coreboot v1. */
+ 
+#ifndef __P6_L2_CACHE_H
+#define __P6_L2_CACHE_H
+
+#define IA32_PLATFORM_ID	0x17
+#define EBL_CR_POWERON	0x2A
+
+#define BBL_CR_D0	0x88
+#define BBL_CR_D1	0x89
+#define BBL_CR_D2	0x8A
+#define BBL_CR_D3	0x8B
+
+#define BBL_CR_ADDR	0x116
+#define BBL_CR_DECC	0x118
+#define BBL_CR_CTL	0x119
+#define BBL_CR_TRIG	0x11A
+#define BBL_CR_BUSY	0x11B
+#define BBL_CR_CTL3	0x11E
+
+#define BBLCR3_L2_CONFIGURED       (1<<0)
+/* bits [4:1] */
+#define BBLCR3_L2_LATENCY          0x1e 
+#define BBLCR3_L2_ECC_CHECK_ENABLE (1<<5)
+#define BBLCR3_L2_ADDR_PARITY_ENABLE (1<<6)
+#define BBLCR3_L2_CRTN_PARITY_ENABLE (1<<7)
+#define BBLCR3_L2_ENABLED          (1<<8)
+/* bits [17:13] */
+#define BBLCR3_L2_SIZE             (0x1f << 13)
+#define BBLCR3_L2_SIZE_256K        (0x01 << 13)
+#define BBLCR3_L2_SIZE_512K        (0x02 << 13)
+#define BBLCR3_L2_SIZE_1M          (0x04 << 13)
+#define BBLCR3_L2_SIZE_2M          (0x08 << 13)
+#define BBLCR3_L2_SIZE_4M          (0x10 << 13)
+/* bits [22:20] */
+#define BBLCR3_L2_PHYSICAL_RANGE   (0x7 << 20);
+/* TODO: This bitmask does not agree with Intel's documentation.
+ * Get confirmation one way or another.
+ */
+#define BBLCR3_L2_SUPPLIED_ECC     0x40000
+
+#define BBLCR3_L2_HARDWARE_DISABLE (1<<23)
+/* Also known as... */
+#define BBLCR3_L2_NOT_PRESENT      (1<<23)
+
+/* L2 commands */
+#define L2CMD_RLU 0x0c /* 01100 Data read w/ LRU update */
+#define L2CMD_TRR 0x0e /* 01110 Tag read with data read */
+#define L2CMD_TI  0x0f /* 01111 Tag inquiry */
+#define L2CMD_CR  0x02 /* 00010 L2 control register read */
+#define L2CMD_CW  0x03 /* 00011 L2 control register write */
+#define L2CMD_TWR 0x08 /* 010-- Tag read w/ data read */
+#define L2CMD_TWW 0x1c /* 111-- Tag write w/ data write */
+#define L2CMD_TW  0x10 /* 100-- Tag write */
+/* MESI encode for L2 commands above */
+#define L2CMD_MESI_M 3
+#define L2CMD_MESI_E 2
+#define L2CMD_MESI_S 1
+#define L2CMD_MESI_I 0
+
+extern int calculate_l2_latency(void);
+extern int signal_l2(u32 address_low, u32 data_high, u32 data_low, int way, u8 command);
+extern int read_l2(u32 address);
+extern int write_l2(u32 address, u32 data);
+extern int test_l2_address_alias(u32 address1, u32 address2,
+				 u32 data_high, u32 data_low);
+extern int calculate_l2_cache_size(void);
+extern int calculate_l2_physical_address_range(void);
+extern int set_l2_ecc(void);
+
+extern int p6_configure_l2_cache(void);
+
+#endif /* __P6_L2_CACHE_H */
Index: src/cpu/intel/model_65x/model_65x_init.c
===================================================================
--- src/cpu/intel/model_65x/model_65x_init.c	(revision 6247)
+++ src/cpu/intel/model_65x/model_65x_init.c	(working copy)
@@ -27,6 +27,7 @@ 
 #include <cpu/x86/lapic.h>
 #include <cpu/intel/microcode.h>
 #include <cpu/x86/cache.h>
+#include <cpu/intel/l2_cache.h>
 
 static u32 microcode_updates[] = {
 	#include "microcode-410-MU16522d.h"
@@ -64,6 +65,8 @@ 
 	/* Update the microcode */
 	intel_update_microcode(microcode_updates);
 
+	p6_configure_l2_cache();
+
 	/* Enable the local cpu apics */
 	setup_lapic();
 };
Index: src/cpu/intel/model_67x/model_67x_init.c
===================================================================
--- src/cpu/intel/model_67x/model_67x_init.c	(revision 6247)
+++ src/cpu/intel/model_67x/model_67x_init.c	(working copy)
@@ -26,6 +26,7 @@ 
 #include <cpu/intel/microcode.h>
 #include <cpu/x86/cache.h>
 #include <cpu/x86/msr.h>
+#include <cpu/intel/l2_cache.h>
 
 static const uint32_t microcode_updates[] = {
 	/* Include microcode updates here. */
@@ -46,6 +47,9 @@ 
 	/* Update the microcode */
 	intel_update_microcode(microcode_updates);
 
+	/* Initialize L2 cache */
+	p6_configure_l2_cache();
+	
 	/* Turn on caching if we haven't already */
 	x86_enable_cache();
 
Index: src/cpu/intel/slot_1/l2_cache.c
===================================================================
--- src/cpu/intel/slot_1/l2_cache.c	(revision 0)
+++ src/cpu/intel/slot_1/l2_cache.c	(revision 0)
@@ -0,0 +1,810 @@ 
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2000 Denis Dowling <dpd@alphalink.com.au>
+ * Copyright (C) 2010 Keith Hui <buurin@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/*
+ * Intel Pentium L2 Cache initialization. 
+ * This code was developed by reverse engineering 
+ * the BIOS. Where the code accesses documented 
+ * registers I have added comments as best I can.
+ * Some undocumented registers on the Pentium II are
+ * used so some of the documentation is incomplete
+ *
+ * References:
+ * Intel Architecture Software Developer's Manual
+ * Volume 3B: System Programming Guide, Part 2 (#253669)
+ * Appendix B.9
+ */
+ 
+/* This code is ported from coreboot v1. 
+ * The L2 cache initalization sequence here only apply to SECC/SECC2 P6 family
+ * CPUs with Klamath (63x), Deschutes (65x) and Katmai (67x) cores.
+ * It is not required for Coppermine (68x) and Tualatin (6bx) cores.
+ * It is currently not known if Celerons with Mendocino (66x) core require the
+ * special initialization.
+ * Covington-core Celerons do not have L2 cache.
+ */
+ 
+#include <stdint.h>
+#include <console/console.h>
+#include <string.h>
+#include <cpu/cpu.h>
+#include <cpu/x86/mtrr.h>
+#include <cpu/intel/l2_cache.h>
+#include <cpu/x86/cache.h>
+#include <cpu/x86/msr.h>
+
+/* Latency Tables */
+struct latency_entry {
+	u8 key;
+	u8 value;
+};
+/*
+Latency maps for Deschutes and Katmai.
+No such mapping is available for Klamath.
+
+Cache latency to
+be written to L2 -----++++
+control register      ||||
+0000 xx 00 -----> 000 cccc 0
+||||    00 66MHz
+||||    10 100MHz
+||||    01 133MHz (Katmai "B" only)
+++++------ CPU frequency multiplier
+
+0000 2x
+0001 3x
+0010 4x
+0011 5x
+0100 2.5x
+0101 3.5x
+0110 4.5x
+0111 5.5x
+1000 6x
+1001 7x
+1010 8x
+1011 Reserved
+1100 6.5x
+1101 7.5x
+1110 1.5x
+1111 2x
+
+*/
+static const struct latency_entry latency_650_t0[] = {
+	{0x10, 0x02}, {0x50, 0x02}, {0x20, 0x04}, {0x60, 0x06},
+	{0x00, 0x08}, {0x40, 0x0C}, {0x12, 0x06}, {0x52, 0x0A},
+	{0x22, 0x0E}, {0x62, 0x10}, {0x02, 0x10}, {0xFF, 0x00}
+};
+
+static const struct latency_entry latency_650_t1[] = {
+	{0x12, 0x14}, {0x52, 0x16}, {0x22, 0x16}, {0x62, 0x16},
+	{0xFF, 0x00}
+};
+
+static const struct latency_entry latency_670_t0[] = {
+	{0x60, 0x06}, {0x00, 0x08}, {0x12, 0x06}, {0x52, 0x0A},
+	{0x22, 0x0E}, {0x62, 0x10}, {0x02, 0x10}, {0x42, 0x02},
+	{0x11, 0x0E}, {0x51, 0x0C}, {0x21, 0x02}, {0x61, 0x10},
+	{0x01, 0x10}, {0x41, 0x02}, {0xFF, 0x00}
+};
+
+static const struct latency_entry latency_670_t1[] = {
+	{0x22, 0x18}, {0x62, 0x18}, {0x02, 0x1A}, {0x11, 0x18},
+	{0xFF, 0x00}
+};
+
+static const struct latency_entry latency_670_t2[] = {
+	{0x22, 0x12}, {0x62, 0x14}, {0x02, 0x16}, {0x42, 0x1E},
+	{0x11, 0x12}, {0x51, 0x16}, {0x21, 0x1E}, {0x61, 0x14},
+	{0x01, 0x16}, {0x41, 0x1E}, {0xFF, 0x00}
+};
+
+/* Latency tables for 650 model/type */
+static const struct latency_entry *latency_650[] = {
+	latency_650_t0, latency_650_t1, latency_650_t1
+};
+
+/* Latency tables for 670 model/type */
+static const struct latency_entry *latency_670[] = {
+	latency_670_t0, latency_670_t1, latency_670_t2
+};
+
+int calculate_l2_latency(void)
+{
+	u32 eax, l, signature;
+	const struct latency_entry *latency_table, *le;
+	msr_t msr;
+
+	/* First, attempt to get cache latency value from
+	   IA32_PLATFORM_ID[56:53]. (L2 Cache Latency Read)
+	 */
+	msr = rdmsr(IA32_PLATFORM_ID);
+
+	printk(BIOS_DEBUG,"rdmsr(IA32_PLATFORM_ID) = %x:%x\n", msr.hi, msr.lo);
+
+	l = (msr.hi >> 20) & 0x1e;
+
+	if (l == 0) {
+		/* If latency value isn't available from
+		   IA32_PLATFORM_ID[56:53], read it from
+		   L2 control register 0 for lookup from
+		   tables. */
+		int t, a;
+
+		/* The raw code is read from L2 register 0, bits [7:4]. */
+		a = read_l2(0);
+		if (a < 0)
+			return -1;
+
+		a &= 0xf0;
+
+		if ((a & 0x20) == 0)
+			t = 0;
+		else if (a == 0x20)
+			t = 1;
+		else if (a == 0x30)
+			t = 2;
+		else
+			return -1;
+		
+		printk(BIOS_DEBUG,"L2 latency type = %x\n", t);
+
+		/* Get CPUID family/model */
+		signature = cpuid_eax(1) & 0xfff0;
+
+		/* Read EBL_CR_POWERON */
+		msr = rdmsr(EBL_CR_POWERON);
+		/* Get clock multiplier and FSB frequency.
+		 * Multiplier is in [25:22]. 
+		 * FSB is in [19:18] in Katmai, [19] in Deschutes ([18] is zero for them).
+		 */
+		eax = msr.lo >> 18;
+		if (signature == 0x650) {
+			eax &= ~0xf2;
+			latency_table = latency_650[t];
+		} else if (signature == 0x670) {
+			eax &= ~0xf3;
+			latency_table = latency_670[t];
+		} else
+			return -1;
+
+		/* Search table for matching entry */
+		for (le = latency_table; le->key != eax; le++) {
+			/* Fail if we get to the end of the table */
+			if (le->key == 0xff) {
+				printk(BIOS_DEBUG, "Could not find key %02x in latency table\n", eax);
+				return -1;
+			}
+		}
+
+		l = le->value;
+	}
+
+	printk(BIOS_DEBUG,"L2 Cache latency is %d\n", l / 2);
+
+	/* Writes the calculated latency in BBL_CR_CTL3[4:1]. */
+	msr = rdmsr(BBL_CR_CTL3);
+	msr.lo &= 0xffffffe1;
+	msr.lo |= l;
+	wrmsr(BBL_CR_CTL3, msr);
+
+	return 0;
+}
+
+
+/* Setup address, data_high:data_low into the L2
+ * control registers and then issue command with correct cache way
+ */
+int signal_l2(u32 address, u32 data_high, u32 data_low, int way, u8 command)
+{
+	int i;
+	msr_t msr;
+
+	/* Write L2 Address to BBL_CR_ADDR */
+	msr.lo = address;
+	msr.hi = 0;
+	wrmsr(BBL_CR_ADDR, msr);
+
+	/* Write data to BBL_CR_D{0..3} */
+	msr.lo = data_low;
+	msr.hi = data_high;
+	for (i = BBL_CR_D0; i <= BBL_CR_D3; i++) {
+		wrmsr(i, msr);
+	}
+
+	/* Put the command and way into BBL_CR_CTL */
+	msr = rdmsr(BBL_CR_CTL);
+	msr.lo = (msr.lo & 0xfffffce0) | command | (way << 8);
+	wrmsr(BBL_CR_CTL, msr);
+
+	/* Trigger L2 controller */
+	msr.lo = 0;
+	msr.hi = 0;
+	wrmsr(BBL_CR_TRIG, msr);
+
+	/* Poll the controller to see when done */
+	for (i = 0; i < 0x100; i++) {
+		/* Read BBL_CR_BUSY */
+		msr = rdmsr(BBL_CR_BUSY);
+		/* If not busy then return */
+		if ((msr.lo & 1) == 0)
+			return 0;
+	}
+
+	/* Return timeout code */
+	return -1;
+}
+
+/* Read the L2 Cache controller register at given address */
+int read_l2(u32 address)
+{
+	msr_t msr;
+
+	/* Send a L2 Control Register Read to L2 controller */
+	if (signal_l2(address << 5, 0, 0, 0, L2CMD_CR) != 0)
+		return -1;
+
+	/* If OK then get the result from BBL_CR_ADDR */
+	msr = rdmsr(BBL_CR_ADDR);
+	return (msr.lo >> 0x15);
+
+}
+
+/* Write data into the L2 controller register at address */
+int write_l2(u32 address, u32 data)
+{
+	int v1, v2, i;
+
+	v1 = read_l2(0);
+	if (v1 < 0)
+		return -1;
+
+	v2 = read_l2(2);
+	if (v2 < 0)
+		return -1;
+
+	if ((v1 & 0x20) == 0) {
+		v2 &= 0x3;
+		v2++;
+	} else
+		v2 &= 0x7;
+	
+	/* This write has to be replicated to a number of places. Not sure what. */
+	
+	for (i = 0; i < v2; i++) {
+
+		u32 data1, data2;
+		// Bits legend
+		// data1   = ffffffff
+		// data2   = 000000dc
+		// address = 00aaaaaa
+		// Final address signalled:
+		// 000fffff fff000c0 000dcaaa aaa00000
+		data1 = data & 0xff;
+		data1 = data1 << 21;
+		data2 = (i << 11) & 0x1800;
+		data1 |= data2;
+		data2 <<= 6;
+		data2 &= 0x20000;
+		data1 |= data2;
+
+		/* Signal L2 controller */
+		if (signal_l2((address << 5) | data1, 0, 0, 0, 3))
+			return -1;
+	}
+	return 0;
+}
+
+/* Write data_high:data_low into the cache at address1. Test address2
+ * to see if the same data is returned. Return 0 if the data matches.
+ * return lower 16 bits if mismatched data if mismatch. Return -1
+ * on error
+ */
+int test_l2_address_alias(u32 address1, u32 address2,
+				 u32 data_high, u32 data_low)
+{
+	int d;
+	msr_t msr;
+
+	/* Tag Write with Data Write for L2 */
+	if (signal_l2(address1, data_high, data_low, 0, L2CMD_TWW))
+		return -1;
+
+	/* Tag Read with Data Read for L2 */
+	if (signal_l2(address2, 0, 0, 0, L2CMD_TRR))
+		return -1;
+
+	/* Read data from BBL_CR_D[0-3] */
+	for (d = BBL_CR_D0; d <= BBL_CR_D3; d++) {
+		msr = rdmsr(d);
+		if (msr.lo != data_low || msr.hi != data_high)
+			return (msr.lo & 0xffff);
+	}
+
+	return 0;
+}
+
+/* Calculates the L2 cache size.
+ *
+ * Reference: Intel(R) 64 and IA-32 Architectures Software Developer’s Manual
+ *            Volume 3B: System Programming Guide, Part 2, Intel pub. 253669, pg. B-172.
+ *
+ */
+int calculate_l2_cache_size(void)
+{
+	int v;
+	msr_t msr;
+	u32 cache_setting;
+	u32 address, size, eax, bblcr3;
+
+	v = read_l2(0);
+	if (v < 0)
+		return -1;
+	if ((v & 0x20) == 0) {
+		msr = rdmsr(BBL_CR_CTL3);		
+		bblcr3 = msr.lo & ~BBLCR3_L2_SIZE;
+		/*
+		 * Successively write in all the possible cache size per bank
+		 * into BBL_CR_CTL3[17:13], starting from 256KB (00001) to 4MB (10000),
+		 * and read the last value written and accepted by the cache.
+		 * 
+		 * No idea why these bits are writable at all.
+		 */
+		for (cache_setting = BBLCR3_L2_SIZE_256K;
+		     cache_setting <= BBLCR3_L2_SIZE_4M; cache_setting <<= 1) {
+
+			eax = bblcr3 | cache_setting;
+			msr.lo = eax;
+			wrmsr(BBL_CR_CTL3, msr);
+			msr = rdmsr(BBL_CR_CTL3);
+
+			/* Value not accepted */
+			if (msr.lo != eax)
+				break;
+		}
+
+		/* Backtrack to the last value that worked... */
+		cache_setting >>= 1;
+
+		/* and write it into BBL_CR_CTL3 */
+		msr.lo &= ~BBLCR3_L2_SIZE;
+		msr.lo |= (cache_setting & BBLCR3_L2_SIZE);
+
+		wrmsr(BBL_CR_CTL3, msr);
+
+		printk(BIOS_DEBUG,"Maximum cache mask is %x\n", cache_setting);
+
+		/* For now, BBL_CR_CTL3 has the highest cache "size" that register
+		 * will accept. Now we'll ping the cache and see where it wraps.
+		 */
+		
+		/* Write aaaaaaaa:aaaaaaaa to address 0 in the l2 cache.
+		 * If this "alias test" returns an "address", it means the 
+		 * cache cannot be written to properly, and we have a problem.
+		 */
+		v = test_l2_address_alias(0, 0, 0xaaaaaaaa, 0xaaaaaaaa);
+		if (v != 0)
+			return -1;
+
+		/* Start with 32K wrap point (256KB actually) */
+		size = 1;
+		address = 0x8000;
+
+		while (1) {
+			v = test_l2_address_alias(address, 0, 0x55555555,
+						  0x55555555);
+			// Write failed.
+			if (v < 0)
+				return -1;
+			// It wraps here.
+			else if (v == 0)
+				break;
+
+			size <<= 1;
+			address <<= 1;
+
+			if (address > 0x200000)
+				return -1;
+		}
+
+		/* Mask size */
+		size &= 0x3e;
+
+		/* Shift to [17:13] */
+		size <<= 12;
+
+		/* Set this into BBL_CR_CTL3 */
+		msr = rdmsr(BBL_CR_CTL3);
+		msr.lo &= ~BBLCR3_L2_SIZE;
+		msr.lo |= size;
+		wrmsr(BBL_CR_CTL3, msr);
+
+		printk(BIOS_DEBUG,"L2 Cache Mask is %x\n", size);
+
+		/* Shift to [6:2] */
+		size >>= 11;
+
+		v = read_l2(2);
+
+		if (v < 0)
+			return -1;
+
+		printk(BIOS_DEBUG,"L2(2): %x ", v);
+
+		v &= 0x3;
+
+		/* Shift size right by v */
+		size >>= v;
+
+		/* Or in this size */
+		v |= size;
+
+		printk(BIOS_DEBUG,"-> %x\n", v);
+
+		if (write_l2(2, v) != 0)
+			return -1;
+	} else {
+		// Some cache size information is available from L2 registers.
+		// Work from there.
+		int b, c;
+
+		v = read_l2(2);
+
+		printk(BIOS_DEBUG,"L2(2) = %x\n", v);
+
+		if (v < 0)
+			return -1;
+
+		// L2 register 2 bitmap: cc---bbb
+		b = v & 0x7;
+		c = v >> 6;
+
+		v = 1 << c * b;
+
+		v &= 0xf;
+
+		printk(BIOS_DEBUG,"Calculated a = %x\n", v);
+
+		if (v == 0)
+			return -1;
+
+		/* Shift to 17:14 */
+		v <<= 14;
+
+		/* Write this size into BBL_CR_CTL3 */
+		msr = rdmsr(BBL_CR_CTL3);
+		msr.lo &= ~BBLCR3_L2_SIZE;
+		msr.lo |= v;
+		wrmsr(BBL_CR_CTL3, msr);
+	}
+
+	return 0;
+}
+
+// L2 physical address range can be found from L2 control register 3, bits [2:0].
+int calculate_l2_physical_address_range(void)
+{
+	int r0, r3;
+	msr_t msr;
+
+	r3 = read_l2(3);
+	if (r3 < 0)
+		return -1;
+
+	r0 = read_l2(0);
+	if (r0 < 0)
+		return -1;
+
+	if (r0 & 0x20)
+		r3 = 0x7;
+	else
+		r3 &= 0x7;
+
+	printk(BIOS_DEBUG,"L2 Physical Address Range is %dM\n", (1 << r3) * 512);
+
+	/* Shift into [22:20] to be saved into BBL_CR_CTL3. */
+	r3 = r3 << 20;
+
+	msr = rdmsr(BBL_CR_CTL3);
+	msr.lo &= ~BBLCR3_L2_PHYSICAL_RANGE;
+	msr.lo |= r3;
+	wrmsr(BBL_CR_CTL3, msr);
+
+	return 0;
+}
+
+int set_l2_ecc(void)
+{
+	u32 eax;
+	const u32 data1 = 0xaa55aa55;
+	const u32 data2 = 0xaaaaaaaa;
+	msr_t msr;
+
+	/* Set User Supplied ECC in BBL_CR_CTL */
+	msr = rdmsr(BBL_CR_CTL);
+	msr.lo |= BBLCR3_L2_SUPPLIED_ECC;
+	wrmsr(BBL_CR_CTL, msr);
+
+	/* Write a value into the L2 Data ECC register BBL_CR_DECC */
+	msr.lo = data1;
+	msr.hi = 0;
+	wrmsr(BBL_CR_DECC, msr);
+
+	if (test_l2_address_alias(0, 0, data2, data2) < 0)
+		return -1;
+
+	/* Read back ECC from BBL_CR_DECC */
+	msr = rdmsr(BBL_CR_DECC);
+	eax = msr.lo;
+
+	if (eax == data1) {
+		printk(BIOS_DEBUG,"L2 ECC Checking is enabled\n");
+
+		/* Set ECC Check Enable in BBL_CR_CTL3 */
+		msr = rdmsr(BBL_CR_CTL3);
+		msr.lo |= BBLCR3_L2_ECC_CHECK_ENABLE;
+		wrmsr(BBL_CR_CTL3, msr);
+	}
+
+	/* Clear User Supplied ECC in BBL_CR_CTL */
+	msr = rdmsr(BBL_CR_CTL);
+	msr.lo &= ~BBLCR3_L2_SUPPLIED_ECC;
+	wrmsr(BBL_CR_CTL, msr);
+
+	return 0;
+}
+
+/*
+ * This is the function called from CPU initialization
+ * driver to set up P6 family L2 cache.
+ */
+
+int p6_configure_l2_cache(void)
+{
+	msr_t msr, bblctl3;
+	unsigned int eax;
+	u16 signature;
+	int cache_size, bank;
+	int result, calc_eax;
+	int v, a;
+
+	int badclk1, badclk2, clkratio;
+	int crctl3_or;
+
+	printk(BIOS_INFO, "Configuring L2 cache... ");
+	
+	/* Read BBL_CR_CTL3 */
+	bblctl3 = rdmsr(BBL_CR_CTL3);
+	/* If bit 23 (L2 Hardware disable) is set then done */
+	/* These would be Covington core Celerons with no L2 cache */
+	if (bblctl3.lo & BBLCR3_L2_NOT_PRESENT) {
+		printk(BIOS_INFO,"hardware disabled\n");
+		return 0;
+	}
+
+	signature = cpuid_eax(1) & 0xfff0;
+
+	/* Klamath-specific bit settings for certain
+	   preliminary checks.
+	 */
+	if (signature == 0x630) {
+		clkratio = 0x1c00000;
+		badclk2 = 0x1000000;
+		crctl3_or = 0x44000;
+	} else {
+		clkratio = 0x3c00000;
+		badclk2 = 0x3000000;
+		crctl3_or = 0x40000;
+	}
+	badclk1 = 0xc00000;
+
+	/* Read EBL_CR_POWERON */
+	msr = rdmsr(EBL_CR_POWERON);
+	eax = msr.lo;
+	/* Mask out [22-25] Clock frequency ratio */
+	eax &= clkratio;
+	if (eax == badclk1 || eax == badclk2) {
+		printk(BIOS_ERR, "Incorrect clock frequency ratio %x\n", eax);
+		return -1;
+	}
+
+	disable_cache();
+
+	/* Mask out from BBL_CR_CTL3:
+	 * [0] L2 Configured
+	 * [5] ECC Check Enable
+	 * [6] Address Parity Check Enable
+	 * [7] CRTN Parity Check Enable
+	 * [8] L2 Enabled
+	 * [12:11] Number of L2 banks
+	 * [17:13] Cache size per bank
+	 * [18] (Set below)
+	 * [22:20] L2 Physical Address Range Support
+	 */
+	bblctl3.lo &= 0xff88061e;
+	/* Set:
+	 * [17:13] = 00010 = 512Kbyte Cache size per bank (63x)
+	 * [17:13] = 00000 = 128Kbyte Cache size per bank (all others)
+	 * [18] Cache state error checking enable
+	 */
+	bblctl3.lo |= crctl3_or;
+
+	/* Write BBL_CR_CTL3 */
+	wrmsr(BBL_CR_CTL3, bblctl3);
+
+	if (signature != 0x630) {
+		eax = bblctl3.lo;
+
+		/* Set the l2 latency in BBL_CR_CTL3 */
+		if (calculate_l2_latency() != 0)
+			goto bad;
+
+		/* Read the new latency values back */
+		bblctl3 = rdmsr(BBL_CR_CTL3);
+		calc_eax = bblctl3.lo;
+
+		/* Write back the original default value */
+		bblctl3.lo = eax;
+		wrmsr(BBL_CR_CTL3, bblctl3);
+
+		/* Write BBL_CR_CTL3[27:26] (reserved??) to bits [1:0] of L2 register 4.
+		 * Apparently all other bits must be preserved, hence these code.
+		 */
+
+		v = (calc_eax >> 26) & 0x3;
+
+		printk(BIOS_DEBUG,"write_l2(4, %x)\n", v);
+
+		a = read_l2(4);
+		if (a >= 0)
+		{
+			a &= 0xfffc;
+			a |= v;
+			a = write_l2(4, a);
+			/* a now contains result code from write_l2() */
+		}
+		if (a != 0)
+			goto bad;
+
+		/* Restore the correct latency value into BBL_CR_CTL3 */
+		bblctl3.lo = calc_eax;
+		wrmsr(BBL_CR_CTL3, bblctl3);
+	} /* ! 63x CPU */
+
+	/* Read L2 register 0 */
+	v = read_l2(0);
+
+	/* If L2(0)[5] set (and can be read properly), enable CRTN and address parity
+	 */
+	if (v >= 0 && (v & 0x20)) {
+		bblctl3 = rdmsr(BBL_CR_CTL3);
+		bblctl3.lo |= (BBLCR3_L2_ADDR_PARITY_ENABLE |
+		               BBLCR3_L2_CRTN_PARITY_ENABLE);
+		wrmsr(BBL_CR_CTL3, bblctl3);
+	}
+
+	/* If something goes wrong at L2 ECC setup, cache ECC
+	 * will just remain disabled.
+	 */
+	set_l2_ecc();
+
+	if (calculate_l2_physical_address_range() != 0) {
+		printk(BIOS_ERR, "Failed to calculate L2 physical address range");
+		goto bad;
+	}
+
+	if (calculate_l2_cache_size() != 0) {
+		printk(BIOS_ERR, "Failed to calculate L2 cache size");
+		goto bad;
+	}
+
+	/* Turn on cache. Only L1 is active at this time. */
+	enable_cache();
+
+	/* Get the calculated cache size from BBL_CR_CTL3[17:13] */
+	bblctl3 = rdmsr(BBL_CR_CTL3);
+	cache_size = (bblctl3.lo & BBLCR3_L2_SIZE);
+	if (cache_size == 0)
+		cache_size = 0x1000;
+	cache_size = cache_size << 3;
+
+	/* TODO: Cache size above is per bank. We're supposed to get
+	 * the number of banks from BBL_CR_CTL3[12:11].
+	 * Confirm that this still provides the correct answer.
+	 */
+	bank = (bblctl3.lo >> 11) & 0x3;
+	if (bank == 0)
+		bank = 1;
+
+	printk(BIOS_INFO, "size %dK... ", cache_size * bank * 4 / 1024);
+
+	/* Write to all cache lines to initialize */
+
+	while (cache_size > 0) {
+
+		/* Each cache line is 32 bytes. */
+		cache_size -= 32;
+
+		/* Update each way */
+
+		/* We're supposed to get L2 associativity from BBL_CR_CTL3[10:9].
+		 * But this code only applies to certain members of the P6 processor family
+		 * and since all P6 processors have 4-way L2 cache, we can safely assume
+		 * 4 way for all cache operations.
+		 */
+
+		for (v = 0; v < 4; v++) {
+			/* Send Tag Write w/Data Write (TWW) to L2 controller 
+			 * MESI = Invalid
+			 */
+			if (signal_l2(cache_size, 0, 0, v, L2CMD_TWW | L2CMD_MESI_I) != 0) {
+				printk(BIOS_ERR, "Failed on signal_l2(%x, %x)\n",
+				       cache_size, v);
+				goto bad;
+			}
+		}
+	}
+	printk(BIOS_DEBUG, "L2 Cache lines initialized\n");
+
+	/* Disable cache */
+	disable_cache();
+
+	/* Set L2 cache configured in BBL_CR_CTL3 */
+	bblctl3 = rdmsr(BBL_CR_CTL3);
+	bblctl3.lo |= BBLCR3_L2_CONFIGURED;
+	wrmsr(BBL_CR_CTL3, bblctl3);
+
+	/* Invalidate cache and discard unsaved writes */
+	asm volatile ("invd");
+
+	/* Write 0 to L2 control register 5 */
+	if (write_l2(5, 0) != 0) {
+		printk(BIOS_ERR,"write_l2(5, 0) failed\n");
+		goto done;
+	}
+
+	bblctl3 = rdmsr(BBL_CR_CTL3);
+	if (signature == 0x650) {
+		/* Change the L2 latency to 0101 then back to 
+		 * original value. I don't know why this is needed - dpd
+		 */
+		eax = bblctl3.lo;
+		bblctl3.lo &= ~BBLCR3_L2_LATENCY;
+		bblctl3.lo |= 0x0a;
+		wrmsr(BBL_CR_CTL3, bblctl3);
+		bblctl3.lo = eax;
+		wrmsr(BBL_CR_CTL3, bblctl3);
+	}
+
+	/* Enable L2 in BBL_CR_CTL3 */
+	bblctl3.lo |= BBLCR3_L2_ENABLED;
+	wrmsr(BBL_CR_CTL3, bblctl3);
+
+	/* Turn on cache. Both L1 and L2 are now active. Wahoo! */
+done:
+	result = 0;
+	goto out;
+bad: 
+	result = -1;
+out:
+	printk(BIOS_INFO, "done.\n");
+	return result;
+}
+
Index: src/cpu/intel/slot_1/Makefile.inc
===================================================================
--- src/cpu/intel/slot_1/Makefile.inc	(revision 6247)
+++ src/cpu/intel/slot_1/Makefile.inc	(working copy)
@@ -19,9 +19,11 @@ 
 ##
 
 ramstage-y += slot_1.c
+ramstage-y += l2_cache.c
 subdirs-y += ../model_6xx
 subdirs-y += ../model_65x
 subdirs-y += ../model_67x
+subdirs-y += ../model_68x
 subdirs-y += ../model_6bx
 subdirs-y += ../../x86/tsc
 subdirs-y += ../../x86/mtrr