aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/boot
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-10-03 01:33:17 -0400
committerPaul Mackerras <paulus@samba.org>2007-10-03 01:33:17 -0400
commit70f227d8846a8a9b1f36f71c42e11cc7c6e9408d (patch)
treefb4dd5c8240bdaada819fb569c01a392b52847b9 /arch/i386/boot
parenta0c7ce9c877ceef8428798ac91fb794f83609aed (diff)
parentf778089cb2445dfc6dfd30a7a567925fd8589f1e (diff)
Merge branch 'linux-2.6' into for-2.6.24
Diffstat (limited to 'arch/i386/boot')
-rw-r--r--arch/i386/boot/header.S2
-rw-r--r--arch/i386/boot/memory.c39
-rw-r--r--arch/i386/boot/video.c14
3 files changed, 40 insertions, 15 deletions
diff --git a/arch/i386/boot/header.S b/arch/i386/boot/header.S
index 7f4a2c53bd76..f3140e596d40 100644
--- a/arch/i386/boot/header.S
+++ b/arch/i386/boot/header.S
@@ -275,7 +275,7 @@ die:
275 hlt 275 hlt
276 jmp die 276 jmp die
277 277
278 .size die, .-due 278 .size die, .-die
279 279
280 .section ".initdata", "a" 280 .section ".initdata", "a"
281setup_corrupt: 281setup_corrupt:
diff --git a/arch/i386/boot/memory.c b/arch/i386/boot/memory.c
index 1a2e62db8bed..378353956b5d 100644
--- a/arch/i386/boot/memory.c
+++ b/arch/i386/boot/memory.c
@@ -20,6 +20,7 @@
20 20
21static int detect_memory_e820(void) 21static int detect_memory_e820(void)
22{ 22{
23 int count = 0;
23 u32 next = 0; 24 u32 next = 0;
24 u32 size, id; 25 u32 size, id;
25 u8 err; 26 u8 err;
@@ -27,20 +28,33 @@ static int detect_memory_e820(void)
27 28
28 do { 29 do {
29 size = sizeof(struct e820entry); 30 size = sizeof(struct e820entry);
30 id = SMAP; 31
32 /* Important: %edx is clobbered by some BIOSes,
33 so it must be either used for the error output
34 or explicitly marked clobbered. */
31 asm("int $0x15; setc %0" 35 asm("int $0x15; setc %0"
32 : "=am" (err), "+b" (next), "+d" (id), "+c" (size), 36 : "=d" (err), "+b" (next), "=a" (id), "+c" (size),
33 "=m" (*desc) 37 "=m" (*desc)
34 : "D" (desc), "a" (0xe820)); 38 : "D" (desc), "d" (SMAP), "a" (0xe820));
39
40 /* Some BIOSes stop returning SMAP in the middle of
41 the search loop. We don't know exactly how the BIOS
42 screwed up the map at that point, we might have a
43 partial map, the full map, or complete garbage, so
44 just return failure. */
45 if (id != SMAP) {
46 count = 0;
47 break;
48 }
35 49
36 if (err || id != SMAP) 50 if (err)
37 break; 51 break;
38 52
39 boot_params.e820_entries++; 53 count++;
40 desc++; 54 desc++;
41 } while (next && boot_params.e820_entries < E820MAX); 55 } while (next && count < E820MAX);
42 56
43 return boot_params.e820_entries; 57 return boot_params.e820_entries = count;
44} 58}
45 59
46static int detect_memory_e801(void) 60static int detect_memory_e801(void)
@@ -89,11 +103,16 @@ static int detect_memory_88(void)
89 103
90int detect_memory(void) 104int detect_memory(void)
91{ 105{
106 int err = -1;
107
92 if (detect_memory_e820() > 0) 108 if (detect_memory_e820() > 0)
93 return 0; 109 err = 0;
94 110
95 if (!detect_memory_e801()) 111 if (!detect_memory_e801())
96 return 0; 112 err = 0;
113
114 if (!detect_memory_88())
115 err = 0;
97 116
98 return detect_memory_88(); 117 return err;
99} 118}
diff --git a/arch/i386/boot/video.c b/arch/i386/boot/video.c
index 693f20d3102e..e4ba897bf9a3 100644
--- a/arch/i386/boot/video.c
+++ b/arch/i386/boot/video.c
@@ -147,7 +147,7 @@ int mode_defined(u16 mode)
147} 147}
148 148
149/* Set mode (without recalc) */ 149/* Set mode (without recalc) */
150static int raw_set_mode(u16 mode) 150static int raw_set_mode(u16 mode, u16 *real_mode)
151{ 151{
152 int nmode, i; 152 int nmode, i;
153 struct card_info *card; 153 struct card_info *card;
@@ -165,8 +165,10 @@ static int raw_set_mode(u16 mode)
165 165
166 if ((mode == nmode && visible) || 166 if ((mode == nmode && visible) ||
167 mode == mi->mode || 167 mode == mi->mode ||
168 mode == (mi->y << 8)+mi->x) 168 mode == (mi->y << 8)+mi->x) {
169 *real_mode = mi->mode;
169 return card->set_mode(mi); 170 return card->set_mode(mi);
171 }
170 172
171 if (visible) 173 if (visible)
172 nmode++; 174 nmode++;
@@ -178,7 +180,7 @@ static int raw_set_mode(u16 mode)
178 if (mode >= card->xmode_first && 180 if (mode >= card->xmode_first &&
179 mode < card->xmode_first+card->xmode_n) { 181 mode < card->xmode_first+card->xmode_n) {
180 struct mode_info mix; 182 struct mode_info mix;
181 mix.mode = mode; 183 *real_mode = mix.mode = mode;
182 mix.x = mix.y = 0; 184 mix.x = mix.y = 0;
183 return card->set_mode(&mix); 185 return card->set_mode(&mix);
184 } 186 }
@@ -223,6 +225,7 @@ static void vga_recalc_vertical(void)
223static int set_mode(u16 mode) 225static int set_mode(u16 mode)
224{ 226{
225 int rv; 227 int rv;
228 u16 real_mode;
226 229
227 /* Very special mode numbers... */ 230 /* Very special mode numbers... */
228 if (mode == VIDEO_CURRENT_MODE) 231 if (mode == VIDEO_CURRENT_MODE)
@@ -232,13 +235,16 @@ static int set_mode(u16 mode)
232 else if (mode == EXTENDED_VGA) 235 else if (mode == EXTENDED_VGA)
233 mode = VIDEO_8POINT; 236 mode = VIDEO_8POINT;
234 237
235 rv = raw_set_mode(mode); 238 rv = raw_set_mode(mode, &real_mode);
236 if (rv) 239 if (rv)
237 return rv; 240 return rv;
238 241
239 if (mode & VIDEO_RECALC) 242 if (mode & VIDEO_RECALC)
240 vga_recalc_vertical(); 243 vga_recalc_vertical();
241 244
245 /* Save the canonical mode number for the kernel, not
246 an alias, size specification or menu position */
247 boot_params.hdr.vid_mode = real_mode;
242 return 0; 248 return 0;
243} 249}
244 250