⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controller.c

📁 version control, version control
💻 C
📖 第 1 页 / 共 5 页
字号:
	/* Fill in the correct memory capabilities */	ctrl.mode = 0;	ctrl.cap = ECC_CORRECT;	/* Checking and correcting enabled */	if (((drc >> 20) & 3) != 0) {		ctrl.mode |= ECC_CORRECT;	}	/* scrub enabled */	ctrl.cap = ECC_SCRUB;	if ((mchscrb & 3) == 2) {		ctrl.mode |= __ECC_SCRUB;	}	/* Now, we can activate Fun1 */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xF4, 1, &dvnp1);	pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn , 0xF4, 1, (dvnp1 | 0x20));	/* Clear any prexisting error reports */	pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x80, 2, 0x4747);	pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x82, 2, 0x4747);}static void poll_iE7xxx(void){	unsigned long ferr;	unsigned long nerr;	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x80, 1, &ferr);	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x82, 1, &nerr);	if (ferr & 1) {		/* Find out about the first correctable error */		unsigned long celog_add;		unsigned long celog_syndrome;		unsigned long page;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn +1, 0xA0, 4, &celog_add);		/* Read the syndrome */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn +1, 0xD0, 2, &celog_syndrome);		/* Parse the error location */		page = (celog_add & 0x0FFFFFC0) >> 6;		/* Report the error */		print_ecc_err(page, 0, 1, celog_syndrome, 0);		/* Clear Bit */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x80, 1, ferr & 3);	}	if (ferr & 2) {		/* Found out about the first uncorrectable error */		unsigned long uccelog_add;		unsigned long page;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn +1, 0xB0, 4, &uccelog_add);		/* Parse the error location */		page = (uccelog_add & 0x0FFFFFC0) >> 6;		/* Report the error */		print_ecc_err(page, 0, 0, 0, 0);		/* Clear Bit */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x80, 1, ferr & 3);	}	/* Check if DRAM_NERR contains data */	if (nerr & 3) {		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn +1, 0x82, 1, nerr & 3);	}}static void setup_i440gx(void){	static const int ddim[] = { ECC_NONE, ECC_DETECT, ECC_CORRECT, ECC_CORRECT };	unsigned long nbxcfg;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x50, 4, &nbxcfg);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(nbxcfg >> 7)&3];}static void poll_i440gx(void){	unsigned long errsts;	unsigned long page;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x91, 2, &errsts);	if (errsts & 0x11) {		unsigned long eap;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x80, 4, &eap);		/* Parse the error location and error type */		page = (eap & 0xFFFFF000) >> 12;		bits = 0;		if (eap &3) {			bits = ((eap & 3) == 1)?1:2;		}		if (bits) {			/* Report the error */			print_ecc_err(page, 0, bits==1?1:0, 0, 0);		}		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0x91, 2, 0x11);		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0x80, 4, 3);	}}static void setup_i840(void){	static const int ddim[] = { ECC_NONE, ECC_RESERVED, ECC_CORRECT, ECC_CORRECT };	unsigned long mchcfg;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x50, 2, &mchcfg);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(mchcfg >> 7)&3];}static void poll_i840(void){	unsigned long errsts;	unsigned long page;	unsigned long syndrome;	int channel;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 3) {		unsigned long eap;		unsigned long derrctl_sts;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE4, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE2, 2, &derrctl_sts);		/* Parse the error location and error type */		page = (eap & 0xFFFFF800) >> 11;		channel = eap & 1;		syndrome = derrctl_sts & 0xFF;		bits = ((errsts & 3) == 1)?1:2;		/* Report the error */		print_ecc_err(page, 0, bits==1?1:0, syndrome, channel);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xE2, 2, 3 << 10);		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, 3);	}}static void setup_i875(void){	long *ptr;	ulong dev0, dev6 ;	/* Fill in the correct memory capabilites */	ctrl.cap = ECC_CORRECT;	ctrl.mode = ECC_NONE;	/* From my article : http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm */	/* Activate Device 6 */	pci_conf_read( 0, 0, 0, 0xF4, 1, &dev0);	pci_conf_write( 0, 0, 0, 0xF4, 1, (dev0 | 0x2));	/* Activate Device 6 MMR */	pci_conf_read( 0, 6, 0, 0x04, 2, &dev6);	pci_conf_write( 0, 6, 0, 0x04, 2, (dev6 | 0x2));	/* Read the MMR Base Address & Define the pointer*/	pci_conf_read( 0, 6, 0, 0x10, 4, &dev6);	ptr=(long*)(dev6+0x68);	if (((*ptr >> 18)&1) == 1) { ctrl.mode = ECC_CORRECT; }	/* Reseting state */	pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2,  0x81);}static void setup_i925(void){	// Activate MMR I/O	ulong dev0, drc;	unsigned long tolm;	long *ptr;		pci_conf_read( 0, 0, 0, 0x54, 4, &dev0);	dev0 = dev0 | 0x10000000;	pci_conf_write( 0, 0, 0, 0x54, 4, dev0);		// CDH start	pci_conf_read( 0, 0, 0, 0x44, 4, &dev0);	if (!(dev0 & 0xFFFFC000)) {		pci_conf_read( 0, 0, 0, 0x9C, 1, &tolm);		pci_conf_write( 0, 0, 0, 0x47, 1, tolm & 0xF8);	}	// CDH end	// ECC Checking	ctrl.cap = ECC_CORRECT;	dev0 &= 0xFFFFC000;	ptr=(long*)(dev0+0x120);	drc = *ptr & 0xFFFFFFFF;		if (((drc >> 20) & 3) == 2) { 		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, 3);		ctrl.mode = ECC_CORRECT; 	} else { 		ctrl.mode = ECC_NONE; 	}}static void poll_i875(void){	unsigned long errsts;	unsigned long page;	unsigned long des;	unsigned long syndrome;	int channel;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 0x81)  {		unsigned long eap;		unsigned long derrsyn;		/* Read the error location, syndrome and channel */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x58, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x5C, 1, &derrsyn);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x5D, 1, &des);		/* Parse the error location and error type */		page = (eap & 0xFFFFF000) >> 12;		syndrome = derrsyn;		channel = des & 1;		bits = (errsts & 0x80)?0:1;		/* Report the error */		print_ecc_err(page, 0, bits, syndrome, channel);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2,  0x81);	}}static void setup_i845(void){	static const int ddim[] = { ECC_NONE, ECC_RESERVED, ECC_CORRECT, ECC_RESERVED };	unsigned long drc;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x7C, 4, &drc);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(drc >> 20)&3];}static void poll_i845(void){	unsigned long errsts;	unsigned long page, offset;	unsigned long syndrome;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 3) {		unsigned long eap;		unsigned long derrsyn;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x8C, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x86, 1, &derrsyn);		/* Parse the error location and error type */		offset = (eap & 0xFE) << 4;		page = (eap & 0x3FFFFFFE) >> 8;		syndrome = derrsyn;		bits = ((errsts & 3) == 1)?1:2;		/* Report the error */		print_ecc_err(page, offset, bits==1?1:0, syndrome, 0);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, 3);	}}static void setup_i820(void){	static const int ddim[] = { ECC_NONE, ECC_RESERVED, ECC_CORRECT, ECC_CORRECT };	unsigned long mchcfg;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xbe, 2, &mchcfg);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(mchcfg >> 7)&3];}static void poll_i820(void){	unsigned long errsts;	unsigned long page;	unsigned long syndrome;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 3) {		unsigned long eap;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xc4, 4, &eap);		/* Parse the error location and error type */		page = (eap & 0xFFFFF000) >> 4;		syndrome = eap & 0xFF;		bits = ((errsts & 3) == 1)?1:2;		/* Report the error */		print_ecc_err(page, 0, bits==1?1:0, syndrome, 0);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, 3);	}}static void setup_i850(void){	static const int ddim[] = { ECC_NONE, ECC_RESERVED, ECC_CORRECT, ECC_RESERVED };	unsigned long mchcfg;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x50, 2, &mchcfg);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(mchcfg >> 7)&3];}static void poll_i850(void){	unsigned long errsts;	unsigned long page;	unsigned long syndrome;	int channel;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 3) {		unsigned long eap;		unsigned long derrctl_sts;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE4, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE2, 2, &derrctl_sts);		/* Parse the error location and error type */		page = (eap & 0xFFFFF800) >> 11;		channel = eap & 1;		syndrome = derrctl_sts & 0xFF;		bits = ((errsts & 3) == 1)?1:2;		/* Report the error */		print_ecc_err(page, 0, bits==1?1:0, syndrome, channel);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, errsts & 3);	}}static void setup_i860(void){	static const int ddim[] = { ECC_NONE, ECC_RESERVED, ECC_CORRECT, ECC_RESERVED };	unsigned long mchcfg;	unsigned long errsts;	/* Fill in the correct memory capabilites */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x50, 2, &mchcfg);	ctrl.cap = ECC_CORRECT;	ctrl.mode = ddim[(mchcfg >> 7)&3];	/* Clear any prexisting error reports */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, errsts & 3);}static void poll_i860(void){	unsigned long errsts;	unsigned long page;	unsigned char syndrome;	int channel;	int bits;	/* Read the error status */	pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);	if (errsts & 3) {		unsigned long eap;		unsigned long derrctl_sts;		/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE4, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xE2, 2, &derrctl_sts);		/* Parse the error location and error type */		page = (eap & 0xFFFFFE00) >> 9;		channel = eap & 1;		syndrome = derrctl_sts & 0xFF;		bits = ((errsts & 3) == 1)?1:2;		/* Report the error */		print_ecc_err(page, 0, bits==1?1:0, syndrome, channel);		/* Clear the error status */		pci_conf_write(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, errsts & 3);	}}static void poll_iE7221(void){	unsigned long errsts;	unsigned long page;	unsigned char syndrome;	int channel;	int bits;	int errocc;		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0xC8, 2, &errsts);		errocc = errsts & 3;		if ((errocc == 1) || (errocc == 2)) {		unsigned long eap, offset;		unsigned long derrctl_sts;						/* Read the error location */		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x58, 4, &eap);		pci_conf_read(ctrl.bus, ctrl.dev, ctrl.fn, 0x5C, 1, &derrctl_sts);						/* Parse the error location and error type */		channel = eap & 1;		eap = eap & 0xFFFFFF80;		page = eap >> 12;		offset = eap & 0xFFF;		syndrome = derrctl_sts & 0xFF;				bits = errocc & 1;		/* Report the error */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -