syscalls: start implementing some basic syscalls

This commit is contained in:
2025-06-20 21:59:08 +03:00
parent a9789b7f57
commit 4ccae473ca
8 changed files with 110 additions and 12 deletions
+4
View File
@@ -1,11 +1,15 @@
#ifndef STDIO_H
#define STDIO_H
#include <stddef.h>
#include <stdbool.h>
//TODO: these should be contained in newlib i guess
//but until i implement it let it be here yo
#define EOF (-1)
#define INT_MAX 2147483647
bool print(const char* data, size_t length);
int printf(const char* __restrict, ...);
int putchar(int);
int puts(const char*);
+7
View File
@@ -0,0 +1,7 @@
#ifndef SYSCALLS_H
#define SYSCALLS_H
#include "../include/task.h"
void handle_syscall(TrapFrame *tf);
#endif
+7
View File
@@ -2,6 +2,7 @@
#define TASK_H
#include <stdint.h>
#include "../include/fat.h"
// Сегменты для ядра и пользователя
#define SEG_KCODE 0x08 // Сегмент кода ядра
@@ -14,6 +15,8 @@
// Флаги процессора
#define FL_IF 0x202 // Разрешить прерывания
#define MAX_OPEN_FILES 32
typedef enum TaskState
{
Ready,
@@ -58,8 +61,12 @@ typedef struct Process
TrapFrame* tf; // Trap frame (только для ring 3)
uint32_t ring; // Уровень привилегий (0 или 3)
struct Process* next; // Следующий процесс
file_t* file_descriptors[MAX_OPEN_FILES];
} Process;
extern Process* current;
Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t* pagedir);
void scheduler_init();
void schedule();