aboutsummaryrefslogtreecommitdiff
path: root/kernel/io/include/io
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-04-03 18:48:59 +0200
committerJakob Odersky <jodersky@gmail.com>2014-04-03 18:48:59 +0200
commitb6181e4a21b1bc3b5615604e175c6a297b661687 (patch)
treeb9b47c10159eef591c6085ab49bee34e2b284b71 /kernel/io/include/io
parentf93ab955074e213ad6f2bf60522cc86952d57d83 (diff)
downloadmux-b6181e4a21b1bc3b5615604e175c6a297b661687.tar.gz
mux-b6181e4a21b1bc3b5615604e175c6a297b661687.tar.bz2
mux-b6181e4a21b1bc3b5615604e175c6a297b661687.zip
add uniform io interface
Diffstat (limited to 'kernel/io/include/io')
-rw-r--r--kernel/io/include/io/io.h30
-rw-r--r--kernel/io/include/io/usart.h31
2 files changed, 30 insertions, 31 deletions
diff --git a/kernel/io/include/io/io.h b/kernel/io/include/io/io.h
new file mode 100644
index 0000000..a715f1b
--- /dev/null
+++ b/kernel/io/include/io/io.h
@@ -0,0 +1,30 @@
+#ifndef IO_H
+#define IO_H
+
+#include <stddef.h>
+
+typedef long ssize_t;
+
+struct file;
+struct file_operations;
+
+struct file {
+ struct file_operations* fops;
+ void* private_data;
+};
+
+struct file_operations {
+ int (*open)(struct file* file);
+ int (*ioctl)(struct file* file, int cmd, long args);
+ ssize_t (*read)(struct file* file, char* const buffer, size_t size);
+ ssize_t (*write)(struct file* file, const char* const buffer, size_t size);
+ int (*close)(struct file* file);
+};
+
+int open(struct file* file);
+int ioctl(struct file* file, int cmd, long args);
+ssize_t read(struct file* file, char* const buffer, size_t size);
+ssize_t write(struct file* file, const char* const buffer, size_t size);
+int close(struct file* file);
+
+#endif \ No newline at end of file
diff --git a/kernel/io/include/io/usart.h b/kernel/io/include/io/usart.h
deleted file mode 100644
index 62e2768..0000000
--- a/kernel/io/include/io/usart.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SERIAL_H
-#define SERIAL_H
-
-#include "collection/rbuffer.h"
-#include "collection/list.h"
-
-#define USARTS 1
-#define USART_BUFFER_SIZE 64
-
-struct usart_device_t {
- volatile char __rx_buffer[USART_BUFFER_SIZE];
- volatile char __tx_buffer[USART_BUFFER_SIZE];
-
- struct rbuffer_t rx_buffer;
- struct rbuffer_t tx_buffer;
-
- struct list_head rx_queue;
- struct list_head tx_queue;
-};
-
-#define USART_DEVICE_INIT(name) \
- { \
- .rx_buffer = RBUFFER_ARRAY_INIT(name.__rx_buffer, USART_BUFFER_SIZE), \
- .tx_buffer = RBUFFER_ARRAY_INIT(name.__tx_buffer, USART_BUFFER_SIZE), \
- .rx_queue = LIST_HEAD_INIT(name.rx_queue), \
- .tx_queue = LIST_HEAD_INIT(name.tx_queue) \
- }
-
-void usart_init(unsigned long baud);
-
-#endif \ No newline at end of file