/*
* BIOS Enhanced Disk Drive support
+ * Copyright (C) 2002, 2003, 2004 Dell, Inc.
* by Matt Domsch <Matt_Domsch@dell.com> October 2002
* conformant to T13 Committee www.t13.org
* projects 1572D, 1484D, 1386D, 1226DT
* disk signature read by Matt Domsch <Matt_Domsch@dell.com>
- * and Andrew Wilks <Andrew_Wilks@dell.com> September 2003
+ * and Andrew Wilks <Andrew_Wilks@dell.com> September 2003, June 2004
* legacy CHS retreival by Patrick J. LoPresti <patl@users.sourceforge.net>
* March 2004
+ * Command line option parsing, Matt Domsch, November 2004
*/
#include <linux/edd.h>
+#include <asm/setup.h>
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-# Read the first sector of device 80h and store the 4-byte signature
+ movb $0, (EDD_MBR_SIG_NR_BUF)
+ movb $0, (EDDNR)
+
+# Check the command line for two options:
+# edd=of disables EDD completely (edd=off)
+# edd=sk skips the MBR test (edd=skipmbr)
+ pushl %esi
+ cmpl $0, %cs:cmd_line_ptr
+ jz done_cl
+ movl %cs:(cmd_line_ptr), %esi
+# ds:esi has the pointer to the command line now
+ movl $(COMMAND_LINE_SIZE-7), %ecx
+# loop through kernel command line one byte at a time
+cl_loop:
+ cmpl $EDD_CL_EQUALS, (%si)
+ jz found_edd_equals
+ incl %esi
+ loop cl_loop
+ jmp done_cl
+found_edd_equals:
+# only looking at first two characters after equals
+ addl $4, %esi
+ cmpw $EDD_CL_OFF, (%si) # edd=of
+ jz do_edd_off
+ cmpw $EDD_CL_SKIP, (%si) # edd=sk
+ jz do_edd_skipmbr
+ jmp done_cl
+do_edd_skipmbr:
+ popl %esi
+ jmp edd_start
+do_edd_off:
+ popl %esi
+ jmp edd_done
+done_cl:
+ popl %esi
+
+
+# Read the first sector of each BIOS disk device and store the 4-byte signature
+edd_mbr_sig_start:
+ movb $0x80, %dl # from device 80
+ movw $EDD_MBR_SIG_BUF, %bx # store buffer ptr in bx
+edd_mbr_sig_read:
movl $0xFFFFFFFF, %eax
- movl %eax, (DISK80_SIG_BUFFER) # assume failure
+ movl %eax, (%bx) # assume failure
+ pushw %bx
movb $READ_SECTORS, %ah
movb $1, %al # read 1 sector
- movb $0x80, %dl # from device 80
movb $0, %dh # at head 0
movw $1, %cx # cylinder 0, sector 0
pushw %es
pushw %ds
popw %es
- movw $EDDBUF, %bx
- pushw %dx # work around buggy BIOSes
+ movw $EDDBUF, %bx # disk's data goes into EDDBUF
+ pushw %dx # work around buggy BIOSes
stc # work around buggy BIOSes
- int $0x13
+ int $0x13
sti # work around buggy BIOSes
- popw %dx
- jc disk_sig_done
- movl (EDDBUF+MBR_SIG_OFFSET), %eax
- movl %eax, (DISK80_SIG_BUFFER) # store success
-disk_sig_done:
+ popw %dx
popw %es
+ popw %bx
+ jc edd_mbr_sig_done # on failure, we're done.
+ movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR
+ movl %eax, (%bx) # store success
+ incb (EDD_MBR_SIG_NR_BUF) # note that we stored something
+ incb %dl # increment to next device
+ addw $4, %bx # increment sig buffer ptr
+ cmpb $EDD_MBR_SIG_MAX, (EDD_MBR_SIG_NR_BUF) # Out of space?
+ jb edd_mbr_sig_read # keep looping
+edd_mbr_sig_done:
# Do the BIOS Enhanced Disk Drive calls
# This consists of two calls:
# result buffer for fn48
movw $EDDBUF+EDDEXTSIZE, %si # in ds:si, fn41 results
# kept just before that
- movb $0, (EDDNR) # zero value at EDDNR
movb $0x80, %dl # BIOS device 0x80
edd_check_ext: