CVS commit: src/sys/arch/news68k/news68k
Module Name:src Committed By: tsutsui Date: Fri Aug 6 05:53:50 UTC 2021 Modified Files: src/sys/arch/news68k/news68k: machdep.c Log Message: Fix mm_md_physacc() to allow only accesses to a region of RAMs. Note on NetBSD/news68k RAMs reserved by the PROM (at the end of the RAM) are not managed. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/sys/arch/news68k/news68k/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/news68k/news68k/machdep.c diff -u src/sys/arch/news68k/news68k/machdep.c:1.108 src/sys/arch/news68k/news68k/machdep.c:1.109 --- src/sys/arch/news68k/news68k/machdep.c:1.108 Thu Jun 11 19:20:44 2020 +++ src/sys/arch/news68k/news68k/machdep.c Fri Aug 6 05:53:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.108 2020/06/11 19:20:44 ad Exp $ */ +/* $NetBSD: machdep.c,v 1.109 2021/08/06 05:53:50 tsutsui Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.108 2020/06/11 19:20:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.109 2021/08/06 05:53:50 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -992,8 +992,17 @@ consinit(void) int mm_md_physacc(paddr_t pa, vm_prot_t prot) { + paddr_t memend; - return (pa < lowram || pa >= 0xfffc) ? EFAULT : 0; + /* + * news68k has one contiguous memory segment. + */ + memend = lowram + ctob(physmem); + + if (lowram <= pa && pa < memend) + return 0; + + return EFAULT; } int
CVS commit: src/sys/arch/hp300/hp300
Module Name:src Committed By: tsutsui Date: Fri Aug 6 05:22:21 UTC 2021 Modified Files: src/sys/arch/hp300/hp300: machdep.c Log Message: Add comments how mm_md_physacc() for hp300 works. mm_md_physacc() for all other hp300 pmap based m68k ports that copied hp300 implemantation should have been fixed properly. XXX: no mm(9) man pages that describe MD implementation API definitions. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/arch/hp300/hp300/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hp300/hp300/machdep.c diff -u src/sys/arch/hp300/hp300/machdep.c:1.234 src/sys/arch/hp300/hp300/machdep.c:1.235 --- src/sys/arch/hp300/hp300/machdep.c:1.234 Thu Jun 11 19:20:43 2020 +++ src/sys/arch/hp300/hp300/machdep.c Fri Aug 6 05:22:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.234 2020/06/11 19:20:43 ad Exp $ */ +/* $NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.234 2020/06/11 19:20:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -1164,6 +1164,10 @@ int mm_md_physacc(paddr_t pa, vm_prot_t prot) { + /* + * On the hp300, physical RAM is always located at the end of + * the physical address space, i.e. from 0x to lowram. + */ return (pa < lowram || pa >= 0xfffc) ? EFAULT : 0; }
CVS commit: src/sys/arch/x68k/x68k
Module Name:src Committed By: isaki Date: Fri Aug 6 04:21:56 UTC 2021 Modified Files: src/sys/arch/x68k/x68k: machdep.c Log Message: Fix broken mm_md_physacc(). - Fix access to main memory and extended memory. This makes /dev/mem work again. - Introduce kauth(9) to access unmanaged memory area. Now you can read/write the internal I/O space via /dev/mem when securelevel = -1. Thanks ryo@, tsutsui@ for advices and reviews. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/sys/arch/x68k/x68k/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x68k/x68k/machdep.c diff -u src/sys/arch/x68k/x68k/machdep.c:1.205 src/sys/arch/x68k/x68k/machdep.c:1.206 --- src/sys/arch/x68k/x68k/machdep.c:1.205 Thu Feb 11 02:37:11 2021 +++ src/sys/arch/x68k/x68k/machdep.c Fri Aug 6 04:21:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $ */ +/* $NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -1252,15 +1252,28 @@ cpu_intr_p(void) int mm_md_physacc(paddr_t pa, vm_prot_t prot) { - uvm_physseg_t i; + int i; - for (i = uvm_physseg_get_first(); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) { - if (uvm_physseg_valid_p(i) == false) - break; + /* Main memory */ + if (phys_basemem_seg.start <= pa && pa < phys_basemem_seg.end) + return 0; - if (ctob(uvm_physseg_get_start(i)) <= pa && - pa < ctob(uvm_physseg_get_end(i))) +#ifdef EXTENDED_MEMORY + for (i = 0; i < EXTMEM_SEGS; i++) { + if (phys_extmem_seg[i].start == phys_extmem_seg[i].end) + continue; + if (phys_extmem_seg[i].start <= pa && + pa < phys_extmem_seg[i].end) { return 0; + } } +#endif + + /* I/O space */ + if (INTIOBASE <= pa && pa < INTIOTOP) { + return kauth_authorize_machdep(kauth_cred_get(), + KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + } + return EFAULT; }
CVS commit: [thorpej-futex2] src/sys/kern
Module Name:src Committed By: thorpej Date: Thu Aug 5 23:23:50 UTC 2021 Modified Files: src/sys/kern [thorpej-futex2]: sys_futex.c Log Message: At the end of futex_wait(), when sleepq_block() returns 0, we would like to assert that l->l_futex == NULL, because all of the code paths that awaken a blocked thread in sys_futex.c itself clear l->l_futex. Unfortunately, there are certain received-a-signal situations (e.g. SIGKILL) where sleepq_block() will not return an error after being awakened by the signal, rendering this assertion too strong. So, rather than going down the rabbit hole of reasoning out and altering long-standing behavior of the signals code, just don't assert there and treat a zero-return from sleepq_block() as an aborted futex wait if l->l_futex != NULL. (Thanks chs@ for helping chase this one down.) To generate a diff of this commit: cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/sys/kern/sys_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_futex.c diff -u src/sys/kern/sys_futex.c:1.12.4.1 src/sys/kern/sys_futex.c:1.12.4.2 --- src/sys/kern/sys_futex.c:1.12.4.1 Thu Aug 5 23:14:21 2021 +++ src/sys/kern/sys_futex.c Thu Aug 5 23:23:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_futex.c,v 1.12.4.1 2021/08/05 23:14:21 thorpej Exp $ */ +/* $NetBSD: sys_futex.c,v 1.12.4.2 2021/08/05 23:23:50 thorpej Exp $ */ /*- * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12.4.1 2021/08/05 23:14:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12.4.2 2021/08/05 23:23:50 thorpej Exp $"); /* * Futexes @@ -1122,8 +1122,23 @@ futex_wait(struct futex *f, int q, const else if (error != ETIMEDOUT) error = EINTR; } else { - KASSERT(l->l_futex == NULL); - SDT_PROBE0(futex, wait, finish, normally); + f = l->l_futex; + if (__predict_false(f != NULL)) { + /* + * There are certain situations that can cause + * sleepq_block() to return 0 even if we were + * signalled (by e.g. SIGKILL). In this case, + * we will need to release our futex hold and + * return EINTR (we're probably about to die + * anyway). + */ + SDT_PROBE0(futex, wait, finish, aborted); + l->l_futex = NULL; + futex_rele(f); + error = EINTR; + } else { + SDT_PROBE0(futex, wait, finish, normally); + } } return error;
CVS commit: [thorpej-futex2] src/sys
Module Name:src Committed By: thorpej Date: Thu Aug 5 23:14:21 UTC 2021 Modified Files: src/sys/kern [thorpej-futex2]: sys_futex.c src/sys/sys [thorpej-futex2]: lwp.h Log Message: Bring over just the futex sleepq infrastructure changes from thorpej-futex to a new branch based on current HEAD. This contains only the fixes for the priority problems, and is intended to finish debugging those changes (without the new extensions). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/kern/sys_futex.c cvs rdiff -u -r1.212 -r1.212.14.1 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_futex.c diff -u src/sys/kern/sys_futex.c:1.12 src/sys/kern/sys_futex.c:1.12.4.1 --- src/sys/kern/sys_futex.c:1.12 Wed Jul 21 06:35:45 2021 +++ src/sys/kern/sys_futex.c Thu Aug 5 23:14:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_futex.c,v 1.12 2021/07/21 06:35:45 skrll Exp $ */ +/* $NetBSD: sys_futex.c,v 1.12.4.1 2021/08/05 23:14:21 thorpej Exp $ */ /*- * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12 2021/07/21 06:35:45 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12.4.1 2021/08/05 23:14:21 thorpej Exp $"); /* * Futexes @@ -121,7 +121,9 @@ __KERNEL_RCSID(0, "$NetBSD: sys_futex.c, #include #include #include +#include #include +#include #include #include @@ -130,13 +132,56 @@ __KERNEL_RCSID(0, "$NetBSD: sys_futex.c, #include /* + * DTrace probes. + */ +SDT_PROVIDER_DEFINE(futex); + +/* entry: uaddr, val, bitset, timeout, clkflags, fflags */ +/* exit: error */ +SDT_PROBE_DEFINE6(futex, func, wait, entry, "int *", "int", "int", + "struct timespec *", "int", "int"); +SDT_PROBE_DEFINE1(futex, func, wait, exit, "int"); + +/* entry: uaddr, nwake, bitset, fflags */ +/* exit: error, nwoken */ +SDT_PROBE_DEFINE4(futex, func, wake, entry, "int *", "int", "int", "int"); +SDT_PROBE_DEFINE2(futex, func, wake, exit, "int", "int"); + +/* entry: uaddr, nwake, uaddr2, nrequeue, fflags */ +/* exit: error, nwoken */ +SDT_PROBE_DEFINE5(futex, func, requeue, entry, "int *", "int", "int *", "int", + "int"); +SDT_PROBE_DEFINE2(futex, func, requeue, exit, "int", "int"); + +/* entry: uaddr, nwake, uaddr2, nrequeue, val3, fflags */ +/* exit: error, nwoken */ +SDT_PROBE_DEFINE6(futex, func, cmp_requeue, entry, "int *", "int", "int *", + "int", "int", "int"); +SDT_PROBE_DEFINE2(futex, func, cmp_requeue, exit, "int", "int"); + +/* entry: uaddr, nwake, uaddr2, nwake2, wakeop, fflags */ +/* exit: error, nwoken */ +SDT_PROBE_DEFINE6(futex, func, wake_op, entry, "int *", "int", "int *", "int", + "int", "int"); +SDT_PROBE_DEFINE2(futex, func, wake_op, exit, "int", "int"); + +SDT_PROBE_DEFINE0(futex, wait, finish, normally); +SDT_PROBE_DEFINE0(futex, wait, finish, wakerace); +SDT_PROBE_DEFINE0(futex, wait, finish, aborted); + +/* entry: timo */ +/* exit: error */ +SDT_PROBE_DEFINE1(futex, wait, sleepq_block, entry, "int"); +SDT_PROBE_DEFINE1(futex, wait, sleepq_block, exit, "int"); + +/* * Lock order: * * futex_tab.lock - * futex::fx_qlock ordered by kva of struct futex - * -> futex_wait::fw_lock only one at a time - * futex_wait::fw_lock only one at a time - * -> futex::fx_abortlock only one at a time + * futex::fx_op_lock ordered by kva of struct futex + * -> futex::fx_sq_lock ordered by kva of sleepq lock + * + * N.B. multiple futexes can share a single sleepq lock. */ /* @@ -166,37 +211,52 @@ union futex_key { * that can be present on the system at any given time, and the * assumption is that limit will be good enough on a 32-bit platform. * See futex_wake() for why overflow needs to be avoided. + * + * XXX Since futex addresses must be 4-byte aligned, we could + * XXX squirrel away fx_shared and fx_on_tree bits in the "va" + * XXX field of the key. Worth it? */ struct futex { union futex_key fx_key; + struct rb_node fx_node; unsigned long fx_refcnt; bool fx_shared; bool fx_on_tree; - struct rb_node fx_node; + uint8_t fx_class; - kmutex_t fx_qlock; - TAILQ_HEAD(, futex_wait) fx_queue; - - kmutex_t fx_abortlock; - LIST_HEAD(, futex_wait) fx_abortlist; - kcondvar_t fx_abortcv; + kmutex_t fx_op_lock; /* adaptive */ + kmutex_t * fx_sq_lock; /* _locks[...] */ + sleepq_t fx_sqs[2]; /* 0=reader, 1=writer */ + unsigned int fx_nwaiters[2]; }; /* - * struct futex_wait - * - * State for a thread to wait on a futex. Threads wait on fw_cv - * for fw_bitset to be set to zero. The thread may transition to - * a different futex queue at any time under the futex's lock. - */ -struct futex_wait { - kmutex_t fw_lock; - kcondvar_t fw_cv; - struct futex *fw_futex; - TAILQ_ENTRY(futex_wait) fw_entry; /* queue lock */ - LIST_ENTRY(futex_wait) fw_abort; /* queue abortlock */ - int
CVS commit: src
Module Name:src Committed By: rillig Date: Thu Aug 5 22:36:08 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/usr.bin/xlint: Makefile Added Files: src/tests/usr.bin/xlint/lint2: Makefile msg_000.exp msg_000.ln msg_001.exp msg_001.ln msg_002.exp msg_002.ln msg_003.exp msg_003.ln msg_004.exp msg_004.ln msg_005.exp msg_005.ln msg_006.exp msg_006.ln msg_007.exp msg_007.ln msg_008.exp msg_008.ln msg_009.exp msg_009.ln msg_010.exp msg_010.ln msg_011.exp msg_011.ln msg_012.exp msg_012.ln msg_013.exp msg_013.ln msg_014.exp msg_014.ln msg_015.exp msg_015.ln msg_016.exp msg_016.ln msg_017.exp msg_017.ln msg_018.exp msg_018.ln t_lint2.sh Log Message: tests/lint: add test skeletons for messages from lint2 To generate a diff of this commit: cvs rdiff -u -r1.1103 -r1.1104 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.185 -r1.186 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint2/Makefile \ src/tests/usr.bin/xlint/lint2/msg_000.exp \ src/tests/usr.bin/xlint/lint2/msg_000.ln \ src/tests/usr.bin/xlint/lint2/msg_001.exp \ src/tests/usr.bin/xlint/lint2/msg_001.ln \ src/tests/usr.bin/xlint/lint2/msg_002.exp \ src/tests/usr.bin/xlint/lint2/msg_002.ln \ src/tests/usr.bin/xlint/lint2/msg_003.exp \ src/tests/usr.bin/xlint/lint2/msg_003.ln \ src/tests/usr.bin/xlint/lint2/msg_004.exp \ src/tests/usr.bin/xlint/lint2/msg_004.ln \ src/tests/usr.bin/xlint/lint2/msg_005.exp \ src/tests/usr.bin/xlint/lint2/msg_005.ln \ src/tests/usr.bin/xlint/lint2/msg_006.exp \ src/tests/usr.bin/xlint/lint2/msg_006.ln \ src/tests/usr.bin/xlint/lint2/msg_007.exp \ src/tests/usr.bin/xlint/lint2/msg_007.ln \ src/tests/usr.bin/xlint/lint2/msg_008.exp \ src/tests/usr.bin/xlint/lint2/msg_008.ln \ src/tests/usr.bin/xlint/lint2/msg_009.exp \ src/tests/usr.bin/xlint/lint2/msg_009.ln \ src/tests/usr.bin/xlint/lint2/msg_010.exp \ src/tests/usr.bin/xlint/lint2/msg_010.ln \ src/tests/usr.bin/xlint/lint2/msg_011.exp \ src/tests/usr.bin/xlint/lint2/msg_011.ln \ src/tests/usr.bin/xlint/lint2/msg_012.exp \ src/tests/usr.bin/xlint/lint2/msg_012.ln \ src/tests/usr.bin/xlint/lint2/msg_013.exp \ src/tests/usr.bin/xlint/lint2/msg_013.ln \ src/tests/usr.bin/xlint/lint2/msg_014.exp \ src/tests/usr.bin/xlint/lint2/msg_014.ln \ src/tests/usr.bin/xlint/lint2/msg_015.exp \ src/tests/usr.bin/xlint/lint2/msg_015.ln \ src/tests/usr.bin/xlint/lint2/msg_016.exp \ src/tests/usr.bin/xlint/lint2/msg_016.ln \ src/tests/usr.bin/xlint/lint2/msg_017.exp \ src/tests/usr.bin/xlint/lint2/msg_017.ln \ src/tests/usr.bin/xlint/lint2/msg_018.exp \ src/tests/usr.bin/xlint/lint2/msg_018.ln \ src/tests/usr.bin/xlint/lint2/t_lint2.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1103 src/distrib/sets/lists/tests/mi:1.1104 --- src/distrib/sets/lists/tests/mi:1.1103 Thu Aug 5 06:34:42 2021 +++ src/distrib/sets/lists/tests/mi Thu Aug 5 22:36:07 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1103 2021/08/05 06:34:42 rillig Exp $ +# $NetBSD: mi,v 1.1104 2021/08/05 22:36:07 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -7023,6 +7023,48 @@ ./usr/tests/usr.bin/xlint/lint1/stmt_if.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/stmt_if.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2 tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/Atffiletests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua +./usr/tests/usr.bin/xlint/lint2/msg_000.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_000.ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_001.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_001.ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_002.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_002.ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_003.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_003.ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_004.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/msg_004.ln tests-usr.bin-tests
CVS commit: src/sys/dev
Module Name:src Committed By: tnn Date: Thu Aug 5 22:31:20 UTC 2021 Modified Files: src/sys/dev/i2c: ssdfb_i2c.c src/sys/dev/ic: ssdfb.c ssdfbvar.h Log Message: ssdfb: revert rev 1.14 Can't run the worker thread MPSAFE with spi(4) yet because most controller drivers still lack MP safety. Cause issues when using multiple displays. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/i2c/ssdfb_i2c.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/ssdfb.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/ssdfbvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/ssdfb_i2c.c diff -u src/sys/dev/i2c/ssdfb_i2c.c:1.10 src/sys/dev/i2c/ssdfb_i2c.c:1.11 --- src/sys/dev/i2c/ssdfb_i2c.c:1.10 Fri Jul 30 13:44:09 2021 +++ src/sys/dev/i2c/ssdfb_i2c.c Thu Aug 5 22:31:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfb_i2c.c,v 1.10 2021/07/30 13:44:09 tnn Exp $ */ +/* $NetBSD: ssdfb_i2c.c,v 1.11 2021/08/05 22:31:20 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.10 2021/07/30 13:44:09 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.11 2021/08/05 22:31:20 tnn Exp $"); #include #include @@ -112,6 +112,7 @@ ssdfb_i2c_attach(device_t parent, device if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN) flags |= SSDFB_PRODUCT_SSD1306_GENERIC; + flags |= SSDFB_ATTACH_FLAG_MPSAFE; sc->sc.sc_dev = self; sc->sc_i2c_tag = ia->ia_tag; sc->sc_i2c_addr = ia->ia_addr; Index: src/sys/dev/ic/ssdfb.c diff -u src/sys/dev/ic/ssdfb.c:1.18 src/sys/dev/ic/ssdfb.c:1.19 --- src/sys/dev/ic/ssdfb.c:1.18 Thu Aug 5 19:07:09 2021 +++ src/sys/dev/ic/ssdfb.c Thu Aug 5 22:31:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfb.c,v 1.18 2021/08/05 19:07:09 tnn Exp $ */ +/* $NetBSD: ssdfb.c,v 1.19 2021/08/05 22:31:20 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.18 2021/08/05 19:07:09 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.19 2021/08/05 22:31:20 tnn Exp $"); #include "opt_ddb.h" @@ -268,6 +268,7 @@ ssdfb_attach(struct ssdfb_softc *sc, int int error = 0; long defattr; const struct ssdfb_product *p; + int kt_flags; p = ssdfb_lookup_product(flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK); if (p == NULL) { @@ -393,11 +394,15 @@ ssdfb_attach(struct ssdfb_softc *sc, int if (sc->sc_is_console) ssdfb_set_usepoll(sc, true); - mutex_init(>sc_cond_mtx, MUTEX_DEFAULT, IPL_SCHED); + mutex_init(>sc_cond_mtx, MUTEX_DEFAULT, + ISSET(flags, SSDFB_ATTACH_FLAG_MPSAFE) ? IPL_SCHED : IPL_BIO); cv_init(>sc_cond, "ssdfb"); - error = kthread_create(PRI_SOFTCLOCK, KTHREAD_MUSTJOIN | KTHREAD_MPSAFE, - NULL, ssdfb_thread, sc, >sc_thread, "%s", - device_xname(sc->sc_dev)); + kt_flags = KTHREAD_MUSTJOIN; + /* XXX spi(4) is not MPSAFE yet. */ + if (ISSET(flags, SSDFB_ATTACH_FLAG_MPSAFE)) + kt_flags |= KTHREAD_MPSAFE; + error = kthread_create(PRI_SOFTCLOCK, kt_flags, NULL, ssdfb_thread, sc, + >sc_thread, "%s", device_xname(sc->sc_dev)); if (error) { cv_destroy(>sc_cond); mutex_destroy(>sc_cond_mtx); Index: src/sys/dev/ic/ssdfbvar.h diff -u src/sys/dev/ic/ssdfbvar.h:1.9 src/sys/dev/ic/ssdfbvar.h:1.10 --- src/sys/dev/ic/ssdfbvar.h:1.9 Thu Aug 5 19:07:09 2021 +++ src/sys/dev/ic/ssdfbvar.h Thu Aug 5 22:31:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfbvar.h,v 1.9 2021/08/05 19:07:09 tnn Exp $ */ +/* $NetBSD: ssdfbvar.h,v 1.10 2021/08/05 22:31:20 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -36,6 +36,7 @@ #define SSDFB_ATTACH_FLAG_UPSIDEDOWN 0x0100 #define SSDFB_ATTACH_FLAG_INVERSE 0x0200 #define SSDFB_ATTACH_FLAG_CONSOLE 0x0400 +#define SSDFB_ATTACH_FLAG_MPSAFE 0x0800 /* * Fundamental commands
CVS commit: src/share/man/man4
Module Name:src Committed By: tnn Date: Thu Aug 5 19:23:45 UTC 2021 Modified Files: src/share/man/man4: ssdfb.4 Log Message: ssdfb(4): note SSD1353 support To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/ssdfb.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/ssdfb.4 diff -u src/share/man/man4/ssdfb.4:1.6 src/share/man/man4/ssdfb.4:1.7 --- src/share/man/man4/ssdfb.4:1.6 Sun Aug 1 16:17:05 2021 +++ src/share/man/man4/ssdfb.4 Thu Aug 5 19:23:44 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ssdfb.4,v 1.6 2021/08/01 16:17:05 tnn Exp $ +.\" $NetBSD: ssdfb.4,v 1.7 2021/08/05 19:23:44 tnn Exp $ .\" .\" Copyright (c) 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 1, 2021 +.Dd August 5, 2021 .Dt SSDFB 4 .Os .Sh NAME @@ -54,6 +54,8 @@ Solomon Systech Ltd SSD1306 Sino Wealth Electronic Ltd SH1106 .It Solomon Systech Ltd SSD1322 +.It +Solomon Systech Ltd SSD1353 .El .Pp The following products (controller + panel assemblies) are supported: @@ -73,6 +75,12 @@ Adafruit Industries, LLC product 931 (12 .It .Em 0x05 : Generic SSD1322 modules using default settings +.It +.Em 0x06 : +Generic SSD1353 modules using default settings +.It +.Em 0x07 : +Display Elektronik GmbH DEP 160128A(1)-RGB .El .Pp The flags value can contain one or more of the following, bitwise OR'ed:
CVS commit: src/sys/dev/spi
Module Name:src Committed By: tnn Date: Thu Aug 5 19:17:22 UTC 2021 Modified Files: src/sys/dev/spi: ssdfb_spi.c Log Message: ssdfb: fix some constant names. NFC because the same cmd code is used To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/ssdfb_spi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/spi/ssdfb_spi.c diff -u src/sys/dev/spi/ssdfb_spi.c:1.8 src/sys/dev/spi/ssdfb_spi.c:1.9 --- src/sys/dev/spi/ssdfb_spi.c:1.8 Thu Aug 5 19:08:59 2021 +++ src/sys/dev/spi/ssdfb_spi.c Thu Aug 5 19:17:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfb_spi.c,v 1.8 2021/08/05 19:08:59 tnn Exp $ */ +/* $NetBSD: ssdfb_spi.c,v 1.9 2021/08/05 19:17:22 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.8 2021/08/05 19:08:59 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.9 2021/08/05 19:17:22 tnn Exp $"); #include #include @@ -410,7 +410,7 @@ ssdfb_spi_xfer_rect_4wire_ssd1353(void * return 0; ssdfb_spi_4wire_set_dc(sc, 0); - cmd = SSD1322_CMD_SET_ROW_ADDRESS; + cmd = SSD1353_CMD_SET_ROW_ADDRESS; error = spi_send(sc->sc_sh, sizeof(cmd), ); if (error) return error; @@ -427,7 +427,7 @@ ssdfb_spi_xfer_rect_4wire_ssd1353(void * return error; ssdfb_spi_4wire_set_dc(sc, 0); - cmd = SSD1322_CMD_SET_COLUMN_ADDRESS; + cmd = SSD1353_CMD_SET_COLUMN_ADDRESS; error = spi_send(sc->sc_sh, sizeof(cmd), ); if (error) return error; @@ -439,7 +439,7 @@ ssdfb_spi_xfer_rect_4wire_ssd1353(void * return error; ssdfb_spi_4wire_set_dc(sc, 0); - cmd = SSD1322_CMD_WRITE_RAM; + cmd = SSD1353_CMD_WRITE_RAM; error = spi_send(sc->sc_sh, sizeof(cmd), ); if (error) return error;
CVS commit: src/sys/dev/spi
Module Name:src Committed By: tnn Date: Thu Aug 5 19:08:59 UTC 2021 Modified Files: src/sys/dev/spi: ssdfb_spi.c Log Message: ssdfb: support SSD1353 at spi(4) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/ssdfb_spi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/spi/ssdfb_spi.c diff -u src/sys/dev/spi/ssdfb_spi.c:1.7 src/sys/dev/spi/ssdfb_spi.c:1.8 --- src/sys/dev/spi/ssdfb_spi.c:1.7 Tue Aug 3 11:30:25 2021 +++ src/sys/dev/spi/ssdfb_spi.c Thu Aug 5 19:08:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfb_spi.c,v 1.7 2021/08/03 11:30:25 tnn Exp $ */ +/* $NetBSD: ssdfb_spi.c,v 1.8 2021/08/05 19:08:59 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.7 2021/08/03 11:30:25 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.8 2021/08/05 19:08:59 tnn Exp $"); #include #include @@ -70,6 +70,8 @@ static int ssdfb_spi_xfer_rect_3wire_ssd static int ssdfb_spi_cmd_4wire(void *, uint8_t *, size_t, bool); static int ssdfb_spi_xfer_rect_4wire_ssd1322(void *, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t *, size_t, bool); +static int ssdfb_spi_xfer_rect_4wire_ssd1353(void *, uint8_t, uint8_t, + uint8_t, uint8_t, uint8_t *, size_t, bool); static void ssdfb_bitstream_init(struct bs_state *, uint8_t *); static void ssdfb_bitstream_append(struct bs_state *, uint8_t, uint8_t); @@ -84,6 +86,8 @@ CFATTACH_DECL_NEW(ssdfb_spi, sizeof(stru static const struct device_compatible_entry compat_data[] = { { .compat = "solomon,ssd1306", .value = SSDFB_PRODUCT_SSD1306_GENERIC }, { .compat = "solomon,ssd1322", .value = SSDFB_PRODUCT_SSD1322_GENERIC }, + { .compat = "solomon,ssd1353", .value = SSDFB_PRODUCT_SSD1353_GENERIC }, + { .compat = "dep160128a", .value = SSDFB_PRODUCT_DEP_160128A_RGB }, DEVICE_COMPAT_EOL }; @@ -154,28 +158,32 @@ ssdfb_spi_attach(device_t parent, device sc->sc_3wiremode = true; #endif + sc->sc.sc_cmd = sc->sc_3wiremode + ? ssdfb_spi_cmd_3wire + : ssdfb_spi_cmd_4wire; + switch (flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) { case SSDFB_PRODUCT_SSD1322_GENERIC: - if (sc->sc_3wiremode) { - sc->sc.sc_transfer_rect = - ssdfb_spi_xfer_rect_3wire_ssd1322; - } else { - sc->sc.sc_transfer_rect = - ssdfb_spi_xfer_rect_4wire_ssd1322; - } + sc->sc.sc_transfer_rect = sc->sc_3wiremode + ? ssdfb_spi_xfer_rect_3wire_ssd1322 + : ssdfb_spi_xfer_rect_4wire_ssd1322; + break; + case SSDFB_PRODUCT_SSD1353_GENERIC: + case SSDFB_PRODUCT_DEP_160128A_RGB: + sc->sc.sc_transfer_rect = sc->sc_3wiremode + ? NULL /* not supported here */ + : ssdfb_spi_xfer_rect_4wire_ssd1353; break; - default: - panic("ssdfb_spi_attach: product not implemented"); } - if (sc->sc_3wiremode) { - sc->sc.sc_cmd = ssdfb_spi_cmd_3wire; - } else { - sc->sc.sc_cmd = ssdfb_spi_cmd_4wire; + + if (!sc->sc.sc_transfer_rect) { + aprint_error(": sc_transfer_rect not implemented\n"); + return; } ssdfb_attach(>sc, flags); - device_printf(sc->sc.sc_dev, "%d-wire SPI interface\n", + aprint_normal_dev(self, "%d-wire SPI interface\n", sc->sc_3wiremode == true ? 3 : 4); } @@ -381,3 +389,79 @@ ssdfb_spi_xfer_rect_4wire_ssd1322(void * return 0; } + +static int +ssdfb_spi_xfer_rect_4wire_ssd1353(void *cookie, uint8_t fromcol, uint8_t tocol, +uint8_t fromrow, uint8_t torow, uint8_t *p, size_t stride, bool usepoll) +{ + struct ssdfb_spi_softc *sc = (struct ssdfb_spi_softc *)cookie; + uint8_t row; + size_t rlen = (tocol + 1 - fromcol) * 3; + uint8_t bitstream[160 * 3]; + uint8_t *dstp, *srcp, *endp; + int error; + uint8_t cmd; + uint8_t data[2]; + + /* + * Unlike iic(4), there is no way to force spi(4) to use polling. + */ + if (usepoll && !cold) + return 0; + + ssdfb_spi_4wire_set_dc(sc, 0); + cmd = SSD1322_CMD_SET_ROW_ADDRESS; + error = spi_send(sc->sc_sh, sizeof(cmd), ); + if (error) + return error; + ssdfb_spi_4wire_set_dc(sc, 1); + data[0] = fromrow; + data[1] = torow; + if (sc->sc.sc_upsidedown) { + /* fix picture outside frame on 160x128 panel */ + data[0] += 132 - sc->sc.sc_p->p_height; + data[1] += 132 - sc->sc.sc_p->p_height; + } + error = spi_send(sc->sc_sh, sizeof(data), data); + if (error) + return error; + + ssdfb_spi_4wire_set_dc(sc, 0); + cmd = SSD1322_CMD_SET_COLUMN_ADDRESS; + error = spi_send(sc->sc_sh, sizeof(cmd), ); + if (error) + return error; + ssdfb_spi_4wire_set_dc(sc, 1); + data[0] = fromcol; + data[1] = tocol; + error = spi_send(sc->sc_sh, sizeof(data), data); + if (error) + return error; + + ssdfb_spi_4wire_set_dc(sc, 0); + cmd = SSD1322_CMD_WRITE_RAM; + error = spi_send(sc->sc_sh, sizeof(cmd), ); + if (error) + return error; + + ssdfb_spi_4wire_set_dc(sc, 1); + KASSERT(rlen <= sizeof(bitstream)); + for (row = fromrow; row <= torow; row++) { + /* downconvert each row from
CVS commit: src/sys/dev/ic
Module Name:src Committed By: tnn Date: Thu Aug 5 19:07:09 UTC 2021 Modified Files: src/sys/dev/ic: ssdfb.c ssdfbvar.h Log Message: ssdfb: support the SSD1353 controller and the DEP 160128A(1)-RGB display DEP 160128A is a 160x128 18-bit RGB OLED display module advertised as having an 8-bit parallel I/O interface. The controller can however attach serially via spi(4) by moving jumper resistors J1 and J2 to GND position. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/ssdfb.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/ssdfbvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ssdfb.c diff -u src/sys/dev/ic/ssdfb.c:1.17 src/sys/dev/ic/ssdfb.c:1.18 --- src/sys/dev/ic/ssdfb.c:1.17 Thu Aug 5 00:16:36 2021 +++ src/sys/dev/ic/ssdfb.c Thu Aug 5 19:07:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ssdfb.c,v 1.17 2021/08/05 00:16:36 tnn Exp $ */ +/* $NetBSD: ssdfb.c,v 1.18 2021/08/05 19:07:09 tnn Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.17 2021/08/05 00:16:36 tnn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.18 2021/08/05 19:07:09 tnn Exp $"); #include "opt_ddb.h" @@ -75,6 +75,7 @@ static void ssdfb_cursor(void *, int, in /* hardware interface */ static int ssdfb_init_ssd1306(struct ssdfb_softc *); static int ssdfb_init_ssd1322(struct ssdfb_softc *); +static int ssdfb_init_ssd1353(struct ssdfb_softc *); static int ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool); static int ssdfb_set_display_on(struct ssdfb_softc *, bool, bool); static int ssdfb_set_mode(struct ssdfb_softc *, u_int); @@ -89,6 +90,7 @@ static void ssdfb_set_usepoll(struct ssd static int ssdfb_sync(struct ssdfb_softc *, bool); static int ssdfb_sync_ssd1306(struct ssdfb_softc *, bool); static int ssdfb_sync_ssd1322(struct ssdfb_softc *, bool); +static int ssdfb_sync_ssd1353(struct ssdfb_softc *, bool); static uint64_t ssdfb_transpose_block(uint8_t *, size_t); /* misc helpers */ @@ -104,7 +106,8 @@ static const char *ssdfb_controller_name [SSDFB_CONTROLLER_UNKNOWN] = "unknown", [SSDFB_CONTROLLER_SSD1306] = "Solomon Systech SSD1306", [SSDFB_CONTROLLER_SH1106] = "Sino Wealth SH1106", - [SSDFB_CONTROLLER_SSD1322] = "Solomon Systech SSD1322" + [SSDFB_CONTROLLER_SSD1322] = "Solomon Systech SSD1322", + [SSDFB_CONTROLLER_SSD1353] = "Solomon Systech SSD1353" }; /* @@ -204,6 +207,44 @@ static const struct ssdfb_product ssdfb_ .p_multiplex_ratio = 0x3f, .p_init = ssdfb_init_ssd1322, .p_sync = ssdfb_sync_ssd1322 + }, + { + .p_product_id = SSDFB_PRODUCT_SSD1353_GENERIC, + .p_controller_id = SSDFB_CONTROLLER_SSD1353, + .p_name = "generic", + .p_width = 160, + .p_height = 132, + .p_bits_per_pixel = 32, + .p_rgb = true, + .p_panel_shift = 0, + .p_compin_cfg = SSD1353_REMAP_RGB | SSD1353_REMAP_SPLIT_ODD_EVEN + | __SHIFTIN(2, SSD1353_REMAP_PIXEL_FORMAT_MASK), + .p_vcomh_deselect_level = SSD1353_DEFAULT_VCOMH, + .p_fosc = SSD1353_DEFAULT_FREQUENCY, + .p_fosc_div = SSD1353_DEFAULT_DIVIDER, + .p_default_contrast = SSD1353_DEFAULT_CONTRAST_CONTROL, + .p_multiplex_ratio = 0x83, + .p_init = ssdfb_init_ssd1353, + .p_sync = ssdfb_sync_ssd1353 + }, + { + .p_product_id = SSDFB_PRODUCT_DEP_160128A_RGB, + .p_controller_id = SSDFB_CONTROLLER_SSD1353, + .p_name = "Display Elektronik GmbH DEP 160128A(1)-RGB", + .p_width = 160, + .p_height = 128, + .p_bits_per_pixel = 32, + .p_rgb = true, + .p_panel_shift = 0, + .p_compin_cfg = SSD1353_REMAP_RGB | SSD1353_REMAP_SPLIT_ODD_EVEN + | __SHIFTIN(2, SSD1353_REMAP_PIXEL_FORMAT_MASK), + .p_vcomh_deselect_level = SSD1353_DEFAULT_VCOMH, + .p_fosc = SSD1353_DEFAULT_FREQUENCY, + .p_fosc_div = SSD1353_DEFAULT_DIVIDER, + .p_default_contrast = SSD1353_DEFAULT_CONTRAST_CONTROL, + .p_multiplex_ratio = 0x83, + .p_init = ssdfb_init_ssd1353, + .p_sync = ssdfb_sync_ssd1353 } }; @@ -872,18 +913,148 @@ ssdfb_init_ssd1322(struct ssdfb_softc *s } static int +ssdfb_init_ssd1353(struct ssdfb_softc *sc) +{ + int error; + uint8_t cmd[3]; + bool usepoll = true; + uint8_t remap; + + /* + * Enter sleep. + */ + SSDFB_CMD2(SSD1353_CMD_SET_COMMAND_LOCK, SSD1353_COMMAND_UNLOCK_MAGIC); + if (error) + return error; + SSDFB_CMD1(SSD1353_CMD_RESET); + if (error) + return error; + SSDFB_CMD1(SSD1353_CMD_DEACTIVATE_SCROLL); + if (error) + return error; + SSDFB_CMD1(SSD1353_CMD_SET_DISPLAY_OFF); + if (error) + return error; + + /* + * Start charge pumps. + */ + SSDFB_CMD2(SSD1353_CMD_SET_VCOMH, sc->sc_p->p_vcomh_deselect_level); + if (error) + return error; + SSDFB_CMD2(SSD1353_CMD_SET_PRE_CHARGE_VOLTAGE_LEVEL, + SSD1353_DEFAULT_PRE_CHARGE_VOLTAGE_LEVEL); + if (error) + return error; + + /* + * Configure timing characteristics. + */ + SSDFB_CMD2(SSD1353_CMD_SET_FRONT_CLOCK_DIVIDER, +
CVS commit: src/sbin/devpubd/hooks
Module Name:src Committed By: kre Date: Thu Aug 5 12:52:47 UTC 2021 Modified Files: src/sbin/devpubd/hooks: 02-wedgenames Log Message: Obliterate bogus $@ usage. While here, fix some quoting, change some style, and attempt to properly handle wedge names with embedded newlines, and those that end with a '/' character (not particularly happy with the solution to that last one, but it is better than it was). Is there a reason that characters that need encoding in wedge names (white space, and more) are encoded as %%XX (XX is the hex value of the char - but 2 % chars? Why?). That remains unchanged, but as the script already relied upon sh's $'...' quoting, I think we can rely upon printf as well, so replace the old (very elegant, but slow) encoding function with a much simpler one (does the same thing). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sbin/devpubd/hooks/02-wedgenames Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/devpubd/hooks/02-wedgenames diff -u src/sbin/devpubd/hooks/02-wedgenames:1.6 src/sbin/devpubd/hooks/02-wedgenames:1.7 --- src/sbin/devpubd/hooks/02-wedgenames:1.6 Sat Jan 9 16:25:19 2021 +++ src/sbin/devpubd/hooks/02-wedgenames Thu Aug 5 12:52:47 2021 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: 02-wedgenames,v 1.6 2021/01/09 16:25:19 mlelstv Exp $ +# $NetBSD: 02-wedgenames,v 1.7 2021/08/05 12:52:47 kre Exp $ # # Try to maintain symlinks to wedge devices # @@ -9,16 +9,15 @@ export LC_ALL=C event="$1" shift -devices=$@ wedgedir=/dev/wedges recurse() { - test -d "$1" && ls -1af "$1" \ - | while read n; do + test -d "$1" && + ls -1af "$1" | while read n; do case $n in - .|..) ;; + .|..) ;; *) echo "$1/$n" if [ -L "$1/$n" ]; then @@ -28,7 +27,7 @@ recurse() fi ;; esac - done + done } simple_readlink() @@ -41,43 +40,49 @@ simple_readlink() esac } -ordtable=$( - for n1 in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - for n2 in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - echo "\$'\x$n1$n2') x=$n1$n2;;" - done - done -) +#ordtable=$( +# for n1 in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do +# for n2 in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do +# echo "\$'\x$n1$n2') x=$n1$n2;;" +# done +# done +#) +# +#ord() +#{ +# local x +# eval "case \$1 in $ordtable esac" +# echo -n $x +#} ord() { - local x - eval "case \$1 in $ordtable esac" - echo -n $x + printf %2.2x "'$1" } encode() { - local a + local a b c a=$1 + b= while [ -n "$a" ]; do c="${a%"${a#?}"}" a=${a#?} case $c in - [[:alnum:]._:\;!^$\&~\(\)[\]{}=,+\-/]) + [][:alnum:]._:\;!^$\&~\(\)[{}=,+/-]) ;; *) - c='%%'$(ord "$c") + c=%%$(ord "$c") ;; esac - echo -n "$c" + b=${b}${c} done + printf %s "$b" } remove_wedge() { - recurse "$wedgedir" \ - | while read w; do + recurse "$wedgedir" | while read w; do t=$(simple_readlink "$w") if [ x"$t" = x"/dev/$1" ]; then rm -f "$w" @@ -87,43 +92,72 @@ remove_wedge() { done } +wedge_label() { + local l + + # dkctl getwedgeinfo always outputs 2 "lines", the first + # contains the label (and may contain embedded \n chars) + # the second contains the size, offset, and type, and one + # trailing \n (stripped by the $()) - so we can safely + # extract the label by deleting from the final \n in the + # value getwedgeinfo prints to the end + + l=$(dkctl "$1" getwedgeinfo) + l=${l%$'\n'*} + case "${l}" in + $1' at '*': '*) + l=${l#*: } + ;; + *) + l=$1 + ;; + esac + + # The trailing is to ensure a trailing \n in the label + # is not deleted by a command substitution which invokes us. + # That will be rmeoved by the caller. + printf %s "${l}" +} + add_wedge() { - dkctl "$1" getwedgeinfo \ - | while read l; do - case $l in - *': '*) - n="${l#*: }" - n=$(encode "$n") - test -d $wedgedir || mkdir -m 755 $wedgedir - basedir="$wedgedir/$n" - basedir=${basedir%/*} - test -d "$basedir" || mkdir -p -m 755 "$basedir" - if oldlink=$(simple_readlink "$wedgedir/$n"); then -if [ x"$oldlink" != x"/dev/$1" ]; then - rm -f "$wedgedir/$n" - ln -s "/dev/$1" "$wedgedir/$n" -fi - else + local l n + + l=$(wedge_label "$1") + l=${l%''} + case "$l" in */) l="${l}Wedge";; esac + + n=$(encode "${l}") + + ( + umask 022 + + test -d "$wedgedir" || mkdir -m 755 "$wedgedir" + basedir="$wedgedir/$n" + basedir=${basedir%/*} + test -d "$basedir" || mkdir -p -m 755 "$basedir" + if oldlink=$(simple_readlink "$wedgedir/$n"); then + if [ x"$oldlink" != x"/dev/$1" ]; then +rm -f "$wedgedir/$n" ln -s "/dev/$1" "$wedgedir/$n" fi - ;; - esac - break - done + else + ln -s "/dev/$1" "$wedgedir/$n" + fi + ) } -for device in $devices; do +for device do case $device in dk*) case $event in device-attach) - remove_wedge $device - add_wedge $device + remove_wedge "$device" + add_wedge "$device" ;; device-detach) -
CVS commit: src/sbin/devpubd
Module Name:src Committed By: kre Date: Thu Aug 5 12:45:33 UTC 2021 Modified Files: src/sbin/devpubd: devpubd-run-hooks.in src/sbin/devpubd/hooks: 01-makedev Log Message: Expunge bogus (implementation defined / unspecified) uses of $@ in scripts. $@ is unspecified except when used in a place where field splitting can occur (which is never in an assignment), X=$@ (with or without double quotes) is simply wrong. Use $* instead of $@ in such places, or as here, simply change the way things are done (very very slightly) and DTRT. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/devpubd/devpubd-run-hooks.in cvs rdiff -u -r1.2 -r1.3 src/sbin/devpubd/hooks/01-makedev Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/devpubd/devpubd-run-hooks.in diff -u src/sbin/devpubd/devpubd-run-hooks.in:1.3 src/sbin/devpubd/devpubd-run-hooks.in:1.4 --- src/sbin/devpubd/devpubd-run-hooks.in:1.3 Sun Feb 15 15:56:30 2015 +++ src/sbin/devpubd/devpubd-run-hooks.in Thu Aug 5 12:45:33 2021 @@ -1,19 +1,19 @@ #!/bin/sh # -# $NetBSD: devpubd-run-hooks.in,v 1.3 2015/02/15 15:56:30 jmcneill Exp $ +# $NetBSD: devpubd-run-hooks.in,v 1.4 2021/08/05 12:45:33 kre Exp $ # # devpubd run hooks devpubd_event=$1 shift -devpubd_devices=$@ + devpubd_hooks_base=@HOOKSDIR@ case $devpubd_event in device-attach|device-detach) for hook in ${devpubd_hooks_base}/*; do if [ -x "${hook}" ]; then - "${hook}" ${devpubd_event} ${devpubd_devices} + "${hook}" ${devpubd_event} "$@" fi done ;; Index: src/sbin/devpubd/hooks/01-makedev diff -u src/sbin/devpubd/hooks/01-makedev:1.2 src/sbin/devpubd/hooks/01-makedev:1.3 --- src/sbin/devpubd/hooks/01-makedev:1.2 Sun Feb 15 15:56:30 2015 +++ src/sbin/devpubd/hooks/01-makedev Thu Aug 5 12:45:33 2021 @@ -1,16 +1,15 @@ #!/bin/sh # -# $NetBSD: 01-makedev,v 1.2 2015/02/15 15:56:30 jmcneill Exp $ +# $NetBSD: 01-makedev,v 1.3 2021/08/05 12:45:33 kre Exp $ # # Try to create a device node if it doesn't exist # event="$1" shift -devices=$@ case $event in device-attach) - cd /dev && sh MAKEDEV -u $devices 2>/dev/null + cd /dev && sh MAKEDEV -u "$@" 2>/dev/null ;; esac
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Thu Aug 5 06:54:16 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: fix type of local variable in inpqstrg Noted by Clang-Tidy. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.47 src/usr.bin/xlint/lint2/read.c:1.48 --- src/usr.bin/xlint/lint2/read.c:1.47 Thu Aug 5 06:45:37 2021 +++ src/usr.bin/xlint/lint2/read.c Thu Aug 5 06:54:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */ +/* $NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $"); #endif #include @@ -1057,7 +1057,7 @@ inpqstrg(const char *src, const char **e { char *strg, *dst; size_t slen; - int c; + char c; int v; dst = strg = xmalloc(slen = 32); @@ -1110,7 +1110,7 @@ inpqstrg(const char *src, const char **e if ((c = *src++) < '0' || c > '7') inperr("not octal: %c", c); v |= c - '0'; -c = (u_char)v; +c = (char)v; break; default: inperr("bad \\ escape: %c", c); @@ -1122,7 +1122,7 @@ inpqstrg(const char *src, const char **e dst = strg + (slen - 1); slen *= 2; } - *dst++ = (char)c; + *dst++ = c; if ((c = *src++) == '\0') inperr("missing closing quote"); }
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Thu Aug 5 06:45:37 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: fix handling of __int128_t/__uint128_t in lint2 Previously, lint exited with "bad type: J u". To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.46 src/usr.bin/xlint/lint2/read.c:1.47 --- src/usr.bin/xlint/lint2/read.c:1.46 Sat Jul 31 19:52:44 2021 +++ src/usr.bin/xlint/lint2/read.c Thu Aug 5 06:45:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $ */ +/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $"); #endif #include @@ -838,6 +838,15 @@ gettlen(const char *cp, const char **epp t = QUAD; } break; +#ifdef INT128_SIZE + case 'J': + if (s == 'u') { + t = UINT128; + } else if (s == '\0') { + t = INT128; + } + break; +#endif case 'D': if (s == 's') { t = FLOAT;
CVS commit: src
Module Name:src Committed By: rillig Date: Thu Aug 5 06:34:43 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile accept.sh Added Files: src/tests/usr.bin/xlint/lint1: emit_lp64.c emit_lp64.exp-ln Log Message: tests/lint: test emitting 128-bit integer types for lint2 To generate a diff of this commit: cvs rdiff -u -r1.1102 -r1.1103 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.101 -r1.102 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/accept.sh cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/emit_lp64.c \ src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1102 src/distrib/sets/lists/tests/mi:1.1103 --- src/distrib/sets/lists/tests/mi:1.1102 Tue Aug 3 20:34:23 2021 +++ src/distrib/sets/lists/tests/mi Thu Aug 5 06:34:42 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1102 2021/08/03 20:34:23 rillig Exp $ +# $NetBSD: mi,v 1.1103 2021/08/05 06:34:42 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6236,6 +6236,8 @@ ./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/emit.lntests-obsolete obsolete +./usr/tests/usr.bin/xlint/lint1/emit_lp64.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_binary.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_binary.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.101 src/tests/usr.bin/xlint/lint1/Makefile:1.102 --- src/tests/usr.bin/xlint/lint1/Makefile:1.101 Tue Aug 3 20:34:23 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Thu Aug 5 06:34:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.101 2021/08/03 20:34:23 rillig Exp $ +# $NetBSD: Makefile,v 1.102 2021/08/05 06:34:43 rillig Exp $ NOMAN= # defined MAX_MESSAGE= 345 # see lint1/err.c @@ -131,6 +131,8 @@ FILES+= decl_struct_member.exp FILES+= emit.c FILES+= emit.exp FILES+= emit.exp-ln +FILES+= emit_lp64.c +FILES+= emit_lp64.exp-ln FILES+= expr_binary.c FILES+= expr_binary.exp FILES+= expr_binary_trad.c Index: src/tests/usr.bin/xlint/lint1/accept.sh diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.3 src/tests/usr.bin/xlint/lint1/accept.sh:1.4 --- src/tests/usr.bin/xlint/lint1/accept.sh:1.3 Sun Jul 11 14:43:57 2021 +++ src/tests/usr.bin/xlint/lint1/accept.sh Thu Aug 5 06:34:43 2021 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: accept.sh,v 1.3 2021/07/11 14:43:57 rillig Exp $ +# $NetBSD: accept.sh,v 1.4 2021/08/05 06:34:43 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -41,7 +41,7 @@ for pattern in "$@"; do cfile="$base.c" expfile="$base.exp" tmpfile="$base.exp.tmp" - ln_file="$base.ln" + ln_file="$base.exp-ln" configure_test_case "$cfile" # shellcheck disable=SC2154 Added files: Index: src/tests/usr.bin/xlint/lint1/emit_lp64.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/emit_lp64.c:1.1 --- /dev/null Thu Aug 5 06:34:43 2021 +++ src/tests/usr.bin/xlint/lint1/emit_lp64.c Thu Aug 5 06:34:43 2021 @@ -0,0 +1,19 @@ +/* $NetBSD: emit_lp64.c,v 1.1 2021/08/05 06:34:43 rillig Exp $ */ +# 3 "emit_lp64.c" + +/* + * Test the symbol information that lint1 writes to a .ln file. Using this + * symbol information, lint2 later checks that the symbols are used + * consistently across different translation units. + * + * This test covers large integer types that are only supported on LP64 + * platforms. + */ + +// omit the option '-g' to avoid having the GCC builtins in the .ln file. +/* lint1-flags: -Sw */ + +/* lint1-only-if: lp64 */ + +__int128_t int128(__int128_t); +__uint128_t uint128(__uint128_t); Index: src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln diff -u /dev/null src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln:1.1 --- /dev/null Thu Aug 5 06:34:43 2021 +++ src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln Thu Aug 5 06:34:43 2021 @@ -0,0 +1,4 @@ +0semit_lp64.c +Semit_lp64.c +18d0.18e6int128F1JJ +19d0.19e7uint128F1uJuJ