fix: remove the kernel process and add a shell process (still not working tho)
This commit is contained in:
@ -21,5 +21,5 @@ struct pcb {
|
||||
|
||||
void switch_process(struct pcb *next_pcb);
|
||||
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);
|
||||
|
||||
@ -21,12 +21,12 @@ static void clock_handler(struct registers *regs);
|
||||
|
||||
static void set_pit_count(unsigned count)
|
||||
{
|
||||
cli();
|
||||
// cli();
|
||||
|
||||
outb(0x40, count & 0xFF); // Low byte
|
||||
outb(0x40, (count & 0xFF00) >> 8); // High byte
|
||||
|
||||
toris();
|
||||
// toris();
|
||||
}
|
||||
|
||||
void clock_init(struct registers *regs)
|
||||
|
||||
10
src/kernel.c
10
src/kernel.c
@ -12,6 +12,7 @@
|
||||
#include "shell.h"
|
||||
#include "string.h"
|
||||
#include "terminal.h"
|
||||
#include "thread.h"
|
||||
#include "time.h"
|
||||
#include "vbe.h"
|
||||
|
||||
@ -38,14 +39,13 @@ static void bozo(int int_code)
|
||||
|
||||
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
cli();
|
||||
init_gdt();
|
||||
init_idt();
|
||||
init_memory(mbd, magic);
|
||||
load_drivers();
|
||||
terminal_initialize();
|
||||
create_kernel_process();
|
||||
signal(4, bozo);
|
||||
kill(0, 4);
|
||||
// create_process(42);
|
||||
shell_init();
|
||||
create_process(1);
|
||||
create_thread(current_pcb, shell_init);
|
||||
toris();
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ struct frame_zone *head;
|
||||
|
||||
void switch_pd(uint32_t *pd, uint32_t *cr3)
|
||||
{
|
||||
// current_pd = pd;
|
||||
current_pd = pd;
|
||||
asm volatile("mov %0, %%cr3" ::"r"(cr3));
|
||||
}
|
||||
|
||||
|
||||
@ -2,22 +2,34 @@
|
||||
#include "alloc.h"
|
||||
#include "interrupts.h"
|
||||
#include "memory.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "string.h"
|
||||
|
||||
int8_t create_kernel_process(void)
|
||||
{
|
||||
struct pcb *new_pcb = vmalloc(sizeof(struct pcb));
|
||||
if (!new_pcb)
|
||||
return -1;
|
||||
new_pcb->pid = 0;
|
||||
new_pcb->uid = 0;
|
||||
new_pcb->heap = kernel_pd;
|
||||
new_pcb->cr3 = (uint32_t *)((uint32_t)kernel_pd - HEAP_END);
|
||||
new_pcb->next = new_pcb;
|
||||
new_pcb->prev = new_pcb;
|
||||
return 0;
|
||||
}
|
||||
// int8_t create_kernel_process(void)
|
||||
// {
|
||||
// struct pcb *new_pcb = vmalloc(sizeof(struct pcb));
|
||||
// if (!new_pcb)
|
||||
// return -1;
|
||||
// new_pcb->pid = 0;
|
||||
// new_pcb->uid = 0;
|
||||
// new_pcb->heap = kernel_pd;
|
||||
// new_pcb->cr3 = (uint32_t *)((uint32_t)kernel_pd - HEAP_END);
|
||||
// new_pcb->next = new_pcb;
|
||||
// new_pcb->prev = new_pcb;
|
||||
// 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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user