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
|
/* SPDX-License-Identifier: GPL-2.0-only */
// Use simple device model for this file even in ramstage
#define __SIMPLE_DEVICE__
#include <arch/romstage.h>
#include <cbmem.h>
#include <cpu/intel/smm_reloc.h>
#include <cpu/x86/mtrr.h>
#include <cpu/x86/smm.h>
#include <device/pci_ops.h>
#include <program_loading.h>
#include <stdint.h>
#include "e7505.h"
#define HOST_BRIDGE PCI_DEV(0, 0, 0)
static uintptr_t top_of_low_ram(void)
{
uintptr_t tolm;
/* This is at 128 MiB boundary. */
tolm = pci_read_config16(HOST_BRIDGE, TOLM) >> 11;
tolm <<= 27;
return tolm;
}
size_t northbridge_get_tseg_size(void)
{
const uint8_t esmramc = pci_read_config8(HOST_BRIDGE, ESMRAMC);
if (!(esmramc & T_EN))
return 0;
switch ((esmramc & TSEG_SZ_MASK) >> 1) {
case 0:
return 128 * KiB;
case 1:
return 256 * KiB;
case 2:
return 512 * KiB;
case 3:
default:
return 1 * MiB;
}
}
uintptr_t northbridge_get_tseg_base(void)
{
uintptr_t tolm = top_of_low_ram();
/* subtract TSEG size */
tolm -= northbridge_get_tseg_size();
return tolm;
}
void smm_region(uintptr_t *start, size_t *size)
{
*start = northbridge_get_tseg_base();
*size = northbridge_get_tseg_size();
}
uintptr_t cbmem_top_chipset(void)
{
return northbridge_get_tseg_base();
}
void smm_open(void)
{
/* Set D_OPEN */
pci_write_config8(HOST_BRIDGE, SMRAMC, D_OPEN | G_SMRAME | C_BASE_SEG);
}
void smm_close(void)
{
/* Clear D_OPEN */
pci_write_config8(HOST_BRIDGE, SMRAMC, G_SMRAME | C_BASE_SEG);
}
void smm_lock(void)
{
/*
* LOCK the SMM memory window and enable normal SMM.
* After running this function, only a full reset can
* make the SMM registers writable again.
*/
printk(BIOS_DEBUG, "Locking SMM.\n");
pci_write_config8(HOST_BRIDGE, SMRAMC, D_LCK | G_SMRAME | C_BASE_SEG);
}
void fill_postcar_frame(struct postcar_frame *pcf)
{
/*
* Choose to NOT set ROM as WP cacheable here.
* Timestamps indicate the CPU this northbridge code is
* connected to, performs better for memcpy() and un-lzma
* operations when source is left as UC.
*/
pcf->skip_common_mtrr = 1;
/* Cache RAM as WB from 0 -> TOLM. */
postcar_frame_add_mtrr(pcf, top_of_low_ram(), CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
}
|