1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-12-11 11:35:39 -05:00

Start working on process management

This commit is contained in:
Alex Kotov 2020-11-26 14:43:20 +05:00
parent a5b7bd8ef2
commit b0d716fdd1
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 82 additions and 0 deletions

View file

@ -19,6 +19,7 @@ OBJS += page_dir.c.o
# Architecture-independent
OBJS += info.c.o
OBJS += process.c.o
# Stdlib
OBJS += memset.c.o

View file

@ -5,6 +5,7 @@
#include "info.h"
#include "stdlib.h"
#include "module.h"
#include "process.h"
#include "tasks.h"
#include "elf.h"
@ -12,6 +13,8 @@
static struct KernelMQ_Info kinfo;
static KernelMQ_Process_List process_list;
void init(const struct KernelMQ_Info *const kinfo_ptr)
{
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
@ -28,6 +31,21 @@ void init(const struct KernelMQ_Info *const kinfo_ptr)
paging_mapkernel(&kinfo);
paging_load();
const enum KernelMQ_Process_List_InitResult process_list_init_result =
KernelMQ_Process_List_init(&process_list);
if (process_list_init_result != KERNELMQ_PROCESS_LIST_INIT_RESULT_OK) {
logger_fail_from(
"init",
"Process list initialization failed with %u.",
process_list_init_result
);
panic("Can not initialize process list.");
}
logger_debug_from("init", "Process list initialized.");
if (kinfo.modules_count > 0) {
const struct KernelMQ_ELF_Header *const elf_header =
(void*)kinfo.modules[0].base;

11
kernelmq/process.c Normal file
View file

@ -0,0 +1,11 @@
#include "process.h"
#include "stdlib.h"
enum KernelMQ_Process_List_InitResult KernelMQ_Process_List_init(
KernelMQ_Process_List *const process_list
) {
kmemset(process_list, 0, sizeof(*process_list));
return KERNELMQ_PROCESS_LIST_INIT_RESULT_OK;
}

52
kernelmq/process.h Normal file
View file

@ -0,0 +1,52 @@
#ifndef KERNELMQ_INCLUDED_PROCESS
#define KERNELMQ_INCLUDED_PROCESS 1
#define KERNELMQ_PROCESS_LIST_LENGTH 20
#define KERNELMQ_PROCESS_CMDLINE_SIZE_MAX 256
#define KERNELMQ_PROCESS_CMDLINE_SLEN_MAX (KERNELMQ_PROCESS_CMDLINE_SIZE_MAX - 1)
#define KERNELMQ_PROCESS_AREAS_LENGTH_MAX 20
#ifdef __cplusplus
extern "C" {
#endif
enum KernelMQ_Process_List_InitResult {
KERNELMQ_PROCESS_LIST_INIT_RESULT_OK = 0,
};
enum KernelMQ_Process_CreatedFrom {
KERNELMQ_PROCESS_CREATED_FROM_KERNEL = 0,
KERNELMQ_PROCESS_CREATED_FROM_MODULE = 1,
};
struct KernelMQ_Process_Area {
unsigned long base;
unsigned long size;
unsigned long limit;
};
struct KernelMQ_Process {
unsigned char is_present;
enum KernelMQ_Process_CreatedFrom created_from;
char cmdline[KERNELMQ_PROCESS_CMDLINE_SIZE_MAX];
struct KernelMQ_Process_Area areas[KERNELMQ_PROCESS_AREAS_LENGTH_MAX];
unsigned int areas_length;
};
typedef struct KernelMQ_Process
KernelMQ_Process_List[KERNELMQ_PROCESS_LIST_LENGTH];
enum KernelMQ_Process_List_InitResult KernelMQ_Process_List_init(
KernelMQ_Process_List *process_list
);
#ifdef __cplusplus
}
#endif
#endif