Rev 622 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Project: OSLib |
2 | * Description: The OS Construction Kit |
||
3 | * Date: 1.6.2000 |
||
4 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
5 | * |
||
6 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
7 | * low-level infrastructure for developing OS kernels and Embedded |
||
8 | * Applications; it partially derives from the HARTIK project but it |
||
9 | * currently is independently developed. |
||
10 | * |
||
11 | * OSLib is distributed under GPL License, and some of its code has |
||
12 | * been derived from the Linux kernel source; also some important |
||
13 | * ideas come from studying the DJGPP go32 extender. |
||
14 | * |
||
15 | * We acknowledge the Linux Community, Free Software Foundation, |
||
16 | * D.J. Delorie and all the other developers who believe in the |
||
17 | * freedom of software and ideas. |
||
18 | * |
||
19 | * For legalese, check out the included GPL license. |
||
20 | */ |
||
21 | |||
22 | /* Reset (or halt...) the system */ |
||
23 | |||
24 | #include <ll/i386/hw-func.h> |
||
40 | pj | 25 | #include <ll/i386/error.h> |
2 | pj | 26 | |
27 | FILE(reboot); |
||
28 | |||
751 | giacomo | 29 | int no_idt[] = { 0, 0 }; |
622 | mauro | 30 | |
2 | pj | 31 | void halt(void) |
32 | { |
||
33 | cputs("Halt called"); |
||
34 | __asm__("hlt"); |
||
35 | } |
||
36 | /* |
||
37 | * This code has been taken by the Linux Kernel and it has been |
||
38 | * freely modified and simplified to do a reboot! |
||
39 | */ |
||
40 | |||
41 | void cold_reboot(void) |
||
42 | { |
||
622 | mauro | 43 | reboot(0); |
2 | pj | 44 | } |
45 | |||
46 | void warm_reboot(void) |
||
47 | { |
||
622 | mauro | 48 | reboot(0x1234); |
2 | pj | 49 | } |
50 | |||
51 | /* |
||
52 | * This routine reboots the machine by asking the keyboard |
||
53 | * controller to pulse the reset-line low. If mode = 0x1234 you |
||
54 | * tell to BIOS to do a warm boot, else cold boot is performed! |
||
55 | */ |
||
56 | void reboot(int mode) |
||
57 | { |
||
622 | mauro | 58 | register int n, i,j; |
2 | pj | 59 | |
622 | mauro | 60 | lmempokew((LIN_ADDR)0x472,mode); |
61 | for (n = 0; n < 100; n++) { |
||
62 | // Wait for keyboard controller ready |
||
63 | for (i=0; i<0x10000; i++) |
||
64 | if ((inp(0x64) & 0x02) == 0) break; |
||
65 | // Do nothing for a while... |
||
66 | for(j = 0; j < 100000 ; j++); |
||
67 | // pulse reset low |
||
68 | outp(0xfe,0x64); |
||
69 | // Do nothing for a while... |
||
70 | for(j = 0; j < 100000 ; j++); |
||
71 | } |
||
72 | /* That didn't work - force a triple fault.. */ |
||
73 | __asm__ __volatile__("lidt %0": :"m" (no_idt)); |
||
74 | __asm__ __volatile__("int3"); |
||
2 | pj | 75 | } |