From ddaaf65efe197dafd7ca9175debb075dca0ce49b Mon Sep 17 00:00:00 2001 From: Sigrid Date: Tue, 31 Mar 2020 10:04:24 +0200 Subject: [PATCH 1/5] kbd(3): fix a typo (thanks Alex Musolino) --- sys/man/3/kbd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/man/3/kbd b/sys/man/3/kbd index 82422c7dd..ea6d772eb 100644 --- a/sys/man/3/kbd +++ b/sys/man/3/kbd @@ -40,8 +40,8 @@ The 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). +first repeat is activated (ranging from 0b00 for 250ms to 0b11 for +1000ms). .SH EXAMPLE Set the Scroll and Caps leds: .EX From 480ce0314ee6338644bc202aa68c13c06b1846ce Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 31 Mar 2020 19:00:32 +0200 Subject: [PATCH 2/5] audiohda: add pci vid/did for AMD Raven HD Audio Controller (T495) --- sys/src/9/pc/audiohda.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/src/9/pc/audiohda.c b/sys/src/9/pc/audiohda.c index bbcf2c3bd..9f9b2f280 100644 --- a/sys/src/9/pc/audiohda.c +++ b/sys/src/9/pc/audiohda.c @@ -1775,6 +1775,7 @@ hdamatch(Pcidev *p) case (0x1022 << 16) | 0x780d: /* AMD FCH Azalia Controller */ case (0x1022 << 16) | 0x1457: /* AMD Family 17h (Models 00h-0fh) HD Audio Controller */ + case (0x1022 << 16) | 0x15e3: /* AMD Raven HD Audio Controller */ case (0x15ad << 16) | 0x1977: /* Vmware */ return p; From d3512f60df5d7a2ea5c4cad3cdef797f1f95a182 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 31 Mar 2020 21:57:53 +0200 Subject: [PATCH 3/5] ip/dhcp6d: work arround non-ethernet based client duid in ndb, we use the ethernet mac to identify the client. in dhcpv6, there is just a uniqueue device id that might even be generated randomly. to find the ethernet address of a client, check the duid type and only use it when the dudid is of type 1 (link layer) or 3 (link layer address + time) and the link layer address type is 1 (ethernet). otherwise, assume the source ip is a link local address and extract it from that. this hack works for thinkpad t495, which uses random uuid based client duid. --- sys/src/cmd/ip/dhcp6d.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/sys/src/cmd/ip/dhcp6d.c b/sys/src/cmd/ip/dhcp6d.c index 8250518a0..c75c67ea0 100644 --- a/sys/src/cmd/ip/dhcp6d.c +++ b/sys/src/cmd/ip/dhcp6d.c @@ -31,7 +31,8 @@ struct Req Udphdr *udp; Ipifc *ifc; - uchar mac[Eaddrlen]; + int ncid; + uchar cid[256]; uchar ips[IPaddrlen*8]; int nips; @@ -236,6 +237,31 @@ lookupips(uchar *ip, int n, Ndb *db, uchar mac[Eaddrlen]) return r; } +static uchar* +clientea(Req *r) +{ + static uchar ea[Eaddrlen]; + u32int type; + uchar *ip; + + if(r->ncid >= 4+Eaddrlen){ + type = r->cid[0]<<24 | r->cid[1]<<16 | r->cid[2]<<8 | r->cid[3]; + switch(type){ + case 0x00010001: + case 0x00030001: + return r->cid + r->ncid - Eaddrlen; + } + } + ip = r->udp->raddr; + ea[0] = ip[8] ^ 2; + ea[1] = ip[9]; + ea[2] = ip[10]; + ea[3] = ip[13]; + ea[4] = ip[14]; + ea[5] = ip[15]; + return ea; +} + static void clearotab(void) { @@ -387,7 +413,7 @@ main(int argc, char *argv[]) if((r->db = opendb()) == nil) continue; - r->nips = lookupips(r->ips, sizeof(r->ips), r->db, r->mac)/IPaddrlen; + r->nips = lookupips(r->ips, sizeof(r->ips), r->db, clientea(r))/IPaddrlen; if(debug){ for(i=0; inips; i++) fprint(2, "ip=%I\n", r->ips+i*IPaddrlen); @@ -411,10 +437,11 @@ oclientid(uchar *w, int n, Otab*, Req *r) if((p = gettlv(1, &len, r->req.p, r->req.e)) == nil) return -1; - if(len < 4+4+Eaddrlen || n < len) + if(len > sizeof(r->cid) || n < len) return -1; - memmove(r->mac, p+len-Eaddrlen, Eaddrlen); memmove(w, p, len); + memmove(r->cid, p, len); + r->ncid = len; return len; } From 4756cf549a8b0e9a6924713666770045b13dd8b8 Mon Sep 17 00:00:00 2001 From: Sigrid Date: Wed, 1 Apr 2020 11:31:19 +0200 Subject: [PATCH 4/5] devkbd: bits bad! revert repeat/delay, better patches welcome --- sys/src/9/pc/devkbd.c | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/sys/src/9/pc/devkbd.c b/sys/src/9/pc/devkbd.c index 5f6865ef1..5aeaded1f 100644 --- a/sys/src/9/pc/devkbd.c +++ b/sys/src/9/pc/devkbd.c @@ -40,14 +40,12 @@ 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; @@ -195,28 +193,6 @@ 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 */ @@ -381,18 +357,16 @@ 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; - if(c->qid.path == Qleds) - setleds(atoi(tmp)); - else if(c->qid.path == Qrepeat) - setrepeat(atoi(tmp)); - else - error(Egreg); + setleds(atoi(tmp)); return n; } From 55033d9aedd86ab398644d188ae826cb537a52c7 Mon Sep 17 00:00:00 2001 From: Sigrid Date: Wed, 1 Apr 2020 11:42:35 +0200 Subject: [PATCH 5/5] kbd(1): revert repeat/delay change --- sys/man/3/kbd | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/sys/man/3/kbd b/sys/man/3/kbd index ea6d772eb..3d95cb4e8 100644 --- a/sys/man/3/kbd +++ b/sys/man/3/kbd @@ -7,17 +7,15 @@ 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 leds +.BR scancode and -.BR repeat . +.BR leds . .PP Reading the .BR scancode @@ -31,27 +29,14 @@ 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 250ms to 0b11 for -1000ms). .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