PERFORCE change 110481 for review

Oleksandr Tymoshenko gonzo at FreeBSD.org
Fri Nov 24 14:29:52 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=110481

Change 110481 by gonzo at gonzo_hq on 2006/11/24 14:28:53

	o Elminate limitation on 4-bytes only pci_config write for GT
	    chip.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips4k/malta/gt_pci.c#3 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips4k/malta/gt_pci.c#3 (text+ko) ====

@@ -459,11 +459,56 @@
 {
 	struct gt_pci_softc *sc = device_get_softc(dev);
 	uint32_t addr;
+	uint32_t reg_data;
+	uint32_t shift, mask;
+
+	if(bytes != 4)
+	{
+		reg_data = gt_pci_read_config(dev, bus, slot, func, reg, 4);
+
+		/*
+		* XXX: We assume that words readed from GT chip are BE.
+		*	Should we set the mode explicitly during chip
+		*	Initialization?
+		*/ 
+		switch(reg % 4)
+		{
+		case 3:
+			shift = 24;
+			break;
+		case 2:
+			shift = 16;
+			break;
+		case 1:
+			shift = 8;
+			break;
+		default:
+			shift = 0;
+			break;
+		}	
 
-	/* 
-	 * It's possible to write only 4 bytes at the moment
-	 */
-	KASSERT(bytes == 4, ("Unsupport write size"));
+		switch(bytes)
+		{
+		case 1:
+			mask = 0xff;
+			data = (reg_data & ~ (mask << shift)) | (data << shift);
+			break;
+		case 2:
+			mask = 0xffff;
+			if(reg % 4 == 0)
+				data = (reg_data & ~mask) | data;
+			else
+				data = (reg_data & ~ (mask << shift)) | 
+				    (data << shift);
+			break;
+		case 4:
+			break;
+		default:
+			panic("gt_pci_readconfig: wrong bytes count");
+			break;
+		}
+	}
+
 	if (gt_pci_conf_setup(sc, bus, slot, func, reg & ~3, &addr))
 		return;
 


More information about the p4-projects mailing list