Earlier quoted context omitted.
If you're on UEFI, the 16bit environment is very likely running inside a UEFI "hypervisor" (ie, it puts the CPU into 16bit mode after setting up the appropriate interrupt handlers and hardware drivers). If you boot Windows or Linux via UEFI and not BIOS methods, then you never leave 64bit mode during boot. Real BIOS that boots from 16bit is quite a rarity these days.
Does UEFI start the same way as BIOS (firmware on LPC bus, PC starts at 0xFFFFFFF0)? Or is there a different top level mechanism? My understanding was that the CPU still starts in 16 bit real mode (with an evil hack to sign-extend IP) but that by the time UEFI hands off to code on a hard drive it is in long mode.
Let’s write a Kernel with keyboard and screen support (2014)
31–40 of 40 posts
Re: Let’s write a Kernel with keyboard and screen support (2014)
#32Looks very accessible :)
Re: Let’s write a Kernel with keyboard and screen support (2014)
#33If anyone wants to breach into kernel development, I recommend osdev[0], which is a very good resources for beginners and others. 0: https://wiki.osdev.org/Main_Page
The forums are also excellent. They are a little bit like the Arch Linux forums: People can be a bit snarky, but pretty much everyone is extremely smart and pretty helpful. Noobs are tolerated if they are willing to put in some effort.
Sounds enticing!
Re: Let’s write a Kernel with keyboard and screen support (2014)
#34Earlier quoted context omitted.
grub is pretty bloated but also reliable. Finding the kernel is not as easy as it used to be. You need to read the partition table on the disk. You need to be able to understand the filesystem that the kernel is stored on. This adds a fair bit of complexity.
On a modern UEFI system you actually get provided with an API that can do all that for you, though only FAT32 partitions are supported for the FS out of the box (you can load your own drivers for more). If your boot partition is FAT32, UEFI makes things much much simpler.
Re: Let’s write a Kernel with keyboard and screen support (2014)
#35This is making me wonder: Thinking about Dan Luu's research on latency of modern systems ( https://danluu.com/input-lag/ ), what is the minimum latency one could get in a modern system (e.g, USB keyboard, modern display hardware)?
Re: Let’s write a Kernel with keyboard and screen support (2014)
#36For further reading, I can't recommend enough this free book: http://pages.cs.wisc.edu/~remzi/OSTEP/ It's fantastically well-written, yet detailed without being overwhelming.
I just read one chapter, which I thought was OK. It felt more like a book on how the C programming language translates to operating system concepts, rather than a book about the operating system concepts themselves. For example, the chapter I read discusses malloc() and indicates that it allocates memory from the heap, but it doesn't mention sbrk().
The correct approach is to use mmap with the MAP_ANON flag (Which interestingly isn't doesn't seem to be fully documented in the Linux documentation...)
Re: Let’s write a Kernel with keyboard and screen support (2014)
#37This is making me wonder: Thinking about Dan Luu's research on latency of modern systems ( https://danluu.com/input-lag/ ), what is the minimum latency one could get in a modern system (e.g, USB keyboard, modern display hardware)?
Display refresh had never gotten much faster than 100hz or so, so that will be your limit. USB, even terrible implementations thereof, is much faster.
Re: Let’s write a Kernel with keyboard and screen support (2014)
#38Earlier quoted context omitted.
Process management is hard. And that's if you throw out all the important stuff like "I want to run my programs outside the kernel" and "It sure would be nice if programs didn't have to share address space". I recommend the OSDev wiki for a deeper dive but ultimately, implementing processes involves a lot of different moving pieces that need to work. The most basic process manager would be cooperative, otherwise you'…
If anyone wants to try this, on x86 getting a regular interrupt for preemptive multitasking is pretty easy, you can write an interrupt handler for the [real-time clock]( https://wiki.osdev.org/RTC ). This will work on any PC and takes about 15 lines of code to set up. Every 1ms, whatever's running will be paused and your scheduling code can run. Actually writing the scheduler is the hard part ;)
Re: Let’s write a Kernel with keyboard and screen support (2014)
#39Earlier quoted context omitted.
If you're on UEFI, the 16bit environment is very likely running inside a UEFI "hypervisor" (ie, it puts the CPU into 16bit mode after setting up the appropriate interrupt handlers and hardware drivers). If you boot Windows or Linux via UEFI and not BIOS methods, then you never leave 64bit mode during boot. Real BIOS that boots from 16bit is quite a rarity these days.
"Running inside a hypervisor" is not equivalent to the UEFI setting interrupt vectors to point to its own code. Not sure how UEFI's "Compatibility Service Module" works exactly but if it acts like the original BIOS did, it's just a chunk of code that can be called, either by a program or be set as the destination for interrupts. But there is no "VM exit" mechanism like there is in hypervisors. One thing a hypervisor…
Re: Let’s write a Kernel with keyboard and screen support (2014)
#40For further reading, I can't recommend enough this free book: http://pages.cs.wisc.edu/~remzi/OSTEP/ It's fantastically well-written, yet detailed without being overwhelming.
I just read one chapter, which I thought was OK. It felt more like a book on how the C programming language translates to operating system concepts, rather than a book about the operating system concepts themselves. For example, the chapter I read discusses malloc() and indicates that it allocates memory from the heap, but it doesn't mention sbrk().
Disclaimer: I'm definitely not an expert, I'm reading the book to learn.