I swear this is going to be a long day.
This commit is contained in:
parent
f25003e0d6
commit
18c6d3c858
@ -1,19 +1,17 @@
|
|||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
// Standard Bois
|
#include "stdio.h"
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
// This only runs once and from there on forth only interrupts will cause something to happen
|
// This only runs once and from there on forth only interrupts will cause something to happen
|
||||||
// e.g. displaying to screen and taking input from keyboard
|
// e.g. displaying to screen and taking input from keyboard
|
||||||
void _start() {
|
void _start() {
|
||||||
// Initialize Global Variables and set up interrrupt handlers
|
// Initialize Global Variables and set up interrrupt handlers
|
||||||
// These variables are a vulnerability to OS security if someone can adjust
|
// These variables are a vulnerability to OS security if someone can adjust
|
||||||
// the lower value in the kernel code (exploiting, for example, an Intel address hack)
|
// the lower value in the kernel code (exploiting, for example, an Intel address hack)
|
||||||
// than kernel memory and even kernel code can be overwritten
|
// than kernel memory and even kernel code can be overwritten
|
||||||
// https://www.wired.com/story/intel-lab-istare-hack-chips/
|
// https://www.wired.com/story/intel-lab-istare-hack-chips/
|
||||||
// See libc/globals.h for KMEM_START and KMEM_END values
|
// See libc/globals.h for KMEM_START and KMEM_END values
|
||||||
// See libc/globals.h for UMEM_START and UMEM_END values
|
// See libc/globals.h for UMEM_START and UMEM_END values
|
||||||
kmem_addr = KMEM_START;
|
kmem_addr = KMEM_START;
|
||||||
kernel_mem_limit = KMEM_END;
|
kernel_mem_limit = KMEM_END;
|
||||||
|
|
||||||
@ -29,32 +27,21 @@ void _start() {
|
|||||||
|
|
||||||
kprint("Type something, it will go through the kernel\n"
|
kprint("Type something, it will go through the kernel\n"
|
||||||
"Type HELP to list commands\n> ");
|
"Type HELP to list commands\n> ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// An interrupt calls this function to parse what was typed in, this is, essentially, your
|
// An interrupt calls this function to parse what was typed in, this is, essentially, your
|
||||||
// Command Line Interpreter for now.
|
// Command Line Interpreter for now.
|
||||||
void user_input(char *input) {
|
void user_input(char *input) {
|
||||||
static u32 delete_id = 0; // static persistent variable for incrementing during test
|
static u32 delete_id = 0; // static persistent variable for incrementing during test
|
||||||
static node* umem_head = NULL; // static persistent head variable for contiguous block allocations
|
static node* umem_head = NULL; // static persistent head variable for contiguous block allocations
|
||||||
if (strcmp(input, "END") == 0) {
|
if (strcmp(input, "END") == 0) {
|
||||||
kprint("Stopping the CPU. Bye!\n");
|
kprint("Stopping the CPU. Bye!\n");
|
||||||
asm volatile("hlt");
|
asm volatile("hlt");
|
||||||
// } else if (strcmp(input, "ADD") == 0) {
|
} else if (strcmp(input, "ADD") == 0) {
|
||||||
// umem_head = add_node( umem_head, 0x10000, 0x100, true, global_id++);
|
if (sstrlen(input, 15) > 4) {
|
||||||
// }
|
kprint("owo");
|
||||||
} else if (strncmp(input, "ADD", 3) == 0) {
|
}
|
||||||
// Parse the base register value from the user input
|
umem_head = add_node( umem_head, 0x10000, 0x100, true, global_id++);
|
||||||
char base_str[16];
|
|
||||||
|
|
||||||
// Get input from your input source (you need to implement this)
|
|
||||||
strncpy(base_str, input + 3, sizeof(base_str) - 1); // Skip the command part
|
|
||||||
base_str[sizeof(base_str) - 1] = '\0'; // Null-terminate the base_str
|
|
||||||
|
|
||||||
// Convert base_str to an integer (you need a suitable conversion function)
|
|
||||||
u32 base = digit_conver(base_str);
|
|
||||||
|
|
||||||
// Now you have the base register input, and you can use it as needed
|
|
||||||
umem_head = add_node(umem_head, base, 0x100, true, global_id++);
|
|
||||||
} else if (strcmp(input, "LIST") == 0) {
|
} else if (strcmp(input, "LIST") == 0) {
|
||||||
kprint("***** FORWARD ****\n");
|
kprint("***** FORWARD ****\n");
|
||||||
print_list( umem_head, true);
|
print_list( umem_head, true);
|
||||||
@ -117,10 +104,10 @@ void user_input(char *input) {
|
|||||||
kprint("\n");
|
kprint("\n");
|
||||||
}
|
}
|
||||||
kprint("> ");
|
kprint("> ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int digconver(const char *str) {
|
int digconver(const char *str) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -134,4 +121,4 @@ int digconver(const char *str) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user