writing text to framebuffer doesn't work with bochs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gideond
Posts: 17
Joined: Wed Oct 23, 2013 9:02 am

writing text to framebuffer doesn't work with bochs

Post by gideond »

So I'm reading this book : littleosbookgithub.io

Their full os impl didn't work : https://github.com/helino/aenix on bochs for me, neither did running minix2. So I tried to do the simplest thing possible to make sure bochs is ok on my machine.

I compiled and installed from source, bochs 2.6.8. I can run "kernel" that sets EAX to 0xCAFEBABE.

I tried next to write to the framework the letter A at (0,0) with a green foreground and dark grey background. I tried several combinations, each look just weird and at the wrong place. (I looked up this for reference of what to write to memory : http://littleosbook.github.io/#the-framebuffer)

I've setup grub to boot an iso with my kernel which is just this:

global loader

Code: Select all

MAGIC_NUMBER equ 0x1BADB002
FLAGS        equ 0x0
CHECKSUM     equ -MAGIC_NUMBER

section .text:
align 4
    dd MAGIC_NUMBER
    dd FLAGS
    dd CHECKSUM

loader:
      mov eax, 0xCAFEBABE
      mov [0x000B8000], word 0x4AF0 # 'A' with white Fground and black bg -> at (0,0)
      mov [0x000B8010], word 0x4A28 #'A' with Green Fground and Darkgrey bg -> at (0,1)
.loop:
      jmp .loop

See screenshot for what happens. Both chars are the wrong character and at the wrong cell.

I'm on fedora 24. I wonder if the problem is bochs? I use x for it's display driver, the authors of littleosbook recommend using sdl which is a display library I cant' see to find for fedora. The aim really is to toy with aenix and get it to run on bochs but I first thought I'll just ascertain if everything is ok with bochs.
Attachments
Bochs output.
Bochs output.
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: writing text to framebuffer doesn't work with bochs

Post by Techel »

It's perfectly fine. Note x86 processors are little endian, the hex numbers have to be 0xF04A and 0x284A. The framebuffer is set up as 80x25 characters, so you should write to offset 25*2 in order to make it appear in the next row at (0, 1).
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: writing text to framebuffer doesn't work with bochs

Post by gerryg400 »

Code: Select all

      mov [0x000B8000], word 0x4AF0 # 'A' with white Fground and black bg -> at (0,0)
      mov [0x000B8010], word 0x4A28 #'A' with Green Fground and Darkgrey bg -> at (0,1)
The output looks correct. Note that the ascii for 'A' is 0x41. Note also that the character should be in the lower 8 bits while the attribute is in the upper. So to write an 'A' to the first cell you need something like this

Code: Select all

      mov [0x000B8000], word 0x0741 # 'A' with white Fground and black bg -> at (0,0)
Hmm, I just looked at that littleosbook. Lots of errors...
If a trainstation is where trains stop, what is a workstation ?
gideond
Posts: 17
Joined: Wed Oct 23, 2013 9:02 am

Re: writing text to framebuffer doesn't work with bochs

Post by gideond »

Hey thanks @Techel and @gerryg400

Maybe I'll just walk through the Bare bones osdev tutorial

I can't seem to find something from grounds up relevant for years now (a book/tutorial), especially since I was something that works on my x64 machine, I'll try out barebones 32bit then the 64 bit tutorial.

Any advice for where to go from there? The intel 386 manual? Or the mammoth 64 and IA-32 Architectures Software Developer Manual ?
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: writing text to framebuffer doesn't work with bochs

Post by SpyderTL »

It depends on what you want to achieve first. A good place to start is learning how to handle keyboard input, so that you can start creating a console with commands that you can execute.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply