Subject: Re: X under netbsd/dreamcast
To: None <port-dreamcast@netbsd.org>
From: Yasushi Oshima <oshimaya@sc.starcat.ne.jp>
List: port-dreamcast
Date: 02/05/2003 21:06:17
Marcus Comstedt <marcus@mc.pp.se> wrote:
>> Do you have some simple example on how to mmap the framebuffer?
>
> IIRC, it was something along the lines of
>
> int fd;
> unsinged short *ptr;
> int gfx_mode = WSDISPLAYIO_MODE_MAPPED;
> int text_mode = WSDISPLAYIO_MODE_EMUL;
>
> /* Open the device */
> fd = open("/dev/ttyE0", O_RDWR);
>
> /* Switch to graphics mode */
> ioctl(fd, WSDISPLAYIO_SMODE, &gfx_mode);
>
> /* Map the framebuffer */
> ptr = mmap(NULL, 640*480*2, PROT_READ|PROT_WRITE, MAP_SHARED,
> fd, 0);
>
> /* Draw on screen using ptr...*/
>
> /* Go back to text mode (don't forget this!) */
> ioctl(fd, WSDISPLAYIO_SMODE, &text_mode);
>
Does this work fine under the current kernel?
I'm trying to access VRAM like this now, but it does not work
on my Dreamcast.
mmap(2) returned with an address (it is 0x20410000), however
the process became hangup when accessing this area.
unsigned short x;
if (ioctl(fd, WSDISPLAYIO_SMODE, &gfx_mode) < 0)
err(1,"ioctl");
ptr = mmap(NULL, 640*480*2, PROT_READ|PROT_WRITE, MAP_SHARED,
fd, 0);
if ( ptr == MAP_FAILED) {
ioctl(fd, WSDISPLAYIO_SMODE, &text_mode);
err(1,"mmap");
}
x = *ptr; /* <------ hangup here ------- */
ioctl ( fd, WSDISPLAYIO_SMODE, &text_mode);
print ("addr = %p\n", ptr);
print ("*addr = %x\n", x);
The CPU load of this process became about 100% by top(1).
| PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
| 835 root 64 0 144K 64K RUN 1:23 99.43% 97.95% pvrtest
When hit Ctrl-C, this process has terminated.
Console has been still graphics mode after terminating.
I use 1.6N kernel (cross built on NetBSD/i386 at Feb 4).
Does anybody know this?
Thanks.
--
Yasushi Oshima