lkml.org 
[lkml]   [2005]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Screen regen buffer at 0x00b8000
On Fri, 20 May 2005, Richard B. Johnson wrote:

> Why can't I consistantly write to the VGA screen regen buffer
> and have it appear on the screen????

I wrote the following little program and understood the effect you are
seeing...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <sys/mman.h>


#define SCREEN 0x000b8000
#define ATTRIB 0x1700

int main (int argc, char **argv) {
int fd;
void *va;
size_t page_size = getpagesize();
unsigned short c = ATTRIB | '0';
int i;
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (!fd) {
perror("open");
exit(1);
}
va = mmap(0, page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, SCREEN);
if (va == (void *) -1) {
perror ("mmap");
exit(1);
}
/* first column of second line of the hardware buffer */
va += 160;
/* printing ascii '0' to '9' */
for (i = 0; i < 10; i++) {
*((unsigned short *) va) = c;
c += 1;
sleep(1);
}
return 0;
}

Do you remember that the linux console uses hardware buffers for
its scrolling capabilities (shift-pgup and shift-pgdown)?

When you hit enter to run your program the display line you are
addressing in your program has gone off by one so it is out of visual.

To see your line you must go to the begginning of the buffer in the
console (shift-pgup until at the top) since you write to the first
line in the hardware buffer.

Hope this helps

-marco
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-05-20 18:39    [from the cache]
©2003-2011 Jasper Spaans