Compare commits
2 Commits
c364dca5e5
...
1af0d1f5bc
Author | SHA1 | Date | |
---|---|---|---|
1af0d1f5bc | |||
504bdbd4ba |
@ -215,13 +215,13 @@ void intr_handleintr(IntrStackFrame *frame) {
|
|||||||
break;
|
break;
|
||||||
case INTR_IRQBASE+1:
|
case INTR_IRQBASE+1:
|
||||||
int32_t c = ps2kb_intr();
|
int32_t c = ps2kb_intr();
|
||||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
uint8_t *bytes = (uint8_t *)&c;
|
uint8_t b = c;
|
||||||
for (size_t i = 0; i < sizeof(c); i++) {
|
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||||
rbuf_push(&PS2KB_BUF.rbuf, bytes[i]);
|
rbuf_push(&PS2KB_BUF.rbuf, b);
|
||||||
}
|
spinlock_release(&PS2KB_BUF.spinlock);
|
||||||
}
|
}
|
||||||
|
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (frame->trapnum == 0x80) {
|
} else if (frame->trapnum == 0x80) {
|
||||||
|
@ -22,26 +22,18 @@ void ps2kbproc_init(Proc *proc) {
|
|||||||
|
|
||||||
void ps2kbproc_fn(void) {
|
void ps2kbproc_fn(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int32_t kbchr = 0;
|
uint8_t b = 0;
|
||||||
uint8_t *buf = (uint8_t *)&kbchr;
|
|
||||||
size_t total = 0;
|
|
||||||
spinlock_acquire(&PS2KB_BUF.spinlock);
|
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||||
for (size_t i = 0; i < sizeof(kbchr); i++) {
|
if (rbuf_pop(&PS2KB_BUF.rbuf, &b) == 0) {
|
||||||
if (rbuf_pop(&PS2KB_BUF.rbuf, &buf[i]) < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
total++;
|
|
||||||
}
|
|
||||||
spinlock_release(&PS2KB_BUF.spinlock);
|
|
||||||
if (total == sizeof(kbchr)) {
|
|
||||||
spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
|
spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
|
||||||
IpcPipe *head = PS2KBPROC->bcast_pipes.list;
|
IpcPipe *head = PS2KBPROC->bcast_pipes.list;
|
||||||
while (head != NULL) {
|
while (head != NULL) {
|
||||||
ipc_pipewrite(head, (uint8_t *)&kbchr, sizeof(kbchr));
|
ipc_pipewrite(head, &b, 1);
|
||||||
head = head->next;
|
head = head->next;
|
||||||
}
|
}
|
||||||
spinlock_release(&PS2KBPROC->bcast_pipes.spinlock);
|
spinlock_release(&PS2KBPROC->bcast_pipes.spinlock);
|
||||||
}
|
}
|
||||||
|
spinlock_release(&PS2KB_BUF.spinlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,19 @@
|
|||||||
#include <util/util.h>
|
#include <util/util.h>
|
||||||
#include <errors.h>
|
#include <errors.h>
|
||||||
#include <uprintf.h>
|
#include <uprintf.h>
|
||||||
|
#include <string/string.h>
|
||||||
|
|
||||||
void pctl_ls(void) {
|
void pctl_ls(void) {
|
||||||
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
|
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++) {
|
for (size_t i = 0; i < procslen; i++) {
|
||||||
ProcStat stat = ZERO(&stat);
|
ProcStat stat = ZERO(&stat);
|
||||||
|
char namebuf[34] = {0};
|
||||||
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
||||||
if (r == E_OK) {
|
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;
|
cursor = 0;
|
||||||
string_memset(linebuf, 0, LINEBUF_MAX);
|
string_memset(linebuf, 0, LINEBUF_MAX);
|
||||||
|
|
||||||
int32_t kbchr = 0;
|
uint8_t b = 0;
|
||||||
for (;;) {
|
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) {
|
if (nrd > 0) {
|
||||||
switch (kbchr) {
|
switch (b) {
|
||||||
case C('C'):
|
case C('C'):
|
||||||
case 0xE9:
|
case 0xE9:
|
||||||
uprintf("\n");
|
uprintf("\n");
|
||||||
@ -126,15 +126,13 @@ void do_mode_interactive(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char chr = kbchr & 0xFF;
|
if (b == '\n') {
|
||||||
|
|
||||||
if (chr == '\n') {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string_chr_isascii(chr) && chr != 0 && cursor < LINEBUF_MAX) {
|
if (string_chr_isascii(b) && b != 0 && cursor < LINEBUF_MAX) {
|
||||||
linebuf[cursor++] = chr;
|
linebuf[cursor++] = b;
|
||||||
uprintf("%c", chr);
|
uprintf("%c", b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user