summaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-06-24 23:46:55 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-06-24 23:46:55 +0000
commit71a1935eec0e651a74ddfc51d2e291d6376e04f0 (patch)
tree0d91eba8831c50397be9cebbbd378e5830fcf7e5 /console
parent52be5cefb4852e6c2921fd1b19c4d0b4952860ea (diff)
2002-06-25 Marcus Brinkmann <marcus@gnu.org>
* Makefile (LCLHDRS): Add priv.h and mutations.h. (MIGSTUBS): Add tioctlServer.o * console.c: Include <hurd/ioctl-types.h>. (new_node): Bump up st_size for display node. (S_tioctl_tiocflush, S_tioctl_tiocgwinsz, S_tioctl_tiocstart, S_tioctl_tiocstop, S_tioctl_tiocoutq, S_tioctl_tiocspgrp, S_tioctl_tiocgpgrp): New functions. (S_tioctl_tiocmodg, S_tioctl_tiocmods, S_tioctl_tiocexcl, S_tioctl_tiocnxcl, S_tioctl_tiocgeta, S_tioctl_tiocseta, S_tioctl_tiocsetaw, S_tioctl_tiocsetaf, S_tioctl_tiocgetd, S_tioctl_tiocsetd, S_tioctl_tiocdrain, S_tioctl_tiocmget, S_tioctl_tiocmset, S_tioctl_tiocsig, S_tioctl_tiocext, S_tioctl_tiocswinsz, S_tioctl_tiocremote, S_tioctl_tiocmbic, S_tioctl_tiocmbis, S_tioctl_tiocpkt, S_tioctl_tiocsti, S_tioctl_tioccdtr, S_tioctl_tiocsdtr, S_tioctl_tioccbrk, S_tioctl_tiocsbrk): New stubs. (console_demuxer): New function. (main): Don't call netfs_server_loop, but call ports_manage_port_operations_multithread, so we can use our own demuxer. * mutations.h: Use intran and outtran for netfs. * priv.h: Likewise. * console.h (cons_change_t): Add bits for bell_audible and bell_visible. (struct cons_display): Add member BELL. * display.c (struct changes): Add new members bell_audible and bell_visible. Add bit flag macro names for those. (display_flush_filechange): Start with first index in buffer. Signal bell events. (display_record_filechange): Set DISPLAY_CHANGE_MATRIX bit in the disjoint case after flushing the update. (display_output_one): Recognize '\a' as audible bell and '\Eg' as visible bell. (display_output_some): Handle bell updates.
Diffstat (limited to 'console')
-rw-r--r--console/ChangeLog38
-rw-r--r--console/Makefile4
-rw-r--r--console/console.c341
-rw-r--r--console/console.h11
-rw-r--r--console/display.c45
-rw-r--r--console/mutations.h8
-rw-r--r--console/priv.h38
7 files changed, 464 insertions, 21 deletions
diff --git a/console/ChangeLog b/console/ChangeLog
index 806c95aa..7bb73433 100644
--- a/console/ChangeLog
+++ b/console/ChangeLog
@@ -1,3 +1,41 @@
+2002-06-25 Marcus Brinkmann <marcus@gnu.org>
+
+ * Makefile (LCLHDRS): Add priv.h and mutations.h.
+ (MIGSTUBS): Add tioctlServer.o
+ * console.c: Include <hurd/ioctl-types.h>.
+ (new_node): Bump up st_size for display node.
+ (S_tioctl_tiocflush, S_tioctl_tiocgwinsz, S_tioctl_tiocstart,
+ S_tioctl_tiocstop, S_tioctl_tiocoutq, S_tioctl_tiocspgrp,
+ S_tioctl_tiocgpgrp): New functions.
+ (S_tioctl_tiocmodg, S_tioctl_tiocmods, S_tioctl_tiocexcl,
+ S_tioctl_tiocnxcl, S_tioctl_tiocgeta, S_tioctl_tiocseta,
+ S_tioctl_tiocsetaw, S_tioctl_tiocsetaf, S_tioctl_tiocgetd,
+ S_tioctl_tiocsetd, S_tioctl_tiocdrain, S_tioctl_tiocmget,
+ S_tioctl_tiocmset, S_tioctl_tiocsig, S_tioctl_tiocext,
+ S_tioctl_tiocswinsz, S_tioctl_tiocremote, S_tioctl_tiocmbic,
+ S_tioctl_tiocmbis, S_tioctl_tiocpkt, S_tioctl_tiocsti,
+ S_tioctl_tioccdtr, S_tioctl_tiocsdtr, S_tioctl_tioccbrk,
+ S_tioctl_tiocsbrk): New stubs.
+ (console_demuxer): New function.
+ (main): Don't call netfs_server_loop, but call
+ ports_manage_port_operations_multithread, so we can use our own
+ demuxer.
+ * mutations.h: Use intran and outtran for netfs.
+ * priv.h: Likewise.
+
+ * console.h (cons_change_t): Add bits for bell_audible and
+ bell_visible.
+ (struct cons_display): Add member BELL.
+ * display.c (struct changes): Add new members bell_audible and
+ bell_visible. Add bit flag macro names for those.
+ (display_flush_filechange): Start with first index in buffer.
+ Signal bell events.
+ (display_record_filechange): Set DISPLAY_CHANGE_MATRIX bit in the
+ disjoint case after flushing the update.
+ (display_output_one): Recognize '\a' as audible bell and '\Eg' as
+ visible bell.
+ (display_output_some): Handle bell updates.
+
2002-06-24 Marcus Brinkmann <marcus@gnu.org>
* console.h (cons_color_t): New enum type replacing color macros.
diff --git a/console/Makefile b/console/Makefile
index 6498e8e4..01b9bf3f 100644
--- a/console/Makefile
+++ b/console/Makefile
@@ -24,9 +24,9 @@ makemode := server
target = console
SRCS = console.c display.c input.c
-LCLHDRS = console.h display.h input.h
+LCLHDRS = console.h display.h input.h priv.h mutations.h
-MIGSTUBS = notifyServer.o
+MIGSTUBS = notifyServer.o tioctlServer.o
HURDLIBS = netfs fshelp iohelp threads ports ihash shouldbeinlibc
OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS))
diff --git a/console/console.c b/console/console.c
index 43f18e6e..d75cf9c7 100644
--- a/console/console.c
+++ b/console/console.c
@@ -36,6 +36,7 @@
#include <version.h>
#include <hurd/netfs.h>
+#include <hurd/ioctl_types.h>
#include "display.h"
#include "input.h"
@@ -314,7 +315,7 @@ new_node (struct node **np, vcons_t vcons, vcons_node_type type)
(*np)->nn_stat.st_mode |= S_IFREG;
(*np)->nn_stat.st_mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
(*np)->nn_stat.st_size = 80*50 * (sizeof (wchar_t) + 4)
- + 14 * 4 + 512 * 8; /* XXX */
+ + 16 * 4 + 512 * 8; /* XXX */
break;
case VCONS_NODE_INPUT:
(*np)->nn_stat.st_ino = (vcons->id << 2) + 3;
@@ -1336,6 +1337,326 @@ netfs_append_args (char **argz, size_t *argz_len)
}
+kern_return_t
+S_tioctl_tiocflush (struct protid *cred, int queue_selector)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ if (!queue_selector)
+ queue_selector = O_READ | O_WRITE;
+
+ if (queue_selector & O_READ)
+ input_flush (vcons->input);
+ if (queue_selector & O_WRITE)
+ display_discard_output (vcons->display);
+
+ return 0;
+}
+
+kern_return_t
+S_tioctl_tiocgwinsz (struct protid *cred, struct winsize *size)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ display_getsize (vcons->display, size);
+ return 0;
+}
+
+kern_return_t
+S_tioctl_tiocstart (struct protid *cred)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ display_start_output (vcons->display);
+ return 0;
+}
+
+kern_return_t
+S_tioctl_tiocstop (struct protid *cred)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ display_stop_output (vcons->display);
+ return 0;
+}
+
+
+kern_return_t
+S_tioctl_tiocoutq (struct protid *cred, int *queue_size)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ *queue_size = display_pending_output (vcons->display);
+ return 0;
+}
+
+kern_return_t
+S_tioctl_tiocspgrp (struct protid *cred, int pgrp)
+{
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ display_set_owner (vcons->display, -pgrp);
+ return 0;
+}
+
+kern_return_t
+S_tioctl_tiocgpgrp (struct protid *cred, int *pgrp)
+{
+ error_t err;
+ struct node *np;
+ vcons_t vcons;
+
+ if (!cred)
+ return EOPNOTSUPP;
+ if (!(cred->po->openstat & (O_READ | O_WRITE)))
+ return EBADF;
+
+ np = cred->po->np;
+ vcons = np->nn->vcons;
+ if (!vcons || np != vcons->cons_node)
+ return EOPNOTSUPP;
+
+ err = display_get_owner (vcons->display, pgrp);
+ if (!err)
+ *pgrp = -*pgrp;
+
+ return err;
+}
+
+kern_return_t
+S_tioctl_tiocmodg (io_t port, int *state)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocmods (io_t port, int state)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocexcl (io_t port)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocnxcl (io_t port)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocgeta (io_t port, tcflag_t *modes, cc_t *ccs, speed_t *speeds)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocseta (io_t port, tcflag_t *modes, cc_t *ccs, speed_t *speeds)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsetaw (io_t port, tcflag_t *modes, cc_t *ccs, speed_t *speeds)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsetaf (io_t port, tcflag_t *modes, cc_t *ccs,
+ speed_t *speeds)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocgetd (io_t port, int *disc)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsetd (io_t port, int disc)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocdrain (io_t port)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocmget (io_t port, int *bits)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocmset (io_t port, int bits)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsig (io_t port, int sig)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocext (io_t port, int mode)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocucntl (io_t port, int mode)
+
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocswinsz (struct protid *cred, struct winsize size)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocremote (struct protid *cred, int how)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocmbic (struct protid *cred, int bits)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocmbis (struct protid *cred, int bits)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocpkt (struct protid *cred, int mode)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsti (struct protid *cred, char c)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tioccdtr (struct protid *cred)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsdtr (struct protid *cred)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tioccbrk (struct protid *cred)
+{
+ return EOPNOTSUPP;
+}
+
+kern_return_t
+S_tioctl_tiocsbrk (struct protid *cred)
+{
+ return EOPNOTSUPP;
+}
+
+
+int
+console_demuxer (mach_msg_header_t *inp,
+ mach_msg_header_t *outp)
+{
+ extern int netfs_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp);
+ extern int tioctl_server (mach_msg_header_t *inp, mach_msg_header_t *outp);
+
+ return (netfs_demuxer (inp, outp)
+ || tioctl_server (inp, outp));
+}
+
int
main (int argc, char **argv)
{
@@ -1414,9 +1735,17 @@ main (int argc, char **argv)
fshelp_touch (&netfs_root_node->nn_stat, TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME,
console_maptime);
-
- netfs_server_loop ();
-
- /*NOTREACHED*/
- return 0;
+
+ do
+ {
+ ports_manage_port_operations_multithread (netfs_port_bucket,
+ console_demuxer,
+ 1000 * 60 * 2,
+ 1000 * 60 * 10,
+ 0);
+ err = netfs_shutdown (0);
+ }
+ while (err);
+
+ exit (err);
}
diff --git a/console/console.h b/console/console.h
index 81940f9e..a6728a26 100644
--- a/console/console.h
+++ b/console/console.h
@@ -62,8 +62,11 @@ typedef union
uint32_t cursor_status : 1;
uint32_t screen_cur_line : 1;
uint32_t screen_scr_lines : 1;
- uint32_t _unused : 27;
+ uint32_t bell_audible : 1;
+ uint32_t bell_visible : 1;
+ uint32_t _unused : 25;
uint32_t not_matrix : 1;
+ /* Here are 32 more unused bits. */
} what;
} cons_change_t;
@@ -106,6 +109,12 @@ struct cons_display
struct
{
+ uint32_t audible; /* Audible bell. */
+ uint32_t visible; /* Visible bell. */
+ } bell;
+
+ struct
+ {
uint32_t buffer; /* Index (in uint32_t) of the beginning of the
changes buffer in this structure. */
uint32_t length; /* Length of buffer. */
diff --git a/console/display.c b/console/display.c
index a70902c0..2b15e343 100644
--- a/console/display.c
+++ b/console/display.c
@@ -58,6 +58,10 @@ struct changes
uint32_t cur_line;
uint32_t scr_lines;
} screen;
+
+ uint32_t bell_audible;
+ uint32_t bell_visible;
+
off_t start;
off_t end;
@@ -65,7 +69,9 @@ struct changes
#define DISPLAY_CHANGE_CURSOR_STATUS 2
#define DISPLAY_CHANGE_SCREEN_CUR_LINE 4
#define DISPLAY_CHANGE_SCREEN_SCR_LINES 8
-#define DISPLAY_CHANGE_MATRIX 16
+#define DISPLAY_CHANGE_BELL_AUDIBLE 16
+#define DISPLAY_CHANGE_BELL_VISIBLE 32
+#define DISPLAY_CHANGE_MATRIX 64
unsigned int which;
};
@@ -544,7 +550,7 @@ static void
display_flush_filechange (display_t display, unsigned int type)
{
struct cons_display *user = display->user;
- cons_change_t *next = &user->changes._buffer[(user->changes.written + 1)
+ cons_change_t *next = &user->changes._buffer[user->changes.written
% _CONS_CHANGES_LENGTH];
int notify = 0;
int bump_written = 0;
@@ -556,7 +562,7 @@ display_flush_filechange (display_t display, unsigned int type)
next->matrix.start = display->changes.start;
next->matrix.end = display->changes.end;
user->changes.written++;
- next = &user->changes._buffer[(user->changes.written + 1)
+ next = &user->changes._buffer[user->changes.written
% _CONS_CHANGES_LENGTH];
display->changes.which &= ~DISPLAY_CHANGE_MATRIX;
}
@@ -605,6 +611,26 @@ display_flush_filechange (display_t display, unsigned int type)
display->changes.which &= ~DISPLAY_CHANGE_SCREEN_SCR_LINES;
}
+ if (type & DISPLAY_CHANGE_BELL_AUDIBLE
+ && display->changes.which & DISPLAY_CHANGE_BELL_AUDIBLE
+ && display->changes.bell_audible != user->bell.audible)
+ {
+ notify = 1;
+ next->what.bell_audible = 1;
+ bump_written = 1;
+ display->changes.which &= ~DISPLAY_CHANGE_BELL_AUDIBLE;
+ }
+
+ if (type & DISPLAY_CHANGE_BELL_VISIBLE
+ && display->changes.which & DISPLAY_CHANGE_BELL_VISIBLE
+ && display->changes.bell_visible != user->bell.visible)
+ {
+ notify = 1;
+ next->what.bell_visible = 1;
+ bump_written = 1;
+ display->changes.which &= ~DISPLAY_CHANGE_BELL_VISIBLE;
+ }
+
if (bump_written)
user->changes.written++;
if (notify)
@@ -682,8 +708,9 @@ display_record_filechange (display_t display, off_t start, off_t end)
if (disjunct)
{
/* The regions are disjunct, so we have to flush the old
- changes. */
+ changes. */
display_flush_filechange (display, DISPLAY_CHANGE_MATRIX);
+ display->changes.which |= DISPLAY_CHANGE_MATRIX;
}
display->changes.start = start;
display->changes.end = end;
@@ -1437,6 +1464,10 @@ display_output_one (display_t display, wchar_t chr)
case L'\0':
/* Padding character: <pad>. */
break;
+ case L'\a':
+ /* Audible bell. */
+ user->bell.audible++;
+ break;
default:
{
int line = (user->screen.cur_line + user->cursor.row)
@@ -1498,6 +1529,10 @@ display_output_one (display_t display, wchar_t chr)
/* In case the screen was larger before: */
limit_cursor (display);
break;
+ case L'g':
+ /* Visible bell. */
+ user->bell.visible++;
+ break;
default:
/* Unsupported escape sequence. */
parse->state = STATE_NORMAL;
@@ -1555,6 +1590,8 @@ display_output_some (display_t display, char **buffer, size_t *length)
display->changes.cursor.status = display->user->cursor.status;
display->changes.screen.cur_line = display->user->screen.cur_line;
display->changes.screen.scr_lines = display->user->screen.scr_lines;
+ display->changes.bell_audible = display->user->bell.audible;
+ display->changes.bell_visible = display->user->bell.visible;
display->changes.which = ~DISPLAY_CHANGE_MATRIX;
while (!err && *length > 0)
diff --git a/console/mutations.h b/console/mutations.h
index b0ec7e16..a8183fc0 100644
--- a/console/mutations.h
+++ b/console/mutations.h
@@ -20,8 +20,8 @@
/* Only CPP macro definitions should go in this file. */
-#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t)
-#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t)
+#define IO_INTRAN protid_t begin_using_protid_port (io_t)
+#define IO_DESTRUCTOR end_using_protid_port (protid_t)
+
+#define TIOCTL_IMPORTS import "priv.h";
-#define IO_IMPORTS import "priv.h";
-#define TIOCTL_IMPORTS IO_IMPORTS
diff --git a/console/priv.h b/console/priv.h
index da5f5ef9..2fb72bf9 100644
--- a/console/priv.h
+++ b/console/priv.h
@@ -1,6 +1,36 @@
-#ifndef CONSOLE_PRIV_H
-#define CONSOLE_PRIV_H
+/*
+ Copyright (C) 1995,96,2001 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/BSG.
-typedef struct trivfs_protid *trivfs_protid_t;
+ This file is part of the GNU Hurd.
-#endif
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd 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, USA. */
+
+#include <hurd/hurd_types.h>
+
+#include <hurd/netfs.h>
+
+static inline struct protid * __attribute__ ((unused))
+begin_using_protid_port (file_t port)
+{
+ return ports_lookup_port (netfs_port_bucket, port, netfs_protid_class);
+}
+
+static inline void __attribute__ ((unused))
+end_using_protid_port (struct protid *cred)
+{
+ if (cred)
+ ports_port_deref (cred);
+}