fix: remove the kernel process and add a shell process (still not working tho)

This commit is contained in:
0x35c
2025-11-05 16:46:55 +01:00
parent 374ea13173
commit 359484b2e4
5 changed files with 34 additions and 22 deletions

View File

@ -21,5 +21,5 @@ struct pcb {
void switch_process(struct pcb *next_pcb); void switch_process(struct pcb *next_pcb);
struct pcb *create_process(uint8_t uid); struct pcb *create_process(uint8_t uid);
int8_t create_kernel_process(void); // int8_t create_kernel_process(void);
void remove_process(struct pcb *pcb); void remove_process(struct pcb *pcb);

View File

@ -21,12 +21,12 @@ static void clock_handler(struct registers *regs);
static void set_pit_count(unsigned count) static void set_pit_count(unsigned count)
{ {
cli(); // cli();
outb(0x40, count & 0xFF); // Low byte outb(0x40, count & 0xFF); // Low byte
outb(0x40, (count & 0xFF00) >> 8); // High byte outb(0x40, (count & 0xFF00) >> 8); // High byte
toris(); // toris();
} }
void clock_init(struct registers *regs) void clock_init(struct registers *regs)

View File

@ -12,6 +12,7 @@
#include "shell.h" #include "shell.h"
#include "string.h" #include "string.h"
#include "terminal.h" #include "terminal.h"
#include "thread.h"
#include "time.h" #include "time.h"
#include "vbe.h" #include "vbe.h"
@ -38,14 +39,13 @@ static void bozo(int int_code)
void kernel_main(multiboot_info_t *mbd, uint32_t magic) void kernel_main(multiboot_info_t *mbd, uint32_t magic)
{ {
cli();
init_gdt(); init_gdt();
init_idt(); init_idt();
init_memory(mbd, magic); init_memory(mbd, magic);
load_drivers(); load_drivers();
terminal_initialize(); terminal_initialize();
create_kernel_process(); create_process(1);
signal(4, bozo); create_thread(current_pcb, shell_init);
kill(0, 4); toris();
// create_process(42);
shell_init();
} }

View File

@ -13,7 +13,7 @@ struct frame_zone *head;
void switch_pd(uint32_t *pd, uint32_t *cr3) void switch_pd(uint32_t *pd, uint32_t *cr3)
{ {
// current_pd = pd; current_pd = pd;
asm volatile("mov %0, %%cr3" ::"r"(cr3)); asm volatile("mov %0, %%cr3" ::"r"(cr3));
} }

View File

@ -2,22 +2,34 @@
#include "alloc.h" #include "alloc.h"
#include "interrupts.h" #include "interrupts.h"
#include "memory.h" #include "memory.h"
#include "thread.h"
#include "string.h" #include "string.h"
int8_t create_kernel_process(void) // int8_t create_kernel_process(void)
{ // {
struct pcb *new_pcb = vmalloc(sizeof(struct pcb)); // struct pcb *new_pcb = vmalloc(sizeof(struct pcb));
if (!new_pcb) // if (!new_pcb)
return -1; // return -1;
new_pcb->pid = 0; // new_pcb->pid = 0;
new_pcb->uid = 0; // new_pcb->uid = 0;
new_pcb->heap = kernel_pd; // new_pcb->heap = kernel_pd;
new_pcb->cr3 = (uint32_t *)((uint32_t)kernel_pd - HEAP_END); // new_pcb->cr3 = (uint32_t *)((uint32_t)kernel_pd - HEAP_END);
new_pcb->next = new_pcb; // new_pcb->next = new_pcb;
new_pcb->prev = new_pcb; // new_pcb->prev = new_pcb;
return 0; // struct tcb *kern_thread = vmalloc(sizeof(struct tcb));
} // if (!kern_thread) {
// vfree(new_pcb);
// return -1;
// }
// kern_thread->esp = ;
// kern_thread->next = NULL;
// kern_thread->process = new_pcb;
// kern_thread->state = RUNNING;
// kern_thread->tid = 1;
// return 0;
// }
struct pcb *create_process(uint8_t uid) struct pcb *create_process(uint8_t uid)
{ {