Use uint8_t for keyboard chars
This commit is contained in:
@ -215,13 +215,13 @@ void intr_handleintr(IntrStackFrame *frame) {
|
||||
break;
|
||||
case INTR_IRQBASE+1:
|
||||
int32_t c = ps2kb_intr();
|
||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
||||
if (c >= 0) {
|
||||
uint8_t *bytes = (uint8_t *)&c;
|
||||
for (size_t i = 0; i < sizeof(c); i++) {
|
||||
rbuf_push(&PS2KB_BUF.rbuf, bytes[i]);
|
||||
}
|
||||
uint8_t b = c;
|
||||
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||
rbuf_push(&PS2KB_BUF.rbuf, b);
|
||||
spinlock_release(&PS2KB_BUF.spinlock);
|
||||
}
|
||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
||||
break;
|
||||
}
|
||||
} else if (frame->trapnum == 0x80) {
|
||||
|
@ -22,26 +22,18 @@ void ps2kbproc_init(Proc *proc) {
|
||||
|
||||
void ps2kbproc_fn(void) {
|
||||
for (;;) {
|
||||
int32_t kbchr = 0;
|
||||
uint8_t *buf = (uint8_t *)&kbchr;
|
||||
size_t total = 0;
|
||||
uint8_t b = 0;
|
||||
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||
for (size_t i = 0; i < sizeof(kbchr); i++) {
|
||||
if (rbuf_pop(&PS2KB_BUF.rbuf, &buf[i]) < 0) {
|
||||
break;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
spinlock_release(&PS2KB_BUF.spinlock);
|
||||
if (total == sizeof(kbchr)) {
|
||||
if (rbuf_pop(&PS2KB_BUF.rbuf, &b) == 0) {
|
||||
spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
|
||||
IpcPipe *head = PS2KBPROC->bcast_pipes.list;
|
||||
while (head != NULL) {
|
||||
ipc_pipewrite(head, (uint8_t *)&kbchr, sizeof(kbchr));
|
||||
ipc_pipewrite(head, &b, 1);
|
||||
head = head->next;
|
||||
}
|
||||
spinlock_release(&PS2KBPROC->bcast_pipes.spinlock);
|
||||
}
|
||||
spinlock_release(&PS2KB_BUF.spinlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,11 +109,11 @@ void do_mode_interactive(void) {
|
||||
cursor = 0;
|
||||
string_memset(linebuf, 0, LINEBUF_MAX);
|
||||
|
||||
int32_t kbchr = 0;
|
||||
uint8_t b = 0;
|
||||
for (;;) {
|
||||
int32_t nrd = ipcpipe(PID, IPCPIPE_IN, IPCPIPE_READ, (uint8_t *)&kbchr, sizeof(kbchr));
|
||||
int32_t nrd = ipcpipe(PID, IPCPIPE_IN, IPCPIPE_READ, &b, 1);
|
||||
if (nrd > 0) {
|
||||
switch (kbchr) {
|
||||
switch (b) {
|
||||
case C('C'):
|
||||
case 0xE9:
|
||||
uprintf("\n");
|
||||
@ -126,15 +126,13 @@ void do_mode_interactive(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
char chr = kbchr & 0xFF;
|
||||
|
||||
if (chr == '\n') {
|
||||
if (b == '\n') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (string_chr_isascii(chr) && chr != 0 && cursor < LINEBUF_MAX) {
|
||||
linebuf[cursor++] = chr;
|
||||
uprintf("%c", chr);
|
||||
if (string_chr_isascii(b) && b != 0 && cursor < LINEBUF_MAX) {
|
||||
linebuf[cursor++] = b;
|
||||
uprintf("%c", b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user