From 47e3c088c90944e49041c8b210dd7169479738da Mon Sep 17 00:00:00 2001 From: Alex Musolino Date: Thu, 26 Mar 2020 18:24:39 +1030 Subject: [PATCH 1/4] grep: fix handling of -b flag Output buffering is automatically disabled when reading from stdin. In this case, supplying the -b flag ought to be redundant. However, since Bflag was being XORed into the flag set - rather than simply ORed - supplying -b would actually enable output buffering. --- sys/src/cmd/grep/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/src/cmd/grep/main.c b/sys/src/cmd/grep/main.c index d17be9c59..9ef2ba6e8 100644 --- a/sys/src/cmd/grep/main.c +++ b/sys/src/cmd/grep/main.c @@ -91,7 +91,7 @@ search(char *file, int flag) } if(flags['b']) - flag ^= Bflag; /* dont buffer output */ + flag |= Bflag; /* dont buffer output */ if(flags['c']) flag |= Cflag; /* count */ if(flags['h']) From 90143609212ed4500409a64d26f6b12d097b13ed Mon Sep 17 00:00:00 2001 From: Sigrid Date: Sat, 28 Mar 2020 15:37:48 +0100 Subject: [PATCH 2/4] kbd: add "repeat" file to set typematic repeat rate/delay on PS/2 keyboards --- sys/man/3/kbd | 21 ++++++++++++++++++--- sys/src/9/pc/devkbd.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/sys/man/3/kbd b/sys/man/3/kbd index 3d95cb4e8..82422c7dd 100644 --- a/sys/man/3/kbd +++ b/sys/man/3/kbd @@ -7,15 +7,17 @@ kbd \- pc keyboard driver .B /dev/scancode .B /dev/leds +.B /dev/repeat .fi .SH DESCRIPTION .PP The .I kbd device serves a one-level directory containing the files -.BR scancode +.BR scancode , +.BR leds and -.BR leds . +.BR repeat . .PP Reading the .BR scancode @@ -29,14 +31,27 @@ file can be only opened once by the hostowner. .PP Writing a number to the write-only .BR leds -file changes the status leds on the keyboard. the value of the +file changes the status leds on the keyboard. The value of the number is the addition of 1, 2 and 4 representing activated Scroll, Num and Caps leds. +.PP +The +.BR repeat +file sets typematic rate and delay. The value of the number is a +bitmask where first 5 bits set the repeat rate (ranging from 0b00000 +for 30Hz to 0b11111 for 2Hz). Bits 6 and 7 set the delay before the +first repeat is activated (ranging from 0b00 for 250Hz to 0b11 for +1000Hz). .SH EXAMPLE Set the Scroll and Caps leds: .EX echo 5 >/dev/leds .EE +.PP +Enable fast repeat rate and the least delay: +.EX +echo 0 >/dev/repeat +.EE .SH "SEE ALSO" .IR kbdfs (8) .SH SOURCE diff --git a/sys/src/9/pc/devkbd.c b/sys/src/9/pc/devkbd.c index 5aeaded1f..5f6865ef1 100644 --- a/sys/src/9/pc/devkbd.c +++ b/sys/src/9/pc/devkbd.c @@ -40,12 +40,14 @@ enum { Qdir, Qscancode, Qleds, + Qrepeat, }; static Dirtab kbdtab[] = { ".", {Qdir, 0, QTDIR}, 0, 0555, "scancode", {Qscancode, 0}, 0, 0440, "leds", {Qleds, 0}, 0, 0220, + "repeat", {Qrepeat, 0}, 0, 0220, }; static Lock i8042lock; @@ -193,6 +195,28 @@ setleds(int leds) iunlock(&i8042lock); } +static void +setrepeat(int repeat) +{ + if(nokbd) + return; + + repeat &= 0x7f; + ilock(&i8042lock); + for(;;){ + if(outready() < 0) + break; + outb(Data, 0xf3); /* `set typematic rate and delay' */ + if(outready() < 0) + break; + outb(Data, repeat); + if(outready() < 0) + break; + break; + } + iunlock(&i8042lock); +} + /* * keyboard interrupt */ @@ -357,16 +381,18 @@ kbdwrite(Chan *c, void *a, long n, vlong) { char tmp[8+1], *p; - if(c->qid.path != Qleds) - error(Egreg); - p = tmp + n; if(n >= sizeof(tmp)) p = tmp + sizeof(tmp)-1; memmove(tmp, a, p - tmp); *p = 0; - setleds(atoi(tmp)); + if(c->qid.path == Qleds) + setleds(atoi(tmp)); + else if(c->qid.path == Qrepeat) + setrepeat(atoi(tmp)); + else + error(Egreg); return n; } From 3c36cadefd5675ad290a607c3be0450eccde1f54 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 29 Mar 2020 00:44:09 +0100 Subject: [PATCH 3/4] pc: fix mp boot regression due mistake in mkfile the previous mkfile had a sneaky hack that would use sed to delete the first 2 lines of hex output to strip the 32 byte long a.out header for apbootstrap and rebootcode. use 8l -H3 flag to strip the header from the output file. --- sys/src/9/pc/mkfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/src/9/pc/mkfile b/sys/src/9/pc/mkfile index ea3fd9513..0d8f19efe 100644 --- a/sys/src/9/pc/mkfile +++ b/sys/src/9/pc/mkfile @@ -139,10 +139,10 @@ initcode.out: init9.$O initcode.$O /$objtype/lib/libc.a $LD -l -R1 -s -o $target $prereq rebootcode.out: rebootcode.$O - $LD -l -R4 -s -o $target -T$REBOOTADDR $prereq + $LD -l -R4 -s -o $target -T$REBOOTADDR -H3 $prereq apbootstrap.out: apbootstrap.$O - $LD -l -R4 -s -o $target -T$APBOOTSTRAP $prereq + $LD -l -R4 -s -o $target -T$APBOOTSTRAP -H3 $prereq sd53c8xx.i: sd53c8xx.n aux/na $prereq > $target From 1b8d87555a0905e5a83000066518c85a2a85b204 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 29 Mar 2020 00:49:07 +0100 Subject: [PATCH 4/4] pc, pc64: ignore the 64-bit bar flag when reserving membar a bar with bit 3 set means the bar is the low half of a 64-bit wide bar. --- sys/src/9/pc/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/src/9/pc/pci.c b/sys/src/9/pc/pci.c index b908efec5..18f4edaa5 100644 --- a/sys/src/9/pc/pci.c +++ b/sys/src/9/pc/pci.c @@ -1083,7 +1083,7 @@ pcireservemem(void) */ for(p=pciroot; p; p=p->list) for(i=0; imem); i++) - if(p->mem[i].bar && (p->mem[i].bar&1) == 0) + if((p->mem[i].bar&~4) != 0 && (p->mem[i].bar&1) == 0) upareserve(p->mem[i].bar&~0x0F, p->mem[i].size); }