Page 1 of 1
got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Mon Oct 06, 2008 9:34 am
by blackoil
Hi,
I got my S3 ViRGE GX/2 working. According to VGADOC4B, I need to read the port 0x9AE8 to check status , but system hangs. Does in/out operation lead to exception?
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Mon Oct 06, 2008 10:10 am
by Combuster
Ask the intel manuals
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Mon Oct 06, 2008 12:00 pm
by Brendan
Hi,
blackoil wrote:I got my S3 ViRGE GX/2 working. According to VGADOC4B, I need to read the port 0x9AE8 to check status , but system hangs. Does in/out operation lead to exception?
IN/OUT can directly cause an exception if CPL > IOPL (e.g. you're in user-mode), unless the I/O permission bitmap in the TSS allows it. If you're running at CPL=0 (in "kernel-mode") it can't happen.
IN/OUT can indirectly cause an exception, depending on the hardware you're messing with. For example, accidentally asking a PCI "bus mastering" card to transfer data to RAM might cause an exception (e.g. overwrite your kernel).
I/O port accesses could also (potentially) cause any sort of interrupt (SMI, NMI, IRQ 123, etc) but this isn't likely unless you're messing with the device's MSI (Message Signaled Interrupts) registers in PCI configuration space.
IMHO the most likely explanation (if CPL <= IOPL) is that the I/O port access doesn't cause the exception and something else does - a timer IRQ that happens to occur at about the same time, some inline assembly that doesn't tell the compiler that it modifies a register, some kernel code that messes up EFLAGS (sets IOPL to something unintended), etc.
If anything does cause an exception, then your exception handlers should tell you about it. If you're messing with a video device driver then this might be difficult to do - you may need to login via. serial to see anything if the video card is in an unusable state. In this case, if you don't want to use the serial port then (as a temporary hack) you might be able to use the PC speaker or turn the floppy motor on when an exception occurs (so at least you know an exception did occur). Another idea might be to setup dual monitors, so you can use one video card while you develop the device driver for the other video card.
Cheers,
Brendan
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Mon Oct 06, 2008 5:28 pm
by blackoil
That code runs in ring 0. I just got freezed, even the caplock led doesn't work after that.
I already made the hardware graphical cursor working, with inverted screen color.
I will continue to do more tests to figure out what's wrong.
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Mon Oct 06, 2008 6:36 pm
by blackoil
I think I figure out what's wrong. I tried to inportw(0x9AE8) in bootloader, it works fine. After switch videomode with VESA 2, the code make system crash, it should be the register read triggers some DMA operations that overwrite my kernel.
So without detailed hardware specification, don't know which register should be initialized,
it's difficult to go on.
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Tue Oct 07, 2008 2:47 am
by Brendan
Hi,
blackoil wrote:So without detailed hardware specification, don't know which register should be initialized,
it's difficult to go on.
A few ideas...
Do the VBE functions leave the "enhanced command registers" enabled? I'd assume that for compatibility purposes the VBE functions would leave the enhanced command registers disabled, so your I/O port read during boot would be ignored.
Does your driver enable access to the enhanced command registers? If it does, then your I/O port read wouldn't be ignored (and could behave entirely differently to the same I/O port read done during boot). If you don't enable access to the enhanced command registers, then you probably should if you're going to use them....
What would happen if the video card sent a "FIFO queue empty" IRQ (or any other IRQ) to your OS? Do you have an IRQ handler (just in case), or is the IDT entry "not present"?
If your video IRQ handler is present, what does it do? There's lots of ways to get PCI IRQ handling wrong...
What do your exception handlers actually do? Do they display information, or do a "cli; hlt", or...? Do you know that an exception definitely does occur, or does everything hang with no way to tell even what happened?
Note: It may be possible to trigger a blit from display memory to host memory using a write to I/O port 0x9AE8, but it should be impossible to start any kind of DMA transfer using a read from to I/O port 0x9AE8.
Cheers,
Brendan
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Tue Oct 07, 2008 5:06 am
by blackoil
Hi Brendan
I forgot to set 0x3D4 index 40h to enable enhanced registers in bootloader. I will try it later.
Ny IDT ends with secondary ATA handler, and incomplete, only 48 entries, maybe it send me a video interrupt that causes corruption.
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Thu Oct 09, 2008 5:35 am
by blackoil
I tried in bootloader, but still crash, once read port 0x9ae8
Code: Select all
mov dx,0x3d4
mov al,0x38
out dx,al
mov dx,0x3d5
mov al,0x48 ;0x48 to unlock
out dx,al
mov dx,0x3d4
mov al,0x39
out dx,al
mov dx,0x3d5
mov al,0xa5 ;0xa5 to unlock
out dx,al
mov dx,0x3d4
mov al,0x40
out dx,al
mov dx,0x3d5
in al,dx
or al,1 ;set bit0 to enable
out dx,al
mov dx,0x9ae8
in al,dx
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Thu Oct 09, 2008 9:28 am
by Combuster
I noticed before (with a mach64 chip) that VGADOC can have the ports wrong when dealing with PCI devices. I.e., VGADOC gives you a sparse register file while the PCI version has a flat register file. To check for that, you'll have to do PCI enumeration to see what ranges the card actually uses.
Secondly, the S3 doc does not mention the S3 Virge at all, are you sure its one of the chips mentioned and not a more recent chip with a different core?
Re: got crash, when access port 0x9AE8 (S3 HW 2D ACCEL)
Posted: Thu Oct 09, 2008 6:53 pm
by blackoil
Hi, combuster,
I never play with PCI yet, it takes time to code.
I do notice my virge gx is not listed in VGADOC4B. I think its 2d acceleration may be share the same design, so I try it. But It goes into a weird state, without any exception/interrupt.
I can set the hw gfx cursor with port 0x46-0x49.
Code: Select all
OutPortB(0x3D4,0x47); OutPortB(0x3D5,MouseX);
OutPortB(0x3D4,0x46); OutPortB(0x3D5,MouseX>>8);
OutPortB(0x3D4,0x49); OutPortB(0x3D5,MouseY);
OutPortB(0x3D4,0x48); OutPortB(0x3D5,MouseY>>8);