Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the boot usb option #209

Merged
merged 10 commits into from
Oct 24, 2024
Merged

Allow the boot usb option #209

merged 10 commits into from
Oct 24, 2024

Conversation

fysnet
Copy link
Collaborator

@fysnet fysnet commented Jan 7, 2024

This allows the usb option to be used in the boot: parameter. Of course there is not support for booting from a USB, but this allows for a (probably much) further down the road addition.

This will break the current bios when booting from a network. However, the bios is already broken in this manner, especially when BX_ELTORITO_BOOT is not defined. The current bios code assumes and hard codes the BEV entry to 4. However, if the BX_ELTORITO_BOOT define is missing, the BEV will be added to the third entry, not the fourth entry.

For the BIOS to be updated correctly, things like the following will need to be updated instead of hard coded to [4].

printf("%s", drivetypes[4]);

The following will need to be not hard coded to 4.

Bochs/bochs/bios/rombios.c

Lines 2253 to 2257 in 54961f0

if (type == IPL_TYPE_BEV) type = 0x4;
if (type == 0 || type > 0x4) BX_PANIC("Bad drive type\n");
printf("Booting from %s", drivetypes[type]);
/* print product string if BEV */
if (type == 4 && e->description != 0) {

The following will need "usb" added.

static char drivetypes[][10]={"", "Floppy","Hard Disk","CD-Rom", "Network"};

The following assumes the next entry will be the fourth entry, not checking to see if BX_ELTORITO_BOOT was defined.

Bochs/bochs/bios/rombios.c

Lines 10851 to 10857 in 54961f0

mov bx, IPL_COUNT_OFFSET ;; Read the number of entries so far
cmp bx, #IPL_TABLE_ENTRIES
je no_bev ;; Get out if the table is full
shl bx, #0x4 ;; Turn count into offset (entries are 16 bytes)
mov 0[bx], #IPL_TYPE_BEV ;; This entry is a BEV device
mov 6[bx], cx ;; Build a far pointer from the segment...
mov 4[bx], ax ;; and the offset

The following comment will need to be updated.

Bochs/bochs/bios/rombios.c

Lines 8365 to 8371 in 54961f0

// boot device codes:
// 0x00 : not defined
// 0x01 : first floppy
// 0x02 : first harddrive
// 0x03 : first cdrom
// 0x04 - 0x0f : PnP expansion ROMs (e.g. Etherboot)
// else : boot failure

As well as a few other fixes and updates.

This PR simply allows the value of '4' (BX_BOOT_USB) to be placed in the boot sequence options, moving the network (BX_BOOT_NETWORK) to the next number.

The boot sequence option still only allows three parameters.
boot: cdrom, floppy, disk
or
boot: cdrom, usb, disk
I don't think it is necessary to add a fourth.

@fysnet fysnet marked this pull request as ready for review January 7, 2024 07:07
@vruppert
Copy link
Contributor

vruppert commented Jan 7, 2024

Having support for booting from USB in Bochs would be nice, but I think it doesn't make sense to apply these changes to master until there is BIOS support for it. With SeaBIOS booting from USB should work, but I never tried it and I don't know how it is implemented. This pull request should be postponed until after release 2.8. Otherwise users may try the new config choice and reporting issues here.

@fysnet
Copy link
Collaborator Author

fysnet commented Jan 7, 2024

Having support for booting from USB in Bochs would be nice, but I think it doesn't make sense to apply these changes to master until there is BIOS support for it.

Agreed. However, BIOS support is currently a work in progress, though it may be a little while. Also, I have been told, and agree to, that small frequent PRs are much more advisable than a single large PR, hence this PR.

With SeaBIOS booting from USB should work, but I never tried it and I don't know how it is implemented.

Without mandatory user intervention, how do you tell SeaBIOS to boot the USB? Unless I am mistaken, there is no current way in Bochs to tell SeaBIOS or any BIOS for that matter, to boot the USB (without mandatory user intervention, which requires the user to know how to intervene).

This pull request should be postponed until after release 2.8.

Agreed. I have no problem with this.

Otherwise users may try the new config choice and reporting issues here.

If it is not included in the documentation yet (.bochsrc, user.dbk, etc.), only those that read and keep up with these PRs would know to try it, and in doing so, would know that it isn't available yet.

Anyway, just my opinion. It is more difficult for me to maintain and have a code base that is not in sync with the Bochs master, so I was hoping that small simple PRs would be accepted. It makes it easier on both me and the Bochs master to keep track of these small changes rather than one large change.

However, do as you feel best. I will manage.

Thanks.

@fysnet
Copy link
Collaborator Author

fysnet commented Oct 12, 2024

Just curious if this PR will ever be merged. I have the source to the referenced BIOS ready to post somewhere, I am simply waiting for the ability to boot from USB, the initial reason I wrote the BIOS. Just curious.

@vruppert
Copy link
Contributor

The USB boot option only makes sense with a BIOS that supports it. I suggest to add the new BIOS sources as new repository inside of "bochs-emu" just like I did it with the LGPL'd VGABIOS. Then we could add the binary in the bochs/bios folder. You may also have a look at the current status of the USB debugger. I made it work with plugins support and started porting it to GTK.

@fysnet
Copy link
Collaborator Author

fysnet commented Oct 19, 2024

The source code to my BIOS is at https://github.com/fysnet/i440fx. I think it will be easier for me to maintain there since I have write permission there and not here. Feel free to include the i440fx.bin file in Bochs' BIOS folder. As always, I appreciate any feedback and improvements.

@vruppert
Copy link
Contributor

Since it's on Github, it should be okay for now. I just tried to compile the BIOS here, but since I'm on Linux, I'm using nbasm with wine. It fails to compile, but I don't know whether or not it's a wine issue. I can open an issue on your page, so can look for a workaround. Now it would be possible to apply the USB boot option, but I don't know whether or not the new BIOS can be included in the Bochs tree. The LGPL license has no restrictions for the type of usage, but if I understand correctly, nbasm and software created with it are for non-commercial usage only.

bochs/gui/siminterface.h Outdated Show resolved Hide resolved
@vruppert vruppert merged commit 8fda742 into bochs-emu:master Oct 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants