Compare commits
2 Commits
80a788617e
...
e71361dcca
Author | SHA1 | Date | |
---|---|---|---|
e71361dcca | |||
659f98910d |
@ -7,7 +7,9 @@
|
||||
|
||||
#define kprintf(fmt, ...) \
|
||||
do { \
|
||||
spinlock_acquire(&TERM.spinlock); \
|
||||
printf_(fmt, ##__VA_ARGS__); \
|
||||
spinlock_release(&TERM.spinlock); \
|
||||
} while(0)
|
||||
|
||||
#define ksprintf sprintf_
|
||||
|
@ -32,6 +32,7 @@ void term_doinit(void *addr) {
|
||||
|
||||
void term_init(void *addr) {
|
||||
term_doinit(addr);
|
||||
spinlock_init(&TERM.spinlock);
|
||||
}
|
||||
|
||||
void term_write_unsafe(const char *s, size_t len) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
typedef struct {
|
||||
struct flanterm_context *ftctx;
|
||||
SpinLock spinlock;
|
||||
} Term;
|
||||
|
||||
extern Term TERM;
|
||||
|
@ -10,6 +10,7 @@ SRCFILES := $(call GRABSRC, \
|
||||
string \
|
||||
system \
|
||||
printf \
|
||||
devices \
|
||||
)
|
||||
|
||||
CFLAGS += -isystem $(ROOT)/share -isystem $(ROOT)/ulib -isystem $(ROOT)/std/include \
|
||||
|
8
ulib/devices/ps2kb.c
Normal file
8
ulib/devices/ps2kb.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sysdefs/ipcpipe.h>
|
||||
#include <system/ipcpipe.h>
|
||||
|
||||
int32_t dev_ps2kb_read(int32_t *ch) {
|
||||
return ipcpipe(1, 0, IPCPIPE_READ, (uint8_t *)ch, sizeof(*ch));
|
||||
}
|
10
ulib/devices/ps2kb.h
Normal file
10
ulib/devices/ps2kb.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef ULIB_DEVICES_PS2KB_H_
|
||||
#define ULIB_DEVICES_PS2KB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PS2KB_C(x) ((x) - '@')
|
||||
|
||||
int32_t dev_ps2kb_read(int32_t *ch);
|
||||
|
||||
#endif // ULIB_DEVICES_PS2KB_H_
|
@ -7,6 +7,7 @@
|
||||
#include <ansiq/all.h>
|
||||
#include <sysdefs/ipcpipe.h>
|
||||
#include <system/ipcpipe.h>
|
||||
#include <devices/ps2kb.h>
|
||||
|
||||
void main(void) {
|
||||
debugprint(ANSIQ_SCR_CLR_ALL);
|
||||
@ -28,10 +29,10 @@ void main(void) {
|
||||
|
||||
while(1) {
|
||||
int32_t kbchar;
|
||||
int32_t read = ipcpipe(1, 0, IPCPIPE_READ, (uint8_t *)&kbchar, sizeof(kbchar));
|
||||
int32_t read = dev_ps2kb_read(&kbchar);
|
||||
|
||||
if (read > 0 && (kbchar >= 0x20 && kbchar <= 0x7F)) {
|
||||
uprintf("%c", (char)kbchar);
|
||||
if (read > 0 && (kbchar >= 0x20 && kbchar <= 0x7F || kbchar == 0xA)) {
|
||||
uprintf("%c", kbchar & 0xFF);
|
||||
ipcpipe(3, 1, IPCPIPE_WRITE, (uint8_t *)&kbchar, 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user