4

I am using a Linux x86_64 machine. Is it possible to write to the screen from my user space application (C or assembly) without using the standard library functions or system calls? I know this is possible in the real mode or in DOS with a pointer to the video memory 0XB800

Ruslan
  • 18,162
  • 8
  • 67
  • 136
Franc
  • 319
  • 9
  • 28
  • 8
    No, it's not possible. – Thomas Jager Jun 05 '20 at 15:09
  • 4
    You can make some system calls to map the framebuffer into your process's memory. https://en.wikipedia.org/wiki/Linux_framebuffer. There's probably a library wrapper to help set things up, but once that's done you can run plain store instructions to directly draw pixels into video RAM, I think. (Of course that only works if you program is running on a console; under X11 or Wayland it's a totally different interface (if it's possible at all) to memory-map a pixmap for a window. – Peter Cordes Jun 05 '20 at 15:20
  • 1
    DOS did not have a display manager running. All graphics was done by each program. The closest you can get with Xorg running is to create a full-screen window using calls to the display manager, then read and write to that window. – stark Jun 05 '20 at 16:03
  • @PeterCordes you can't mmap FB: see [_mmap /dev/fb0 fails with “Invalid argument”_](https://stackoverflow.com/q/22915778/673852) – Ruslan Jun 05 '20 at 17:18
  • @Ruslan: thanks, yeah it's been a while since I even ran anything other than an X server. I thought it was possible somehow but forgot which kernel API / driver let you map video memory. SVGAlib might be a good choice to hide the lowest-level setup details, if it lets you map VGA memory. – Peter Cordes Jun 05 '20 at 17:21
  • 1
    As Raymond Chen is fond of saying, imagine two programs would do that. – Seva Alekseyev Jun 05 '20 at 17:29
  • @SevaAlekseyev that's as easy as two programs `write`ing to `/dev/fb0`. The resolution is exactly the same (failure to open an already open device, I suppose; didn't check actual behavior). – Ruslan Jun 05 '20 at 17:38
  • 1
    I meant as desired by the OP, *sans* kernel's involvement. – Seva Alekseyev Jun 10 '20 at 12:24

0 Answers0