Re: Kernel written in bytecode
Posted: Sun Jan 26, 2025 5:13 am
I’ve never been a big fan of censorship. If an idea is worth expressing then it’s worth discussing.
The Place to Start for Operating System Developers
http://f.osdev.org/
I’ve never been a big fan of censorship. If an idea is worth expressing then it’s worth discussing.
Sure, I just got the impression that you didn't think it was worth discussing.
It doesn't. Executable files (of any sort, ELF or PE) contain machine code and relocation information. The OS loader gets a chunk of memory and loads the ELF formatted image there, and then uses the relocation information to fixup the image so calls and references use the right addresses. You could also decide the OS image always is loaded at a fixed position, and let the linker locate your executable at that point, and then relocation is not necessary. Long mode images can also be built so they don't require relocation.
That's not how my OS works. I have a config file that contain which drivers should be part of the OS image (potentially with parameters), which services should be started and which apps. It's also possible to add environmental variables that drivers could use. I then run a tool (on Windows) to create the OS image, which is a single binary file. This binary file is then booted and the drivers are initialized in the order they are listed in the config file. I certainly don't want this to be done by an interpreter in the OS. I want full control of what is loaded and how it is configured.vlad9486 wrote: ↑Sun Jan 26, 2025 5:42 am Systemd unit files and kubernetes yaml configs tell an OS what needs to run in what order, what are interdependencies and what to do on crash/failure (restart policy). Cron does a similar job. Maybe you can add some more relevant examples of text or binary code/config that is OS related.
I suggest that we can think of the core of an OS as an interpreter of the language that can express all these things. In this way of thinking, the OS consists of three parts: the interpreter, a very compact (a few hundred lines) config, and a bunch of binary blobs containing machine code.
Seriously? Are you going to catch all my words? It does. In simplest case, without any relocations it contains the address where each page of the binary is mapped to the userspace. Before paging, this process was called loading.It doesn't.
Me too! That's why I propose the way of flexible control over it. You will have full control not only when you write the code, but also years after. If the hardware changes, you don't need to revisit your code. Another developer can do it by editing the config, written in a specially designed language, without having to recompile the kernel and dig into your code.I want full control of what is loaded and how it is configured.
That's why I don't like the idea of linking a huge kernel image. All my device drivers, including basic stuff like the scheduler, are linked as separate executable files, and I decide which to bring in by a configuration file, and not by recompiling the kernel or trying trying to figure out how to change the configuration in the target system. The kernel image only contains basic memory & exception handling, support for registering kernel and user entrypoints and patching code. I want to have configuration information in a single configuration file that doesn't need to be on the target system.vlad9486 wrote: ↑Sun Jan 26, 2025 7:46 am Me too! That's why I propose the way of flexible control over it. You will have full control not only when you write the code, but also years after. If the hardware changes, you don't need to revisit your code. Another developer can do it by editing the config, written in a specially designed language, without having to recompile the kernel and dig into your code.
I see, so the information is only available at build time. Does your kernel support dynamic loading of modules? Like insmod in Linux?rdos wrote: ↑Sun Jan 26, 2025 8:02 am That's why I don't like the idea of linking a huge kernel image. All my device drivers, including basic stuff like the scheduler, are linked as separate executable files, and I decide which to bring in by a configuration file, and not by recompiling the kernel or trying trying to figure out how to change the configuration in the target system. The kernel image only contains basic memory & exception handling, support for registering kernel and user entrypoints and patching code. I want to have configuration information in a single configuration file that doesn't need to be on the target system.
It doesn't need to since all modules are dynamic.
ACPI is not very useful on modern hardware. As long as you only have modern PCI devices, you don't need ACPI (or devicetree).
There's no standard PCI configuration access mechanism on RISC-V platforms the way there is on x86 PCs. You still need ACPI or devicetree to tell you how to access the PCI configuration space.
I doubt that is completely different between RISC-V platforms, and there problably is a common standard just like for PCs.Octocontrabass wrote: ↑Mon Jan 27, 2025 12:13 pmThere's no standard PCI configuration access mechanism on RISC-V platforms the way there is on x86 PCs. You still need ACPI or devicetree to tell you how to access the PCI configuration space.
All legacy device can be probed, so that is no reason to support ACPI. Actually, I don't have ACPI on PCs with legacy PIC, as it will typically not work properly there. The legacy hardware I support will probe the standard IO ports. After all, these legacy devices are much older than ACPI, so you cannot rely on ACPI to find them. At least not if you want to support older hardware.Octocontrabass wrote: ↑Mon Jan 27, 2025 12:13 pm Also, modern x86 PCs still have some non-PCI devices that can only be detected through ACPI.
It's not completely different, but it's different enough that you can't assume fixed addresses like you could with legacy PC hardware. You need either ACPI or devicetree.
Who said I was taking about legacy devices? Modern PCs have things like SPI and I2C buses that can't be probed, the only way to find devices on those buses is to use ACPI.
How old is "older"? ACPI has been pretty reliable for at least a decade now.
That's chipset related stuff. Some PCs also have GPIO, special serial ports with extended capabilities, or CAN controllers. However, I doubt it's better to use ACPI for this than to simply read the motherboard manual and write a driver for it. Which seems to be how Windows and Linux often handles this. Also, these things actually are PCI devices, as basically everything in modern chipsets build on PCI.Octocontrabass wrote: ↑Mon Jan 27, 2025 4:56 pmWho said I was taking about legacy devices? Modern PCs have things like SPI and I2C buses that can't be probed, the only way to find devices on those buses is to use ACPI.
That is not how I do it. I install a legacy driver because I know the legacy function exists and I want to use it. It's not some type of automatic probing. If the driver is not part of the OS image, the legacy device will not be probed.Octocontrabass wrote: ↑Mon Jan 27, 2025 4:56 pm But speaking of probing legacy devices, that's a bad idea on a modern PC. If the legacy device isn't there, something else might be, and that something else might misbehave. Intel Macs that lock up when probing the nonexistent keyboard controller are the most famous example, but I'm sure there are others.
A decade is nothing. I want to support the first 386SX from the late 1980s / early 1990s.Octocontrabass wrote: ↑Mon Jan 27, 2025 4:56 pmHow old is "older"? ACPI has been pretty reliable for at least a decade now.
Where are you finding motherboard manuals that include enough information to write drivers?
The I2C bus controller in my laptop is a PCI device. The I2C touchpad in my laptop is not a PCI device.
ACPI isn't perfect.rdos wrote: ↑Tue Jan 28, 2025 2:04 amThe problem here is that ACPI name spaces are not strictly enough defined, and different manufacturers use different names for the same devices. Some manufacturers will not add these devices to the ACPI name space at all since they also provide motherboard drivers for Windows, or rely on Windows drivers for specific PCI vendor/product combinations.
Me too, but I don't see why that would stop you from using ACPI on modern PCs.
It's a two step process. You indentify which chipset they use, and if it is Intel (but probably also for AMD), then you can find the chipset manual on their site.Octocontrabass wrote: ↑Tue Jan 28, 2025 2:05 pmWhere are you finding motherboard manuals that include enough information to write drivers?
The touchpad is probably an USB device, which means it's on top of XHCI, or some other USB controller, and USB controllers are always PCI devices.'Octocontrabass wrote: ↑Tue Jan 28, 2025 2:05 pmThe I2C bus controller in my laptop is a PCI device. The I2C touchpad in my laptop is not a PCI device.
I do, but if I started from scratch, I probably wouldn't.Octocontrabass wrote: ↑Tue Jan 28, 2025 2:05 pmMe too, but I don't see why that would stop you from using ACPI on modern PCs.
That works for the chipset, but what about the rest of the motherboard?
No, it's definitely an I2C device attached to one of the chipset's I2C controllers.
Can you explain why supporting a 386SX prevents you from supporting ACPI?