Conversation
The IOAPIC polarity for an interrupt pin is 0=High and 1=Low based on how the tool eventually makes the kernel system call, which casts the enum value to a word and then passes it to the kernel. The kernel then ors in the value passed at the corresponding bit position in the ioredtbl_state. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
|
I don't think it makes sense to add breaking changes for something that in the end is arbitrary, and is (hopefully) documented correctly. If anything (I seem to recall discussing polarity with @dreamliner787-9 at some point) it makes more sense to use a string, as in "polarity=high" or "polarity=rising" or combine them as "trigger=level_high" or some such). |
|
I don't think the current behaviour is really arbitrary, it's my understanding that atm if you write in the SDF "low" the kernel will in the end configure the polarity as high and vice-versa... |
|
@cazb2 I think you are right but when making a PR like this you should point to the actual kernel source code or documentation that backs up your argument. When I checked the manual it didn't make it clear what argument values relate to what actual polarity, so please point to source code and explain why the Microkit tool is doing the wrong thing. |
|
Yep nws I can update my description. |
Current: The microkit tool has an IOAPIC Polarity enum used to represent the polarity of an interrupt for x86 IOAPIC pins. The enum represents low triggered with 0 and high triggered with 1. The initializer will eventually make the system call defined in section 10.4.1.1 in the kernel manual. The kernel documentation (as pointed out previously does not consistently describe x86 and arm level(trigger)/polarity concepts the same way). Nonetheless the polarity value chosen in the syscall (0 or 1 only) is directly bitwise ORed into the IOAPIC ioredtbl_state data structure as well as the device register (see ioapic_map_pin_to_vector in ioapic.c). This bit in this register is defined by intel (i imagine this is standardised across x86 implementations ??) to be set when you want low polarity and not set when you want high polarity. However the microkit tool is directly passing the underlying enum value. This means when you set the polarity to be low in the SDF the system call actually sets the polarity high, and vice versa.
Fix: this commit swaps the value associated with each variant in the IOAPIC polarity enum, to fix the problem described above.