diff options
author | Marvin Borner | 2021-04-13 22:09:23 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-13 22:09:23 +0200 |
commit | 9ded3a2bde80eede5fd887812d70c2f834b53c84 (patch) | |
tree | 932a90608c5f30d38b810dc4fe9264cc43c2da68 /kernel/inc | |
parent | f96b8ad1ee83dec08ae636e179cc48019ca50b12 (diff) |
Started IO dev manager
Diffstat (limited to 'kernel/inc')
-rw-r--r-- | kernel/inc/fs.h | 52 | ||||
-rw-r--r-- | kernel/inc/io.h | 30 | ||||
-rw-r--r-- | kernel/inc/proc.h | 19 |
3 files changed, 52 insertions, 49 deletions
diff --git a/kernel/inc/fs.h b/kernel/inc/fs.h index 1a78072..93a8a5c 100644 --- a/kernel/inc/fs.h +++ b/kernel/inc/fs.h @@ -13,67 +13,60 @@ enum dev_type { DEV_BLOCK, DEV_CHAR }; -struct device { +struct vfs_dev { u32 id; const char *name; enum dev_type type; struct vfs *vfs; void *data; - res (*read)(void *buf, u32 offset, u32 count, struct device *dev) NONNULL; - res (*write)(void *buf, u32 offset, u32 count, struct device *dev) NONNULL; - res (*ioctl)(u32 request, void *arg1, void *arg2, void *arg3, struct device *dev) + res (*read)(void *buf, u32 offset, u32 count, struct vfs_dev *dev) NONNULL; + res (*write)(void *buf, u32 offset, u32 count, struct vfs_dev *dev) NONNULL; + res (*ioctl)(u32 request, void *arg1, void *arg2, void *arg3, struct vfs_dev *dev) ATTR((nonnull(5))); - res (*ready)(void); }; -void device_install(void); - -void device_add(struct device *dev) NONNULL; - /** * VFS */ -enum vfs_type { VFS_DEVFS, VFS_TMPFS, VFS_PROCFS, VFS_EXT2 }; +enum vfs_type { VFS_TMPFS, VFS_PROCFS, VFS_EXT2 }; enum vfs_perm { VFS_EXEC, VFS_WRITE, VFS_READ }; struct vfs { enum vfs_type type; int flags; void *data; - res (*read)(const char *path, void *buf, u32 offset, u32 count, struct device *dev) NONNULL; + res (*read)(const char *path, void *buf, u32 offset, u32 count, + struct vfs_dev *dev) NONNULL; res (*write)(const char *path, void *buf, u32 offset, u32 count, - struct device *dev) NONNULL; + struct vfs_dev *dev) NONNULL; res (*ioctl)(const char *path, u32 request, void *arg1, void *arg2, void *arg3, - struct device *dev) ATTR((nonnull(1, 6))); - res (*stat)(const char *path, struct stat *buf, struct device *dev) NONNULL; - res (*block)(const char *path, u32 func_ptr, struct device *dev) NONNULL; - res (*ready)(const char *path, struct device *dev) NONNULL; - res (*perm)(const char *path, enum vfs_perm perm, struct device *dev) NONNULL; + struct vfs_dev *dev) ATTR((nonnull(1, 6))); + res (*stat)(const char *path, struct stat *buf, struct vfs_dev *dev) NONNULL; + res (*block)(const char *path, u32 func_ptr, struct vfs_dev *dev) NONNULL; + res (*perm)(const char *path, enum vfs_perm perm, struct vfs_dev *dev) NONNULL; }; struct mount_info { const char *path; - struct device *dev; + struct vfs_dev *dev; }; void vfs_install(void); -u8 vfs_mounted(struct device *dev, const char *path) NONNULL; -res vfs_mount(struct device *dev, const char *path) NONNULL; +u8 vfs_mounted(struct vfs_dev *dev, const char *path) NONNULL; +res vfs_mount(struct vfs_dev *dev, const char *path) NONNULL; -struct device *vfs_find_dev(const char *path) NONNULL; +struct vfs_dev *vfs_find_dev(const char *path) NONNULL; +void vfs_add_dev(struct vfs_dev *dev) NONNULL; res vfs_read(const char *path, void *buf, u32 offset, u32 count) NONNULL; res vfs_write(const char *path, void *buf, u32 offset, u32 count) NONNULL; res vfs_ioctl(const char *path, u32 request, void *arg1, void *arg2, void *arg3) ATTR((nonnull(1))); res vfs_stat(const char *path, struct stat *buf) NONNULL; -res vfs_block(const char *path, u32 func_ptr) NONNULL; -res vfs_poll(const char **files) NONNULL; -res vfs_ready(const char *path) NONNULL; -struct device *device_get_by_name(const char *name) NONNULL; -struct device *device_get_by_id(u32 id) NONNULL; +struct vfs_dev *device_get_by_name(const char *name) NONNULL; +struct vfs_dev *device_get_by_id(u32 id) NONNULL; /** * EXT2 @@ -177,9 +170,8 @@ struct ext2_file { u32 curr_block_pos; }; -res ext2_read(const char *path, void *buf, u32 offset, u32 count, struct device *dev) NONNULL; -res ext2_stat(const char *path, struct stat *buf, struct device *dev) NONNULL; -res ext2_perm(const char *path, enum vfs_perm perm, struct device *dev) NONNULL; -res ext2_ready(const char *path, struct device *dev) NONNULL; +res ext2_read(const char *path, void *buf, u32 offset, u32 count, struct vfs_dev *dev) NONNULL; +res ext2_stat(const char *path, struct stat *buf, struct vfs_dev *dev) NONNULL; +res ext2_perm(const char *path, enum vfs_perm perm, struct vfs_dev *dev) NONNULL; #endif diff --git a/kernel/inc/io.h b/kernel/inc/io.h new file mode 100644 index 0000000..e05a419 --- /dev/null +++ b/kernel/inc/io.h @@ -0,0 +1,30 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef DEV_H +#define DEV_H + +#include <def.h> +#include <sys.h> + +enum io_type { + IO_MIN, + IO_FRAMEBUFFER, + IO_NETWORK, + IO_KEYBOARD, + IO_MOUSE, + IO_BUS, + IO_MAX, +}; + +struct io_dev { + const char *name; +}; + +void io_install(void); + +res io_control(); +res io_write(enum io_type io, void *buf, u32 offset, u32 count); +res io_read(enum io_type io, void *buf, u32 offset, u32 count); +res io_poll(); + +#endif diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h index b8912a5..754693f 100644 --- a/kernel/inc/proc.h +++ b/kernel/inc/proc.h @@ -22,27 +22,11 @@ #define RING(regs) ((regs->cs) & 3) -#define PROC_MAX_BLOCK_IDS 16 -#define PROC_BLOCK_MAGIC 0x00528491 - #define STREAM_MAX_SIZE 4096 enum stream_defaults { STREAM_IN, STREAM_OUT, STREAM_ERR, STREAM_LOG, STREAM_UNKNOWN = -1 }; enum proc_priv { PROC_PRIV_NONE, PROC_PRIV_ROOT, PROC_PRIV_KERNEL }; enum proc_state { PROC_RUNNING, PROC_BLOCKED }; -enum proc_block_type { PROC_BLOCK_DEV, PROC_BLOCK_MSG }; - -struct proc_block_identifier { - u32 magic; - u32 id; - enum proc_block_type type; - u32 func_ptr; -}; - -struct proc_block { - struct proc_block_identifier ids[PROC_MAX_BLOCK_IDS]; - u32 id_cnt; -}; struct stream { u32 offset_read; @@ -59,7 +43,6 @@ struct proc { struct stream streams[4]; struct page_dir *page_dir; struct regs regs; - struct proc_block block; // dev_id enum proc_priv priv; enum proc_state state; struct stack *messages; @@ -92,8 +75,6 @@ void proc_yield(struct regs *r) NONNULL; void proc_set_quantum(struct proc *proc, u32 value); void proc_reset_quantum(struct proc *proc); void proc_state(struct proc *proc, enum proc_state state); -void proc_block(u32 id, enum proc_block_type type, u32 func_ptr); -void proc_unblock(u32 id, enum proc_block_type type); struct proc *proc_make(enum proc_priv priv); void proc_stack_push(struct proc *proc, u32 data) NONNULL; |