示例#1
0
static void print_bitval(FILE *f, const struct msrbits *mb, const struct msr val) {
	uint8_t i;
	struct msr tmp, mask = MSR1(1);
	const struct msrbitvalues *mbv = mb->bitval;
	while (mbv->text && !msr_eq(mbv->value, val))
		mbv++;
	switch (mb->present) {
	case PRESENT_BIN:
		mask = msr_shl(mask, mb->size - 1);
		for (i = 0; i < mb->size; i++) {
			memcpy(&tmp, &val, sizeof(val));
			msr_and(&tmp, mask);
			fprintf(f, "%d", (tmp.hi || tmp.lo) ? 1 : 0);
			mask = msr_shr(mask, 1);
		}
		break;
	case PRESENT_DEC:
		fprintf(f, "%d", val.lo);
		break;
	case PRESENT_OCT:
		fprintf(f, "0%o", val.lo);
		break;
	case PRESENT_HEX:
		hexprint(f, val, mb->size);
		break;
	case PRESENT_HEXDEC:
		hexprint(f, val, mb->size);
		fprintf(f, " %d", val.lo);
		break;
	}
	if (mbv->text)
		fprintf(f, ": %s", mbv->text);
	fprintf(f, "\n");
}
示例#2
0
 *
 */

const struct msrdef cs5536_msrs[] = {
	/* 0x51400008-0x5140000f per 33238G pages 356-361 */
	/* 0x51400015 per 33238G pages 365-366 */
	/* 0x51400020-0x51400027 per 33238G pages 379-385 */
	{ 0x51400008, MSRTYPE_RDWR, MSR2(0, 0), "DIVIL_LBAR_IRQ", "Local BAR - IRQ Mapper", {
		{ 63, 15, RESERVED },
		{ 48, 1, RESERVED },
		{ 47, 4, "IO_MASK", "I/O Address Mask Value", PRESENT_BIN, {
			{ BITVAL_EOT }
		}},
		{ 43, 11, RESERVED },
		{ 32, 1, "LBAR_EN", "LBAR Enable", PRESENT_BIN, {
			{ MSR1(0), "Disable LBAR" },
			{ MSR1(1), "Enable LBAR" },
			{ BITVAL_EOT }
		}},
		{ 31, 15, RESERVED },
		{ 16, 1, RESERVED },
		{ 15, 11, "BASE_ADDR", "Base Address in I/O Space", PRESENT_HEX, {
			{ BITVAL_EOT }
		}},
		{ 4, 5, RESERVED },
		{ BITS_EOT }
	}},
	{ 0x51400009, MSRTYPE_RDWR, MSR2(0, 0), "DIVIL_LBAR_KEL", "Local BAR - Keyboard Emulation Logic from USB", {
		{ 63, 20, "MEM_MASK", "Memory Address Mask Value", PRESENT_HEX, {
			{ BITVAL_EOT }
		}},
示例#3
0
文件: k8.c 项目: MikeeHawk/coreboot
#include "msrtool.h"

int k8_probe(const struct targetdef *target, const struct cpuid_t *id) {
	return 0xF == id->family;
}

/*
 * AMD BKDG Publication # 32559 Revision: 3.08 Issue Date: July 2007
 */
const struct msrdef k8_msrs[] = {
	{ 0xC0000080, MSRTYPE_RDWR, MSR2(0, 0), "EFER Register", "Extended Feature Enable Register", {
		{ 63, 32, RESERVED },
		{ 31, 18, RESERVED },
		{ 14, 1, "FFXSR:", "Fast FXSAVE/FRSTOR Enable", PRESENT_DEC, {
			{ MSR1(0), "FXSAVE/FRSTOR disabled" },
			{ MSR1(1), "FXSAVE/FRSTOR enabled" },
			{ BITVAL_EOT }
		}},
		{ 13, 1, "LMSLE:", "Long Mode Segment Limit Enable", PRESENT_DEC, {
			{ MSR1(0), "Long mode segment limit check disabled" },
			{ MSR1(1), "Long mode segment limit check enabled" },
			{ BITVAL_EOT }
		}},
		{ 12, 1, "SVME:", "SVM Enable", PRESENT_DEC, {
			{ MSR1(0), "SVM features disabled" },
			{ MSR1(1), "SVM features enabled" },
			{ BITVAL_EOT }
		}},
		{ 11, 1, "NXE:", "No-Execute Page Enable", PRESENT_DEC, {
			{ MSR1(0), "NXE features disabled" },
示例#4
0
 * 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.
 */

#include "msrtool.h"

int geodelx_probe(const struct targetdef *target, const struct cpuid_t *id) {
	return 5 == id->family && 10 == id->model;
}

const struct msrdef geodelx_msrs[] = {
	{ 0x20000018, MSRTYPE_RDWR, MSR2(0x10071007, 0x40), "MC_CF07_DATA", "Refresh and SDRAM Program", {
		{ 63, 4, "D1_SZ", "DIMM1 Size", PRESENT_BIN, {
			{ MSR1(0), "Reserved" },
			{ MSR1(1), "8 MB" },
			{ MSR1(2), "16 MB" },
			{ MSR1(3), "32 MB" },
			{ MSR1(4), "64 MB" },
			{ MSR1(5), "128 MB" },
			{ MSR1(6), "256 MB" },
			{ MSR1(7), "512 MB" },
			{ MSR1(8), "1 GB" },
			{ MSR1(9), "Reserved" },
			{ MSR1(10), "Reserved" },
			{ MSR1(11), "Reserved" },
			{ MSR1(12), "Reserved" },
			{ MSR1(13), "Reserved" },
			{ MSR1(14), "Reserved" },
			{ MSR1(15), "Reserved" },
示例#5
0
 * 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
 */

#include "msrtool.h"

int geodegx2_probe(const struct targetdef *target) {
	struct cpuid_t *id = cpuid();
	return 5 == id->family && 5 == id->model;
}

const struct msrdef geodegx2_msrs[] = {
	{ 0x20000018, MSRTYPE_RDWR, MSR2(0x10071007, 0x40), "MC_CF07_DATA", "Refresh and SDRAM Program", {
		{ 63, 4, "D1_SZ", "DIMM1 Size", PRESENT_BIN, {
			{ MSR1(0), "Reserved" },
			{ MSR1(1), "8 MB" },
			{ MSR1(2), "16 MB" },
			{ MSR1(3), "32 MB" },
			{ MSR1(4), "64 MB" },
			{ MSR1(5), "128 MB" },
			{ MSR1(6), "256 MB" },
			{ MSR1(7), "512 MB" },
			{ MSR1(8), "Reserved" },
			{ MSR1(9), "Reserved" },
			{ MSR1(10), "Reserved" },
			{ MSR1(11), "Reserved" },
			{ MSR1(12), "Reserved" },
			{ MSR1(13), "Reserved" },
			{ MSR1(14), "Reserved" },
			{ MSR1(15), "Reserved" },
示例#6
0
int do_diff(const char *difffn) {
	char tmpfn[20], line[512], *m1start, *m2start;
	size_t len;
	int ret = 1, tmp, m1pos, sys_opened = 0;
	FILE *fin = NULL, *fout = stdout;
	uint8_t rev = 0;
	uint32_t addr, linenum;
	struct msr m1 = MSR1(0), m2 = MSR1(0);

	if (':' == difffn[0]) {
		rev = 1;
		++difffn;
	}
	if (0 == strcmp(difffn, "-"))
		fin = stdin;
	else if (NULL == (fin = fopen(difffn, "r"))) {
		perror("fopen()");
		return 1;
	}

	for (linenum = 1; NULL != fgets(line, sizeof(line), fin); ++linenum) {
		tmp = strncmp("0x", line, 2) ? 0 : 2;
		if (sscanf(line + tmp, "%8x %n%*x", &addr, &m1pos) < 1)
			continue;
		m1start = line + tmp + m1pos;
		for (len = strlen(m1start) - 1; NULL != strchr("\r\n", m1start[len]); --len)
			m1start[len] = 0;
		if (!str2msr(m1start, &m1, &m2start)) {
			fprintf(stderr, "%s:%d: invalid MSR1 value '%s'\n", difffn, linenum, m1start);
			continue;
		}
		while (' ' == *m2start)
			++m2start;
		if (!str2msr(m2start, &m2, NULL)) {
			fprintf(stderr, "%s:%d: invalid MSR2 value '%s' - reading from hardware!\n", difffn, linenum, m2start);
			if (!sys_opened) {
				if (!found_system())
					goto done;
				sys_opened = sys->open(cpu, SYS_RDONLY);
				if (!sys_opened)
					goto done;
			}
			if (!sys->rdmsr(cpu, addr, &m2))
				goto done;
		}
		if (diff_msr(fout, addr, rev ? m2 : m1, rev ? m1 : m2))
			fprintf(fout, "\n");
	}
	if (!feof(fin))
		fprintf(stderr, "%s:%d: fgets: %s\n", difffn, linenum, strerror(errno));
	else
		ret = 0;
done:
	if (sys_opened)
		sys->close(cpu);
	if (strcmp(difffn, "-")) {
		if (ret)
			unlink(tmpfn);
		else
			rename(tmpfn, difffn);
		fclose(fin);
		fclose(fout);
	}
	return ret;
}
示例#7
0
int do_stream(const char *streamfn, uint8_t ignoreinput) {
	char tmpfn[20], line[256];
	uint8_t tn;
	size_t start, len;
	int ret = 1;
	int fdout = -1;
	FILE *fin = NULL, *fout = NULL;
	uint32_t addr, linenum;
	struct msr m = MSR1(0);

	if (0 == strcmp(streamfn, "-")) {
		fin = stdin;
		fout = stdout;
	} else {
		if (!ignoreinput) {
			if (NULL == (fin = fopen(streamfn, "r"))) {
				perror("fopen()");
				return 1;
			}
			if (snprintf(tmpfn, sizeof(tmpfn), "msrtoolXXXXXX") >= sizeof(tmpfn)) {
				perror("snprintf");
				return 1;
			}
			if (-1 == (fdout = mkstemp(tmpfn))) {
				perror("mkstemp");
				return 1;
			}
			if (NULL == (fout = fdopen(fdout, "w"))) {
				perror("fdopen");
				return 1;
			}
		} else {
			if (NULL == (fout = fopen(streamfn, "w"))) {
				perror("fopen");
				return 1;
			}
		}
	}

	if (!found_system())
		goto done;
	if (!sys->open(cpu, SYS_RDONLY))
		goto done;
	if (ignoreinput) {
		for (tn = 0; tn < targets_found; tn++)
			if (dumpmsrdefsvals(fout, targets[tn], cpu)) {
				ret = 1;
				break;
			}
	} else {
		for (linenum = 1; NULL != fgets(line, sizeof(line), fin); ++linenum) {
			start = (0 == strncmp("0x", line, 2)) ? 2 : 0;
			if (1 == sscanf(line + start, "%8x", &addr)) {
				if (!sys->rdmsr(cpu, addr, &m))
					goto done;
				fprintf(fout, "0x%08x 0x%08x%08x\n", addr, m.hi, m.lo);
				continue;
			}
			while (1) {
				fprintf(fout, "%s", line);
				len = strlen(line);
				if (NULL != strchr("\r\n", line[len - 1]))
					break;
				if (NULL == fgets(line, sizeof(line), fin))
					goto read_done;
			}
		}
read_done:
		if (!feof(fin)) {
			fprintf(stderr, "%s:%d: fgets: %s\n", streamfn, linenum, strerror(errno));
			goto done;
		}
	}
	ret = 0;
done:
	sys->close(cpu);
	if (strcmp(streamfn, "-")) {
		if (ret)
			unlink(tmpfn);
		else if (!ignoreinput)
			rename(tmpfn, streamfn);
	}
	if (!ignoreinput)
		fclose(fin);
	fclose(fout);
	return ret;
}