From: David van Moolenbroek Date: Fri, 25 Mar 2011 10:43:24 +0000 (+0000) Subject: TTY/LOG driver cleanup: X-Git-Tag: v3.2.0~604 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.named-checkzone.html?a=commitdiff_plain;h=f56c4001d57552365259ca4184dd41f7bb43f921;p=minix.git TTY/LOG driver cleanup: - remove non-safecopy support from TTY - make TTY warning-free with gcc -Wall - remove obsolete diagnostics support --- diff --git a/common/include/minix/com.h b/common/include/minix/com.h index bd1b9e280..621ceecd9 100644 --- a/common/include/minix/com.h +++ b/common/include/minix/com.h @@ -14,7 +14,6 @@ * 0x700 - 0x7FF Reincarnation Server (RS) requests * 0x800 - 0x8FF Data Store (DS) requests * 0x900 - 0x9FF Requests from PM to VFS, and responses - * (0xA00 - 0xAFF old TTY and LOG requests, being phased out) * 0xA00 - 0xAFF Requests from VFS to file systems (see vfsif.h) * 0xB00 - 0xBFF Requests from VM to VFS * 0xC00 - 0xCFF Virtual Memory (VM) requests @@ -762,18 +761,6 @@ # define FKEY_EVENTS 12 /* request open key presses */ # define FKEY_FKEYS m2_l1 /* F1-F12 keys pressed */ # define FKEY_SFKEYS m2_l2 /* Shift-F1-F12 keys pressed */ -#define DIAG_BASE 0xa00 -#define DIAGNOSTICS_OLD (DIAG_BASE+1) /* output a string without FS in between */ -#define DIAGNOSTICS_S_OLD (DIAG_BASE+2) /* grant-based version of DIAGNOSTICS */ -# define DIAG_PRINT_BUF_G m1_p1 -# define DIAG_BUF_COUNT m1_i1 -#define GET_KMESS (DIAG_BASE+3) /* get kmess from TTY */ -# define GETKM_PTR m1_p1 -#define GET_KMESS_S (DIAG_BASE+4) /* get kmess from TTY */ -# define GETKM_GRANT m1_i1 -#define ASYN_DIAGNOSTICS_OLD (DIAG_BASE+5) /* grant-based, replyless DIAGNOSTICS */ - -#define DIAG_REPL_OLD (DIAG_BASE+0x80+0) /* reply to DIAGNOSTICS(_S) */ /*===========================================================================* * Messages used between PM and VFS * diff --git a/drivers/log/diag.c b/drivers/log/diag.c index 4d6ac1244..1e3885536 100644 --- a/drivers/log/diag.c +++ b/drivers/log/diag.c @@ -1,81 +1,42 @@ -/* This file handle diagnostic output that is directly sent to the LOG driver. - * This output can either be a kernel message (announced through a SYS_EVENT - * with a SIGKMESS in the signal set) or output from another system process - * (announced through a DIAGNOSTICS message). +/* This file handle diagnostic output that is sent to the LOG driver. Output + * can be either from the kernel, or from other system processes. Output from + * system processes is also routed through the kernel. The kernel notifies + * this driver with a SIGKMESS signal if any messages are available. * * Changes: * 21 July 2005: Created (Jorrit N. Herder) */ -#include -#include -#include -#include - #include "log.h" /*==========================================================================* * do_new_kmess * *==========================================================================*/ -PUBLIC int do_new_kmess(from) -endpoint_t from; /* who sent this message? */ +PUBLIC void do_new_kmess(void) { /* Notification for a new kernel message. */ static struct kmessages kmess; /* entire kmess structure */ static char print_buf[_KMESS_BUF_SIZE]; /* copy new message here */ int bytes; int i, r; - int *prev_nextp; - - static int kernel_prev_next = 0; - static int tty_prev_next = 0; - - if (from == TTY_PROC_NR) - { - cp_grant_id_t gid; - message mess; - - prev_nextp= &tty_prev_next; - gid= cpf_grant_direct(TTY_PROC_NR, (vir_bytes)&kmess, sizeof(kmess), - CPF_WRITE); - if (gid == -1) - { - return EDONTREPLY; - } + static int prev_next = 0; - /* Ask TTY driver for log output */ - mess.GETKM_GRANT= gid; - mess.m_type = GET_KMESS_S; - r= sendrec(TTY_PROC_NR, &mess); - cpf_revoke(gid); - - if (r == OK) r= mess.m_type; - if (r != OK) - { - printf("log: couldn't get copy of kmessages from TTY: %d\n", r); - return EDONTREPLY; - } - } - else - { - /* Try to get a fresh copy of the buffer with kernel messages. */ - if ((r=sys_getkmessages(&kmess)) != OK) { - printf("log: couldn't get copy of kmessages: %d\n", r); - return EDONTREPLY; - } - prev_nextp= &kernel_prev_next; + /* Try to get a fresh copy of the buffer with kernel messages. */ + if ((r=sys_getkmessages(&kmess)) != OK) { + printf("log: couldn't get copy of kmessages: %d\n", r); + return; } /* Print only the new part. Determine how many new bytes there are with * help of the current and previous 'next' index. Note that the kernel - * buffer is circular. This works fine if less then KMESS_BUF_SIZE bytes - * is new data; else we miss % KMESS_BUF_SIZE here. + * buffer is circular. This works fine if less than KMESS_BUF_SIZE bytes + * are new data; else we miss % KMESS_BUF_SIZE here. * Check for size being positive, the buffer might as well be emptied! */ if (kmess.km_size > 0) { - bytes = ((kmess.km_next + _KMESS_BUF_SIZE) - (*prev_nextp)) % + bytes = ((kmess.km_next + _KMESS_BUF_SIZE) - prev_next) % _KMESS_BUF_SIZE; - r= *prev_nextp; /* start at previous old */ + r= prev_next; /* start at previous old */ i=0; while (bytes > 0) { print_buf[i] = kmess.km_buf[(r%_KMESS_BUF_SIZE)]; @@ -91,46 +52,5 @@ endpoint_t from; /* who sent this message? */ /* Almost done, store 'next' so that we can determine what part of the * kernel messages buffer to print next time a notification arrives. */ - *prev_nextp = kmess.km_next; - return EDONTREPLY; -} - -/*===========================================================================* - * do_diagnostics * - *===========================================================================*/ -PUBLIC int do_diagnostics(message *m, int safe) -{ -/* The LOG server handles all diagnostic messages from servers and device - * drivers. It forwards the message to the TTY driver to display it to the - * user. It also saves a copy in a local buffer so that messages can be - * reviewed at a later time. - */ - vir_bytes src; - int count; - char c; - int i = 0, offset = 0; - static char diagbuf[10240]; - - /* Also make a copy for the private buffer at the LOG server, so - * that the messages can be reviewed at a later time. - */ - src = (vir_bytes) m->DIAG_PRINT_BUF_G; - count = m->DIAG_BUF_COUNT; - while (count > 0 && i < sizeof(diagbuf)-1) { - int r; - if(safe) { - r = sys_safecopyfrom(m->m_source, src, offset, (vir_bytes) &c, 1, D); - } else { - r = sys_datacopy(m->m_source, src+offset, SELF, (vir_bytes) &c, 1); - } - if(r != OK) break; - offset ++; - count --; - diagbuf[i++] = c; - } - log_append(diagbuf, i); - - if(m->m_type == ASYN_DIAGNOSTICS_OLD) return EDONTREPLY; - - return OK; + prev_next = kmess.km_next; } diff --git a/drivers/log/log.c b/drivers/log/log.c index 84e3e5257..727e04b59 100644 --- a/drivers/log/log.c +++ b/drivers/log/log.c @@ -31,7 +31,7 @@ FORWARD _PROTOTYPE( int log_cancel, (struct driver *dp, message *m_ptr) ); FORWARD _PROTOTYPE( int log_select, (struct driver *dp, message *m_ptr) ); FORWARD _PROTOTYPE( int log_other, (struct driver *dp, message *m_ptr) ); FORWARD _PROTOTYPE( void log_geometry, (struct partition *entry) ); -FORWARD _PROTOTYPE( int subread, (struct logdevice *log, int count, int proc_nr, vir_bytes user_vir, size_t) ); +FORWARD _PROTOTYPE( int subread, (struct logdevice *log, int count, int proc_nr, cp_grant_id_t grant, size_t) ); /* Entry points to this driver. */ PRIVATE struct driver log_dtab = { @@ -128,7 +128,7 @@ PRIVATE void sef_cb_signal_handler(int signo) /* Only check for a pending message from the kernel, ignore anything else. */ if (signo != SIGKMESS) return; - do_new_kmess(SYSTEM); + do_new_kmess(); } /*===========================================================================* @@ -160,7 +160,7 @@ int device; *===========================================================================*/ PRIVATE int subwrite(struct logdevice *log, int count, int proc_nr, - vir_bytes user_vir, size_t offset) + cp_grant_id_t grant, size_t offset, char *localbuf) { int d, r; char *buf; @@ -170,11 +170,11 @@ subwrite(struct logdevice *log, int count, int proc_nr, count = LOG_SIZE - log->log_write; buf = log->log_buffer + log->log_write; - if(proc_nr == SELF) { - memcpy(buf, (char *) user_vir, count); + if(localbuf != NULL) { + memcpy(buf, localbuf, count); } else { - if((r=sys_safecopyfrom(proc_nr, user_vir, offset, + if((r=sys_safecopyfrom(proc_nr, grant, offset, (vir_bytes)buf, count, D)) != OK) return r; } @@ -194,13 +194,13 @@ subwrite(struct logdevice *log, int count, int proc_nr, * be revived. */ log->log_status = subread(log, log->log_iosize, - log->log_proc_nr, log->log_user_vir_g, - log->log_user_vir_offset); + log->log_proc_nr, log->log_user_grant, + log->log_user_offset); m.m_type = DEV_REVIVE; m.REP_ENDPT = log->log_proc_nr; m.REP_STATUS = log->log_status; - m.REP_IO_GRANT = log->log_user_vir_g; + m.REP_IO_GRANT = log->log_user_grant; r= send(log->log_source, &m); if (r != OK) { @@ -243,7 +243,7 @@ subwrite(struct logdevice *log, int count, int proc_nr, } /*===========================================================================* - * log_append * + * log_append * *===========================================================================*/ PUBLIC void log_append(char *buf, int count) @@ -254,10 +254,11 @@ log_append(char *buf, int count) if(count > LOG_SIZE) skip = count - LOG_SIZE; count -= skip; buf += skip; - w = subwrite(&logdevices[0], count, SELF, (vir_bytes) buf,0); + w = subwrite(&logdevices[0], count, SELF, GRANT_INVALID, 0, buf); if(w > 0 && w < count) - subwrite(&logdevices[0], count-w, SELF, (vir_bytes) buf+w,0); + subwrite(&logdevices[0], count-w, SELF, GRANT_INVALID, 0, + buf + w); return; } @@ -266,7 +267,7 @@ log_append(char *buf, int count) *===========================================================================*/ PRIVATE int subread(struct logdevice *log, int count, int proc_nr, - vir_bytes user_vir, size_t offset) + cp_grant_id_t grant, size_t offset) { char *buf; int r; @@ -276,7 +277,7 @@ subread(struct logdevice *log, int count, int proc_nr, count = LOG_SIZE - log->log_read; buf = log->log_buffer + log->log_read; - if((r=sys_safecopyto(proc_nr, user_vir, offset, + if((r=sys_safecopyto(proc_nr, grant, offset, (vir_bytes)buf, count, D)) != OK) return r; @@ -297,8 +298,8 @@ iovec_t *iov; /* pointer to read or write request vector */ unsigned nr_req; /* length of request vector */ { /* Read or write one the driver's minor devices. */ - unsigned count; - vir_bytes user_vir; + int count; + cp_grant_id_t grant; int accumulated_read = 0; struct logdevice *log; size_t vir_offset = 0; @@ -312,7 +313,7 @@ unsigned nr_req; /* length of request vector */ while (nr_req > 0) { /* How much to transfer and where to / from. */ count = iov->iov_size; - user_vir = iov->iov_addr; + grant = iov->iov_addr; switch (log_device) { @@ -331,8 +332,8 @@ unsigned nr_req; /* length of request vector */ /* No data available; let caller block. */ log->log_proc_nr = proc_nr; log->log_iosize = count; - log->log_user_vir_g = user_vir; - log->log_user_vir_offset = 0; + log->log_user_grant = grant; + log->log_user_offset = 0; log->log_revive_alerted = 0; /* Device_caller is a global in drivers library. */ @@ -343,13 +344,13 @@ unsigned nr_req; /* length of request vector */ #endif return(EDONTREPLY); } - count = subread(log, count, proc_nr, user_vir, vir_offset); + count = subread(log, count, proc_nr, grant, vir_offset); if(count < 0) { return count; } accumulated_read += count; } else { - count = subwrite(log, count, proc_nr, user_vir, vir_offset); + count = subwrite(log, count, proc_nr, grant, vir_offset, NULL); if(count < 0) return count; } @@ -419,27 +420,10 @@ message *m_ptr; * understand. */ if (is_notify(m_ptr->m_type)) { - switch (_ENDPOINT_P(m_ptr->m_source)) { - case TTY_PROC_NR: - do_new_kmess(m_ptr->m_source); - r = EDONTREPLY; - break; - default: - r = EINVAL; - break; - } - return r; + return EINVAL; } switch(m_ptr->m_type) { - case DIAGNOSTICS_OLD: { - r = do_diagnostics(m_ptr, 0); - break; - } - case ASYN_DIAGNOSTICS_OLD: - case DIAGNOSTICS_S_OLD: - r = do_diagnostics(m_ptr, 1); - break; case DEV_STATUS: { printf("log_other: unexpected DEV_STATUS request\n"); r = EDONTREPLY; diff --git a/drivers/log/log.h b/drivers/log/log.h index 6cc5e4a0a..f4f20105a 100644 --- a/drivers/log/log.h +++ b/drivers/log/log.h @@ -23,14 +23,14 @@ struct logdevice { log_iosize, log_revive_alerted, log_status; /* proc that is blocking on read */ - vir_bytes log_user_vir_g, log_user_vir_offset; + cp_grant_id_t log_user_grant; + vir_bytes log_user_offset; #endif int log_selected, log_select_proc, log_select_alerted, log_select_ready_ops; }; /* Function prototypes. */ -_PROTOTYPE( int do_new_kmess, (endpoint_t from) ); -_PROTOTYPE( int do_diagnostics, (message *m, int safe) ); -_PROTOTYPE( void log_append, (char *buf, int len) ); +_PROTOTYPE( void do_new_kmess, (void) ); +_PROTOTYPE( void log_append, (char *buf, int len) ); diff --git a/drivers/tty/console.c b/drivers/tty/console.c index bbe4b3cf1..b02476210 100644 --- a/drivers/tty/console.c +++ b/drivers/tty/console.c @@ -171,17 +171,10 @@ int try; */ do { if (count > sizeof(buf)) count = sizeof(buf); - if(tp->tty_out_safe) { - if ((result = sys_safecopyfrom(tp->tty_outproc, tp->tty_out_vir_g, - tp->tty_out_vir_offset, (vir_bytes) buf, count, D)) != OK) + if ((result = sys_safecopyfrom(tp->tty_outproc, tp->tty_outgrant, + tp->tty_outoffset, (vir_bytes) buf, count, D)) != OK) break; - tp->tty_out_vir_offset += count; - } else { - if ((result = sys_vircopy(tp->tty_outproc, D, tp->tty_out_vir_g, - SELF, D, (vir_bytes) buf, (vir_bytes) count)) != OK) - break; - tp->tty_out_vir_g += count; - } + tp->tty_outoffset += count; tbuf = buf; /* Update terminal data structure. */ @@ -767,9 +760,7 @@ PRIVATE void beep() */ static timer_t tmr_stop_beep; pvb_pair_t char_out[3]; - clock_t now; unsigned long port_b_val; - int s; /* Set timer in advance to prevent beeping delay. */ set_timer(&tmr_stop_beep, B_TIME, stop_beep, 0); @@ -793,7 +784,7 @@ PRIVATE void beep() *===========================================================================*/ PUBLIC void do_video(message *m) { - int r, safe = 0; + int r; /* Execute the requested device driver function. */ r= EINVAL; /* just in case */ @@ -808,7 +799,6 @@ PUBLIC void do_video(message *m) r= OK; break; case DEV_IOCTL_S: - safe=1; switch(m->TTY_REQUEST) { case TIOCMAPMEM: case TIOCUNMAPMEM: { @@ -817,15 +807,9 @@ PUBLIC void do_video(message *m) do_map= (m->REQUEST == TIOCMAPMEM); /* else unmap */ - /* Get request structure */ - if(!safe) { - printf("tty: safecopy only\n"); - return; - } - r = sys_safecopyfrom(m->IO_ENDPT, - (vir_bytes)m->ADDRESS, 0, (vir_bytes) &mapreqvm, - sizeof(mapreqvm), D); + (cp_grant_id_t) m->IO_GRANT, 0, + (vir_bytes) &mapreqvm, sizeof(mapreqvm), D); if (r != OK) { @@ -844,7 +828,7 @@ PUBLIC void do_video(message *m) mapreqvm.vaddr_ret = vm_map_phys(m->POSITION, (void *) mapreqvm.phys_offset, mapreqvm.size); if((r = sys_safecopyto(m->IO_ENDPT, - (vir_bytes)m->ADDRESS, 0, + (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes) &mapreqvm, sizeof(mapreqvm), D)) != OK) { printf("tty: sys_safecopyto failed\n"); @@ -883,9 +867,7 @@ clock_t dur; */ static timer_t tmr_stop_beep; pvb_pair_t char_out[3]; - clock_t now; unsigned long port_b_val; - int s; unsigned long ival= TIMER_FREQ / freq; if (ival == 0 || ival > 0xffff) @@ -1069,86 +1051,6 @@ PUBLIC void do_new_kmess() prev_next = kmess.km_next; } -/*===========================================================================* - * do_diagnostics * - *===========================================================================*/ -PUBLIC void do_diagnostics(m_ptr, safe) -message *m_ptr; /* pointer to request message */ -int safe; -{ -/* Print a string for a server. */ - char c; - vir_bytes src; - int count, offset = 0; - int result = OK; - int proc_nr = m_ptr->m_source; - - src = (vir_bytes) m_ptr->DIAG_PRINT_BUF_G; - for (count = m_ptr->DIAG_BUF_COUNT; count > 0; count--) { - int r; - if(safe) { - r = sys_safecopyfrom(proc_nr, src, offset, (vir_bytes) &c, 1, D); - if(r != OK) - printf("", proc_nr, src); - } else { - r = sys_vircopy(proc_nr, D, src+offset, SELF, D, (vir_bytes) &c, 1); - } - offset++; - if(r != OK) { - result = EFAULT; - break; - } - cons_putk(c); - } - cons_putk(0); /* always terminate, even with EFAULT */ - - if(m_ptr->m_type != ASYN_DIAGNOSTICS_OLD) { - m_ptr->m_type = DIAG_REPL_OLD; - m_ptr->REP_STATUS = result; - send(m_ptr->m_source, m_ptr); - } -} - -/*===========================================================================* - * do_get_kmess * - *===========================================================================*/ -PUBLIC void do_get_kmess(m_ptr) -message *m_ptr; /* pointer to request message */ -{ -/* Provide the log device with debug output */ - vir_bytes dst; - int r; - - dst = (vir_bytes) m_ptr->GETKM_PTR; - r= OK; - if (sys_vircopy(SELF, D, (vir_bytes)&kmess, m_ptr->m_source, D, - dst, sizeof(kmess)) != OK) { - r = EFAULT; - } - m_ptr->m_type = r; - send(m_ptr->m_source, m_ptr); -} - -/*===========================================================================* - * do_get_kmess_s * - *===========================================================================*/ -PUBLIC void do_get_kmess_s(m_ptr) -message *m_ptr; /* pointer to request message */ -{ -/* Provide the log device with debug output */ - cp_grant_id_t gid; - int r; - - gid = m_ptr->GETKM_GRANT; - r= OK; - if (sys_safecopyto(m_ptr->m_source, gid, 0, (vir_bytes)&kmess, sizeof(kmess), - D) != OK) { - r = EFAULT; - } - m_ptr->m_type = r; - send(m_ptr->m_source, m_ptr); -} - /*===========================================================================* * cons_putk * *===========================================================================*/ @@ -1299,7 +1201,7 @@ message *m; if (!machine.vdu_ega) return(ENOTTY); result = ga_program(seq1); /* bring font memory into view */ - if(sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) m->ADDRESS, 0, + if(sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes) font_memory, GA_FONT_SIZE, D) != OK) { printf("tty: copying from %d failed\n", m->IO_ENDPT); return EFAULT; diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 9b9d9e411..8766e1d2a 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -108,10 +108,10 @@ PRIVATE int locks[NR_CONS]; /* per console lock keys state */ #define CAPS_LOCK 0x04 #define ALT_LOCK 0x08 -PRIVATE char numpad_map[] = +PRIVATE char numpad_map[12] = {'H', 'Y', 'A', 'B', 'D', 'C', 'V', 'U', 'G', 'S', 'T', '@'}; -PRIVATE char *fkey_map[] = +PRIVATE char *fkey_map[12] = {"11", "12", "13", "14", "15", "17", /* F1-F6 */ "18", "19", "20", "21", "23", "24"}; /* F7-F12 */ @@ -129,8 +129,7 @@ PRIVATE struct kbd int avail; int req_size; int req_proc; - int req_safe; /* nonzero: safe (req_addr_g is grant) */ - vir_bytes req_addr_g; /* Virtual address or grant */ + cp_grant_id_t req_grant; vir_bytes req_addr_offset; int incaller; int select_ops; @@ -217,7 +216,7 @@ PRIVATE void handle_req(kbdp, m) struct kbd *kbdp; message *m; { - int i, n, r, ops, watch, safecopy = 0; + int i, n, r, ops, watch; unsigned char c; /* Execute the requested device driver function. */ @@ -239,7 +238,6 @@ message *m; r= OK; break; case DEV_READ_S: - safecopy = 1; if (kbdp->req_size) { /* We handle only request at a time */ @@ -251,9 +249,8 @@ message *m; /* Should record proc */ kbdp->req_size= m->COUNT; kbdp->req_proc= m->IO_ENDPT; - kbdp->req_addr_g= (vir_bytes)m->ADDRESS; + kbdp->req_grant= (cp_grant_id_t) m->IO_GRANT; kbdp->req_addr_offset= 0; - kbdp->req_safe= safecopy; kbdp->incaller= m->m_source; r= SUSPEND; break; @@ -267,13 +264,8 @@ message *m; n= KBD_BUFSZ-kbdp->offset; if (n <= 0) panic("do_kbd(READ): bad n: %d", n); - if(safecopy) { - r= sys_safecopyto(m->IO_ENDPT, (vir_bytes) m->ADDRESS, 0, + r= sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes) &kbdp->buf[kbdp->offset], n, D); - } else { - r= sys_vircopy(SELF, D, (vir_bytes)&kbdp->buf[kbdp->offset], - m->IO_ENDPT, D, (vir_bytes) m->ADDRESS, n); - } if (r == OK) { kbdp->offset= (kbdp->offset+n) % KBD_BUFSZ; @@ -286,7 +278,6 @@ message *m; break; case DEV_WRITE_S: - safecopy = 1; if (kbdp != &kbdaux) { printf("write to keyboard not implemented\n"); @@ -300,14 +291,8 @@ message *m; */ for (i= 0; iCOUNT; i++) { - if(safecopy) { - r= sys_safecopyfrom(m->IO_ENDPT, (vir_bytes) - m->ADDRESS, i, (vir_bytes)&c, 1, D); - } else { - r= sys_vircopy(m->IO_ENDPT, D, - (vir_bytes) m->ADDRESS+i, - SELF, D, (vir_bytes)&c, 1); - } + r= sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) + m->IO_GRANT, i, (vir_bytes) &c, 1, D); if (r != OK) break; kbc_cmd1(KBC_WRITE_AUX, c); @@ -337,21 +322,15 @@ message *m; } break; case DEV_IOCTL_S: - safecopy=1; if (kbdp == &kbd && m->TTY_REQUEST == KIOCSLEDS) { kio_leds_t leds; unsigned char b; - if(safecopy) { - r= sys_safecopyfrom(m->IO_ENDPT, (vir_bytes) - m->ADDRESS, 0, (vir_bytes)&leds, + r= sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) + m->IO_GRANT, 0, (vir_bytes) &leds, sizeof(leds), D); - } else { - r= sys_vircopy(m->IO_ENDPT, D, (vir_bytes) m->ADDRESS, - SELF, D, (vir_bytes)&leds, sizeof(leds)); - } if (r != OK) break; b= 0; @@ -384,14 +363,9 @@ message *m; kio_bell_t bell; clock_t ticks; - if(safecopy) { - r= sys_safecopyfrom(m->IO_ENDPT, (vir_bytes) - m->ADDRESS, 0, (vir_bytes)&bell, + r = sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) + m->IO_GRANT, 0, (vir_bytes) &bell, sizeof(bell), D); - } else { - r= sys_vircopy(m->IO_ENDPT, D, (vir_bytes) m->ADDRESS, - SELF, D, (vir_bytes)&bell, sizeof(bell)); - } if (r != OK) break; @@ -436,13 +410,8 @@ message *m; if (n <= 0) panic("kbd_status: bad n: %d", n); kbdp->req_size= 0; - if(kbdp->req_safe) { - r= sys_safecopyto(kbdp->req_proc, kbdp->req_addr_g, 0, + r= sys_safecopyto(kbdp->req_proc, kbdp->req_grant, 0, (vir_bytes)&kbdp->buf[kbdp->offset], n, D); - } else { - r= sys_vircopy(SELF, D, (vir_bytes)&kbdp->buf[kbdp->offset], - kbdp->req_proc, D, kbdp->req_addr_g, n); - } if (r == OK) { kbdp->offset= (kbdp->offset+n) % KBD_BUFSZ; @@ -452,7 +421,7 @@ message *m; m->m_type = DEV_REVIVE; m->REP_ENDPT= kbdp->req_proc; - m->REP_IO_GRANT= kbdp->req_addr_g; + m->REP_IO_GRANT= kbdp->req_grant; m->REP_STATUS= r; return 1; } @@ -653,7 +622,7 @@ int try; ch -= SF1; suffix = '2'; } else - if (CF1 <= ch && ch <= CF12) { + /* (CF1 <= ch && ch <= CF12) */ { ch -= CF1; suffix = shift ? '6' : '5'; } @@ -709,7 +678,6 @@ PRIVATE void kbd_send() { unsigned long sb; int r; - clock_t now; if (!kbdout.avail) return; @@ -1088,21 +1056,12 @@ PUBLIC void kb_init_once(void) /*===========================================================================* * kbd_loadmap * *===========================================================================*/ -PUBLIC int kbd_loadmap(m, safe) +PUBLIC int kbd_loadmap(m) message *m; -int safe; { /* Load a new keymap. */ - int result; - if(safe) { - result = sys_safecopyfrom(m->IO_ENDPT, (vir_bytes) m->ADDRESS, - 0, (vir_bytes) keymap, (vir_bytes) sizeof(keymap), D); - } else { - result = sys_vircopy(m->IO_ENDPT, D, (vir_bytes) m->ADDRESS, - SELF, D, (vir_bytes) keymap, - (vir_bytes) sizeof(keymap)); - } - return(result); + return sys_safecopyfrom(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, + 0, (vir_bytes) keymap, (vir_bytes) sizeof(keymap), D); } /*===========================================================================* @@ -1341,8 +1300,6 @@ int *isauxp; PRIVATE void kbd_watchdog(tmrp) timer_t *tmrp; { - int r; - clock_t now; kbd_watchdog_set= 0; if (!kbdout.avail) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index ee162f122..72a1c3b96 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -36,9 +36,8 @@ typedef struct pty { char rdsendreply; /* send a reply (instead of notify) */ int rdcaller; /* process making the call (usually FS) */ int rdproc; /* process that wants to read from the pty */ - vir_bytes rdvir_g; /* virtual address in readers address space */ - vir_bytes rdvir_offset; /* offset in above grant */ - int rdsafe; /* safe read mode? */ + cp_grant_id_t rdgrant; /* grant for readers address space */ + vir_bytes rdoffset; /* offset in above grant */ int rdleft; /* # bytes yet to be read */ int rdcum; /* # bytes written so far */ @@ -46,9 +45,8 @@ typedef struct pty { char wrsendreply; /* send a reply (instead of notify) */ int wrcaller; /* process making the call (usually FS) */ int wrproc; /* process that wants to write to the pty */ - vir_bytes wrvir_g; /* virtual address in writers address space */ - vir_bytes wrvir_offset; /* offset in above grant */ - int wrsafe; /* safe write mode? */ + cp_grant_id_t wrgrant; /* grant for writers address space */ + vir_bytes wroffset; /* offset in above grant */ int wrleft; /* # bytes yet to be written */ int wrcum; /* # bytes written so far */ @@ -87,11 +85,9 @@ PUBLIC void do_pty(tty_t *tp, message *m_ptr) /* Perform an open/close/read/write call on a /dev/ptypX device. */ pty_t *pp = tp->tty_priv; int r; - int safe = 0; switch (m_ptr->m_type) { case DEV_READ_S: - safe=1; /* Check, store information on the reader, do I/O. */ if (pp->state & TTY_CLOSED) { r = 0; @@ -108,9 +104,8 @@ PUBLIC void do_pty(tty_t *tp, message *m_ptr) pp->rdsendreply = TRUE; pp->rdcaller = m_ptr->m_source; pp->rdproc = m_ptr->IO_ENDPT; - pp->rdvir_g = (vir_bytes) m_ptr->ADDRESS; - pp->rdvir_offset = 0; - pp->rdsafe = safe; + pp->rdgrant = (cp_grant_id_t) m_ptr->IO_GRANT; + pp->rdoffset = 0; pp->rdleft = m_ptr->COUNT; pty_start(pp); handle_events(tp); @@ -125,7 +120,6 @@ PUBLIC void do_pty(tty_t *tp, message *m_ptr) break; case DEV_WRITE_S: - safe=1; /* Check, store information on the writer, do I/O. */ if (pp->state & TTY_CLOSED) { r = EIO; @@ -142,9 +136,8 @@ PUBLIC void do_pty(tty_t *tp, message *m_ptr) pp->wrsendreply = TRUE; pp->wrcaller = m_ptr->m_source; pp->wrproc = m_ptr->IO_ENDPT; - pp->wrvir_g = (vir_bytes) m_ptr->ADDRESS; - pp->wrvir_offset = 0; - pp->wrsafe = safe; + pp->wrgrant = (cp_grant_id_t) m_ptr->IO_GRANT; + pp->wroffset = 0; pp->wrleft = m_ptr->COUNT; handle_events(tp); if (pp->wrleft == 0) { @@ -237,16 +230,9 @@ PRIVATE int pty_write(tty_t *tp, int try) break; /* Copy from user space to the PTY output buffer. */ - if(tp->tty_out_safe) { - if ((s = sys_safecopyfrom(tp->tty_outproc, tp->tty_out_vir_g, - tp->tty_out_vir_offset, (vir_bytes) pp->ohead, count, D))!=OK) { + if ((s = sys_safecopyfrom(tp->tty_outproc, tp->tty_outgrant, + tp->tty_outoffset, (vir_bytes) pp->ohead, count, D))!=OK) { break; - } - } else { - if ((s = sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir_g, - SELF, D, (vir_bytes) pp->ohead, (phys_bytes) count)) != OK) { - break; - } } /* Perform output processing on the output buffer. */ @@ -262,8 +248,7 @@ PRIVATE int pty_write(tty_t *tp, int try) pp->ohead -= buflen(pp->obuf); pty_start(pp); - if(tp->tty_out_safe) tp->tty_out_vir_offset += count; - else tp->tty_out_vir_g += count; + tp->tty_outoffset += count; tp->tty_outcum += count; if ((tp->tty_outleft -= count) == 0) { @@ -322,20 +307,11 @@ PRIVATE void pty_start(pty_t *pp) if (count == 0) break; /* Copy from the output buffer to the readers address space. */ - if (pp->rdsafe) { - if((s = sys_safecopyto(pp->rdproc, pp->rdvir_g, - pp->rdvir_offset, (vir_bytes) pp->otail, count, D)) != OK) { - break; - } - pp->rdvir_offset += count; - } else { - if ((s = sys_vircopy(SELF, D, (vir_bytes)pp->otail, - (vir_bytes) pp->rdproc, D, (vir_bytes) pp->rdvir_g, (phys_bytes) count)) != OK) { - printf("pty tty: copy failed (error %d)\n", s); + if((s = sys_safecopyto(pp->rdproc, pp->rdgrant, + pp->rdoffset, (vir_bytes) pp->otail, count, D)) != OK) { break; - } - pp->rdvir_g += count; - } + } + pp->rdoffset += count; /* Bookkeeping. */ pp->ocount -= count; @@ -400,21 +376,12 @@ PRIVATE int pty_read(tty_t *tp, int try) int s; /* Transfer one character to 'c'. */ - if(pp->wrsafe) { - if ((s = sys_safecopyfrom(pp->wrproc, pp->wrvir_g, - pp->wrvir_offset, (vir_bytes) &c, 1, D)) != OK) { + if ((s = sys_safecopyfrom(pp->wrproc, pp->wrgrant, pp->wroffset, + (vir_bytes) &c, 1, D)) != OK) { printf("pty: safecopy failed (error %d)\n", s); break; - } - pp->wrvir_offset++; - } else { - if ((s = sys_vircopy(pp->wrproc, D, (vir_bytes) pp->wrvir_g, - SELF, D, (vir_bytes) &c, (phys_bytes) 1)) != OK) { - printf("pty: copy failed (error %d)\n", s); - break; - } - pp->wrvir_g++; } + pp->wroffset++; /* Input processing. */ if (in_process(tp, &c, 1, -1) == 0) break; @@ -534,7 +501,7 @@ PUBLIC int pty_status(message *m_ptr) { m_ptr->m_type = DEV_REVIVE; m_ptr->REP_ENDPT = pp->rdproc; - m_ptr->REP_IO_GRANT = pp->rdvir_g; + m_ptr->REP_IO_GRANT = pp->rdgrant; m_ptr->REP_STATUS = pp->rdcum; pp->rdleft = pp->rdcum = 0; @@ -548,7 +515,7 @@ PUBLIC int pty_status(message *m_ptr) { m_ptr->m_type = DEV_REVIVE; m_ptr->REP_ENDPT = pp->wrproc; - m_ptr->REP_IO_GRANT = pp->wrvir_g; + m_ptr->REP_IO_GRANT = pp->wrgrant; if (pp->wrcum == 0) m_ptr->REP_STATUS = EIO; else diff --git a/drivers/tty/rs232.c b/drivers/tty/rs232.c index 482024296..5bf8bec8a 100644 --- a/drivers/tty/rs232.c +++ b/drivers/tty/rs232.c @@ -248,13 +248,8 @@ PRIVATE int rs_write(register tty_t *tp, int try) if (try) return 1; /* Copy from user space to the RS232 output buffer. */ - if(tp->tty_out_safe) { - sys_safecopyfrom(tp->tty_outproc, tp->tty_out_vir_g, - tp->tty_out_vir_offset, (vir_bytes) rs->ohead, count, D); - } else { - sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir_g, - SELF, D, (vir_bytes) rs->ohead, (phys_bytes) count); - } + sys_safecopyfrom(tp->tty_outproc, tp->tty_outgrant, + tp->tty_outoffset, (vir_bytes) rs->ohead, count, D); /* Perform output processing on the output buffer. */ out_process(tp, rs->obuf, rs->ohead, bufend(rs->obuf), &count, &ocount); @@ -270,11 +265,7 @@ PRIVATE int rs_write(register tty_t *tp, int try) unlock(); if ((rs->ohead += ocount) >= bufend(rs->obuf)) rs->ohead -= buflen(rs->obuf); - if(tp->tty_out_safe) { - tp->tty_out_vir_offset += count; - } else { - tp->tty_out_vir_g += count; - } + tp->tty_outoffset += count; tp->tty_outcum += count; if ((tp->tty_outleft -= count) == 0) { /* Output is finished, reply to the writer. */ diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 3a44d3571..bdb269ea7 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -30,15 +30,15 @@ * DEV_STATUS: FS wants to know status for SELECT or REVIVE * CANCEL: terminate a previous incomplete system call immediately * - * m_type TTY_LINE IO_ENDPT COUNT TTY_SPEKS ADDRESS + * m_type TTY_LINE IO_ENDPT COUNT TTY_SPEKS IO_GRANT * ----------------------------------------------------------------- * | HARD_INT | | | | | | * |-------------+---------+---------+---------+---------+---------| * | SYS_SIG | sig set | | | | | * |-------------+---------+---------+---------+---------+---------| - * | DEV_READ |minor dev| proc nr | count | | buf ptr | + * | DEV_READ |minor dev| proc nr | count | | grant | * |-------------+---------+---------+---------+---------+---------| - * | DEV_WRITE |minor dev| proc nr | count | | buf ptr | + * | DEV_WRITE |minor dev| proc nr | count | | grant | * |-------------+---------+---------+---------+---------+---------| * | DEV_IOCTL |minor dev| proc nr |func code|erase etc| | * |-------------+---------+---------+---------+---------+---------| @@ -104,11 +104,11 @@ struct kmessages kmess; FORWARD _PROTOTYPE( void tty_timed_out, (timer_t *tp) ); FORWARD _PROTOTYPE( void settimer, (tty_t *tty_ptr, int enable) ); FORWARD _PROTOTYPE( void do_cancel, (tty_t *tp, message *m_ptr) ); -FORWARD _PROTOTYPE( void do_ioctl, (tty_t *tp, message *m_ptr, int s) ); +FORWARD _PROTOTYPE( void do_ioctl, (tty_t *tp, message *m_ptr) ); FORWARD _PROTOTYPE( void do_open, (tty_t *tp, message *m_ptr) ); FORWARD _PROTOTYPE( void do_close, (tty_t *tp, message *m_ptr) ); -FORWARD _PROTOTYPE( void do_read, (tty_t *tp, message *m_ptr, int s) ); -FORWARD _PROTOTYPE( void do_write, (tty_t *tp, message *m_ptr, int s) ); +FORWARD _PROTOTYPE( void do_read, (tty_t *tp, message *m_ptr) ); +FORWARD _PROTOTYPE( void do_write, (tty_t *tp, message *m_ptr) ); FORWARD _PROTOTYPE( void do_select, (tty_t *tp, message *m_ptr) ); FORWARD _PROTOTYPE( void do_status, (message *m_ptr) ); FORWARD _PROTOTYPE( void in_transfer, (tty_t *tp) ); @@ -210,25 +210,6 @@ PUBLIC int main(void) } switch (tty_mess.m_type) { - case DIAGNOSTICS_OLD: /* a server wants to print some */ -#if 0 - if (tty_mess.m_source != LOG_PROC_NR) - { - printf("[%d ", tty_mess.m_source); - } -#endif - do_diagnostics(&tty_mess, 0); - continue; - case DIAGNOSTICS_S_OLD: - case ASYN_DIAGNOSTICS_OLD: - do_diagnostics(&tty_mess, 1); - continue; - case GET_KMESS: - do_get_kmess(&tty_mess); - continue; - case GET_KMESS_S: - do_get_kmess_s(&tty_mess); - continue; case FKEY_CONTROL: /* (un)register a fkey observer */ do_fkey_ctl(&tty_mess); continue; @@ -289,9 +270,9 @@ PUBLIC int main(void) /* Execute the requested device driver function. */ switch (tty_mess.m_type) { - case DEV_READ_S: do_read(tp, &tty_mess, 1); break; - case DEV_WRITE_S: do_write(tp, &tty_mess, 1); break; - case DEV_IOCTL_S: do_ioctl(tp, &tty_mess, 1); break; + case DEV_READ_S: do_read(tp, &tty_mess); break; + case DEV_WRITE_S: do_write(tp, &tty_mess); break; + case DEV_IOCTL_S: do_ioctl(tp, &tty_mess); break; case DEV_OPEN: do_open(tp, &tty_mess); break; case DEV_CLOSE: do_close(tp, &tty_mess); break; case DEV_SELECT: do_select(tp, &tty_mess); break; @@ -399,7 +380,7 @@ message *m_ptr; /* Suspended request finished. Send a REVIVE. */ m_ptr->m_type = DEV_REVIVE; m_ptr->REP_ENDPT = tp->tty_inproc; - m_ptr->REP_IO_GRANT = tp->tty_in_vir_g; + m_ptr->REP_IO_GRANT = tp->tty_ingrant; m_ptr->REP_STATUS = tp->tty_incum; tp->tty_inleft = tp->tty_incum = 0; @@ -412,7 +393,7 @@ message *m_ptr; /* Suspended request finished. Send a REVIVE. */ m_ptr->m_type = DEV_REVIVE; m_ptr->REP_ENDPT = tp->tty_outproc; - m_ptr->REP_IO_GRANT = tp->tty_out_vir_g; + m_ptr->REP_IO_GRANT = tp->tty_outgrant; m_ptr->REP_STATUS = tp->tty_outcum; tp->tty_outcum = 0; @@ -424,7 +405,7 @@ message *m_ptr; /* Suspended request finished. Send a REVIVE. */ m_ptr->m_type = DEV_REVIVE; m_ptr->REP_ENDPT = tp->tty_ioproc; - m_ptr->REP_IO_GRANT = tp->tty_iovir_g; + m_ptr->REP_IO_GRANT = tp->tty_iogrant; m_ptr->REP_STATUS = tp->tty_iostatus; tp->tty_iorevived = 0; /* unmark revive event */ event_found = 1; @@ -455,10 +436,9 @@ message *m_ptr; /*===========================================================================* * do_read * *===========================================================================*/ -PRIVATE void do_read(tp, m_ptr, safe) +PRIVATE void do_read(tp, m_ptr) register tty_t *tp; /* pointer to tty struct */ register message *m_ptr; /* pointer to message sent to the task */ -int safe; /* use safecopies? */ { /* A process wants to read from a terminal. */ int r; @@ -476,9 +456,8 @@ int safe; /* use safecopies? */ tp->tty_inrepcode = TASK_REPLY; tp->tty_incaller = m_ptr->m_source; tp->tty_inproc = m_ptr->IO_ENDPT; - tp->tty_in_vir_g = (vir_bytes) m_ptr->ADDRESS; - tp->tty_in_vir_offset = 0; - tp->tty_in_safe = safe; + tp->tty_ingrant = (cp_grant_id_t) m_ptr->IO_GRANT; + tp->tty_inoffset = 0; tp->tty_inleft = m_ptr->COUNT; if (!(tp->tty_termios.c_lflag & ICANON) @@ -524,10 +503,9 @@ int safe; /* use safecopies? */ /*===========================================================================* * do_write * *===========================================================================*/ -PRIVATE void do_write(tp, m_ptr, safe) +PRIVATE void do_write(tp, m_ptr) register tty_t *tp; register message *m_ptr; /* pointer to message sent to the task */ -int safe; { /* A process wants to write on a terminal. */ int r; @@ -545,9 +523,8 @@ int safe; tp->tty_outrepcode = TASK_REPLY; tp->tty_outcaller = m_ptr->m_source; tp->tty_outproc = m_ptr->IO_ENDPT; - tp->tty_out_vir_g = (vir_bytes) m_ptr->ADDRESS; - tp->tty_out_vir_offset = 0; - tp->tty_out_safe = safe; + tp->tty_outgrant = (cp_grant_id_t) m_ptr->IO_GRANT; + tp->tty_outoffset = 0; tp->tty_outleft = m_ptr->COUNT; /* Try to write. */ @@ -567,10 +544,9 @@ int safe; /*===========================================================================* * do_ioctl * *===========================================================================*/ -PRIVATE void do_ioctl(tp, m_ptr, safe) +PRIVATE void do_ioctl(tp, m_ptr) register tty_t *tp; message *m_ptr; /* pointer to message sent to task */ -int safe; { /* Perform an IOCTL on this terminal. Posix termios calls are handled * by the IOCTL system call @@ -622,14 +598,8 @@ int safe; switch (m_ptr->TTY_REQUEST) { case TCGETS: /* Get the termios attributes. */ - if(safe) { - r = sys_safecopyto(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, + r = sys_safecopyto(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, 0, (vir_bytes) &tp->tty_termios, (vir_bytes) size, D); - } else { - r = sys_vircopy(SELF, D, (vir_bytes) &tp->tty_termios, - m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - (vir_bytes) size); - } break; case TCSETSW: @@ -640,8 +610,7 @@ int safe; tp->tty_iocaller = m_ptr->m_source; tp->tty_ioproc = m_ptr->IO_ENDPT; tp->tty_ioreq = m_ptr->REQUEST; - tp->tty_iovir_g = (vir_bytes) m_ptr->ADDRESS; - tp->tty_io_safe = safe; + tp->tty_iogrant = (cp_grant_id_t) m_ptr->IO_GRANT; r = SUSPEND; break; } @@ -650,25 +619,15 @@ int safe; /*FALL THROUGH*/ case TCSETS: /* Set the termios attributes. */ - if(safe) { - r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, - (vir_bytes) &tp->tty_termios, (vir_bytes) size, D); - } else { - r = sys_vircopy( m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - SELF, D, (vir_bytes) &tp->tty_termios, (vir_bytes) size); - } + r = sys_safecopyfrom(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, + 0, (vir_bytes) &tp->tty_termios, (vir_bytes) size, D); if (r != OK) break; setattr(tp); break; case TCFLSH: - if(safe) { - r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, - (vir_bytes) ¶m.i, (vir_bytes) size, D); - } else { - r = sys_vircopy(m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - SELF, D, (vir_bytes) ¶m.i, (vir_bytes) size); - } + r = sys_safecopyfrom(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, + 0, (vir_bytes) ¶m.i, (vir_bytes) size, D); if (r != OK) break; switch (param.i) { case TCIFLUSH: tty_icancel(tp); break; @@ -679,13 +638,8 @@ int safe; break; case TCFLOW: - if(safe) { - r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, - (vir_bytes) ¶m.i, (vir_bytes) size, D); - } else { - r = sys_vircopy( m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - SELF, D, (vir_bytes) ¶m.i, (vir_bytes) size); - } + r = sys_safecopyfrom(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, + 0, (vir_bytes) ¶m.i, (vir_bytes) size, D); if (r != OK) break; switch (param.i) { case TCOOFF: @@ -709,31 +663,20 @@ int safe; break; case TIOCGWINSZ: - if(safe) { - r = sys_safecopyto(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, + r = sys_safecopyto(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, 0, (vir_bytes) &tp->tty_winsize, (vir_bytes) size, D); - } else { - r = sys_vircopy(SELF, D, (vir_bytes) &tp->tty_winsize, - m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - (vir_bytes) size); - } break; case TIOCSWINSZ: - if(safe) { - r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS, 0, - (vir_bytes) &tp->tty_winsize, (vir_bytes) size, D); - } else { - r = sys_vircopy( m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS, - SELF, D, (vir_bytes) &tp->tty_winsize, (vir_bytes) size); - } + r = sys_safecopyfrom(m_ptr->IO_ENDPT, (cp_grant_id_t) m_ptr->IO_GRANT, + 0, (vir_bytes) &tp->tty_winsize, (vir_bytes) size, D); sigchar(tp, SIGWINCH, 0); break; #if (MACHINE == IBM_PC) case KIOCSMAP: /* Load a new keymap (only /dev/console). */ - if (isconsole(tp)) r = kbd_loadmap(m_ptr, safe); + if (isconsole(tp)) r = kbd_loadmap(m_ptr); break; case TIOCSFON_OLD: @@ -745,12 +688,6 @@ int safe; break; #endif -#if (MACHINE == ATARI) - case VDU_LOADFONT: - r = vdu_loadfont(m_ptr); - break; -#endif - /* These Posix functions are allowed to fail if _POSIX_JOB_CONTROL is * not defined. */ @@ -830,14 +767,14 @@ message *m_ptr; /* pointer to message sent to task */ proc_nr = m_ptr->IO_ENDPT; mode = m_ptr->COUNT; if ((mode & R_BIT) && tp->tty_inleft != 0 && proc_nr == tp->tty_inproc && - (!tp->tty_in_safe || tp->tty_in_vir_g==(vir_bytes)m_ptr->IO_GRANT)) { + tp->tty_ingrant == (cp_grant_id_t) m_ptr->IO_GRANT) { /* Process was reading when killed. Clean up input. */ tty_icancel(tp); r = tp->tty_incum > 0 ? tp->tty_incum : EAGAIN; tp->tty_inleft = tp->tty_incum = tp->tty_inrevived = 0; } if ((mode & W_BIT) && tp->tty_outleft != 0 && proc_nr == tp->tty_outproc && - (!tp->tty_out_safe || tp->tty_out_vir_g==(vir_bytes)m_ptr->IO_GRANT)) { + tp->tty_outgrant == (cp_grant_id_t) m_ptr->IO_GRANT) { /* Process was writing when killed. Clean up output. */ r = tp->tty_outcum > 0 ? tp->tty_outcum : EAGAIN; tp->tty_outleft = tp->tty_outcum = tp->tty_outrevived = 0; @@ -976,18 +913,11 @@ register tty_t *tp; /* pointer to terminal to read from */ tp->tty_inleft--; if (++bp == bufend(buf)) { /* Temp buffer full, copy to user space. */ - if(tp->tty_in_safe) { - sys_safecopyto(tp->tty_inproc, - tp->tty_in_vir_g, tp->tty_in_vir_offset, - (vir_bytes) buf, - (vir_bytes) buflen(buf), D); - tp->tty_in_vir_offset += buflen(buf); - } else { - sys_vircopy(SELF, D, (vir_bytes) buf, - tp->tty_inproc, D, tp->tty_in_vir_g, - (vir_bytes) buflen(buf)); - tp->tty_in_vir_g += buflen(buf); - } + sys_safecopyto(tp->tty_inproc, + tp->tty_ingrant, tp->tty_inoffset, + (vir_bytes) buf, + (vir_bytes) buflen(buf), D); + tp->tty_inoffset += buflen(buf); tp->tty_incum += buflen(buf); bp = buf; } @@ -1007,16 +937,10 @@ register tty_t *tp; /* pointer to terminal to read from */ if (bp > buf) { /* Leftover characters in the buffer. */ count = bp - buf; - if(tp->tty_in_safe) { - sys_safecopyto(tp->tty_inproc, - tp->tty_in_vir_g, tp->tty_in_vir_offset, - (vir_bytes) buf, (vir_bytes) count, D); - tp->tty_in_vir_offset += count; - } else { - sys_vircopy(SELF, D, (vir_bytes) buf, - tp->tty_inproc, D, tp->tty_in_vir_g, (vir_bytes) count); - tp->tty_in_vir_g += count; - } + sys_safecopyto(tp->tty_inproc, + tp->tty_ingrant, tp->tty_inoffset, + (vir_bytes) buf, (vir_bytes) count, D); + tp->tty_inoffset += count; tp->tty_incum += count; } @@ -1453,16 +1377,10 @@ tty_t *tp; if (tp->tty_ioreq != TCDRAIN) { if (tp->tty_ioreq == TCSETSF) tty_icancel(tp); - if(tp->tty_io_safe) { - result = sys_safecopyfrom(tp->tty_ioproc, tp->tty_iovir_g, 0, + result = sys_safecopyfrom(tp->tty_ioproc, tp->tty_iogrant, 0, (vir_bytes) &tp->tty_termios, (vir_bytes) sizeof(tp->tty_termios), D); - } else { - result = sys_vircopy(tp->tty_ioproc, D, tp->tty_iovir_g, - SELF, D, (vir_bytes) &tp->tty_termios, - (vir_bytes) sizeof(tp->tty_termios)); - } - setattr(tp); + if (result == OK) setattr(tp); } tp->tty_ioreq = 0; notify(tp->tty_iocaller); diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 5a04570b2..2f82e7be4 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -66,18 +66,16 @@ typedef struct tty { char tty_inrevived; /* set to 1 if revive callback is pending */ int tty_incaller; /* process that made the call (usually FS) */ int tty_inproc; /* process that wants to read from tty */ - vir_bytes tty_in_vir_g; /* address or grant where data is to go */ - vir_bytes tty_in_vir_offset; /* offset into grant */ - int tty_in_safe; /* nonzero: safecopies (in_vir is grantid) */ + cp_grant_id_t tty_ingrant; /* grant where data is to go */ + vir_bytes tty_inoffset; /* offset into grant */ int tty_inleft; /* how many chars are still needed */ int tty_incum; /* # chars input so far */ int tty_outrepcode; /* reply code, TASK_REPLY or REVIVE */ int tty_outrevived; /* set to 1 if revive callback is pending */ int tty_outcaller; /* process that made the call (usually FS) */ int tty_outproc; /* process that wants to write to tty */ - vir_bytes tty_out_vir_g; /* address or grant where data comes from */ - vir_bytes tty_out_vir_offset; /* offset into grant */ - int tty_out_safe; /* nonzero: safecopies (out_vir is grantid) */ + cp_grant_id_t tty_outgrant; /* grant where data comes from */ + vir_bytes tty_outoffset; /* offset into grant */ int tty_outleft; /* # chars yet to be output */ int tty_outcum; /* # chars output so far */ int tty_iocaller; /* process that made the call (usually FS) */ @@ -85,8 +83,7 @@ typedef struct tty { int tty_ioproc; /* process that wants to do an ioctl */ int tty_iostatus; /* result */ int tty_ioreq; /* ioctl request code */ - int tty_io_safe; /* safe copy mode? (iovir is grant id) */ - vir_bytes tty_iovir_g; /* virtual address of ioctl buffer or grant */ + cp_grant_id_t tty_iogrant; /* virtual address of ioctl buffer or grant */ /* select() data */ int tty_select_ops; /* which operations are interesting */ @@ -163,9 +160,6 @@ _PROTOTYPE( void rs_interrupt, (message *m) ); _PROTOTYPE( void kputc, (int c) ); _PROTOTYPE( void cons_stop, (void) ); _PROTOTYPE( void do_new_kmess, (void) ); -_PROTOTYPE( void do_diagnostics, (message *m, int safe) ); -_PROTOTYPE( void do_get_kmess, (message *m) ); -_PROTOTYPE( void do_get_kmess_s, (message *m) ); _PROTOTYPE( void scr_init, (struct tty *tp) ); _PROTOTYPE( void toggle_scroll, (void) ); _PROTOTYPE( int con_loadfont, (message *m) ); @@ -176,7 +170,7 @@ _PROTOTYPE( void do_video, (message *m) ); /* keyboard.c */ _PROTOTYPE( void kb_init, (struct tty *tp) ); _PROTOTYPE( void kb_init_once, (void) ); -_PROTOTYPE( int kbd_loadmap, (message *m, int safe) ); +_PROTOTYPE( int kbd_loadmap, (message *m) ); _PROTOTYPE( void do_fkey_ctl, (message *m) ); _PROTOTYPE( void kbd_interrupt, (message *m) ); _PROTOTYPE( void do_kbd, (message *m) );