Live data from Hacker News

After 5 days, my OS doesn't crash when I press a key

jvns.ca

11–20 of 90 posts

Re: After 5 days, my OS doesn't crash when I press a key

#12

Would echoing the chracter on screen require a seperate video driver to mark the pixels that make up the character ? Considering how hard is to make the keyboard driver, wouldn't the video driver be many folds harder?

Text mode is super easy - you just set bytes in the correct memory location (0xb8000000 if I remember correctly). Writing an actual graphics driver is tricky - although there are some ways to get decent frame buffer modes (like VESA Bios Extentions), to do things really well requires thousands of lines of code before you can even get a pixel on the screen, and is different for every card. It may be a bit easier now -…

If I remember my go at writing an `OS` you can just ask the BIOS to print the string for you, until you switch to protected mode. Even then, you could jump between protected and real mode to use the BIOS and still get the full address space.

EDIT: Nevermind, that still required putting the string in a magic location.

Re: After 5 days, my OS doesn't crash when I press a key

#13
I enjoyed this. It brought back memories of bringing up BSD2.9 on the PDP 11/55t we had in the lab. That particular PDP 11 was pretty rare (it had some memory split features to improve performance for computational tasks) and poking around in the kernel to get to the point where init was started. Nothing quite like that thrill, a mixture of power, and 'oh crap this is going to be a lot of work'.

Re: After 5 days, my OS doesn't crash when I press a key

#14

Would echoing the chracter on screen require a seperate video driver to mark the pixels that make up the character ? Considering how hard is to make the keyboard driver, wouldn't the video driver be many folds harder?

Text mode is super easy - you just set bytes in the correct memory location (0xb8000000 if I remember correctly). Writing an actual graphics driver is tricky - although there are some ways to get decent frame buffer modes (like VESA Bios Extentions), to do things really well requires thousands of lines of code before you can even get a pixel on the screen, and is different for every card. It may be a bit easier now -…

0xB8000, to be precise. This is 16-bit 8086 legacy, where addresses were 20-bit and segmented.

The most fun mode was mode 0x13 from INT 0x10, with its fantastic 320x200 resolution and 256 colors. That one had the buffer at 0xA0000.

Re: After 5 days, my OS doesn't crash when I press a key

#16

I'm guessing that a lot of the difficulty comes from the fact he's creating an OS for a PC, which is a pretty quirky and inconsistent architecture.

The blog author is not a 'he' but a 'she.' Her name is mentioned through the article.

And I'm guessing that the difficulty comes from the fact that she's building a freaking operating system from scratch... ;)

Re: After 5 days, my OS doesn't crash when I press a key

#19
This brings back memories...

I remember fresh out of high school following a few tutorials and writing a basic kernel & code for my old Pentium MMX and reading through the intel developer manuals for the 386 processor , and all the complexity involved that was inherited from the 8086 & 286 processors. Was a fantastic learning exercise... though I would suggest against using Pascal as the implementation language.

Re: After 5 days, my OS doesn't crash when I press a key

#20
post #10
post #9

Earlier quoted context omitted.

> Writing an actual graphics driver is tricky Does that include things that are not in text mode, if I recall the name correctly? Sometimes I just want my tiniest netbook to display the normal 80x40 resolution but it keeps putting the characters in what I think is video mode

I'm not sure how it is implemented at the graphics card level, but the Linux kernel virtual console can be high-resolution. The "correct" thing to do here is set the console font to a larger one. If you are on a systemd-using distribution, see vconsole.conf(8). Now, you could force a lower resolution, but that causes jaggy text, as pixels will be stretched unevenly by the graphics card. This can be done with KMS, or…

Thanks for the tips.
Post reply on HN