|
CMHG documentation failure |
|
ksattic (06:05 13/7/2007) Phlamethrower (07:12 13/7/2007) ksattic (15:26 13/7/2007) adrianl (16:39 13/7/2007) ksattic (17:01 13/7/2007) adrianl (17:20 13/7/2007) ksattic (17:48 13/7/2007) adrianl (17:54 13/7/2007) ksattic (18:06 13/7/2007) adrianl (20:34 13/7/2007) ksattic (22:05 13/7/2007) ksattic (06:47 14/7/2007) adrianl (19:12 14/7/2007) ksattic (19:18 15/7/2007) Phlamethrower (19:37 15/7/2007) ksattic (21:46 15/7/2007) Phlamethrower (22:01 15/7/2007) adrianl (22:25 15/7/2007) Phlamethrower (22:41 15/7/2007)
|
|
Simon Wilson |
Message #103483, posted by ksattic at 06:05, 13/7/2007 |
Finally, an avatar!
Posts: 1291
|
Reading the "CMunge" doc inside !gcc has left me a bit confused.
How do I specify a vector handler for a PCI interrupt line? The doc says:
* vector-handlers: <C-function-name>[/<C-function-name>][(<params>)] ...
Several pairs of function names can be given here; each corresponds to an entry point into the module (to be used for OS_Claim or similar) and the name of the C function that that entry point calls. If you omit the '/' and the second half of the pair, then that name is constructed by adding '_handler' on to the end of the first name. [snip blah] So, for 'vector-handlers: irq1' the following function is expected:
int wrch_handler(_kernel_swi_regs *r, void *pw); Eh?
According to the text, if the first of the pair is "irq1", then the C function should be called "irq1_handler". Where did wrch come from?
I thought all I needed to do was tell CMHG that my function is an ISR so it doesn't generate the usual prologue and epilogue for the function, and then I pass the address of that into OS_ClaimDeviceVector (R1). |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #103484, posted by Phlamethrower at 07:12, 13/7/2007, in reply to message #103483 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
It's a mistake.
If you specify 'vector-handlers: irq1' then you'll need to write the irq1_handler(...) function, and use 'irq1' as the function address to pass to OS_ClaimDeviceVector. |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103491, posted by ksattic at 15:26, 13/7/2007, in reply to message #103484 |
Finally, an avatar!
Posts: 1291
|
OK, makes sense now.
Now my module stiffs the machine just by claiming the vector, even though I return 1 to pass it on, as specified here:
http://www.iyonix.com/32bit/PCI_API.shtml |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103495, posted by adrianl at 16:39, 13/7/2007, in reply to message #103491 |
Member
Posts: 1637
|
OK, makes sense now.
Now my module stiffs the machine just by claiming the vector, even though I return 1 to pass it on, as specified here:
Er, you are performing the necessary action(s) to clear all pending interrupts on your device? Also, when you do the 'clear interrupt' write(s), you must read back from the same locations (and dump the read data if you want), to ensure that the write has actually crossed the PCI bridges and caused the device to deassert its interrupt line before you return from your interrupt handler. |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103496, posted by ksattic at 17:01, 13/7/2007, in reply to message #103495 |
Finally, an avatar!
Posts: 1291
|
Er, you are performing the necessary action(s) to clear all pending interrupts on your device? Nope - since the device is definitely not interrupting. That's why I was surprised that my lowly module that called OS_ClaimDeviceVector managed to stiff the machine.
Have I missed something? |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103497, posted by adrianl at 17:20, 13/7/2007, in reply to message #103496 |
Member
Posts: 1637
|
Have I missed something? If you're right that it's not generating interrupts, then undoubtedly. Unfortunately I can't tell you what, having never generated an IRQ handler using CMHG/CMunge. If you want to upload the binary somewhere I'll work out what's wrong.
Edit: Oh, you are passing your module's private word (as passed to your CMHG-generated module init function) as the workspace pointer to xos_claim_device_vector, right?
[Edited by adrianl at 18:21, 13/7/2007] |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103498, posted by ksattic at 17:48, 13/7/2007, in reply to message #103497 |
Finally, an avatar!
Posts: 1291
|
Edit: Oh, you are passing your module's private word (as passed to your CMHG-generated module init function) as the workspace pointer to xos_claim_device_vector, right? If you mean in R1, then yes. |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103499, posted by adrianl at 17:54, 13/7/2007, in reply to message #103498 |
Member
Posts: 1637
|
If you mean in R1, then yes. R2 ? The CMHG veneers need to be able to locate the module's workspace (via R12) so that they can set up the stack-based ugliness for accessing global data etc. |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103501, posted by ksattic at 18:06, 13/7/2007, in reply to message #103499 |
Finally, an avatar!
Posts: 1291
|
OK, then I am missing something.
The StrongHelp OS manual page for OS_ClaimDeviceVector makes no mention of the need to do this, though I do see that the value in R2 gets passed to the "device driver" via R12. The CMunge manual supplied with gcc also makes no mention of this.
Thanks for the help - I can probably ask people on the gccsdk mailing list about the missing documentation. |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103504, posted by adrianl at 20:34, 13/7/2007, in reply to message #103501 |
Member
Posts: 1637
|
I thought you might have made a typo, hence 'R2?'.... R1 = address of interrupt handling routine within device driver, R2 = value passed to interrupt handling routine in R12.... CMHG/CMunge veneers typically (always?) require that the value in R12 is the pointer that was passed to your module_init function and it's used to locate the module's workspace. |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103505, posted by ksattic at 22:05, 13/7/2007, in reply to message #103504 |
Finally, an avatar!
Posts: 1291
|
I thought you might have made a typo, hence 'R2?'.... R1 = address of interrupt handling routine within device driver, R2 = value passed to interrupt handling routine in R12.... CMHG/CMunge veneers typically (always?) require that the value in R12 is the pointer that was passed to your module_init function and it's used to locate the module's workspace. OK, I passed the pw (private word) pointer from module_init to OS_ClaimDeviceVector, but now the module causes an internal error upon loading. |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103506, posted by ksattic at 06:47, 14/7/2007, in reply to message #103505 |
Finally, an avatar!
Posts: 1291
|
After much playing around with code, I think I have figured it out. It seems to work without hanging the devices that share the same line.
Is it possible for two interrupts to be asserted on the same line at the same time from two PCI cards? If so, is there any way to know, and pass on the message to other claimants?
Edit: sometimes after rmkilling my module, ektest 0 fails the interrupt test - it is sharing the same line. The computer never freezes. Running and killing my module allows the ektest to pass. When rmkilling, I call OS_ReleaseDeviceVector. Isn't this the right thing to do?
[Edited by ksattic at 07:55, 14/7/2007] |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103511, posted by adrianl at 19:12, 14/7/2007, in reply to message #103506 |
Member
Posts: 1637
|
Did you provide exactly the same register values to OS_ReleaseDeviceVector as you did for OS_ClaimDeviceVector? And did you check for an error being returned? Perhaps your interrupt handler was never deregistered but your module went ahead and quit anyway? |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103524, posted by ksattic at 19:18, 15/7/2007, in reply to message #103511 |
Finally, an avatar!
Posts: 1291
|
Yes, the values are the same.
The module is very unstable, freezing the machine at seemingly random intervals. I noticed that R3 is being used during the ISR - surely this is a bad thing, but I don't know how to prevent gcc from doing so. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #103525, posted by Phlamethrower at 19:37, 15/7/2007, in reply to message #103524 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
I noticed that R3 is being used during the ISR - surely this is a bad thing, but I don't know how to prevent gcc from doing so. In that case it's probably a bug in CMunge.
[edit]
Is it possible to poke the module a bit in StrongED to make it save R3 onto the stack with everything else? That would be a quick way of testing if that's what's causing all the problems.
[Edited by Phlamethrower at 20:38, 15/7/2007] |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #103526, posted by ksattic at 21:46, 15/7/2007, in reply to message #103525 |
Finally, an avatar!
Posts: 1291
|
Nope, doesn't help. I also saved R0 on the stack because that's what the StrongHelp manual says to do.
I also found another error in the CMunge (cmhg) manual which I reported to the gccsdk list - the VECTOR_CLAIM and VECTOR_PASSON symbols are undefined.
Is anyone using this other than me? |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #103528, posted by Phlamethrower at 22:01, 15/7/2007, in reply to message #103526 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Is anyone using this other than me? I've used CMunge a few times in the past, but never for device vectors. |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #103531, posted by adrianl at 22:25, 15/7/2007, in reply to message #103524 |
Member
Posts: 1637
|
The veneer that CMunge generates for OS_ClaimDeviceVector routines is allowed to corrupt R0-R3,R12 according to the PRM (1-126) |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #103532, posted by Phlamethrower at 22:41, 15/7/2007, in reply to message #103531 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
For RISC OS 3, yes. But not necessarily for 5.
http://www.iyonix.com/32bit/CDV.shtml http://www.iyonix.com/32bit/PCI_API.shtml#section-5. |
|
[ Log in to reply ] |
|
|