I forgot to note imp, sorry…
rgds,
toomas
> On 31 Oct 2018, at 18:42, Toomas Soome wrote:
>
> Author: tsoome
> Date: Wed Oct 31 16:42:40 2018
> New Revision: 339959
> URL: https://svnweb.freebsd.org/changeset/base/339959
>
> Log:
> loader: issue edd probe before legacy ah=08 and detect no media
>
> while probing for drives, use int13 extended info before standard one and
> provide workaround for case we are not getting needed information in case
> of floppy drive.
>
> In case of INT13 errors, there are (at least) 3 error codes appearing in case
> of missin media - 20h, 31h and 80h. Flag the no media and do not print an
> error.
>
> Differential Revision: https://reviews.freebsd.org/D17667
>
> Modified:
> head/stand/i386/libi386/biosdisk.c
>
> Modified: head/stand/i386/libi386/biosdisk.c
> ==
> --- head/stand/i386/libi386/biosdisk.cWed Oct 31 16:17:45 2018
> (r339958)
> +++ head/stand/i386/libi386/biosdisk.cWed Oct 31 16:42:40 2018
> (r339959)
> @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
> #include
> #include
> #include
> -#include
>
> #include
> #include
> @@ -81,8 +80,10 @@ static struct bdinfo
> #define BD_MODEINT130x
> #define BD_MODEEDD1 0x0001
> #define BD_MODEEDD3 0x0002
> +#define BD_MODEEDD (BD_MODEEDD1 | BD_MODEEDD3)
> #define BD_MODEMASK 0x0003
> #define BD_FLOPPY 0x0004
> +#define BD_NO_MEDIA 0x0008
> int bd_type;/* BIOS 'drive type' (floppy only) */
> uint16_tbd_sectorsize; /* Sector size */
> uint64_tbd_sectors; /* Disk size */
> @@ -188,60 +189,83 @@ bd_init(void)
> }
>
> /*
> - * Try to detect a device supported by the legacy int13 BIOS
> + * Return EDD version or 0 if EDD is not supported on this drive.
> */
> static int
> -bd_int13probe(struct bdinfo *bd)
> +bd_check_extensions(int unit)
> {
> - struct edd_params params;
> - int ret = 1;/* assume success */
> + /* Determine if we can use EDD with this device. */
> + v86.ctl = V86_FLAGS;
> + v86.addr = 0x13;
> + v86.eax = 0x4100;
> + v86.edx = unit;
> + v86.ebx = 0x55aa;
> + v86int();
>
> + if (V86_CY(v86.efl) || /* carry set */
> + (v86.ebx & 0x) != 0xaa55) /* signature */
> + return (0);
> +
> + /* extended disk access functions (AH=42h-44h,47h,48h) supported */
> + if ((v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0)
> + return (0);
> +
> + return ((v86.eax >> 8) & 0xff);
> +}
> +
> +static void
> +bd_reset_disk(int unit)
> +{
> + /* reset disk */
> v86.ctl = V86_FLAGS;
> v86.addr = 0x13;
> + v86.eax = 0;
> + v86.edx = unit;
> + v86int();
> +}
> +
> +/*
> + * Read CHS info. Return 0 on success, error otherwise.
> + */
> +static int
> +bd_get_diskinfo_std(struct bdinfo *bd)
> +{
> + bzero(, sizeof(v86));
> + v86.ctl = V86_FLAGS;
> + v86.addr = 0x13;
> v86.eax = 0x800;
> v86.edx = bd->bd_unit;
> v86int();
>
> - /* Don't error out if we get bad sector number, try EDD as well */
> - if (V86_CY(v86.efl) || /* carry set */
> - (v86.edx & 0xff) <= (unsigned)(bd->bd_unit & 0x7f)) /* unit # bad */
> - return (0); /* skip device */
> + if (V86_CY(v86.efl) && ((v86.eax & 0xff00) != 0))
> + return ((v86.eax & 0xff00) >> 8);
>
> - if ((v86.ecx & 0x3f) == 0) /* absurd sector number */
> - ret = 0;/* set error */
> + /* return custom error on absurd sector number */
> + if ((v86.ecx & 0x3f) == 0)
> + return (0x60);
>
> - /* Convert max cyl # -> # of cylinders */
> bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1;
> /* Convert max head # -> # of heads */
> bd->bd_hds = ((v86.edx & 0xff00) >> 8) + 1;
> bd->bd_sec = v86.ecx & 0x3f;
> - bd->bd_type = v86.ebx & 0xff;
> - bd->bd_flags |= BD_MODEINT13;
> + bd->bd_type = v86.ebx;
> + bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
>
> - /* Calculate sectors count from the geometry */
> - bd->bd_sectors = bd->bd_cyl * bd->bd_hds * bd->bd_sec;
> - bd->bd_sectorsize = BIOSDISK_SECSIZE;
> - DEBUG("unit 0x%x geometry %d/%d/%d", bd->bd_unit, bd->bd_cyl,
> - bd->bd_hds, bd->bd_sec);
> + return (0);
> +}
>
> - /* Determine if we can use EDD with this device. */
> - v86.ctl = V86_FLAGS;
> - v86.addr = 0x13;
> - v86.eax = 0x4100;
> - v86.edx = bd->bd_unit;
> - v86.ebx = 0x55aa;
> - v86int();
> - if (V86_CY(v86.efl) || /* carry set */
> - (v86.ebx & 0x) != 0xaa55 || /* signature */
> - (v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0)
> - return (ret); /* return code from int13 AH=08 */
> +/*
> + * Read EDD info. Return