From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastian Herbszt" Subject: Re: [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered ATA drives Date: Sun, 7 Dec 2008 19:11:03 +0100 Message-ID: <4A58ABD7D38C471D9D5865C3E634515E@FSCPC> References: <1228494009-20270-1-git-send-email-Laurent.Vivier@bull.net> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Cc: "Laurent Vivier" , To: "Laurent Vivier" , Return-path: Received: from mail.gmx.net ([213.165.64.20]:35822 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751428AbYLGSLu (ORCPT ); Sun, 7 Dec 2008 13:11:50 -0500 In-Reply-To: <1228494009-20270-1-git-send-email-Laurent.Vivier@bull.net> Sender: kvm-owner@vger.kernel.org List-ID: Laurent Vivier wrote: > This patch shows in boot menu only available devices. > > This patch has been tested with Bochs BIOS version from the KVM source tree. > > Signed-off-by: Laurent Vivier > --- > bios/rombios.c | 54 +++++++++++++++++++++++++++++++++++++----------------- > 1 files changed, 37 insertions(+), 17 deletions(-) > > diff --git a/bios/rombios.c b/bios/rombios.c > index 70b3584..d2a7c09 100644 > --- a/bios/rombios.c > +++ b/bios/rombios.c > @@ -1981,18 +1981,6 @@ init_boot_vectors() > memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e)); > count++; > > - /* First HDD */ > - e.type = IPL_TYPE_HARDDISK; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0; > - memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e)); > - count++; We need this bit for the !BX_USE_ATADRV case. Please "#if !BX_USE_ATADRV ... #endif" it instead of removing. > -#if BX_ELTORITO_BOOT > - /* CDROM */ > - e.type = IPL_TYPE_CDROM; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0; > - memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e)); > - count++; > -#endif This is ok since BX_ELTORITO_BOOT depends on BX_USE_ATADRV. > /* Remember how many devices we have */ > write_word(IPL_SEG, IPL_COUNT_OFFSET, count); > /* Not tried booting anything yet */ > @@ -2027,15 +2015,19 @@ Bit16u i; > if (i >= count) return 0; > type = read_word(IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (ipl_entry_t), > sizeof(Bit16u)); > - if (type != IPL_TYPE_HARDDISK) > + if (type == IPL_TYPE_HARDDISK) > + drv = 0x80; > + else if(type == IPL_TYPE_CDROM) Please put a space between "if" and "(". > + drv = 0xe0; > + else > return 0; > - for (curr = 0, drv = 0; curr < i; curr++) { > + for (curr = 0; curr < i; curr++) { > curr_type = read_word(IPL_SEG, > IPL_TABLE_OFFSET + curr * sizeof (ipl_entry_t), > sizeof(Bit16u)); > if (type == curr_type) drv++; > } > - return 0x80 + drv; > + return drv; > } > > #if BX_ELTORITO_BOOT > @@ -2082,6 +2074,9 @@ interactive_bootkey() > memcpyb(ss, &description, (Bit16u)(e.description >> 16), (Bit16u)(e.description & 0xffff), 32); > description[32] = 0; > printf(" [%S]", ss, description); > + } else { > + Bit16u drive = get_bootdrv(i); > + if (drive) printf(" (0x%02x)", drive); get_bootdrv() returns Bit8u. > } > printf("\n"); > break; > @@ -2484,6 +2479,9 @@ void ata_detect( ) > Bit16u ebda_seg=read_word(0x0040,0x000E); > Bit8u hdcount, cdcount, device, type; > Bit8u buffer[0x0200]; > + Bit16u ss = get_SS(); > + ipl_entry_t e; > + Bit16u count; > > #if BX_MAX_ATA_INTERFACES > 0 > write_byte(ebda_seg,&EbdaData->ata.channels[0].iface,ATA_IFACE_ISA); > @@ -2750,6 +2748,16 @@ void ata_detect( ) > printf(" ATA-%d Hard-Disk (%4u MBytes)\n", version, (Bit16u)sizeinmb); > else > printf(" ATA-%d Hard-Disk (%4u GBytes)\n", version, (Bit16u)(sizeinmb>>10)); > + /* add to IPL list */ > + count = read_word(IPL_SEG, IPL_COUNT_OFFSET); > + e.type = IPL_TYPE_HARDDISK; > + e.flags = 0; > + e.vector = 0; > + e.description = 0; > + e.reserved = 0; > + memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), > + ss, &e, sizeof (e)); > + write_word(IPL_SEG, IPL_COUNT_OFFSET, count + 1); > break; > case ATA_TYPE_ATAPI: > printf("ata%d %s: ",channel,slave?" slave":"master"); > @@ -2758,6 +2766,18 @@ void ata_detect( ) > printf(" ATAPI-%d CD-Rom/DVD-Rom\n",version); > else > printf(" ATAPI-%d Device\n",version); > + /* add to IPL list */ > +#if BX_ELTORITO_BOOT > + count = read_word(IPL_SEG, IPL_COUNT_OFFSET); > + e.type = IPL_TYPE_CDROM; > + e.flags = 0; > + e.vector = 0; > + e.description = 0; > + e.reserved = 0; > + memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), > + ss, &e, sizeof (e)); > + write_word(IPL_SEG, IPL_COUNT_OFFSET, count + 1); > +#endif > break; > case ATA_TYPE_UNKNOWN: > printf("ata%d %s: Unknown device\n",channel,slave?" slave":"master"); > @@ -10663,6 +10683,8 @@ post_default_ints: > ;; > call hard_drive_post > > + call _init_boot_vectors > + > #if BX_USE_ATADRV > > ;; > @@ -10682,8 +10704,6 @@ post_default_ints: > ;; > #endif // BX_ELTORITO_BOOT > > - call _init_boot_vectors > - > mov cx, #0xc800 ;; init option roms > mov ax, #0xe000 > call rom_scan > -- - Sebastian