Re: rasops1

2021-01-07 Thread Frederic Cambus
On Thu, Dec 24, 2020 at 12:25:40AM +0100, Patrick Wildt wrote:

> > On Fri, Dec 18, 2020 at 10:33:52PM +0100, Mark Kettenis wrote:
> > 
> > > The diff below disables the optimized functions on little-endian
> > > architectures such that we always use rasops1_putchar().  This makes
> > > ssdfb(4) work with the default 8x16 font on arm64.
> > 
> > I noticed it was committed already, but it seems the following
> > directives:
> > 
> > #if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
> > 
> > Should have been:
> > 
> > #if !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
> > 
> > We want to include the optimized putchar functions only if RASOPS_SMALL
> > is not defined.
> > 
> 
> True that.  In one #endif comment he actually kept the !, but the actual
> ifs lost it.

Here is a diff to fix the issue, which includes the optimized putchar
functions only if RASOPS_SMALL is not defined.

Comments? OK?

Index: sys/dev/rasops/rasops1.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops1.c,v
retrieving revision 1.11
diff -u -p -r1.11 rasops1.c
--- sys/dev/rasops/rasops1.c21 Dec 2020 12:58:42 -  1.11
+++ sys/dev/rasops/rasops1.c7 Jan 2021 11:08:55 -
@@ -44,7 +44,7 @@ int   rasops1_copycols(void *, int, int, i
 intrasops1_erasecols(void *, int, int, int, uint32_t);
 intrasops1_do_cursor(struct rasops_info *);
 intrasops1_putchar(void *, int, int col, u_int, uint32_t);
-#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
+#if !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
 intrasops1_putchar8(void *, int, int col, u_int, uint32_t);
 intrasops1_putchar16(void *, int, int col, u_int, uint32_t);
 #endif
@@ -58,7 +58,7 @@ rasops1_init(struct rasops_info *ri)
rasops_masks_init();
 
switch (ri->ri_font->fontwidth) {
-#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
+#if !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
case 8:
ri->ri_ops.putchar = rasops1_putchar8;
break;
@@ -223,7 +223,7 @@ rasops1_putchar(void *cookie, int row, i
return 0;
 }
 
-#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
+#if !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
 /*
  * Paint a single character. This is for 8-pixel wide fonts.
  */



Re: rasops1

2020-12-23 Thread Frederic Cambus
Hi Mark,

On Fri, Dec 18, 2020 at 10:33:52PM +0100, Mark Kettenis wrote:

> The diff below disables the optimized functions on little-endian
> architectures such that we always use rasops1_putchar().  This makes
> ssdfb(4) work with the default 8x16 font on arm64.

I noticed it was committed already, but it seems the following
directives:

#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN

Should have been:

#if !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN

We want to include the optimized putchar functions only if RASOPS_SMALL
is not defined.



Document the WSDISPLAYIO_GETSCREENTYPE ioctl in wsdisplay.4

2020-09-14 Thread Frederic Cambus
Hi tech@,

Here is a diff to document the WSDISPLAYIO_GETSCREENTYPE ioctl in
wsdisplay.4.

The wsdisplay_screentype structure definition can be found in
.

Comments? OK?

Index: wsdisplay.4
===
RCS file: /cvs/src/share/man/man4/wsdisplay.4,v
retrieving revision 1.54
diff -u -p -r1.54 wsdisplay.4
--- wsdisplay.4 25 May 2019 11:02:19 -  1.54
+++ wsdisplay.4 14 Sep 2020 09:56:03 -
@@ -174,6 +174,38 @@ indicates the number of color map entrie
 and
 .Dv WSDISPLAYIO_PUTCMAP .
 This call is likely to be unavailable on text-only displays.
+.It Dv WSDISPLAYIO_GETSCREENTYPE Fa "struct wsdisplay_screentype"
+Retrieve basic information about a screen.
+The returned structure is as follows:
+.Bd -literal -offset indent
+struct wsdisplay_screentype {
+int idx;
+int nidx;
+char name[WSSCREEN_NAME_SIZE];
+int ncols, nrows;
+int fontwidth, fontheight;
+};
+.Ed
+.Pp
+The
+.Va idx
+field indicates the index of the screen.
+The
+.Va nidx
+field indicates the number of screens.
+The
+.Va name
+field contains a human readable string used to identify the screen.
+The 
+.Va ncols
+and
+.Va  nrows
+fields indicate the available number of columns and rows.
+The 
+.Va fontwidth
+and
+.Va fontheight
+fields indicate the dimensions of a character cell and are counted in pixels.
 .It Dv WSDISPLAYIO_GETCMAP Fa "struct wsdisplay_cmap"
 Retrieve the current color map from the display.
 This call needs the



Reflect recent wsfontload(8) changes in the man page

2020-08-07 Thread Frederic Cambus
Hi tech@,

We are now getting the default values for font height and width using
the WSDISPLAYIO_GETSCREENTYPE ioctl, so they always match the currently
loaded font metrics. The following diff reflects that in the man page.

As text-mode VGA compatible displays are increasingly uncommon, I took
the liberty to switch the order and to mention raster displays first.

Comments? OK?

Index: usr.sbin/wsfontload/wsfontload.8
===
RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.8,v
retrieving revision 1.20
diff -u -p -r1.20 wsfontload.8
--- usr.sbin/wsfontload/wsfontload.83 Apr 2017 18:43:41 -   1.20
+++ usr.sbin/wsfontload/wsfontload.87 Aug 2020 13:40:26 -
@@ -85,8 +85,8 @@ Default is
 .Pa /dev/ttyCcfg .
 .It Fl h Ar height
 Sets the height of a font character in pixels.
-Default is 16 for text-mode VGA compatible displays,
-and 22 for raster displays.
+Default is to match the currently loaded font height for raster displays,
+and 16 for text-mode VGA compatible displays.
 .It Fl l
 Specifies to print out a list of loaded fonts, no other
 arguments should be specified.
@@ -97,8 +97,8 @@ If none is given, the
 name is used to create one.
 .It Fl w Ar width
 Sets the width of a font character in pixels.
-Default is 8 for text-mode VGA compatible displays,
-and 12 for raster displays.
+Default is to match the currently loaded font width for raster displays,
+and 8 for text-mode VGA compatible displays.
 .El
 .Pp
 .\" Typically, the



Re: wsfontload(8): restore working default height/width values

2020-08-04 Thread Frederic Cambus
On Tue, Jul 21, 2020 at 12:44:57PM +0200, Frederic Cambus wrote:

> Currently, wsfontload(8) hardcodes the default height and width values
> for the font to be loaded as 12x22 when using framebuffer consoles, and
> as 8x16 when in text mode. The 12x22 value wasn't correct in case we
> felt back to the smaller 8x16 font for screen widths smaller than 960px,
> and isn't valid anymore since we replaced Gallant 12x22 by Spleen 12x24
> on all architectures but sparc64.
>  
> Here is a diff to get the default values for font height and width using
> the WSDISPLAYIO_GETSCREENTYPE ioctl. This ensures that they always match
> the currently loaded font metrics.
> 
> Tested on a system with a text mode console only, on efifb(4) and
> inteldrm(4) framebuffer consoles, and on Loongson with smfb(4).
> 
> Please note that this needs the diff I sent to tech@ yesterday to allow
> the WSDISPLAYIO_GETSCREENTYPE ioctl on tty*cfg.
> 
> Comments? OK?
> 
> Index: usr.sbin/wsfontload/wsfontload.c
> ===
> RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 wsfontload.c
> --- usr.sbin/wsfontload/wsfontload.c  20 Jul 2020 14:09:24 -  1.22
> +++ usr.sbin/wsfontload/wsfontload.c  21 Jul 2020 10:41:56 -
> @@ -76,6 +76,7 @@ main(int argc, char *argv[])
>  {
>   char *wsdev, *infile, *p;
>   struct wsdisplay_font f;
> + struct wsdisplay_screentype screens;
>   int c, res, wsfd, ffd, type, list, i;
>   int defwidth, defheight;
>   struct stat stat;
> @@ -178,23 +179,16 @@ main(int argc, char *argv[])
>   ffd = STDIN_FILENO;
>   }
>  
> - res = ioctl(wsfd, WSDISPLAYIO_GTYPE, );
> - if (res != 0)
> - type = WSDISPLAY_TYPE_UNKNOWN;
> -
> - switch (type) {
> - /* text-mode VGA */
> - case WSDISPLAY_TYPE_ISAVGA:
> - case WSDISPLAY_TYPE_PCIVGA:
> + memset(, 0, sizeof(screens));
> + res = ioctl(wsfd, WSDISPLAYIO_GETSCREENTYPE, );
> + if (res == 0) {
> + /* raster frame buffers */
> + defwidth = screens.fontwidth;
> + defheight = screens.fontheight;
> + } else {
> + /* text-mode VGA */
>   defwidth = 8;
>   defheight = 16;
> - break;
> - /* raster frame buffers */
> - default:
> - /* XXX ought to be computed from the frame buffer resolution */
> - defwidth = 12;
> - defheight = 22;
> - break;
>   }
>  
>   f.index = -1;

Ping. Anyone willing to look at this? Thanks!



Re: Allow the WSDISPLAYIO_GETSCREENTYPE ioctl on tty*cfg

2020-08-04 Thread Frederic Cambus
On Mon, Jul 20, 2020 at 04:36:46PM +0200, Frederic Cambus wrote:

> Here is a diff to allow the WSDISPLAYIO_GETSCREENTYPE ioctl on the
> tty*cfg device, passing it back to tty*0.
> 
> I need this to restore working defaults in wsfontload(8).
> 
> Comments? OK?
> 
> Index: sys/dev/wscons/wsdisplay.c
> ===
> RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v
> retrieving revision 1.141
> diff -u -p -r1.141 wsdisplay.c
> --- sys/dev/wscons/wsdisplay.c25 May 2020 09:55:49 -  1.141
> +++ sys/dev/wscons/wsdisplay.c20 Jul 2020 14:28:42 -
> @@ -1046,10 +1046,15 @@ wsdisplayioctl(dev_t dev, u_long cmd, ca
>  #endif
>  
>   if (ISWSDISPLAYCTL(dev)) {
> - if (cmd != WSDISPLAYIO_GTYPE)
> + switch (cmd) {
> + case WSDISPLAYIO_GTYPE:
> + case WSDISPLAYIO_GETSCREENTYPE:
> + /* pass to the first screen */
> + dev = makedev(major(dev), WSDISPLAYMINOR(unit, 0));
> + break;
> + default:
>   return (wsdisplay_cfg_ioctl(sc, cmd, data, flag, p));
> - /* pass WSDISPLAYIO_GTYPE to the first screen */
> - dev = makedev(major(dev), WSDISPLAYMINOR(unit, 0));
> + }
>   }
>  
>   if (WSDISPLAYSCREEN(dev) >= WSDISPLAY_MAXSCREEN)

Ping. Anyone willing to look at this? Thanks!



wsfontload(8): restore working default height/width values

2020-07-21 Thread Frederic Cambus
Hi tech@,

Currently, wsfontload(8) hardcodes the default height and width values
for the font to be loaded as 12x22 when using framebuffer consoles, and
as 8x16 when in text mode. The 12x22 value wasn't correct in case we
felt back to the smaller 8x16 font for screen widths smaller than 960px,
and isn't valid anymore since we replaced Gallant 12x22 by Spleen 12x24
on all architectures but sparc64.
 
Here is a diff to get the default values for font height and width using
the WSDISPLAYIO_GETSCREENTYPE ioctl. This ensures that they always match
the currently loaded font metrics.

Tested on a system with a text mode console only, on efifb(4) and
inteldrm(4) framebuffer consoles, and on Loongson with smfb(4).

Please note that this needs the diff I sent to tech@ yesterday to allow
the WSDISPLAYIO_GETSCREENTYPE ioctl on tty*cfg.

Comments? OK?

Index: usr.sbin/wsfontload/wsfontload.c
===
RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.c,v
retrieving revision 1.22
diff -u -p -r1.22 wsfontload.c
--- usr.sbin/wsfontload/wsfontload.c20 Jul 2020 14:09:24 -  1.22
+++ usr.sbin/wsfontload/wsfontload.c21 Jul 2020 10:41:56 -
@@ -76,6 +76,7 @@ main(int argc, char *argv[])
 {
char *wsdev, *infile, *p;
struct wsdisplay_font f;
+   struct wsdisplay_screentype screens;
int c, res, wsfd, ffd, type, list, i;
int defwidth, defheight;
struct stat stat;
@@ -178,23 +179,16 @@ main(int argc, char *argv[])
ffd = STDIN_FILENO;
}
 
-   res = ioctl(wsfd, WSDISPLAYIO_GTYPE, );
-   if (res != 0)
-   type = WSDISPLAY_TYPE_UNKNOWN;
-
-   switch (type) {
-   /* text-mode VGA */
-   case WSDISPLAY_TYPE_ISAVGA:
-   case WSDISPLAY_TYPE_PCIVGA:
+   memset(, 0, sizeof(screens));
+   res = ioctl(wsfd, WSDISPLAYIO_GETSCREENTYPE, );
+   if (res == 0) {
+   /* raster frame buffers */
+   defwidth = screens.fontwidth;
+   defheight = screens.fontheight;
+   } else {
+   /* text-mode VGA */
defwidth = 8;
defheight = 16;
-   break;
-   /* raster frame buffers */
-   default:
-   /* XXX ought to be computed from the frame buffer resolution */
-   defwidth = 12;
-   defheight = 22;
-   break;
}
 
f.index = -1;



Re: Use VGA text mode palette RGB values in rasops(9)

2020-07-20 Thread Frederic Cambus
On Wed, Jul 15, 2020 at 10:26:12AM -0600, Theo de Raadt wrote:
> > So here is a new iteration taking feedback into account, using the
> > #if WS_DEFAULT_BG == WSCOL_WHITE check for clarity, and also switching
> > the foreground color of printed kernel messages to light cyan to improve
> > contrast and readability.
> 
> I really dislike how two issues are being mixed into one diff.

Right. This was to allow easier testing by having only one diff to
apply, and that's why I wasn't explicitely asking for OKs.

So let's move forward with this, here is a diff addressing only the
color palette changes.

OK?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.63
diff -u -p -r1.63 rasops.c
--- sys/dev/rasops/rasops.c 11 Jul 2020 15:02:52 -  1.63
+++ sys/dev/rasops/rasops.c 15 Jul 2020 14:55:45 -
@@ -47,7 +47,8 @@
 
 /* ANSI colormap (R,G,B) */
 
-#defineNORMAL_BLACK0x00
+#if WS_DEFAULT_BG == WSCOL_WHITE
+#defineNORMAL_BLACK0x00/* Rasops palette */
 #defineNORMAL_RED  0x7f
 #defineNORMAL_GREEN0x007f00
 #defineNORMAL_BROWN0x7f7f00
@@ -64,6 +65,25 @@
 #defineHILITE_MAGENTA  0xff00ff
 #defineHILITE_CYAN 0x00
 #defineHILITE_WHITE0xff
+#else
+#defineNORMAL_BLACK0x00/* VGA text mode palette */
+#defineNORMAL_RED  0xaa
+#defineNORMAL_GREEN0x00aa00
+#defineNORMAL_BROWN0xaa5500
+#defineNORMAL_BLUE 0xaa
+#defineNORMAL_MAGENTA  0xaa00aa
+#defineNORMAL_CYAN 0x00
+#defineNORMAL_WHITE0xaa
+
+#defineHILITE_BLACK0x55
+#defineHILITE_RED  0xff
+#defineHILITE_GREEN0x55ff55
+#defineHILITE_BROWN0x55
+#defineHILITE_BLUE 0xff
+#defineHILITE_MAGENTA  0xff55ff
+#defineHILITE_CYAN 0x55
+#defineHILITE_WHITE0xff
+#endif
 
 const u_char rasops_cmap[256 * 3] = {
 #define_C(x)   ((x) & 0xff) >> 16, ((x) & 0x00ff00) >> 8, ((x) & 
0xff)



Allow the WSDISPLAYIO_GETSCREENTYPE ioctl on tty*cfg

2020-07-20 Thread Frederic Cambus
Hi tech@,

Here is a diff to allow the WSDISPLAYIO_GETSCREENTYPE ioctl on the
tty*cfg device, passing it back to tty*0.

I need this to restore working defaults in wsfontload(8).

Comments? OK?

Index: sys/dev/wscons/wsdisplay.c
===
RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v
retrieving revision 1.141
diff -u -p -r1.141 wsdisplay.c
--- sys/dev/wscons/wsdisplay.c  25 May 2020 09:55:49 -  1.141
+++ sys/dev/wscons/wsdisplay.c  20 Jul 2020 14:28:42 -
@@ -1046,10 +1046,15 @@ wsdisplayioctl(dev_t dev, u_long cmd, ca
 #endif
 
if (ISWSDISPLAYCTL(dev)) {
-   if (cmd != WSDISPLAYIO_GTYPE)
+   switch (cmd) {
+   case WSDISPLAYIO_GTYPE:
+   case WSDISPLAYIO_GETSCREENTYPE:
+   /* pass to the first screen */
+   dev = makedev(major(dev), WSDISPLAYMINOR(unit, 0));
+   break;
+   default:
return (wsdisplay_cfg_ioctl(sc, cmd, data, flag, p));
-   /* pass WSDISPLAYIO_GTYPE to the first screen */
-   dev = makedev(major(dev), WSDISPLAYMINOR(unit, 0));
+   }
}
 
if (WSDISPLAYSCREEN(dev) >= WSDISPLAY_MAXSCREEN)



Re: wsfontload(8): display number of characters in a loaded font

2020-07-20 Thread Frederic Cambus
On Fri, Jul 17, 2020 at 11:04:07AM +0100, Stuart Henderson wrote:
> Seems useful. While it's not especially likely anyone is parsing the output
> of this, just in case they are it's usually more admin-friendly to add a new
> column at the end unless there's a good reason not to.

Good point, here is a revised diff adding the new column at the end,
and the new output as follow:

 # Name Encoding  W  HChars
 0 Boldface  ibm  8 16  254
 1 Spleen 6x12   iso  6 12   96
 2 Spleen 8x16   iso  8 16  224
 3 Spleen 12x24  iso 12 24  224
 4 Spleen 16x32  iso 16 32  224
 5 Spleen 32x64  iso 32 64  224

Comments? OK?

Index: usr.sbin/wsfontload/wsfontload.c
===
RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.c,v
retrieving revision 1.21
diff -u -p -r1.21 wsfontload.c
--- usr.sbin/wsfontload/wsfontload.c28 Jun 2019 13:32:51 -  1.21
+++ usr.sbin/wsfontload/wsfontload.c20 Jul 2020 11:41:32 -
@@ -141,7 +141,8 @@ main(int argc, char *argv[])
 
if (list) {
i = 0;
-   p = " # Name Encoding  W  H";
+   p = " # Name Encoding" \
+   "  W  HChars";
do {
f.index = i;
res = ioctl(wsfd, WSDISPLAYIO_LSFONT, );
@@ -151,10 +152,11 @@ main(int argc, char *argv[])
puts(p);
p = NULL;
}
-   printf("%2d %-32s %8s %2d %2d\n",
+   printf("%2d %-32s %8s %2d %2d %8d\n",
f.index, f.name,
encodings[f.encoding].name,
-   f.fontwidth, f.fontheight);
+   f.fontwidth, f.fontheight,
+   f.numchars);
}
}
i++;



wsfontload(8): display number of characters in a loaded font

2020-07-16 Thread Frederic Cambus
Hi tech@,

Here is a diff to add a new column to wsfontload -l output, which
reports the number of characters contained in a loaded font.

It's especially useful with user loaded fonts as they can contain more
than 256 characters.

Below is the current output of wsfontload -l, without the diff:

# Name Encoding  W  H
 0 Boldface  ibm  8 16
 1 Spleen 6x12   iso  6 12
 2 Spleen 8x16   iso  8 16
 3 Spleen 12x24  iso 12 24
 4 Spleen 16x32  iso 16 32
 5 Spleen 32x64  iso 32 64

And now with the diff:

 # Name EncodingChars  W  H
 0 Boldface  ibm  254  8 16
 1 Spleen 6x12   iso   96  6 12
 2 Spleen 8x16   iso  224  8 16
 3 Spleen 12x24  iso  224 12 24
 4 Spleen 16x32  iso  224 16 32
 5 Spleen 32x64  iso  224 32 64

Comments? OK?

Index: usr.sbin/wsfontload/wsfontload.c
===
RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.c,v
retrieving revision 1.21
diff -u -p -r1.21 wsfontload.c
--- usr.sbin/wsfontload/wsfontload.c28 Jun 2019 13:32:51 -  1.21
+++ usr.sbin/wsfontload/wsfontload.c16 Jul 2020 16:11:18 -
@@ -141,7 +141,8 @@ main(int argc, char *argv[])
 
if (list) {
i = 0;
-   p = " # Name Encoding  W  H";
+   p = " # Name Encoding" \
+   "Chars  W  H";
do {
f.index = i;
res = ioctl(wsfd, WSDISPLAYIO_LSFONT, );
@@ -151,10 +152,11 @@ main(int argc, char *argv[])
puts(p);
p = NULL;
}
-   printf("%2d %-32s %8s %2d %2d\n",
+   printf("%2d %-32s %8s %8d %2d %2d\n",
f.index, f.name,
encodings[f.encoding].name,
-   f.fontwidth, f.fontheight);
+   f.numchars, f.fontwidth,
+   f.fontheight);
}
}
i++;



Merge if blocks in rasops_mapchar()

2020-07-16 Thread Frederic Cambus
Hi tech@,

Here is a diff to merge the two if blocks checking if the font in use
contains a given character in rasops_mapchar().

Comments? OK?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.63
diff -u -p -r1.63 rasops.c
--- sys/dev/rasops/rasops.c 11 Jul 2020 15:02:52 -  1.63
+++ sys/dev/rasops/rasops.c 16 Jul 2020 14:18:58 -
@@ -532,13 +532,8 @@ rasops_mapchar(void *cookie, int c, u_in
}
}
 
-
-   if (c < ri->ri_font->firstchar) {
-   *cp = '?';
-   return (0);
-   }
-
-   if (c - ri->ri_font->firstchar >= ri->ri_font->numchars) {
+   if (c < ri->ri_font->firstchar ||
+   c - ri->ri_font->firstchar >= ri->ri_font->numchars) {
*cp = '?';
return (0);
}



Re: Use VGA text mode palette RGB values in rasops(9)

2020-07-15 Thread Frederic Cambus
On Wed, Jul 08, 2020 at 12:37:11PM +1000, Jonathan Gray wrote:

> Thanks for the explanation.  The proposal makes more sense from the
> point of view of the existing colours being darker for openboot black
> on white.
> 
> #if WS_DEFAULT_BG == WSCOL_WHITE
> 
> old
> 
> #else
> 
> new
> 
> #endif
> 
> would have made that a bit more readable.

Yes, this is indeed better, thanks for the suggestion.

> It is interesting that the choice of blue comes up as being problematic
> in xterm as well when reading XTerm-col.ad
> 
> For us though it really comes down to white on black (!sparc64), black
> on white (sparc64) and white on blue for the kernel.

I understand the concern is about the contrast for printed kernel
messages.

Currently, output originating from the kernel is displayed using
WSCOL_WHITE on WSCOL_BLUE, which translates to NORMAL_WHITE on
NORMAL_BLUE, and I agree that 0xaa as foreground on a blue
background is not optimal, I think I raised the issue a few years
ago as it's what we currently get when booting in BIOS mode. But
it doesn't have to be this way, it could be changed.

> I agree with the sentiment that people should be using X and leave
> rasops/wscons as simple as possible.

I understand some developers share this position, however we do have
supported platforms (loongson being one, for example), on which X is
not realistically usable.

So here is a new iteration taking feedback into account, using the
#if WS_DEFAULT_BG == WSCOL_WHITE check for clarity, and also switching
the foreground color of printed kernel messages to light cyan to improve
contrast and readability.

Does this proposal look reasonable?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.63
diff -u -p -r1.63 rasops.c
--- sys/dev/rasops/rasops.c 11 Jul 2020 15:02:52 -  1.63
+++ sys/dev/rasops/rasops.c 15 Jul 2020 14:55:45 -
@@ -47,7 +47,8 @@
 
 /* ANSI colormap (R,G,B) */
 
-#defineNORMAL_BLACK0x00
+#if WS_DEFAULT_BG == WSCOL_WHITE
+#defineNORMAL_BLACK0x00/* Rasops palette */
 #defineNORMAL_RED  0x7f
 #defineNORMAL_GREEN0x007f00
 #defineNORMAL_BROWN0x7f7f00
@@ -64,6 +65,25 @@
 #defineHILITE_MAGENTA  0xff00ff
 #defineHILITE_CYAN 0x00
 #defineHILITE_WHITE0xff
+#else
+#defineNORMAL_BLACK0x00/* VGA text mode palette */
+#defineNORMAL_RED  0xaa
+#defineNORMAL_GREEN0x00aa00
+#defineNORMAL_BROWN0xaa5500
+#defineNORMAL_BLUE 0xaa
+#defineNORMAL_MAGENTA  0xaa00aa
+#defineNORMAL_CYAN 0x00
+#defineNORMAL_WHITE0xaa
+
+#defineHILITE_BLACK0x55
+#defineHILITE_RED  0xff
+#defineHILITE_GREEN0x55ff55
+#defineHILITE_BROWN0x55
+#defineHILITE_BLUE 0xff
+#defineHILITE_MAGENTA  0xff55ff
+#defineHILITE_CYAN 0x55
+#defineHILITE_WHITE0xff
+#endif
 
 const u_char rasops_cmap[256 * 3] = {
 #define_C(x)   ((x) & 0xff) >> 16, ((x) & 0x00ff00) >> 8, ((x) & 
0xff)
Index: sys/dev/wscons/wsemul_vt100.c
===
RCS file: /cvs/src/sys/dev/wscons/wsemul_vt100.c,v
retrieving revision 1.39
diff -u -p -r1.39 wsemul_vt100.c
--- sys/dev/wscons/wsemul_vt100.c   25 May 2020 09:55:49 -  1.39
+++ sys/dev/wscons/wsemul_vt100.c   15 Jul 2020 14:55:45 -
@@ -165,13 +165,13 @@ wsemul_vt100_cnattach(const struct wsscr
edp->cbcookie = NULL;
 
 #ifndef WS_KERNEL_FG
-#define WS_KERNEL_FG WSCOL_WHITE
+#define WS_KERNEL_FG WSCOL_CYAN
 #endif
 #ifndef WS_KERNEL_BG
 #define WS_KERNEL_BG WSCOL_BLUE
 #endif
 #ifndef WS_KERNEL_COLATTR
-#define WS_KERNEL_COLATTR 0
+#define WS_KERNEL_COLATTR WSATTR_HILIT
 #endif
 #ifndef WS_KERNEL_MONOATTR
 #define WS_KERNEL_MONOATTR 0



Re: [PATCH} Optimized rasops32 putchar

2020-07-15 Thread Frederic Cambus
On Tue, Jul 14, 2020 at 12:15:37PM +0200, Frederic Cambus wrote:

> The diff makes sense to me, I will commit it this week with some minor
> style(9) fixes for the switch statement (don't indent the case), unless
> I hear objections.

Committed, thanks again!



Re: [PATCH} Optimized rasops32 putchar

2020-07-14 Thread Frederic Cambus
On Sun, Jul 12, 2020 at 07:16:13PM +0200, Frederic Cambus wrote:
> On Fri, Jun 26, 2020 at 07:42:50AM -0700, jo...@armadilloaerospace.com wrote:
> > Optimized 32 bit character rendering with unrolled rows and pairwise
> > foreground / background pixel rendering.
> > 
> > If it weren't for the 5x8 font, I would have just assumed everything
> > was an even width and made the fallback path also pairwise.
> > 
> > In isolation, the 16x32 character case got 2x faster, but that wasn't
> > a huge real world speedup where the space rendering that was already
> > at memory bandwidth limits accounted for most of the character
> > rendering time.  However, in combination with the previous fast
> > conditional console scrolling that removes most of the space rendering,
> > it becomes significant.
> 
> On my Ryzen desktop with radeondrm, I don't see any improvements, the
> rasops_vcons_copyrows() optimizations seems to have made character
> plotting fast enough so that it's not a bottleneck anymore, which is
> definitely great.
> 
> cpu0: AMD Ryzen 7 2700 Eight-Core Processor, 3394.18 MHz, 17-08-02
> radeondrm0 at pci8 dev 0 function 0 "ATI Radeon HD 6450" rev 0x00
> radeondrm0: 1920x1080, 32bpp
> 
> On my T450 however, this diff makes cat'ing my usual test file [1] up
> to 20% faster with the default 12x24 font on the built-in 1600x900
> screen, which I think is significant enough for the diff to go in.
> 
> cpu0: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz, 2095.47 MHz, 06-3d-04
> inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 5500" rev 0x09
> drm0 at inteldrm0
> inteldrm0: 1600x900, 32bpp
> 
> On my Cubieboard2 (armv7) I didn't notice any meaningful difference,
> which I assume is to be expected on a 32-bit platform. I suppose it's
> also reasonable to assume other 32-bit platforms (i386, hppa, macppc)
> will not see any regression beyond noise level?
>  
> Anyone willing to OK this diff?
> 
> [1] https://norvig.com/big.txt

So I tested on the other 32-bit machine I have, and didn't notice any
regression on my i386 machine with inteldrm, it is actually up to 1.5%
faster.

It seems we can remove the 'q' variable and drop this assignement, as
it is not used:

q = u.q[0];

The diff makes sense to me, I will commit it this week with some minor
style(9) fixes for the switch statement (don't indent the case), unless
I hear objections.



Use CPU_IS_PRIMARY macro on alpha and mips64

2020-07-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to use the CPU_IS_PRIMARY macro on alpha and mips64.

Comments? OK?

Index: sys/arch/alpha/alpha/cpu.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/cpu.c,v
retrieving revision 1.43
diff -u -p -r1.43 cpu.c
--- sys/arch/alpha/alpha/cpu.c  29 May 2020 04:42:23 -  1.43
+++ sys/arch/alpha/alpha/cpu.c  13 Jul 2020 15:39:02 -
@@ -426,7 +426,7 @@ cpu_boot_secondary_processors(void)
ci = cpu_info[i];
if (ci == NULL || ci->ci_idle_pcb == NULL)
continue;
-   if (ci->ci_flags & CPUF_PRIMARY)
+   if (CPU_IS_PRIMARY(ci))
continue;
if ((cpus_booted & (1UL << i)) == 0)
continue;
Index: sys/arch/mips64/mips64/cpu.c
===
RCS file: /cvs/src/sys/arch/mips64/mips64/cpu.c,v
retrieving revision 1.75
diff -u -p -r1.75 cpu.c
--- sys/arch/mips64/mips64/cpu.c11 Jul 2020 15:18:08 -  1.75
+++ sys/arch/mips64/mips64/cpu.c13 Jul 2020 15:39:02 -
@@ -514,7 +514,7 @@ cpu_boot_secondary_processors(void)
CPU_INFO_FOREACH(cii, ci) {
if ((ci->ci_flags & CPUF_PRESENT) == 0)
continue;
-   if (ci->ci_flags & CPUF_PRIMARY)
+   if (CPU_IS_PRIMARY(ci))
continue;
 
ci->ci_randseed = (arc4random() & 0x7fff) + 1;



Use CPU_IS_PRIMARY macro in identifycpu() on i386

2020-07-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to use the CPU_IS_PRIMARY macro in identifycpu() on i386.

Comments? OK?

Index: sys/arch/i386/i386/machdep.c
===
RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.636
diff -u -p -r1.636 machdep.c
--- sys/arch/i386/i386/machdep.c31 May 2020 06:23:57 -  1.636
+++ sys/arch/i386/i386/machdep.c13 Jul 2020 10:17:07 -
@@ -2106,7 +2106,7 @@ identifycpu(struct cpu_info *ci)
cpu_device);
}
 
-   if (ci->ci_flags & CPUF_PRIMARY) {
+   if (CPU_IS_PRIMARY(ci)) {
if (cpu_ecxfeature & CPUIDECX_RDRAND)
has_rdrand = 1;
if (ci->ci_feature_sefflags_ebx & SEFF0EBX_RDSEED)



Re: [PATCH} Optimized rasops32 putchar

2020-07-12 Thread Frederic Cambus
On Fri, Jun 26, 2020 at 07:42:50AM -0700, jo...@armadilloaerospace.com wrote:
> Optimized 32 bit character rendering with unrolled rows and pairwise
> foreground / background pixel rendering.
> 
> If it weren't for the 5x8 font, I would have just assumed everything
> was an even width and made the fallback path also pairwise.
> 
> In isolation, the 16x32 character case got 2x faster, but that wasn't
> a huge real world speedup where the space rendering that was already
> at memory bandwidth limits accounted for most of the character
> rendering time.  However, in combination with the previous fast
> conditional console scrolling that removes most of the space rendering,
> it becomes significant.

On my Ryzen desktop with radeondrm, I don't see any improvements, the
rasops_vcons_copyrows() optimizations seems to have made character
plotting fast enough so that it's not a bottleneck anymore, which is
definitely great.

cpu0: AMD Ryzen 7 2700 Eight-Core Processor, 3394.18 MHz, 17-08-02
radeondrm0 at pci8 dev 0 function 0 "ATI Radeon HD 6450" rev 0x00
radeondrm0: 1920x1080, 32bpp

On my T450 however, this diff makes cat'ing my usual test file [1] up
to 20% faster with the default 12x24 font on the built-in 1600x900
screen, which I think is significant enough for the diff to go in.

cpu0: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz, 2095.47 MHz, 06-3d-04
inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 5500" rev 0x09
drm0 at inteldrm0
inteldrm0: 1600x900, 32bpp

On my Cubieboard2 (armv7) I didn't notice any meaningful difference,
which I assume is to be expected on a 32-bit platform. I suppose it's
also reasonable to assume other 32-bit platforms (i386, hppa, macppc)
will not see any regression beyond noise level?
 
Anyone willing to OK this diff?

[1] https://norvig.com/big.txt



Re: [PATCH] fast conditional console scrolling

2020-07-11 Thread Frederic Cambus
On Fri, Jul 10, 2020 at 03:26:16PM +0200, Frederic Cambus wrote:
> On Fri, Jun 26, 2020 at 07:49:55AM -0700, jo...@armadilloaerospace.com wrote:
> > I should have been more rigorous -- I had two different changes running
> > on my system, as well as forcing it to use the 12x24 font for a 160x45
> > console.
> > 
> > If you apply the "Optimized rasops32 putchar" patch I just posted, you
> > should see another significant speedup.
> 
> Leaving aside rasops32_putchar() optimizations for now, I tried this
> on radeondrm and simplefb (on armv7) with a 1920x1080 monitor and on
> top of what John and Paul are reporting, I'm also seeing improvements
> when cat'ing the text file [1] I usually use for rasops performance
> testing. It's up to 30% faster on both devices, which is significant.
> 
> The diff makes sense to me, and I think this should go in.
> 
> Anyone willing to OK this diff or to commit with my OK?

Committed with some minor style(9) formatting fixes pointed out by jcs@
offlist.

Thanks!



Re: [PATCH] fast conditional console scrolling

2020-07-10 Thread Frederic Cambus
On Fri, Jun 26, 2020 at 07:49:55AM -0700, jo...@armadilloaerospace.com wrote:
> I should have been more rigorous -- I had two different changes running
> on my system, as well as forcing it to use the 12x24 font for a 160x45
> console.
> 
> If you apply the "Optimized rasops32 putchar" patch I just posted, you
> should see another significant speedup.

Leaving aside rasops32_putchar() optimizations for now, I tried this
on radeondrm and simplefb (on armv7) with a 1920x1080 monitor and on
top of what John and Paul are reporting, I'm also seeing improvements
when cat'ing the text file [1] I usually use for rasops performance
testing. It's up to 30% faster on both devices, which is significant.

The diff makes sense to me, and I think this should go in.

Anyone willing to OK this diff or to commit with my OK?

[1] https://norvig.com/big.txt



Enable Spleen 16x32 and 32x64 on armv7

2020-07-08 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable spleen16x32 and spleen32x64 on armv7 for
GENERIC kernels, like on arm64.

I'm using the 16x32 version on my Cubieboard2.

I'm not sure if any armv7 devices we support is actually capable
of driving a 4K screen, so the 32x64 version might not be useful.
If this is a concern, I can send a revised diff to include only
the 16x32 version.

Comments? OK?

Index: sys/dev/wsfont/wsfont.c
===
RCS file: /cvs/src/sys/dev/wsfont/wsfont.c,v
retrieving revision 1.56
diff -u -p -r1.56 wsfont.c
--- sys/dev/wsfont/wsfont.c 11 Jul 2019 18:07:54 -  1.56
+++ sys/dev/wsfont/wsfont.c 7 Jul 2020 13:54:56 -
@@ -97,7 +97,7 @@
 #endif
 
 #if !defined(SMALL_KERNEL) && (defined(__amd64__) || defined(__i386__) || \
-defined(__arm64__))
+defined(__arm64__) || defined(__armv7__))
 #define FONT_SPLEEN16x32
 #define FONT_SPLEEN32x64
 #endif



Add "Spleen 6x12" font to wsfont

2020-07-08 Thread Frederic Cambus
Hi tech@,

I created a new size for Spleen, to bridge the gap between the 5x8 and
the 8x16 versions. The idea is to have something more readable than the
5x8 version while still being small enough to be usable on OLED displays.

Similar to "Spleen 5x8" it only contains the printable ASCII characters
(96 glyphes).

In order to enable and test the font, this option should be added to the
kernel configuration file: option FONT_SPLEEN6x12

Comments? OK?

Index: sys/dev/wsfont/wsfont.c
===
RCS file: /cvs/src/sys/dev/wsfont/wsfont.c,v
retrieving revision 1.56
diff -u -p -r1.56 wsfont.c
--- sys/dev/wsfont/wsfont.c 11 Jul 2019 18:07:54 -  1.56
+++ sys/dev/wsfont/wsfont.c 8 Jul 2020 10:16:31 -
@@ -48,6 +48,11 @@
 #include 
 #endif
 
+#ifdef FONT_SPLEEN6x12
+#define HAVE_FONT 1
+#include 
+#endif
+
 #ifdef FONT_SPLEEN8x16
 #define HAVE_FONT 1
 #endif
@@ -150,17 +155,20 @@ static struct font builtin_fonts[] = {
 #ifdef FONT_SPLEEN5x8
BUILTIN_FONT(spleen5x8, 4),
 #endif
+#ifdef FONT_SPLEEN6x12
+   BUILTIN_FONT(spleen6x12, 5),
+#endif
 #ifdef FONT_SPLEEN8x16
-   BUILTIN_FONT(spleen8x16, 5),
+   BUILTIN_FONT(spleen8x16, 6),
 #endif
 #ifdef FONT_SPLEEN12x24
-   BUILTIN_FONT(spleen12x24, 6),
+   BUILTIN_FONT(spleen12x24, 7),
 #endif
 #ifdef FONT_SPLEEN16x32
-   BUILTIN_FONT(spleen16x32, 7),
+   BUILTIN_FONT(spleen16x32, 8),
 #endif
 #ifdef FONT_SPLEEN32x64
-   BUILTIN_FONT(spleen32x64, 8),
+   BUILTIN_FONT(spleen32x64, 9),
 #endif
 #undef BUILTIN_FONT
 };
Index: sys/dev/wsfont/spleen6x12.h
===
RCS file: sys/dev/wsfont/spleen6x12.h
diff -N sys/dev/wsfont/spleen6x12.h
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/dev/wsfont/spleen6x12.h 8 Jul 2020 10:16:31 -
@@ -0,0 +1,1294 @@
+/* $OpenBSD$ */
+
+/*
+ * Copyright (c) 2018-2020 Frederic Cambus 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static u_char spleen6x12_data[];
+
+struct wsdisplay_font spleen6x12 = {
+   .name   = "Spleen 6x12",
+   .index  = 0,
+   .firstchar  = ' ',
+   .numchars   = 128 - ' ',
+   .encoding   = WSDISPLAY_FONTENC_ISO,
+   .fontwidth  = 6,
+   .fontheight = 12,
+   .stride = 1,
+   .bitorder   = WSDISPLAY_FONTORDER_L2R,
+   .byteorder  = WSDISPLAY_FONTORDER_L2R,
+   .cookie = NULL,
+   .data   = spleen6x12_data
+};
+
+static u_char spleen6x12_data[] = {
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+
+   0x00,   /*  */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x00,   /*  */
+   0x20,   /* ..*. */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+
+   0x00,   /*  */
+   0x50,   /* .*.* */
+   0x50,   /* .*.* */
+   0x50,   /* .*.* */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /* 

Re: Use VGA text mode palette RGB values in rasops(9)

2020-07-07 Thread Frederic Cambus
On Wed, Jul 08, 2020 at 12:06:27AM +1000, Jonathan Gray wrote:
> On Tue, Jul 07, 2020 at 03:16:33PM +0200, Frederic Cambus wrote:
> > Hi tech@,
> > 
> > The recent spike of interest around framebuffer consoles has prompted
> > me to revisit a proposal I sent back in early 2017 [1].
> > 
> > Aesthetics considerations aside, kettenis@ raised the concern that colors
> > from the original rasops palette carefully matched what OpenFirmware
> > uses for the console on sparc64.
> > 
> > Therefore, I propose to default on using the proper VGA text mode palette
> > RGB values, and to keep the original rasops color palette on sparc64.
> > 
> > The differences between the two palettes can be seen here [2].
> > 
> > Comments? OK?
> 
> Why is it important to match VGA colours?
> We don't try to match video modes or fonts.

In case it wasn't obvious by comparing the two palettes, the main problem
with the rasops palette it that the NORMAL_RED, NORMAL_GREEN, NORMAL_BLUE,
NORMAL_MAGENTA and NORMAL_CYAN colors are too dark.

NORMAL_BLUE is especially problematic as it's very difficult to read on
a black background.

It is used as the default color for comments in vim. It's also (I know I'm
not going to make any friends here) the color used to "highlight" (ahem)
directories in colorls.

One can test in frame buffer consoles by doing:

export TERM=wsvt25

And run either vim or colorls -G.



Use VGA text mode palette RGB values in rasops(9)

2020-07-07 Thread Frederic Cambus
Hi tech@,

The recent spike of interest around framebuffer consoles has prompted
me to revisit a proposal I sent back in early 2017 [1].

Aesthetics considerations aside, kettenis@ raised the concern that colors
from the original rasops palette carefully matched what OpenFirmware
uses for the console on sparc64.

Therefore, I propose to default on using the proper VGA text mode palette
RGB values, and to keep the original rasops color palette on sparc64.

The differences between the two palettes can be seen here [2].

Comments? OK?

[1] https://marc.info/?l=openbsd-tech=148374502927423=2
[2] 
https://www.cambus.net/openbsd-framebuffer-console-and-custom-color-palettes/

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.62
diff -u -p -r1.62 rasops.c
--- sys/dev/rasops/rasops.c 16 Jun 2020 21:49:30 -  1.62
+++ sys/dev/rasops/rasops.c 7 Jul 2020 09:10:08 -
@@ -47,7 +47,26 @@
 
 /* ANSI colormap (R,G,B) */
 
-#defineNORMAL_BLACK0x00
+#ifndef __sparc64__
+#defineNORMAL_BLACK0x00/* VGA text mode palette */
+#defineNORMAL_RED  0xaa
+#defineNORMAL_GREEN0x00aa00
+#defineNORMAL_BROWN0xaa5500
+#defineNORMAL_BLUE 0xaa
+#defineNORMAL_MAGENTA  0xaa00aa
+#defineNORMAL_CYAN 0x00
+#defineNORMAL_WHITE0xaa
+
+#defineHILITE_BLACK0x55
+#defineHILITE_RED  0xff
+#defineHILITE_GREEN0x55ff55
+#defineHILITE_BROWN0x55
+#defineHILITE_BLUE 0xff
+#defineHILITE_MAGENTA  0xff55ff
+#defineHILITE_CYAN 0x55
+#defineHILITE_WHITE0xff
+#else
+#defineNORMAL_BLACK0x00/* Rasops palette */
 #defineNORMAL_RED  0x7f
 #defineNORMAL_GREEN0x007f00
 #defineNORMAL_BROWN0x7f7f00
@@ -64,6 +83,7 @@
 #defineHILITE_MAGENTA  0xff00ff
 #defineHILITE_CYAN 0x00
 #defineHILITE_WHITE0xff
+#endif
 
 const u_char rasops_cmap[256 * 3] = {
 #define_C(x)   ((x) & 0xff) >> 16, ((x) & 0x00ff00) >> 8, ((x) & 
0xff)



Use CPU_IS_PRIMARY macro in identifycpu() on amd64

2020-07-06 Thread Frederic Cambus
Hi tech@,

While having a glance at identcpu.c to see how CPU flags were printed
for each CPU, I noticed we have the following macro in cpu.h:

#define CPU_IS_PRIMARY(ci)  ((ci)->ci_flags & CPUF_PRIMARY)

Here is a diff to use it in identifycpu() on amd64.

Comments? OK?

Index: sys/arch/amd64/amd64/identcpu.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/identcpu.c,v
retrieving revision 1.115
diff -u -p -r1.115 identcpu.c
--- sys/arch/amd64/amd64/identcpu.c 27 May 2020 05:08:53 -  1.115
+++ sys/arch/amd64/amd64/identcpu.c 6 Jul 2020 21:04:13 -
@@ -480,7 +480,7 @@ identifycpu(struct cpu_info *ci)
ci->ci_efeature_ecx, ci->ci_feature_eflags);
/* Other bits may clash */
ci->ci_feature_flags |= (ci->ci_feature_eflags & CPUID_NXE);
-   if (ci->ci_flags & CPUF_PRIMARY)
+   if (CPU_IS_PRIMARY(ci))
ecpu_ecxfeature = ci->ci_efeature_ecx;
/* Let cpu_feature be the common bits */
cpu_feature &= ci->ci_feature_flags;
@@ -515,7 +515,7 @@ identifycpu(struct cpu_info *ci)
sizeof(mycpu_model));
 
/* If primary cpu, fill in the global cpu_model used by sysctl */
-   if (ci->ci_flags & CPUF_PRIMARY)
+   if (CPU_IS_PRIMARY(ci))
strlcpy(cpu_model, mycpu_model, sizeof(cpu_model));
 
ci->ci_family = (ci->ci_signature >> 8) & 0x0f;
@@ -561,7 +561,7 @@ identifycpu(struct cpu_info *ci)
printf(", %llu.%02llu MHz", (freq + 4999) / 100,
((freq + 4999) / 1) % 100);
 
-   if (ci->ci_flags & CPUF_PRIMARY) {
+   if (CPU_IS_PRIMARY(ci)) {
cpuspeed = (freq + 4999) / 100;
cpu_cpuspeed = cpu_amd64speed;
}
@@ -689,7 +689,7 @@ identifycpu(struct cpu_info *ci)
ci->ci_dev->dv_xname);
}
 
-   if (ci->ci_flags & CPUF_PRIMARY) {
+   if (CPU_IS_PRIMARY(ci)) {
 #ifndef SMALL_KERNEL
if (!strcmp(cpu_vendor, "AuthenticAMD") &&
ci->ci_pnfeatset >= 0x8007) {
@@ -737,7 +737,7 @@ identifycpu(struct cpu_info *ci)
 #endif
 
 #ifdef CRYPTO
-   if (ci->ci_flags & CPUF_PRIMARY) {
+   if (CPU_IS_PRIMARY(ci)) {
if (cpu_ecxfeature & CPUIDECX_PCLMUL)
amd64_has_pclmul = 1;
 



C99 initializers in wsdisplay_font struct definitions

2020-06-22 Thread Frederic Cambus
Hi tech@,

Here is a diff to use C99 initializers in wsdisplay_font struct
definitions for Spleen kernel fonts.

Comments? OK?

Index: sys/dev/wsfont/spleen12x24.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen12x24.h,v
retrieving revision 1.6
diff -u -p -r1.6 spleen12x24.h
--- sys/dev/wsfont/spleen12x24.h21 Jun 2020 19:03:29 -  1.6
+++ sys/dev/wsfont/spleen12x24.h22 Jun 2020 09:44:40 -
@@ -29,18 +29,18 @@
 static u_char spleen12x24_data[];
 
 struct wsdisplay_font spleen12x24 = {
-   "Spleen 12x24", /* typeface name */
-   0,  /* index */
-   ' ',/* firstchar */
-   256 - ' ',  /* numchars */
-   WSDISPLAY_FONTENC_ISO,  /* encoding */
-   12, /* width */
-   24, /* height */
-   2,  /* stride */
-   WSDISPLAY_FONTORDER_L2R,/* bit order */
-   WSDISPLAY_FONTORDER_L2R,/* byte order */
-   NULL,   /* cookie */
-   spleen12x24_data/* data */
+   .name   = "Spleen 12x24",
+   .index  = 0,
+   .firstchar  = ' ',
+   .numchars   = 256 - ' ',
+   .encoding   = WSDISPLAY_FONTENC_ISO,
+   .fontwidth  = 12,
+   .fontheight = 24,
+   .stride = 2,
+   .bitorder   = WSDISPLAY_FONTORDER_L2R,
+   .byteorder  = WSDISPLAY_FONTORDER_L2R,
+   .cookie = NULL,
+   .data   = spleen12x24_data
 };
 
 static u_char spleen12x24_data[] = {
Index: sys/dev/wsfont/spleen16x32.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen16x32.h,v
retrieving revision 1.5
diff -u -p -r1.5 spleen16x32.h
--- sys/dev/wsfont/spleen16x32.h21 Jun 2020 19:03:29 -  1.5
+++ sys/dev/wsfont/spleen16x32.h22 Jun 2020 09:44:40 -
@@ -29,18 +29,18 @@
 static u_char spleen16x32_data[];
 
 struct wsdisplay_font spleen16x32 = {
-   "Spleen 16x32", /* typeface name */
-   0,  /* index */
-   ' ',/* firstchar */
-   256 - ' ',  /* numchars */
-   WSDISPLAY_FONTENC_ISO,  /* encoding */
-   16, /* width */
-   32, /* height */
-   2,  /* stride */
-   WSDISPLAY_FONTORDER_L2R,/* bit order */
-   WSDISPLAY_FONTORDER_L2R,/* byte order */
-   NULL,   /* cookie */
-   spleen16x32_data/* data */
+   .name   = "Spleen 16x32",
+   .index  = 0,
+   .firstchar  = ' ',
+   .numchars   = 256 - ' ',
+   .encoding   = WSDISPLAY_FONTENC_ISO,
+   .fontwidth  = 16,
+   .fontheight = 32,
+   .stride = 2,
+   .bitorder   = WSDISPLAY_FONTORDER_L2R,
+   .byteorder  = WSDISPLAY_FONTORDER_L2R,
+   .cookie = NULL,
+   .data   = spleen16x32_data
 };
 
 static u_char spleen16x32_data[] = {
Index: sys/dev/wsfont/spleen32x64.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen32x64.h,v
retrieving revision 1.6
diff -u -p -r1.6 spleen32x64.h
--- sys/dev/wsfont/spleen32x64.h21 Jun 2020 19:03:29 -  1.6
+++ sys/dev/wsfont/spleen32x64.h22 Jun 2020 09:44:41 -
@@ -29,18 +29,18 @@
 static u_char spleen32x64_data[];
 
 struct wsdisplay_font spleen32x64 = {
-   "Spleen 32x64", /* typeface name */
-   0,  /* index */
-   ' ',/* firstchar */
-   256 - ' ',  /* numchars */
-   WSDISPLAY_FONTENC_ISO,  /* encoding */
-   32, /* width */
-   64, /* height */
-   4,  /* stride */
-   WSDISPLAY_FONTORDER_L2R,/* bit order */
-   WSDISPLAY_FONTORDER_L2R,/* byte order */
-   NULL,   /* cookie */
-   spleen32x64_data/* data */
+   .name   = "Spleen 32x64",
+   .index  = 0,
+   .firstchar  = ' ',
+   .numchars   = 256 - ' ',
+   .encoding   = WSDISPLAY_FONTENC_ISO,
+   .fontwidth  = 32,
+   .fontheight = 64,
+   .stride = 4,
+   .bitorder   = WSDISPLAY_FONTORDER_L2R,
+   .byteorder  = WSDISPLAY_FONTORDER_L2R,
+   .cookie = NULL,
+   .data   = spleen32x64_data
 };
 
 static u_char spleen32x64_data[] = {
Index: sys/dev/wsfont/spleen5x8.h

Enable virtual consoles on armv7

2020-06-18 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable virtual consoles on armv7, the same way it is
done on arm64.

Also see the diff I sent earlier to sync fbtab.

Tested on a Cubieboard2.

Comments? OK?

Index: etc/etc.armv7/ttys
===
RCS file: /cvs/src/etc/etc.armv7/ttys,v
retrieving revision 1.1
diff -u -p -r1.1 ttys
--- etc/etc.armv7/ttys  4 Sep 2013 16:53:40 -   1.1
+++ etc/etc.armv7/ttys  18 Jun 2020 13:28:18 -
@@ -4,6 +4,18 @@
 # name getty   typestatus  comments
 #
 console"/usr/libexec/getty std.115200" vt220   on  secure
+ttyC0  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyC1  "/usr/libexec/getty std.9600"   vt220   on  secure
+ttyC2  "/usr/libexec/getty std.9600"   vt220   on  secure
+ttyC3  "/usr/libexec/getty std.9600"   vt220   on  secure
+ttyC4  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyC5  "/usr/libexec/getty std.9600"   vt220   on  secure
+ttyC6  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyC7  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyC8  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyC9  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyCa  "/usr/libexec/getty std.9600"   vt220   off secure
+ttyCb  "/usr/libexec/getty std.9600"   vt220   off secure
 tty00  "/usr/libexec/getty std.115200" unknown off secure
 tty01  "/usr/libexec/getty std.9600"   unknown off secure
 tty02  "/usr/libexec/getty std.9600"   unknown off
Index: sys/arch/armv7/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
retrieving revision 1.131
diff -u -p -r1.131 GENERIC
--- sys/arch/armv7/conf/GENERIC 29 Apr 2020 19:30:58 -  1.131
+++ sys/arch/armv7/conf/GENERIC 18 Jun 2020 13:28:18 -
@@ -17,9 +17,9 @@ makeoptions   KERNEL_BASE_VIRT="0xc030
 maxusers   32  # estimated number of users
 option CPU_ARMv7   # Support the ARMv7
 
-#option WSDISPLAY_COMPAT_USL   # VT handling
+option WSDISPLAY_COMPAT_USL# VT handling
 option WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
-option WSDISPLAY_DEFAULTSCREENS=1
+option WSDISPLAY_DEFAULTSCREENS=6  # initial number of text consoles
 
 option CONF_HAVE_GPIO
 option PCIVERBOSE



Sync armv7 fbtab with arm64 fbtab

2020-06-17 Thread Frederic Cambus
Hi tech@,

Here is a diff to sync armv7 fbtab with arm64 fbtab. I left out drm
devices as there aren't any on this platform.

Comments? OK?

Index: etc/etc.armv7/fbtab
===
RCS file: /cvs/src/etc/etc.armv7/fbtab,v
retrieving revision 1.1
diff -u -p -r1.1 fbtab
--- etc/etc.armv7/fbtab 4 Sep 2013 16:53:40 -   1.1
+++ etc/etc.armv7/fbtab 17 Jun 2020 21:07:00 -
@@ -1 +1,2 @@
 /dev/tty00 0600/dev/console
+/dev/ttyC0 0600
/dev/console:/dev/wskbd:/dev/wskbd0:/dev/wsmouse:/dev/wsmouse0:/dev/ttyCcfg:/dev/ttyC4



Add entry for wsfont_init.9 in man9 Makefile

2020-06-17 Thread Frederic Cambus
Hi tech@,

I commited wsfont_init.9 last year to document the wsfont module of
wscons, but apparently forgot to add an entry in the man9 Makefile.

The following diff does exactly that.

Comments? OK?

Index: share/man/man9/Makefile
===
RCS file: /cvs/src/share/man/man9/Makefile,v
retrieving revision 1.302
diff -u -p -r1.302 Makefile
--- share/man/man9/Makefile 17 Jun 2020 00:28:28 -  1.302
+++ share/man/man9/Makefile 17 Jun 2020 16:30:37 -
@@ -49,6 +49,6 @@ MAN=  aml_evalnode.9 atomic_add_int.9 ato
vfs_cache.9 vaccess.9 vclean.9 vcount.9 vdevgone.9 vfinddev.9 vflush.9 \
vflushbuf.9 vget.9 vgone.9 vhold.9 vinvalbuf.9 vnode.9 vnsubr.9 \
VOP_LOOKUP.9 vput.9 vrecycle.9 vref.9 vrele.9 \
-   vwaitforio.9 vwakeup.9 wdog_register.9
+   vwaitforio.9 vwakeup.9 wdog_register.9 wsfont_init.9
 
 .include 



Enable bwfm(4) on armv7 RAMDISK for SD/MMC and USB devices

2020-06-17 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable bwfm(4) on armv7 RAMDISK for SD/MMC and USB
devices. Discussed with patrick@.

Tested on a Cubieboard2 by building a RAMDISK kernel, which shows my
USB Wi-Fi dongle attaching when booting it.

I checked the miniroot images and they all have several megabytes of
free space:

Filesystem SizeUsed   Avail Capacity  Mounted on
/dev/vnd0a14.9M   12.0M3.0M80%/mnt

Comments? OK?

Index: arch/armv7/conf/RAMDISK
===
RCS file: /cvs/src/sys/arch/armv7/conf/RAMDISK,v
retrieving revision 1.118
diff -u -p -r1.118 RAMDISK
--- arch/armv7/conf/RAMDISK 29 Apr 2020 19:30:58 -  1.118
+++ arch/armv7/conf/RAMDISK 17 Jun 2020 10:05:23 -
@@ -126,6 +126,7 @@ pci*at pciecam?
 
 sdhc*  at fdt?
 sdmmc* at sdhc?
+bwfm*  at sdmmc?   # Broadcom FullMAC
 
 psci*  at fdt? early 1
 syscon*at fdt? early 1
@@ -272,6 +273,7 @@ rsu*at uhub?# Realtek 
RTL8188SU/RTL8
 uath*  at uhub?# Atheros AR5005UG/AR5005UX
 otus*  at uhub?# Atheros AR9001U
 athn*  at uhub?# Atheros AR9002U
+bwfm*  at uhub?# Broadcom FullMAC
 
 atphy* at mii? # Attansic F1 PHYs
 rgephy*at mii? # Realtek 8169S/8110S PHY



Re: Enable building wsmoused on arm64 and armv7

2020-05-28 Thread Frederic Cambus
On Thu, May 28, 2020 at 10:52:44AM -0600, Theo de Raadt wrote:
> -MANSUBDIR= i386 amd64 alpha
> +MANSUBDIR= i386 amd64 arm64 armv7 alpha
> 
> Actually, I suggest making this a MI man page.  Delete that line, and see
> where the files land.  I'll adjust sets.

Yes, makes sense. Just commited the change, MANSUBDIR is now gone.

The man page ends up in /usr/share/man/man8 as expected.



Enable building wsmoused on arm64 and armv7

2020-05-28 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable building wsmoused on arm64 and armv7.

Builds and works correctly on my CubieBoard2.

Comments? OK?

Index: usr.sbin/wsmoused/Makefile
===
RCS file: /cvs/src/usr.sbin/wsmoused/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- usr.sbin/wsmoused/Makefile  16 Jul 2014 20:07:03 -  1.7
+++ usr.sbin/wsmoused/Makefile  28 May 2020 16:35:14 -
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.7 2014/07/16 20:07:03 okan Exp $ 
 
-.if ${MACHINE} == "i386" || ${MACHINE} == "amd64" ||\
+.if ${MACHINE} == "i386" || ${MACHINE} == "amd64" || \
+${MACHINE} == "arm64" || ${MACHINE} == "armv7" || \
 ${MACHINE} == "alpha"
 
 PROG=  wsmoused
@@ -13,6 +14,6 @@ NOPROG=yes
 .endif
 
 MAN=   wsmoused.8 
-MANSUBDIR= i386 amd64 alpha
+MANSUBDIR= i386 amd64 arm64 armv7 alpha
 
 .include 



Enable building wsfontload on arm64 and armv7

2020-05-28 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable building wsfontload on arm64 and armv7.

Builds and works correctly on my CubieBoard2.

Comments? OK?

Index: usr.sbin/wsfontload/Makefile
===
RCS file: /cvs/src/usr.sbin/wsfontload/Makefile,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile
--- usr.sbin/wsfontload/Makefile19 Jan 2017 08:06:27 -  1.16
+++ usr.sbin/wsfontload/Makefile28 May 2020 16:34:58 -
@@ -2,6 +2,7 @@
 
 .if ${MACHINE} == "i386" || ${MACHINE} == "amd64" || \
 ${MACHINE} == "alpha" || ${MACHINE} == "hppa" || \
+${MACHINE} == "arm64" || ${MACHINE} == "armv7" || \
 ${MACHINE} == "loongson"
 
 PROG=  wsfontload



Enable scrollback in simplefb(4)

2020-05-28 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable scrollback in simplefb(4).

Tested on OpenBSD/armv7 on my CubieBoard2. The only arm64 device I own
is headless so I cannot test on this platform.

Comments? OK?

Index: sys/dev/fdt/simplefb.c
===
RCS file: /cvs/src/sys/dev/fdt/simplefb.c,v
retrieving revision 1.10
diff -u -p -r1.10 simplefb.c
--- sys/dev/fdt/simplefb.c  25 May 2020 09:55:48 -  1.10
+++ sys/dev/fdt/simplefb.c  28 May 2020 10:52:42 -
@@ -103,6 +103,7 @@ struct wsdisplay_accessops simplefb_acce
.getchar = rasops_getchar,
.load_font = rasops_load_font,
.list_font = rasops_list_font,
+   .scrollback = rasops_scrollback
 };
 
 int



Re: clear margins when remapping efifb

2020-05-28 Thread Frederic Cambus
On Wed, May 27, 2020 at 12:25:00PM +0200, Mark Kettenis wrote:
> > Date: Wed, 27 May 2020 19:39:07 +1000
> > From: Jonathan Gray 
> > 
> > When testing the row and column increase for efifb on a 1920x1080
> > display I noticed the top part of the screen continues to contain part
> > of a white on blue line from earlier in the dmesg even after the machine
> > has finished booting.
> > 
> > RI_CENTER changes the ri_bits offset, doing RI_CLEARMARGINS in cnremap
> > clears the fragment of a line caused by using RI_CENTER.
> 
> ok kettenis@

I had a different fix for this issue, which prevents the margins to
appear in the first place.

This is why the margins appear:

In rasops(9), if 'ri_emuwidth' is larger than 'ri_width', it is set to
'ri_width', and similarly for 'ri_emuheight' relative to 'ri_height'.

In efifb_cnattach_common(), we call rasops_init() with EFIFB_HEIGHT
and EFIFB_WIDTH as parameters, so on smaller screens or with larger
fonts, or when increasing the EFIFB_HEIGHT and EFIFB_WIDTH values,
'ri_emu{width,height}' becomes equals to 'ri_{width,height}' and no
centering happens.

Then in efifb_cnremap() and efifb_attach(), efifb_std_descr.nrows and
efifb_std_descr.ncols are used instead, and in this case 'ri_emuwidth'
and 'ri_emuheight' can now be a few pixels smaller than 'ri_width' and
'ri_height' and the text area is centered where it previously wasn't,
causing the content previously displayed in what are now margins to
remain there.

Here is a rebased version of the diff:

Index: sys/arch/amd64/amd64/efifb.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/efifb.c,v
retrieving revision 1.31
diff -u -p -r1.31 efifb.c
--- sys/arch/amd64/amd64/efifb.c27 May 2020 07:48:02 -  1.31
+++ sys/arch/amd64/amd64/efifb.c28 May 2020 07:17:49 -
@@ -222,7 +222,7 @@ efifb_attach(struct device *parent, stru
ri->ri_flg &= ~RI_CLEAR;
ri->ri_flg |= RI_VCONS | RI_WRONLY;
 
-   rasops_init(ri, efifb_std_descr.nrows, efifb_std_descr.ncols);
+   rasops_init(ri, EFIFB_HEIGHT, EFIFB_WIDTH);
 
ri->ri_ops.pack_attr(ri->ri_active, 0, 0, 0, );
wsdisplay_cnattach(_std_descr, ri->ri_active, ccol, crow,
@@ -480,7 +480,7 @@ efifb_cnremap(void)
ri->ri_flg &= ~RI_CLEAR;
ri->ri_flg |= RI_CENTER | RI_WRONLY;
 
-   rasops_init(ri, efifb_std_descr.nrows, efifb_std_descr.ncols);
+   rasops_init(ri, EFIFB_HEIGHT, EFIFB_WIDTH);
 
efifb_early_cleanup();
 }

Because the efifb resolution doesn't change, this ensures 'ri_emuwidth'
and 'ri_emuheight' will always get the same value when we remap and
later when we attach, so the text area is always displayed at the same
position.

I verified it still works, and it solves the issue for me on a 1920x1080
screen.

It was commited [1] and reverted [2] at the time we tried to increase
EFIFB_HEIGHT / EFIFB_WIDTH. I reverted it to be on the safe side as we
were nearing a release and it wasn't useful on its own after reverting
the other changes.

[1] 
https://cvsweb.openbsd.org/src/sys/arch/amd64/amd64/efifb.c?rev=1.20=text/x-cvsweb-markup
[2] 
https://cvsweb.openbsd.org/src/sys/arch/amd64/amd64/efifb.c?rev=1.23=text/x-cvsweb-markup



Add sizes for free() in clct(4)

2019-12-20 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in clct(4).

Similar diff to the ones previously sent for other audio drivers.

Comments? OK?

Index: sys/dev/pci/cs4281.c
===
RCS file: /cvs/src/sys/dev/pci/cs4281.c,v
retrieving revision 1.36
diff -u -p -r1.36 cs4281.c
--- sys/dev/pci/cs4281.c19 Sep 2016 06:46:44 -  1.36
+++ sys/dev/pci/cs4281.c20 Dec 2019 15:56:40 -
@@ -1187,7 +1187,7 @@ cs4281_malloc(void *addr, int direction,
error = cs4281_allocmem(sc, size, pool, flags, p);
 
if (error) {
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return (0);
}
 
@@ -1212,7 +1212,7 @@ cs4281_free(void *addr, void *ptr, int p
bus_dmamem_unmap(sc->sc_dmatag, p->addr, p->size);
bus_dmamem_free(sc->sc_dmatag, p->segs, p->nsegs);
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
}



Add sizes for free() in vio(4)

2019-12-18 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in vio(4).

There is an existing allocsize variable tracking size of allocations,
turns out we can pass it to free() in the error path.

Comments? OK?

Index: sys/dev/pv/if_vio.c
===
RCS file: /cvs/src/sys/dev/pv/if_vio.c,v
retrieving revision 1.14
diff -u -p -r1.14 if_vio.c
--- sys/dev/pv/if_vio.c 25 Oct 2019 07:13:54 -  1.14
+++ sys/dev/pv/if_vio.c 18 Dec 2019 14:13:45 -
@@ -482,7 +482,7 @@ err_reqs:
bus_dmamap_destroy(vsc->sc_dmat, sc->sc_rx_dmamaps[i]);
}
if (sc->sc_arrays) {
-   free(sc->sc_arrays, M_DEVBUF, 0);
+   free(sc->sc_arrays, M_DEVBUF, allocsize);
sc->sc_arrays = 0;
}
 err_hdr:



Add sizes for free() in eso(4)

2019-12-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in eso(4).

Similar diff to the ones previously sent for other audio drivers.

Comments? OK?

Index: sys/dev/pci/eso.c
===
RCS file: /cvs/src/sys/dev/pci/eso.c,v
retrieving revision 1.44
diff -u -p -r1.44 eso.c
--- sys/dev/pci/eso.c   11 Apr 2018 04:37:19 -  1.44
+++ sys/dev/pci/eso.c   13 Dec 2019 10:02:04 -
@@ -1519,7 +1519,7 @@ eso_allocm(void *hdl, int direction, siz
 
error = eso_allocmem(sc, size, 32, boundary, flags, direction, ed);
if (error) {
-   free(ed, type, 0);
+   free(ed, type, sizeof(*ed));
return (NULL);
}
ed->ed_next = sc->sc_dmas;
@@ -1538,7 +1538,7 @@ eso_freem(void *hdl, void *addr, int typ
if (KVADDR(p) == addr) {
eso_freemem(p);
*pp = p->ed_next;
-   free(p, type, 0);
+   free(p, type, sizeof(*p));
return;
}
}



Add sizes for free() in eap(4)

2019-12-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in eap(4).

Similar diff to the ones previously sent for other audio drivers.

Comments? OK?

Index: sys/dev/pci/eap.c
===
RCS file: /cvs/src/sys/dev/pci/eap.c,v
retrieving revision 1.56
diff -u -p -r1.56 eap.c
--- sys/dev/pci/eap.c   14 Sep 2018 08:37:34 -  1.56
+++ sys/dev/pci/eap.c   13 Dec 2019 09:36:24 -
@@ -1471,7 +1471,7 @@ eap_malloc(void *addr, int direction, si
return (0);
error = eap_allocmem(sc, size, 16, p);
if (error) {
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return (0);
}
p->next = sc->sc_dmas;
@@ -1489,7 +1489,7 @@ eap_free(void *addr, void *ptr, int pool
if (KERNADDR(p) == ptr) {
eap_freemem(sc, p);
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
}



Add sizes for free() in auixp(4)

2019-12-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in auixp(4).

Similar diff to the ones previously sent for other audio drivers.

Comments? OK?

Index: sys/dev/pci/auixp.c
===
RCS file: /cvs/src/sys/dev/pci/auixp.c,v
retrieving revision 1.40
diff -u -p -r1.40 auixp.c
--- sys/dev/pci/auixp.c 3 Sep 2018 05:37:32 -   1.40
+++ sys/dev/pci/auixp.c 13 Dec 2019 09:46:27 -
@@ -382,7 +382,7 @@ auixp_malloc(void *hdl, int direction, s
/* get us a dma buffer itself */
error = auixp_allocmem(sc, size, 16, dma);
if (error) {
-   free(dma, pool, 0);
+   free(dma, pool, sizeof(*dma));
printf("%s: auixp_malloc: not enough memory\n",
sc->sc_dev.dv_xname);
return NULL;
@@ -415,7 +415,7 @@ auixp_free(void *hdl, void *addr, int po
SLIST_REMOVE(>sc_dma_list, dma, auixp_dma,
dma_chain);
auixp_freemem(sc, dma);
-   free(dma, pool, 0);
+   free(dma, pool, sizeof(*dma));
return;
}
}
@@ -537,7 +537,7 @@ auixp_allocate_dma_chain(struct auixp_so
if (error) {
printf("%s: can't malloc dma descriptor chain\n",
sc->sc_dev.dv_xname);
-   free(dma, M_DEVBUF, 0);
+   free(dma, M_DEVBUF, sizeof(*dma));
return ENOMEM;
}
 



Add sizes for free() in auglx(4)

2019-12-12 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in auglx(4).

Similar diff to the ones commited for auvia(4) and autri(4).

Comments? OK?

Index: sys/dev/pci/auglx.c
===
RCS file: /cvs/src/sys/dev/pci/auglx.c,v
retrieving revision 1.16
diff -u -p -r1.16 auglx.c
--- sys/dev/pci/auglx.c 20 Dec 2016 15:45:29 -  1.16
+++ sys/dev/pci/auglx.c 12 Dec 2019 21:38:51 -
@@ -587,7 +587,7 @@ auglx_allocm(void *v, int direction, siz
 
error = auglx_allocmem(sc, size, PAGE_SIZE, p);
if (error) {
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return NULL;
}
 
@@ -608,7 +608,7 @@ auglx_freem(void *v, void *ptr, int pool
if (p->addr == ptr) {
auglx_freemem(sc, p);
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
}



Add sizes for free() in auacer(4)

2019-12-12 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in auacer(4).

Similar diff to the ones commited for auvia(4) and autri(4).

Comments? OK?

Index: sys/dev/pci/auacer.c
===
RCS file: /cvs/src/sys/dev/pci/auacer.c,v
retrieving revision 1.21
diff -u -p -r1.21 auacer.c
--- sys/dev/pci/auacer.c12 Dec 2016 06:43:01 -  1.21
+++ sys/dev/pci/auacer.c12 Dec 2019 21:38:59 -
@@ -603,7 +603,7 @@ auacer_allocm(void *v, int direction, si
 
error = auacer_allocmem(sc, size, PAGE_SIZE, p);
if (error) {
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return (NULL);
}
 
@@ -623,7 +623,7 @@ auacer_freem(void *v, void *ptr, int poo
if (KERNADDR(p) == ptr) {
auacer_freemem(sc, p);
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
}



Add sizes for free() in autri(4)

2019-12-03 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in autri(4).

Similar diff to the one commited for auvia(4).

Comments? OK?

Index: sys/dev/pci/autri.c
===
RCS file: /cvs/src/sys/dev/pci/autri.c,v
retrieving revision 1.42
diff -u -p -r1.42 autri.c
--- sys/dev/pci/autri.c 20 Dec 2016 15:45:29 -  1.42
+++ sys/dev/pci/autri.c 3 Dec 2019 12:45:19 -
@@ -995,7 +995,7 @@ autri_malloc(void *addr, int direction, 
 #endif
error = autri_allocmem(sc, size, 0x1, p);
if (error) {
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return NULL;
}
 
@@ -1014,7 +1014,7 @@ autri_free(void *addr, void *ptr, int po
if (KERNADDR(p) == ptr) {
autri_freemem(sc, p);
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
}



Add sizes for free() in auvia(4)

2019-11-30 Thread Frederic Cambus
Hi tech@,

Here is a diff to add sizes for free() in auvia(4).

Comments? OK?

Index: sys/dev/pci/auvia.c
===
RCS file: /cvs/src/sys/dev/pci/auvia.c,v
retrieving revision 1.59
diff -u -p -r1.59 auvia.c
--- sys/dev/pci/auvia.c 14 Sep 2018 08:37:34 -  1.59
+++ sys/dev/pci/auvia.c 30 Nov 2019 22:03:32 -
@@ -763,7 +763,7 @@ fail_create:
 fail_map:
bus_dmamem_free(sc->sc_dmat, >seg, 1);
 fail_alloc:
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return 0;
 }
 
@@ -782,7 +782,7 @@ auvia_free(void *addr, void *ptr, int po
bus_dmamem_free(sc->sc_dmat, >seg, 1);
 
*pp = p->next;
-   free(p, pool, 0);
+   free(p, pool, sizeof(*p));
return;
}
 



tsleep_nsec(9) for wsdisplay(4)

2019-10-08 Thread Frederic Cambus
Hi tech@,

Here is a diff to convert all tsleep(9) calls in wsdisplay(4)
to tsleep_nsec(9).

Comments? OK?

Index: sys/dev/wscons/wsdisplay.c
===
RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v
retrieving revision 1.133
diff -u -p -r1.133 wsdisplay.c
--- sys/dev/wscons/wsdisplay.c  1 Jul 2019 19:38:40 -   1.133
+++ sys/dev/wscons/wsdisplay.c  8 Oct 2019 14:40:56 -
@@ -1830,7 +1830,8 @@ wsdisplay_switch(struct device *dev, int
s = spltty();
 
while (sc->sc_resumescreen != WSDISPLAY_NULLSCREEN && res == 0)
-   res = tsleep(>sc_resumescreen, PCATCH, "wsrestore", 0);
+   res = tsleep_nsec(>sc_resumescreen, PCATCH, "wsrestore",
+   INFSLP);
if (res) {
splx(s);
return (res);
@@ -1980,7 +1981,7 @@ wsscreen_switchwait(struct wsdisplay_sof
if (no == WSDISPLAY_NULLSCREEN) {
s = spltty();
while (sc->sc_focus && res == 0) {
-   res = tsleep(sc, PCATCH, "wswait", 0);
+   res = tsleep_nsec(sc, PCATCH, "wswait", INFSLP);
}
splx(s);
return (res);
@@ -1995,7 +1996,7 @@ wsscreen_switchwait(struct wsdisplay_sof
s = spltty();
if (scr != sc->sc_focus) {
scr->scr_flags |= SCR_WAITACTIVE;
-   res = tsleep(scr, PCATCH, "wswait2", 0);
+   res = tsleep_nsec(scr, PCATCH, "wswait2", INFSLP);
if (scr != sc->sc_scr[no])
res = ENXIO; /* disappeared in the meantime */
else



Spleen kernel fonts improvements

2019-10-02 Thread Frederic Cambus
, 0x0f, 0xe0, 0xf0, /* ***. */
-   0x0f, 0x1f, 0xc0, 0xf0, /* ...***.. */
-   0x0f, 0x3f, 0x80, 0xf0, /* ..***... */
-   0x0f, 0x7f, 0x00, 0xf0, /* .*** */
-   0x0f, 0xfe, 0x00, 0xf0, /* ***. */
+   0x0f, 0x00, 0x7e, 0xf0, /* .**. */
+   0x0f, 0x00, 0xfc, 0xf0, /* **.. */
+   0x0f, 0x01, 0xf8, 0xf0, /* ...**... */
+   0x0f, 0x03, 0xf0, 0xf0, /* ..** */
+   0x0f, 0x07, 0xe0, 0xf0, /* .**. */
+   0x0f, 0x0f, 0xc0, 0xf0, /* **.. */
+   0x0f, 0x1f, 0x80, 0xf0, /* ...**... */
+   0x0f, 0x3f, 0x00, 0xf0, /* ..** */
+   0x0f, 0x7e, 0x00, 0xf0, /* .**. */
0x0f, 0xfc, 0x00, 0xf0, /* **.. */
0x0f, 0xf8, 0x00, 0xf0, /* *... */
0x0f, 0xf0, 0x00, 0xf0, /*  */
0x0f, 0xe0, 0x00, 0xf0, /* ***. */
0x0f, 0xc0, 0x00, 0xf0, /* **.. */
0x0f, 0x80, 0x00, 0xf0, /* *... */
+   0x0f, 0x00, 0x00, 0xf0, /*  */
0x0f, 0x00, 0x00, 0xf0, /*  */
0x0f, 0x00, 0x00, 0xf0, /*  */
0x0f, 0x00, 0x00, 0xf0, /*  */
Index: sys/dev/wsfont/spleen5x8.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen5x8.h,v
retrieving revision 1.3
diff -u -p -r1.3 spleen5x8.h
--- sys/dev/wsfont/spleen5x8.h  8 Jun 2019 07:44:07 -   1.3
+++ sys/dev/wsfont/spleen5x8.h  2 Oct 2019 20:54:25 -
@@ -1,7 +1,7 @@
 /* $OpenBSD: spleen5x8.h,v 1.3 2019/06/08 07:44:07 fcambus Exp $ */
 
 /*
- * Copyright (c) 2018 Frederic Cambus 
+ * Copyright (c) 2018-2019 Frederic Cambus 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -254,7 +254,7 @@ static u_char spleen5x8_data[] = {
0x00,   /*  */
0xf0,   /*  */
0x90,   /* *..* */
-   0x20,   /* ..*. */
+   0x10,   /* ...* */
0x20,   /* ..*. */
0x40,   /* .*.. */
0x40,   /* .*.. */



Spleen kernel fonts improvements

2019-09-04 Thread Frederic Cambus
Hi tech@,

Here is a diff to sync kernel fonts with the latest released Spleen
version, bringing the following improvements:

- Character at position CB is 'E' with diaeresis, not with tilde (12x24 version)
- Character at position D6 is 'O' with diaeresis, not with tilde (12x24 version)
- Character at position DC is 'U' with diaeresis, not with tilde (12x24 version)
- Fix middle bar thickness in the upper case 'eth' character (12x24 version)
- Fix ring alignment for the 'A' and 'a' characters (16x32 and 32x64 versions)
- Fix tilde alignment in the 'o' with tilde character (32x64 version)
- Remove strain pixel on the '3' and 'k' characters (32x64 version)

Comments? OK?

Index: sys/dev/wsfont/spleen12x24.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen12x24.h,v
retrieving revision 1.3
diff -u -p -r1.3 spleen12x24.h
--- sys/dev/wsfont/spleen12x24.h8 Jun 2019 07:44:07 -   1.3
+++ sys/dev/wsfont/spleen12x24.h3 Sep 2019 20:22:08 -
@@ -4319,9 +4319,9 @@ static u_char spleen12x24_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
 
-   0x1c, 0x60, /* ...***...**. */
-   0x3f, 0xc0, /* .... */
-   0x63, 0x80, /* .**...***... */
+   0x00, 0x00, /*  */
+   0x30, 0xc0, /* ..****.. */
+   0x30, 0xc0, /* ..****.. */
0x00, 0x00, /*  */
0x1f, 0xe0, /* .... */
0x30, 0x00, /* ..** */
@@ -4419,9 +4419,9 @@ static u_char spleen12x24_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
 
-   0x1c, 0x60, /* ...***...**. */
-   0x3f, 0xc0, /* .... */
-   0x63, 0x80, /* .**...***... */
+   0x00, 0x00, /*  */
+   0x30, 0xc0, /* ..****.. */
+   0x30, 0xc0, /* ..****.. */
0x00, 0x00, /*  */
0x3f, 0xc0, /* .... */
0x06, 0x00, /* .**. */
@@ -4456,7 +4456,7 @@ static u_char spleen12x24_data[] = {
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0xfc, 0x60, /* **...**. */
-   0xfc, 0x60, /* **...**. */
+   0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
@@ -4744,9 +4744,9 @@ static u_char spleen12x24_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
 
-   0x1c, 0x60, /* ...***...**. */
-   0x3f, 0xc0, /* .... */
-   0x63, 0x80, /* .**...***... */
+   0x00, 0x00, /*  */
+   0x30, 0xc0, /* ..****.. */
+   0x30, 0xc0, /* ..****.. */
0x00, 0x00, /*  */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
Index: sys/dev/wsfont/spleen16x32.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen16x32.h,v
retrieving revision 1.3
diff -u -p -r1.3 spleen16x32.h
--- sys/dev/wsfont/spleen16x32.h8 Jun 2019 07:44:07 -   1.3
+++ sys/dev/wsfont/spleen16x32.h3 Sep 2019 20:22:09 -
@@ -5489,12 +5489,12 @@ static u_char spleen16x32_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
 
-   0x00, 0x00, /*  */
0x01, 0x80, /* ...**... */
0x03, 0xc0, /* .... */
0x06, 0x60, /* .**..**. */
0x06, 0x60, /* .**..**. */
0x03, 0xc0, /* .... */
+   0x01, 0x80, /* ...**... */
0x0f, 0xf0, /*  */
0x1f, 0xf8, /* ...**... */
0x38, 0x1c, /* ..***..***.. */
@@ -6548,7 +6548,6 @@ static u_char spleen16x32_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
-   0x00, 0x00, /*  */
0x01, 0xc0, /* ...***.. */
0x03, 0xe0, /* ..*. */
0x06, 0x30, /* .**...** */
@@ -6556,6 +6555,7 @@ static u_char spleen16x32_data[] = {
0x06, 0x30, /* .**...** */
0x03, 0xe0, /* ..*. */
0x01, 0xc0, /* ...***.. */
+   0x00, 0x00, /*  */
0x00, 0x00, /*  */
0x1f, 0xf0, /* ...* */
0x1f, 0xf8, /* ...**... */
Index: sys/dev/wsfont/spleen32x64.h

Fix a segmentation fault in awk

2019-08-12 Thread Frederic Cambus
Hi tech@,

Here is a diff to fix a segmentation fault in awk, from upstream
version 20121220 [1]. Upstream fix didn't check for strdup return value
so I added the check.

I've been seeing some awk.core files in my home directory for a while
now, and finally decided to try investigating why it happened. It turns
out misc/mc calls awk to process file information when navigating through
ZIP files, and it sometimes causes awk to segfault.

[1] http://distcache.FreeBSD.org/ports-distfiles/nawk-20121220/awk.tar.gz

Comments? OK?

Index: usr.bin/awk/run.c
===
RCS file: /cvs/src/usr.bin/awk/run.c,v
retrieving revision 1.42
diff -u -p -r1.42 run.c
--- usr.bin/awk/run.c   9 Oct 2017 14:51:31 -   1.42
+++ usr.bin/awk/run.c   12 Aug 2019 18:01:14 -
@@ -1217,13 +1217,15 @@ Cell *dopa2(Node **a, int n)/* a[0], a[
 Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
 {
Cell *x = 0, *y, *ap;
-   char *s;
+   char *s, *origs;
int sep;
char *t, temp, num[50], *fs = 0;
int n, tempstat, arg3type;
 
y = execute(a[0]);  /* source string */
-   s = getsval(y);
+   origs = s = strdup(getsval(y));
+   if (s == NULL)
+   FATAL("out of space in split");
arg3type = ptoi(a[3]);
if (a[2] == 0)  /* fs string */
fs = *FS;
@@ -1343,6 +1345,7 @@ Cell *split(Node **a, int nnn)/* split(
}
tempfree(ap);
tempfree(y);
+   free(origs);
if (a[2] != 0 && arg3type == STRING) {
tempfree(x);
}



Spleen kernel fonts improvements

2019-06-05 Thread Frederic Cambus
Hi tech@,

Here is a diff to sync kernel fonts with the latest released Spleen
version, bringing the following improvements:

- Shift the middle bar of the upper case 'G' one pixel down in the 12x24
  version
- Shift lower case 'k' character right, for better alignment in the 12x24,
  16x32, and 32x64 versions
- Make upper case 'X' thicker in the 16x32 and 32x64 versions
- Make upper case 'V' thicker in the 32x64 version
- Make lower case 'g' character smoother in the 16x32 and 32x64 versions
- Add some artefacts on each side of the lower case 'i' characters

Comments? OK?

Index: sys/dev/wsfont/spleen12x24.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen12x24.h,v
retrieving revision 1.2
diff -u -p -r1.2 spleen12x24.h
--- sys/dev/wsfont/spleen12x24.h8 Mar 2019 10:53:59 -   1.2
+++ sys/dev/wsfont/spleen12x24.h5 Jun 2019 10:15:21 -
@@ -1029,13 +1029,13 @@ static u_char spleen12x24_data[] = {
0x60, 0x00, /* .**. */
0x60, 0x00, /* .**. */
0x60, 0x00, /* .**. */
+   0x60, 0x00, /* .**. */
0x63, 0xe0, /* .**...*. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
-   0x60, 0x60, /* .**..**. */
0x30, 0x60, /* ..**.**. */
0x1f, 0xe0, /* .... */
0x00, 0x00, /*  */
@@ -1877,6 +1877,7 @@ static u_char spleen12x24_data[] = {
0x06, 0x00, /* .**. */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
+   0x1e, 0x00, /* .... */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
@@ -1886,8 +1887,7 @@ static u_char spleen12x24_data[] = {
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
-   0x06, 0x00, /* .**. */
-   0x06, 0x00, /* .**. */
+   0x07, 0x80, /* .... */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
@@ -1923,21 +1923,21 @@ static u_char spleen12x24_data[] = {
0x00, 0x00, /*  */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
-   0x60, 0x00, /* .**. */
-   0x60, 0x00, /* .**. */
-   0x60, 0x00, /* .**. */
-   0x60, 0x00, /* .**. */
-   0x61, 0x80, /* .****... */
-   0x61, 0x80, /* .****... */
-   0x63, 0x00, /* .**...** */
-   0x66, 0x00, /* .**..**. */
-   0x7c, 0x00, /* .*.. */
-   0x6c, 0x00, /* .**.**.. */
-   0x66, 0x00, /* .**..**. */
-   0x63, 0x00, /* .**...** */
-   0x61, 0x80, /* .****... */
-   0x60, 0xc0, /* .**.**.. */
-   0x60, 0xc0, /* .**.**.. */
+   0x30, 0x00, /* ..** */
+   0x30, 0x00, /* ..** */
+   0x30, 0x00, /* ..** */
+   0x30, 0x00, /* ..** */
+   0x30, 0xc0, /* ..****.. */
+   0x30, 0xc0, /* ..****.. */
+   0x31, 0x80, /* ..**...**... */
+   0x33, 0x00, /* ..**..** */
+   0x3e, 0x00, /* ..*. */
+   0x36, 0x00, /* ..**.**. */
+   0x33, 0x00, /* ..**..** */
+   0x31, 0x80, /* ..**...**... */
+   0x30, 0xc0, /* ..****.. */
+   0x30, 0x60, /* ..**.**. */
+   0x30, 0x60, /* ..**.**. */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
@@ -5152,6 +5152,7 @@ static u_char spleen12x24_data[] = {
0x03, 0x00, /* ..** */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
+   0x1e, 0x00, /* .... */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
@@ -5161,8 +5162,7 @@ static u_char spleen12x24_data[] = {
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
0x06, 0x00, /* .**. */
-   0x06, 0x00, /* .**. */
-   0x06, 0x00, /* .**. */
+   0x07, 0x80, /* 

Re: sbin/wsconsctl: show more data

2019-03-27 Thread Frederic Cambus
On Mon, Mar 18, 2019 at 08:02:09PM +0200, Artturi Alm wrote:

> > Revised diff below iterating on what Artturi previously sent, and
> > a snippet of wsconsctl output with the diff applied:
> > 
> >  display.width=1600
> >  display.height=900
> >  display.depth=32
> > +display.fontwidth=12
> > +display.fontheight=24
> >  display.emulations=vt100
> >  display.screentypes=std
> >  display.focus=4
> > 
> > [1] https://undeadly.org/cgi?action=article=20131023125815
> > 
> > Comments? OK?
> > 
> 
> While my opinion is irrelevant, it does look good to me, thanks :]

Ping. Anyone willing to OK the revised diff?

Would be useful to have this in 6.5.



Re: sbin/wsconsctl: show more data

2019-03-18 Thread Frederic Cambus
On Mon, Jan 07, 2019 at 04:27:46PM -0700, Theo de Raadt wrote:
> Ted Unangst  wrote:
> 
> > Artturi Alm wrote:
> > > display.width=1920
> > > display.height=1200
> > > display.depth=32
> > > display.emulations=vt100
> > > display.col_x_row=120x37
> > > display.font_wxh=16x32
> > 
> > now that we've all had a chance to weigh in on the font, why are you adding
> > this weird x format? speaking of ugly... it should print columns and rows 
> > just
> > like width and height.
> 
> it is a waste of kernel and userland code since another mechanism already 
> exists
> 
> use stty -a

While I agree it doesn't make sense to add variables for showing
the number of columns and rows, as the information can be obtained
using ssty -a, displaying fontwidth and fontheight values would be
useful. This allows users to know the size of the currently loaded
font.

Thinking forward, this would also allow to easily get those values
in shell scripts, which can be leveraged if we wanted to only embed
7-bit ASCII characters in the kernel and load the full font later on,
or if someone wanted to continue the UTF-8 work [1] started by miod@.

Revised diff below iterating on what Artturi previously sent, and
a snippet of wsconsctl output with the diff applied:

 display.width=1600
 display.height=900
 display.depth=32
+display.fontwidth=12
+display.fontheight=24
 display.emulations=vt100
 display.screentypes=std
 display.focus=4

[1] https://undeadly.org/cgi?action=article=20131023125815

Comments? OK?

Index: sbin/wsconsctl/display.c
===
RCS file: /cvs/src/sbin/wsconsctl/display.c,v
retrieving revision 1.20
diff -u -p -r1.20 display.c
--- sbin/wsconsctl/display.c8 May 2015 19:12:51 -   1.20
+++ sbin/wsconsctl/display.c18 Mar 2019 17:11:59 -
@@ -41,7 +41,7 @@
 #include "wsconsctl.h"
 
 u_int dpytype;
-u_int width, height, depth;
+u_int width, height, depth, fontwidth, fontheight;
 int focus;
 struct field_pc brightness, contrast, backlight;
 int burnon, burnoff, vblank, kbdact, msact, outact;
@@ -54,6 +54,8 @@ struct field display_field_tab[] = {
 { "width", , FMT_UINT,   FLG_RDONLY },
 { "height",,FMT_UINT,   FLG_RDONLY },
 { "depth", , FMT_UINT,   FLG_RDONLY },
+{ "fontwidth", , FMT_UINT,   FLG_RDONLY },
+{ "fontheight",,FMT_UINT,   FLG_RDONLY },
 { "emulations",, FMT_EMUL,   FLG_RDONLY },
 { "screentypes",   ,   FMT_SCREEN, FLG_RDONLY },
 { "focus", , FMT_INT,FLG_NORDBACK },
@@ -84,7 +86,7 @@ display_get_values(int fd)
const char *cmd_str;
void *ptr;
unsigned long cmd;
-   int bon = 0, fbon = 0;
+   int bon = 0, fbon = 0, son = 0;
 
focus = gscr.idx = -1;
for (pf = display_field_tab; pf->name; pf++) {
@@ -102,6 +104,10 @@ display_get_values(int fd)
} else if (ptr == ) {
fillioctl(WSDISPLAYIO_GETEMULTYPE);
emuls.idx=0;
+   } else if (ptr ==  || ptr == ) {
+   fillioctl(WSDISPLAYIO_GETSCREENTYPE);
+   ptr = 
+   screens.idx = 0;
} else if (ptr == ) {
fillioctl(WSDISPLAYIO_GETSCREENTYPE);
screens.idx=0;
@@ -168,6 +174,11 @@ display_get_values(int fd)
emuls.idx=fd;
} else if (ptr == ) {
screens.idx=fd;
+   if (!son) {
+   fontwidth = screens.fontwidth;
+   fontheight = screens.fontheight;
+   }
+   son++;
} else if (ptr == ) {
struct field_pc *pc = pf->valp;
 



rasops(9): revert changes in rasops32_putchar()?

2019-03-18 Thread Frederic Cambus
Hi tech@,

Now that efifb(4) supports remapping the framebuffer in write combining
mode, it's on par with inteldrm regarding display performance as for as
rasops(9) is concerned.

Therefore, I'm proposing reverting changes which were introduced in
rasops32_putchar() in revision 1.8 [1] as they are now also slowing
things down on efifb(4).

I used a 6.3M text file for testing display performance:
ftp https://norvig.com/big.txt

The inteldrm and efifb tests were done on the same machine, the
radeondrm ones were done on another (faster) machine.

Screen size: 1920x1080
Font size: 16x32

Here are the results (3 runs each) of running: time cat big.txt

inteldrm:

2m39.52s real 0m00.00s user 2m39.52s system
2m39.74s real 0m00.00s user 2m39.84s system
2m39.74s real 0m00.00s user 2m39.77s system

inteldrm (with revert diff applied):

1m37m76s real 0m00.00s user 1m37m60s system
1m37m80s real 0m00.00s user 1m37m56s system
1m37m43s real 0m00.00s user 1m37m47s system

efifb:

2m40.46s real 0m00.00s user 2m39.43s system
2m39.49s real 0m00.00s user 2m39.52s system
2m39.45s real 0m00.00s user 2m39.48s system

efifb (with revert diff applied):

1m37m66s real 0m00.00s user 1m37m19s system
1m37m17s real 0m00.00s user 1m37m22s system
1m37m15s real 0m00.00s user 1m37m20s system

radeondrm:

4m40.75s real 0m00.00s user 4m39m75s system
4m39.84s real 0m00.00s user 4m39m85s system
4m39.68s real 0m00.00s user 4m39m71s system

radeondrm (with revert diff applied):

0m21.08s real 0m00.00s user 0m21.08s system
0m21.15s real 0m00.00s user 0m21.05s system
0m21.10s real 0m00.00s user 0m21.06s system

[1] 
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/rasops/rasops32.c.diff?r1=1.7=1.8

Comments? OK?

Index: sys/dev/rasops/rasops32.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops32.c,v
retrieving revision 1.8
diff -u -p -r1.8 rasops32.c
--- sys/dev/rasops/rasops32.c   20 Feb 2017 15:35:05 -  1.8
+++ sys/dev/rasops/rasops32.c   18 Mar 2019 08:15:18 -
@@ -69,7 +69,6 @@ rasops32_putchar(void *cookie, int row, 
struct rasops_info *ri;
int32_t *dp, *rp;
u_char *fr;
-   uint32_t buffer[64];
 
ri = (struct rasops_info *)cookie;
 
@@ -91,13 +90,12 @@ rasops32_putchar(void *cookie, int row, 
clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
 
if (uc == ' ') {
-   for (cnt = 0; cnt < width; cnt++)
-   buffer[cnt] = clr[0];
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
 
-   memcpy(dp, buffer, width << 2);
+   for (cnt = width; cnt; cnt--)
+   *dp++ = clr[0];
}
} else {
uc -= ri->ri_font->firstchar;
@@ -111,11 +109,10 @@ rasops32_putchar(void *cookie, int row, 
fr += fs;
DELTA(rp, ri->ri_stride, int32_t *);
 
-   for (cnt = 0; cnt < width; cnt++) {
-   buffer[cnt] = clr[(fb >> 31) & 1];
+   for (cnt = width; cnt; cnt--) {
+   *dp++ = clr[(fb >> 31) & 1];
fb <<= 1;
}
-   memcpy(dp, buffer, width << 2);
}
}
 



rasops(9): remove filtering in rasops_list_font_cb()

2019-03-16 Thread Frederic Cambus
Hi tech@,

Here is a diff to modify rasops_list_font_cb() to not filter out fonts
with different sizes than the currently used one. This allows getting a
list of all loaded fonts when using the WSDISPLAYIO_LSFONT ioctl.

Currently, the output of wsfontload -l on my machine is:

 # Name Encoding  W  H
 0 Spleen 12x24  iso 12 24

With the diff applied:

 # Name Encoding  W  H
 0 Spleen 8x16   iso  8 16
 1 Spleen 12x24  iso 12 24
 2 Spleen 16x32  iso 16 32
 3 Spleen 32x64  iso 32 64

On top of allowing to see all fonts which are currently loaded, it
removes the confusion as to why we reach the WSDISPLAY_MAXFONTCOUNT
limit faster than expected when loading more fonts.

It is also a first step towards allowing loading and enabling fonts
of different sizes.

Comments? OK?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.58
diff -u -p -r1.58 rasops.c
--- sys/dev/rasops/rasops.c 9 Jan 2019 11:23:32 -   1.58
+++ sys/dev/rasops/rasops.c 15 Mar 2019 22:57:43 -
@@ -1899,10 +1899,6 @@ rasops_list_font_cb(void *cbarg, struct 
 {
struct rasops_list_font_ctx *ctx = cbarg;
 
-   if (font->fontheight != ctx->ri->ri_font->fontheight ||
-   font->fontwidth != ctx->ri->ri_font->fontwidth)
-   return 0;
-
if (ctx->cnt-- == 0) {
ctx->font = font;
return 1;



efifb(4): raise maximum size to match inteldrm and radeondrm?

2019-03-15 Thread Frederic Cambus
Hi tech@,

Currently, we set the maximum size for the EFI framebuffer console to
100 columns and 31 rows.

Now that efifb(4) supports remapping the framebuffer in write combining
mode, it's now fast enough to consider increasing those values to 160
columns and 160 rows, to match the values in inteldrm and radeondrm.

Comments? OK?

Index: sys/arch/amd64/amd64/efifb.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/efifb.c,v
retrieving revision 1.20
diff -u -p -r1.20 efifb.c
--- sys/arch/amd64/amd64/efifb.c15 Mar 2019 10:38:14 -  1.20
+++ sys/arch/amd64/amd64/efifb.c15 Mar 2019 14:52:11 -
@@ -114,8 +114,8 @@ const struct cfattach efifb_ca = {
sizeof(struct efifb_softc), efifb_match, efifb_attach, NULL
 };
 
-#defineEFIFB_WIDTH 100
-#defineEFIFB_HEIGHT31
+#defineEFIFB_WIDTH 160
+#defineEFIFB_HEIGHT160
 
 struct wsscreen_descr efifb_std_descr = { "std" };
 



Update openchrome to 0.6.182 in Xenocara

2019-03-12 Thread Frederic Cambus
Hi tech@,

Here is a diff to update openchrome to 0.6.182 in Xenocara.

Tested on my VX900 system.

Comments? OK?

Index: driver/xf86-video-openchrome/Makefile.in
===
RCS file: /cvs/xenocara/driver/xf86-video-openchrome/Makefile.in,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile.in
--- driver/xf86-video-openchrome/Makefile.in9 Dec 2018 21:07:33 -   
1.10
+++ driver/xf86-video-openchrome/Makefile.in11 Mar 2019 22:46:14 -
@@ -73,7 +73,7 @@ subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING ChangeLog NEWS config.guess \
-   config.sub install-sh ltmain.sh missing
+   config.sub depcomp install-sh ltmain.sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
Index: driver/xf86-video-openchrome/aclocal.m4
===
RCS file: /cvs/xenocara/driver/xf86-video-openchrome/aclocal.m4,v
retrieving revision 1.9
diff -u -p -r1.9 aclocal.m4
--- driver/xf86-video-openchrome/aclocal.m4 9 Dec 2018 21:07:33 -   
1.9
+++ driver/xf86-video-openchrome/aclocal.m4 11 Mar 2019 22:46:14 -
@@ -8606,32 +8606,63 @@ m4_ifndef([_LT_PROG_F77],   [AC_DEFUN([_L
 m4_ifndef([_LT_PROG_FC],   [AC_DEFUN([_LT_PROG_FC])])
 m4_ifndef([_LT_PROG_CXX],  [AC_DEFUN([_LT_PROG_CXX])])
 
-# pkg.m4 - Macros to locate and utilise pkg-config.-*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-# 
-# Copyright © 2004 Scott James Remnant .
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# --
+dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+dnl serial 11 (pkg-config-0.29.1)
+dnl
+dnl Copyright © 2004 Scott James Remnant .
+dnl Copyright © 2012-2015 Dan Nicholson 
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl ---
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running 
autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+[m4_fatal([pkg.m4 version $1 or higher is required but 
]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl --
+dnl 

Spleen kernel fonts improvements

2019-03-07 Thread Frederic Cambus
Hi tech@,

Here is a diff to sync kernel fonts with the latest released Spleen
version, bringing the following improvements:

- Remove strain pixels on the inner upper part of parentheses for the
  16x32 version
- Harmonize the 'v' and 'V' characters across all sizes
- Remove artefacts from the 'c' in the copyright sign across all sizes
- Make the upper left corner of the 'R' sharp in the registered sign
  for the 16x32 and 32x64 versions

Comments? OK?

Index: sys/dev/wsfont/spleen12x24.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen12x24.h,v
retrieving revision 1.1
diff -u -p -r1.1 spleen12x24.h
--- sys/dev/wsfont/spleen12x24.h2 Dec 2018 14:44:33 -   1.1
+++ sys/dev/wsfont/spleen12x24.h7 Mar 2019 14:13:19 -
@@ -1,7 +1,7 @@
 /* $OpenBSD: spleen12x24.h,v 1.1 2018/12/02 14:44:33 fcambus Exp $ */
 
 /*
- * Copyright (c) 2018 Frederic Cambus 
+ * Copyright (c) 2018-2019 Frederic Cambus 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1408,10 +1408,10 @@ static u_char spleen12x24_data[] = {
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
-   0x30, 0xe0, /* ..*****. */
+   0x30, 0xc0, /* ..****.. */
0x30, 0xc0, /* ..****.. */
0x19, 0x80, /* ...**..**... */
-   0x0f, 0x80, /* *... */
+   0x0f, 0x00, /*  */
0x06, 0x00, /* .**. */
0x00, 0x00, /*  */
0x00, 0x00, /*  */
@@ -2208,7 +2208,7 @@ static u_char spleen12x24_data[] = {
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
0x60, 0x60, /* .**..**. */
-   0x30, 0xe0, /* ..*****. */
+   0x30, 0xc0, /* ..****.. */
0x30, 0xc0, /* ..****.. */
0x19, 0x80, /* ...**..**... */
0x0f, 0x00, /*  */
@@ -3480,7 +3480,7 @@ static u_char spleen12x24_data[] = {
0x30, 0xc0, /* ..****.. */
0x60, 0x60, /* .**..**. */
0x67, 0x60, /* .**..***.**. */
-   0x6d, 0x60, /* .**.**.*.**. */
+   0x6c, 0x60, /* .**.**...**. */
0x6c, 0x60, /* .**.**...**. */
0x6c, 0x60, /* .**.**...**. */
0x6c, 0x60, /* .**.**...**. */
Index: sys/dev/wsfont/spleen16x32.h
===
RCS file: /cvs/src/sys/dev/wsfont/spleen16x32.h,v
retrieving revision 1.1
diff -u -p -r1.1 spleen16x32.h
--- sys/dev/wsfont/spleen16x32.h2 Dec 2018 14:44:33 -   1.1
+++ sys/dev/wsfont/spleen16x32.h7 Mar 2019 14:13:19 -
@@ -1,7 +1,7 @@
 /* $OpenBSD: spleen16x32.h,v 1.1 2018/12/02 14:44:33 fcambus Exp $ */
 
 /*
- * Copyright (c) 2018 Frederic Cambus 
+ * Copyright (c) 2018-2019 Frederic Cambus 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -316,7 +316,7 @@ static u_char spleen16x32_data[] = {
0x01, 0xe0, /* .... */
0x03, 0x80, /* ..***... */
0x07, 0x00, /* .*** */
-   0x07, 0x00, /* .*** */
+   0x06, 0x00, /* .**. */
0x0e, 0x00, /* ***. */
0x0c, 0x00, /* **.. */
0x1c, 0x00, /* ...***.. */
@@ -349,7 +349,7 @@ static u_char spleen16x32_data[] = {
0x07, 0x80, /* .... */
0x01, 0xc0, /* ...***.. */
0x00, 0xe0, /* ***. */
-   0x00, 0xe0, /* ***. */
+   0x00, 0x60, /* .**. */
0x00, 0x70, /* .*** */
0x00, 0x30, /* ..** */
0x00, 0x38, /* ..***... */
@@ -1846,7 +1846,7 @@ static u_char spleen16x32_data[] = {
0x30, 0x0c, /* ..****.. */
0x30, 0x0c, /* ..****.. */
0x30, 0x0c, /* ..****.. */
-   0x18, 0x18, /* ...**..**... */
+   0x38, 0x1c, /* ..***..***.. */
0x1c, 0x38, /* ...******... */
0x0e, 0x70, /* ***..*** */
0x07, 0xe0, /* .**. */
@@ -4581,7 +4581,7 @@ static u_char spleen16x32_data[] = {
0x30, 0x0c, /* ..****.. */
0x33, 0xec, /* ..**..*.**.. */
0x37, 0xec, /* ..**.**.**.. */
-   0x36, 0x6c, /* ..**.**..**.**.. */
+   0x36, 0x0c, /* ..**.**.**.. */
0x36, 0x0c, /* ..**.**.**.. */
0x36, 0x0c, /* ..**.**.**.. */
0x36, 0x0c, /* ..**.**.**.. */
@@ -4742,7 +4742,7 @@ static u_char

Re: bktr(4): remove useless assignment

2018-11-18 Thread Frederic Cambus
On Sat, Nov 17, 2018 at 04:36:49PM -0700, Theo de Raadt wrote:
> Why not delete the 2nd line?
> 
> I mean isn't it obvious?  I'd expect some archeology to figure
> out how this bug got introduced, rather than a diff which you
> obviously don't know the result of.

Fair enough, I realize it indeed looks that way if I don't mention
anything.

Before sending the diff I found out that both assignements are in our
tree since the driver got imported from FreeBSD in 2001 and remained
untouched since r1.1. I then checked the actual state of yuvpack_prog()
in FreeBSD and only the second assignment remains.

The second assignment in its current form got introduced in FreeBSD in
1997 with r29233 [1], when syncinc the driver. The first assignment got
removed in 2017 with r314147 [2].

[1]: https://svnweb.freebsd.org/base?view=revision=29233
[2]: https://svnweb.freebsd.org/base?view=revision=314147



bktr(4): remove useless assignment

2018-11-17 Thread Frederic Cambus
Hi tech@,

Remove useless assignment, value is overwritten right after being set.

Coverity CID 1453008.

Comments? OK?

Index: dev/pci/bktr/bktr_core.c
===
RCS file: /cvs/src/sys/dev/pci/bktr/bktr_core.c,v
retrieving revision 1.39
diff -u -p -r1.39 bktr_core.c
--- dev/pci/bktr/bktr_core.c28 Apr 2018 15:44:59 -  1.39
+++ dev/pci/bktr/bktr_core.c17 Nov 2018 21:24:29 -
@@ -2864,7 +2864,6 @@ yuvpack_prog( bktr_ptr_t bktr, char i_fl
OUTB(bktr, BKTR_COLOR_CTL, INB(bktr, BKTR_COLOR_CTL) | 
BT848_COLOR_CTL_RGB_DED | BT848_COLOR_CTL_GAMMA);
OUTB(bktr, BKTR_ADC, SYNC_LEVEL);
 
-   bktr->capcontrol =   1 << 6 | 1 << 4 | 1 << 2 | 3;
bktr->capcontrol = 3 << 2 |  3;
 
dma_prog = (u_int *) bktr->dma_prog;



Add wsfont.9, documenting the wsfont subsystem

2018-11-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to add wsfont.9, documenting the wsfont subsystem.

This is wsfont.9 revision 1.18 from NetBSD with the following changes:

- Add $Mdocdate$ marker
- Remove documentation for wsfont_matches() which we don't have
- Remove wsfont_find() arguments which we don't have
- Add missing arguments for wsfont_lock() which NetBSD doesn't have
- Modify wsfont_enum() signature to match our implementation
- Modify the wsdisplay_font structure to add the index and cookie members
  which NetBSD doesn't have
- Removed some macros for font encoding we do not support anymore
- Removed and corrected stuff which doesn't apply to us because
  the codebases have diverged

Comments? OK?

Index: share/man/man9/wsfont.9
===
RCS file: share/man/man9/wsfont.9
diff -N share/man/man9/wsfont.9
--- /dev/null   1 Jan 1970 00:00:00 -
+++ share/man/man9/wsfont.9 13 Nov 2018 21:57:35 -
@@ -0,0 +1,191 @@
+.\"$OpenBSD$
+.\" $NetBSD: wsfont.9,v 1.18 2012/01/13 23:09:51 wiz Exp $
+.\"
+.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd $Mdocdate$
+.Dt WSFONT 9
+.Os
+.Sh NAME
+.Nm wsfont ,
+.Nm wsfont_init ,
+.Nm wsfont_find ,
+.Nm wsfont_add ,
+.Nm wsfont_remove ,
+.Nm wsfont_enum ,
+.Nm wsfont_lock ,
+.Nm wsfont_unlock ,
+.Nm wsfont_map_unichar
+.Nd wscons font support
+.Sh SYNOPSIS
+.In dev/wscons/wsconsio.h
+.In dev/wsfont/wsfont.h
+.Ft void
+.Fn wsfont_init "void"
+.Ft int
+.Fn wsfont_find "const char *name" "int width" "int height" "int stride"
+.Ft int
+.Fn wsfont_add "struct wsdisplay_font *font" "int copy"
+.Ft int
+.Fn wsfont_remove "int cookie"
+.Ft void
+.Fn wsfont_enum "int (*cb)(void *, struct wsdisplay_font *)" "void *cbarg"
+.Ft int
+.Fn wsfont_lock "int cookie" "struct wsdisplay_font **ptr" "int bitorder" \
+"int byteorder"
+.Ft int
+.Fn wsfont_unlock "int cookie"
+.Ft int
+.Fn wsfont_map_unichar "struct wsdisplay_font *font" "int c"
+.Sh DESCRIPTION
+The
+.Nm
+module is a component of the wscons
+.\" .Xr wscons 9
+framework to provide access to display fonts.
+Fonts may be loaded dynamically into the kernel or included statically
+in the kernel at compile time.
+Display drivers which emulate a glass-tty console on a bit-mapped
+display can add, remove and find fonts for use by device-dependent
+blitter operations.
+.Pp
+The primary data type for manipulating fonts is the
+.Em wsdisplay_font
+structure in
+.Pa dev/wscons/wsconsio.h :
+.Bd -literal
+struct wsdisplay_font {
+   char name[WSFONT_NAME_SIZE];/* font name */
+   int index;
+   int firstchar;
+   int numchars;   /* size of font table */
+   int encoding;   /* font encoding */
+   u_int fontwidth;/* character width */
+   u_int fontheight;   /* character height */
+   u_int stride;
+   int bitorder;
+   int byteorder;
+   void *cookie;
+   void *data; /* pointer to font table */
+};
+.Ed
+.Pp
+The maximum font table size is
+.Em WSDISPLAY_MAXFONTSZ .
+.Pp
+The
+.Nm
+framework supports fonts with the following encodings:
+.Bl -tag -width compact
+.It Dv WSDISPLAY_FONTENC_ISO
+ISO-encoded fonts.
+.It Dv WSDISPLAY_FONTENC_IBM
+IBM-encoded fonts commonly available for IBM CGA, EGA and VGA display
+adapters.
+.El
+.Sh FUNCTIONS
+.Bl -tag -width compact
+.It Fn wsfont_init "void"
+Initialise the font list with the built-in fonts.
+.It Fn wsfont_find "name" "width" "height" 

Re: pcidevs update for VIA HD Audio device

2018-11-11 Thread Frederic Cambus
On Sun, Nov 11, 2018 at 07:54:12PM +0100, Frederic Cambus wrote:

> > Add ID for a VIA HD Audio device found on my HP t5570 Thin Client.
> > 
> > While there, update URL for the vendor ID search engine.
> > 
> > Comments? OK?
> 
> Anyone willing to OK this? Thanks!

Please disregard previous mail.

It was already OK'ed, daniel@ was kind enough to point me to the mail I
missed. Sorry for the noise.



Re: pcidevs update for VIA HD Audio device

2018-11-11 Thread Frederic Cambus
On Thu, Nov 01, 2018 at 11:07:20PM +0100, Frederic Cambus wrote:

> Add ID for a VIA HD Audio device found on my HP t5570 Thin Client.
> 
> While there, update URL for the vendor ID search engine.
> 
> Comments? OK?

Anyone willing to OK this? Thanks!



pcidevs update for VIA HD Audio device

2018-11-01 Thread Frederic Cambus
Hi tech@,

Add ID for a VIA HD Audio device found on my HP t5570 Thin Client.

While there, update URL for the vendor ID search engine.

Comments? OK?

Index: sys/dev/pci/pcidevs
===
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1865
diff -u -p -r1.1865 pcidevs
--- sys/dev/pci/pcidevs 26 Oct 2018 05:53:58 -  1.1865
+++ sys/dev/pci/pcidevs 31 Oct 2018 17:43:06 -
@@ -39,7 +39,7 @@ $OpenBSD: pcidevs,v 1.1865 2018/10/26 05
  *
  * There is a Vendor ID search engine available at:
  *
- * http://www.pcisig.com/membership/vid_search/
+ * https://pcisig.com/membership/member-companies
  */
 
 /*
@@ -7623,7 +7623,7 @@ product VIATECH PM800_DRAM0x3259  PM800 
 product VIATECH KT880_30x3269  KT880 Host
 product VIATECH K8HTB_30x3282  K8HTB Host
 product VIATECH VT8251_ISA 0x3287  VT8251 ISA
-product VIATECH HDA0x3288  HD Audio
+product VIATECH HDA_0  0x3288  HD Audio
 product VIATECH CX700_40x3324  CX700 Host
 product VIATECH P4M890_3   0x3327  P4M890 Host
 product VIATECH K8M890_3   0x3336  K8M890 Host
@@ -7706,6 +7706,7 @@ product VIATECH VT82C598AGP   0x8598  VT82C
 product VIATECH VT82C601   0x8601  VT82C601 AGP
 product VIATECH VT8605_AGP 0x8605  VT8605 AGP
 product VIATECH VX900_IDE  0x9001  VX900 IDE
+product VIATECH HDA_1  0x9170  HD Audio
 product VIATECH VX800_SDMMC0x9530  VX800 SD/MMC
 product VIATECH VX800_SDIO 0x95d0  VX800 SDIO
 product VIATECH K8T890_PPB_A   0xa238  K8T890



wdc(4): remove unnecessary if/else block

2018-11-01 Thread Frederic Cambus
Hi tech@,

Remove unnecessary if/else block, both branches are identical. We can
in fact use the ATA_DELAY macro directly.

Coverity CID 1453008.

Comments? OK?

Index: dev/ata/ata_wdc.c
===
RCS file: /cvs/src/sys/dev/ata/ata_wdc.c,v
retrieving revision 1.51
diff -u -p -r1.51 ata_wdc.c
--- dev/ata/ata_wdc.c   30 Dec 2017 20:46:59 -  1.51
+++ dev/ata/ata_wdc.c   1 Nov 2018 12:34:17 -
@@ -240,7 +240,6 @@ _wdc_ata_bio_start(struct channel_softc 
u_int16_t cyl;
u_int8_t head, sect, cmd = 0;
int nblks;
-   int ata_delay;
int error, dma_flags = 0;
 
WDCDEBUG_PRINT(("_wdc_ata_bio_start %s:%d:%d\n",
@@ -283,10 +282,6 @@ _wdc_ata_bio_start(struct channel_softc 
if (ata_bio->flags & ATA_LBA48)
dma_flags |= WDC_DMA_LBA48;
}
-   if (ata_bio->flags & ATA_SINGLE)
-   ata_delay = ATA_DELAY;
-   else
-   ata_delay = ATA_DELAY;
 again:
/*
 *
@@ -345,7 +340,7 @@ again:
}
/* Initiate command */
wdc_set_drive(chp, xfer->drive);
-   if (wait_for_ready(chp, ata_delay) < 0)
+   if (wait_for_ready(chp, ATA_DELAY) < 0)
goto timeout;
 
/* start the DMA channel (before) */
@@ -391,7 +386,7 @@ again:
}
/* Initiate command! */
wdc_set_drive(chp, xfer->drive);
-   if (wait_for_ready(chp, ata_delay) < 0)
+   if (wait_for_ready(chp, ATA_DELAY) < 0)
goto timeout;
if (ata_bio->flags & ATA_LBA48) {
wdccommandext(chp, xfer->drive, cmd,
@@ -410,7 +405,7 @@ again:
}
/* If this was a write and not using DMA, push the data. */
if ((ata_bio->flags & ATA_READ) == 0) {
-   if (wait_for_drq(chp, ata_delay) != 0) {
+   if (wait_for_drq(chp, ATA_DELAY) != 0) {
printf("%s:%d:%d: timeout waiting for DRQ, "
"st=0x%b, err=0x%02x\n",
chp->wdc->sc_dev.dv_xname, chp->channel,



Add "Spleen 5x8" font to wsfont

2018-09-20 Thread Frederic Cambus
Hi tech@,

Here is a diff to add "Spleen 5x8" to wsfont, a font targetted at small
OLED displays to be used with devices handled by ssdfb(4). It contains
all printable ASCII characters (96 glyphes).

The font is 2-Clause BSD licensed and is my original creation.

In order to enable and test the font, this option should be added to the
kernel configuration file: option FONT_SPLEEN5x8

Screenshot: https://www.cambus.net/files/openbsd/dmesg-spleen5x8.png

Comments? OK?

Index: sys/dev/wsfont/wsfont.c
===
RCS file: /cvs/src/sys/dev/wsfont/wsfont.c,v
retrieving revision 1.52
diff -u -p -r1.52 wsfont.c
--- sys/dev/wsfont/wsfont.c 8 Sep 2017 05:36:53 -   1.52
+++ sys/dev/wsfont/wsfont.c 20 Sep 2018 18:52:29 -
@@ -43,6 +43,11 @@
 
 #undef HAVE_FONT
 
+#ifdef FONT_SPLEEN5x8
+#define HAVE_FONT 1
+#include 
+#endif
+
 #ifdef FONT_BOLD8x16
 #define HAVE_FONT 1
 #include 
@@ -105,6 +110,9 @@ static struct font builtin_fonts[] = {
 #endif
 #ifdef FONT_GALLANT12x22
BUILTIN_FONT(gallant12x22, 3),
+#endif
+#ifdef FONT_SPLEEN5x8
+   BUILTIN_FONT(spleen5x8, 4),
 #endif
 #undef BUILTIN_FONT
 };
Index: sys/dev/wsfont/spleen5x8.h
===
RCS file: sys/dev/wsfont/spleen5x8.h
diff -N sys/dev/wsfont/spleen5x8.h
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sys/dev/wsfont/spleen5x8.h  20 Sep 2018 18:52:29 -
@@ -0,0 +1,910 @@
+/* $OpenBSD$ */
+
+/*
+ * Copyright (c) 2018 Frederic Cambus 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static u_char spleen5x8_data[];
+
+struct wsdisplay_font spleen5x8 = {
+   "Spleen 5x8",   /* typeface name */
+   0,  /* index */
+   ' ',/* firstchar */
+   128 - ' ',  /* numchars */
+   WSDISPLAY_FONTENC_ISO,  /* encoding */
+   5,  /* width */
+   8,  /* height */
+   1,  /* stride */
+   WSDISPLAY_FONTORDER_L2R,/* bit order */
+   WSDISPLAY_FONTORDER_L2R,/* byte order */
+   NULL,   /* cookie */
+   spleen5x8_data  /* data */
+};
+
+static u_char spleen5x8_data[] = {
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x20,   /* ..*. */
+   0x00,   /*  */
+   0x20,   /* ..*. */
+   0x00,   /*  */
+
+   0x50,   /* .*.* */
+   0x50,   /* .*.* */
+   0x50,   /* .*.* */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+   0x00,   /*  */
+
+   0x00,   /*  */
+   0x50,   /* .*.* */
+   0xf8,   /* *... */
+   0x50,   /* .*.* */
+   0x50,   /* .*.* */
+   0xf8,   /* *... */
+   0x50,   /* .*.* */
+   0x00,   /*  */
+
+   0x20,   /* ..*. */
+   0x70,   /* .*** */
+   0xa0,   /* *.*. */
+   0x60,   /* .**. */
+   0x30,   /* ..** */
+   0x30,   /* ..** */
+   0xe0,   /* ***. */
+   0x20,   /* ..*. */
+
+   0x10,   /* ...* */
+   0x90,   /* *..*

Re: Harmonize spacing after ellipses in install.sub

2018-09-20 Thread Frederic Cambus
On Tue, Aug 14, 2018 at 11:31:30AM +0200, Frederic Cambus wrote:

> We are using spacing after ellipses in displayed messages in an
> inconsistant way.

Here is an improved diff which takes into account the cursor position
while we are waiting for the task to complete, as pointed out by
deraadt@.

In this version the cursor is always positioned after the last dot, and
the space is added when displaying completion confirmation.

This also fixes the extra leading space in dhclient messages.

Comments? OK?

Index: distrib/miniroot/install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1100
diff -u -p -r1.1100 install.sub
--- distrib/miniroot/install.sub19 Aug 2018 20:35:51 -  1.1100
+++ distrib/miniroot/install.sub21 Aug 2018 14:27:17 -
@@ -2517,10 +2517,10 @@ check_fs() {
((_passno > 0)) || continue
echo -n "fsck -${_f}p $_dev..."
if ! fsck -${_f}p $_dev >/dev/null 2>&1; then
-   echo "FAILED. You must fsck $_dev manually."
+   echo " FAILED. You must fsck $_dev manually."
_fail=y
else
-   echo "OK."
+   echo " OK."
fi
done /dev/null 2>&1 && echo "done." || echo "failed."
+   ) >/dev/null 2>&1 && echo " done." || echo " failed."
fi
 
# Ensure that sysmerge in batch mode is run on reboot.
@@ -2791,8 +2791,8 @@ set -A _KERNV -- \$(sysctl -n kern.versi
sed 's/^OpenBSD \([0-9]\.[0-9]\)\([^ ]*\).*/\1 \2/;q')
 if ((\${#_KERNV[*]} == 1)) && [[ -s /etc/installurl ]] &&
_CKPATCH=\$(mktemp /tmp/_ckpatch.XX); then
-   echo -n "Checking for available binary patches... "
-   syspatch -c > \$_CKPATCH && echo -n "done."
+   echo -n "Checking for available binary patches..."
+   syspatch -c > \$_CKPATCH && echo -n " done."
echo
if [[ -s \$_CKPATCH ]]; then
echo "Run syspatch(8) to install:"
@@ -3070,7 +3070,7 @@ do_install() {
[[ -f $_f && -s $_f ]] && mv $_f /mnt/etc/.
done)
 
-   echo "done."
+   echo " done."
 
# Apply configuration settings based on information from questions().
apply
@@ -3124,11 +3124,11 @@ do_upgrade() {
 
echo -n "Checking root filesystem (fsck -fp /dev/$ROOTDEV)..."
fsck -fp /dev/$ROOTDEV >/dev/null 2>&1 || { echo "FAILED."; exit; }
-   echo "OK."
+   echo " OK."
 
echo -n "Mounting root filesystem (mount -o ro /dev/$ROOTDEV /mnt)..."
mount -o ro /dev/$ROOTDEV /mnt || { echo "FAILED."; exit; }
-   echo "OK."
+   echo " OK."
 
# The fstab and myname files are required.
for _f in /mnt/etc/{fstab,myname}; do
Index: sys/kern/vfs_subr.c
===
RCS file: /cvs/src/sys/kern/vfs_subr.c,v
retrieving revision 1.277
diff -u -p -r1.277 vfs_subr.c
--- sys/kern/vfs_subr.c 13 Jul 2018 09:25:23 -  1.277
+++ sys/kern/vfs_subr.c 21 Aug 2018 14:27:20 -
@@ -1691,7 +1691,7 @@ vfs_shutdown(struct proc *p)
acct_shutdown();
 #endif
 
-   printf("syncing disks... ");
+   printf("syncing disks...");
 
if (panicstr == 0) {
/* Sync before unmount, in case we hang on something. */
@@ -1704,9 +1704,9 @@ vfs_shutdown(struct proc *p)
 #endif
 
if (vfs_syncwait(p, 1))
-   printf("giving up\n");
+   printf(" giving up\n");
else
-   printf("done\n");
+   printf(" done\n");
 }
 
 /*
Index: sbin/dhclient/dhclient.c
===
RCS file: /cvs/src/sbin/dhclient/dhclient.c,v
retrieving revision 1.576
diff -u -p -r1.576 dhclient.c
--- sbin/dhclient/dhclient.c13 Aug 2018 14:10:26 -  1.576
+++ sbin/dhclient/dhclient.c21 Aug 2018 14:27:21 -
@@ -2771,7 +2771,7 @@ tick_msg(const char *preamble, int succe
return;
 
if (preamble_sent == 0) {
-   fprintf(stderr, "%s: no %s ...", log_procname, preamble);
+   fprintf(stderr, "%s: no %s...", log_procname, preamble);
fflush(stderr);
preamble_sent = 1;
}



Re: rasops(9) cursor drawing code

2018-08-24 Thread Frederic Cambus
On Tue, Aug 21, 2018 at 08:07:03PM +0200, Mark Kettenis wrote:
> > Date: Mon, 20 Aug 2018 20:55:16 +0200 (CEST)
> > From: Mark Kettenis 
> > 
> > > Date: Mon, 20 Aug 2018 15:46:57 +0200
> > > From: Frederic Cambus 
> > > 
> > > There is an issue when moving the cursor backwards with the left arrow
> > > key, characters disappear and only reappear when moving back forward
> > > with the right arrow key.
> > > 
> > > I also noticed some similar artefacts when using interactive programs
> > > with wsmoused enabled.
> > 
> > Ah, I didn't take the scrollback offset into account.  Here is a
> > better diff.
> 
> As fcambus@ noticed, I attached the old diff again.  Here is the right
> one.

This version fixes the issues I was seeing.

OK fcambus@



Re: rasops(9) cursor drawing code

2018-08-20 Thread Frederic Cambus
On Mon, Aug 20, 2018 at 02:05:15PM +0200, Mark Kettenis wrote:
> So even when you set the RI_WRONLY or RI_VCONS flag, the rasops code
> still does framebuffer reads when it draws the cursor.  This causes
> problems on a particular (somewhat broken) machine I have.  But since
> we know that framebuffer reads are quite expensive on other machines,
> I think it makes sense to fix this.
> 
> The existing code would xor the cursor position with 0x.  This
> implementation instead redraws the character at the cursor position
> with foreground and background color reversed.  That isn't the same
> thing, but I think it is a sensible approach and for most cases you
> wouldn't be able to tell the difference.

There is an issue when moving the cursor backwards with the left arrow
key, characters disappear and only reappear when moving back forward
with the right arrow key.

I also noticed some similar artefacts when using interactive programs
with wsmoused enabled.



Add /usr/include/c++ to hier.7

2018-08-14 Thread Frederic Cambus
Hi tech@,

Here is a diff to add /usr/include/c++ in hier.7.

Comments? OK?

Index: share/man/man7/hier.7
===
RCS file: /cvs/src/share/man/man7/hier.7,v
retrieving revision 1.160
diff -u -p -r1.160 hier.7
--- share/man/man7/hier.7   11 Jul 2018 18:45:45 -  1.160
+++ share/man/man7/hier.7   14 Aug 2018 11:27:16 -
@@ -210,6 +210,8 @@ Standard C include files.
 .Bl -tag -width "libmilter/" -compact
 .It arpa/
 C include files for Internet service protocols.
+.It c++/
+Include files for the Clang C++ compiler.
 .It crypto/
 C include files for the cryptographic libraries.
 .It ddb/



Harmonize spacing after ellipses in install.sub

2018-08-14 Thread Frederic Cambus
Hi tech@,

We are using spacing after ellipses in displayed messages in an
inconsistant way.

A few examples:

- openssl: generating isakmpd/iked RSA keys... done.
- syncing disks... done
- iwm0: no link . got link
- iwm0: no lease .. got lease

Another example, from syspatch:

- Relinking to create unique kernel... done.

In install.sub though, we find the same message for kernel relinking,
without a space this time:

- Relinking to create unique kernel...done.

And most messages with ellipses in install.sub are displayed without a
space, except for:

- Checking for available binary patches... done.

I propose to standardize on using "... " everywhere, and the following
diff enforces this for the installer.

Comments? OK?

Index: distrib/miniroot/install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1098
diff -u -p -r1.1098 install.sub
--- distrib/miniroot/install.sub10 Jul 2018 14:22:36 -  1.1098
+++ distrib/miniroot/install.sub14 Aug 2018 09:06:28 -
@@ -2515,7 +2515,7 @@ check_fs() {
# Make sure device exists before fsck'ing it.
make_dev "$_dn" || continue
((_passno > 0)) || continue
-   echo -n "fsck -${_f}p $_dev..."
+   echo -n "fsck -${_f}p $_dev... "
if ! fsck -${_f}p $_dev >/dev/null 2>&1; then
echo "FAILED. You must fsck $_dev manually."
_fail=y
@@ -2716,7 +2716,7 @@ finish_up() {
echo "$INSTALL_URL" >/mnt/etc/installurl
fi
 
-   echo -n "Making all device nodes..."
+   echo -n "Making all device nodes... "
(cd /mnt/dev; sh MAKEDEV all
# Make sure any devices we found during probe are created in the
# installed system.
@@ -2760,7 +2760,7 @@ finish_up() {
sha256 /mnt/bsd | (umask 077; sed 's,/mnt,,' >/mnt/var/db/kernel.SHA256)
 
if [[ -f $_kernel_dir.tgz ]]; then
-   echo -n "Relinking to create unique kernel..."
+   echo -n "Relinking to create unique kernel... "
(
set -e
rm -rf $_kernel_dir
@@ -3029,7 +3029,7 @@ do_install() {
/mnt/etc/ttys >/tmp/i/ttys
mv /tmp/i/ttys /mnt/etc/ttys
 
-   echo -n "Saving configuration files..."
+   echo -n "Saving configuration files... "
 
# Save any leases obtained during install.
(cd /var/db; for _f in dhclient.leases.*; do
@@ -3122,11 +3122,11 @@ do_upgrade() {
# Get $ROOTDISK and $ROOTDEV
get_rootinfo
 
-   echo -n "Checking root filesystem (fsck -fp /dev/$ROOTDEV)..."
+   echo -n "Checking root filesystem (fsck -fp /dev/$ROOTDEV)... "
fsck -fp /dev/$ROOTDEV >/dev/null 2>&1 || { echo "FAILED."; exit; }
echo "OK."
 
-   echo -n "Mounting root filesystem (mount -o ro /dev/$ROOTDEV /mnt)..."
+   echo -n "Mounting root filesystem (mount -o ro /dev/$ROOTDEV /mnt)... "
mount -o ro /dev/$ROOTDEV /mnt || { echo "FAILED."; exit; }
echo "OK."
 



Remove dead assignment in login(1)

2018-08-07 Thread Frederic Cambus
Hi tech@,

Since rev 1.36, the instance variable is never read again so we can
simply drop the else clause with the assignment.

Comments? OK?

Index: usr.bin/login/login.c
===
RCS file: /cvs/src/usr.bin/login/login.c,v
retrieving revision 1.69
diff -u -p -r1.69 login.c
--- usr.bin/login/login.c   8 Dec 2017 17:04:15 -   1.69
+++ usr.bin/login/login.c   7 Aug 2018 13:47:00 -
@@ -406,8 +406,7 @@ main(int argc, char *argv[])
if (strncmp(instance + 1, "root", 4) == 0)
rootlogin = 1;
*instance++ = '\0';
-   } else
-   instance = "";
+   }
 
if (strlen(username) > UT_NAMESIZE)
username[UT_NAMESIZE] = '\0';



simplefb(4): display color depth when attaching

2018-07-30 Thread Frederic Cambus
Hi tech@,

Here is a diff to display color depth alongside resolution when
attaching simplefb(4).

Compile tested only, the only arm64 device I own is headless.

Comments? OK?

Index: sys/dev/fdt/simplefb.c
===
RCS file: /cvs/src/sys/dev/fdt/simplefb.c,v
retrieving revision 1.3
diff -u -p -r1.3 simplefb.c
--- sys/dev/fdt/simplefb.c  18 Dec 2017 10:13:45 -  1.3
+++ sys/dev/fdt/simplefb.c  29 Jul 2018 21:15:13 -
@@ -154,7 +154,7 @@ simplefb_attach(struct device *parent, s
ri->ri_flg &= ~RI_CLEAR;
}
 
-   printf(": %dx%d\n", ri->ri_width, ri->ri_height);
+   printf(": %dx%d, %dbpp\n", ri->ri_width, ri->ri_height, ri->ri_depth);
 
ri->ri_flg |= RI_VCONS;
rasops_init(ri, SIMPLEFB_HEIGHT, SIMPLEFB_WIDTH);



Re: rasops(9): Remove rasops4 functions?

2018-07-28 Thread Frederic Cambus
On Tue, Jul 24, 2018 at 05:42:32PM +0200, Mark Kettenis wrote:
> > Date: Sun, 22 Jul 2018 15:12:09 +0200
> > From: Frederic Cambus 
> > 
> > Hi tech@,
> > 
> > Nothing uses the rasops4 (4-bit color depth) functions anymore.
> > 
> > It seems unlikely that any future new platform will ever need them.
> > 
> > Should we remove them?
> > 
> > Comments? OK?
> 
> Hmm, apparently 4-bit is quite common for e-ink displays.  So maybe it
> makes sense to keep this...

In light of this, I think it indeed makes sense to keep them.

Thanks for pointing this out.



rasops(9): Remove rasops4 functions?

2018-07-22 Thread Frederic Cambus
Hi tech@,

Nothing uses the rasops4 (4-bit color depth) functions anymore.

It seems unlikely that any future new platform will ever need them.

Should we remove them?

Comments? OK?

Index: sys/conf/files
===
RCS file: /cvs/src/sys/conf/files,v
retrieving revision 1.664
diff -u -p -r1.664 files
--- sys/conf/files  13 Jul 2018 09:25:22 -  1.664
+++ sys/conf/files  22 Jul 2018 10:29:36 -
@@ -41,7 +41,6 @@ attachmidi at midibus
 
 # raster operations attributes
 define rasops1
-define rasops4
 define rasops8
 define rasops15
 define rasops16
Index: sys/dev/rasops/files.rasops
===
RCS file: /cvs/src/sys/dev/rasops/files.rasops,v
retrieving revision 1.7
diff -u -p -r1.7 files.rasops
--- sys/dev/rasops/files.rasops 15 Dec 2016 19:18:41 -  1.7
+++ sys/dev/rasops/files.rasops 22 Jul 2018 10:29:36 -
@@ -3,14 +3,13 @@
 
 # Note: `rasops_glue' is only here to force the header file's name
 #  hence it must be mentioned first (shudder...)
-file   dev/rasops/rasops.c ((rasops_glue | rasops1 | rasops4 | rasops8 |
+file   dev/rasops/rasops.c ((rasops_glue | rasops1 | rasops8 |
  rasops15 | rasops16 | rasops24 | rasops32 |
  rasops_bswap | rasops_rotation) &
 wsdisplay) needs-flag
 
-file   dev/rasops/rasops_masks.c  wsdisplay & (rasops1 | rasops4)
+file   dev/rasops/rasops_masks.c  wsdisplay & rasops1
 file   dev/rasops/rasops1.cwsdisplay & rasops1
-file   dev/rasops/rasops4.cwsdisplay & rasops4
 file   dev/rasops/rasops8.cwsdisplay & rasops8
 file   dev/rasops/rasops15.c   wsdisplay & (rasops15 | rasops16)
 file   dev/rasops/rasops24.c   wsdisplay & rasops24
Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.54
diff -u -p -r1.54 rasops.c
--- sys/dev/rasops/rasops.c 3 May 2018 10:05:47 -   1.54
+++ sys/dev/rasops/rasops.c 22 Jul 2018 10:29:37 -
@@ -428,11 +428,6 @@ rasops_reconfig(struct rasops_info *ri, 
rasops1_init(ri);
break;
 #endif
-#if NRASOPS4 > 0
-   case 4:
-   rasops4_init(ri);
-   break;
-#endif
 #if NRASOPS8 > 0
case 8:
rasops8_init(ri);
@@ -785,8 +780,6 @@ rasops_init_devcmap(struct rasops_info *
int i;
 #if NRASOPS15 > 0 || NRASOPS16 > 0 || NRASOPS24 > 0 || NRASOPS32 > 0
const u_char *p;
-#endif
-#if NRASOPS4 > 0 || NRASOPS15 > 0 || NRASOPS16 > 0 || NRASOPS24 > 0 || 
NRASOPS32 > 0
int c;
 #endif
 
@@ -798,14 +791,6 @@ rasops_init_devcmap(struct rasops_info *
}
 
switch (ri->ri_depth) {
-#if NRASOPS4 > 0
-   case 4:
-   for (i = 0; i < 16; i++) {
-   c = i | (i << 4);
-   ri->ri_devcmap[i] = c | (c<<8) | (c<<16) | (c<<24);
-   }
-   return;
-#endif
 #if NRASOPS8 > 0
case 8:
for (i = 0; i < 16; i++)
Index: sys/dev/rasops/rasops.h
===
RCS file: /cvs/src/sys/dev/rasops/rasops.h,v
retrieving revision 1.22
diff -u -p -r1.22 rasops.h
--- sys/dev/rasops/rasops.h 27 Apr 2018 21:36:12 -  1.22
+++ sys/dev/rasops/rasops.h 22 Jul 2018 10:29:37 -
@@ -159,7 +159,6 @@ struct rasops_info {
  * the rasops code.
  */
 void   rasops1_init(struct rasops_info *);
-void   rasops4_init(struct rasops_info *);
 void   rasops8_init(struct rasops_info *);
 void   rasops15_init(struct rasops_info *);
 void   rasops24_init(struct rasops_info *);
Index: sys/dev/rasops/rasops4.c
===
RCS file: sys/dev/rasops/rasops4.c
diff -N sys/dev/rasops/rasops4.c
--- sys/dev/rasops/rasops4.c19 Dec 2014 22:44:59 -  1.11
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,479 +0,0 @@
-/* $OpenBSD: rasops4.c,v 1.11 2014/12/19 22:44:59 guenther Exp $   */
-/* $NetBSD: rasops4.c,v 1.4 2001/11/15 09:48:15 lukem Exp $*/
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED 

Document xcrypt in the amd64 version of cpu.4

2018-07-13 Thread Frederic Cambus
Hi tech@,

Here is a diff to document xcrypt in the amd64 version of cpu.4.
Bits taken from the i386 version.

Comments? OK?

Index: share/man/man4/man4.amd64/cpu.4
===
RCS file: /cvs/src/share/man/man4/man4.amd64/cpu.4,v
retrieving revision 1.7
diff -u -p -r1.7 cpu.4
--- share/man/man4/man4.amd64/cpu.4 12 Jan 2018 04:36:44 -  1.7
+++ share/man/man4/man4.amd64/cpu.4 5 Jun 2018 06:06:54 -
@@ -52,6 +52,15 @@ offering frequency scaling with numerous
 Found on various AMD processors.
 It currently only supports a limited set of models in the K8 families.
 .El
+.Sh INSTRUCTION SET EXTENSIONS
+The presence of extended instruction sets can be determined by the
+sysctl machdep.
+.Bl -tag -width "tenletters"
+.It xcrypt
+Supports the VIA AES encryption instruction set.
+If this is supported,
+the libcrypto EVP AES functions automatically use this support.
+.El
 .Sh THERMAL MONITORING
 The
 .Xr sysctl 2



Remove i386 specific mention for pcvtfonts in hier.7

2018-07-11 Thread Frederic Cambus
Hi tech@,

Remove the i386 specific mention for pcvtfonts, they are also installed
on alpha and amd64.

>From share/misc/Makefile:

.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \
(${MACHINE} == "alpha")
SUBDIR= pcvtfonts
.endif

Comments? OK?

Index: share/man/man7/hier.7
===
RCS file: /cvs/src/share/man/man7/hier.7,v
retrieving revision 1.159
diff -u -p -r1.159 hier.7
--- share/man/man7/hier.7   8 Nov 2017 11:24:24 -   1.159
+++ share/man/man7/hier.7   11 Jul 2018 08:24:33 -
@@ -407,7 +407,7 @@ Miscellaneous system-wide ASCII text fil
 Terminal characteristics database (see
 .Xr termcap 5 ) .
 .It pcvtfonts/
-Additional i386 console fonts.
+Additional console fonts.
 .El
 .Pp
 .It mk/



Add support for the VIA VX900 chipset in viapm(4)

2018-07-04 Thread Frederic Cambus
Hi tech@,

Here is a diff to add support for the VIA VX900 chipset in viapm(4).

Comments? OK?

Index: share/man/man4/viapm.4
===
RCS file: /cvs/src/share/man/man4/viapm.4,v
retrieving revision 1.11
diff -u -p -r1.11 viapm.4
--- share/man/man4/viapm.4  16 Jul 2013 16:05:49 -  1.11
+++ share/man/man4/viapm.4  3 Jul 2018 22:11:37 -
@@ -28,8 +28,8 @@ The
 .Nm
 driver provides support for the bus control and power management
 component of the VIA VT82C596, VT82C596B, VT82C686A, VT8231, VT8233,
-VT8233A, VT8235, VT8237, VT8237A, VT8237S, VT8251, CX700, VX800 and
-VX855 South Bridges.
+VT8233A, VT8235, VT8237, VT8237A, VT8237S, VT8251, CX700, VX800,
+VX855 and VX900 South Bridges.
 Only the SMBus host interface is supported and can be used with the
 .Xr iic 4
 framework.
Index: sys/dev/pci/viapm.c
===
RCS file: /cvs/src/sys/dev/pci/viapm.c,v
retrieving revision 1.16
diff -u -p -r1.16 viapm.c
--- sys/dev/pci/viapm.c 5 Oct 2012 10:51:28 -   1.16
+++ sys/dev/pci/viapm.c 3 Jul 2018 22:11:37 -
@@ -53,7 +53,7 @@
 /*
  * Driver for the SMBus controller and power management timer
  * in the VIA VT82C596[B], VT82C686A, VT8231, VT8233[A], VT8235, VT8237[A,S],
- * VT8251, CX700, VX800 and VX855 South Bridges.
+ * VT8251, CX700, VX800, VX855 and VX900 South Bridges.
  * Also for the hardware monitoring part of the VIA VT82C686A and VT8231.
  */
 
@@ -246,7 +246,8 @@ const struct pci_matchid viapm_ids[] = {
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_ISA },
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_CX700_ISA },
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX800_ISA },
-   { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX855_ISA }
+   { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX855_ISA },
+   { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_ISA }
 };
 
 /*



pcidevs updates for the VIA VX900 chipset

2018-07-01 Thread Frederic Cambus
Hi tech@,

Add device IDs of the VIA VX900 chipset.

Attaching a dmesg from my HP t510 Thin Client.

Comments? OK?

Index: sys/dev/pci/pcidevs
===
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1851
diff -u -p -r1.1851 pcidevs
--- sys/dev/pci/pcidevs 16 Jun 2018 21:29:39 -  1.1851
+++ sys/dev/pci/pcidevs 1 Jul 2018 13:53:17 -
@@ -7427,6 +7427,7 @@ product VIATECH VT3351_HB 0x0351  VT3351 
 product VIATECH VX800_00x0353  VX800 Host
 product VIATECH P4M900 0x0364  P4M900 Host
 product VIATECH VT8371_HB  0x0391  VT8371 Host
+product VIATECH VX900_HB   0x0410  VX900 Host
 product VIATECH VT6415 0x0415  VT6415 IDE
 product VIATECH VT8501 0x0501  VT8501
 product VIATECH VT82C505   0x0505  VT82C505
@@ -7464,6 +7465,7 @@ product VIATECH K8M890_1  0x1336  K8M890 H
 product VIATECH VT3351_2   0x1351  VT3351 Host
 product VIATECH VX800_10x1353  VX800 Host
 product VIATECH P4M900_1   0x1364  P4M900 Host
+product VIATECH VX900_ERR  0x1410  VX900 Error Reporting
 product VIATECH VT82C416   0x1571  VT82C416 IDE
 product VIATECH VT82C1595  0x1595  VT82C1595 PCI
 product VIATECH K8M800_2   0x2204  K8M800 Host
@@ -7480,6 +7482,7 @@ product VIATECH K8M890_2  0x2336  K8M890 H
 product VIATECH VT3351_3   0x2351  VT3351 Host
 product VIATECH VX800_20x2353  VX800 Host
 product VIATECH P4M900_2   0x2364  P4M900 Host
+product VIATECH VX900_00x2410  VX900 Host
 product VIATECH VT8251_PCI 0x287a  VT8251 PCI
 product VIATECH VT8251_PCIE_0  0x287b  VT8251 PCIE
 product VIATECH VT8251_PCIE_1  0x287c  VT8251 PCIE
@@ -7553,6 +7556,7 @@ product VIATECH CHROME9_HC0x3371  Chrome
 product VIATECH VT8237S_ISA0x3372  VT8237S ISA
 product VIATECH VT8237A_PPB_1  0x337a  VT8237A
 product VIATECH VT8237A_PPB_2  0x337b  VT8237A
+product VIATECH VX900_DRAM 0x3410  VX900 DRAM
 product VIATECH VL80x_XHCI 0x3432  VL80x xHCI
 productVIATECH VL805_XHCI  0x3483  VL805 xHCI
 product VIATECH K8M800_4   0x4204  K8M800 Host
@@ -7569,6 +7573,7 @@ product VIATECH K8M890_4  0x4336  K8M890 H
 product VIATECH VT3351_5   0x4351  VT3351 Host
 product VIATECH VX800_40x4353  VX800 Host
 product VIATECH P4M900_4   0x4364  P4M900 Host
+product VIATECH VX900_10x4410  VX900 Host
 product VIATECH K8T890_IOAPIC  0x5238  K8T890 IOAPIC
 product VIATECH PT894_IOAPIC   0x5308  PT894 IOAPIC
 product VIATECH CX700_IDE  0x5324  CX700 IDE
@@ -7579,6 +7584,7 @@ product VIATECH VT3351_IOAPIC 0x5351  VT3
 product VIATECH VX800_IOAPIC   0x5353  VX800 IOAPIC
 product VIATECH P4M900_IOAPIC  0x5364  P4M900 IOAPIC
 product VIATECH VT8237S_SATA   0x5372  VT8237S SATA
+product VIATECH VX900_APIC 0x5410  VX900 APIC
 product VIATECH RHINEII0x6100  RhineII
 product VIATECH VT3351_6   0x6238  VT3351 Host
 product VIATECH VT8251_AHCI0x6287  VT8251 AHCI
@@ -7586,6 +7592,8 @@ product VIATECH K8M890_6  0x6290  K8M890 H
 product VIATECH P4M890_6   0x6327  P4M890 Security
 product VIATECH VX800_60x6353  VX800 Host
 product VIATECH P4M900_6   0x6364  P4M900 Security
+product VIATECH VX900_SCRATCH  0x6410  VX900 Scratch
+product VIATECH CHROME9_HD 0x7122  Chrome9 HD
 product VIATECH K8M800_7   0x7204  K8M800 Host
 product VIATECH VT8378_VGA 0x7205  VT8378 VGA
 product VIATECH PT894_50x7308  PT894 Host
@@ -7601,6 +7609,7 @@ product VIATECH K8HTB_7   0x7282  K8HTB Ho
 product VIATECH CN700_70x7314  CN700 Host
 product VIATECH CX700_70x7324  CX700 Host
 product VIATECH VT3351_7   0x7351  VT3351 Host
+product VIATECH VX900_20x7410  VX900 Host
 product VIATECH VT8231_ISA 0x8231  VT8231 ISA
 product VIATECH VT8231_PWR 0x8235  VT8231 PMG
 product VIATECH VT8363_AGP 0x8305  VT8363 AGP
@@ -7608,6 +7617,7 @@ product VIATECH CX700_ISA 0x8324  CX700 I
 product VIATECH VX800_ISA  0x8353  VX800 ISA
 product VIATECH VT8371_PPB 0x8391  VT8371
 product VIATECH VX855_ISA  0x8409  VX855 ISA
+product VIATECH VX900_ISA  0x8410  VX900 ISA
 product VIATECH VT8501_AGP 0x8501  VT8501 AGP
 product VIATECH VT82C597AGP0x8597  VT82C597 AGP
 product VIATECH VT82C598AGP0x8598  VT82C598 AGP
@@ -7617,6 +7627,7 @@ product VIATECH VX900_IDE 0x9001  VX900 I
 product VIATECH VX800_SDMMC0x9530  VX800 SD/MMC
 product VIATECH VX800_SDIO 0x95d0  VX800 SDIO
 product VIATECH K8T890_PPB_A   0xa238  K8T890
+product VIATECH VX900_PCIE_0   0xa410  VX900 PCIE
 product VIATECH P4M890_PPB_1   0xa327  P4M890
 product VIATECH VX800_A0xa353  VX800 Host
 product VIATECH P4M900_PPB_1   0xa364  P4M900
@@ -7629,15 +7640,19 @@ product VIATECH VT8235_AGP  0xb168  VT8235
 product VIATECH K8HTB_AGP  0xb188  K8HTB AGP
 product VIATECH VT8377_AGP 

Re: cpu.4: VIA C7 CPUs support Enhanced SpeedStep (i386)

2018-07-01 Thread Frederic Cambus
On Tue, Jun 05, 2018 at 10:04:52PM +1000, Jonathan Gray wrote:

> > VIA C7 CPUs support Enhanced SpeedStep, so reflect that in cpu.4.
> > 
> > On the VIA C7 1.5Ghz:
> > 
> > cpu0: VIA Esther processor 1500MHz ("CentaurHauls" 686-class) 1.51 GHz
> > cpu0: 
> > FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,APIC,SEP,MTRR,PGE,CMOV,PAT,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,TM,PBE,NXE,SSE3,EST,TM2
> > cpu0: Enhanced SpeedStep 1501 MHz: speeds: 1500, 800 MHz
> 
> If you just have the faked high/low table does it really support it
> besides setting the cpuid bit?  No PSS in ACPI?  There is a table
> for a 1.5GHz C7 in i386
> 
> /* 1.50GHz Centaur C7-M 400 MHz FSB */
> static struct est_op C7M_754[] = {
>   ID16(1500, 1004, BUS100),
>   ID16(1400,  988, BUS100),
>   ID16(1000,  940, BUS100),
>   ID16( 800,  844, BUS100),
>   ID16( 600,  844, BUS100),
>   ID16( 400,  844, BUS100),
> };

Sorry for the delay, I wanted to try booting an old VIA C7 motherboard
I have (the dmesg bits from previous mail came from our dmesg archive)
before answering.

I finally was able to find it and do so, and indeed it seems there are
some issues as well:

cpu0: VIA C7 Processor 1000MHz ("CentaurHauls" 686-class) 1 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,CMOV,PAT,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,TM,PBE,NXE,SSE3,EST,TM2,xTPR

cpu0: unknown Enhanced SpeedStep CPU, msr 0x08100a1308000a13
cpu0: using only highest and lowest power states
cpu0: Enhanced SpeedStep 998 MHz: speeds: 1333, 1067 MHz

I'm not sure it makes sense to spend any time on this, let's forget it.



cpu.4: VIA C7 CPUs support Enhanced SpeedStep (i386)

2018-06-05 Thread Frederic Cambus
Hi tech@,

VIA C7 CPUs support Enhanced SpeedStep, so reflect that in cpu.4.

On the VIA C7 1.5Ghz:

cpu0: VIA Esther processor 1500MHz ("CentaurHauls" 686-class) 1.51 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,APIC,SEP,MTRR,PGE,CMOV,PAT,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,TM,PBE,NXE,SSE3,EST,TM2
cpu0: Enhanced SpeedStep 1501 MHz: speeds: 1500, 800 MHz

Comments? OK?

Index: share/man/man4/man4.i386/cpu.4
===
RCS file: /cvs/src/share/man/man4/man4.i386/cpu.4,v
retrieving revision 1.18
diff -u -p -r1.18 cpu.4
--- share/man/man4/man4.i386/cpu.4  12 Jan 2018 04:36:44 -  1.18
+++ share/man/man4/man4.i386/cpu.4  5 Jun 2018 08:39:38 -
@@ -53,8 +53,8 @@ positions.
 The processor dynamically adjusts frequency in response to load; the setperf
 value is interpreted as the maximum.
 .It EST
-Enhanced SpeedStep found on Intel Pentium M processors,
-offering frequency scaling with numerous positions.
+Enhanced SpeedStep found on Intel Pentium M and newer processors, as well as
+on VIA C7 processors, offering frequency scaling with numerous positions.
 .It SpeedStep
 Found on some Intel Pentium 3 and newer mobile chips,
 it is capable of adjusting frequency between a low and high value.



Re: Remove unused C3 values (VIA)

2018-06-02 Thread Frederic Cambus
On Sat, Jun 02, 2018 at 11:30:15AM +, Visa Hankala wrote:
> On Sat, Jun 02, 2018 at 01:00:05PM +0200, Frederic Cambus wrote:
> > Hi tech@,
> > 
> > Here is a diff to remove unused C3 values.
> > 
> > Comments? OK?
> 
> I would keep the definitions because they can at least serve as a weak
> form of documentation about the hardware. For example,
> C3_CRYPT_CWLO_ALG_M indicates what bits specify the algorithm, which
> in turn helps one to understand the value of C3_CRYPT_CWLO_ALG_AES.

Agreed. That makes sense indeed, sorry for the noise.



Remove unused C3 values (VIA)

2018-06-02 Thread Frederic Cambus
Hi tech@,

Here is a diff to remove unused C3 values.

Comments? OK?

Index: sys/arch/amd64/include/specialreg.h
===
RCS file: /cvs/src/sys/arch/amd64/include/specialreg.h,v
retrieving revision 1.72
diff -u -p -r1.72 specialreg.h
--- sys/arch/amd64/include/specialreg.h 23 May 2018 05:37:01 -  1.72
+++ sys/arch/amd64/include/specialreg.h 2 Jun 2018 09:14:32 -
@@ -873,14 +873,9 @@
 #define C3_CPUID_DO_PMM0x002000
 
 /* VIA C3 xcrypt-* instruction context control options */
-#defineC3_CRYPT_CWLO_ROUND_M   0x000f
-#defineC3_CRYPT_CWLO_ALG_M 0x0070
 #defineC3_CRYPT_CWLO_ALG_AES   0x
-#defineC3_CRYPT_CWLO_KEYGEN_M  0x0080
-#defineC3_CRYPT_CWLO_KEYGEN_HW 0x
 #defineC3_CRYPT_CWLO_KEYGEN_SW 0x0080
 #defineC3_CRYPT_CWLO_NORMAL0x
-#defineC3_CRYPT_CWLO_INTERMEDIATE  0x0100
 #defineC3_CRYPT_CWLO_ENCRYPT   0x
 #defineC3_CRYPT_CWLO_DECRYPT   0x0200
 #defineC3_CRYPT_CWLO_KEY1280x000a  /* 128bit, 10 
rds */
Index: sys/arch/i386/include/specialreg.h
===
RCS file: /cvs/src/sys/arch/i386/include/specialreg.h,v
retrieving revision 1.66
diff -u -p -r1.66 specialreg.h
--- sys/arch/i386/include/specialreg.h  28 May 2018 20:52:44 -  1.66
+++ sys/arch/i386/include/specialreg.h  2 Jun 2018 09:14:32 -
@@ -724,14 +724,9 @@
 #define C3_CPUID_DO_PMM0x002000
 
 /* VIA C3 xcrypt-* instruction context control options */
-#defineC3_CRYPT_CWLO_ROUND_M   0x000f
-#defineC3_CRYPT_CWLO_ALG_M 0x0070
 #defineC3_CRYPT_CWLO_ALG_AES   0x
-#defineC3_CRYPT_CWLO_KEYGEN_M  0x0080
-#defineC3_CRYPT_CWLO_KEYGEN_HW 0x
 #defineC3_CRYPT_CWLO_KEYGEN_SW 0x0080
 #defineC3_CRYPT_CWLO_NORMAL0x
-#defineC3_CRYPT_CWLO_INTERMEDIATE  0x0100
 #defineC3_CRYPT_CWLO_ENCRYPT   0x
 #defineC3_CRYPT_CWLO_DECRYPT   0x0200
 #defineC3_CRYPT_CWLO_KEY1280x000a  /* 128bit, 10 
rds */



Enable bwfm(4) on Loongson for USB devices

2018-05-30 Thread Frederic Cambus
Hi tech@,

Here is a diff to enable bwfm(4) on Loongson for USB devices.

Tested on a Lemote Yeeloong 8101B.

Comments? OK?

Index: sys/arch/loongson/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/loongson/conf/GENERIC,v
retrieving revision 1.57
diff -u -p -r1.57 GENERIC
--- sys/arch/loongson/conf/GENERIC  24 Apr 2018 03:17:36 -  1.57
+++ sys/arch/loongson/conf/GENERIC  30 May 2018 15:45:25 -
@@ -164,6 +164,7 @@ atu*at uhub?# Atmel AT76c50x based 
80
 aue*   at uhub?# ADMtek AN986 Pegasus Ethernet  
 axe*   at uhub?# ASIX Electronics AX88172 USB Ethernet
 axen*  at uhub?# ASIX Electronics AX88179 USB Ethernet
+bwfm*  at uhub?# Broadcom FullMAC
 cdce*  at uhub?# CDC Ethernet
 urndis*at uhub?# Remote NDIS Ethernet
 cue*   at uhub?# CATC USB-EL1201A based Ethernet



Add sizes for free() for octeon

2018-05-29 Thread Frederic Cambus
Hi tech@,

Add sizes for free() for octeon.

Comments? OK?

Index: sys/arch/octeon/dev/amdcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/amdcf.c,v
retrieving revision 1.5
diff -u -p -r1.5 amdcf.c
--- sys/arch/octeon/dev/amdcf.c 30 Dec 2017 23:08:29 -  1.5
+++ sys/arch/octeon/dev/amdcf.c 30 Apr 2018 21:40:24 -
@@ -495,7 +495,7 @@ amdcfioctl(dev_t dev, u_long xfer, caddr
lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK);
amdcfgetdisklabel(dev, sc, lp, 0);
bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp));
-   free(lp, M_TEMP, 0);
+   free(lp, M_TEMP, sizeof(*lp));
goto exit;
 
case DIOCGPDINFO:
Index: sys/arch/octeon/dev/octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.31
diff -u -p -r1.31 octcf.c
--- sys/arch/octeon/dev/octcf.c 30 Dec 2017 23:08:29 -  1.31
+++ sys/arch/octeon/dev/octcf.c 30 Apr 2018 21:40:24 -
@@ -563,7 +563,7 @@ octcfioctl(dev_t dev, u_long xfer, caddr
lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK);
octcfgetdisklabel(dev, wd, lp, 0);
bcopy(lp, wd->sc_dk.dk_label, sizeof(*lp));
-   free(lp, M_TEMP, 0);
+   free(lp, M_TEMP, sizeof(*lp));
goto exit;
 
case DIOCGPDINFO:
@@ -788,7 +788,7 @@ octcf_get_params(struct octcf_softc *wd,
 
if (error != 0) {
printf("%s: identify failed: %d\n", __func__, error);
-   free(tb, M_DEVBUF, 0);
+   free(tb, M_DEVBUF, ATAPARAMS_SIZE);
return CMD_ERR;
} else {
/*
@@ -818,7 +818,7 @@ octcf_get_params(struct octcf_softc *wd,
params->atap_model[1] == 'E') ||
 (params->atap_model[0] == 'F' &&
 params->atap_model[1] == 'X'))) {
-   free(tb, M_DEVBUF, 0);
+   free(tb, M_DEVBUF, ATAPARAMS_SIZE);
return CMD_OK;
}
for (i = 0; i < sizeof(params->atap_model); i += 2) {
@@ -834,7 +834,7 @@ octcf_get_params(struct octcf_softc *wd,
*p = swap16(*p);
}
 
-   free(tb, M_DEVBUF, 0);
+   free(tb, M_DEVBUF, ATAPARAMS_SIZE);
return CMD_OK;
}
 }



Some tweaks for the VIA PadLock driver

2018-05-29 Thread Frederic Cambus
Hi tech@,

Return error values directly where appropriate, instead of using the err
variable.

While there, remove TODO about bitching. We haven't felt the need to bitch
since the driver was commited, and we do not bitch in aesni_setup() either.

Comments? OK?

Index: sys/arch/amd64/amd64/via.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/via.c,v
retrieving revision 1.29
diff -u -p -r1.29 via.c
--- sys/arch/amd64/amd64/via.c  28 Apr 2018 15:44:59 -  1.29
+++ sys/arch/amd64/amd64/via.c  29 May 2018 15:34:03 -
@@ -87,7 +87,7 @@ viac3_crypto_setup(void)
 
vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (vc3_sc == NULL)
-   return; /* YYY bitch? */
+   return;
 
bzero(algs, sizeof(algs));
algs[CRYPTO_AES_CBC] = CRYPTO_ALG_FLAG_SUPPORTED;
@@ -102,7 +102,7 @@ viac3_crypto_setup(void)
vc3_sc->sc_cid = crypto_get_driverid(0);
if (vc3_sc->sc_cid < 0) {
free(vc3_sc, M_DEVBUF, sizeof(*vc3_sc));
-   return; /* YYY bitch? */
+   return;
}
 
crypto_register(vc3_sc->sc_cid, algs, viac3_crypto_newsession,
@@ -340,16 +340,12 @@ viac3_crypto_encdec(struct cryptop *crp,
u_int32_t *key;
int err = 0;
 
-   if ((crd->crd_len % 16) != 0) {
-   err = EINVAL;
-   return (err);
-   }
+   if ((crd->crd_len % 16) != 0)
+   return (EINVAL);
 
sc->op_buf = malloc(crd->crd_len, M_DEVBUF, M_NOWAIT);
-   if (sc->op_buf == NULL) {
-   err = ENOMEM;
-   return (err);
-   }
+   if (sc->op_buf == NULL)
+   return (ENOMEM);
 
if (crd->crd_flags & CRD_F_ENCRYPT) {
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;
Index: sys/arch/i386/i386/via.c
===
RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
retrieving revision 1.43
diff -u -p -r1.43 via.c
--- sys/arch/i386/i386/via.c28 Apr 2018 15:44:59 -  1.43
+++ sys/arch/i386/i386/via.c29 May 2018 15:34:03 -
@@ -88,7 +88,7 @@ viac3_crypto_setup(void)
 
vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (vc3_sc == NULL)
-   return; /* YYY bitch? */
+   return;
 
bzero(algs, sizeof(algs));
algs[CRYPTO_AES_CBC] = CRYPTO_ALG_FLAG_SUPPORTED;
@@ -103,7 +103,7 @@ viac3_crypto_setup(void)
vc3_sc->sc_cid = crypto_get_driverid(0);
if (vc3_sc->sc_cid < 0) {
free(vc3_sc, M_DEVBUF, sizeof(*vc3_sc));
-   return; /* YYY bitch? */
+   return;
}
 
crypto_register(vc3_sc->sc_cid, algs, viac3_crypto_newsession,
@@ -341,16 +341,12 @@ viac3_crypto_encdec(struct cryptop *crp,
u_int32_t *key;
int err = 0;
 
-   if ((crd->crd_len % 16) != 0) {
-   err = EINVAL;
-   return (err);
-   }
+   if ((crd->crd_len % 16) != 0)
+   return (EINVAL);
 
sc->op_buf = malloc(crd->crd_len, M_DEVBUF, M_NOWAIT);
-   if (sc->op_buf == NULL) {
-   err = ENOMEM;
-   return (err);
-   }
+   if (sc->op_buf == NULL)
+   return (ENOMEM);
 
if (crd->crd_flags & CRD_F_ENCRYPT) {
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;



Add sizes for free() in cryptosoft.c

2018-05-29 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in cryptosoft.c.

Comments? OK?

Index: sys/crypto/cryptosoft.c
===
RCS file: /cvs/src/sys/crypto/cryptosoft.c,v
retrieving revision 1.83
diff -u -p -r1.83 cryptosoft.c
--- sys/crypto/cryptosoft.c 2 May 2017 11:44:32 -   1.83
+++ sys/crypto/cryptosoft.c 29 May 2018 11:13:13 -
@@ -971,7 +971,8 @@ swcr_freesession(u_int64_t tid)
 
if (swd->sw_kschedule) {
explicit_bzero(swd->sw_kschedule, txf->ctxsize);
-   free(swd->sw_kschedule, M_CRYPTO_DATA, 0);
+   free(swd->sw_kschedule, M_CRYPTO_DATA,
+   txf->ctxsize);
}
break;
 
@@ -985,11 +986,11 @@ swcr_freesession(u_int64_t tid)
 
if (swd->sw_ictx) {
explicit_bzero(swd->sw_ictx, axf->ctxsize);
-   free(swd->sw_ictx, M_CRYPTO_DATA, 0);
+   free(swd->sw_ictx, M_CRYPTO_DATA, axf->ctxsize);
}
if (swd->sw_octx) {
explicit_bzero(swd->sw_octx, axf->ctxsize);
-   free(swd->sw_octx, M_CRYPTO_DATA, 0);
+   free(swd->sw_octx, M_CRYPTO_DATA, axf->ctxsize);
}
break;
 
@@ -1001,12 +1002,12 @@ swcr_freesession(u_int64_t tid)
 
if (swd->sw_ictx) {
explicit_bzero(swd->sw_ictx, axf->ctxsize);
-   free(swd->sw_ictx, M_CRYPTO_DATA, 0);
+   free(swd->sw_ictx, M_CRYPTO_DATA, axf->ctxsize);
}
break;
}
 
-   free(swd, M_CRYPTO_DATA, 0);
+   free(swd, M_CRYPTO_DATA, sizeof(*swd));
}
return 0;
 }



Sizes for free() in the Enhanced SpeedStep driver

2018-02-13 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in the i386 version of the Enhanced SpeedStep driver.

It was already done on amd64, but not on i386. Tested on an Atom N270.

Comments? OK?

Index: sys/arch/i386/i386/est.c
===
RCS file: /cvs/src/sys/arch/i386/i386/est.c,v
retrieving revision 1.48
diff -u -p -r1.48 est.c
--- sys/arch/i386/i386/est.c7 Mar 2016 05:32:46 -   1.48
+++ sys/arch/i386/i386/est.c20 Jan 2018 17:53:44 -
@@ -1036,7 +1036,7 @@ est_acpi_pss_changed(struct acpicpu_pss 
needtran = 0;
}
 
-   free(est_fqlist->table, M_DEVBUF, 0);
+   free(est_fqlist->table, M_DEVBUF, npss * sizeof(struct est_op));
free(est_fqlist, M_DEVBUF, sizeof *est_fqlist);
est_fqlist = acpilist;
 
@@ -1141,7 +1141,7 @@ est_init(struct cpu_info *ci, int vendor
 
if ((fake_table = mallocarray(3, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL) {
-   free(fake_fqlist, M_DEVBUF, 0);
+   free(fake_fqlist, M_DEVBUF, sizeof(struct fqlist));
printf("%s: EST: cannot allocate memory for fake "
"table\n", cpu_device);
return;
@@ -1206,7 +1206,7 @@ nospeedstep:
 * it can't fail in that case and therefore can't reach here.
 */
free(est_fqlist->table, M_DEVBUF, 0);
-   free(est_fqlist, M_DEVBUF, 0);
+   free(est_fqlist, M_DEVBUF, sizeof(*est_fqlist));
 }
 
 void



rasops(9): Fix underline rotation on CCW rotated screens

2018-01-19 Thread Frederic Cambus
Hi tech@,

Fix underline rotation on CCW (quarter counter-clockwise) rotated
screens.

Currently, the "underline" is actually drawn above text.

Comments? OK?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.49
diff -u -p -r1.49 rasops.c
--- sys/dev/rasops/rasops.c 23 Dec 2017 10:30:25 -  1.49
+++ sys/dev/rasops/rasops.c 17 Jan 2018 17:35:49 -
@@ -1247,6 +1247,8 @@ rasops_putchar_rotated(void *cookie, int
 
/* Do rotated underline */
rp = ri->ri_bits + col * ri->ri_yscale + row * ri->ri_xscale;
+   if (ri->ri_flg & RI_ROTATE_CCW)
+   rp += (ri->ri_font->fontwidth - 1) * ri->ri_pelbytes;
height = ri->ri_font->fontheight;
 
/* XXX this assumes 16-bit color depth */



Add sizes for free() in wscons(4)

2018-01-16 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in wscons(4).

Comments? OK?

Index: sys/dev/wscons/wsdisplay.c
===
RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v
retrieving revision 1.129
diff -u -p -r1.129 wsdisplay.c
--- sys/dev/wscons/wsdisplay.c  19 Jul 2017 20:12:54 -  1.129
+++ sys/dev/wscons/wsdisplay.c  15 Jan 2018 09:49:03 -
@@ -3326,7 +3326,7 @@ allocate_copybuffer(struct wsdisplay_sof
}
if (size != sc->sc_copybuffer_size && sc->sc_copybuffer_size != 0) {
bzero(sc->sc_copybuffer, sc->sc_copybuffer_size);
-   free(sc->sc_copybuffer, M_DEVBUF, 0);
+   free(sc->sc_copybuffer, M_DEVBUF, sc->sc_copybuffer_size);
}
if ((sc->sc_copybuffer = (char *)malloc(size, M_DEVBUF, M_NOWAIT)) ==
NULL) {
Index: sys/dev/wscons/wskbd.c
===
RCS file: /cvs/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.87
diff -u -p -r1.87 wskbd.c
--- sys/dev/wscons/wskbd.c  12 May 2017 09:16:55 -  1.87
+++ sys/dev/wscons/wskbd.c  15 Jan 2018 09:49:03 -
@@ -1126,7 +1126,7 @@ getkeyrepeat:
KB_HANDLEDBYWSKBD);
wskbd_update_layout(sc->id, enc);
}
-   free(buf, M_TEMP, 0);
+   free(buf, M_TEMP, len);
return(error);
 
case WSKBDIO_GETMAP:



Re: Remove unnecessary includes (i386 VIA PadLock driver)

2017-12-28 Thread Frederic Cambus
On Fri, Dec 08, 2017 at 12:39:36PM +0100, Frederic Cambus wrote:

> This diff remove unnecessary includes in the i386 version of the
> VIA PadLock driver.
> 
> Comments? OK?

Ping. Anyone?

This is the last step in syncing amd64 and i386 versions of the
VIA PadLock driver.



cpu.4: VIA amd64 compatible CPUs support Enhanced SpeedStep

2017-12-28 Thread Frederic Cambus
Hi tech@,

VIA amd64 compatible CPUs support Enhanced SpeedStep, so reflect that
in cpu.4.

On my VIA Nano U3500:

cpu0: VIA Nano U3500@1000MHz, 997.66 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,
CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,PBE,SSE3,MWAIT,VMX,EST,TM2,SSSE3,
CX16,xTPR,SSE4.1,POPCNT,NXE,LONG,LAHF,PERF
cpu0: Enhanced SpeedStep 997 MHz: speeds: 1000, 800 MHz

On my VIA Eden X2 U4200:

cpu0: VIA Eden X2 U4200 @ 1.0+ GHz, 1000.23 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,
CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,MWAIT,VMX,EST,TM2,
SSSE3,CX16,xTPR,SSE4.1,POPCNT,NXE,LONG,LAHF,PERF
cpu0: Enhanced SpeedStep 1000 MHz: speeds: 1000, 900, 800 MHz

Comments? OK?

Index: share/man/man4/man4.amd64/cpu.4
===
RCS file: /cvs/src/share/man/man4/man4.amd64/cpu.4,v
retrieving revision 1.4
diff -u -p -r1.4 cpu.4
--- share/man/man4/man4.amd64/cpu.4 13 Jul 2009 15:43:05 -  1.4
+++ share/man/man4/man4.amd64/cpu.4 27 Dec 2017 17:22:10 -
@@ -46,7 +46,7 @@ There are several possible implementatio
 to the user.
 .Bl -tag -width tenletters
 .It EST
-Enhanced SpeedStep found on Intel processors,
+Enhanced SpeedStep found on Intel and VIA processors,
 offers frequency scaling with numerous positions.
 .It PowerNow
 Found on various AMD processors.



Add sizes for free() in glxsb(4)

2017-12-24 Thread Frederic Cambus
Hi tech@,

Add sizes for free() for the Geode LX Security Block crypto accelerator.

Comments? OK?

Index: sys/arch/i386/pci/glxsb.c
===
RCS file: /cvs/src/sys/arch/i386/pci/glxsb.c,v
retrieving revision 1.33
diff -u -p -r1.33 glxsb.c
--- sys/arch/i386/pci/glxsb.c   8 Sep 2017 05:36:51 -   1.33
+++ sys/arch/i386/pci/glxsb.c   24 Dec 2017 18:37:54 -
@@ -525,22 +525,22 @@ glxsb_crypto_freesession(uint64_t tid)
 
if (swd->sw_kschedule) {
explicit_bzero(swd->sw_kschedule, txf->ctxsize);
-   free(swd->sw_kschedule, M_CRYPTO_DATA, 0);
+   free(swd->sw_kschedule, M_CRYPTO_DATA, txf->ctxsize);
}
-   free(swd, M_CRYPTO_DATA, 0);
+   free(swd, M_CRYPTO_DATA, sizeof(*swd));
}
if ((swd = sc->sc_sessions[sesn].ses_swd_auth)) {
axf = swd->sw_axf;
 
if (swd->sw_ictx) {
explicit_bzero(swd->sw_ictx, axf->ctxsize);
-   free(swd->sw_ictx, M_CRYPTO_DATA, 0);
+   free(swd->sw_ictx, M_CRYPTO_DATA, axf->ctxsize);
}
if (swd->sw_octx) {
explicit_bzero(swd->sw_octx, axf->ctxsize);
-   free(swd->sw_octx, M_CRYPTO_DATA, 0);
+   free(swd->sw_octx, M_CRYPTO_DATA, axf->ctxsize);
}
-   free(swd, M_CRYPTO_DATA, sizeof *swd);
+   free(swd, M_CRYPTO_DATA, sizeof(*swd));
}
explicit_bzero(>sc_sessions[sesn], sizeof(sc->sc_sessions[sesn]));
return (0);



rasops(9): Remove dead assignment

2017-12-22 Thread Frederic Cambus
Hi tech@,

Now that we call rasops_putchar_rotated(), we don't need ri anymore.

Comments? OK?

Index: sys/dev/rasops/rasops.c
===
RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
retrieving revision 1.48
diff -u -p -r1.48 rasops.c
--- sys/dev/rasops/rasops.c 22 Aug 2017 12:24:45 -  1.48
+++ sys/dev/rasops/rasops.c 22 Dec 2017 21:08:39 -
@@ -1265,11 +1265,8 @@ rasops_putchar_rotated(void *cookie, int
 int
 rasops_erasecols_rotated(void *cookie, int row, int col, int num, long attr)
 {
-   struct rasops_info *ri;
int i;
int rc;
-
-   ri = (struct rasops_info *)cookie;
 
for (i = col; i < col + num; i++) {
rc = rasops_putchar_rotated(cookie, row, i, ' ', attr);



Change bcopy to memcpy (i386 VIA PadLock driver)

2017-12-13 Thread Frederic Cambus
Hi tech@,

This diff changes bcopy to memcpy in the i386 version of the VIA PadLock
driver. It was done a while ago in the amd64 version of the driver.

Comments? OK?

Index: sys/arch/i386/i386/via.c
===
RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
retrieving revision 1.37
diff -u -p -r1.37 via.c
--- sys/arch/i386/i386/via.c2 May 2017 11:47:49 -   1.37
+++ sys/arch/i386/i386/via.c10 Dec 2017 14:01:21 -
@@ -161,7 +161,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
-   bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses));
+   memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
sc->sc_sessions = ses;
@@ -370,7 +370,7 @@ viac3_crypto_encdec(struct cryptop *crp,
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_ENCRYPT;
key = ses->ses_ekey;
if (crd->crd_flags & CRD_F_IV_EXPLICIT)
-   bcopy(crd->crd_iv, sc->op_iv, 16);
+   memcpy(sc->op_iv, crd->crd_iv, 16);
else
arc4random_buf(sc->op_iv, 16);
 
@@ -382,8 +382,8 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copyback((struct uio *)crp->crp_buf,
crd->crd_inject, 16, sc->op_iv);
else
-   bcopy(sc->op_iv,
-   crp->crp_buf + crd->crd_inject, 16);
+   memcpy(crp->crp_buf + crd->crd_inject,
+   sc->op_iv, 16);
if (err)
return (err);
}
@@ -391,7 +391,7 @@ viac3_crypto_encdec(struct cryptop *crp,
sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT;
key = ses->ses_dkey;
if (crd->crd_flags & CRD_F_IV_EXPLICIT)
-   bcopy(crd->crd_iv, sc->op_iv, 16);
+   memcpy(sc->op_iv, crd->crd_iv, 16);
else {
if (crp->crp_flags & CRYPTO_F_IMBUF)
m_copydata((struct mbuf *)crp->crp_buf,
@@ -400,8 +400,8 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copydata((struct uio *)crp->crp_buf,
crd->crd_inject, 16, sc->op_iv);
else
-   bcopy(crp->crp_buf + crd->crd_inject,
-   sc->op_iv, 16);
+   memcpy(sc->op_iv,
+   crp->crp_buf + crd->crd_inject, 16);
}
}
 
@@ -412,7 +412,7 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copydata((struct uio *)crp->crp_buf,
crd->crd_skip, crd->crd_len, sc->op_buf);
else
-   bcopy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len);
+   memcpy(sc->op_buf, crp->crp_buf + crd->crd_skip, crd->crd_len);
 
sc->op_cw[1] = sc->op_cw[2] = sc->op_cw[3] = 0;
viac3_cbc(>op_cw, sc->op_buf, sc->op_buf, key,
@@ -425,7 +425,7 @@ viac3_crypto_encdec(struct cryptop *crp,
cuio_copyback((struct uio *)crp->crp_buf,
crd->crd_skip, crd->crd_len, sc->op_buf);
else
-   bcopy(sc->op_buf, crp->crp_buf + crd->crd_skip,
+   memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf,
crd->crd_len);
 
if (sc->op_buf != NULL) {



Add sizes for free() in libsa for amd64 and i386

2017-12-10 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in libsa for amd64 and i386.

Comments? OK?

Index: sys/arch/amd64/stand/libsa/diskprobe.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/diskprobe.c,v
retrieving revision 1.21
diff -u -p -r1.21 diskprobe.c
--- sys/arch/amd64/stand/libsa/diskprobe.c  6 Nov 2017 08:57:34 -   
1.21
+++ sys/arch/amd64/stand/libsa/diskprobe.c  8 Dec 2017 14:35:27 -
@@ -94,7 +94,7 @@ floppyprobe(void)
if (debug)
printf(" ", i);
 #endif
-   free(dip, 0);
+   free(dip, sizeof(*dip));
break;
}
 
@@ -136,7 +136,7 @@ hardprobe(void)
if (debug)
printf(" ", i&0x7f);
 #endif
-   free(dip, 0);
+   free(dip, sizeof(*dip));
break;
}
 
@@ -323,7 +323,7 @@ cdprobe(void)
 #if 0
if (bios_getdiskinfo(cddev, >bios_info)) {
printf(" ");  /* XXX */
-   free(dip, 0);
+   free(dip, sizeof(*dip));
return;
}
 #endif
Index: sys/arch/amd64/stand/libsa/softraid_amd64.c
===
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/softraid_amd64.c,v
retrieving revision 1.4
diff -u -p -r1.4 softraid_amd64.c
--- sys/arch/amd64/stand/libsa/softraid_amd64.c 5 Jan 2017 11:18:54 -   
1.4
+++ sys/arch/amd64/stand/libsa/softraid_amd64.c 8 Dec 2017 14:35:27 -
@@ -305,7 +305,7 @@ srprobe(void)
}
 
explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
-   free(md, 0);
+   free(md, SR_META_SIZE * DEV_BSIZE);
 }
 
 int
Index: sys/arch/i386/stand/libsa/diskprobe.c
===
RCS file: /cvs/src/sys/arch/i386/stand/libsa/diskprobe.c,v
retrieving revision 1.44
diff -u -p -r1.44 diskprobe.c
--- sys/arch/i386/stand/libsa/diskprobe.c   21 Jul 2017 01:21:42 -  
1.44
+++ sys/arch/i386/stand/libsa/diskprobe.c   8 Dec 2017 14:35:27 -
@@ -94,7 +94,7 @@ floppyprobe(void)
if (debug)
printf(" ", i);
 #endif
-   free(dip, 0);
+   free(dip, sizeof(*dip));
break;
}
 
@@ -136,7 +136,7 @@ hardprobe(void)
if (debug)
printf(" ", i&0x7f);
 #endif
-   free(dip, 0);
+   free(dip, sizeof(*dip));
break;
}
 
@@ -310,7 +310,7 @@ cdprobe(void)
 #if 0
if (bios_getdiskinfo(cddev, >bios_info)) {
printf(" ");  /* XXX */
-   free(dip, 0);
+   free(dip, sizeof(*dip));
return;
}
 #endif
Index: sys/arch/i386/stand/libsa/softraid_i386.c
===
RCS file: /cvs/src/sys/arch/i386/stand/libsa/softraid_i386.c,v
retrieving revision 1.2
diff -u -p -r1.2 softraid_i386.c
--- sys/arch/i386/stand/libsa/softraid_i386.c   11 Sep 2016 17:52:47 -  
1.2
+++ sys/arch/i386/stand/libsa/softraid_i386.c   8 Dec 2017 14:35:27 -
@@ -300,7 +300,7 @@ srprobe(void)
}
 
explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
-   free(md, 0);
+   free(md, SR_META_SIZE * DEV_BSIZE);
 }
 
 int



Add sizes for free() in the AMD PowerNow! K8 driver

2017-12-08 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in the AMD PowerNow! K8 driver.

Comments? OK?

Index: sys/arch/amd64/amd64/powernow-k8.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/powernow-k8.c,v
retrieving revision 1.26
diff -u -p -r1.26 powernow-k8.c
--- sys/arch/amd64/amd64/powernow-k8.c  8 Sep 2017 05:36:51 -   1.26
+++ sys/arch/amd64/amd64/powernow-k8.c  8 Dec 2017 17:37:02 -
@@ -380,7 +380,7 @@ k8pnow_acpi_pss_changed(struct acpicpu_p
if (needtran)
k8pnow_transition(nstate, curs);
 
-   free(cstate, M_DEVBUF, 0);
+   free(cstate, M_DEVBUF, sizeof(*cstate));
k8pnow_current_state = nstate;
 }
 
@@ -510,5 +510,5 @@ k8_powernow_init(struct cpu_info *ci)
setperf_prio = 1;
return;
}
-   free(cstate, M_DEVBUF, 0);
+   free(cstate, M_DEVBUF, sizeof(*cstate));
 }



Remove unnecessary includes (i386 VIA PadLock driver)

2017-12-08 Thread Frederic Cambus
Hi tech@,

This diff remove unnecessary includes in the i386 version of the
VIA PadLock driver.

Comments? OK?

Index: sys/arch/i386/i386/via.c
===
RCS file: /cvs/src/sys/arch/i386/i386/via.c,v
retrieving revision 1.37
diff -u -p -r1.37 via.c
--- sys/arch/i386/i386/via.c2 May 2017 11:47:49 -   1.37
+++ sys/arch/i386/i386/via.c8 Dec 2017 10:33:39 -
@@ -21,18 +21,9 @@
 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #ifdef CRYPTO
 #include 
@@ -41,17 +32,8 @@
 #include 
 #endif
 
-#include 
-
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 
 #include 
 



Add sizes for free() in the VIA PadLock driver

2017-11-12 Thread Frederic Cambus
Hi tech@,

Add sizes for free() in the VIA PadLock driver.

Comments? OK?

Index: sys/arch/amd64/amd64/via.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/via.c,v
retrieving revision 1.24
diff -u -p -r1.24 via.c
--- sys/arch/amd64/amd64/via.c  14 Oct 2017 04:44:43 -  1.24
+++ sys/arch/amd64/amd64/via.c  12 Nov 2017 20:18:37 -
@@ -144,7 +144,7 @@ viac3_crypto_newsession(u_int32_t *sidp,
return (ENOMEM);
memcpy(ses, sc->sc_sessions, sesn * sizeof(*ses));
explicit_bzero(sc->sc_sessions, sesn * sizeof(*ses));
-   free(sc->sc_sessions, M_DEVBUF, 0);
+   free(sc->sc_sessions, M_DEVBUF, sesn * sizeof(*ses));
sc->sc_sessions = ses;
ses = >sc_sessions[sesn];
sc->sc_nsessions++;
@@ -284,13 +284,13 @@ viac3_crypto_freesession(u_int64_t tid)
 
if (swd->sw_ictx) {
explicit_bzero(swd->sw_ictx, axf->ctxsize);
-   free(swd->sw_ictx, M_CRYPTO_DATA, 0);
+   free(swd->sw_ictx, M_CRYPTO_DATA, axf->ctxsize);
}
if (swd->sw_octx) {
explicit_bzero(swd->sw_octx, axf->ctxsize);
-   free(swd->sw_octx, M_CRYPTO_DATA, 0);
+   free(swd->sw_octx, M_CRYPTO_DATA, axf->ctxsize);
}
-   free(swd, M_CRYPTO_DATA, 0);
+   free(swd, M_CRYPTO_DATA, sizeof(*swd));
}
 
explicit_bzero(>sc_sessions[sesn], sizeof(sc->sc_sessions[sesn]));
@@ -411,7 +411,7 @@ viac3_crypto_encdec(struct cryptop *crp,
 
if (sc->op_buf != NULL) {
explicit_bzero(sc->op_buf, crd->crd_len);
-   free(sc->op_buf, M_DEVBUF, 0);
+   free(sc->op_buf, M_DEVBUF, crd->crd_len);
sc->op_buf = NULL;
}
 



Remove the no longer true CAVEATS section in rasops.9

2017-08-29 Thread Frederic Cambus
Hi tech@,

Remove the CAVEATS section in rasops.9, which no longer holds truth.

Comments? OK?

Index: share/man/man9/rasops.9
===
RCS file: /cvs/src/share/man/man9/rasops.9,v
retrieving revision 1.18
diff -u -p -r1.18 rasops.9
--- share/man/man9/rasops.9 21 Aug 2017 11:49:50 -  1.18
+++ share/man/man9/rasops.9 29 Aug 2017 22:25:52 -
@@ -235,5 +235,3 @@ subsystem was written by
 .An Andrew Doran Aq Mt a...@netbsd.org .
 Display rotation was written by
 .An Christopher Pascoe Aq Mt pas...@openbsd.org .
-.Sh CAVEATS
-Display rotation only works for 16bpp displays.



Re: Update inaccurate comment in rasops(9)

2017-08-21 Thread Frederic Cambus
On Fri, Aug 04, 2017 at 11:31:00PM +0200, Frederic Cambus wrote:

> Update inaccurate comment: rasops_copycols() doesn't use bcopy()
> anymore, but either memmove() or slow_bcopy().
> 
> Comments? OK?

Ping. Anyone?

> Index: sys/dev/rasops/rasops.c
> ===
> RCS file: /cvs/src/sys/dev/rasops/rasops.c,v
> retrieving revision 1.45
> diff -u -p -r1.45 rasops.c
> --- sys/dev/rasops/rasops.c   16 May 2017 02:22:51 -  1.45
> +++ sys/dev/rasops/rasops.c   1 Aug 2017 21:32:14 -
> @@ -660,8 +660,8 @@ rasops_copyrows(void *cookie, int src, i
>  /*
>   * Copy columns. This is slow, and hard to optimize due to alignment,
>   * and the fact that we have to copy both left->right and right->left.
> - * We simply cop-out here and use bcopy(), since it handles all of
> - * these cases anyway.
> + * We simply cop-out here and use either memmove() or slow_bcopy(),
> + * since they handle all of these cases anyway.
>   */
>  int
>  rasops_copycols(void *cookie, int row, int src, int dst, int num)



Document the RI_ROTATE_CCW flag in rasops.9

2017-08-21 Thread Frederic Cambus
Hi tech@,

Document the newly introduced RI_ROTATE_CCW flag.

Comments? OK?

Index: share/man/man9/rasops.9
===
RCS file: /cvs/src/share/man/man9/rasops.9,v
retrieving revision 1.17
diff -u -p -r1.17 rasops.9
--- share/man/man9/rasops.9 18 Jan 2017 20:07:40 -  1.17
+++ share/man/man9/rasops.9 21 Aug 2017 09:33:00 -
@@ -153,6 +153,8 @@ Center the text area.
 .\" Cursor is currently clipped
 .It RI_ROTATE_CW
 Rotate the text display quarter clockwise.
+.It RI_ROTATE_CCW
+Rotate the text display quarter counter-clockwise.
 .It RI_CFGDONE
 .Fn rasops_reconfig
 completed successfully



  1   2   >