Advertisement
Guest User

sahoaishfias

a guest
Nov 25th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. void *vg_init(unsigned short mode) {
  2. struct reg86u reg86;
  3. vbe_mode_info_t info;
  4. struct mem_range range;
  5. int r;
  6.  
  7. reg86.u.b.intno = 0x10;
  8. reg86.u.w.ax = 0x4F02;
  9. reg86.u.w.bx = 1 << 14 | mode;
  10.  
  11. if (sys_int86(&reg86) != OK) {
  12. printf("set_vbe_mode: sys_int86() failed \n");
  13. return NULL;
  14. }
  15.  
  16. vbe_get_mode_info(mode, &info);
  17. range.mr_base = info.PhysBasePtr;
  18. range.mr_limit = range.mr_base + info.XResolution * info.YResolution * info.BitsPerPixel;
  19.  
  20. if (OK != (r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &range)))
  21. panic("video_txt: sys_privctl (ADD_MEM) failed: %d\n", r);
  22. video_mem = vm_map_phys(SELF, (void *) range.mr_base, info.XResolution * info.YResolution * info.BitsPerPixel);
  23. h_res = info.XResolution;
  24. v_res = info.YResolution;
  25. bits_per_pixel = info.BitsPerPixel;
  26. printf("physical address: %x\n",info.PhysBasePtr);
  27. return NULL;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement