Page MenuHomeFreeBSD

loader: create bio_alloc and bio_free for bios bounce buffer
ClosedPublic

Authored by tsoome on Sep 12 2018, 12:27 PM.

Details

Summary

We do have 16KB buffer space defined in pxe.c, move it to bio.c and implement
bio_alloc()/bio_free() interface to make it possible to use this space for
other BIOS calls (notably, from biosdisk.c).

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

tsoome created this revision.Sep 12 2018, 12:27 PM
tsoome updated this revision to Diff 47950.Sep 12 2018, 12:30 PM

BIO_BUFFER_SIZE is defined in libi386.h

imp added a comment.Sep 12 2018, 6:16 PM

Generally I like this, but it also looks like there's some drive reset retry logic tossed in as well...

In D17131#365407, @imp wrote:

Generally I like this, but it also looks like there's some drive reset retry logic tossed in as well...

yes, it is not clean current below this patch - I had D11174 below. I can rebase on current but I would rather keep my own order or I will mix fbsd and illumos up at some point:D

tsoome updated this revision to Diff 51431.Nov 30 2018, 11:40 AM

Rebase on r341328

imp added a comment.Nov 30 2018, 4:15 PM

Couple of minor nits, but otherwise looks OK.

stand/i386/libi386/biosdisk.c
472 ↗(On Diff #51431)

speaking of which...

We are getting pretty big with all the crazy new features. Is there a reliable way to tell the largest bootable image since it must all fit <= 640k? I run into trouble in the mid 500's...

952 ↗(On Diff #51431)

you said 16k above? Is that still right or ???

tsoome marked 2 inline comments as done.Nov 30 2018, 5:22 PM
tsoome added inline comments.
stand/i386/libi386/biosdisk.c
472 ↗(On Diff #51431)

not really.

The fundamental issue (and also way out in a sense) is the memory layout.

The BTX is at 0x9000, loader is starting at 0xa000 - thats code + data + bss. We get the memory size from 0x413 (2 bytes, in pages), and thats basically our initial stack pointer. Since the BDA is variable, we have no way to know ahead how much space we have for sure.

However, our stack does not have to be in low memory, we could set it just below the heap too - but that means we wont provide stack variables for BIOS calls. Not too hard to clean up.

952 ↗(On Diff #51431)

Thats the 1 page from current setup. There is one page in between BTX data areas we are using. if somehow we end up the "bio" area exhausted, this is our fallback. I'd expect it never happen, but ...

tsoome updated this revision to Diff 52140.Dec 18 2018, 10:43 AM

Update the comment about alloc/free ordering.

tsoome updated this revision to Diff 52144.Dec 18 2018, 2:54 PM

Small nits

This revision was not accepted when it landed; it landed in state Needs Review.Dec 30 2018, 9:36 AM
This revision was automatically updated to reflect the committed changes.