[752cd8f] | 1 | /* set_vector |
---|
| 2 | * |
---|
| 3 | * This routine installs an interrupt vector on the Force CPU-386. |
---|
| 4 | * |
---|
| 5 | * INPUT: |
---|
| 6 | * handler - interrupt handler entry point |
---|
| 7 | * vector - vector number |
---|
| 8 | * type - 0 indicates raw hardware connect |
---|
| 9 | * 1 indicates RTEMS interrupt connect |
---|
| 10 | * |
---|
| 11 | * RETURNS: |
---|
| 12 | * address of previous interrupt handler |
---|
| 13 | * |
---|
[60b791ad] | 14 | * COPYRIGHT (c) 1989-1998. |
---|
[752cd8f] | 15 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 16 | * Copyright assigned to U.S. Government, 1994. |
---|
[752cd8f] | 17 | * |
---|
[98e4ebf5] | 18 | * The license and distribution terms for this file may be |
---|
| 19 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 20 | * http://www.OARcorp.com/rtems/license.html. |
---|
[752cd8f] | 21 | * |
---|
| 22 | * $Id$ |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include <rtems.h> |
---|
| 26 | #include <bsp.h> |
---|
| 27 | |
---|
| 28 | i386_isr_entry set_vector( /* returns old vector */ |
---|
| 29 | rtems_isr_entry handler, /* isr routine */ |
---|
| 30 | rtems_vector_number vector, /* vector number */ |
---|
| 31 | int type /* RTEMS or RAW intr */ |
---|
| 32 | ) |
---|
| 33 | { |
---|
| 34 | i386_isr_entry previous_isr; |
---|
| 35 | i386_IDT_slot idt; |
---|
| 36 | |
---|
| 37 | if ( type ) |
---|
| 38 | rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr ); |
---|
| 39 | else { |
---|
| 40 | /* get the address of the old handler */ |
---|
| 41 | |
---|
| 42 | idt = Interrupt_descriptor_table[ vector ]; |
---|
| 43 | |
---|
| 44 | previous_isr = (i386_isr_entry) |
---|
| 45 | ((idt.offset_16_31 << 16) | idt.offset_0_15); |
---|
| 46 | |
---|
| 47 | /* build the IDT entry */ |
---|
| 48 | idt.offset_0_15 = ((rtems_unsigned32) handler) & 0xffff; |
---|
| 49 | idt.segment_selector = get_cs(); |
---|
| 50 | idt.reserved = 0x00; |
---|
| 51 | idt.p_dpl = 0x8e; /* present, ISR */ |
---|
| 52 | idt.offset_16_31 = ((rtems_unsigned32) handler) >> 16; |
---|
| 53 | |
---|
| 54 | /* install the IDT entry */ |
---|
| 55 | Interrupt_descriptor_table[ vector ] = idt; |
---|
| 56 | } |
---|
| 57 | return previous_isr; |
---|
| 58 | } |
---|
| 59 | |
---|