> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 21:42:49 up 7 days,  6:40,  1 user,  load average: 1.10, 1.01, 0.88
This commit is contained in:
tracer-ics2023
2024-09-24 21:42:51 +08:00
committed by zzy
parent bcdb36b828
commit 6016a237d4
6 changed files with 17 additions and 6 deletions

View File

@ -4,5 +4,6 @@
#include <common.h>
size_t serial_write(const void *buf, size_t offset, size_t len);
size_t events_read(void *buf, size_t offset, size_t len);
#endif

View File

@ -22,8 +22,12 @@ size_t serial_write(const void *buf, size_t offset, size_t len) {
}
size_t events_read(void *buf, size_t offset, size_t len) {
// io_read();
return 0;
// io_read(AM_INPUT_CONFIG);
AM_INPUT_KEYBRD_T kb = io_read(AM_INPUT_KEYBRD);
if (kb.keycode == AM_KEY_NONE) {
return 0;
}
return snprintf(buf, len, "%s %s\n", kb.keydown ? "kd" : "ku", keyname[kb.keycode]);
}
size_t dispinfo_read(void *buf, size_t offset, size_t len) {

View File

@ -31,7 +31,7 @@ static Finfo file_table[] __attribute__((used)) = {
[FD_STDIN] = {"stdin", 0, 0, invalid_read, invalid_write},
[FD_STDOUT] = {"stdout", 0, 0, invalid_read, serial_write},
[FD_STDERR] = {"stderr", 0, 0, invalid_read, serial_write},
[FD_EVENTS] = {"/dev/events", 0, 0, invalid_read, invalid_write},
[FD_EVENTS] = {"/dev/events", 0, 0, events_read, invalid_write},
#include "files.h"
};

View File

@ -26,7 +26,7 @@ void init_proc() {
// load program here
void naive_uload(PCB *pcb, const char *filename);
naive_uload(NULL, "/bin/timer-test");
naive_uload(NULL, "/bin/event-test");
}

View File

@ -167,7 +167,7 @@ $(CLEAN_ALL):
### Build fsimg and ramdisk for Nanos-lite
APPS =
TESTS = dummy hello file-test timer-test
TESTS = dummy hello file-test timer-test event-test
fsimg: $(addprefix apps/, $(APPS)) $(addprefix tests/, $(TESTS))
-for t in $^; do $(MAKE) -s -C $(NAVY_HOME)/$$t install; done

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
static int evtdev = -1;
static int fbdev = -1;
@ -15,7 +16,12 @@ uint32_t NDL_GetTicks() {
}
int NDL_PollEvent(char *buf, int len) {
return 0;
FILE* fd = fopen("/dev/events", "r");
if (fd == NULL) {
printf("cannot open /dev/events");
exit(-1);
}
return fread(buf, 1, len, fd);
}
void NDL_OpenCanvas(int *w, int *h) {