Subversion Repositories shark

Rev

Rev 3 | 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
 
29
void halt(void)
30
{
31
        cputs("Halt called");
32
        __asm__("hlt");
33
}
34
/*
35
 * This code has been taken by the Linux Kernel and it has been
36
 * freely modified and simplified to do a reboot!
37
 */
38
 
39
void cold_reboot(void)
40
{
41
    reboot(0);
42
}
43
 
44
void warm_reboot(void)
45
{
46
    reboot(0x1234);
47
}
48
 
49
/*
50
 * This routine reboots the machine by asking the keyboard
51
 * controller to pulse the reset-line low. If mode = 0x1234 you
52
 * tell to BIOS to do a warm boot, else cold boot is performed!
53
 */
54
void reboot(int mode)
55
{
56
    register int i,j;
57
 
58
    lmempokew((LIN_ADDR)0x472,mode);
59
    for (;;) {
60
        /* Wait for keyboard controller ready */
61
        for (i=0; i<0x10000; i++)
62
            if ((inp(0x64) & 0x02) == 0) break;
63
        /* Do nothing for a while... */
64
        for(j = 0; j < 100000 ; j++);
65
        /* pulse reset low */
66
        outp(0xfe,0x64);
67
        /* Do nothing for a while... */
68
        for(j = 0; j < 100000 ; j++);
69
    }
70
}