Skip to content

Commit e93e1c0

Browse files
committed
chario: more EOF propagation
Propagate it also from Busy(), which allows to remove it from the kbd buffer immediately, rather than to leave for next read(). Thus the change in console.asm.
1 parent bf97aaa commit e93e1c0

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎kernel/chario.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ STATIC void CharCmd(struct dhdr FAR *pdev, unsigned command)
106106

107107
STATIC int Busy(struct dhdr FAR *pdev)
108108
{
109+
int ret;
110+
____R(CharReqHdr.r_count) = 1;
109111
CharCmd(pdev, C_ISTAT);
110-
return CharReqHdr.r_status & S_BUSY;
112+
ret = CharReqHdr.r_status & S_BUSY;
113+
if (!ret && !CharReqHdr.r_count)
114+
return 256;
115+
return ret;
111116
}
112117

113118
void con_flush(struct dhdr FAR *pdev)
@@ -150,6 +155,8 @@ int ndread(struct dhdr FAR *pdev)
150155
CharCmd(pdev, C_NDREAD);
151156
if (CharReqHdr.r_status & S_BUSY)
152157
return -1;
158+
if (!CharReqHdr.r_count)
159+
return 256;
153160
return CharReqHdr.r_ndbyte;
154161
}
155162

@@ -321,13 +328,15 @@ STATIC unsigned do_read_char_dev(struct dhdr FAR *pdev, BOOL check_break)
321328

322329
FOREVER
323330
{
324-
if (!Busy(pdev))
331+
if (!(c = Busy(pdev)))
325332
{
326333
c = CharIO(pdev, 0, C_INPUT);
327334
if (c == CTL_C && !check_break && !break_ena)
328335
clear_break();
329336
break;
330337
}
338+
if (c == 256)
339+
break;
331340
if (pdev != syscon)
332341
{
333342
if (check_break)

‎kernel/console.asm‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes
158158
add ah,[cs:_kbdType]
159159
int 16h ; Get status, if zf=0 al=char
160160
jz ConNdRd4 ; Jump if no char available
161-
or ax,ax ; See if call was supported
162-
jz _IOSuccess ; 0 (sometimes) means unsupported
163161
call checke0 ; check for e0 scancode
164162
or ax,ax ; Zero ?
165163
jnz ConNdRd1 ; Jump if not zero

0 commit comments

Comments
 (0)