Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kernel/include/kernel/fs/chardev.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#define CHAR_DEV_H

#include <kernel/fs/vfs.h>
#include <kernel/process.h>

struct chardev_info {
process_queue rsrc_wait_queue;
};

void init_tty1 (inode* absolute_root);

Expand Down
7 changes: 7 additions & 0 deletions kernel/include/kernel/fs/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ typedef enum { UNDEF, EFILE, DIRECTORY, LINK, CHAR_DEV } file_type_t;
typedef struct inode inode;
typedef struct file file;

typedef struct chardev_info chardev_info_t;
typedef struct ramfs_info ramfs_info_t;

typedef struct {
int (*lookup) (char*, inode**, inode*);
int (*create) (char*, inode**, inode*);
Expand All @@ -41,6 +44,10 @@ struct inode {
inode_operations* i_iops;
file_operations* i_fops;
file_type_t i_type;
union {
chardev_info_t* chardev_info;
ramfs_info_t* ramfs_info;
} i_info;
};

struct file {
Expand Down
4 changes: 4 additions & 0 deletions kernel/src/kernel/fs/chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ void init_tty1 (inode* absolute_root) {
tty1_fops->write = stdout_write;
// tty1_fops->read = // connect to keyboard get_next_char when available

chardev_info_t* tty1_info = kmalloc(sizeof(chardev_info_t));
kmemset (tty1_info, 0, sizeof(chardev_info_t));

tty1_file->i_iops = nullptr;
tty1_file->i_fops = tty1_fops;
tty1_file->i_type = CHAR_DEV;
tty1_file->i_info.chardev_info = tty1_info;
}
6 changes: 6 additions & 0 deletions kernel/src/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ int process_fork (process* source_process, process** dest_ptr) {
return new_process->p_id;
}

void process_block (process_queue* wait_queue) {
current_process->p_state = TASK_BLOCKED;
enqueue_process(wait_queue, current_process);
do_sched_yield();
}

static uint64_t sys_fork (uint64_t arg1, uint64_t arg2, uint64_t arg3) {
(void)arg1, (void)arg2, (void)arg3; // fork does not use any args
process* child = nullptr;
Expand Down
Loading