alexfru wrote:Thatguyme wrote:alexfru wrote:There’s no standard MIPS PC like x86 PC. It’s SoC/board/emulator-specific.
How does the kernel know where devices are then?
It depends. If device addresses are fixed, they can be hard-coded in the kernel/drivers. If the devices are attached to some flexible bus like PCI(e), I'd expect a standard discovery/enumeration procedure for that bus.
Now, just to clarify this point: what Alex said about MIPS is just as true about
any computer hardware, including the PC class x86 systems; the difference with those is that PCs are all designed to be backwards-compatible with existing PC software, and have certain features which have to present the a standardized set of hardware and firmware interfaces, most notably the BIOS (whether Legacy or UEFI).
The very fact that a general term (Basic Input/Output System) long predating the PC is now seen as specifically referring to the PC Legacy BIOS, to the point that many will argue that it is the only true meaning of the term, underscores this (though the fact that UEFI isn't
just a BIOS, and that a given UEFI implementation's internal BIOS is only really used by UEFI itself, does muddy the water a bit).
For all its faults and limitations, the PC Legacy BIOS, and specifically the fact that a clean-room re-implementation of it was possible and those making them withstood legal challenges (this was a big deal waaaay back in the mid-1980s), was more than anything the reason the PC class of systems succeeded - had IBM not lost control of the platform after Compaq's BIOS was ruled not to be infringing, the PC would probably be a historical footnote today. It is a unique aspect of the PC platform today that anyone with the funds and engineering team to do it can build a PC-compatible system, and set it up so that it can run Windows (and in most cases, any other PC OS) so long as they can modify an existing BIOS framework to talk to their specific hardware. There is a lot more to it than that, of course, but the BIOS, and the ability to re-implement it for a wide variety of x86-compatible CPUs and ISA/PCI/PCIe compatible bus configurations, was a major factor in the success of the platform. All of the existing standards for PC hardware and software built on this success.
The introduction of UEFI has expanded this a bit, as it isn't exclusively tied to the x86 and the common types of PC bus systems, but it is definitely heavily influenced by the PC BIOS. Since very few if any non-PC systems have implemented UEFI to date, it isn't really something you can expect to be present for a MIPS-based system.
Note that this also means that an x86-based system that
doesn't have a BIOS or UEFI as it's firmware (or has a memory bus or peripheral buses that are drastically different from those common on PCs) cannot run PC software, at least not out of the box. This was a fairly common issue in the early 1980s, especially with some of the not-quite-PC compatibles such as the DEC Rainbow (often nicknamed the "DREC Painbow" for it's poor build quality and lack of actual PC compatibility) and the Olivetti/AT&T 6300 (which was actually pretty good hardware, when looked at in a vacuum) which ran versions of MS-DOS, but which were partly or wholly incompatible with off-the-shelf IBM PC programs and peripherals. This sort of thing mostly vanished by around 1986 or so, because, seriously, why put up with something as awful as the x86 if you don't get the main benefit of doing it, namely the huge PC-DOS (or later, Windows) software library?
But the take-away here is that you need to have the appropriate documentation for the hardware and firmware when writing an OS (or indeed anything that interfaces with said subsystems). The difference is that with PC class systems, the hardware manufacturers all copy IBM (or, after 1987 or so, each other), and stick to doing things that won't break compatibility in a way that a driver update won't fix. The ability to assume that the hardware works in one way across hundreds of different brands and models, over a span of three-going-on-four decades, is something unique to PCs.