2 The interface layer for memory controller access.
3 It is supporting both real hardware platform and simulation environment.
5 Copyright (c) 2013-2015 Intel Corporation.
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "memory_options.h"
18 #include "meminit_utils.h"
36 // This is a simple delay function.
37 // It takes "nanoseconds" as a parameter.
38 void delay_n(uint32_t nanoseconds
)
40 SimDelayClk( 800*nanoseconds
/1000);
58 SimMmio32Read( 1, addr
, &data
);
68 // Handle case addr bigger than 8bit
69 pciwrite32(0, 0, 0, SB_HADR_REG
, addr
& 0xFFF00);
72 pciwrite32(0, 0, 0, SB_PACKET_REG
,
73 SB_COMMAND(SB_REG_READ_OPCODE
, unit
, addr
));
74 data
= pciread32(0, 0, 0, SB_DATA_REG
);
78 // Handle case addr bigger than 8bit
79 pciwrite32(0, 0, 0, SB_HADR_REG
, addr
& 0xFFF00);
82 pciwrite32(0, 0, 0, SB_PACKET_REG
,
83 SB_COMMAND(SB_DDRIO_REG_READ_OPCODE
, unit
, addr
));
84 data
= pciread32(0, 0, 0, SB_DATA_REG
);
93 DPF(D_REGRD
, "RD32 %03X %08X %08X\n", unit
, addr
, data
);
107 DPF(D_REGWR
, "WR32 %03X %08X %08X\n", unit
, addr
, data
);
114 SimMmio32Write( 1, addr
, data
);
124 // Handle case addr bigger than 8bit
125 pciwrite32(0, 0, 0, SB_HADR_REG
, addr
& 0xFFF00);
128 pciwrite32(0, 0, 0, SB_DATA_REG
, data
);
129 pciwrite32(0, 0, 0, SB_PACKET_REG
,
130 SB_COMMAND(SB_REG_WRITE_OPCODE
, unit
, addr
));
134 // Handle case addr bigger than 8bit
135 pciwrite32(0, 0, 0, SB_HADR_REG
, addr
& 0xFFF00);
138 pciwrite32(0, 0, 0, SB_DATA_REG
, data
);
139 pciwrite32(0, 0, 0, SB_PACKET_REG
,
140 SB_COMMAND(SB_DDRIO_REG_WRITE_OPCODE
, unit
, addr
));
144 pciwrite32(0, 0, 0, SB_HADR_REG
, 0);
145 pciwrite32(0, 0, 0, SB_DATA_REG
, data
);
146 pciwrite32(0, 0, 0, SB_PACKET_REG
,
147 SB_COMMAND(SB_DRAM_CMND_OPCODE
, MCU
, 0));
165 Wr32(unit
, addr
, ((Rd32(unit
, addr
) & ~mask
) | (data
& mask
)));
178 Wr32(MMIO
, PCIADDR(bus
,dev
,fn
,reg
), data
);
190 return Rd32(MMIO
, PCIADDR(bus
,dev
,fn
,reg
));