51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
#include <stdint.h>
|
|
#include <string/string.h>
|
|
#include <system/system.h>
|
|
#include <sysdefs/ioctl.h>
|
|
#include <system/ioctl.h>
|
|
#include <uprintf.h>
|
|
#include <ansiq/all.h>
|
|
#include <sysdefs/ipcpipe.h>
|
|
#include <system/ipcpipe.h>
|
|
#include <devices/ps2kb.h>
|
|
|
|
void main(void) {
|
|
debugprint(ANSIQ_SCR_CLR_ALL);
|
|
debugprint(ANSIQ_CUR_SET(0, 0));
|
|
|
|
int32_t ioh = ioctl_openfile("base:/hello.txt", IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE);
|
|
|
|
char *text = "Hello from the filesystem";
|
|
ioctl_writefile(ioh, (const uint8_t *const)text, string_len(text), 0);
|
|
|
|
char buf[0x100] = {0};
|
|
ioctl_readfile(ioh, (uint8_t *const)buf, string_len(text), 0);
|
|
|
|
uprintf("FILE: %s\n", buf);
|
|
|
|
ioctl_closefile(ioh);
|
|
|
|
uprintf("Hello world using uprintf\n");
|
|
|
|
if (ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_MAKE, NULL, 0) < 0) {
|
|
uprintf("failed to create 10th pipe\n");
|
|
}
|
|
|
|
int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_REG_EVT_PIPE, NULL, 1);
|
|
uprintf("%d\n", r);
|
|
|
|
while(1) {
|
|
int32_t kbchr;
|
|
int32_t read = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_READ, (uint8_t *)&kbchr, sizeof(kbchr));
|
|
if (read > 0) {
|
|
kbchr &= 0xFF;
|
|
if ((kbchr >= 0x20 && kbchr <= 0x7F) || kbchr == 0xA) {
|
|
uprintf("%c", kbchr & 0xFF);
|
|
}
|
|
}
|
|
}
|
|
|
|
for(;;);
|
|
}
|
|
|