tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Patching wscons_keydesc at runtime



On Fri, Aug 04, 2017 at 02:46:15 +0300, Valery Ushakov wrote:
> Date: Fri, 4 Aug 2017 02:46:15 +0300
> From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
> Subject: Re: Patching wscons_keydesc at runtime
> To: tech-kern%netbsd.org@localhost
> Mail-Followup-To: tech-kern%netbsd.org@localhost
> 
> On Fri, Aug 04, 2017 at 01:38:38 +0200, Emmanuel Dreyfus wrote:
> 
> > Emmanuel Dreyfus <manu%netbsd.org@localhost> wrote:
> > 
> > > > Unfortunately this breaks hpcsh which initializes console very early
> > > > when malloc is not available, so when you boot with wscons the machine
> > > > wedges.
> > > > 
> > > > I think your change should be reverted for now and a different fix
> > > > developed.
> > > 
> > > Or perhaps it could be just ifdef hpcarm?
> > 
> > What about this change?
> > 
> > Index: sys/dev/hpc/hpckbd.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/dev/hpc/hpckbd.c,v
> > retrieving revision 1.31
> > diff -U4 -r1.31 hpckbd.c
> > --- sys/dev/hpc/hpckbd.c        12 Jun 2017 09:23:39 -0000      1.31
> > +++ sys/dev/hpc/hpckbd.c        3 Aug 2017 23:36:47 -0000
> > @@ -265,15 +265,17 @@
> >                     const keysym_t *map, int mapsize)
> >  {
> >         int i;
> >         const struct wscons_keydesc *desc;
> > +#ifdef hpcarm
> >         static struct wscons_keydesc *ndesc = NULL;
> >  
> >         /* 
> >          * fix keydesc table. Since it is const data, we must 
> > -        * copy it once before changingg it.
> > +        * copy it once before changingg it. That does not work
> > +        * on hpcsh which initialize console before malloc is 
> > +        * available.
> >          */
> > -
> >         if (ndesc == NULL) {
> >                 size_t sz;
> >  
> >                 for (sz = 0; hpckbd_keymapdata.keydesc[sz].name != 0; sz++);
> > @@ -282,14 +284,15 @@
> >                 memcpy(ndesc, hpckbd_keymapdata.keydesc, sz * sizeof(*ndesc));
> >  
> >                 hpckbd_keymapdata.keydesc = ndesc;
> >         }
> > +#endif /* hpcarm */
> >  
> >         desc = hpckbd_keymapdata.keydesc;
> >         for (i = 0; desc[i].name != 0; i++) {
> >                 if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
> > -                       ndesc[i].map = map;
> > -                       ndesc[i].map_size = mapsize;
> > +                       desc[i].map = map;
> > +                       desc[i].map_size = mapsize;
> >                 }
> >         }
> >  
> >         return;
> 
> I think it might be better to just have two copies of the function,
> old and new.  E.g. this patch doesn't restore the unconst hack.
> 
> PS: Also "changingg" has a typo.

Looking closer (it's been a while since I touched low-level sh3
stuff), I think I'll just drop the early consinit() call that hpcsh
does and let main() do it.  That avoids the ugly special case.

-uwe


Home | Main Index | Thread Index | Old Index