Re: Call for Foundation-supported Project Ideas

From: Tomoaki AOKI <junchoon_at_dec.sakura.ne.jp>
Date: Wed, 05 Jan 2022 15:17:04 UTC
On Wed, 5 Jan 2022 13:16:02 +0100
Stefan Blachmann <sblachmann@gmail.com> wrote:

> On 1/4/22, Warner Losh <imp@bsdimp.com> wrote:
> > 15 or 20 years [...]
> > main reason laptops stopped suspending in the early 2000s... [...]
> > And the INT xx interface is unavailable on amd64 after we
> > enter long mode
> 
> First, you mentioned a hacking session in the "early 2000s".
> This makes me wonder whether you might mistake some other thing from
> the distance of time, as UEFI was no real thing until ~2010, and was
> never a thing on platforms other than amd64 also. Suspend/resume on
> FreeBSD only appeared much later, too.

UEFI is based on EFI, developed initially for IA-64 (Itanium), and IIRC,
FreeBSD EFI boot was first developed for (already dropped) IA-64
support.


> Second, there is kernel functionality to call real mode interrupt
> handlers from long mode, which manage switching to real mode and back.
> Just an example, these are being used by vt (via vesa.ko) to switch vesa modes.

IIUC about [1] and related ones, vesa.ko is for sc, not vt.
And unfortunately, UEFI forces grphical frame buffer, making text-only
sc driver prohibited. Of course, sc can work on legacy boot.

[1]
https://lists.freebsd.org/archives/freebsd-current/2021-November/001083.html


> So I do not see why this real mode access infrastructure could not
> also be used to make a call to C000:(PCI PROM Programming interface
> code offset), or the respective segment address where the actual VGA
> BIOS is, to have it initialize the int 10h interface handler, if a
> hybrid/dual graphics card BIOS is present.

Do you mean creating handler running on virtual 8086 mode?
If so, once x86 CPUs switches to long mode (aka amd64 mode),
it can no longer workable, as virtual 8086 mode is only on 32bit mode
or less.


> I think a single function "InitializeVGABIOSifpresent" to enable
> access to VGA/VESA BIOS functionality might actually be fairly easy to
> implement.
> Furthermore, there is no need at all to access hardware specific stuff
> like you mentioned, as the necessary functionality is completely
> covered by the int 10h interface.
> 
> Imho it could be worth to allocate a small part of the sponsoring
> budget to put a bounty to motivate people (including possibly me) to
> implement these improvements regarding suspend/resume and enhanced sc
> and vt usability.
> 
> 
> 
> On 1/4/22, Warner Losh <imp@bsdimp.com> wrote:
> > On Tue, Jan 4, 2022 at 12:14 AM Stefan Blachmann <sblachmann@gmail.com>
> > wrote:
> >
> >> On 1/4/22, Warner Losh <imp@bsdimp.com> wrote:
> >> > Not without loading the xorg graphics stuff... graphics chips from the
> >> last
> >> > 15 or 20 years have lots of chip specific state that only the graphics
> >> > stuff knows about... IIRC, it only knows about it because it put the
> >> > graphics into a known state... it's the main reason laptops stopped
> >> > suspending in the early 2000s... it looks to be a lot of work for a
> >> > relatively rare use case...
> >>
> >> UEFI GOP seems to have the necessary functionalities
> >> (https://wiki.osdev.org/GOP#Get_the_Current_Mode) so I guess the work
> >> required would be limited (restore mode and redraw screen from
> >> buffer).
> >>
> >
> > UEFI GOP isn't available after we start the kernel, so this is a
> > non-starter.
> > It works great in the boot loader, but not so good after we boot. It could
> > work
> > for S3 sleep to disk where we actually reboot to restore the machine state,
> > but we don't have sleep to disk today :(
> >
> >
> >> With non-UEFI or old UGA UEFI implementations possibly one could use
> >> the dual BIOS$B!-(B CSM part. Just call the CSM BIOS init to set up GPU and
> >> the int 10h interface, and then set previously used mode+redraw.
> >> BTW, doing that also could both enable vt(4) to change
> >> modes/resolutions and using sc on UEFI computers.
> >>
> >
> > Ah, if only things were really that simple...  I tried variations on that
> > hack years ago when suspending broke due to video. And it
> > works for some machines, but not others, was the quick assessment
> > I made. And the INT xx interface is unavailable on amd64 after we
> > enter long mode (I tried this out on my then-current FreeBSD laptop
> > which was 32 bit only, so 15 years ago?).
> >
> > Warner
> >
> >
> >> But I think you are right, there are probably not too many users who
> >> would make use of that.
> >>
> >>
> >> On 1/4/22, Warner Losh <imp@bsdimp.com> wrote:
> >> > On Mon, Jan 3, 2022, 11:03 PM Stefan Blachmann <sblachmann@gmail.com>
> >> > wrote:
> >> >
> >> >> Implementing S3 suspend/resume was a sponsored project itself.
> >> >> However, it still does only work when at xorg graphics mode, which
> >> >> already was topic in this thread.
> >> >> When using it from console, no matter sc or vt, it still hangs with
> >> >> dark screen and unresponsive keyboard.
> >> >> Could finishing the suspend/resume work be sponsored, so that it also
> >> >> works on console-only computers?
> >> >>
> >> >
> >> > Not without loading the xorg graphics stuff... graphics chips from the
> >> last
> >> > 15 or 20 years have lots of chip specific state that only the graphics
> >> > stuff knows about... IIRC, it only knows about it because it put the
> >> > graphics into a known state... it's the main reason laptops stopped
> >> > suspending in the early 2000s... it looks to be a lot of work for a
> >> > relatively rare use case...
> >> >
> >> > Warner
> >> >
> >> >
> >> >> On 12/30/21, Joseph Mingrone <jrm@freebsd.org> wrote:
> >> >> > On Thu, 2021-12-30 at 14:15, Joseph Mingrone <jrm@FreeBSD.org>
> >> >> > wrote:
> >> >> >
> >> >> >> On Thu, 2021-12-30 at 08:05, $B".(Bzkan KIRIK <ozkan.kirik@gmail.com>
> >> >> >> wrote:
> >> >> >>> I've ideas about enhancing the routing architecture. Is it
> >> >> >>> possible
> >> >> >>> to
> >> >> >>> add to wiki?
> >> >> >
> >> >> >> Certainly.  Please do.
> >> >> >
> >> >> > The link again is https://wiki.freebsd.org/2021FoundationCFI
> >> >> >
> >> >>
> >> >>
> >> >
> >>
> >
> 
> 


-- 
Tomoaki AOKI    <junchoon@dec.sakura.ne.jp>