Hi Matt,
TL;DR you can simply compile a VGA BIOS with GCC/Clang. You don't have to make the same mistakes as AMD and compile/interpret some byte code. Which, IMHO, would only make it harder to implement an open-source version.
On 05.06.19 02:38, Matt B wrote:
I'm not talking about replacing a blob that nobody understands with a technically different but equally incomprehensible one. It sounds like your interpretation is to simply copy all the individual routines to a new blob. (Some sort of strange Theseus' ship exercise?) But you don't develop an open-source replacement for any a piece of software by a copying several sequences of instructions from the original ELF file to another.
well, I'm afraid that is what many people do. Most of the AtomBIOS code will be like: write magic number A into magic register B. If you do that too in your code, it works. If you don't do it, it doesn't work. I fear, without an unreasonably huge effort, the open-source version won't get much more comprehensible. I don't think the AMD hardware is worth it when you can get documentation from many other vendors. Or maybe the time is better spend on convincing AMD to release documentation.
Presumably (one would hope) somewhere AMD has un-obfuscated (understandable) source code of some form that was compiled into the vgabios roms that are frequently used. I recognize that it would be a colossal pain to figure out how the chips work without documentation, but in order to go through that process, tooling would presumably be advantageous.
Afaik, the only development tooling anyone has right now is a disassembler. Nothing which can turn the source code one might try to write into a vgabios blob that could be loaded into a build of coreboot and tried out. This is important as the painful process typically works when replacing any proprietary code is [1]: a) try to write something that's a little bit correct b) build and flash c) test the result and make a few changes d) go back to step B until a little bit more functionality is understood, then go back to step A for more
For that to work it's a big help to have a compiler that can turn annotated, documented source code into the binary format that's stored in flash. That same compiler also sees use in builds once things are complete enough to start sharing source code. That's why I'm interested in the question of whether such a tooling is available.
Let's add some more background. AMD's VGA BIOS contains two code parts: 1. The AtomBIOS that is card/mainboard specific, compiled to some byte code. 2. An interpreter for the AtomBIOS byte code.
There are already open-source implementations of 2. So I guess what you are asking for is a compiler for the AtomBIOS. But I wonder why? A new, clean implementation wouldn't have to keep this weird structure. You can simply skip AtomBIOS byte code and write your VGA BIOS in C, Rust or whatever you prefer; use GCC or Clang to compile it.
Nico
[1] One example is the panfrost team's development of the panfrost GPU driver. They started by recording and replaying command streams to understand how things work, but to move beyond that they obviously had to start writing the skeleton of a driver in C.