diff options
| author | Jake Mannens <jake72360@gmail.com> | 2018-09-01 02:27:36 +1000 |
|---|---|---|
| committer | Jake Mannens <jake72360@gmail.com> | 2018-09-01 02:27:36 +1000 |
| commit | 6d87016287ea76afbdf7e16fb2cf9e4fa20cc0de (patch) | |
| tree | 9c2ed07925bc89ff3da3d275a6d29d80bb91d955 /kernel/tty.c | |
| parent | 307eaac66d378c1f6150519123ec1204277464d9 (diff) | |
Removed the sys_puts system call in favour of calls to tty_write().
Removed the rsputs() function in favour of calls to tty_write().
Corrected a bug in the serial driver and TTY subsystem where a full
buffer wouldn't be detected. This was caused by a missing set of
brackets on several operations involving the modulus operator.
Added the ability for the serial driver to automatically take data from
the TTY device's write buffer and push it to the serial port. This can
happen in one of two ways; 1) the TTY subsystem notifies the serial
driver of new data by calling the write() function pointer in the
tty_struct or, 2) the serial port issues an interrupt signalling that it
has finished sending data prompting the driver to check the buffers for
any more pending data.
Diffstat (limited to 'kernel/tty.c')
| -rw-r--r-- | kernel/tty.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/tty.c b/kernel/tty.c index 75c3701..bfbf775 100644 --- a/kernel/tty.c +++ b/kernel/tty.c @@ -35,14 +35,24 @@ static int sleep_while_empty(struct tty_queue *q) { } /* check if a buffer's full and if so, go to sleep */ -static int sleep_while_full(struct tty_queue *q) { +static int sleep_while_full(struct tty_queue *q, struct tty_struct *tty) { cli(); while(1) { - if(q->pwrite == (q->pread - 1 % sizeof(q->buf))) + /* + * if the buffer is full, first notify the + * driver so it can try to remove some + * data then, check again and if it's + * still full, go to sleep. + */ + if(q->pwrite == ((q->pread - 1) % sizeof(q->buf))) + if(tty->write) + tty->write(); + + if(q->pwrite == ((q->pread - 1) % sizeof(q->buf))) interruptible_sleep_on(&q->waiting); /* check again to see if anything was removed, or we were interrupted */ - if(q->pwrite == (q->pread - 1 % sizeof(q->buf))) { + if(q->pwrite == ((q->pread - 1) % sizeof(q->buf))) { sti(); return -1; } @@ -98,7 +108,7 @@ ssize_t tty_write(unsigned tty, void *buf, size_t len) { for(i = 0; i < len; i++) { /* check if the buffer's full and if so, go to sleep */ - if(sleep_while_full(q) < 0) { + if(sleep_while_full(q, ttys[tty]) < 0) { if(i == 0) return -EINTR; |
