Skip to contentSkip to conversation

How to Simulate hardware that counts scanlines?

Qemu-devel Steve Ellenoff 4 participants 4 messages Jul 27, 2006 – Jul 28, 2006

lore
Share & tools
lore
#0 lore raw

I'm working on some custom emulated hardware to integrate with qemu's full pc emulation ( i guess you could call it a new target, but really just some mods of the x86 )..
I am curious if there's a way I could simulate counting scanlines. Basically a small piece of the chipset I'm implementing has a register that increments on each scanline pass. Since other parts of the chipset setup the timing, it probably uses some kind of formula to determine when to count them, rather than any kind of mechanism that tells it a scanline just completed.. but I've no idea how the thing really works.. The guest os code is polling this register on a very fast interval, and when it detects a certain # of scanlines have been counted, it will swap it's display buffers, ie, it's waiting for the vblank, so it can have nice smooth animations.
What's the best way to approximate this using qemu? Currently, I'm guessing at it, and the animations are choppy.
FYI - this is not using VGA at all, it's all custom programmed via the chipset and the running code.
I'm not all that familiar with vga hardware, so I didn't really see anything like this in there. I'm not sure if it does anything like that or not, but if it does, I guess I didn't see it..
Hope someone has some good suggestions - Thanks!
-Steve

#1 lore raw

[Qemu-devel] Adding a device into Qemu ARM

Hi all,
I'm running Qemu ARM system and Debian Sarge on it.
I try to add a new device, for example a LED, into Qemu ARM system. And I think that I must do the following steps:
1. Make a file led.c which simulates this LED, edit the file vl.c and vl.h
2. In file integratorcp.c, function integratorcp_init(), I must register a MEMORY SPACE for this LED (as the PL011 UART at 0x16000000)
3. Write a character device driver; this device driver will function on the MEMORY SPACE of the LED device. And this device driver has a MAJOR NUMBER
4. Make a character device file with the corresponding MAJOR NUMBER: mknod /dev/my_LED c MAJOR_NUMBER 0
5. Write an application which opens the file /dev/my_LED and write on it (to communication with my LED on Linux)
OR: for example "echo -n a > /dev/my_LED" to communication with my LED on Linux

I find that some of you who added the devices into Qemu ARM system, but I don't sure the steps I think above is as you 've done or not? Please confirm it for me, thank a lot!

Furthermore, I have some questions on the steps above:
+ step 2: which interrupt I can register with the PIC? Or in my case, it must not?
+ step 2: which value of MEMORY SPACE I can register for this LED? Best regards,
Tieu

---------------------------------
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta.

#2 lore raw

Re: [Qemu-devel] Adding a device into Qemu ARM

Quoted 5 lines

Furthermore, I have some questions on the steps above:
+ step 2: which interrupt I can register with the PIC? Or in my case, it
must not?
+ step 2: which value of MEMORY SPACE I can register for this LED?

Anything that's not already being used. Same way you would if you were designing real hardware.

Paul

#3 lore raw
In reply to Steve Ellenoff
Quoted 4 lines · Steve Ellenoff

The guest os code is polling this register on a very fast interval, and when it detects a certain # of scanlines have been counted, it will swap it's display buffers, ie, it's waiting for the vblank, so it can have nice smooth animations.

Since this is all custom, I'd rather raise an interrupt when the DAC reaches the final portion of the frame buffer... This has to be better than polling.