New kernel option GDBSPEED (as in CONSPEED)?

2002-05-27 Thread Nick Hibma


CONSPEED is used for both console and gdb. This is a bit awkward because
it means that I have to run my kernel console on 9600 baud on my
diskless box. The attached patch fixes this by introducing another
variable GDBSPEED.

The patch makes the default for GDBSPEED 9600, so anyone who uses a
higher speed would need to set the variable to something sensible
afterwards. Would that require an entry in UPDATING?

Is there any documentation that needs to be updated because of this
change (I couldn't find anything that mentioned CONSPEED wrt gdb in
either src/ or doc/)


Any objections?

Nick
-- 
[EMAIL PROTECTED]  http://www.van-laarhoven.org/
[EMAIL PROTECTED]http://www.etla.net/~n_hibma/



Index: sys/conf/options.i386
===
RCS file: /home/ncvs/src/sys/conf/options.i386,v
retrieving revision 1.170
diff -u -r1.170 options.i386
--- sys/conf/options.i386   16 May 2002 21:23:40 -  1.170
+++ sys/conf/options.i386   23 May 2002 19:38:42 -
@@ -15,6 +15,7 @@
 AUTO_EOI_1 opt_auto_eoi.h
 AUTO_EOI_2 opt_auto_eoi.h
 CONSPEED   opt_comconsole.h
+GDBSPEED   opt_comconsole.h
 I586_PMC_GUPROFopt_i586_guprof.h
 WLCACHEopt_wavelan.h
 WLDEBUGopt_wavelan.h
Index: sys/conf/options.pc98
===
RCS file: /home/ncvs/src/sys/conf/options.pc98,v
retrieving revision 1.145
diff -u -r1.145 options.pc98
--- sys/conf/options.pc98   19 May 2002 13:18:10 -  1.145
+++ sys/conf/options.pc98   23 May 2002 19:38:58 -
@@ -15,6 +15,7 @@
 AUTO_EOI_1 opt_auto_eoi.h
 AUTO_EOI_2 opt_auto_eoi.h
 CONSPEED   opt_comconsole.h
+GDBSPEED   opt_comconsole.h
 I586_PMC_GUPROFopt_i586_guprof.h
 WLCACHEopt_wavelan.h
 WLDEBUGopt_wavelan.h
Index: sys/dev/sio/sio.c
===
RCS file: /home/ncvs/src/sys/dev/sio/sio.c,v
retrieving revision 1.374
diff -u -r1.374 sio.c
--- sys/dev/sio/sio.c   26 Apr 2002 20:24:10 -  1.374
+++ sys/dev/sio/sio.c   26 May 2002 10:25:02 -
@@ -332,9 +332,7 @@
 static volatile speed_tcomdefaultrate = CONSPEED;
 static u_long  comdefaultrclk = DEFAULT_RCLK;
 SYSCTL_ULONG(_machdep, OID_AUTO, conrclk, CTLFLAG_RW, comdefaultrclk, 0, );
-#ifdef __alpha__
-static volatile speed_tgdbdefaultrate = CONSPEED;
-#endif
+static volatile speed_tgdbdefaultrate = GDBSPEED;
 static u_int   com_events; /* input chars + weighted output completions */
 static Port_t  siocniobase;
 #ifndef __alpha__
@@ -418,6 +416,32 @@
0, 0, sysctl_machdep_comdefaultrate, I, );
 /* TUNABLE_INT(machdep.conspeed, comdefaultrate); */
 
+#ifndef __alpha__
+/*
+ * Handle sysctl read/write requests for serial gdb speed
+ */
+
+static int
+sysctl_machdep_gdbdefaultrate(SYSCTL_HANDLER_ARGS)
+{
+   int error;
+   speed_t newspeed;
+
+   newspeed = gdbdefaultrate;
+
+   error = sysctl_handle_opaque(oidp, newspeed, sizeof newspeed, req);
+   if (error || !req-newptr)
+   return (error);
+
+   gdbdefaultrate = newspeed;
+
+   return 0;
+}
+
+SYSCTL_PROC(_machdep, OID_AUTO, gdbspeed, CTLTYPE_INT | CTLFLAG_RW,
+   0, 0, sysctl_machdep_gdbdefaultrate, I, );
+#endif
+
 #define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit))
 #define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev)  ~(bit))
 
@@ -3126,13 +3150,17 @@
Port_t  iobase;
int s;
struct siocnstate   sp;
+   speed_t speed;
 
-   if (minor(dev) == siogdbunit)
+   if (minor(dev) == siogdbunit) {
iobase = siogdbiobase;
-   else
+   speed = gdbdefaultrate;
+   } else {
iobase = siocniobase;
+   speed = comdefaultrate;
+   }
s = spltty();
-   siocnopen(sp, iobase, comdefaultrate);
+   siocnopen(sp, iobase, speed);
if (inb(iobase + com_lsr)  LSR_RXRDY)
c = inb(iobase + com_data);
else
@@ -3151,13 +3179,17 @@
Port_t  iobase;
int s;
struct siocnstate   sp;
+   speed_t speed;
 
-   if (minor(dev) == siogdbunit)
+   if (minor(dev) == siogdbunit) {
iobase = siogdbiobase;
-   else
+   speed = gdbdefaultrate;
+   } else {
iobase = siocniobase;
+   speed = comdefaultrate;
+   }
s = spltty();
-   siocnopen(sp, iobase, comdefaultrate);
+   siocnopen(sp, iobase, speed);
while (!(inb(iobase + com_lsr)  LSR_RXRDY))

Re: New kernel option GDBSPEED (as in CONSPEED)?

2002-05-27 Thread Bruce Evans

On Mon, 27 May 2002, Nick Hibma wrote:

 CONSPEED is used for both console and gdb. This is a bit awkward because
 it means that I have to run my kernel console on 9600 baud on my
 diskless box. The attached patch fixes this by introducing another
 variable GDBSPEED.

 The patch makes the default for GDBSPEED 9600, so anyone who uses a
 higher speed would need to set the variable to something sensible
 afterwards. Would that require an entry in UPDATING?

GDBSPEED should default to CONSPEED so that people who don't need it to
be different won't have to know about it.  The speed should also be the
one given by CONSPEED when the gdb port is the same as the console port.

 Is there any documentation that needs to be updated because of this
 change (I couldn't find anything that mentioned CONSPEED wrt gdb in
 either src/ or doc/)

I don't know of any.

 Any objections?

Quite a few.  Ones related to the above, plus ones involving the patch
being too large for a hack and having style bugs.  Comments on the patch
in private mail.

Bruce


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message