Compare commits
2 Commits
c364dca5e5
...
1af0d1f5bc
Author | SHA1 | Date | |
---|---|---|---|
1af0d1f5bc | |||
504bdbd4ba |
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,19 @@
|
||||
#include <util/util.h>
|
||||
#include <errors.h>
|
||||
#include <uprintf.h>
|
||||
#include <string/string.h>
|
||||
|
||||
void pctl_ls(void) {
|
||||
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
|
||||
uprintf("%-80s %s %-6s\n", "NAME", "PID", "TYPE");
|
||||
uprintf("%-30s %s %-6s\n", "NAME", "PID", "TYPE");
|
||||
for (size_t i = 0; i < procslen; i++) {
|
||||
ProcStat stat = ZERO(&stat);
|
||||
char namebuf[34] = {0};
|
||||
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
||||
if (r == E_OK) {
|
||||
uprintf("%-80s %3lu %-6s\n", stat.name, stat.pid, stat.kern ? "KERNEL" : "USER");
|
||||
string_memcpy(namebuf, stat.name, 30);
|
||||
namebuf[31] = namebuf[32] = namebuf[33] = '.';
|
||||
uprintf("%-30s %3lu %-6s\n", namebuf, stat.pid, stat.kern ? "KERNEL" : "USER");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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