src/kernel/trap/trap.c
/*!
 * @note register a trap handler to trap system
 * @warning there is not a lock to ensuring
 *         the safety of critical section.
 * @param cpu_id : must check if is valid by caller.
 * @param number
 * @param is_irq : if the trap is irq
 * @param func : trap handler
 * @return register executing status
 */
@note register a trap handler to trap system
@warning there is not a lock to ensuring
the safety of critical section.
@param cpu_id : must check if is valid by caller.
@param number
@param is_irq : if the trap is irq
@param func : trap handler
@return register executing status
@note register a trap handler to trap system @warning there is not a lock to ensuring the safety of critical section . @param cpu_id : must check if is valid by caller . @param number @param is_irq : if the trap is irq @param func : trap handler @return register executing status
int trap_register(int cpu_id, int number, bool is_irq ,trap_func_t func){
    if(number<0){
        return 1;
    }
    if(is_irq){
        if(number>=PLATFORM_S_MAX_IRQ_NO){
            return -1;
        }
        trap_irq_table[cpu_id][number] = func;
    }
    else{
        if(number>=PLATFORM_S_MAX_EXC_NO){
            return -1;
        }
        trap_exc_table[cpu_id][number] = func;
    }
    return 1;
}
int trap_register ( int cpu_id , int number , bool is_irq , trap_func_t func ) { if ( number < 0 ) { return 1 ; } if ( is_irq ) { if ( number >= PLATFORM_S_MAX_IRQ_NO ) { return -1 ; } trap_irq_table [ cpu_id ] [ number ] = func ; } else { if ( number >= PLATFORM_S_MAX_EXC_NO ) { return -1 ; } trap_exc_table [ cpu_id ] [ number ] = func ; } return 1 ; }
@note register a trap handler to trap system
 @warning there is not a lock to ensuring
         the safety of critical section.
@note register a trap handler to trap system @warning there is not a lock to ensuring the safety of critical section .