summaryrefslogtreecommitdiffstats
path: root/contrib/auto-default/main.c.patch
blob: e707b63a32a75292f7f2c5c743fc7048d2ea32d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- main.c	Mon Nov  5 18:58:30 2001
+++ main.c.new	Thu Nov 15 01:45:12 2001
@@ -149,21 +151,49 @@
 static unsigned short ipchksum(unsigned short *ip, int len);
 static unsigned short udpchksum(struct iphdr *packet);
 
+
+#if defined(ASK_BOOT) && ASK_BOOT > 0 && (ANS_DEFAULT == ANS_AUTO)
+/*
+ * Read Installed Hard Disk Count from BIOS memory at 0:0475
+ */
+static int hdsk_cnt(void)
+{
+	int retv;
+	__asm__ __volatile__(
+       "xorw %%ax,%%ax\n\t"
+       "movb 0x475,%%al\n"
+       : "=a" (retv)
+       : /* no inputs */
+       : "ax", "cc", "memory"
+	);
+	return(retv);
+}
+#endif /* ASK_BOOT && ANS_AUTO */
+
+
 static inline void ask_boot(void)
 {
 #if defined(ASK_BOOT) && ASK_BOOT > 0
 	while(1) {
-		int c;
+		int c, deflt;
 		unsigned long time;
+#if defined(ASK_BOOT) && ASK_BOOT > 0 && (ANS_DEFAULT == ANS_AUTO)
+		if (hdsk_cnt() != 0)
+			deflt = ANS_LOCAL;
+		else
+			deflt = ANS_NETWORK;
+#else
+		deflt = ANS_DEFAULT;
+#endif
 		printf(ASK_PROMPT);
 		for (time = currticks() + ASK_BOOT*TICKS_PER_SEC; !iskey(); )
 			if (currticks() > time) {
-				c = ANS_DEFAULT;
+				c = deflt;
 				goto done;
 			}
 		c = getchar();
 		if ((c >= 'a') && (c <= 'z')) c &= 0x5F;
-		if (c == '\n') c = ANS_DEFAULT;
+		if (c == '\n') c = deflt;
 done:
 		if ((c >= ' ') && (c <= '~')) putchar(c);
 		putchar('\n');