small refactoring & fix

This commit is contained in:
2025-07-27 12:24:50 +03:00
parent f742d1fe9b
commit ee6c87c6d7
2 changed files with 24 additions and 24 deletions

View File

@@ -1,6 +1,24 @@
#pragma once
#include "common.h"
#define PROCS_MAX 8 // Maximum ammount of processes
#define PROC_UNUSED 0 // Unused processes control structure
#define PROC_RUNNABLE 1 // Runnable proccess
#define SATP_SV32 (1u << 31)
#define PAGE_V (1 << 0) // "Valid" bit (entry is allowed)
#define PAGE_R (1 << 1) // Readable
#define PAGE_W (1 << 2) // Writable
#define PAGE_X (1 << 3) // Executable
#define PAGE_U (1 << 4) // User (accessible in user mode)
struct process {
int pid; // ID of a process
int state; // State of the process: either PROC_UNUSED or PROC_RUNNABLE
vaddr_t sp; // Stack pointer
uint32_t *page_table; // points to first level page table
uint8_t stack[8192]; // Kernel stack
};
struct sbiret {
long error;
long value;
@@ -59,24 +77,3 @@ struct trap_frame {
while (1) {} \
} while (0)
#define PROCS_MAX 8 // Maximum ammount of processes
#define PROC_UNUSED 0 // Unused processes control structure
#define PROC_RUNNABLE 1 // Runnable proccess
// Page table
#define SATP_SV32 (1u << 32)
#define PAGE_V (1 << 0) // "Valid" bit (entry is allowed)
#define PAGE_R (1 << 1) // Readable
#define PAGE_W (1 << 2) // Writable
#define PAGE_X (1 << 3) // Executable
#define PAGE_U (1 << 4) // User (accessible in user mode)
struct process {
int pid; // ID of a process
int state; // State of the process: either PROC_UNUSED or PROC_RUNNABLE
vaddr_t sp; // Stack pointer
uint32_t *page_table;
uint8_t stack[8192]; // Kernel stack
};