I have always went by the understanding that no two interrupts could have the same priority wether in seperate INT controllers or same. You do raise an interesting point though. Below is the function I use to set the priority level of an interrupt. This function will try higher or lower priority level based on direction flag if the level being requested is already in use.
Code:
//**************************************************************************// char SetInterruptLevel(char Level, char Priority, char Direction, int InterruptVector)//// Paramaters,// char Level = interrupt request level, valid range 1 to 7// char Prioriry = priority of the interrupt request level, valid range 0 to 7// char Direction = TRUE-try higher level. FALSE-try lower interrupt request level// int InterruptVector = interrupt vector number, valid range 65 to 191//// Returns,// char = Mask of interrupt level or 0 if error occured//// This function will test to see if the requested interrupt level and// priority have already been used. If not in use the requested level// will be set for the InterruptVector. If the interrupt request level// is already in use higher or lower priority requests will be tried.// The next highest, lowest interrupt request level that is found will// be used. If no higher, lower priority levels are available then an// error will be returned. The returned Mask can be tested to check for// the actual interupt level used.//char SetInterruptLevel(char Level, char Priority, char Direction, int InterruptVector){ // Local variables int Index; // Combined Level and Priority register mask unsigned char Mask = 0; // Pointer to Interrupt Control Register block, IPSBAR must be defined volatile unsigned char *ICRn = (vuint8*)(&__IPSBAR[0xc40]); // Check Level for valid value if(Level < 1 || Level > 7) // Return with error return 0; // Check Priority for valid value if(Priority < 0 || Priority > 7) // Return with error return 0; // Adjust Interrupt, all user interrupts are above cpu exceptions InterruptVector -= 64; // Check to see which interrupt controller to use if(InterruptVector > 64) { // Use interrupt controller INTC1 ICRn = (vuint8*)(&__IPSBAR[0xd40]); // Adjust Interrupt InterruptVector -= 64; } // Check for valid interrupt vector if(InterruptVector < 7 || InterruptVector > 63) // Return with error return 0; // Setup level and priority mask Mask = Level; Mask <<= 3; Mask += Priority; // Check to see if this level and priority are in use already // If in use try higher priorty first, if priority fails then // try higher level. If all higher interrupt levels are in use // return error else return current interrupt level mask for(Index = 7; Index < 64; Index++) { if(ICRn[Index] == Mask) { // Try higher or lower interrupt level— if(Direction) { // Level used already try higher priority if(Priority < 7) { // Reset Index and check again Index = 6; // Increase Priority one level Priority++; // Setup level and priority mask Mask = Level; Mask <<= 3; Mask += Priority; }else{ // Reset Priority to lowest level Priority = 0; // Try a higher Level if(Level < 7) { // Increase Level Level++; // Reset Index and try again Index = 6; // Setup level and priority mask Mask = Level; Mask <<= 3; Mask += Priority; }else{ // Return with error return 0; } } }else{ // Level used already try lower priority if(Priority > 0) { // Reset Index and check again Index = 6; // Decrease Priority one level Priority--; // Setup level and priority mask Mask = Level; Mask <<= 3; Mask += Priority; }else{ // Reset Priority to highest level Priority = 7; // Try a lower Level if(Level > 1) { // Decrease Level Level--; // Reset Index and try again Index = 6; // Setup level and priority mask Mask = Level; Mask <<= 3; Mask += Priority; }else{ // Return with error return 0; } } } } } // Enter critical section, disable interrupts OS_ENTER_CRITICAL(); // Set interrupt level ICRn[InterruptVector] = Mask; // Exit critical section, enable interrupts OS_EXIT_CRITICAL(); // Return success (Mask) return Mask;}