]>
Commit | Line | Data |
---|---|---|
14c7c974 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
4f6e3300 A |
6 | * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.1 (the "License"). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
14c7c974 A |
13 | * |
14 | * The Original Code and all software distributed under the License are | |
4f6e3300 | 15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
14c7c974 A |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
4f6e3300 A |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License. | |
14c7c974 A |
21 | * |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | #include <bios.h>\r | |
25 | #include <dos.h>\r | |
26 | #include <stdio.h>\r | |
27 | \r | |
28 | char bufold[512];\r | |
29 | \r | |
30 | int main(int argc, char *argv[])\r | |
31 | {\r | |
32 | void far (*reset)();\r | |
33 | #define CMD 2\r | |
34 | #define DRIVE 0x80\r | |
35 | #define HEAD 0\r | |
36 | #define TRACK 0\r | |
37 | #define SECT 1\r | |
38 | #define NSECT 1\r | |
39 | int result, i;\r | |
40 | int found;\r | |
41 | unsigned char *p1, *p2, key;\r | |
42 | int softReboot=0;\r | |
43 | int dontAsk=0;\r | |
44 | \r | |
45 | for (i=1; i<argc; i++)\r | |
46 | {\r | |
47 | if (!strcmp(argv[i],"-dontask")) dontAsk=1;\r | |
48 | else if (!strcmp(argv[i],"-soft")) softReboot=1;\r | |
49 | }\r | |
50 | \r | |
51 | if (!dontAsk)\r | |
52 | {\r | |
53 | printf("Do you want to reboot into NEXTSTEP?\n");\r | |
54 | printf(" (This will immediately terminate all processes!)\n");\r | |
55 | key = bioskey(0);\r | |
56 | if (!(key=='y' || key=='Y'))\r | |
57 | {\r | |
58 | printf("Cancelled\n");\r | |
59 | exit(0);\r | |
60 | }\r | |
61 | }\r | |
62 | \r | |
63 | result = biosdisk(CMD,DRIVE,HEAD,TRACK,SECT,NSECT,bufold);\r | |
64 | if (result != 0)\r | |
65 | { printf("Couldn't read bootsectorread\n");\r | |
66 | exit(0);\r | |
67 | }\r | |
68 | \r | |
69 | p1 = bufold + 445;\r | |
70 | \r | |
71 | if (*p1 != 0xa7)\r | |
72 | {\r | |
73 | printf("GONEXT can only work if NeXT's BOOT0 bootsector"\r | |
74 | " is installed.\n");\r | |
75 | exit(0);\r | |
76 | }\r | |
77 | \r | |
78 | found = 0;\r | |
79 | p1=bufold + 446;\r | |
80 | for (i=0; i<4; i++)\r | |
81 | { p2 = p1 + (i*16) + 4;\r | |
82 | if (*p2 == 0xa7)\r | |
83 | { found=1;\r | |
84 | break;\r | |
85 | }\r | |
86 | }\r | |
87 | \r | |
88 | if (!found)\r | |
89 | { printf("No NEXTSTEP partition installed\n");\r | |
90 | exit(0);\r | |
91 | }\r | |
92 | \r | |
93 | /* now do the proper CMOS write! */\r | |
94 | \r | |
95 | \r | |
96 | outportb(0x70,6); /* select */\r | |
97 | key = inportb(0x71);\r | |
98 | key |= 0x10;\r | |
99 | outportb(0x70,6); /* select */\r | |
100 | outportb(0x71,key);\r | |
101 | \r | |
102 | if (softReboot) geninterrupt(0x19);\r | |
103 | else\r | |
104 | {\r | |
105 | printf("'Scuse me while I kiss the sky!\n");\r | |
106 | reset = MK_FP(0xf000,0xfff0);\r | |
107 | reset();\r | |
108 | geninterrupt(0x19); /* try again - shouldn't get here */\r | |
109 | }\r | |
110 | \r | |
111 | printf("Reboot failed\n");\r | |
112 | return -1; /* you never get here */\r | |
113 | } |