CVS commit: src/sys
Module Name:src Committed By: mrg Date: Wed Jun 23 00:56:41 UTC 2021 Modified Files: src/sys/arch/arm/rockchip: rk_platform.c src/sys/dev/ic: ahcisata_core.c Log Message: make ahcisata(4) work on rk3399 (rockpro64) on rk3399, a marvell 9230 ahci sata card consistently takes between 1213 and 1216 milliseconds, the ahci spec says this should complete in 1000 or fewer. add a "pcie-reset-ms" uint32 property that ahcisata defaults to 1000 if not set, and the rockchip platform code sets to 2000. ok @jmcneill To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/rockchip/rk_platform.c cvs rdiff -u -r1.98 -r1.99 src/sys/dev/ic/ahcisata_core.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/arm/rockchip/rk_platform.c diff -u src/sys/arch/arm/rockchip/rk_platform.c:1.12 src/sys/arch/arm/rockchip/rk_platform.c:1.13 --- src/sys/arch/arm/rockchip/rk_platform.c:1.12 Sat Apr 24 23:36:28 2021 +++ src/sys/arch/arm/rockchip/rk_platform.c Wed Jun 23 00:56:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_platform.c,v 1.12 2021/04/24 23:36:28 thorpej Exp $ */ +/* $NetBSD: rk_platform.c,v 1.13 2021/06/23 00:56:41 mrg Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -31,7 +31,7 @@ #include "opt_console.h" #include -__KERNEL_RCSID(0, "$NetBSD: rk_platform.c,v 1.12 2021/04/24 23:36:28 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rk_platform.c,v 1.13 2021/06/23 00:56:41 mrg Exp $"); #include #include @@ -39,6 +39,8 @@ __KERNEL_RCSID(0, "$NetBSD: rk_platform. #include #include +#include + #include #include @@ -70,6 +72,17 @@ rk_platform_init_attach_args(struct fdt_ static void rk_platform_device_register(device_t self, void *aux) { + prop_dictionary_t dict = device_properties(self); + + if (device_is_a(self, "ahcisata")) { + /* + * Marvel 9230 AHCI SATA controllers take between 1213 and 1216 + * milliseconds to reset, exceeding the AHCI spec of 1000. + */ + if (!prop_dictionary_set_uint32(dict, "ahci-reset-ms", 2000)) + printf("%s: Failed to set \"ahci-reset-ms\" property" + " on ahcisata\n", __func__); + } } static void Index: src/sys/dev/ic/ahcisata_core.c diff -u src/sys/dev/ic/ahcisata_core.c:1.98 src/sys/dev/ic/ahcisata_core.c:1.99 --- src/sys/dev/ic/ahcisata_core.c:1.98 Sat Apr 24 23:36:55 2021 +++ src/sys/dev/ic/ahcisata_core.c Wed Jun 23 00:56:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.98 2021/04/24 23:36:55 thorpej Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.99 2021/06/23 00:56:41 mrg Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.98 2021/04/24 23:36:55 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.99 2021/06/23 00:56:41 mrg Exp $"); #include #include @@ -144,19 +144,31 @@ static int ahci_reset(struct ahci_softc *sc) { int i; + uint32_t timeout_ms = 1000; /* default to 1s timeout */ + prop_dictionary_t dict; /* reset controller */ AHCI_WRITE(sc, AHCI_GHC, AHCI_GHC_HR); - /* wait up to 1s for reset to complete */ - for (i = 0; i < 1000; i++) { + + /* some systems (rockchip rk3399) need extra reset time for ahcisata. */ + dict = device_properties(sc->sc_atac.atac_dev); + if (dict) + prop_dictionary_get_uint32(dict, "ahci-reset-ms", _ms); + + /* wait for reset to complete */ + for (i = 0; i < timeout_ms; i++) { delay(1000); if ((AHCI_READ(sc, AHCI_GHC) & AHCI_GHC_HR) == 0) break; } - if ((AHCI_READ(sc, AHCI_GHC) & AHCI_GHC_HR)) { - aprint_error("%s: reset failed\n", AHCINAME(sc)); + if ((AHCI_READ(sc, AHCI_GHC) & AHCI_GHC_HR) != 0) { + aprint_error_dev(sc->sc_atac.atac_dev, "reset failed\n"); return -1; } + if (i > 1000) { + aprint_normal_dev(sc->sc_atac.atac_dev, + "reset took %d milliseconds\n", i); + } /* enable ahci mode */ ahci_enable(sc);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Jun 23 00:38:12 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c Log Message: print_banner: Print memory size like x86 does To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/boot.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/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.32 src/sys/stand/efiboot/boot.c:1.33 --- src/sys/stand/efiboot/boot.c:1.32 Mon Jun 21 21:18:47 2021 +++ src/sys/stand/efiboot/boot.c Wed Jun 23 00:38:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.32 2021/06/21 21:18:47 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.33 2021/06/23 00:38:12 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -450,13 +450,56 @@ set_bootargs(const char *arg) return 0; } +static void +get_memory_info(uint64_t *ptotal) +{ + EFI_MEMORY_DESCRIPTOR *md, *memmap; + UINTN nentries, mapkey, descsize; + UINT32 descver; + uint64_t totalpg = 0; + int n; + + memmap = LibMemoryMap(, , , ); + for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) { + if ((md->Attribute & EFI_MEMORY_WB) == 0) { + continue; + } + totalpg += md->NumberOfPages; + } + + *ptotal = totalpg * EFI_PAGE_SIZE; +} + +static void +format_bytes(uint64_t val, uint64_t *pdiv, const char **punit) +{ + static const char *units[] = { "KB", "MB", "GB" }; + unsigned n; + + *punit = "bytes"; + *pdiv = 1; + + for (n = 0; n < __arraycount(units) && val >= 1024; n++) { + *punit = units[n]; + *pdiv *= 1024; + val /= 1024; + } +} + void print_banner(void) { + const char *total_unit; + uint64_t total, total_div; + + get_memory_info(); + format_bytes(total, _div, _unit); + printf(" \\-__,--,___.\n"); printf(" \\__,---` %s\n", bootprog_name); printf("\\ `---,_. Revision %s\n", bootprog_rev); - printf(" \\-,_,.---`\n"); + printf(" \\-,_,.---` Memory: %" PRIu64 " %s\n", + total / total_div, total_unit); printf(" \\\n"); printf(" \\\n"); printf("\\\n\n");
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Jun 22 21:56:51 UTC 2021 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: efiboot: Use EFI_BLOCK_IO_PROTOCOL if EFI_DISK_IO_PROTOCOL is missing UEFI spec says that firmware should automatically add EFI_DISK_IO_PROTOCOL for all produced EFI_BLOCK_IO_PROTOCOL interfaces. Unfortunately U-Boot doesn't do this, so fallback to block I/O if disk I/O is not there. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/efiblock.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/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.14 src/sys/stand/efiboot/efiblock.c:1.15 --- src/sys/stand/efiboot/efiblock.c:1.14 Mon Jun 21 21:18:47 2021 +++ src/sys/stand/efiboot/efiblock.c Tue Jun 22 21:56:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.14 2021/06/21 21:18:47 jmcneill Exp $ */ +/* $NetBSD: efiblock.c,v 1.15 2021/06/22 21:56:51 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -118,7 +118,74 @@ efi_block_generate_hash_mbr(struct efi_b } static EFI_STATUS -efi_block_disk_readahead(struct efi_block_dev *bdev, UINT64 off, void *buf, +efi_block_do_read_blockio(struct efi_block_dev *bdev, UINT64 off, void *buf, +UINTN bufsize) +{ + UINT8 *blkbuf, *blkbuf_start; + EFI_STATUS status; + EFI_LBA lba_start, lba_end; + UINT64 blkbuf_offset; + UINT64 blkbuf_size; + + lba_start = off / bdev->bio->Media->BlockSize; + lba_end = (off + bufsize + bdev->bio->Media->BlockSize - 1) / + bdev->bio->Media->BlockSize; + blkbuf_offset = off % bdev->bio->Media->BlockSize; + blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize; + if (bdev->bio->Media->IoAlign > 1) { + blkbuf_size += bdev->bio->Media->IoAlign - 1; + } + + blkbuf = AllocatePool(blkbuf_size); + if (blkbuf == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (bdev->bio->Media->IoAlign > 1) { + blkbuf_start = (void *)roundup2((intptr_t)blkbuf, + bdev->bio->Media->IoAlign); + } else { + blkbuf_start = blkbuf; + } + + status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, + bdev->media_id, lba_start, blkbuf_size, blkbuf_start); + if (EFI_ERROR(status)) { + goto done; + } + + memcpy(buf, blkbuf_start + blkbuf_offset, bufsize); + +done: + FreePool(blkbuf); + return status; +} + +static EFI_STATUS +efi_block_do_read_diskio(struct efi_block_dev *bdev, UINT64 off, void *buf, +UINTN bufsize) +{ + return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio, + bdev->media_id, off, bufsize, buf); +} + +static EFI_STATUS +efi_block_do_read(struct efi_block_dev *bdev, UINT64 off, void *buf, +UINTN bufsize) +{ + /* + * Perform read access using EFI_DISK_IO_PROTOCOL if available, + * otherwise use EFI_BLOCK_IO_PROTOCOL. + */ + if (bdev->dio != NULL) { + return efi_block_do_read_diskio(bdev, off, buf, bufsize); + } else { + return efi_block_do_read_blockio(bdev, off, buf, bufsize); + } +} + +static EFI_STATUS +efi_block_readahead(struct efi_block_dev *bdev, UINT64 off, void *buf, UINTN bufsize) { EFI_STATUS status; @@ -140,8 +207,7 @@ efi_block_disk_readahead(struct efi_bloc if (len > mediasize - off) { len = mediasize - off; } - status = uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio, - bdev->media_id, off, len, efi_ra_buffer); + status = efi_block_do_read(bdev, off, efi_ra_buffer, len); if (EFI_ERROR(status)) { efi_ra_start = efi_ra_length = 0; return status; @@ -156,15 +222,14 @@ efi_block_disk_readahead(struct efi_bloc } static EFI_STATUS -efi_block_disk_read(struct efi_block_dev *bdev, UINT64 off, void *buf, +efi_block_read(struct efi_block_dev *bdev, UINT64 off, void *buf, UINTN bufsize) { if (efi_ra_enable) { - return efi_block_disk_readahead(bdev, off, buf, bufsize); + return efi_block_readahead(bdev, off, buf, bufsize); } - return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio, - bdev->media_id, off, bufsize, buf); + return efi_block_do_read(bdev, off, buf, bufsize); } static int @@ -176,7 +241,7 @@ efi_block_find_partitions_cd9660(struct EFI_LBA lba; for (lba = 16;; lba++) { - status = efi_block_disk_read(bdev, + status = efi_block_read(bdev, lba * ISO_DEFAULT_BLOCK_SIZE, , sizeof(vd)); if (EFI_ERROR(status)) { goto io_error; @@ -220,7 +285,7 @@ efi_block_find_partitions_disklabel(stru EFI_STATUS status; int n; - status = efi_block_disk_read(bdev, + status = efi_block_read(bdev, ((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE, buf, sizeof(buf)); if (EFI_ERROR(status) || getdisklabel(buf, ) != NULL) { FreePool(buf); @@ -268,7 +333,7 @@ efi_block_find_partitions_mbr(struct efi EFI_STATUS status; int n; - status = efi_block_disk_read(bdev, 0, , sizeof(mbr)); + status = efi_block_read(bdev, 0, , sizeof(mbr)); if (EFI_ERROR(status)) return EIO; @@ -348,7 +413,7
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nia Date: Tue Jun 22 19:53:58 UTC 2021 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c Log Message: efiboot (x86): add ASCII art To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/efiboot/boot.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/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.18 src/sys/arch/i386/stand/efiboot/boot.c:1.19 --- src/sys/arch/i386/stand/efiboot/boot.c:1.18 Sun May 30 05:59:22 2021 +++ src/sys/arch/i386/stand/efiboot/boot.c Tue Jun 22 19:53:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.18 2021/05/30 05:59:22 mlelstv Exp $ */ +/* $NetBSD: boot.c,v 1.19 2021/06/22 19:53:58 nia Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -287,8 +287,19 @@ print_banner(void) for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n]; n++) printf("%s\n", bootcfg_info.banner[n]); - } else - command_version("short"); + } else { + printf("\n" + " \\-__,--,___.\n" + " \\__,---` %s (from NetBSD %s)\n" + "\\ `---,_. Revision %s\n" + " \\-,_,.---` Memory: %d/%d k\n" + " \\\n" + " \\\n" + "\\\n", + bootprog_name, bootprog_kernrev, + bootprog_rev, + getbasemem(), getextmem()); + } } void
CVS commit: src/doc
Module Name:src Committed By: martin Date: Tue Jun 22 13:02:52 UTC 2021 Modified Files: src/doc: HACKS Log Message: Document sh3* lint hack for gcc 9 To generate a diff of this commit: cvs rdiff -u -r1.218 -r1.219 src/doc/HACKS Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/HACKS diff -u src/doc/HACKS:1.218 src/doc/HACKS:1.219 --- src/doc/HACKS:1.218 Mon May 31 22:33:19 2021 +++ src/doc/HACKS Tue Jun 22 13:02:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: HACKS,v 1.218 2021/05/31 22:33:19 rin Exp $ +# $NetBSD: HACKS,v 1.219 2021/06/22 13:02:52 martin Exp $ # # This file is intended to document workarounds for currently unsolved # (mostly) compiler bugs. @@ -998,3 +998,16 @@ descr For alpha gcc-9 and gcc-10 miscomp allocation from the stack and freeing with regular free which causes a crash. kcah + +port sh3 + + hack gcc9-sh3-lint + cdate Tue Jun 22 14:59:52 CEST 2021 + mdate Tue Jun 22 14:59:52 CEST 2021 + who martin + file usr.bin/xlint/lint1/Makefile : 1.70 + descr + The in-tree gcc 9 crashes with an internal invalid + opcode exception when using any kind of optimization + on the lex.c file. Force -O0 for this file. +kcah
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: martin Date: Tue Jun 22 12:58:28 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile Log Message: Hack to avoid gcc 9 internal compiler error for sh3. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/lint1/Makefile 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/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.70 src/usr.bin/xlint/lint1/Makefile:1.71 --- src/usr.bin/xlint/lint1/Makefile:1.70 Sun Apr 18 22:51:24 2021 +++ src/usr.bin/xlint/lint1/Makefile Tue Jun 22 12:58:28 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.70 2021/04/18 22:51:24 rillig Exp $ +# $NetBSD: Makefile,v 1.71 2021/06/22 12:58:28 martin Exp $ .include @@ -27,6 +27,11 @@ CPPFLAGS+= ${DEBUG:D-DDEBUG} COPTS.err.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :} +.if ${HAVE_GCC} == 9 && \ + (${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb") +COPTS.lex.c+= -O0 +.endif + BINDIR= /usr/libexec CLEANFILES+= ${MAN}
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Jun 22 10:19:35 UTC 2021 Modified Files: src/sys/stand/efiboot: efirng.c Log Message: efirng: fix va_num arg to uefi_call_wrapper for GetRNG calls As far as I can tell this param isn't actually used, but it is supposed to be the number of arguments passed to the called method. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efirng.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/stand/efiboot/efirng.c diff -u src/sys/stand/efiboot/efirng.c:1.2 src/sys/stand/efiboot/efirng.c:1.3 --- src/sys/stand/efiboot/efirng.c:1.2 Thu May 14 23:09:29 2020 +++ src/sys/stand/efiboot/efirng.c Tue Jun 22 10:19:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efirng.c,v 1.2 2020/05/14 23:09:29 jmcneill Exp $ */ +/* $NetBSD: efirng.c,v 1.3 2021/06/22 10:19:35 jmcneill Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -121,14 +121,14 @@ efi_rng(void *buf, UINTN len) if (!efi_rng_available()) return EIO; - status = uefi_call_wrapper(rng->GetRNG, 3, rng, , + status = uefi_call_wrapper(rng->GetRNG, 4, rng, , len, buf); if (status == EFI_UNSUPPORTED) { /* * Fall back to any supported RNG `algorithm' even * though we would prefer raw samples. */ - status = uefi_call_wrapper(rng->GetRNG, 3, rng, NULL, len, buf); + status = uefi_call_wrapper(rng->GetRNG, 4, rng, NULL, len, buf); } if (EFI_ERROR(status)) { DPRINT(L"efirng: GetRNG: %r\n", status);
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:49:59 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: addstr2.chk addstr3.chk copywin6.chk copywin7.chk dupwin1.chk dupwin2.chk src/tests/lib/libcurses/tests: addstr Log Message: Update the check files to account for fixes to addstr.c To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/check_files/addstr2.chk \ src/tests/lib/libcurses/check_files/addstr3.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/check_files/copywin6.chk \ src/tests/lib/libcurses/check_files/copywin7.chk cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/check_files/dupwin1.chk \ src/tests/lib/libcurses/check_files/dupwin2.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addstr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/addstr2.chk diff -u src/tests/lib/libcurses/check_files/addstr2.chk:1.1 src/tests/lib/libcurses/check_files/addstr2.chk:1.2 --- src/tests/lib/libcurses/check_files/addstr2.chk:1.1 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/addstr2.chk Tue Jun 22 07:49:58 2021 @@ -1 +1 @@ -cup24;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456clearcup24;76Xa \ No newline at end of file +cup24;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456cup24;1Xclearcup24;76Xa rmamhsmamcup24;1X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/addstr3.chk diff -u src/tests/lib/libcurses/check_files/addstr3.chk:1.1 src/tests/lib/libcurses/check_files/addstr3.chk:1.2 --- src/tests/lib/libcurses/check_files/addstr3.chk:1.1 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/addstr3.chk Tue Jun 22 07:49:58 2021 @@ -1,2 +1,4 @@ -cup22;76Xa 0cup23;1X123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(cup24;1X)cup24;76Xel)clearcup23;76Xa -hello \ No newline at end of file +csr2;24Xhomehome +rin1Xcsr1;24Xhomehomecup24;1Xhome +()cup23;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*cup2;3Xclear +hellocup23;76Xacup2;6X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/copywin6.chk diff -u src/tests/lib/libcurses/check_files/copywin6.chk:1.3 src/tests/lib/libcurses/check_files/copywin6.chk:1.4 --- src/tests/lib/libcurses/check_files/copywin6.chk:1.3 Sun May 26 07:28:15 2019 +++ src/tests/lib/libcurses/check_files/copywin6.chk Tue Jun 22 07:49:58 2021 @@ -1,4 +1,4 @@ cup3;6Xstingt ingtes gtesti - estingcup8;6X \ No newline at end of file + estingcup4;6X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/copywin7.chk diff -u src/tests/lib/libcurses/check_files/copywin7.chk:1.3 src/tests/lib/libcurses/check_files/copywin7.chk:1.4 --- src/tests/lib/libcurses/check_files/copywin7.chk:1.3 Sun May 26 07:28:15 2019 +++ src/tests/lib/libcurses/check_files/copywin7.chk Tue Jun 22 07:49:58 2021 @@ -1,4 +1,4 @@ -el +el el el elcup11;15Xelcup12;15Xelcup13;15Xelcup14;15Xelcup15;15Xelcup17;15Xel \ No newline at end of file Index: src/tests/lib/libcurses/check_files/dupwin1.chk diff -u src/tests/lib/libcurses/check_files/dupwin1.chk:1.2 src/tests/lib/libcurses/check_files/dupwin1.chk:1.3 --- src/tests/lib/libcurses/check_files/dupwin1.chk:1.2 Tue Jun 11 08:09:36 2019 +++ src/tests/lib/libcurses/check_files/dupwin1.chk Tue Jun 22 07:49:58 2021 @@ -3,4 +3,4 @@ 33 44 55 - 66 cup9;13X11cup10;13X22cup11;13X33cup12;13X44cup13;13X55cup14;13X66cup14;13X \ No newline at end of file + 66 cup9;13X11cup10;13X22cup11;13X33cup12;13X44cup13;13X55cup14;13X66 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/dupwin2.chk diff -u src/tests/lib/libcurses/check_files/dupwin2.chk:1.2 src/tests/lib/libcurses/check_files/dupwin2.chk:1.3 --- src/tests/lib/libcurses/check_files/dupwin2.chk:1.2 Tue Jun 11 08:09:36 2019 +++ src/tests/lib/libcurses/check_files/dupwin2.chk Tue Jun 22 07:49:58 2021 @@ -1 +1 @@ -cup8;6Xcup9;13Xaacup10;13Xbbcup11;13Xcccup12;13Xddcup13;13Xeecup14;13Xffcup14;13X \ No newline at end of file +cup9;13Xaacup10;13Xbbcup11;13Xcccup12;13Xddcup13;13Xeecup14;13Xffcup14;13X \ No newline at end of file Index: src/tests/lib/libcurses/tests/addstr diff -u src/tests/lib/libcurses/tests/addstr:1.3 src/tests/lib/libcurses/tests/addstr:1.4 --- src/tests/lib/libcurses/tests/addstr:1.3 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/tests/addstr Tue Jun 22 07:49:58 2021 @@ -9,12 +9,12 @@ compare addstr.chk # Checks for PR#56224 # call OK move 23 0 -# the addstr should be truncated since no scrolling -call OK addstr
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:49:09 UTC 2021 Modified Files: src/lib/libcurses: addbytes.c Log Message: Rework the fix for lib/56224. Move the scroll check to _cursesi_addwchar Perform the scroll check before updating the cursor location when processing \n. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.56 src/lib/libcurses/addbytes.c:1.57 --- src/lib/libcurses/addbytes.c:1.56 Tue Jun 15 22:18:55 2021 +++ src/lib/libcurses/addbytes.c Tue Jun 22 07:49:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $ */ +/* $NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $"); #endif #endif/* not lint */ @@ -171,14 +171,6 @@ _cursesi_waddbytes(WINDOW *win, const ch break; } - /* if scrollok is false and we are at the bottom of - * screen and this character would take us past the - * end of the line then we are done. - */ - if ((win->curx + wcwidth(wc) >= win->maxx) && - (!(win->flags & __SCROLLOK)) && - (win->cury == win->scr_b)) - break; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n", @@ -371,16 +363,17 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *x = 0; return OK; case L'\n': - wclrtoeol(win); - *x = 0; - (*lnp)->flags &= ~__ISPASTEOL; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; +wclrtoeol(win); scroll(win); } else { +wclrtoeol(win); (*y)++; } + *x = 0; + (*lnp)->flags &= ~__ISPASTEOL; return OK; case L'\t': cc.vals[0] = L' '; @@ -395,7 +388,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** if ((*y == win->scr_b) && !(win->flags & __SCROLLOK)) { if ((*lnp)->flags & __ISPASTEOL) { - return OK; + return ERR; } if (*x + newx > win->maxx - 1) @@ -489,6 +482,12 @@ _cursesi_addwchar(WINDOW *win, __LINE ** "_cursesi_addwchar: clear EOL (%d,%d)\n", *y, *x); #endif /* DEBUG */ + if (*y == win->scr_b) { + if (!(win->flags & __SCROLLOK)) +return ERR; + scroll(win); + } + (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) @@ -505,11 +504,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); sx = *x = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) -return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = >alines[*y]->line[0]; @@ -588,16 +583,23 @@ _cursesi_addwchar(WINDOW *win, __LINE ** #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do line wrap\n"); #endif /* DEBUG */ + if (*y == win->scr_b) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: at bottom of screen\n"); +#endif /* DEBUG */ + if (!(win->flags & __SCROLLOK)) +return ERR; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do a scroll\n"); +#endif /* DEBUG */ + scroll(win); + } newx = win->maxx - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); *x = sx = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) -return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = >alines[*y]->line[0];
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:29:16 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: slk1.chk slk3.chk slk5.chk slk6.chk slk_init.chk src/tests/lib/libcurses/tests: slk Log Message: Fix slk test and check files due to libcurses slk changes. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/check_files/slk1.chk \ src/tests/lib/libcurses/check_files/slk3.chk \ src/tests/lib/libcurses/check_files/slk5.chk \ src/tests/lib/libcurses/check_files/slk6.chk \ src/tests/lib/libcurses/check_files/slk_init.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/slk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/slk1.chk diff -u src/tests/lib/libcurses/check_files/slk1.chk:1.2 src/tests/lib/libcurses/check_files/slk1.chk:1.3 --- src/tests/lib/libcurses/check_files/slk1.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk1.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!cup24;50Xrmulsgr0 \ No newline at end of file +cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!rmam!smamcup24;50Xrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk3.chk diff -u src/tests/lib/libcurses/check_files/slk3.chk:1.2 src/tests/lib/libcurses/check_files/slk3.chk:1.3 --- src/tests/lib/libcurses/check_files/slk3.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk3.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -smulrev one five eight!!rmulsgr0 \ No newline at end of file +smulrev one five eight!!rmam!smamrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk5.chk diff -u src/tests/lib/libcurses/check_files/slk5.chk:1.2 src/tests/lib/libcurses/check_files/slk5.chk:1.3 --- src/tests/lib/libcurses/check_files/slk5.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk5.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmulsgr0elcup24;18X \ No newline at end of file +cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmam!smamcup24;18Xrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk6.chk diff -u src/tests/lib/libcurses/check_files/slk6.chk:1.2 src/tests/lib/libcurses/check_files/slk6.chk:1.3 --- src/tests/lib/libcurses/check_files/slk6.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk6.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -opsetaf7Xsetab0Xsmulrev onesgr0setaf7Xsetab0X smulrev two sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X setaf1Xsetab2Xsmulrevfoursgr0setaf7Xsetab0X smulrev five sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulreveight!!rmulsgr0opsetaf7Xsetab0Xelcup24;40Xop \ No newline at end of file +opsetaf7Xsetab0Xsmulrev onesgr0setaf7Xsetab0X smulrev two sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X setaf1Xsetab2Xsmulrevfoursgr0setaf7Xsetab0X smulrev five sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulreveight!!rmam!smamcup24;40Xrmulsgr0op \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk_init.chk diff -u src/tests/lib/libcurses/check_files/slk_init.chk:1.2 src/tests/lib/libcurses/check_files/slk_init.chk:1.3 --- src/tests/lib/libcurses/check_files/slk_init.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk_init.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -enacsenacssmcupcnormclearcup24;1Xrevsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 rev sgr0elcup1;1X \ No newline at end of file +enacsenacssmcupcnormclearcup24;1Xrevsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 rev rmam smamcup1;1Xsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/tests/slk diff -u src/tests/lib/libcurses/tests/slk:1.3 src/tests/lib/libcurses/tests/slk:1.4 --- src/tests/lib/libcurses/tests/slk:1.3 Tue Jun 15 22:21:09 2021 +++ src/tests/lib/libcurses/tests/slk Tue Jun 22 07:29:16 2021 @@ -54,8 +54,7 @@ call OK slk_refresh compare slk6.chk # test slk_wset -# returning ERR now - blymn 20210606
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:26:45 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: Fix how the slk are drawn by making sure we use ins_wchar in the bottom left of the screen to avoid a scroll because this may cause an ERR if scrollok is false. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.8 src/lib/libcurses/slk.c:1.9 --- src/lib/libcurses/slk.c:1.8 Sun Jul 28 00:51:59 2019 +++ src/lib/libcurses/slk.c Tue Jun 22 07:26:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.8 2019/07/28 00:51:59 uwe Exp $ */ +/* $NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.8 2019/07/28 00:51:59 uwe Exp $"); +__RCSID("$NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $"); #endif/* not lint */ #include @@ -555,9 +555,21 @@ __slk_wset(SCREEN *screen, int labnum, c if (screen == NULL) return ERR; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: entry\n"); +#endif olabel = label; - if ((len = wcsrtombs(NULL, , 0, >sp)) == -1) + if ((len = wcsrtombs(NULL, , 0, >sp)) == -1) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: conversion failed on char 0x%x\n", + (uint16_t) *olabel); +#endif return ERR; + } + +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: wcsrtombs %ld\n", len); +#endif len++; /* We need to store the NULL character. */ if ((str = malloc(len)) == NULL) return ERR; @@ -567,6 +579,10 @@ __slk_wset(SCREEN *screen, int labnum, c result = __slk_set(screen, labnum, str, justify); out: free(str); +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: return %s\n", + (result == OK)?"OK":"ERR"); +#endif return result; } #endif /* HAVE_WCHAR */ @@ -801,19 +817,69 @@ static int __slk_draw(SCREEN *screen, int labnum) { const struct __slk_label *l; + int retval, inc, lcnt, tx; + cchar_t cc; + wchar_t wc[2]; + char ts[MB_CUR_MAX]; if (screen->slk_hidden) return OK; + retval = OK; /* quiet gcc... */ + l = >slk_labels[labnum]; if (screen->is_term_slk) return ti_putp(screen->term, ti_tiparm(screen->term, t_plab_norm(screen->term), labnum + 1, l->label)); - else if (screen->slk_window != NULL) - return mvwaddnstr(screen->slk_window, 0, l->x, - l->label, screen->slk_label_len); - else + else if (screen->slk_window != NULL) { + if ((labnum != screen->slk_nlabels - 1) || + (screen->slk_window->flags & __SCROLLOK) || + ((l->x + screen->slk_label_len) < screen->slk_window->maxx)) { + retval = mvwaddnstr(screen->slk_window, 0, l->x, + l->label, screen->slk_label_len); + } else { + lcnt = 0; + tx = 0; + while (lcnt < screen->slk_label_len) { +inc = wctomb(ts, l->label[lcnt]); +if (inc < 0) { + /* conversion failed, skip? */ + lcnt++; + continue; +} + +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_draw: last label, (%d,%d) char[%d] 0x%x\n", + l->x + tx, 0, lcnt, l->label[lcnt]); + __CTRACE(__CTRACE_INPUT, "__slk_draw: label len %d, wcwidth %d\n", + screen->slk_label_len, wcwidth(l->label[lcnt])); +#endif +wc[0] = l->label[lcnt]; +wc[1] = L'\0'; +if (setcchar(, wc, +screen->slk_window->wattr, 0, +NULL) == ERR) + return ERR; + +if (l->x + wcwidth(l->label[lcnt] + tx) >= +screen->slk_label_len) { + /* last character that will fit + * so insert it to avoid scroll + */ + retval = mvwins_wch(screen->slk_window, + 0, l->x + tx, ); +} else { + retval = mvwadd_wch(screen->slk_window, + 0, l->x + tx, ); +} +tx += wcwidth(l->label[lcnt]); +lcnt += inc; + } + } + + return retval; + } else return ERR; }
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:22:44 UTC 2021 Modified Files: src/lib/libcurses: ins_wch.c Log Message: Fix the debug output to stop spamming out the aline for row 0, we may not be working on that row so the output is pointless. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/ins_wch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ins_wch.c diff -u src/lib/libcurses/ins_wch.c:1.15 src/lib/libcurses/ins_wch.c:1.16 --- src/lib/libcurses/ins_wch.c:1.15 Mon Jul 6 22:46:50 2020 +++ src/lib/libcurses/ins_wch.c Tue Jun 22 07:22:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $ */ +/* $NetBSD: ins_wch.c,v 1.16 2021/06/22 07:22:44 blymn Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $"); +__RCSID("$NetBSD: ins_wch.c,v 1.16 2021/06/22 07:22:44 blymn Exp $"); #endif /* not lint */ #include @@ -95,19 +95,14 @@ wins_wch(WINDOW *win, const cchar_t *wch if (!wch) return OK; cw = wcwidth(wch->vals[0]); +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "wins_wch: wcwidth %d\n", cw); +#endif if (cw < 0) cw = 1; if (!cw) return wadd_wch( win, wch ); -#ifdef DEBUG - __CTRACE(__CTRACE_INPUT, "--before--\n"); - for (x = 0; x < win->maxx; x++) - __CTRACE(__CTRACE_INPUT, "wins_wch: (0,%d)=(%x,%x,%p)\n", x, - win->alines[0]->line[x].ch, - win->alines[0]->line[x].attr, - win->alines[0]->line[x].nsp); -#endif /* DEBUG */ x = win->curx; y = win->cury; #ifdef DEBUG @@ -217,17 +212,7 @@ wins_wch(WINDOW *win, const cchar_t *wch temp1->nsp = NULL; ex++, temp1++; } -#ifdef DEBUG - { - __CTRACE(__CTRACE_INPUT, "--after---\n"); - for (x = 0; x < win->maxx; x++) - __CTRACE(__CTRACE_INPUT, - "wins_wch: (0,%d)=(%x,%x,%p)\n", x, - win->alines[0]->line[x].ch, - win->alines[0]->line[x].attr, - win->alines[0]->line[x].nsp); - } -#endif /* DEBUG */ + newx = win->maxx - 1 + win->ch_off; if (newx > *lnp->lastchp) *lnp->lastchp = newx;