kernel: add basic proc outline
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
9de7664bb9
commit
1b8fe6b24d
4 changed files with 67 additions and 0 deletions
52
include/kernel/proc.h
Normal file
52
include/kernel/proc.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _PROC_H_
|
||||
#define _PROC_H_
|
||||
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/spinlock.h>
|
||||
|
||||
#include <lib/rbtree.h>
|
||||
|
||||
#define PROC_STATE_RUNNING 0
|
||||
#define PROC_STATE_WAITING 1
|
||||
#define PROC_STATE_DNS 2 /* do not schedule */
|
||||
|
||||
typedef u64 pid_t;
|
||||
typedef u64 tid_t;
|
||||
|
||||
struct vm_area {
|
||||
vaddr_t start;
|
||||
vaddr_t end;
|
||||
u64 flags;
|
||||
};
|
||||
|
||||
struct proc;
|
||||
struct thread {
|
||||
struct proc *proc;
|
||||
tid_t tid;
|
||||
u64 state;
|
||||
bool in_kernel;
|
||||
|
||||
vaddr_t user_stack;
|
||||
vaddr_t kernel_stack;
|
||||
|
||||
u64 tls_base;
|
||||
|
||||
struct thread *next;
|
||||
};
|
||||
|
||||
struct proc {
|
||||
pid_t pid;
|
||||
struct thread main_thread;
|
||||
|
||||
char *name;
|
||||
|
||||
rbtree_t vm_tree;
|
||||
spinlock_t vm_lock;
|
||||
|
||||
spinlock_t sched_lock;
|
||||
};
|
||||
|
||||
void proc_init();
|
||||
|
||||
#endif /* _PROC_H_ */
|
||||
|
|
@ -2,4 +2,5 @@
|
|||
obj-y += device.o
|
||||
obj-y += sg.o
|
||||
obj-y += block/
|
||||
obj-y += proc/
|
||||
obj-y += tty/
|
||||
|
|
|
|||
2
kernel/proc/Makefile
Normal file
2
kernel/proc/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += proc.o
|
||||
12
kernel/proc/proc.c
Normal file
12
kernel/proc/proc.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <kernel/proc.h>
|
||||
#include <kernel/slab.h>
|
||||
|
||||
mem_cache_t *proc_slab;
|
||||
mem_cache_t *thread_slab;
|
||||
|
||||
void proc_init()
|
||||
{
|
||||
proc_slab = slab_create("proc_slab", sizeof(struct proc), 1 * MB, 8);
|
||||
thread_slab = slab_create("thread_slab", sizeof(struct thread), 1 * MB, 8);
|
||||
}
|
||||
Loading…
Reference in a new issue