Furthermore, a quick way to get one's own process number.
#include <sys/ioc_tty.h>
#include <signal.h>
#include <minix/callnr.h>
-#include <minix/com.h>
#if (CHIP == INTEL)
#include <minix/keymap.h>
#endif
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 in_transfer, (tty_t *tp) );
-FORWARD _PROTOTYPE( int echo, (tty_t *tp, int ch) );
+FORWARD _PROTOTYPE( int tty_echo, (tty_t *tp, int ch) );
FORWARD _PROTOTYPE( void rawecho, (tty_t *tp, int ch) );
FORWARD _PROTOTYPE( int back_over, (tty_t *tp) );
FORWARD _PROTOTYPE( void reprint, (tty_t *tp) );
if (ch == tp->tty_termios.c_cc[VERASE]) {
(void) back_over(tp);
if (!(tp->tty_termios.c_lflag & ECHOE)) {
- (void) echo(tp, ch);
+ (void) tty_echo(tp, ch);
}
continue;
}
if (ch == tp->tty_termios.c_cc[VKILL]) {
while (back_over(tp)) {}
if (!(tp->tty_termios.c_lflag & ECHOE)) {
- (void) echo(tp, ch);
+ (void) tty_echo(tp, ch);
if (tp->tty_termios.c_lflag & ECHOK)
rawecho(tp, '\n');
}
sig = SIGINT;
if (ch == tp->tty_termios.c_cc[VQUIT]) sig = SIGQUIT;
sigchar(tp, sig);
- (void) echo(tp, ch);
+ (void) tty_echo(tp, ch);
continue;
}
}
}
/* Perform the intricate function of echoing. */
- if (tp->tty_termios.c_lflag & (ECHO|ECHONL)) ch = echo(tp, ch);
+ if (tp->tty_termios.c_lflag & (ECHO|ECHONL)) ch = tty_echo(tp, ch);
/* Save the character in the input queue. */
*tp->tty_inhead++ = ch;
/*===========================================================================*
* echo *
*===========================================================================*/
-PRIVATE int echo(tp, ch)
+PRIVATE int tty_echo(tp, ch)
register tty_t *tp; /* terminal on which to echo */
register int ch; /* pointer to character to echo */
{
if (count == tp->tty_incount) return; /* no reason to reprint */
/* Show REPRINT (^R) and move to a new line. */
- (void) echo(tp, tp->tty_termios.c_cc[VREPRINT] | IN_ESC);
+ (void) tty_echo(tp, tp->tty_termios.c_cc[VREPRINT] | IN_ESC);
rawecho(tp, '\r');
rawecho(tp, '\n');
/* Reprint from the last break onwards. */
do {
if (head == bufend(tp->tty_inbuf)) head = tp->tty_inbuf;
- *head = echo(tp, *head);
+ *head = tty_echo(tp, *head);
head++;
count++;
} while (count < tp->tty_incount);
/*===========================================================================*
- * System calls and magic process numbers *
+ * Magic process numbers *
*===========================================================================*/
-/* Masks and flags for system calls. */
-#define SYSCALL_FUNC 0x0F /* mask for system call function */
-#define SYSCALL_FLAGS 0xF0 /* mask for system call flags */
-#define NON_BLOCKING 0x10 /* prevent blocking, return error */
-#define FRESH_ANSWER 0x20 /* ignore pending notifications as answer */
- /* default behaviour for SENDREC calls */
-
-/* System calls (numbers passed when trapping to the kernel) */
-#define SEND 1 /* function code for sending messages */
-#define RECEIVE 2 /* function code for receiving messages */
-#define SENDREC 3 /* function code for SEND + RECEIVE */
-#define NOTIFY 4 /* function code for notifications */
-#define NB_SEND (SEND | NON_BLOCKING) /* non-blocking SEND */
-#define NB_RECEIVE (RECEIVE | NON_BLOCKING) /* non-blocking RECEIVE */
-
-/* Magic, invalid process numbers. */
#define ANY 0x7ace /* used to indicate 'any process' */
#define NONE 0x6ace /* used to indicate 'no process at all' */
#define SELF 0x8ace /* used to indicate 'own process' */
*==========================================================================*/
/* Hide names to avoid name space pollution. */
+#define echo _echo
#define sendrec _sendrec
#define receive _receive
#define send _send
#define nb_receive _nb_receive
#define nb_send _nb_send
+_PROTOTYPE( int echo, (message *m_ptr) );
_PROTOTYPE( int sendrec, (int src_dest, message *m_ptr) );
_PROTOTYPE( int receive, (int src, message *m_ptr) );
_PROTOTYPE( int send, (int dest, message *m_ptr) );
proc.o: $h/callnr.h
proc.o: $h/com.h
proc.o: proc.h
+proc.o: ipc.h
proc.o: sendmask.h
protect.o: $a
--- /dev/null
+/* Masks and flags for system calls. */
+#define SYSCALL_FUNC 0x0F /* mask for system call function */
+#define SYSCALL_FLAGS 0xF0 /* mask for system call flags */
+#define NON_BLOCKING 0x10 /* prevent blocking, return error */
+#define FRESH_ANSWER 0x20 /* ignore pending notifications as answer */
+ /* (default behaviour for SENDREC calls) */
+
+/* System calls (numbers passed when trapping to the kernel) */
+#define ECHO 0 /* function code for echoing messages */
+#define SEND 1 /* function code for sending messages */
+#define RECEIVE 2 /* function code for receiving messages */
+#define SENDREC 3 /* function code for SEND + RECEIVE */
+#define NOTIFY 4 /* function code for notifications */
+
#include <minix/callnr.h>
#include <minix/com.h>
#include "proc.h"
+#include "ipc.h"
#include "sendmask.h"
return(ECALLDENIED); /* SENDREC was required */
/* Verify that requested source and/ or destination is a valid process. */
- if (! isoksrc_dst(src_dst))
+ if (! isoksrc_dst(src_dst) && function != ECHO)
return(EBADSRCDST);
/* Check validity of message pointer. */
case NOTIFY:
result = mini_notify(caller_ptr, src_dst, m_ptr);
break;
+ case ECHO:
+ kprintf("Echo message from process %s\n", proc_nr(caller_ptr));
+ CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, caller_ptr, m_ptr);
+ result = OK;
+ break;
default:
result = EBADCALL; /* illegal system call */
}
.sect .text; .sect .rom; .sect .data; .sect .bss
-.define __send, __nb_send, __receive, __nb_receive, __sendrec, __notify
+.define __echo, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify
-! See ../h/com.h for C definitions
+! See src/kernel/ipc.h for C definitions
+ECHO = 0
SEND = 1
RECEIVE = 2
BOTH = 3
NOTIFY = 4
NB_SEND = 1 + 16 ! SEND | 0xF0
NB_RECEIVE = 2 + 16 ! RECEIVE | 0xF0
-SYSVEC = 33
+SYSVEC = 33 ! trap to kernel
-SRCDEST = 8
-MESSAGE = 12
+SRC_DST = 8 ! source/ destination process
+ECHO_MESS = 8 ! doesn't have SRC_DST
+MESSAGE = 12 ! message pointer
!*========================================================================*
-! _send and _receive *
+! IPC assembly routines *
!*========================================================================*
-! _send(), _nb_send(), _receive(), _nb_receive(), and _sendrec() all
-! save ebp, but destroy eax and ecx.
-.define __send, __nb_send, __receive, __nb_receive, __sendrec, __notify
+! all message passing routines save ebp, but destroy eax and ecx.
+.define __echo, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify
.sect .text
__send:
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, SEND ! _send(dest, ptr)
int SYSVEC ! trap to the kernel
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, NB_SEND ! _nb_send(dest, ptr)
int SYSVEC ! trap to the kernel
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, RECEIVE ! _receive(src, ptr)
int SYSVEC ! trap to the kernel
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, NB_RECEIVE ! _nb_receive(src, ptr)
int SYSVEC ! trap to the kernel
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, BOTH ! _sendrec(srcdest, ptr)
int SYSVEC ! trap to the kernel
push ebp
mov ebp, esp
push ebx
- mov eax, SRCDEST(ebp) ! eax = dest-src
+ mov eax, SRC_DST(ebp) ! eax = dest-src
mov ebx, MESSAGE(ebp) ! ebx = message pointer
mov ecx, NOTIFY ! _notify(srcdest, ptr)
int SYSVEC ! trap to the kernel
pop ebp
ret
+__echo:
+ push ebp
+ mov ebp, esp
+ push ebx
+ mov ebx, ECHO_MESS(ebp) ! ebx = message pointer
+ mov ecx, ECHO ! _echo(srcdest, ptr)
+ int SYSVEC ! trap to the kernel
+ pop ebx
+ pop ebp
+ ret
+