aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/boot/edd.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-07-31 16:17:13 -0400
committerH. Peter Anvin <hpa@zytor.com>2007-07-31 16:18:05 -0400
commitff659d13ed91dd0b237064aba91a5259f827aeb3 (patch)
tree43f73d3d59ece433b3b463ec2c7d36d6a6d85fec /arch/i386/boot/edd.c
parent8b608d2f5a1b3552363a3161566645a409ff8530 (diff)
[x86 setup] EDD: Fix the computation of the MBR sector buffer
Some BIOSes require that sector buffers not cross 64K boundaries. As a result, we compute a dynamic address on the setup heap. Unfortunately, this address computation was just totally wrong. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/i386/boot/edd.c')
-rw-r--r--arch/i386/boot/edd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/i386/boot/edd.c b/arch/i386/boot/edd.c
index 25a282494f4c..77d92daf7923 100644
--- a/arch/i386/boot/edd.c
+++ b/arch/i386/boot/edd.c
@@ -72,17 +72,18 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei)
72 u32 mbrsig; 72 u32 mbrsig;
73 u32 buf_base, mbr_base; 73 u32 buf_base, mbr_base;
74 extern char _end[]; 74 extern char _end[];
75 static char mbr_buf[1024];
76 75
77 sector_size = ei->params.bytes_per_sector; 76 sector_size = ei->params.bytes_per_sector;
78 if (!sector_size) 77 if (!sector_size)
79 sector_size = 512; /* Best available guess */ 78 sector_size = 512; /* Best available guess */
80 79
80 /* Produce a naturally aligned buffer on the heap */
81 buf_base = (ds() << 4) + (u32)&_end; 81 buf_base = (ds() << 4) + (u32)&_end;
82 mbr_base = (buf_base+sector_size-1) & ~(sector_size-1); 82 mbr_base = (buf_base+sector_size-1) & ~(sector_size-1);
83 mbrbuf_ptr = mbr_buf + (mbr_base-buf_base); 83 mbrbuf_ptr = _end + (mbr_base-buf_base);
84 mbrbuf_end = mbrbuf_ptr + sector_size; 84 mbrbuf_end = mbrbuf_ptr + sector_size;
85 85
86 /* Make sure we actually have space on the heap... */
86 if (!(boot_params.hdr.loadflags & CAN_USE_HEAP)) 87 if (!(boot_params.hdr.loadflags & CAN_USE_HEAP))
87 return 0; 88 return 0;
88 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr) 89 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)