From 495970a17ce4b2e3d7af3685ef950d1a7d112699 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 2 Jun 2010 13:23:15 +0000 Subject: [PATCH] boot monitor: introduce a 'reset' command that causes the cpu to reset (triple fault). --- boot/boot.c | 10 +++++++--- boot/boothead.s | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index c72838fc1..f73ae45b6 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -715,12 +715,12 @@ static void initialize(void) /* Reserved names: */ enum resnames { R_NULL, R_BOOT, R_CTTY, R_DELAY, R_ECHO, R_EXIT, R_HELP, - R_LS, R_MENU, R_OFF, R_SAVE, R_SET, R_TRAP, R_UNSET + R_LS, R_MENU, R_OFF, R_SAVE, R_SET, R_TRAP, R_UNSET, R_RESET }; static char resnames[][6] = { "", "boot", "ctty", "delay", "echo", "exit", "help", - "ls", "menu", "off", "save", "set", "trap", "unset", + "ls", "menu", "off", "save", "set", "trap", "unset", "reset", }; /* Using this for all null strings saves a lot of memory. */ @@ -731,7 +731,7 @@ static enum resnames reserved(const char *s) { enum resnames r; - for (r= R_BOOT; r <= R_UNSET; r++) { + for (r= R_BOOT; r <= R_RESET; r++) { if (strcmp(s, resnames[r]) == 0) return r; } return R_NULL; @@ -1877,6 +1877,7 @@ static void execute(void) case R_EXIT: exit(0); case R_OFF: off(); ok= 1; break; case R_CTTY: ctty(nil); ok= 1; break; + case R_RESET: reset(); ok= 1; break; } /* Command to check bootparams: */ @@ -2029,6 +2030,9 @@ void main(int argc, char **argv) } exit(0); } + +reset() { } + #endif /* UNIX */ /* diff --git a/boot/boothead.s b/boot/boothead.s index f72777ff1..7fefb1ec3 100644 --- a/boot/boothead.s +++ b/boot/boothead.s @@ -1454,6 +1454,11 @@ _scan_keyboard: outb 0x61 ret +.define _reset +_reset: + lidt idt_zero + int 0x3 + .data .ascii "(null)\0" ! Just in case someone follows a null pointer .align 2 @@ -1461,6 +1466,8 @@ c60: .data2 60 ! Constants for MUL and DIV c1024: .data2 1024 c1080: .data2 1080 c19663: .data2 19663 +idt_zero: +.data4 0,0 ! Global descriptor tables. UNSET = 0 ! Must be computed