summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-05-05 18:25:29 +0200
committerNiklas Halle <niklas@niklashalle.net>2020-05-05 18:25:29 +0200
commit1c0fe61eb340d0b5f59fb81517f468fbd4fe1208 (patch)
treeae6621f5cb95f61d0721124810dd8a8254979de2
parent06606fef1127717d031eea6b519cc6e43e715394 (diff)
downloadbetriebssysteme-1c0fe61eb340d0b5f59fb81517f468fbd4fe1208.tar.gz
betriebssysteme-1c0fe61eb340d0b5f59fb81517f468fbd4fe1208.zip
better reboot
-rw-r--r--01_exercise/bootloader.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/01_exercise/bootloader.c b/01_exercise/bootloader.c
index afd4d96..50a6b0e 100644
--- a/01_exercise/bootloader.c
+++ b/01_exercise/bootloader.c
@@ -29,20 +29,22 @@ char getc() {
char ret;
asm volatile(
".no_key:"
- "xor %%ax, %%ax;"
+ "xor %%eax, %%eax;"
"mov $0x0100, %%ax;" // check for keystroke:
"int $0x16;" // http://www.ctyme.com/intr/rb-1755.htm
"jz .no_key;" // wait for a key
".done:"
- "xor %%ax, %%ax;"
+
+ "xor %%eax, %%eax;"
"mov $0x1000, %%ax;" // get keystroke: http://www.ctyme.com/intr/rb-1754.htm
"int $0x16;"
+
"mov %%al, %%bl;" // temp store char in bl
"mov $0400, %%ax;" // clear keyboard buffer:
"int $0x16;" // http://www.ctyme.com/intr/rb-1759.htm
: "=b"(ret)
:
- : "ax");
+ : "eax");
return ret;
}
@@ -67,20 +69,16 @@ void main(void) {
char c = getc();
if (c == '\r') {
if (i == 0) { // empty entry
- print("Reboot!");
- /*asm volatile(
- "mov $0x5307, %%ax;" // TURN OFF SYSTEM:
- // http://www.ctyme.com/intr/rb-1356.htm
- "mov $0x0001, %%bx;"
- "mov $0x0003, %%cx;"
- "int $0x15" ::
- : "ax", "bx", "cx");*/
- asm volatile("xor %%eax, %%eax\n"
- "push %%eax\n"
- "push %%ax\n"
- "lidt (%%esp)\n"
- "mov %%ss, %%eax" ::
- : "eax");
+ print("Reboot!\n\r");
+ sleep(250); // too see the reboot print out, even if short
+ asm volatile(
+ "cli;" // disable interrupts
+ "mov $0x0FE, %%al;" // tell the keyboard controller to...
+ "out %%al, $0x64;" // ...activate the CPU reset line
+ ".halt:"
+ "hlt;" // some motherboards require this
+ "jmp .halt;" :: // and again, just to be sure
+ : "al");
return;
} else {
break;