Browse Source

Plan 9 from Bell Labs 2003-10-11

David du Colombier 20 years ago
parent
commit
4d4213024a

+ 5 - 5
dist/replica/plan9.db

@@ -275,7 +275,7 @@
 386/bin/ip/httpd/save - 775 sys sys 1064598231 130742
 386/bin/ip/httpd/webls - 775 sys sys 1065646626 129996
 386/bin/ip/httpd/wikipost - 775 sys sys 1064598232 111102
-386/bin/ip/imap4d - 775 sys sys 1064598233 234268
+386/bin/ip/imap4d - 775 sys sys 1065833429 235591
 386/bin/ip/ipconfig - 775 sys sys 1064598234 128285
 386/bin/ip/ping - 775 sys sys 1064598234 74889
 386/bin/ip/ppp - 775 sys sys 1064598236 216026
@@ -5264,7 +5264,7 @@ sys/src/9/pc/pcf - 664 sys sys 1056503364 1457
 sys/src/9/pc/pcf.c - 664 sys sys 1058659039 5110
 sys/src/9/pc/pcfl - 664 sys sys 1042004821 1563
 sys/src/9/pc/pcflop - 664 sys sys 1055700671 1410
-sys/src/9/pc/pci.c - 664 sys sys 1032052921 23359
+sys/src/9/pc/pci.c - 664 sys sys 1065815722 23867
 sys/src/9/pc/pcmciamodem.c - 664 sys sys 1048635123 1545
 sys/src/9/pc/piix4smbus.c - 664 sys sys 1015014521 5264
 sys/src/9/pc/plan9l.s - 664 sys sys 1015014521 910
@@ -6320,7 +6320,7 @@ sys/src/boot/pc/pbsdisk.s - 664 sys sys 1017854325 6371
 sys/src/boot/pc/pbsdisklba - 775 sys sys 1015007954 509
 sys/src/boot/pc/pbsdisklba.s - 664 sys sys 1015007954 6022
 sys/src/boot/pc/pbslba.s - 664 sys sys 1017854326 8147
-sys/src/boot/pc/pci.c - 664 sys sys 1032059068 17251
+sys/src/boot/pc/pci.c - 664 sys sys 1065815736 17580
 sys/src/boot/pc/queue.c - 664 sys sys 1015007954 566
 sys/src/boot/pc/sd.h - 664 sys sys 1032215925 2404
 sys/src/boot/pc/sd53c8xx.c - 664 sys sys 1015007954 52004
@@ -9202,10 +9202,10 @@ sys/src/cmd/ip/imap4d/copy.c - 664 sys sys 1062298855 4597
 sys/src/cmd/ip/imap4d/csquery.c - 664 sys sys 1015013076 762
 sys/src/cmd/ip/imap4d/date.c - 664 sys sys 1045505209 5668
 sys/src/cmd/ip/imap4d/debug.c - 664 sys sys 1016731557 1962
-sys/src/cmd/ip/imap4d/fetch.c - 664 sys sys 1040309082 11765
+sys/src/cmd/ip/imap4d/fetch.c - 664 sys sys 1065833426 11749
 sys/src/cmd/ip/imap4d/fns.h - 664 sys sys 1015013076 4282
 sys/src/cmd/ip/imap4d/folder.c - 664 sys sys 1015013076 5959
-sys/src/cmd/ip/imap4d/imap4d.c - 664 sys sys 1045505233 40500
+sys/src/cmd/ip/imap4d/imap4d.c - 664 sys sys 1065805751 40675
 sys/src/cmd/ip/imap4d/imap4d.h - 664 sys sys 1015013076 6697
 sys/src/cmd/ip/imap4d/list.c - 664 sys sys 1015013076 7619
 sys/src/cmd/ip/imap4d/mbox.c - 664 sys sys 1015013077 16842

+ 6 - 0
dist/replica/plan9.log

@@ -13858,3 +13858,9 @@
 1065718912 4 c sys/src/cmd/upas/send/main.c - 664 sys sys 1065717618 11856
 1065718912 5 c sys/src/cmd/upas/send/message.c - 664 sys sys 1065717617 11064
 1065753032 0 c sys/games/lib/fortunes - 664 sys sys 1065751340 245757
+1065807099 0 c 386/bin/ip/imap4d - 775 sys sys 1065805760 235516
+1065807099 1 c sys/src/cmd/ip/imap4d/imap4d.c - 664 sys sys 1065805751 40675
+1065816109 0 c sys/src/9/pc/pci.c - 664 sys sys 1065815722 23867
+1065816109 1 c sys/src/boot/pc/pci.c - 664 sys sys 1065815736 17580
+1065834010 0 c 386/bin/ip/imap4d - 775 sys sys 1065833429 235591
+1065834010 1 c sys/src/cmd/ip/imap4d/fetch.c - 664 sys sys 1065833426 11749

+ 45 - 17
sys/src/9/pc/pci.c

@@ -744,17 +744,20 @@ static void
 pcicfginit(void)
 {
 	char *p;
-	int bno;
 	Pcidev **list;
 	ulong mema, ioa;
+	int bno, n, pcibios;
 
 	lock(&pcicfginitlock);
 	if(pcicfgmode != -1)
 		goto out;
 
-	if (getconf("*nobios"))
+	pcibios = 0;
+	if(getconf("*nobios"))
 		nobios = 1;
-	if (getconf("*nopcirouting"))
+	else if(getconf("*pcibios"))
+		pcibios = 1;
+	if(getconf("*nopcirouting"))
 		nopcirouting = 1;
 
 	/*
@@ -765,16 +768,35 @@ pcicfginit(void)
 	 * a device behind these addresses so if Mode1 accesses fail try
 	 * for Mode2 (Mode2 is deprecated).
 	 */
-	outl(PciADDR, 0);
-	if(inl(PciADDR) == 0){
-		pcicfgmode = 1;
-		pcimaxdno = 31;
-	}
-	else{
-		outb(PciCSE, 0);
-		if(inb(PciCSE) == 0){
-			pcicfgmode = 2;
-			pcimaxdno = 15;
+	if(!pcibios){
+		/*
+		 * Bits [30:24] of PciADDR must be 0,
+		 * according to the spec.
+		 */
+		n = inl(PciADDR);
+		if(!(n & 0x7FF00000)){
+			outl(PciADDR, 0x80000000);
+			outb(PciADDR+3, 0);
+			if(inl(PciADDR) & 0x80000000){
+				pcicfgmode = 1;
+				pcimaxdno = 31;
+			}
+		}
+		outl(PciADDR, n);
+
+		if(pcicfgmode < 0){
+			/*
+			 * The 'key' part of PciCSE should be 0.
+			 */
+			n = inb(PciCSE);
+			if(!(n & 0xF0)){
+				outb(PciCSE, 0x0E);
+				if(inb(PciCSE) == 0x0E){
+					pcicfgmode = 2;
+					pcimaxdno = 15;
+				}
+			}
+			outb(PciCSE, n);
 		}
 	}
 	
@@ -783,10 +805,16 @@ pcicfginit(void)
 
 	fmtinstall('T', tbdffmt);
 
-	if(p = getconf("*pcimaxbno"))
-		pcimaxbno = strtoul(p, 0, 0);
-	if(p = getconf("*pcimaxdno"))
-		pcimaxdno = strtoul(p, 0, 0);
+	if(p = getconf("*pcimaxbno")){
+		n = strtoul(p, 0, 0);
+		if(n < pcimaxbno)
+			pcimaxbno = n;
+	}
+	if(p = getconf("*pcimaxdno")){
+		n = strtoul(p, 0, 0);
+		if(n < pcimaxdno)
+			pcimaxdno = n;
+	}
 
 	list = &pciroot;
 	for(bno = 0; bno <= pcimaxbno; bno++) {

+ 28 - 10
sys/src/boot/pc/pci.c

@@ -468,7 +468,7 @@ static void
 pcicfginit(void)
 {
 	char *p;
-	int bno;
+	int bno, n;
 	Pcidev **list;
 
 	lock(&pcicfginitlock);
@@ -483,17 +483,35 @@ pcicfginit(void)
 	 * a device behind these addresses so if Mode1 accesses fail try
 	 * for Mode2 (Mode2 is deprecated).
 	 */
-	outl(PciADDR, 0);
-	if(inl(PciADDR) == 0){
-		pcicfgmode = 1;
-		pcimaxdno = 31;
+
+	/*
+	 * Bits [30:24] of PciADDR must be 0,
+	 * according to the spec.
+	 */
+	n = inl(PciADDR);
+	if(!(n & 0x7FF00000)){
+		outl(PciADDR, 0x80000000);
+		outb(PciADDR+3, 0);
+		if(inl(PciADDR) & 0x80000000){
+			pcicfgmode = 1;
+			pcimaxdno = 31;
+		}
 	}
-	else{
-		outb(PciCSE, 0);
-		if(inb(PciCSE) == 0){
-			pcicfgmode = 2;
-			pcimaxdno = 15;
+	outl(PciADDR, n);
+
+	if(pcicfgmode < 0){
+		/*
+		 * The 'key' part of PciCSE should be 0.
+		 */
+		n = inb(PciCSE);
+		if(!(n & 0xF0)){
+			outb(PciCSE, 0x0E);
+			if(inb(PciCSE) == 0x0E){
+				pcicfgmode = 2;
+				pcimaxdno = 15;
+			}
 		}
+		outb(PciCSE, n);
 	}
 	
 	if(pcicfgmode < 0)

+ 5 - 7
sys/src/cmd/ip/imap4d/fetch.c

@@ -52,7 +52,7 @@ breakout:
  *	body[id] === body[id.header] + body[id.text]
 */
 int
-fetchMsg(Box *box, Msg *m, int uids, void *vf)
+fetchMsg(Box *, Msg *m, int uids, void *vf)
 {
 	Tm tm;
 	Fetch *f;
@@ -66,11 +66,6 @@ fetchMsg(Box *box, Msg *m, int uids, void *vf)
 	for(f = vf; f != nil; f = f->next){
 		switch(f->op){
 		case FFlags:
-			/*
-			 * flags get sent with status update
-			 */
-			box->sendFlags = 1;
-			m->sendFlags = 1;
 			break;
 		case FUid:
 			todo = 1;
@@ -118,7 +113,10 @@ fetchMsg(Box *box, Msg *m, int uids, void *vf)
 			bye("bad implementation of fetch");
 			break;
 		case FFlags:
-			continue;
+			Bprint(&bout, "%sflags (", sep);
+			writeFlags(&bout, m, 1);
+			Bprint(&bout, ")");
+			break;
 		case FUid:
 			if(uids)
 				continue;

+ 20 - 9
sys/src/cmd/ip/imap4d/imap4d.c

@@ -93,7 +93,7 @@ static	int	getc(void);
 static	char	*listmbox(void);
 static	char	*literal(void);
 static	ulong	litlen(void);
-static	MsgSet	*msgSet(void);
+static	MsgSet	*msgSet(int);
 static	void	mustBe(int c);
 static	ulong	number(int nonzero);
 static	int	peekc(void);
@@ -102,6 +102,7 @@ static	void	sectText(Fetch *f, int mimeOk);
 static	ulong	seqNo(void);
 static	Store	*storeWhat(void);
 static	char	*tag(void);
+static	ulong	uidNo(void);
 static	void	ungetc(void);
 
 static	ParseCmd	SNonAuthed[] =
@@ -588,7 +589,7 @@ copyUCmd(char *tg, char *cmd, int uids)
 	int ok;
 
 	mustBe(' ');
-	ms = msgSet();
+	ms = msgSet(uids);
 	mustBe(' ');
 	mbox = astring();
 	crnl();
@@ -713,7 +714,7 @@ fetchUCmd(char *tg, char *cmd, int uids)
 	int ok;
 
 	mustBe(' ');
-	ms = msgSet();
+	ms = msgSet(uids);
 	mustBe(' ');
 	f = fetchWhat();
 	crnl();
@@ -1256,7 +1257,7 @@ storeUCmd(char *tg, char *cmd, int uids)
 	int ok;
 
 	mustBe(' ');
-	ms = msgSet();
+	ms = msgSet(uids);
 	mustBe(' ');
 	st = storeWhat();
 	crnl();
@@ -1748,7 +1749,7 @@ searchKey(int first)
 	c = peekc();
 	if(c >= '0' && c <= '9'){
 		sr->key = SKSet;
-		sr->set = msgSet();
+		sr->set = msgSet(0);
 		return sr;
 	}
 
@@ -1801,7 +1802,7 @@ searchKey(int first)
 	}else if(cistrcmp(a, "UID") == 0){
 		sr->key = SKUid;
 		mustBe(' ');
-		sr->set = msgSet();
+		sr->set = msgSet(0);
 	}else if(cistrcmp(a, "NOT") == 0){
 		sr->key = SKNot;
 		mustBe(' ');
@@ -1832,7 +1833,7 @@ searchKey(int first)
  *
  */
 static MsgSet*
-msgSet(void)
+msgSet(int uids)
 {
 	MsgSet head, *last, *ms;
 	ulong from, to;
@@ -1840,11 +1841,11 @@ msgSet(void)
 	last = &head;
 	head.next = nil;
 	for(;;){
-		from = seqNo();
+		from = uids ? uidNo() : seqNo();
 		to = from;
 		if(peekc() == ':'){
 			getc();
-			to = seqNo();
+			to = uids ? uidNo() : seqNo();
 		}
 		ms = binalloc(&parseBin, sizeof(MsgSet), 0);
 		if(ms == nil)
@@ -1871,6 +1872,16 @@ seqNo(void)
 	return number(1);
 }
 
+static ulong
+uidNo(void)
+{
+	if(peekc() == '*'){
+		getc();
+		return ~0UL;
+	}
+	return number(0);
+}
+
 /*
  * 7 bit, non-ctl chars, no (){%*"\
  * NIL is special case for nstring or parenlist