On Sat, Dec 31, 2022 at 1:03 PM Paul Ruizendaal <pnr@planet.nl> wrote:


> On 31 Dec 2022, at 15:59, Dan Cross <crossd@gmail.com> wrote:
>
> On Fri, Dec 30, 2022 at 1:26 PM Paul Ruizendaal <pnr@planet.nl> wrote:
>> [snip]
>> It would seem that the next step for Unix in the area of boot, config and device drivers came with Sun’s OpenBoot in 1988 or so. This also appears to be the first appearance of device trees to describe the hardware to the bios and the kernel. Moreover, it would seem to me that OpenBoot is a spiritual ancestor of the modern Risc-V SBI specification. Maybe by 1988 the IO hardware had become sufficiently complex and/or diverse to warrant a break from tradition?
>>
>> Was there any other notable Unix work on better organising the boot process and the device drivers prior to OpenBoot?
>
> I think that BSD supported autoconfiguration on the VAX well before
> OpenBoot; the OpenBSD man page says it dates from 4.1 (1981) and was
> revamped in 4.4.

That is interesting. Are you referring to this:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/a/sys/conf
https://www.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/usr/man/man8/config.8

Or is auto configuration something else?

> SBI was/is an attempt to define a common interface to different
> devices using RISC-V CPUs, but it's growing wildly and tending more
> towards UEFI+ACPI than something like OpenBoot, which was much
> simpler.
>
> In general, the idea of a BIOS isn't terrible: provide an interface
> that decouples the OS and hardware. But in practice, no one has come
> up with a particularly good set of interfaces yet. Ironically,
> BSD-style autoconfig might have been the best yet.

When it comes to abstracting devices, it would seem to me that virtio has gotten quite some traction in the last decade.

Looking at both the systems of 40 years ago and the Risc-V SoC’s of last year, I could imagine something like:

- A simple SBI, like the Berkeley Boot Loader (BBL) without the proxy kernel & host interface
- Devices presented to the OS as virtio devices
- MMU abstraction somewhat similar in idea to that in SYSV/68 [1]

Let's not forget that the diversity of systems is 1000s of times greater than it was in the early days of Unix. There were just two busses (Unibus and QBUS) in pdp-11 unix. There were a limited number of peripherals that could live at a limited number of CSRs and compatibility requirements of other DEC OSes meant that most of the 3rd party cards were compatible with DEC gear, though there were exceptions. There was no hot plug, there was no need to hierarchically assign address pools for things like PCIe hot-plug. There was no USB. There were only a very limited number of keyboard and graphics configurations. VAXen increased the number, but not by a huge amount, at least in the early days before new busses were introduced).

As such, the unixes from the system III era simply didn't have any notion of this diversity. So trying to layer it in will be quite difficult. The SoC space has become huge, with memory being mapped in different locations, busses being different, etc.

There's been much nasty said about FDT and ACPI, but they do solve real problems: how to enumerate this diversity to the OS in a way that's sane and might not always be as simple as returning a specific number but that requires hardware access to answer even basic questions (because, say, the CPUs were wired this way or that and you have to read those wirings). Linux, even in Linuxboot environments, still uses ACPI, FDT and UEFI to get the job done, and the code there isn't horrific.

V7 unix for the PDP-11 shipped with maybe 25 drivers total for the whole system, and many of them were quite niche...
 
Together this might be a usable Unix BIOS that could have worked in the early 80’s. One could also think of it as a simple hypervisor for only one client. The remaining BBL functionality is not all that different from the content in mch.s on 16-bit Unix (e.g. floating point emulation for CPU’s that don’t have it in hardware). A virtio device is not all that different from the interface presented by e.g. PDP-11 ethernet devices (e.g. DELUA), the MMU abstraction was contemporary.

virtio solves a different problem, though: It's goal is to provide THE interface for mass storage, THE interface for networking, etc so that hypervisor clients can limit their drivers substantially and not have to deal with the thousands of drivers normally needed. ACPI/FDT just try to make the non-self-describing aspects of the hardware described. Which is a different target market (so that one can hook up the right driver of the thousands to choose from when the OS autoconfig's the devices by whatever means it does that, even Linux and System V have this concept, though with radically different code than the BSDs).
 
High end systems could have had device hardware that implemented the virtio interface directly, low end systems could use simpler hardware and use the BIOS to present this interface via software.

I'd worry that 'use the BIOS' bit here leads to the ugly UEFI/ACPI hybrid to be generic enough to describe everything.

Now, I don't disagree with the org chart args for why they are so large outside of linuxboot, but they do fill a vacuum that would otherwise exist.

Warner
 

[1] From mmu.h in the SYSV/68 source tree:

/*
        @(#)mmu.h       2.26
        This is the header file for the UNIX V/68 generic
        MMU interface. This provides the information that
        is used by the various routines that call:

        mmufork ()
        mmuexec ()
        mmuexit ()
        mmuread ()
        mmuwrite ()
        mmuattach ()
        mmudetach ()
        mmuregs ()
        mmualloc ()
        mmuinit ()
        mmuint ()

        The above routines and secondary routines called
        by them are contained in io/mmu1.c and io/mmu2.c.
*/