Nits here and there. Made log device buffer messages again.
This commit is contained in:
parent
b9b334c38c
commit
d09f170abc
@ -23,7 +23,7 @@ LIBDRIVER = $d/libdriver/driver.o
|
||||
all build: $(DRIVER)
|
||||
$(DRIVER): $(OBJ) $(LIBDRIVER)
|
||||
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS)
|
||||
install -S 64w $(DRIVER)
|
||||
install -S 4kb $(DRIVER)
|
||||
|
||||
$(LIBDRIVER):
|
||||
cd $d/libdriver && $(MAKE)
|
||||
|
@ -48,14 +48,14 @@ message *m; /* notification message */
|
||||
i=0;
|
||||
while (bytes > 0) {
|
||||
print_buf[i] = kmess.km_buf[(r%KMESS_BUF_SIZE)];
|
||||
log_putc( kmess.km_buf[(r%KMESS_BUF_SIZE)] );
|
||||
bytes --;
|
||||
r ++;
|
||||
i ++;
|
||||
}
|
||||
/* Now terminate the new message and print it. */
|
||||
print_buf[i] = 0;
|
||||
printf(print_buf);
|
||||
printf("%s", print_buf);
|
||||
log_append(print_buf, i);
|
||||
}
|
||||
|
||||
/* Almost done, store 'next' so that we can determine what part of the
|
||||
@ -82,7 +82,7 @@ PUBLIC int do_diagnostics(message *m)
|
||||
int count;
|
||||
char c;
|
||||
int i = 0;
|
||||
static char diagbuf[1024];
|
||||
static char diagbuf[10240];
|
||||
|
||||
/* Forward the message to the TTY driver. Inform the TTY driver about the
|
||||
* original sender, so that it knows where the buffer to be printed is.
|
||||
@ -97,26 +97,14 @@ PUBLIC int do_diagnostics(message *m)
|
||||
*/
|
||||
src = (vir_bytes) m->DIAG_PRINT_BUF;
|
||||
count = m->DIAG_BUF_COUNT;
|
||||
while (count > 0) {
|
||||
while (count > 0 && i < sizeof(diagbuf)-1) {
|
||||
if (sys_datacopy(proc_nr, src, SELF, (vir_bytes) &c, 1) != OK)
|
||||
break; /* stop copying on error */
|
||||
log_putc(c); /* accumulate character */
|
||||
src ++;
|
||||
count --;
|
||||
diagbuf[i++] = c;
|
||||
}
|
||||
log_append(diagbuf, i);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* log_putc *
|
||||
*===========================================================================*/
|
||||
PUBLIC void log_putc(c)
|
||||
int c; /* char to be added to diag buffer */
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -112,8 +112,13 @@ subwrite(struct logdevice *log, int count, int proc_nr, vir_bytes user_vir)
|
||||
count = LOG_SIZE - log->log_write;
|
||||
buf = log->log_buffer + log->log_write;
|
||||
|
||||
if((r=sys_vircopy(proc_nr,D,user_vir, SELF,D,(int)buf, count)) != OK)
|
||||
return r;
|
||||
if(proc_nr == SELF) {
|
||||
memcpy(buf, (char *) user_vir, count);
|
||||
}
|
||||
else {
|
||||
if((r=sys_vircopy(proc_nr,D,user_vir, SELF,D,(int)buf, count)) != OK)
|
||||
return r;
|
||||
}
|
||||
|
||||
LOGINC(log->log_write, count);
|
||||
log->log_size += count;
|
||||
@ -160,6 +165,25 @@ subwrite(struct logdevice *log, int count, int proc_nr, vir_bytes user_vir)
|
||||
return count;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* log_append *
|
||||
*===========================================================================*/
|
||||
PUBLIC void
|
||||
log_append(char *buf, int count)
|
||||
{
|
||||
int w = 0, skip = 0;
|
||||
|
||||
if(count < 1) return;
|
||||
if(count > LOG_SIZE) skip = count - LOG_SIZE;
|
||||
count -= skip;
|
||||
buf += skip;
|
||||
w = subwrite(&logdevices[0], count, SELF, (vir_bytes) buf);
|
||||
|
||||
if(w > 0 && w < count)
|
||||
subwrite(&logdevices[0], count-w, SELF, (vir_bytes) buf+w);
|
||||
return;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* subread *
|
||||
*===========================================================================*/
|
||||
@ -224,9 +248,6 @@ unsigned nr_req; /* length of request vector */
|
||||
/* There's already someone hanging to read, or
|
||||
* no real I/O requested.
|
||||
*/
|
||||
#if LOG_DEBUG
|
||||
printf("someone (%d) is already blocking\n", log->log_proc_nr);
|
||||
#endif
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@ -345,7 +366,7 @@ message *m_ptr;
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* log_select *
|
||||
* log_other *
|
||||
*============================================================================*/
|
||||
PRIVATE int log_other(dp, m_ptr)
|
||||
struct driver *dp;
|
||||
|
@ -31,6 +31,5 @@ struct logdevice {
|
||||
_PROTOTYPE( void kputc, (int c) );
|
||||
_PROTOTYPE( int do_new_kmess, (message *m) );
|
||||
_PROTOTYPE( int do_diagnostics, (message *m) );
|
||||
_PROTOTYPE( void log_putc, (int c) );
|
||||
|
||||
_PROTOTYPE( void log_append, (char *buf, int len) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user