sched: apply proper blocking mechanism for chardev
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
86041e90e4
commit
dfed938383
12 changed files with 183 additions and 24 deletions
|
|
@ -148,6 +148,9 @@ struct vnode *vfs_create_vno();
|
|||
void vfs_dealloc(struct fs *fs);
|
||||
int vfs_mount(struct fs *fs, const char *mount_point);
|
||||
|
||||
uint64_t vfs_file_type(struct file *file);
|
||||
void *vfs_file_dev(struct file *file);
|
||||
|
||||
int stdout_write(struct file_descriptor *fdesc, void *buf, size_t len);
|
||||
|
||||
#endif /* _VFS_H_ */
|
||||
|
|
|
|||
|
|
@ -3,13 +3,5 @@
|
|||
#define _CHAR_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
#include <kernel/proc.h>
|
||||
|
||||
struct char_queue {
|
||||
char *buf;
|
||||
size_t size;
|
||||
struct proc *proc;
|
||||
struct char_queue *next;
|
||||
};
|
||||
|
||||
#endif /* _CHAR_H_ */
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
void yield();
|
||||
void panic();
|
||||
void cli();
|
||||
void sti();
|
||||
|
||||
typedef uintptr_t paddr_t;
|
||||
typedef uint32_t paddr32_t;
|
||||
|
|
|
|||
|
|
@ -65,9 +65,25 @@ struct proc {
|
|||
sem_t block_sem;
|
||||
};
|
||||
|
||||
struct proc_block_queue {
|
||||
struct proc_block_node *head;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
struct proc_block_node {
|
||||
struct proc *proc;
|
||||
void *dev;
|
||||
void *buf;
|
||||
bool read;
|
||||
size_t size;
|
||||
struct proc_block_node *next;
|
||||
};
|
||||
|
||||
struct procregs *proc_current_regs();
|
||||
void proc_block(pid_t pid);
|
||||
void proc_block(struct proc *proc, void *dev, void *buf, bool read, size_t size);
|
||||
void proc_unblock(pid_t pid);
|
||||
struct proc_block_node *proc_block_find(void *dev);
|
||||
void proc_block_remove(struct proc_block_node *node);
|
||||
struct proc *proc_create();
|
||||
struct proc *proc_get(pid_t pid);
|
||||
pid_t getpid();
|
||||
|
|
|
|||
|
|
@ -7,4 +7,9 @@
|
|||
#define SYS_OPEN 2
|
||||
#define SYS_EXIT 60
|
||||
|
||||
#include <kernel/common.h>
|
||||
#include <kernel/proc.h>
|
||||
|
||||
void sys_set_return(struct proc *proc, uint64_t ret);
|
||||
|
||||
#endif /* _SYSCALL_H_ */
|
||||
|
|
|
|||
9
include/kernel/umem.h
Normal file
9
include/kernel/umem.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _UMEM_H_
|
||||
#define _UMEM_H_
|
||||
|
||||
#include <kernel/proc.h>
|
||||
|
||||
void copy_to_user(struct proc *proc, void *dst, const void *src, size_t size);
|
||||
|
||||
#endif /* _UMEM_H_ */
|
||||
Loading…
Reference in a new issue