2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2004-10-13 05:38:42 +00:00
|
|
|
* Copyright (C) 2003,2004
|
|
|
|
* Hidetoshi Shimokawa. All rights reserved.
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
*
|
2004-10-13 05:38:42 +00:00
|
|
|
* 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
*
|
|
|
|
* This product includes software developed by Hidetoshi Shimokawa.
|
|
|
|
*
|
|
|
|
* 4. Neither the name of the author nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
*
|
2004-10-13 05:38:42 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
*
|
2004-10-13 05:38:42 +00:00
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kdb.h>
|
|
|
|
#include <gdb/gdb.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/cons.h>
|
|
|
|
#include <sys/consio.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/malloc.h>
|
2006-11-06 13:42:10 +00:00
|
|
|
#include <sys/priv.h>
|
2004-10-13 05:38:42 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/ucred.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/dcons/dcons.h>
|
|
|
|
#include <dev/dcons/dcons_os.h>
|
|
|
|
|
|
|
|
#include <ddb/ddb.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
|
|
|
|
#include "opt_dcons.h"
|
2007-05-27 13:58:43 +00:00
|
|
|
#include "opt_kdb.h"
|
|
|
|
#include "opt_gdb.h"
|
|
|
|
#include "opt_ddb.h"
|
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
#ifndef DCONS_POLL_HZ
|
2009-04-06 13:09:02 +00:00
|
|
|
#define DCONS_POLL_HZ 25
|
2004-10-13 05:38:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DCONS_BUF_SIZE
|
|
|
|
#define DCONS_BUF_SIZE (16*1024)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DCONS_FORCE_CONSOLE
|
|
|
|
#define DCONS_FORCE_CONSOLE 0 /* Mostly for FreeBSD-4/DragonFly */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef KLD_MODULE
|
|
|
|
static char bssbuf[DCONS_BUF_SIZE]; /* buf in bss */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* global data */
|
|
|
|
static struct dcons_global dg;
|
|
|
|
struct dcons_global *dcons_conf;
|
|
|
|
static int poll_hz = DCONS_POLL_HZ;
|
|
|
|
|
|
|
|
static struct dcons_softc sc[DCONS_NPORT];
|
|
|
|
|
2011-11-07 15:43:11 +00:00
|
|
|
static SYSCTL_NODE(_kern, OID_AUTO, dcons, CTLFLAG_RD, 0, "Dumb Console");
|
2004-10-13 05:38:42 +00:00
|
|
|
SYSCTL_INT(_kern_dcons, OID_AUTO, poll_hz, CTLFLAG_RW, &poll_hz, 0,
|
|
|
|
"dcons polling rate");
|
|
|
|
|
|
|
|
static int drv_init = 0;
|
|
|
|
static struct callout dcons_callout;
|
|
|
|
struct dcons_buf *dcons_buf; /* for local dconschat */
|
|
|
|
|
|
|
|
static void dcons_timeout(void *);
|
|
|
|
static int dcons_drv_init(int);
|
|
|
|
|
|
|
|
static cn_probe_t dcons_cnprobe;
|
|
|
|
static cn_init_t dcons_cninit;
|
2006-05-26 13:51:38 +00:00
|
|
|
static cn_term_t dcons_cnterm;
|
2004-10-13 05:38:42 +00:00
|
|
|
static cn_getc_t dcons_cngetc;
|
|
|
|
static cn_putc_t dcons_cnputc;
|
2011-12-17 15:08:43 +00:00
|
|
|
static cn_grab_t dcons_cngrab;
|
|
|
|
static cn_ungrab_t dcons_cnungrab;
|
2004-10-13 05:38:42 +00:00
|
|
|
|
2006-05-26 13:51:38 +00:00
|
|
|
CONSOLE_DRIVER(dcons);
|
2004-10-13 05:38:42 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
#if defined(GDB)
|
|
|
|
static gdb_probe_f dcons_dbg_probe;
|
|
|
|
static gdb_init_f dcons_dbg_init;
|
|
|
|
static gdb_term_f dcons_dbg_term;
|
|
|
|
static gdb_getc_f dcons_dbg_getc;
|
|
|
|
static gdb_putc_f dcons_dbg_putc;
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
GDB_DBGPORT(dcons, dcons_dbg_probe, dcons_dbg_init, dcons_dbg_term,
|
2006-05-26 11:54:32 +00:00
|
|
|
dcons_dbg_getc, dcons_dbg_putc);
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
extern struct gdb_dbgport *gdb_cur;
|
|
|
|
#endif
|
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
static tsw_outwakeup_t dcons_outwakeup;
|
|
|
|
|
|
|
|
static struct ttydevsw dcons_ttydevsw = {
|
|
|
|
.tsw_flags = TF_NOPREFIX,
|
|
|
|
.tsw_outwakeup = dcons_outwakeup,
|
|
|
|
};
|
|
|
|
|
Attempt to make break-to-debugger and alternative break-to-debugger more
accessible:
(1) Always compile in support for breaking into the debugger if options
KDB is present in the kernel.
(2) Disable both by default, but allow them to be enabled via tunables
and sysctls debug.kdb.break_to_debugger and
debug.kdb.alt_break_to_debugger.
(3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue
to behave as before -- only now instead of compiling in
break-to-debugger support, they change the default values of the
above sysctls to enable those features by default. Current kernel
configurations should, therefore, continue to behave as expected.
(4) Migrate alternative break-to-debugger state machine logic out of
individual device drivers into centralised KDB code. This has a
number of upsides, but also one downside: it's now tricky to release
sio spin locks when entering the debugger, so we don't. However,
similar logic does not exist in other device drivers, including uart.
(5) dcons requires some special handling; unlike other console types, it
allows overriding KDB's own debugger selection, so we need a new
interface to KDB to allow that to work.
GENERIC kernels in -CURRENT will now support break-to-debugger as long as
appropriate boot/run-time options are set, which should improve the
debuggability of BETA kernels significantly.
MFC after: 3 weeks
Reviewed by: kib, nwhitehorn
Approved by: re (bz)
2011-08-26 21:46:36 +00:00
|
|
|
#if (defined(GDB) || defined(DDB))
|
2004-10-13 05:38:42 +00:00
|
|
|
static int
|
|
|
|
dcons_check_break(struct dcons_softc *dc, int c)
|
|
|
|
{
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
if (c < 0)
|
|
|
|
return (c);
|
|
|
|
|
2007-05-28 02:20:40 +00:00
|
|
|
#ifdef GDB
|
Attempt to make break-to-debugger and alternative break-to-debugger more
accessible:
(1) Always compile in support for breaking into the debugger if options
KDB is present in the kernel.
(2) Disable both by default, but allow them to be enabled via tunables
and sysctls debug.kdb.break_to_debugger and
debug.kdb.alt_break_to_debugger.
(3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue
to behave as before -- only now instead of compiling in
break-to-debugger support, they change the default values of the
above sysctls to enable those features by default. Current kernel
configurations should, therefore, continue to behave as expected.
(4) Migrate alternative break-to-debugger state machine logic out of
individual device drivers into centralised KDB code. This has a
number of upsides, but also one downside: it's now tricky to release
sio spin locks when entering the debugger, so we don't. However,
similar logic does not exist in other device drivers, including uart.
(5) dcons requires some special handling; unlike other console types, it
allows overriding KDB's own debugger selection, so we need a new
interface to KDB to allow that to work.
GENERIC kernels in -CURRENT will now support break-to-debugger as long as
appropriate boot/run-time options are set, which should improve the
debuggability of BETA kernels significantly.
MFC after: 3 weeks
Reviewed by: kib, nwhitehorn
Approved by: re (bz)
2011-08-26 21:46:36 +00:00
|
|
|
if ((dc->flags & DC_GDB) != 0 && gdb_cur == &dcons_gdb_dbgport)
|
|
|
|
kdb_alt_break_gdb(c, &dc->brk_state);
|
|
|
|
else
|
2007-05-27 13:58:43 +00:00
|
|
|
#endif
|
Attempt to make break-to-debugger and alternative break-to-debugger more
accessible:
(1) Always compile in support for breaking into the debugger if options
KDB is present in the kernel.
(2) Disable both by default, but allow them to be enabled via tunables
and sysctls debug.kdb.break_to_debugger and
debug.kdb.alt_break_to_debugger.
(3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue
to behave as before -- only now instead of compiling in
break-to-debugger support, they change the default values of the
above sysctls to enable those features by default. Current kernel
configurations should, therefore, continue to behave as expected.
(4) Migrate alternative break-to-debugger state machine logic out of
individual device drivers into centralised KDB code. This has a
number of upsides, but also one downside: it's now tricky to release
sio spin locks when entering the debugger, so we don't. However,
similar logic does not exist in other device drivers, including uart.
(5) dcons requires some special handling; unlike other console types, it
allows overriding KDB's own debugger selection, so we need a new
interface to KDB to allow that to work.
GENERIC kernels in -CURRENT will now support break-to-debugger as long as
appropriate boot/run-time options are set, which should improve the
debuggability of BETA kernels significantly.
MFC after: 3 weeks
Reviewed by: kib, nwhitehorn
Approved by: re (bz)
2011-08-26 21:46:36 +00:00
|
|
|
kdb_alt_break(c, &dc->brk_state);
|
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
return (c);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define dcons_check_break(dc, c) (c)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
2007-08-17 05:32:39 +00:00
|
|
|
dcons_os_checkc_nopoll(struct dcons_softc *dc)
|
2004-10-13 05:38:42 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
if (dg.dma_tag != NULL)
|
|
|
|
bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_POSTREAD);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
c = dcons_check_break(dc, dcons_checkc(dc));
|
|
|
|
|
|
|
|
if (dg.dma_tag != NULL)
|
|
|
|
bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_PREREAD);
|
|
|
|
|
|
|
|
return (c);
|
|
|
|
}
|
|
|
|
|
2007-08-17 05:32:39 +00:00
|
|
|
static int
|
|
|
|
dcons_os_checkc(struct dcons_softc *dc)
|
|
|
|
{
|
|
|
|
EVENTHANDLER_INVOKE(dcons_poll, 0);
|
|
|
|
return (dcons_os_checkc_nopoll(dc));
|
|
|
|
}
|
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
static void
|
|
|
|
dcons_os_putc(struct dcons_softc *dc, int c)
|
|
|
|
{
|
|
|
|
if (dg.dma_tag != NULL)
|
|
|
|
bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_POSTWRITE);
|
|
|
|
|
|
|
|
dcons_putc(dc, c);
|
|
|
|
|
|
|
|
if (dg.dma_tag != NULL)
|
|
|
|
bus_dmamap_sync(dg.dma_tag, dg.dma_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
dcons_outwakeup(struct tty *tp)
|
2004-10-13 05:38:42 +00:00
|
|
|
{
|
|
|
|
struct dcons_softc *dc;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
char ch;
|
2004-10-13 05:38:42 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
dc = tty_softc(tp);
|
2004-10-13 05:38:42 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
while (ttydisc_getc(tp, &ch, sizeof ch) != 0)
|
|
|
|
dcons_os_putc(dc, ch);
|
2004-10-13 05:38:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_timeout(void *v)
|
|
|
|
{
|
|
|
|
struct tty *tp;
|
|
|
|
struct dcons_softc *dc;
|
|
|
|
int i, c, polltime;
|
|
|
|
|
|
|
|
for (i = 0; i < DCONS_NPORT; i ++) {
|
|
|
|
dc = &sc[i];
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
tp = dc->tty;
|
|
|
|
|
|
|
|
tty_lock(tp);
|
2007-08-17 05:32:39 +00:00
|
|
|
while ((c = dcons_os_checkc_nopoll(dc)) != -1)
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
ttydisc_rint(tp, c, 0);
|
|
|
|
ttydisc_rint_done(tp);
|
|
|
|
tty_unlock(tp);
|
2004-10-13 05:38:42 +00:00
|
|
|
}
|
|
|
|
polltime = hz / poll_hz;
|
|
|
|
if (polltime < 1)
|
|
|
|
polltime = 1;
|
|
|
|
callout_reset(&dcons_callout, polltime, dcons_timeout, tp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_cnprobe(struct consdev *cp)
|
|
|
|
{
|
|
|
|
sprintf(cp->cn_name, "dcons");
|
|
|
|
#if DCONS_FORCE_CONSOLE
|
|
|
|
cp->cn_pri = CN_REMOTE;
|
|
|
|
#else
|
|
|
|
cp->cn_pri = CN_NORMAL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_cninit(struct consdev *cp)
|
|
|
|
{
|
|
|
|
dcons_drv_init(0);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
cp->cn_arg = (void *)&sc[DCONS_CON]; /* share port0 with unit0 */
|
2004-10-13 05:38:42 +00:00
|
|
|
}
|
|
|
|
|
2006-05-26 13:51:38 +00:00
|
|
|
static void
|
|
|
|
dcons_cnterm(struct consdev *cp)
|
2004-10-13 05:38:42 +00:00
|
|
|
{
|
|
|
|
}
|
2006-05-26 13:51:38 +00:00
|
|
|
|
2011-12-17 15:08:43 +00:00
|
|
|
static void
|
|
|
|
dcons_cngrab(struct consdev *cp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_cnungrab(struct consdev *cp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
static int
|
2006-05-26 13:51:38 +00:00
|
|
|
dcons_cngetc(struct consdev *cp)
|
2004-10-13 05:38:42 +00:00
|
|
|
{
|
|
|
|
struct dcons_softc *dc = (struct dcons_softc *)cp->cn_arg;
|
|
|
|
return (dcons_os_checkc(dc));
|
|
|
|
}
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
static void
|
|
|
|
dcons_cnputc(struct consdev *cp, int c)
|
|
|
|
{
|
|
|
|
struct dcons_softc *dc = (struct dcons_softc *)cp->cn_arg;
|
|
|
|
dcons_os_putc(dc, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_drv_init(int stage)
|
|
|
|
{
|
2004-10-28 12:18:22 +00:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2004-10-24 12:41:04 +00:00
|
|
|
quad_t addr, size;
|
2004-10-14 00:21:32 +00:00
|
|
|
#endif
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
if (drv_init)
|
|
|
|
return(drv_init);
|
|
|
|
|
|
|
|
drv_init = -1;
|
|
|
|
|
|
|
|
bzero(&dg, sizeof(dg));
|
|
|
|
dcons_conf = &dg;
|
|
|
|
dg.cdev = &dcons_consdev;
|
|
|
|
dg.buf = NULL;
|
|
|
|
dg.size = DCONS_BUF_SIZE;
|
|
|
|
|
2004-10-28 12:18:22 +00:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2004-10-24 12:41:04 +00:00
|
|
|
if (getenv_quad("dcons.addr", &addr) > 0 &&
|
|
|
|
getenv_quad("dcons.size", &size) > 0) {
|
2004-10-28 12:18:22 +00:00
|
|
|
#ifdef __i386__
|
2004-10-24 12:41:04 +00:00
|
|
|
vm_paddr_t pa;
|
|
|
|
/*
|
|
|
|
* Allow read/write access to dcons buffer.
|
|
|
|
*/
|
|
|
|
for (pa = trunc_page(addr); pa < addr + size; pa += PAGE_SIZE)
|
|
|
|
*vtopte(KERNBASE + pa) |= PG_RW;
|
|
|
|
invltlb();
|
2004-10-28 12:18:22 +00:00
|
|
|
#endif
|
2004-10-13 05:38:42 +00:00
|
|
|
/* XXX P to V */
|
2004-10-24 12:41:04 +00:00
|
|
|
dg.buf = (struct dcons_buf *)(vm_offset_t)(KERNBASE + addr);
|
2004-10-13 05:38:42 +00:00
|
|
|
dg.size = size;
|
|
|
|
if (dcons_load_buffer(dg.buf, dg.size, sc) < 0)
|
|
|
|
dg.buf = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (dg.buf != NULL)
|
|
|
|
goto ok;
|
|
|
|
|
|
|
|
#ifndef KLD_MODULE
|
|
|
|
if (stage == 0) { /* XXX or cold */
|
|
|
|
/*
|
|
|
|
* DCONS_FORCE_CONSOLE == 1 and statically linked.
|
|
|
|
* called from cninit(). can't use contigmalloc yet .
|
|
|
|
*/
|
|
|
|
dg.buf = (struct dcons_buf *) bssbuf;
|
|
|
|
dcons_init(dg.buf, dg.size, sc);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* DCONS_FORCE_CONSOLE == 0 or kernel module case.
|
|
|
|
* if the module is loaded after boot,
|
|
|
|
* bssbuf could be non-continuous.
|
|
|
|
*/
|
|
|
|
dg.buf = (struct dcons_buf *) contigmalloc(dg.size,
|
|
|
|
M_DEVBUF, 0, 0x10000, 0xffffffff, PAGE_SIZE, 0ul);
|
2009-01-07 21:25:44 +00:00
|
|
|
if (dg.buf == NULL)
|
|
|
|
return (-1);
|
2004-10-13 05:38:42 +00:00
|
|
|
dcons_init(dg.buf, dg.size, sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok:
|
|
|
|
dcons_buf = dg.buf;
|
|
|
|
|
|
|
|
drv_init = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_attach_port(int port, char *name, int flags)
|
|
|
|
{
|
|
|
|
struct dcons_softc *dc;
|
|
|
|
struct tty *tp;
|
|
|
|
|
|
|
|
dc = &sc[port];
|
2009-05-29 06:41:23 +00:00
|
|
|
tp = tty_alloc(&dcons_ttydevsw, dc);
|
2004-10-13 05:38:42 +00:00
|
|
|
dc->flags = flags;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
dc->tty = tp;
|
2009-03-13 02:15:49 +00:00
|
|
|
tty_init_console(tp, 0);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
tty_makedev(tp, NULL, "%s", name);
|
2004-10-13 05:38:42 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_attach(void)
|
|
|
|
{
|
|
|
|
int polltime;
|
|
|
|
|
|
|
|
dcons_attach_port(DCONS_CON, "dcons", 0);
|
|
|
|
dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB);
|
2008-11-19 21:12:26 +00:00
|
|
|
callout_init(&dcons_callout, CALLOUT_MPSAFE);
|
2004-10-13 05:38:42 +00:00
|
|
|
polltime = hz / poll_hz;
|
|
|
|
if (polltime < 1)
|
|
|
|
polltime = 1;
|
|
|
|
callout_reset(&dcons_callout, polltime, dcons_timeout, NULL);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_detach(int port)
|
|
|
|
{
|
|
|
|
struct tty *tp;
|
|
|
|
struct dcons_softc *dc;
|
|
|
|
|
|
|
|
dc = &sc[port];
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
tp = dc->tty;
|
2004-10-13 05:38:42 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
tty_lock(tp);
|
|
|
|
tty_rel_gone(tp);
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_modevent(module_t mode, int type, void *data)
|
|
|
|
{
|
|
|
|
int err = 0, ret;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
ret = dcons_drv_init(1);
|
2009-04-06 02:29:28 +00:00
|
|
|
if (ret != -1)
|
2009-01-07 21:25:44 +00:00
|
|
|
dcons_attach();
|
2009-04-06 02:29:28 +00:00
|
|
|
if (ret == 0) {
|
2004-10-13 05:38:42 +00:00
|
|
|
dcons_cnprobe(&dcons_consdev);
|
|
|
|
dcons_cninit(&dcons_consdev);
|
|
|
|
cnadd(&dcons_consdev);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
printf("dcons: unload\n");
|
2009-01-07 21:25:44 +00:00
|
|
|
if (drv_init == 1) {
|
|
|
|
callout_stop(&dcons_callout);
|
|
|
|
cnremove(&dcons_consdev);
|
|
|
|
dcons_detach(DCONS_CON);
|
|
|
|
dcons_detach(DCONS_GDB);
|
|
|
|
dg.buf->magic = 0;
|
|
|
|
|
|
|
|
contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
|
|
|
|
}
|
2004-10-13 05:38:42 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case MOD_SHUTDOWN:
|
2007-06-08 08:23:14 +00:00
|
|
|
#if 0 /* Keep connection after halt */
|
2004-10-13 05:38:42 +00:00
|
|
|
dg.buf->magic = 0;
|
2007-06-08 08:23:14 +00:00
|
|
|
#endif
|
2004-10-13 05:38:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(err);
|
|
|
|
}
|
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
#if defined(GDB)
|
2004-10-13 05:38:42 +00:00
|
|
|
/* Debugger interface */
|
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
static int
|
|
|
|
dcons_os_getc(struct dcons_softc *dc)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
while ((c = dcons_os_checkc(dc)) == -1);
|
|
|
|
|
|
|
|
return (c & 0xff);
|
|
|
|
}
|
|
|
|
|
2004-10-13 05:38:42 +00:00
|
|
|
static int
|
|
|
|
dcons_dbg_probe(void)
|
|
|
|
{
|
2007-06-11 04:08:50 +00:00
|
|
|
int dcons_gdb;
|
|
|
|
|
|
|
|
if (getenv_int("dcons_gdb", &dcons_gdb) == 0)
|
|
|
|
return (-1);
|
|
|
|
return (dcons_gdb);
|
2004-10-13 05:38:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_dbg_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_dbg_term(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dcons_dbg_putc(int c)
|
|
|
|
{
|
|
|
|
struct dcons_softc *dc = &sc[DCONS_GDB];
|
|
|
|
dcons_os_putc(dc, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dcons_dbg_getc(void)
|
|
|
|
{
|
|
|
|
struct dcons_softc *dc = &sc[DCONS_GDB];
|
|
|
|
return (dcons_os_getc(dc));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DEV_MODULE(dcons, dcons_modevent, NULL);
|
|
|
|
MODULE_VERSION(dcons, DCONS_VERSION);
|