This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
OS_Project/Part4/10_scheduler/kernel/kernel.c

42 lines
926 B
C
Raw Normal View History

2023-11-29 19:16:15 +00:00
#include "kernel.h"
void _start() {
free_mem_addr = 0x20000;
global_id = 0;
memory_limit = 0x40000;
isr_install();
irq_install();
kprint("Type something, it will go through the kernel\n"
"Type END to halt the CPU\n> ");
}
void user_input(char *input) {
if (strcmp(input, "END") == 0) {
kprint("Stopping the CPU. Bye!\n");
asm volatile("hlt");
} else if (strcmp(input, "ADD") == 0) {
u32 *n0; n0 = (u32 *) 16; n0++;
node *n1; n1 = NULL;
kmalloc( 20, 0, (u32 *) &n1);
n1->id = global_id++;
n1->base = global_id*100;
n1->size = global_id*10;
n1->next = NULL;
n1->previous = NULL;
kprint("ADDED: ");
char c[16];
hex_to_ascii( (u32 ) n1, c);
kprint( c);
kprint( " id: ");
hex_to_ascii( n1->id, c);
kprint( c);
} else if (strcmp(input, "ZOO") == 0) {
kprint("ZOO.\n");
}
kprint("You said: ");
kprint(input);
kprint("\n> ");
}