title: How to get VESA BIOS Information
body: <p>I'm following through the <a href="https://os.phil-opp.com/" rel="noreferrer">Phil-Opp Tutorials</a> about writing an OS in Rust, and, after playing around with it a little bit, I want to fiddle with displaying real graphics on the screen.</p>
  
  <p>I've figured out that I should probably start out by using the Linear Frame Buffer, with VESA. I found some tutorials on osdev.org <a href="https://wiki.osdev.org/User:Omarrx024/VESA_Tutorial" rel="noreferrer">here</a> and <a href="https://wiki.osdev.org/Getting_VBE_Mode_Info" rel="noreferrer">here</a>, but they keep on talking about "function codes" and <code>es:di</code>. The second link says this:</p>
  
  <blockquote>
    <p>FUNCTION: Get VESA BIOS information</p>
    
    <p>Function code: 0x4F00</p>
    
    <p>Description: Returns the VESA BIOS information, including manufacturer, supported modes, available video memory, etc... Input: AX = 0x4F00</p>
    
    <p>Input: ES:DI = Segment:Offset pointer to where to store VESA BIOS information structure.</p>
    
    <p>Output: AX = 0x004F on success, other values indicate that VESA BIOS is not supported.</p>
    
    <p>Anyway, the above function returns the following structure and stores it in ES:DI as they were on entry. On entry, ES:DI should contain a pointer to the following structure:</p>
    
    <p><code>vbe_info_structure:
        .signature      db "VBE2"   ; indicate support for VBE 2.0+
        .table_data:        resb 512-4  ; reserve space for the table below</code></p>
  </blockquote>
  
  <p>Though I've looked at some assembly language tutorials, I have no idea what a "function code" is. From what I understand, if I <code>mov ax, 0x4f00</code>, and create a structure like the one above, it will magically overwrite the structure, which I could then pass as a parameter to my Rust Code? How do I, or do I need to, set my <code>es:di</code>? (From researching, I thought that it was just automatically set on modern processors)</p>
  
  <p>Should I do all of this stuff in Inline Assembly instead? Should I just use UEFI and rewrite my kernel? I would love if you could give an example of how to access the vbe_info_structure in Rust code (I'm running in <code>long mode</code>).</p>
  
  <p>Here's my <code>boot.asm</code> file so far, but it doesn't work yet: <a href="https://gist.github.com/nebrelbug/5a0042d4de32f942bb72e71fe282bdd2" rel="noreferrer">https://gist.github.com/nebrelbug/5a0042d4de32f942bb72e71fe282bdd2</a>. Thanks!</p>