Replace REVIVE with notify.
This commit is contained in:
		
							parent
							
								
									1198491af2
								
							
						
					
					
						commit
						537d7ddcdf
					
				| @ -17,6 +17,7 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include "../drivers.h" | #include "../drivers.h" | ||||||
|  | #include <assert.h> | ||||||
| #include <termios.h> | #include <termios.h> | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
| #include <minix/com.h> | #include <minix/com.h> | ||||||
| @ -31,7 +32,7 @@ typedef struct pty { | |||||||
|   char		state;		/* flags: busy, closed, ... */ |   char		state;		/* flags: busy, closed, ... */ | ||||||
| 
 | 
 | ||||||
|   /* Read call on /dev/ptypX. */ |   /* Read call on /dev/ptypX. */ | ||||||
|   char		rdrepcode;	/* reply code, TASK_REPLY or REVIVE */ |   char		rdsendreply;	/* send a reply (instead of notify) */ | ||||||
|   char		rdcaller;	/* process making the call (usually FS) */ |   char		rdcaller;	/* process making the call (usually FS) */ | ||||||
|   char		rdproc;		/* process that wants to read from the pty */ |   char		rdproc;		/* process that wants to read from the pty */ | ||||||
|   vir_bytes	rdvir;		/* virtual address in readers address space */ |   vir_bytes	rdvir;		/* virtual address in readers address space */ | ||||||
| @ -39,7 +40,7 @@ typedef struct pty { | |||||||
|   int		rdcum;		/* # bytes written so far */ |   int		rdcum;		/* # bytes written so far */ | ||||||
| 
 | 
 | ||||||
|   /* Write call to /dev/ptypX. */ |   /* Write call to /dev/ptypX. */ | ||||||
|   char		wrrepcode;	/* reply code, TASK_REPLY or REVIVE */ |   char		wrsendreply;	/* send a reply (instead of notify) */ | ||||||
|   char		wrcaller;	/* process making the call (usually FS) */ |   char		wrcaller;	/* process making the call (usually FS) */ | ||||||
|   char		wrproc;		/* process that wants to write to the pty */ |   char		wrproc;		/* process that wants to write to the pty */ | ||||||
|   vir_bytes	wrvir;		/* virtual address in writers address space */ |   vir_bytes	wrvir;		/* virtual address in writers address space */ | ||||||
| @ -88,7 +89,7 @@ message *m_ptr; | |||||||
| 		r = 0; | 		r = 0; | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	if (pp->rdleft != 0) { | 	if (pp->rdleft != 0 || pp->rdcum != 0) { | ||||||
| 		r = EIO; | 		r = EIO; | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| @ -105,7 +106,7 @@ message *m_ptr; | |||||||
| #endif | #endif | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	pp->rdrepcode = TASK_REPLY; | 	pp->rdsendreply = TRUE; | ||||||
| 	pp->rdcaller = m_ptr->m_source; | 	pp->rdcaller = m_ptr->m_source; | ||||||
| 	pp->rdproc = m_ptr->PROC_NR; | 	pp->rdproc = m_ptr->PROC_NR; | ||||||
| 	pp->rdvir = (vir_bytes) m_ptr->ADDRESS; | 	pp->rdvir = (vir_bytes) m_ptr->ADDRESS; | ||||||
| @ -119,7 +120,7 @@ message *m_ptr; | |||||||
| 		pp->rdleft = pp->rdcum = 0; | 		pp->rdleft = pp->rdcum = 0; | ||||||
| 	} else { | 	} else { | ||||||
| 		r = SUSPEND;				/* do suspend */ | 		r = SUSPEND;				/* do suspend */ | ||||||
| 		pp->rdrepcode = REVIVE; | 		pp->rdsendreply = FALSE; | ||||||
| 	} | 	} | ||||||
| 	break; | 	break; | ||||||
| 
 | 
 | ||||||
| @ -129,7 +130,7 @@ message *m_ptr; | |||||||
| 		r = EIO; | 		r = EIO; | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	if (pp->wrleft != 0) { | 	if (pp->wrleft != 0 || pp->wrcum != 0) { | ||||||
| 		r = EIO; | 		r = EIO; | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| @ -147,7 +148,7 @@ message *m_ptr; | |||||||
| #endif | #endif | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	pp->wrrepcode = TASK_REPLY; | 	pp->wrsendreply = TRUE; | ||||||
| 	pp->wrcaller = m_ptr->m_source; | 	pp->wrcaller = m_ptr->m_source; | ||||||
| 	pp->wrproc = m_ptr->PROC_NR; | 	pp->wrproc = m_ptr->PROC_NR; | ||||||
| 	pp->wrvir = (vir_bytes) m_ptr->ADDRESS; | 	pp->wrvir = (vir_bytes) m_ptr->ADDRESS; | ||||||
| @ -159,7 +160,7 @@ message *m_ptr; | |||||||
| 		r = pp->wrcum > 0 ? pp->wrcum : EAGAIN; | 		r = pp->wrcum > 0 ? pp->wrcum : EAGAIN; | ||||||
| 		pp->wrleft = pp->wrcum = 0; | 		pp->wrleft = pp->wrcum = 0; | ||||||
| 	} else { | 	} else { | ||||||
| 		pp->wrrepcode = REVIVE;			/* do suspend */ | 		pp->wrsendreply = FALSE;			/* do suspend */ | ||||||
| 		r = SUSPEND; | 		r = SUSPEND; | ||||||
| 	} | 	} | ||||||
| 	break; | 	break; | ||||||
| @ -167,6 +168,8 @@ message *m_ptr; | |||||||
|     case DEV_OPEN: |     case DEV_OPEN: | ||||||
| 	r = pp->state != 0 ? EIO : OK; | 	r = pp->state != 0 ? EIO : OK; | ||||||
| 	pp->state |= PTY_ACTIVE; | 	pp->state |= PTY_ACTIVE; | ||||||
|  | 	pp->rdcum = 0; | ||||||
|  | 	pp->wrcum = 0; | ||||||
| 	break; | 	break; | ||||||
| 
 | 
 | ||||||
|     case DEV_CLOSE: |     case DEV_CLOSE: | ||||||
| @ -338,8 +341,12 @@ pty_t *pp; | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|   if (pp->rdcum > 0) { |   if (pp->rdcum > 0) { | ||||||
| 	tty_reply(pp->rdrepcode, pp->rdcaller, pp->rdproc, pp->rdcum); |         if (pp->rdsendreply) { | ||||||
| 	pp->rdleft = pp->rdcum = 0; | 		tty_reply(TASK_REPLY, pp->rdcaller, pp->rdproc, pp->rdcum); | ||||||
|  | 		pp->rdleft = pp->rdcum = 0; | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 		notify(pp->rdcaller); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -390,8 +397,13 @@ int try; | |||||||
| 	pp->wrvir++; | 	pp->wrvir++; | ||||||
| 	pp->wrcum++; | 	pp->wrcum++; | ||||||
| 	if (--pp->wrleft == 0) { | 	if (--pp->wrleft == 0) { | ||||||
| 		tty_reply(pp->wrrepcode, pp->wrcaller, pp->wrproc, pp->wrcum); | 		if (pp->wrsendreply) { | ||||||
| 		pp->wrcum = 0; | 			tty_reply(TASK_REPLY, pp->wrcaller, pp->wrproc, | ||||||
|  | 				pp->wrcum); | ||||||
|  | 			pp->wrcum = 0; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 			notify(pp->wrcaller); | ||||||
| 	} | 	} | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -410,13 +422,13 @@ int try; | |||||||
|   if (!(pp->state & PTY_ACTIVE)) return; |   if (!(pp->state & PTY_ACTIVE)) return; | ||||||
| 
 | 
 | ||||||
|   if (pp->rdleft > 0) { |   if (pp->rdleft > 0) { | ||||||
| 	tty_reply(pp->rdrepcode, pp->rdcaller, pp->rdproc, 0); |   	assert(!pp->rdsendreply); | ||||||
| 	pp->rdleft = pp->rdcum = 0; |   	notify(pp->rdcaller); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (pp->wrleft > 0) { |   if (pp->wrleft > 0) { | ||||||
| 	tty_reply(pp->wrrepcode, pp->wrcaller, pp->wrproc, EIO); |   	assert(!pp->wrsendreply); | ||||||
| 	pp->wrleft = pp->wrcum = 0; |   	notify(pp->wrcaller); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (pp->state & PTY_CLOSED) pp->state = 0; else pp->state |= TTY_CLOSED; |   if (pp->state & PTY_CLOSED) pp->state = 0; else pp->state |= TTY_CLOSED; | ||||||
| @ -434,9 +446,10 @@ int try; | |||||||
|   pty_t *pp = tp->tty_priv; |   pty_t *pp = tp->tty_priv; | ||||||
| 
 | 
 | ||||||
|   if (pp->wrleft > 0) { |   if (pp->wrleft > 0) { | ||||||
| 	tty_reply(pp->wrrepcode, pp->wrcaller, pp->wrproc, |   	assert(!pp->wrsendreply); | ||||||
| 						pp->wrcum + pp->wrleft); |   	pp->wrcum += pp->wrleft; | ||||||
| 	pp->wrleft = pp->wrcum = 0; |   	pp->wrleft= 0; | ||||||
|  |   	notify(pp->wrcaller); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -481,4 +494,48 @@ tty_t *tp; | |||||||
|   tp->tty_ocancel = pty_ocancel; |   tp->tty_ocancel = pty_ocancel; | ||||||
|   tp->tty_close = pty_close; |   tp->tty_close = pty_close; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /*==========================================================================*
 | ||||||
|  |  *				pty_status				    * | ||||||
|  |  *==========================================================================*/ | ||||||
|  | PUBLIC int pty_status(message *m_ptr) | ||||||
|  | { | ||||||
|  | 	int i, event_found; | ||||||
|  | 	pty_t *pp; | ||||||
|  | 
 | ||||||
|  | 	event_found = 0; | ||||||
|  | 	for (i= 0, pp = pty_table; i<NR_PTYS; i++, pp++) { | ||||||
|  | 		if (((pp->state & TTY_CLOSED && pp->rdleft > 0) || | ||||||
|  | 			pp->rdcum > 0) && | ||||||
|  | 			pp->rdcaller == m_ptr->m_source) | ||||||
|  | 		{ | ||||||
|  | 			m_ptr->m_type = DEV_REVIVE; | ||||||
|  | 			m_ptr->REP_PROC_NR = pp->rdproc; | ||||||
|  | 			m_ptr->REP_STATUS = pp->rdcum; | ||||||
|  | 
 | ||||||
|  | 			pp->rdleft = pp->rdcum = 0; | ||||||
|  | 			event_found = 1; | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if (((pp->state & TTY_CLOSED && pp->wrleft > 0) || | ||||||
|  | 			pp->wrcum > 0) && | ||||||
|  | 			pp->wrcaller == m_ptr->m_source) | ||||||
|  | 		{ | ||||||
|  | 			m_ptr->m_type = DEV_REVIVE; | ||||||
|  | 			m_ptr->REP_PROC_NR = pp->wrproc; | ||||||
|  | 			if (pp->wrcum == 0) | ||||||
|  | 				m_ptr->REP_STATUS = EIO; | ||||||
|  | 			else | ||||||
|  | 				m_ptr->REP_STATUS = pp->wrcum; | ||||||
|  | 
 | ||||||
|  | 			pp->wrleft = pp->wrcum = 0; | ||||||
|  | 			event_found = 1; | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return event_found; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #endif /* NR_PTYS > 0 */ | #endif /* NR_PTYS > 0 */ | ||||||
|  | |||||||
| @ -352,6 +352,9 @@ message *m_ptr; | |||||||
| 	} | 	} | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   if (!event_found) | ||||||
|  |   	event_found = pty_status(m_ptr); | ||||||
|  | 
 | ||||||
|   if (! event_found) { |   if (! event_found) { | ||||||
| 	/* No events of interest were found. Return an empty message. */ | 	/* No events of interest were found. Return an empty message. */ | ||||||
|   	m_ptr->m_type = DEV_NO_STATUS; |   	m_ptr->m_type = DEV_NO_STATUS; | ||||||
|  | |||||||
| @ -155,6 +155,7 @@ _PROTOTYPE( void kbd_interrupt, (message *m)				); | |||||||
| /* pty.c */ | /* pty.c */ | ||||||
| _PROTOTYPE( void do_pty, (struct tty *tp, message *m_ptr)		); | _PROTOTYPE( void do_pty, (struct tty *tp, message *m_ptr)		); | ||||||
| _PROTOTYPE( void pty_init, (struct tty *tp)				); | _PROTOTYPE( void pty_init, (struct tty *tp)				); | ||||||
|  | _PROTOTYPE( int pty_status, (message *m_ptr)				); | ||||||
| 
 | 
 | ||||||
| /* vidcopy.s */ | /* vidcopy.s */ | ||||||
| _PROTOTYPE( void vid_vid_copy, (unsigned src, unsigned dst, unsigned count)); | _PROTOTYPE( void vid_vid_copy, (unsigned src, unsigned dst, unsigned count)); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Philip Homburg
						Philip Homburg