]> git.corax.cc Git - corax/commitdiff
sys/io: Add dummy IO process
authorMatthias Kruk <m@m10k.eu>
Tue, 28 Jul 2020 13:19:33 +0000 (22:19 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 28 Jul 2020 13:19:33 +0000 (22:19 +0900)
sys/initfs.c
sys/io/Makefile [new file with mode: 0644]
sys/io/main.c [new file with mode: 0644]

index c7f4d1f2a213a193f69a70137614df9c10f3e541..13de1c4b97512bb007679bcd587f5b762d41db70 100644 (file)
@@ -13,21 +13,34 @@ extern const char _binary_vga_start[];
 extern const unsigned long _binary_vga_size;
 #endif /* FEATURE(VGA) */
 
+#if FEATURE(IO)
+extern const char _binary_io_end[];
+extern const char _binary_io_start[];
+extern const unsigned long _binary_io_size;
+#endif /* FEATURE(VGA) */
+
 static struct initfs_entry _ifs_entries[] = {
+#if FEATURE(IO)
+       {
+               .ife_name = "io",
+               .ife_base = &_binary_io_start,
+               .ife_limit = (unsigned long)&_binary_io_size
+       },
+#endif /* FEATURE(IO) */
 #if FEATURE(KBD)
        {
                .ife_name = "kbd",
                .ife_base = &_binary_kbd_start,
                .ife_limit = (unsigned long)&_binary_kbd_size
        },
-#endif
+#endif /* FEATURE(KBD) */
 #if FEATURE(VGA)
        {
                .ife_name = "vga",
                .ife_base = &_binary_vga_start,
                .ife_limit = (unsigned long)&_binary_vga_size
        },
-#endif
+#endif /* FEATURE(VGA) */
 };
 
 struct initfs initfs = {
diff --git a/sys/io/Makefile b/sys/io/Makefile
new file mode 100644 (file)
index 0000000..9c599f7
--- /dev/null
@@ -0,0 +1,26 @@
+OBJECTS = main.o #globals.o open.o close.o read.o write.o
+OUTPUT = io
+MODULE = io.ko
+
+INCLUDES = -I../../include -I../..
+CFLAGS = -m32 -Wall -nostdlib -nodefaultlibs -nostartfiles -ffreestanding \
+        -nostdinc -fno-builtin -fno-builtin-memcpy
+LIBS = ../../libc/libc.a
+CFLAGS += $(INCLUDES)
+
+ASFLAGS = $(CFLAGS)
+PHONY = clean
+
+all: $(MODULE)
+
+$(MODULE): $(OUTPUT)
+       ld -r --oformat=elf32-i386 -m elf_i386 -b binary -o $@ $<
+       cp $@ ../
+
+$(OUTPUT): $(OBJECTS)
+       gcc -static $(CFLAGS) -o $@ $^ $(LIBS)
+
+clean:
+       rm -f $(OBJECTS) $(OUTPUT)
+
+.PHONY: $(PHONY)
diff --git a/sys/io/main.c b/sys/io/main.c
new file mode 100644 (file)
index 0000000..07cd1bc
--- /dev/null
@@ -0,0 +1,69 @@
+#include <crxstd.h>
+#include <corax/ipc.h>
+#include <corax/ipc/io.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+/*
+int cxio_read(struct cxmsg*);
+int cxio_write(struct cxmsg*);
+int cxio_open(struct cxmsg*);
+int cxio_close(struct cxmsg*);
+*/
+
+int main(int argc, char *argv[])
+{
+       struct cxmsg msg;
+       int err;
+
+       while(1) {
+               char str[64];
+               int len;
+
+               len = snprintf(str, sizeof(str), "[IO] Waiting for messages...\n");
+               debug(str, len);
+
+               err = cxrecv(PID_ANY, &msg);
+
+               len = snprintf(str, sizeof(str), "[IO] Received a message from %u\n", msg.cm_src);
+               debug(str, len);
+
+               if(err < 0) {
+                       continue;
+               }
+
+               switch(msg.cm_type) {
+#if 0
+               case CXIO_READ:
+                       err = cxio_read(&msg);
+                       break;
+
+               case CXIO_WRITE:
+                       err = cxio_write(&msg);
+                       break;
+
+               case CXIO_OPEN:
+                       err = cxio_open(&msg);
+                       break;
+
+               case CXIO_CLOSE:
+                       err = cxio_close(&msg);
+                       break;
+#endif /* 0 */
+               case CXIO_PIPE:
+                       memset(str, 0, sizeof(str));
+                       len = snprintf(str, sizeof(str), "CXIO_PIPE from 0x%x.\n", msg.cm_src);
+                       debug(str, len);
+                       break;
+
+               default:
+                       memset(str, 0, sizeof(str));
+                       len = snprintf(str, sizeof(str), "0x%x from 0x%x.\n", msg.cm_type, msg.cm_src);
+                       debug(str, len);
+                       break;
+               }
+       }
+
+       return(0);
+}