mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2025-12-17 12:24:37 +03:00
lesson 21, keyboard input and shell
This commit is contained in:
23
21-shell/kernel/kernel.c
Normal file
23
21-shell/kernel/kernel.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../cpu/isr.h"
|
||||
#include "../drivers/screen.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void main() {
|
||||
isr_install();
|
||||
irq_install();
|
||||
|
||||
kprint("Type something, it will go through the kernel\n"
|
||||
"Type END to halt the CPU\n> ");
|
||||
|
||||
// Do we need an infinite loop here?
|
||||
}
|
||||
|
||||
void user_input(char *input) {
|
||||
if (strcmp(input, "END") == 0) {
|
||||
kprint("Stopping the CPU. Bye!\n");
|
||||
asm volatile("hlt");
|
||||
}
|
||||
kprint("You said: ");
|
||||
kprint(input);
|
||||
kprint("\n> ");
|
||||
}
|
||||
6
21-shell/kernel/kernel.h
Normal file
6
21-shell/kernel/kernel.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
void user_input(char *input);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user