* [PATCH][BIOS] Fill IPL table according discovered ATA drives
@ 2008-12-05 16:20 Laurent Vivier
2008-12-07 18:11 ` [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered " Sebastian Herbszt
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2008-12-05 16:20 UTC (permalink / raw)
To: bochs-developers; +Cc: kvm, Laurent Vivier
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 <Laurent.Vivier@bull.net>
---
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++;
-
-#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
-
/* 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)
+ 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);
}
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
--
1.5.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered ATA drives
2008-12-05 16:20 [PATCH][BIOS] Fill IPL table according discovered ATA drives Laurent Vivier
@ 2008-12-07 18:11 ` Sebastian Herbszt
2008-12-08 10:05 ` Laurent Vivier
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Herbszt @ 2008-12-07 18:11 UTC (permalink / raw)
To: Laurent Vivier, bochs-developers; +Cc: Laurent Vivier, kvm
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 <Laurent.Vivier@bull.net>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered ATA drives
2008-12-07 18:11 ` [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered " Sebastian Herbszt
@ 2008-12-08 10:05 ` Laurent Vivier
2008-12-09 22:50 ` [Bochs-developers] [PATCH][BIOS] Fill IPL tableaccordingdiscovered " Sebastian Herbszt
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2008-12-08 10:05 UTC (permalink / raw)
To: Sebastian Herbszt; +Cc: bochs-developers, kvm
Le dimanche 07 décembre 2008 à 19:11 +0100, Sebastian Herbszt a écrit :
> 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 <Laurent.Vivier@bull.net>
> > ---
> > 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 there is no ATA drive, what is the aim of adding an harddrive in the IPL table ?
Thank you for all your comments (I'm going to resend the two patches)
Regards,
Laurent
--
------------------ Laurent.Vivier@bull.net ------------------
"Tout ce qui est impossible reste à accomplir" Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bochs-developers] [PATCH][BIOS] Fill IPL tableaccordingdiscovered ATA drives
2008-12-08 10:05 ` Laurent Vivier
@ 2008-12-09 22:50 ` Sebastian Herbszt
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Herbszt @ 2008-12-09 22:50 UTC (permalink / raw)
To: Laurent Vivier; +Cc: bochs-developers, kvm
Laurent Vivier wrote:
> Le dimanche 07 décembre 2008 à 19:11 +0100, Sebastian Herbszt a écrit :
>> 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 <Laurent.Vivier@bull.net>
>> > ---
>> > 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 there is no ATA drive, what is the aim of adding an harddrive in the IPL table ?
I think BX_USE_ATADRV enables the "new" ATA/ATAPI driver. You can still use hard drives with
the older code enabled by BX_USE_ATADRV=0.
- Sebastian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-09 22:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-05 16:20 [PATCH][BIOS] Fill IPL table according discovered ATA drives Laurent Vivier
2008-12-07 18:11 ` [Bochs-developers] [PATCH][BIOS] Fill IPL table accordingdiscovered " Sebastian Herbszt
2008-12-08 10:05 ` Laurent Vivier
2008-12-09 22:50 ` [Bochs-developers] [PATCH][BIOS] Fill IPL tableaccordingdiscovered " Sebastian Herbszt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).