Re: usb mem wait

2010-11-22 Thread Ted Unangst
On Mon, Nov 22, 2010 at 12:06 AM, Jacob Meuser jake...@sdf.lonestar.org
wrote:
 On Sun, Nov 21, 2010 at 06:47:01PM -0500, Ted Unangst wrote:
 instead of faking an assertwaitok check, let's use the real thing.  this
 is almost the opposite of progress on the whole bluetooth issue, but it
 shortens the stack trace considerably.  the curproc check isn't terribly
 accurate, either, so it misses bugs.

 i don't see any reason to avoid sleeping once we've decided that waiting
 is ok, so i changed that too.

 where was it decided that waiting is ok?  because it's not supposed to
 be interrupt context?  I dunno about that.  this function makes it into
 a lot of places, and I don't see any that wait.

Well, it is waiting!  running btconfig up will panic later down the
chain, with this function on the call stack.  Sorry, don't have the
exact trace handy.  And it's already checking for curproc.  That's
just a broken test for the same thing.



 Index: usb_mem.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/usb/usb_mem.c,v
 retrieving revision 1.22
 diff -u -r1.22 usb_mem.c
 --- usb_mem.c 29 Sep 2010 20:06:38 -  1.22
 +++ usb_mem.c 21 Nov 2010 23:15:26 -
 @@ -98,12 +98,7 @@
   DPRINTFN(5, (usb_block_allocmem: size=%lu align=%lu\n,
(u_long)size, (u_long)align));

 -#ifdef DIAGNOSTIC
 - if (!curproc) {
 - printf(usb_block_allocmem: in interrupt context,
size=%lu\n,
 - (unsigned long) size);
 - }
 -#endif
 + assertwaitok();

   s = splusb();
   /* First check the free list. */
 @@ -120,17 +115,8 @@
   }
   splx(s);

 -#ifdef DIAGNOSTIC
 - if (!curproc) {
 - printf(usb_block_allocmem: in interrupt context,
failed\n);
 - return (USBD_NOMEM);
 - }
 -#endif
 -
   DPRINTFN(6, (usb_block_allocmem: no free\n));
 - p = malloc(sizeof *p, M_USB, M_NOWAIT);
 - if (p == NULL)
 - return (USBD_NOMEM);
 + p = malloc(sizeof *p, M_USB, M_WAITOK);

   p-tag = tag;
   p-size = size;

 --
 jake...@sdf.lonestar.org
 SDF Public Access UNIX System - http://sdf.lonestar.org



ksh: delete-key friends

2010-11-22 Thread Martin Pieuchot
When using ksh in emacs mode you need to bind some of the special keys
(delete, home, end, up and down) in order to make them work as intended.
Example for a xterm:

bind '^XF' = end-of-line
bind '^XH' = beginning-of-line

But if you want to use the same key from the console or the `delete key`
it becomes much more complicated. This is related to the fact that ksh
binds at most 3 characters when most of the terminals uses 4 characters.
So you end up with some lines in your kshrc like:

bind -m '^[[3'='^X'
bind '^X~'=delete-char-forward
...

The funny part is that even if your binding work you end up with a '~'
character printed for some keys. If you want more details you can have
a look at  nicm@'s explanation:
http://marc.info/?l=openbsd-miscm=125542186700477

The patch below is adapted from a Debian pdksh patch. It adds the two
xterm bindings for home/end as default (they are not more than 3 chars)
and a way to handle the 4-characters bindings ending with a '~'.
To do the later we use a mask on the function definition to know if we
should eat a '~' or not. Yeah its a hack but is there any other case
where a 4-characters binding is needed ?

With this patch applied I don't need any tweak on my vaio or my ibook
for both X and console.

Comments?

Martin

Index: emacs.c
===
RCS file: /home/aer/cvs/src/bin/ksh/emacs.c,v
retrieving revision 1.42
diff -u -p -r1.42 emacs.c
--- emacs.c 2 Jun 2009 06:47:47 -   1.42
+++ emacs.c 22 Nov 2010 13:16:05 -
@@ -303,6 +303,18 @@ static struct x_defbindings const x_defb
{ XFUNC_next_com,   2,  'B'  },
{ XFUNC_mv_forw,2,  'C'  },
{ XFUNC_mv_back,2,  'D'  },
+   { XFUNC_mv_end, 2,  'F'  },
+   { XFUNC_mv_begin,   2,  'H'  },
+   /* These for home/end/delete/up  down keys. The mask is used
+* to deal with 4-characters sequences send by some terminals.
+*/
+   { XFUNC_mv_begin | 0x80,2,  '1'  },
+   { XFUNC_mv_begin | 0x80,2,  '7'  },
+   { XFUNC_mv_end | 0x80,  2,  '4'  },
+   { XFUNC_mv_end | 0x80,  2,  '8'  },
+   { XFUNC_del_char | 0x80,2,  '3'  },
+   { XFUNC_prev_com | 0x80,2,  '5'  },
+   { XFUNC_next_com | 0x80,2,  '6'  },
 };
 
 int
@@ -360,6 +372,13 @@ x_emacs(char *buf, size_t len)
f = x_curprefix == -1 ? XFUNC_insert :
x_tab[x_curprefix][cCHARMASK];
 
+   /* Is it a 4-characters control sequence ending with a '~'? */
+   if (f  0x80) {
+   f = 0x7F;
+   if ((i = x_e_getc()) != '~')
+   x_e_ungetc(i);
+   }
+
if (macroptr  f == XFUNC_ins_string)
f = XFUNC_insert;
 
@@ -1288,14 +1307,19 @@ x_mapout(int c)
 static void
 x_print(int prefix, int key)
 {
+   int f = x_tab[prefix][key];
+
if (prefix == 1)
shprintf(%s, x_mapout(x_prefix1));
if (prefix == 2)
shprintf(%s, x_mapout(x_prefix2));
-   shprintf(%s = , x_mapout(key));
-   if (x_tab[prefix][key] != XFUNC_ins_string)
-   shprintf(%s\n, x_ftab[x_tab[prefix][key]].xf_name);
-   else
+
+   /* Restore character '~' when printing a binding. */
+   shprintf(%s%s = , x_mapout(key), (f  0x80) ? ~ : );
+
+   if (META(f) != XFUNC_ins_string)
+   shprintf(%s\n, x_ftab[META(f)].xf_name); 
+   else 
shprintf('%s'\n, x_atab[prefix][key]);
 }
 
@@ -1308,6 +1332,7 @@ x_bind( const char *a1, const char *a2,
int prefix, key;
char *sp = NULL;
char *m1, *m2;
+   int hastilde = 0;
 
if (x_tab == NULL) {
bi_errorf(cannot bind, not a tty);
@@ -1346,6 +1371,19 @@ x_bind( const char *a1, const char *a2,
else
break;
}
+
+   /* Only allow 4-characters binding if they ends with a '~'. */
+   if (strnlen(m2, 4) == 4) {
+   if (m2[3] == '~'  m2[4] == '\0') {
+   hastilde = 1;
+   } else {
+   bi_errorf(key sequence too long);
+   afree(m2, ATEMP);
+
+   return (1);
+   }
+   }
+   
afree(m2, ATEMP);
 
if (a2 == NULL) {
@@ -1377,7 +1415,7 @@ x_bind( const char *a1, const char *a2,
 
if (x_tab[prefix][key] == XFUNC_ins_string  x_atab[prefix][key])
afree((void *)x_atab[prefix][key], AEDIT);
-   x_tab[prefix][key] = f;
+   x_tab[prefix][key] =  f | (hastilde ? 0x80 : 0);
x_atab[prefix][key] = sp;
 
/* Track what the user has bound so x_emacs_keys() won't toast things */



cleanup pckbc_cnattach

2010-11-22 Thread Alexandr Shadchin
removed slot argument of function pckbc_cnattach
because it is always PCKBC_KBD_SLOT

-- 
Alexandr Shadchin

Index: arch/alpha/alpha/api_up1000.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/api_up1000.c,v
retrieving revision 1.10
diff -u -p -r1.10 api_up1000.c
--- arch/alpha/alpha/api_up1000.c   26 Oct 2009 20:17:26 -  1.10
+++ arch/alpha/alpha/api_up1000.c   22 Nov 2010 12:48:43 -
@@ -130,8 +130,7 @@ api_up1000_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(icp-ic_iot, IO_KBD, KBCMDP,
-   PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(icp-ic_iot, IO_KBD, KBCMDP, 0);
 
if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
CTB_TURBOSLOT_TYPE_ISA)
Index: arch/alpha/alpha/dec_1000a.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_1000a.c,v
retrieving revision 1.6
diff -u -p -r1.6 dec_1000a.c
--- arch/alpha/alpha/dec_1000a.c16 Jul 2008 20:03:20 -  1.6
+++ arch/alpha/alpha/dec_1000a.c22 Nov 2010 12:48:44 -
@@ -201,7 +201,7 @@ dec_1000a_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, 0);
 
/*
 * AlphaServer 1000s have a firmware bug whereby the
Index: arch/alpha/alpha/dec_2100_a50.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_2100_a50.c,v
retrieving revision 1.20
diff -u -p -r1.20 dec_2100_a50.c
--- arch/alpha/alpha/dec_2100_a50.c 24 Jul 2008 16:34:22 -  1.20
+++ arch/alpha/alpha/dec_2100_a50.c 22 Nov 2010 12:48:44 -
@@ -150,8 +150,7 @@ dec_2100_a50_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(acp-ac_iot, IO_KBD, KBCMDP,
-   PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(acp-ac_iot, IO_KBD, KBCMDP, 0);
 
if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
CTB_TURBOSLOT_TYPE_ISA)
Index: arch/alpha/alpha/dec_550.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_550.c,v
retrieving revision 1.12
diff -u -p -r1.12 dec_550.c
--- arch/alpha/alpha/dec_550.c  26 Oct 2009 20:17:26 -  1.12
+++ arch/alpha/alpha/dec_550.c  22 Nov 2010 12:48:44 -
@@ -131,8 +131,7 @@ dec_550_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(ccp-cc_iot, IO_KBD, KBCMDP,
-   PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(ccp-cc_iot, IO_KBD, KBCMDP, 0);
 
if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
CTB_TURBOSLOT_TYPE_ISA)
Index: arch/alpha/alpha/dec_6600.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_6600.c,v
retrieving revision 1.12
diff -u -p -r1.12 dec_6600.c
--- arch/alpha/alpha/dec_6600.c 26 Oct 2009 20:17:26 -  1.12
+++ arch/alpha/alpha/dec_6600.c 22 Nov 2010 12:48:44 -
@@ -153,8 +153,7 @@ dec_6600_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(tsp-pc_iot, IO_KBD, KBCMDP,
-   PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(tsp-pc_iot, IO_KBD, KBCMDP, 0);
 
if (CTB_TURBOSLOT_TYPE(ctbslot) ==
CTB_TURBOSLOT_TYPE_ISA)
Index: arch/alpha/alpha/dec_axppci_33.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_axppci_33.c,v
retrieving revision 1.21
diff -u -p -r1.21 dec_axppci_33.c
--- arch/alpha/alpha/dec_axppci_33.c30 Jul 2009 21:39:13 -  1.21
+++ arch/alpha/alpha/dec_axppci_33.c22 Nov 2010 12:48:44 -
@@ -173,8 +173,7 @@ dec_axppci_33_cons_init()
 #if NPCKBD  0
/* display console ... */
/* XXX */
-   (void) pckbc_cnattach(lcp-lc_iot, IO_KBD, KBCMDP,
-   PCKBC_KBD_SLOT, 0);
+   (void) pckbc_cnattach(lcp-lc_iot, IO_KBD, KBCMDP, 0);
 
if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
CTB_TURBOSLOT_TYPE_ISA)
Index: arch/alpha/alpha/dec_eb164.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/dec_eb164.c,v
retrieving revision 1.17
diff -u -p -r1.17 dec_eb164.c
--- arch/alpha/alpha/dec_eb164.c26 Oct 2009 20:17:26 -  1.17
+++ arch/alpha/alpha/dec_eb164.c22 Nov 2010 12:48:44 -
@@ -125,8 +125,7 

Re: cleanup pckbc_cnattach

2010-11-22 Thread Kenneth R Westerback
On Mon, Nov 22, 2010 at 10:09:31PM +0500, Alexandr Shadchin wrote:
 removed slot argument of function pckbc_cnattach
 because it is always PCKBC_KBD_SLOT
 
 -- 
 Alexandr Shadchin

Seems reasonable to me, but this would be something miod@ will have to
comment on in case he has evil plans to use other values ...

 Ken

 
 Index: arch/alpha/alpha/api_up1000.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/api_up1000.c,v
 retrieving revision 1.10
 diff -u -p -r1.10 api_up1000.c
 --- arch/alpha/alpha/api_up1000.c 26 Oct 2009 20:17:26 -  1.10
 +++ arch/alpha/alpha/api_up1000.c 22 Nov 2010 12:48:43 -
 @@ -130,8 +130,7 @@ api_up1000_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(icp-ic_iot, IO_KBD, KBCMDP,
 - PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(icp-ic_iot, IO_KBD, KBCMDP, 0);
  
   if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
   CTB_TURBOSLOT_TYPE_ISA)
 Index: arch/alpha/alpha/dec_1000a.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/dec_1000a.c,v
 retrieving revision 1.6
 diff -u -p -r1.6 dec_1000a.c
 --- arch/alpha/alpha/dec_1000a.c  16 Jul 2008 20:03:20 -  1.6
 +++ arch/alpha/alpha/dec_1000a.c  22 Nov 2010 12:48:44 -
 @@ -201,7 +201,7 @@ dec_1000a_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, 0);
  
   /*
* AlphaServer 1000s have a firmware bug whereby the
 Index: arch/alpha/alpha/dec_2100_a50.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/dec_2100_a50.c,v
 retrieving revision 1.20
 diff -u -p -r1.20 dec_2100_a50.c
 --- arch/alpha/alpha/dec_2100_a50.c   24 Jul 2008 16:34:22 -  1.20
 +++ arch/alpha/alpha/dec_2100_a50.c   22 Nov 2010 12:48:44 -
 @@ -150,8 +150,7 @@ dec_2100_a50_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(acp-ac_iot, IO_KBD, KBCMDP,
 - PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(acp-ac_iot, IO_KBD, KBCMDP, 0);
  
   if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
   CTB_TURBOSLOT_TYPE_ISA)
 Index: arch/alpha/alpha/dec_550.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/dec_550.c,v
 retrieving revision 1.12
 diff -u -p -r1.12 dec_550.c
 --- arch/alpha/alpha/dec_550.c26 Oct 2009 20:17:26 -  1.12
 +++ arch/alpha/alpha/dec_550.c22 Nov 2010 12:48:44 -
 @@ -131,8 +131,7 @@ dec_550_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(ccp-cc_iot, IO_KBD, KBCMDP,
 - PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(ccp-cc_iot, IO_KBD, KBCMDP, 0);
  
   if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
   CTB_TURBOSLOT_TYPE_ISA)
 Index: arch/alpha/alpha/dec_6600.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/dec_6600.c,v
 retrieving revision 1.12
 diff -u -p -r1.12 dec_6600.c
 --- arch/alpha/alpha/dec_6600.c   26 Oct 2009 20:17:26 -  1.12
 +++ arch/alpha/alpha/dec_6600.c   22 Nov 2010 12:48:44 -
 @@ -153,8 +153,7 @@ dec_6600_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(tsp-pc_iot, IO_KBD, KBCMDP,
 - PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(tsp-pc_iot, IO_KBD, KBCMDP, 0);
  
   if (CTB_TURBOSLOT_TYPE(ctbslot) ==
   CTB_TURBOSLOT_TYPE_ISA)
 Index: arch/alpha/alpha/dec_axppci_33.c
 ===
 RCS file: /cvs/src/sys/arch/alpha/alpha/dec_axppci_33.c,v
 retrieving revision 1.21
 diff -u -p -r1.21 dec_axppci_33.c
 --- arch/alpha/alpha/dec_axppci_33.c  30 Jul 2009 21:39:13 -  1.21
 +++ arch/alpha/alpha/dec_axppci_33.c  22 Nov 2010 12:48:44 -
 @@ -173,8 +173,7 @@ dec_axppci_33_cons_init()
  #if NPCKBD  0
   /* display console ... */
   /* XXX */
 - (void) pckbc_cnattach(lcp-lc_iot, IO_KBD, KBCMDP,
 - PCKBC_KBD_SLOT, 0);
 + (void) pckbc_cnattach(lcp-lc_iot, IO_KBD, KBCMDP, 0);
  
   if (CTB_TURBOSLOT_TYPE(ctb-ctb_turboslot) ==
   CTB_TURBOSLOT_TYPE_ISA)
 Index: arch/alpha/alpha/dec_eb164.c
 ===
 RCS file: 

Re: small cleanup xf86-input-mouse

2010-11-22 Thread Miod Vallat
 Now SunMouse works through wsmouse(sunms add miod@ 20 May 2009)
 so we can remove our patch to SunMouse for xf86-input-mouse.

I am not sure this is something we want to do. This code is third-party,
and it does not hurt to keep the ability to run on older kernels.

Miod



Re: small cleanup xf86-input-mouse

2010-11-22 Thread Matthieu Herrb
On Mon, Nov 22, 2010 at 06:28:01PM +, Miod Vallat wrote:
  Now SunMouse works through wsmouse(sunms add miod@ 20 May 2009)
  so we can remove our patch to SunMouse for xf86-input-mouse.
 
 I am not sure this is something we want to do. This code is third-party,
 and it does not hurt to keep the ability to run on older kernels.

The sunmouse protocol decoder is a local addition (it was added by
millert@ back in 2002 and never merged upstreams. 

http://www.openbsd.org/cgi-bin/cvsweb/XF4/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c.diff?r1=1.4;r2=1.5

-- 
Matthieu Herrb



Re: small cleanup xf86-input-mouse

2010-11-22 Thread Miod Vallat
   Now SunMouse works through wsmouse(sunms add miod@ 20 May 2009)
   so we can remove our patch to SunMouse for xf86-input-mouse.
  
  I am not sure this is something we want to do. This code is third-party,
  and it does not hurt to keep the ability to run on older kernels.
 
 The sunmouse protocol decoder is a local addition (it was added by
 millert@ back in 2002 and never merged upstreams. 
 
 http://www.openbsd.org/cgi-bin/cvsweb/XF4/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c.diff?r1=1.4;r2=1.5

Ah! Then my objection no longer stands.

Miod



All It Takes Is 13 Clicks And 12 Minutes A Day To Run - Guaranteed

2010-11-22 Thread Auto Traffic
Profiting 112 Minutes From NOW
$4,191 In First 7 Days
$219,249 Last Month
Only 234 Copies Available - If You Don't Get Results, You'll Get A Full Refund
AND $100

Download Now : http://business-page.us/change-your-life-become-rich.html



Re: usb mem wait

2010-11-22 Thread Jacob Meuser
On Mon, Nov 22, 2010 at 09:09:17AM -0500, Ted Unangst wrote:
 On Mon, Nov 22, 2010 at 12:06 AM, Jacob Meuser jake...@sdf.lonestar.org
 wrote:
  On Sun, Nov 21, 2010 at 06:47:01PM -0500, Ted Unangst wrote:
  instead of faking an assertwaitok check, let's use the real thing.  this
  is almost the opposite of progress on the whole bluetooth issue, but it
  shortens the stack trace considerably.  the curproc check isn't terribly
  accurate, either, so it misses bugs.
 
  i don't see any reason to avoid sleeping once we've decided that waiting
  is ok, so i changed that too.
 
  where was it decided that waiting is ok?  because it's not supposed to
  be interrupt context?  I dunno about that.  this function makes it into
  a lot of places, and I don't see any that wait.
 
 Well, it is waiting!  running btconfig up will panic later down the
 chain, with this function on the call stack.  Sorry, don't have the
 exact trace handy.  And it's already checking for curproc.  That's
 just a broken test for the same thing.

I don't understand the purpose of this change.  do you plan to change
the rest of the stack (usb_allocmem, *hci_allocm, etc) that calls
this function to wait for memory?  are you sure the only reason for
the M_NOWAITs is to not wait in interrupt context?  I'm not saying
this change is necessarily wrong, but by itself, it raises questions.

 
 
  Index: usb_mem.c
  ===
  RCS file: /home/tedu/cvs/src/sys/dev/usb/usb_mem.c,v
  retrieving revision 1.22
  diff -u -r1.22 usb_mem.c
  --- usb_mem.c 29 Sep 2010 20:06:38 -  1.22
  +++ usb_mem.c 21 Nov 2010 23:15:26 -
  @@ -98,12 +98,7 @@
DPRINTFN(5, (usb_block_allocmem: size=%lu align=%lu\n,
 (u_long)size, (u_long)align));
 
  -#ifdef DIAGNOSTIC
  - if (!curproc) {
  - printf(usb_block_allocmem: in interrupt context,
 size=%lu\n,
  - (unsigned long) size);
  - }
  -#endif
  + assertwaitok();
 
s = splusb();
/* First check the free list. */
  @@ -120,17 +115,8 @@
}
splx(s);
 
  -#ifdef DIAGNOSTIC
  - if (!curproc) {
  - printf(usb_block_allocmem: in interrupt context,
 failed\n);
  - return (USBD_NOMEM);
  - }
  -#endif
  -
DPRINTFN(6, (usb_block_allocmem: no free\n));
  - p = malloc(sizeof *p, M_USB, M_NOWAIT);
  - if (p == NULL)
  - return (USBD_NOMEM);
  + p = malloc(sizeof *p, M_USB, M_WAITOK);
 
p-tag = tag;
p-size = size;
 
  --
  jake...@sdf.lonestar.org
  SDF Public Access UNIX System - http://sdf.lonestar.org

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Re: update pms driver

2010-11-22 Thread Nicholas Marriott
Hi Alexandr

This works fine for me with both with X and wsmoused.

A few things:

- Did you deliberately remove WSMOUSEIO_SRES?

- Do we know what the XFree86 bug was and is it now fixed? Or do the
  PMS_PS2_XNEG/YNEG flags make the bounding unnecessary?

- dz = (char)sc-packet[3]; -- shouldn't this be (signed char)?

- So we now call wsmouse_input even if the buttons haven't changed. This
  is fine, right?

I take it the overall aim of this is to make it easier to add additional
mice types in future?

Cheers


On Thu, Nov 18, 2010 at 12:11:09AM +0500, Alexandr Shadchin wrote:
 Add a common interface for various devices
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.14
 diff -u -p -r1.14 pms.c
 --- pms.c 15 Nov 2010 20:25:31 -  1.14
 +++ pms.c 17 Nov 2010 18:23:35 -
 @@ -40,6 +40,20 @@
  
  #define DEVNAME(sc)  ((sc)-sc_dev.dv_xname)
  
 +struct pms_softc;
 +
 +struct pms_protocol {
 + int type;
 +#define PMS_STANDARD 0
 +#define PMS_INTELLI  1
 + int packetsize;
 + int (*enable)(struct pms_softc *);
 + int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
 + int (*sync)(struct pms_softc *, int);
 + void (*proc)(struct pms_softc *);
 + void (*disable)(struct pms_softc *);
 +};
 +
  struct pms_softc {   /* driver status information */
   struct device sc_dev;
  
 @@ -52,14 +66,38 @@ struct pms_softc {/* driver status inf
  #define PMS_STATE_SUSPENDED  2
  
   int poll;
 - int intelli;
   int inputstate;
 - u_int buttons, oldbuttons;  /* mouse button status */
 - signed char dx, dy;
 +
 + struct pms_protocol protocol;
 +
 + unsigned char packet[8];
  
   struct device *sc_wsmousedev;
  };
  
 +#define PMS_BUTTON1DOWN  0x0001  /* left */
 +#define PMS_BUTTON2DOWN  0x0002  /* middle */
 +#define PMS_BUTTON3DOWN  0x0004  /* right */
 +
 +static const u_int butmap[8] = {
 + 0,
 + PMS_BUTTON1DOWN,
 + PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON2DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
 + PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
 +};
 +
 +/* PS/2 mouse data packet */
 +#define PMS_PS2_BUTTONSMASK  0x07
 +#define PMS_PS2_BUTTON1  0x01/* left */
 +#define PMS_PS2_BUTTON2  0x04/* middle */
 +#define PMS_PS2_BUTTON3  0x02/* right */
 +#define PMS_PS2_XNEG 0x10
 +#define PMS_PS2_YNEG 0x20
 +
  int  pmsprobe(struct device *, void *, void *);
  void pmsattach(struct device *, struct device *, void *);
  int  pmsactivate(struct device *, int);
 @@ -81,7 +119,11 @@ int   pms_reset(struct pms_softc *);
  int  pms_dev_enable(struct pms_softc *);
  int  pms_dev_disable(struct pms_softc *);
  
 -int  pms_setintellimode(struct pms_softc *sc);
 +int  pms_enable_intelli(struct pms_softc *);
 +
 +int  pms_ioctl_mouse(struct pms_softc *, u_long, caddr_t, int, struct proc 
 *);
 +int  pms_sync_mouse(struct pms_softc *, int);
 +void pms_proc_mouse(struct pms_softc *);
  
  struct cfattach pms_ca = {
   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
 @@ -98,6 +140,27 @@ const struct wsmouse_accessops pms_acces
   pms_disable,
  };
  
 +const struct pms_protocol pms_mouse[] = {
 + /* Generic PS/2 mouse */
 + {
 + PMS_STANDARD, 3,
 + NULL,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + },
 + /* Microsoft IntelliMouse */
 + {
 + PMS_INTELLI, 4,
 + pms_enable_intelli,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + }
 +};
 +
  int
  pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int 
 resplen)
  {
 @@ -208,7 +271,7 @@ pms_dev_disable(struct pms_softc *sc)
  }
  
  int
 -pms_setintellimode(struct pms_softc *sc)
 +pms_enable_intelli(struct pms_softc *sc)
  {
   static const int rates[] = {200, 100, 80};
   u_char resp;
 @@ -224,6 +287,65 @@ pms_setintellimode(struct pms_softc *sc)
  }
  
  int
 +pms_ioctl_mouse(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
 +struct proc *p)
 +{
 + switch (cmd) {
 + case WSMOUSEIO_GTYPE:
 + *(u_int *)data = WSMOUSE_TYPE_PS2;
 + break;
 + default:
 + return (-1);
 + }
 + return (0);
 +}
 +
 +int
 +pms_sync_mouse(struct pms_softc *sc, int data)
 +{
 + if (sc-inputstate != 0)
 + return (0);
 +
 + switch (sc-protocol.type) {
 + case PMS_STANDARD:
 + if ((data  0xc0) != 0)
 + return (-1);
 + break;
 + case PMS_INTELLI:
 + if ((data  0x08) != 0x08)
 + 

Inalámbricos Panasonic

2010-11-22 Thread DigitalesNet
USD97PANASONIC  
   KX-TG3612 Funciones:  Flash Teclado,
Expandible y Altavos en el handie  /
Pantalla iluminada / Comunicacion en 4 vias 
Intercomunicador entre handies / Agenda Compartida  
   5 tonos y 5 melodias Baterias recargables AAA
 / Frecuencia 2.48 GHZ / Doble Handie   USD 
  82   PANASONIC  KX-TG402 1 6.0
Funciones:  Flash / Teclado Con contestador
digital / Tegnologia  DECT 6.0 Expandible
hasta 6 handies / 18 minutos  de grabacion
en el contestador digital / Altavos  en el
handie Pantalla iluminada / Comunicacion  en
4 vias / Baterias recargables AAA   USD125  
PANASONIC  KX-TG403 2 6.0 Teleacute;fono   
  inalambrico Digital Explandible con
contestador  / Disfrute de la calidad del
sonido a distancias  largas / Gran display
blanco con luz y teclado  luminoso /
Parlante, Bloqueo de llamadas, Modo 
silencioso /