Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include <l4io.h>
  2. #include <l4/sigma0.h>
  3. #include <l4/ia32/arch.h>
  4.  
  5. void set_port(unsigned int port_address, unsigned char index, unsigned char value)
  6. {
  7.     unsigned int port_register = port_address;
  8.     if(port_address!=0x3C0)
  9.         port_register = port_address+1;
  10.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (index), "d" (port_address));
  11.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (value), "d" (port_register));
  12.        
  13. }
  14.  
  15. int main(int argc, char** argv)
  16. {
  17.     //definitions
  18.     L4_Fpage_t VGA;
  19.     volatile L4_Word_t* pixels;
  20.    
  21.     __asm__ __volatile__ ("in %%dx, %%al" :: "a" (0x3DA));
  22.     set_port(0x3C0, 0x00, 0x41);
  23.     set_port(0x3C0, 0x01, 0x00);
  24.     set_port(0x3C0, 0x02, 0x0F);
  25.     set_port(0x3C0, 0x03, 0x00);
  26.     set_port(0x3C0, 0x04, 0x00);
  27.     set_port(0x3C0, 0x20, 0x00);
  28.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (0x63), "d" (0x3C2));
  29.     set_port(0x3C4, 0x01, 0x01);
  30.     set_port(0x3C4, 0x02, 0x01);
  31.     set_port(0x3C4, 0x03, 0x00);
  32.     set_port(0x3C4, 0x04, 0x0E);
  33.     set_port(0x3CE, 0x05, 0x40);
  34.     set_port(0x3CE, 0x06, 0x05);
  35.     set_port(0x3D4, 0x00, 0x5F);
  36.     set_port(0x3D4, 0x01, 0x4F);
  37.     set_port(0x3D4, 0x02, 0x50);
  38.     set_port(0x3D4, 0x03, 0x82);
  39.     set_port(0x3D4, 0x04, 0x54);
  40.     set_port(0x3D4, 0x05, 0x80);
  41.     set_port(0x3D4, 0x06, 0xBF);
  42.     set_port(0x3D4, 0x07, 0x1F);
  43.     set_port(0x3D4, 0x08, 0x00);
  44.     set_port(0x3D4, 0x09, 0x41);
  45.     set_port(0x3D4, 0x10, 0x9C);
  46.     set_port(0x3D4, 0x11, 0x8E);
  47.     set_port(0x3D4, 0x12, 0x8F);
  48.     set_port(0x3D4, 0x13, 0x28);
  49.     set_port(0x3D4, 0x14, 0x40);
  50.     set_port(0x3D4, 0x15, 0x96);
  51.     set_port(0x3D4, 0x16, 0xB9);
  52.     set_port(0x3D4, 0x17, 0xA3);
  53.    
  54.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (0xFF), "d" (0x3C6));
  55.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (0x00), "d" (0x3C8));
  56.     __asm__ __volatile__ ("out %%al, %%dx" :: "a" (0xFF), "d" (0x3C9));
  57.    
  58.     //aquire the VGA address space
  59.     VGA = L4_Fpage(0xA0000, 64);
  60.     L4_Sigma0_GetPage(L4_nilthread, VGA);
  61.    
  62.     //setup is now complete drawing will commence
  63.     pixels=(L4_Word_t*)0xA0000;
  64.     for(int i=0; i<64999; i++)
  65.     {
  66.         pixels++;
  67.         *pixels=(L4_Word_t)0x00;
  68.     }
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement