1

I am trying to mdevelop my own proof of concept operationg system. Just some basics. I just got into graphics with vbe. One problem I had was to get supported video modes. After intense research I found vbe get bios information (ax=4f00 int 10) and I implemented it as follows

This is real mode

    mov ax, 0
    mov es, ax
    mov ax, [vbe_info_structure]
    mov di, ax

    mov ax, 0x4f00

    int 0x10

    cmp ax, 0x004F
    jne notOK

and declared vbe_info structure as follows also in real mode

vbe_info_structure:
    .signature      db "VESA"   ; indicate support for VBE 2.0+
    .table_data:        resb 512-4  ; reserve space for the table below


I then passed its adress to my kernel as a parameter like this (32 BIT !!!)

mov eax, [vbe_info_structure]
    push eax

    call _kmain

and my simple kernel code is like this (32 BIT)


struct VbeInfoBlock {
   char VbeSignature[4];             // == "VESA"
   uint16_t VbeVersion;                 // == 0x0300 for VBE 3.0
   uint16_t OemStringPtr[2];            // isa vbeFarPtr
   uint8_t Capabilities[4];
   uint16_t VideoModePtr[2];         // isa vbeFarPtr
   uint16_t TotalMemory;             // as # of 64KB blocks
} __attribute__((packed));

int kmain(struct VbeInfoBlock *vbeinfo)
{


    init_idt();
    SetPITSpeed(100);

    init_DTCursor();

    printf(vbeinfo->VbeSignature[0]);

    while(1);
}

Excepted input from printf should be "V" but I get junk S and some ascii junk only 2 characters.

  • I think you need to understand the difference between getting the address of something (e.g. "`mov di, vbe_info_structure`") and getting the data at an address (e.g. "`mov di, [vbe_info_structure]`"). They are very different things (same as the difference between `x = myPointer;` and `x = *myPointer;` in C). Specifically (I think) your `mov ax, [vbe_info_structure]` will probably (depending on `DS`) load the characters `'VE'` (from the "VESA" signature in the structure) into `ax`, where you want to load the address of the structure into `AX` instead. – Brendan Oct 08 '19 at 15:45
  • @Brendan So do I change ```mov ax, [vbe_info_structure]``` to ```mov ax, vbe_info_structure``` – Gameplayer Xd Oct 08 '19 at 17:07
  • @Brendan It worked but I have another question how do we get video mode pointer. It is a list of 2 16 bit integers so I understand but I dont understand how to use it and I also couldnt get it one of the numbers return 1053 while the other returns 0? – Gameplayer Xd Oct 08 '19 at 17:45
  • From memory; I think that's a `segment:offset` pair, where you'd load the first 16 bit value into a normal register (e.g. `si`) and the second 16-bit value into a segment register (e.g. `es`) and then read the list using both (e.g. `es:si`). – Brendan Oct 08 '19 at 19:11
  • @Brendan Ok but I cannot use es si or any segment operator since I m using C. Can I copy memory from 0000:1053 which must be 0x1053 to an array and read it from there – Gameplayer Xd Oct 09 '19 at 08:45
  • If you're using C to generate 32-bit code, then you convert it into something compatible with C (e.g. maybe "`myPointer = segment << 4 + offset`" if there's no paging and segment registers have their base address set to zero). If you're using C to generate 16 bit code then you'll need to use compiler specific extensions (that may not exist) or inline assembly to access it where it is or copy it somewhere else. – Brendan Oct 09 '19 at 15:05

0 Answers0