diff options
Diffstat (limited to 'kernel/inc')
-rw-r--r-- | kernel/inc/event.h | 19 | ||||
-rw-r--r-- | kernel/inc/fs.h | 33 | ||||
-rw-r--r-- | kernel/inc/keyboard.h | 1 | ||||
-rw-r--r-- | kernel/inc/load.h | 55 | ||||
-rw-r--r-- | kernel/inc/proc.h | 25 |
5 files changed, 34 insertions, 99 deletions
diff --git a/kernel/inc/event.h b/kernel/inc/event.h deleted file mode 100644 index 59a0df1..0000000 --- a/kernel/inc/event.h +++ /dev/null @@ -1,19 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#ifndef EVENT_H -#define EVENT_H - -#include <def.h> -#include <proc.h> -#include <sys.h> - -struct event_descriptor { - u32 id; - struct proc *proc; -}; - -u32 event_register(u32 id, struct proc *proc); -void event_unregister(u32 id, struct proc *proc); -u32 event_trigger(u32 id, void *data); - -#endif diff --git a/kernel/inc/fs.h b/kernel/inc/fs.h index ff14361..64f3970 100644 --- a/kernel/inc/fs.h +++ b/kernel/inc/fs.h @@ -18,8 +18,9 @@ struct device { enum dev_type type; struct vfs *vfs; void *data; - u32 (*read)(void *buf, u32 offset, u32 count, struct device *dev); - u32 (*write)(void *buf, u32 offset, u32 count, struct device *dev); + s32 (*read)(void *buf, u32 offset, u32 count, struct device *dev); + s32 (*write)(void *buf, u32 offset, u32 count, struct device *dev); + u8 (*ready)(); }; void device_install(void); @@ -35,9 +36,11 @@ enum vfs_type { VFS_DEVFS, VFS_TMPFS, VFS_PROCFS, VFS_EXT2 }; struct vfs { enum vfs_type type; int flags; - u32 (*read)(const char *path, void *buf, u32 offset, u32 count, struct device *dev); - u32 (*write)(const char *path, void *buf, u32 offset, u32 count, struct device *dev); - u32 (*stat)(const char *path, struct stat *buf, struct device *dev); + void *data; + s32 (*read)(const char *path, void *buf, u32 offset, u32 count, struct device *dev); + s32 (*write)(const char *path, void *buf, u32 offset, u32 count, struct device *dev); + s32 (*stat)(const char *path, struct stat *buf, struct device *dev); + u8 (*ready)(const char *path, struct device *dev); }; struct mount_info { @@ -47,12 +50,17 @@ struct mount_info { void vfs_install(void); -u32 vfs_mounted(struct device *dev, const char *path); -u32 vfs_mount(struct device *dev, const char *path); +u8 vfs_mounted(struct device *dev, const char *path); +s32 vfs_mount(struct device *dev, const char *path); + +struct device *vfs_find_dev(const char *path); + +s32 vfs_read(const char *path, void *buf, u32 offset, u32 count); +s32 vfs_write(const char *path, void *buf, u32 offset, u32 count); +s32 vfs_stat(const char *path, struct stat *buf); +u8 vfs_ready(const char *path); -u32 vfs_read(const char *path, void *buf, u32 offset, u32 count); -u32 vfs_write(const char *path, void *buf, u32 offset, u32 count); -u32 vfs_stat(const char *path, struct stat *buf); +struct device *device_get_by_name(const char *name); /** * EXT2 @@ -145,7 +153,8 @@ struct ext2_file { u32 curr_block_pos; }; -u32 ext2_read(const char *path, void *buf, u32 offset, u32 count, struct device *dev); -u32 ext2_stat(const char *path, struct stat *buf, struct device *dev); +s32 ext2_read(const char *path, void *buf, u32 offset, u32 count, struct device *dev); +s32 ext2_stat(const char *path, struct stat *buf, struct device *dev); +u8 ext2_ready(const char *path, struct device *dev); #endif diff --git a/kernel/inc/keyboard.h b/kernel/inc/keyboard.h index 32168f4..22120e5 100644 --- a/kernel/inc/keyboard.h +++ b/kernel/inc/keyboard.h @@ -4,5 +4,6 @@ #define KEYBOARD_H void keyboard_install(void); +void keyboard_reset(void); #endif diff --git a/kernel/inc/load.h b/kernel/inc/load.h index 43c941c..422a28c 100644 --- a/kernel/inc/load.h +++ b/kernel/inc/load.h @@ -5,60 +5,7 @@ #include <proc.h> -#define ELF_MAG 0x7F // 0 -#define ELF_32 (1) // 4: 32-bit Architecture -#define ELF_LITTLE (1) // 5: Little Endian -#define ELF_CURRENT (1) // 6: ELF Current Version -#define ELF_386 (3) // header->machine x86 machine type - -#define ET_NONE 0 // Unkown type -#define ET_REL 1 // Relocatable file -#define ET_EXEC 2 // Executable file - -#define PT_LOAD 1 - -struct elf_header { - u8 ident[16]; - u16 type; - u16 machine; - u32 version; - u32 entry; - u32 phoff; - u32 shoff; - u32 flags; - u16 ehsize; - u16 phentsize; - u16 phnum; - u16 shentsize; - u16 shnum; - u16 shstrndx; -}; - -struct elf_section_header { - u32 name; - u32 type; - u32 flags; - u32 addr; - u32 offset; - u32 size; - u32 link; - u32 info; - u32 addralign; - u32 entsize; -}; - -struct elf_program_header { - u32 type; - u32 offset; - u32 vaddr; - u32 paddr; - u32 filesz; - u32 memsz; - u32 flags; - u32 align; -}; - +void proc_load(struct proc *proc, void *data); int bin_load(char *path, struct proc *proc); -void elf_load(char *path, struct proc *proc); #endif diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h index 5fc217c..6be7da3 100644 --- a/kernel/inc/proc.h +++ b/kernel/inc/proc.h @@ -4,12 +4,12 @@ #define PROC_H #include <def.h> -#include <event.h> #include <interrupts.h> #include <list.h> +#include <stack.h> #include <sys.h> -#define PROC_QUANTUM 100 // Milliseconds or something // TODO +#define PROC_QUANTUM 42 // Milliseconds or something // TODO #define EFLAGS_ALWAYS 0x2 // Always one #define EFLAGS_INTERRUPTS 0x200 // Enable interrupts @@ -19,32 +19,29 @@ enum proc_state { PROC_RUNNING, PROC_SLEEPING }; +struct proc_wait { + u32 id; // dev_id + s32 (*func)(); +}; + struct proc { u32 pid; char name[32]; struct regs regs; - struct regs regs_backup; + struct proc_wait wait; // dev_id enum proc_state state; - struct list *messages; + struct stack *messages; }; -struct proc_message { - struct proc *src; - struct proc *dest; - struct message *msg; -}; - -struct proc *kernel_proc; - void scheduler(struct regs *regs); void proc_init(void); void proc_print(void); struct proc *proc_current(void); -void proc_send(struct proc *src, struct proc *dest, u32 type, void *data); -struct proc_message *proc_receive(struct proc *proc); struct proc *proc_from_pid(u32 pid); void proc_exit(struct proc *proc, int status); void proc_yield(struct regs *r); +void proc_clear_quantum(); +void proc_enable_waiting(u32 dev_id); struct proc *proc_make(void); #endif |