Changeset da1bafb in mainline for kernel/arch/ia32


Ignore:
Timestamp:
2010-05-24T18:57:31Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
Location:
kernel/arch/ia32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/include/smp/apic.h

    r666f492 rda1bafb  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    3939#include <cpu.h>
    4040
    41 #define FIXED           (0<<0)
    42 #define LOPRI           (1<<0)
    43 
    44 #define APIC_ID_COUNT   16
     41#define FIXED  (0 << 0)
     42#define LOPRI  (1 << 0)
     43
     44#define APIC_ID_COUNT  16
    4545
    4646/* local APIC macros */
    47 #define IPI_INIT        0
    48 #define IPI_STARTUP     0
     47#define IPI_INIT     0
     48#define IPI_STARTUP  0
    4949
    5050/** Delivery modes. */
    51 #define DELMOD_FIXED    0x0
    52 #define DELMOD_LOWPRI   0x1
    53 #define DELMOD_SMI      0x2
     51#define DELMOD_FIXED    0x0
     52#define DELMOD_LOWPRI   0x1
     53#define DELMOD_SMI      0x2
    5454/* 0x3 reserved */
    55 #define DELMOD_NMI      0x4
    56 #define DELMOD_INIT     0x5
    57 #define DELMOD_STARTUP  0x6
    58 #define DELMOD_EXTINT   0x7
     55#define DELMOD_NMI      0x4
     56#define DELMOD_INIT     0x5
     57#define DELMOD_STARTUP  0x6
     58#define DELMOD_EXTINT   0x7
    5959
    6060/** Destination modes. */
    61 #define DESTMOD_PHYS    0x0
    62 #define DESTMOD_LOGIC   0x1
     61#define DESTMOD_PHYS   0x0
     62#define DESTMOD_LOGIC  0x1
    6363
    6464/** Trigger Modes. */
    65 #define TRIGMOD_EDGE    0x0
    66 #define TRIGMOD_LEVEL   0x1
     65#define TRIGMOD_EDGE   0x0
     66#define TRIGMOD_LEVEL  0x1
    6767
    6868/** Levels. */
    69 #define LEVEL_DEASSERT  0x0
    70 #define LEVEL_ASSERT    0x1
     69#define LEVEL_DEASSERT  0x0
     70#define LEVEL_ASSERT    0x1
    7171
    7272/** Destination Shorthands. */
    73 #define SHORTHAND_NONE          0x0
    74 #define SHORTHAND_SELF          0x1
    75 #define SHORTHAND_ALL_INCL      0x2
    76 #define SHORTHAND_ALL_EXCL      0x3
     73#define SHORTHAND_NONE      0x0
     74#define SHORTHAND_SELF      0x1
     75#define SHORTHAND_ALL_INCL  0x2
     76#define SHORTHAND_ALL_EXCL  0x3
    7777
    7878/** Interrupt Input Pin Polarities. */
    79 #define POLARITY_HIGH   0x0
    80 #define POLARITY_LOW    0x1
     79#define POLARITY_HIGH  0x0
     80#define POLARITY_LOW   0x1
    8181
    8282/** Divide Values. (Bit 2 is always 0) */
    83 #define DIVIDE_2        0x0
    84 #define DIVIDE_4        0x1
    85 #define DIVIDE_8        0x2
    86 #define DIVIDE_16       0x3
    87 #define DIVIDE_32       0x8
    88 #define DIVIDE_64       0x9
    89 #define DIVIDE_128      0xa
    90 #define DIVIDE_1        0xb
     83#define DIVIDE_2    0x0
     84#define DIVIDE_4    0x1
     85#define DIVIDE_8    0x2
     86#define DIVIDE_16   0x3
     87#define DIVIDE_32   0x8
     88#define DIVIDE_64   0x9
     89#define DIVIDE_128  0xa
     90#define DIVIDE_1    0xb
    9191
    9292/** Timer Modes. */
    93 #define TIMER_ONESHOT   0x0
    94 #define TIMER_PERIODIC  0x1
     93#define TIMER_ONESHOT   0x0
     94#define TIMER_PERIODIC  0x1
    9595
    9696/** Delivery status. */
    97 #define DELIVS_IDLE     0x0
    98 #define DELIVS_PENDING  0x1
     97#define DELIVS_IDLE     0x0
     98#define DELIVS_PENDING  0x1
    9999
    100100/** Destination masks. */
    101 #define DEST_ALL        0xff
     101#define DEST_ALL  0xff
    102102
    103103/** Dest format models. */
    104 #define MODEL_FLAT      0xf
    105 #define MODEL_CLUSTER   0x0
     104#define MODEL_FLAT     0xf
     105#define MODEL_CLUSTER  0x0
    106106
    107107/** Interrupt Command Register. */
    108 #define ICRlo           (0x300 / sizeof(uint32_t))
    109 #define ICRhi           (0x310 / sizeof(uint32_t))
     108#define ICRlo  (0x300 / sizeof(uint32_t))
     109#define ICRhi  (0x310 / sizeof(uint32_t))
     110
    110111typedef struct {
    111112        union {
    112113                uint32_t lo;
    113114                struct {
    114                         uint8_t vector;                 /**< Interrupt Vector. */
    115                         unsigned delmod : 3;            /**< Delivery Mode. */
    116                         unsigned destmod : 1;           /**< Destination Mode. */
    117                         unsigned delivs : 1;            /**< Delivery status (RO). */
    118                         unsigned : 1;                   /**< Reserved. */
    119                         unsigned level : 1;             /**< Level. */
    120                         unsigned trigger_mode : 1;      /**< Trigger Mode. */
    121                         unsigned : 2;                   /**< Reserved. */
    122                         unsigned shorthand : 2;         /**< Destination Shorthand. */
    123                         unsigned : 12;                  /**< Reserved. */
     115                        uint8_t vector;                 /**< Interrupt Vector. */
     116                        unsigned int delmod : 3;        /**< Delivery Mode. */
     117                        unsigned int destmod : 1;       /**< Destination Mode. */
     118                        unsigned int delivs : 1;        /**< Delivery status (RO). */
     119                        unsigned int : 1;               /**< Reserved. */
     120                        unsigned int level : 1;         /**< Level. */
     121                        unsigned int trigger_mode : 1;  /**< Trigger Mode. */
     122                        unsigned int : 2;               /**< Reserved. */
     123                        unsigned int shorthand : 2;     /**< Destination Shorthand. */
     124                        unsigned int : 12;              /**< Reserved. */
    124125                } __attribute__ ((packed));
    125126        };
     
    127128                uint32_t hi;
    128129                struct {
    129                         unsigned : 24;                  /**< Reserved. */
    130                         uint8_t dest;                   /**< Destination field. */
     130                        unsigned int : 24;  /**< Reserved. */
     131                        uint8_t dest;       /**< Destination field. */
    131132                } __attribute__ ((packed));
    132133        };
     
    134135
    135136/* End Of Interrupt. */
    136 #define EOI             (0x0b0 / sizeof(uint32_t))
     137#define EOI  (0x0b0 / sizeof(uint32_t))
    137138
    138139/** Error Status Register. */
    139 #define ESR             (0x280 / sizeof(uint32_t))
     140#define ESR  (0x280 / sizeof(uint32_t))
     141
    140142typedef union {
    141143        uint32_t value;
    142144        uint8_t err_bitmap;
    143145        struct {
    144                 unsigned send_checksum_error : 1;
    145                 unsigned receive_checksum_error : 1;
    146                 unsigned send_accept_error : 1;
    147                 unsigned receive_accept_error : 1;
    148                 unsigned : 1;
    149                 unsigned send_illegal_vector : 1;
    150                 unsigned received_illegal_vector : 1;
    151                 unsigned illegal_register_address : 1;
    152                 unsigned : 24;
     146                unsigned int send_checksum_error : 1;
     147                unsigned int receive_checksum_error : 1;
     148                unsigned int send_accept_error : 1;
     149                unsigned int receive_accept_error : 1;
     150                unsigned int : 1;
     151                unsigned int send_illegal_vector : 1;
     152                unsigned int received_illegal_vector : 1;
     153                unsigned int illegal_register_address : 1;
     154                unsigned int : 24;
    153155        } __attribute__ ((packed));
    154156} esr_t;
    155157
    156158/* Task Priority Register */
    157 #define TPR             (0x080 / sizeof(uint32_t))
    158 typedef union {
    159         uint32_t value;
    160         struct {
    161                 unsigned pri_sc : 4;            /**< Task Priority Sub-Class. */
    162                 unsigned pri : 4;               /**< Task Priority. */
     159#define TPR  (0x080 / sizeof(uint32_t))
     160
     161typedef union {
     162        uint32_t value;
     163        struct {
     164                unsigned int pri_sc : 4;  /**< Task Priority Sub-Class. */
     165                unsigned int pri : 4;     /**< Task Priority. */
    163166        } __attribute__ ((packed));
    164167} tpr_t;
    165168
    166169/** Spurious-Interrupt Vector Register. */
    167 #define SVR             (0x0f0 / sizeof(uint32_t))
    168 typedef union {
    169         uint32_t value;
    170         struct {
    171                 uint8_t vector;                 /**< Spurious Vector. */
    172                 unsigned lapic_enabled : 1;     /**< APIC Software Enable/Disable. */
    173                 unsigned focus_checking : 1;    /**< Focus Processor Checking. */
    174                 unsigned : 22;                  /**< Reserved. */
     170#define SVR  (0x0f0 / sizeof(uint32_t))
     171
     172typedef union {
     173        uint32_t value;
     174        struct {
     175                uint8_t vector;                   /**< Spurious Vector. */
     176                unsigned int lapic_enabled : 1;   /**< APIC Software Enable/Disable. */
     177                unsigned int focus_checking : 1;  /**< Focus Processor Checking. */
     178                unsigned int : 22;                /**< Reserved. */
    175179        } __attribute__ ((packed));
    176180} svr_t;
    177181
    178182/** Time Divide Configuration Register. */
    179 #define TDCR            (0x3e0 / sizeof(uint32_t))
    180 typedef union {
    181         uint32_t value;
    182         struct {
    183                 unsigned div_value : 4;         /**< Divide Value, bit 2 is always 0. */
    184                 unsigned : 28;                  /**< Reserved. */
     183#define TDCR  (0x3e0 / sizeof(uint32_t))
     184
     185typedef union {
     186        uint32_t value;
     187        struct {
     188                unsigned int div_value : 4;  /**< Divide Value, bit 2 is always 0. */
     189                unsigned int : 28;           /**< Reserved. */
    185190        } __attribute__ ((packed));
    186191} tdcr_t;
    187192
    188193/* Initial Count Register for Timer */
    189 #define ICRT            (0x380 / sizeof(uint32_t))
     194#define ICRT  (0x380 / sizeof(uint32_t))
    190195
    191196/* Current Count Register for Timer */
    192 #define CCRT            (0x390 / sizeof(uint32_t))
     197#define CCRT  (0x390 / sizeof(uint32_t))
    193198
    194199/** LVT Timer register. */
    195 #define LVT_Tm          (0x320 / sizeof(uint32_t))
    196 typedef union {
    197         uint32_t value;
    198         struct {
    199                 uint8_t vector;         /**< Local Timer Interrupt vector. */
    200                 unsigned : 4;           /**< Reserved. */
    201                 unsigned delivs : 1;    /**< Delivery status (RO). */
    202                 unsigned : 3;           /**< Reserved. */
    203                 unsigned masked : 1;    /**< Interrupt Mask. */
    204                 unsigned mode : 1;      /**< Timer Mode. */
    205                 unsigned : 14;          /**< Reserved. */
     200#define LVT_Tm  (0x320 / sizeof(uint32_t))
     201
     202typedef union {
     203        uint32_t value;
     204        struct {
     205                uint8_t vector;           /**< Local Timer Interrupt vector. */
     206                unsigned int : 4;         /**< Reserved. */
     207                unsigned int delivs : 1;  /**< Delivery status (RO). */
     208                unsigned int : 3;         /**< Reserved. */
     209                unsigned int masked : 1;  /**< Interrupt Mask. */
     210                unsigned int mode : 1;    /**< Timer Mode. */
     211                unsigned int : 14;        /**< Reserved. */
    206212        } __attribute__ ((packed));
    207213} lvt_tm_t;
    208214
    209215/** LVT LINT registers. */
    210 #define LVT_LINT0       (0x350 / sizeof(uint32_t))
    211 #define LVT_LINT1       (0x360 / sizeof(uint32_t))
    212 typedef union {
    213         uint32_t value;
    214         struct {
    215                 uint8_t vector;                 /**< LINT Interrupt vector. */
    216                 unsigned delmod : 3;            /**< Delivery Mode. */
    217                 unsigned : 1;                   /**< Reserved. */
    218                 unsigned delivs : 1;            /**< Delivery status (RO). */
    219                 unsigned intpol : 1;            /**< Interrupt Input Pin Polarity. */
    220                 unsigned irr : 1;               /**< Remote IRR (RO). */
    221                 unsigned trigger_mode : 1;      /**< Trigger Mode. */
    222                 unsigned masked : 1;            /**< Interrupt Mask. */
    223                 unsigned : 15;                  /**< Reserved. */
     216#define LVT_LINT0  (0x350 / sizeof(uint32_t))
     217#define LVT_LINT1  (0x360 / sizeof(uint32_t))
     218
     219typedef union {
     220        uint32_t value;
     221        struct {
     222                uint8_t vector;                 /**< LINT Interrupt vector. */
     223                unsigned int delmod : 3;        /**< Delivery Mode. */
     224                unsigned int : 1;               /**< Reserved. */
     225                unsigned int delivs : 1;        /**< Delivery status (RO). */
     226                unsigned int intpol : 1;        /**< Interrupt Input Pin Polarity. */
     227                unsigned int irr : 1;           /**< Remote IRR (RO). */
     228                unsigned int trigger_mode : 1;  /**< Trigger Mode. */
     229                unsigned int masked : 1;        /**< Interrupt Mask. */
     230                unsigned int : 15;              /**< Reserved. */
    224231        } __attribute__ ((packed));
    225232} lvt_lint_t;
    226233
    227234/** LVT Error register. */
    228 #define LVT_Err         (0x370 / sizeof(uint32_t))
    229 typedef union {
    230         uint32_t value;
    231         struct {
    232                 uint8_t vector;         /**< Local Timer Interrupt vector. */
    233                 unsigned : 4;           /**< Reserved. */
    234                 unsigned delivs : 1;    /**< Delivery status (RO). */
    235                 unsigned : 3;           /**< Reserved. */
    236                 unsigned masked : 1;    /**< Interrupt Mask. */
    237                 unsigned : 15;          /**< Reserved. */
     235#define LVT_Err  (0x370 / sizeof(uint32_t))
     236
     237typedef union {
     238        uint32_t value;
     239        struct {
     240                uint8_t vector;           /**< Local Timer Interrupt vector. */
     241                unsigned int : 4;         /**< Reserved. */
     242                unsigned int delivs : 1;  /**< Delivery status (RO). */
     243                unsigned int : 3;         /**< Reserved. */
     244                unsigned int masked : 1;  /**< Interrupt Mask. */
     245                unsigned int : 15;        /**< Reserved. */
    238246        } __attribute__ ((packed));
    239247} lvt_error_t;
    240248
    241249/** Local APIC ID Register. */
    242 #define L_APIC_ID       (0x020 / sizeof(uint32_t))
    243 typedef union {
    244         uint32_t value;
    245         struct {
    246                 unsigned : 24;          /**< Reserved. */
    247                 uint8_t apic_id;                /**< Local APIC ID. */
     250#define L_APIC_ID  (0x020 / sizeof(uint32_t))
     251
     252typedef union {
     253        uint32_t value;
     254        struct {
     255                unsigned int : 24;  /**< Reserved. */
     256                uint8_t apic_id;    /**< Local APIC ID. */
    248257        } __attribute__ ((packed));
    249258} l_apic_id_t;
    250259
    251260/** Local APIC Version Register */
    252 #define LAVR            (0x030 / sizeof(uint32_t))
    253 #define LAVR_Mask       0xff
    254 #define is_local_apic(x)        (((x) & LAVR_Mask & 0xf0) == 0x1)
    255 #define is_82489DX_apic(x)      ((((x) & LAVR_Mask & 0xf0) == 0x0))
    256 #define is_local_xapic(x)       (((x) & LAVR_Mask) == 0x14)
     261#define LAVR       (0x030 / sizeof(uint32_t))
     262#define LAVR_Mask  0xff
     263
     264#define is_local_apic(x)    (((x) & LAVR_Mask & 0xf0) == 0x1)
     265#define is_82489DX_apic(x)  ((((x) & LAVR_Mask & 0xf0) == 0x0))
     266#define is_local_xapic(x)   (((x) & LAVR_Mask) == 0x14)
    257267
    258268/** Logical Destination Register. */
    259 #define  LDR            (0x0d0 / sizeof(uint32_t))
    260 typedef union {
    261         uint32_t value;
    262         struct {
    263                 unsigned : 24;          /**< Reserved. */
    264                 uint8_t id;             /**< Logical APIC ID. */
     269#define  LDR  (0x0d0 / sizeof(uint32_t))
     270
     271typedef union {
     272        uint32_t value;
     273        struct {
     274                unsigned int : 24;  /**< Reserved. */
     275                uint8_t id;         /**< Logical APIC ID. */
    265276        } __attribute__ ((packed));
    266277} ldr_t;
    267278
    268279/** Destination Format Register. */
    269 #define DFR             (0x0e0 / sizeof(uint32_t))
    270 typedef union {
    271         uint32_t value;
    272         struct {
    273                 unsigned : 28;          /**< Reserved, all ones. */
    274                 unsigned model : 4;     /**< Model. */
     280#define DFR  (0x0e0 / sizeof(uint32_t))
     281
     282typedef union {
     283        uint32_t value;
     284        struct {
     285                unsigned int : 28;       /**< Reserved, all ones. */
     286                unsigned int model : 4;  /**< Model. */
    275287        } __attribute__ ((packed));
    276288} dfr_t;
    277289
    278290/* IO APIC */
    279 #define IOREGSEL        (0x00 / sizeof(uint32_t))
    280 #define IOWIN           (0x10 / sizeof(uint32_t))
    281 
    282 #define IOAPICID        0x00
    283 #define IOAPICVER       0x01
    284 #define IOAPICARB       0x02
    285 #define IOREDTBL        0x10
     291#define IOREGSEL  (0x00 / sizeof(uint32_t))
     292#define IOWIN     (0x10 / sizeof(uint32_t))
     293
     294#define IOAPICID   0x00
     295#define IOAPICVER  0x01
     296#define IOAPICARB  0x02
     297#define IOREDTBL   0x10
    286298
    287299/** I/O Register Select Register. */
     
    289301        uint32_t value;
    290302        struct {
    291                 uint8_t reg_addr;               /**< APIC Register Address. */
    292                 unsigned : 24;          /**< Reserved. */
     303                uint8_t reg_addr;   /**< APIC Register Address. */
     304                unsigned int : 24;  /**< Reserved. */
    293305        } __attribute__ ((packed));
    294306} io_regsel_t;
     
    299311                uint32_t lo;
    300312                struct {
    301                         uint8_t intvec;                 /**< Interrupt Vector. */
    302                         unsigned delmod : 3;            /**< Delivery Mode. */
    303                         unsigned destmod : 1;           /**< Destination mode. */
    304                         unsigned delivs : 1;            /**< Delivery status (RO). */
    305                         unsigned intpol : 1;            /**< Interrupt Input Pin Polarity. */
    306                         unsigned irr : 1;               /**< Remote IRR (RO). */
    307                         unsigned trigger_mode : 1;      /**< Trigger Mode. */
    308                         unsigned masked : 1;            /**< Interrupt Mask. */
    309                         unsigned : 15;                  /**< Reserved. */
     313                        uint8_t intvec;                 /**< Interrupt Vector. */
     314                        unsigned int delmod : 3;        /**< Delivery Mode. */
     315                        unsigned int destmod : 1;       /**< Destination mode. */
     316                        unsigned int delivs : 1;        /**< Delivery status (RO). */
     317                        unsigned int intpol : 1;        /**< Interrupt Input Pin Polarity. */
     318                        unsigned int irr : 1;           /**< Remote IRR (RO). */
     319                        unsigned int trigger_mode : 1;  /**< Trigger Mode. */
     320                        unsigned int masked : 1;        /**< Interrupt Mask. */
     321                        unsigned int : 15;              /**< Reserved. */
    310322                } __attribute__ ((packed));
    311323        };
     
    313325                uint32_t hi;
    314326                struct {
    315                         unsigned : 24;                  /**< Reserved. */
    316                         uint8_t dest : 8;                       /**< Destination Field. */
     327                        unsigned int : 24;  /**< Reserved. */
     328                        uint8_t dest : 8;   /**< Destination Field. */
    317329                } __attribute__ ((packed));
    318330        };
     
    325337        uint32_t value;
    326338        struct {
    327                 unsigned : 24;          /**< Reserved. */
    328                 unsigned apic_id : 4;   /**< IO APIC ID. */
    329                 unsigned : 4;           /**< Reserved. */
     339                unsigned int : 24;         /**< Reserved. */
     340                unsigned int apic_id : 4;  /**< IO APIC ID. */
     341                unsigned int : 4;          /**< Reserved. */
    330342        } __attribute__ ((packed));
    331343} io_apic_id_t;
     
    340352extern void l_apic_init(void);
    341353extern void l_apic_eoi(void);
    342 extern int l_apic_broadcast_custom_ipi(uint8_t vector);
    343 extern int l_apic_send_init_ipi(uint8_t apicid);
     354extern int l_apic_broadcast_custom_ipi(uint8_t);
     355extern int l_apic_send_init_ipi(uint8_t);
    344356extern void l_apic_debug(void);
    345357extern uint8_t l_apic_id(void);
    346358
    347 extern uint32_t io_apic_read(uint8_t address);
    348 extern void io_apic_write(uint8_t address , uint32_t x);
    349 extern void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t v, int flags);
    350 extern void io_apic_disable_irqs(uint16_t irqmask);
    351 extern void io_apic_enable_irqs(uint16_t irqmask);
     359extern uint32_t io_apic_read(uint8_t);
     360extern void io_apic_write(uint8_t, uint32_t);
     361extern void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t v, unsigned int);
     362extern void io_apic_disable_irqs(uint16_t);
     363extern void io_apic_enable_irqs(uint16_t);
    352364
    353365#endif
  • kernel/arch/ia32/src/ddi/ddi.c

    r666f492 rda1bafb  
    5050 * Interrupts are disabled and task is locked.
    5151 *
    52  * @param task Task.
     52 * @param task   Task.
    5353 * @param ioaddr Startign I/O space address.
    54  * @param size Size of the enabled I/O range.
     54 * @param size   Size of the enabled I/O range.
    5555 *
    5656 * @return 0 on success or an error code from errno.h.
     57 *
    5758 */
    5859int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    5960{
    60         size_t bits;
    61 
    62         bits = ioaddr + size;
     61        size_t bits = ioaddr + size;
    6362        if (bits > IO_PORTS)
    6463                return ENOENT;
    65 
     64       
    6665        if (task->arch.iomap.bits < bits) {
    67                 bitmap_t oldiomap;
    68                 uint8_t *newmap;
    69        
    7066                /*
    7167                 * The I/O permission bitmap is too small and needs to be grown.
    7268                 */
    7369               
    74                 newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
     70                uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
    7571                if (!newmap)
    7672                        return ENOMEM;
    7773               
     74                bitmap_t oldiomap;
    7875                bitmap_initialize(&oldiomap, task->arch.iomap.map,
    7976                    task->arch.iomap.bits);
    8077                bitmap_initialize(&task->arch.iomap, newmap, bits);
    81 
     78               
    8279                /*
    8380                 * Mark the new range inaccessible.
     
    8582                bitmap_set_range(&task->arch.iomap, oldiomap.bits,
    8683                    bits - oldiomap.bits);
    87 
     84               
    8885                /*
    8986                 * In case there really existed smaller iomap,
    9087                 * copy its contents and deallocate it.
    91                  */             
     88                 */
    9289                if (oldiomap.bits) {
    9390                        bitmap_copy(&task->arch.iomap, &oldiomap,
     
    9693                }
    9794        }
    98 
     95       
    9996        /*
    10097         * Enable the range and we are done.
    10198         */
    10299        bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t) size);
    103 
     100       
    104101        /*
    105102         * Increment I/O Permission bitmap generation counter.
    106103         */
    107104        task->arch.iomapver++;
    108 
     105       
    109106        return 0;
    110107}
     
    116113 *
    117114 * Interrupts must be disabled prior this call.
     115 *
    118116 */
    119117void io_perm_bitmap_install(void)
    120118{
    121         size_t bits;
    122         ptr_16_32_t cpugdtr;
    123         descriptor_t *gdt_p;
    124         size_t ver;
    125 
    126119        /* First, copy the I/O Permission Bitmap. */
    127         spinlock_lock(&TASK->lock);
    128         ver = TASK->arch.iomapver;
    129         if ((bits = TASK->arch.iomap.bits)) {
     120        irq_spinlock_lock(&TASK->lock, false);
     121        size_t ver = TASK->arch.iomapver;
     122        size_t bits = TASK->arch.iomap.bits;
     123        if (bits) {
     124                ASSERT(TASK->arch.iomap.map);
     125               
    130126                bitmap_t iomap;
    131                 task_t *task = TASK;
    132        
    133                 ASSERT(TASK->arch.iomap.map);
    134127                bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    135128                    TSS_IOMAP_SIZE * 8);
    136                 bitmap_copy(&iomap, &task->arch.iomap, task->arch.iomap.bits);
     129                bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     130               
    137131                /*
    138132                 * It is safe to set the trailing eight bits because of the
     
    141135                bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8);
    142136        }
    143         spinlock_unlock(&TASK->lock);
    144 
     137        irq_spinlock_unlock(&TASK->lock, false);
     138       
    145139        /*
    146140         * Second, adjust TSS segment limit.
    147141         * Take the extra ending byte with all bits set into account.
    148142         */
     143        ptr_16_32_t cpugdtr;
    149144        gdtr_store(&cpugdtr);
    150         gdt_p = (descriptor_t *) cpugdtr.base;
     145       
     146        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    151147        gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits));
    152148        gdtr_load(&cpugdtr);
    153 
     149       
    154150        /*
    155151         * Before we load new TSS limit, the current TSS descriptor
  • kernel/arch/ia32/src/drivers/i8254.c

    r666f492 rda1bafb  
    5454#include <ddi/device.h>
    5555
    56 #define CLK_PORT1       ((ioport8_t *)0x40)
    57 #define CLK_PORT4       ((ioport8_t *)0x43)
     56#define CLK_PORT1  ((ioport8_t *) 0x40)
     57#define CLK_PORT4  ((ioport8_t *) 0x43)
    5858
    59 #define CLK_CONST       1193180
    60 #define MAGIC_NUMBER    1194
     59#define CLK_CONST     1193180
     60#define MAGIC_NUMBER  1194
     61
     62#define LOOPS  150000
     63#define SHIFT  11
    6164
    6265static irq_t i8254_irq;
     
    7578         * lock. We just release it, call clock() and then reacquire it again.
    7679         */
    77         spinlock_unlock(&irq->lock);
     80        irq_spinlock_unlock(&irq->lock, false);
    7881        clock();
    79         spinlock_lock(&irq->lock);
     82        irq_spinlock_lock(&irq->lock, false);
    8083}
    8184
     
    102105}
    103106
    104 #define LOOPS 150000
    105 #define SHIFT 11
    106107void i8254_calibrate_delay_loop(void)
    107108{
    108         uint64_t clk1, clk2;
    109         uint32_t t1, t2, o1, o2;
    110         uint8_t not_ok;
    111 
    112 
    113109        /*
    114110         * One-shot timer. Count-down from 0xffff at 1193180Hz
     
    118114        pio_write_8(CLK_PORT1, 0xff);
    119115        pio_write_8(CLK_PORT1, 0xff);
    120 
     116       
     117        uint8_t not_ok;
     118        uint32_t t1;
     119        uint32_t t2;
     120       
    121121        do {
    122122                /* will read both status and count */
     
    126126                t1 |= pio_read_8(CLK_PORT1) << 8;
    127127        } while (not_ok);
    128 
     128       
    129129        asm_delay_loop(LOOPS);
    130 
     130       
    131131        pio_write_8(CLK_PORT4, 0xd2);
    132132        t2 = pio_read_8(CLK_PORT1);
    133133        t2 |= pio_read_8(CLK_PORT1) << 8;
    134 
     134       
    135135        /*
    136136         * We want to determine the overhead of the calibrating mechanism.
    137137         */
    138138        pio_write_8(CLK_PORT4, 0xd2);
    139         o1 = pio_read_8(CLK_PORT1);
     139        uint32_t o1 = pio_read_8(CLK_PORT1);
    140140        o1 |= pio_read_8(CLK_PORT1) << 8;
    141 
     141       
    142142        asm_fake_loop(LOOPS);
    143 
     143       
    144144        pio_write_8(CLK_PORT4, 0xd2);
    145         o2 = pio_read_8(CLK_PORT1);
     145        uint32_t o2 = pio_read_8(CLK_PORT1);
    146146        o2 |= pio_read_8(CLK_PORT1) << 8;
    147 
     147       
    148148        CPU->delay_loop_const =
    149149            ((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2)) +
    150150            (((MAGIC_NUMBER * LOOPS) / 1000) % ((t1 - t2) - (o1 - o2)) ? 1 : 0);
    151 
    152         clk1 = get_cycle();
     151       
     152        uint64_t clk1 = get_cycle();
    153153        delay(1 << SHIFT);
    154         clk2 = get_cycle();
     154        uint64_t clk2 = get_cycle();
    155155       
    156156        CPU->frequency_mhz = (clk2 - clk1) >> SHIFT;
    157 
     157       
    158158        return;
    159159}
  • kernel/arch/ia32/src/interrupt.c

    r666f492 rda1bafb  
    9494{
    9595        fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n);
    96 
     96       
    9797        decode_istate(istate);
    9898        panic("Unserviced interrupt: %d.", n);
     
    102102{
    103103        fault_if_from_uspace(istate, "Divide error.");
    104 
     104       
    105105        decode_istate(istate);
    106106        panic("Divide error.");
     
    111111{
    112112        if (TASK) {
    113                 size_t ver;
     113                irq_spinlock_lock(&TASK->lock, false);
     114                size_t ver = TASK->arch.iomapver;
     115                irq_spinlock_unlock(&TASK->lock, false);
    114116               
    115                 spinlock_lock(&TASK->lock);
    116                 ver = TASK->arch.iomapver;
    117                 spinlock_unlock(&TASK->lock);
    118        
    119117                if (CPU->arch.iomapver_copy != ver) {
    120118                        /*
     
    130128                fault_if_from_uspace(istate, "General protection fault.");
    131129        }
    132 
     130       
    133131        decode_istate(istate);
    134132        panic("General protection fault.");
     
    138136{
    139137        fault_if_from_uspace(istate, "Stack fault.");
    140 
     138       
    141139        decode_istate(istate);
    142140        panic("Stack fault.");
     
    146144{
    147145        uint32_t mxcsr;
    148         asm (
     146        asm volatile (
    149147                "stmxcsr %[mxcsr]\n"
    150148                : [mxcsr] "=m" (mxcsr)
    151149        );
     150       
    152151        fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx.",
    153152            (unative_t) mxcsr);
     
    158157}
    159158
    160 static void nm_fault(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
    161 {
    162 #ifdef CONFIG_FPU_LAZY     
     159static void nm_fault(int n __attribute__((unused)),
     160    istate_t *istate __attribute__((unused)))
     161{
     162#ifdef CONFIG_FPU_LAZY
    163163        scheduler_fpu_lazy_request();
    164164#else
     
    169169
    170170#ifdef CONFIG_SMP
    171 static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
     171static void tlb_shootdown_ipi(int n __attribute__((unused)),
     172    istate_t *istate __attribute__((unused)))
    172173{
    173174        trap_virtual_eoi();
     
    191192                 * The IRQ handler was found.
    192193                 */
    193                  
     194               
    194195                if (irq->preack) {
    195196                        /* Send EOI before processing the interrupt */
     
    198199                }
    199200                irq->handler(irq);
    200                 spinlock_unlock(&irq->lock);
     201                irq_spinlock_unlock(&irq->lock, false);
    201202        } else {
    202203                /*
  • kernel/arch/ia32/src/smp/apic.c

    r666f492 rda1bafb  
    5353 * Advanced Programmable Interrupt Controller for SMP systems.
    5454 * Tested on:
    55  *      Bochs 2.0.2 - Bochs 2.2.6 with 2-8 CPUs
    56  *      Simics 2.0.28 - Simics 2.2.19 2-15 CPUs
    57  *      VMware Workstation 5.5 with 2 CPUs
    58  *      QEMU 0.8.0 with 2-15 CPUs
    59  *      ASUS P/I-P65UP5 + ASUS C-P55T2D REV. 1.41 with 2x 200Mhz Pentium CPUs
    60  *      ASUS PCH-DL with 2x 3000Mhz Pentium 4 Xeon (HT) CPUs
    61  *      MSI K7D Master-L with 2x 2100MHz Athlon MP CPUs
     55 *    Bochs 2.0.2 - Bochs 2.2.6 with 2-8 CPUs
     56 *    Simics 2.0.28 - Simics 2.2.19 2-15 CPUs
     57 *    VMware Workstation 5.5 with 2 CPUs
     58 *    QEMU 0.8.0 with 2-15 CPUs
     59 *    ASUS P/I-P65UP5 + ASUS C-P55T2D REV. 1.41 with 2x 200Mhz Pentium CPUs
     60 *    ASUS PCH-DL with 2x 3000Mhz Pentium 4 Xeon (HT) CPUs
     61 *    MSI K7D Master-L with 2x 2100MHz Athlon MP CPUs
     62 *
    6263 */
    6364
     
    6970 * optimize the code too much and accesses to l_apic and io_apic, that must
    7071 * always be 32-bit, would use byte oriented instructions.
     72 *
    7173 */
    7274volatile uint32_t *l_apic = (uint32_t *) 0xfee00000;
     
    7981
    8082#ifdef LAPIC_VERBOSE
    81 static char *delmod_str[] = {
     83static const char *delmod_str[] = {
    8284        "Fixed",
    8385        "Lowest Priority",
     
    9092};
    9193
    92 static char *destmod_str[] = {
     94static const char *destmod_str[] = {
    9395        "Physical",
    9496        "Logical"
    9597};
    9698
    97 static char *trigmod_str[] = {
     99static const char *trigmod_str[] = {
    98100        "Edge",
    99101        "Level"
    100102};
    101103
    102 static char *mask_str[] = {
     104static const char *mask_str[] = {
    103105        "Unmasked",
    104106        "Masked"
    105107};
    106108
    107 static char *delivs_str[] = {
     109static const char *delivs_str[] = {
    108110        "Idle",
    109111        "Send Pending"
    110112};
    111113
    112 static char *tm_mode_str[] = {
     114static const char *tm_mode_str[] = {
    113115        "One-shot",
    114116        "Periodic"
    115117};
    116118
    117 static char *intpol_str[] = {
     119static const char *intpol_str[] = {
    118120        "Polarity High",
    119121        "Polarity Low"
     
    123125/** APIC spurious interrupt handler.
    124126 *
    125  * @param n Interrupt vector.
     127 * @param n      Interrupt vector.
    126128 * @param istate Interrupted state.
    127  */
    128 static void apic_spurious(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
     129 *
     130 */
     131static void apic_spurious(int n __attribute__((unused)),
     132    istate_t *istate __attribute__((unused)))
    129133{
    130134#ifdef CONFIG_DEBUG
     
    145149         * irq->lock so we just unlock it and then lock it again.
    146150         */
    147         spinlock_unlock(&irq->lock);
     151        irq_spinlock_unlock(&irq->lock, false);
    148152        clock();
    149         spinlock_lock(&irq->lock);
     153        irq_spinlock_lock(&irq->lock, false);
    150154}
    151155
     
    153157void apic_init(void)
    154158{
    155         io_apic_id_t idreg;
    156        
    157159        exc_register(VECTOR_APIC_SPUR, "apic_spurious", (iroutine) apic_spurious);
    158 
     160       
    159161        enable_irqs_function = io_apic_enable_irqs;
    160162        disable_irqs_function = io_apic_disable_irqs;
     
    179181        for (i = 0; i < IRQ_COUNT; i++) {
    180182                int pin;
    181        
     183               
    182184                if ((pin = smp_irq_to_pin(i)) != -1)
    183185                        io_apic_change_ioredtbl((uint8_t) pin, DEST_ALL, (uint8_t) (IVT_IRQBASE + i), LOPRI);
     
    187189         * Ensure that io_apic has unique ID.
    188190         */
     191        io_apic_id_t idreg;
     192       
    189193        idreg.value = io_apic_read(IOAPICID);
    190         if ((1 << idreg.apic_id) & apic_id_mask) {      /* see if IO APIC ID is used already */
     194        if ((1 << idreg.apic_id) & apic_id_mask) {  /* See if IO APIC ID is used already */
    191195                for (i = 0; i < APIC_ID_COUNT; i++) {
    192196                        if (!((1 << i) & apic_id_mask)) {
     
    197201                }
    198202        }
    199 
     203       
    200204        /*
    201205         * Configure the BSP's lapic.
    202206         */
    203207        l_apic_init();
    204 
    205         l_apic_debug();
     208        l_apic_debug();
    206209}
    207210
     
    211214 *
    212215 * @return 0 on error, 1 on success.
     216 *
    213217 */
    214218int apic_poll_errors(void)
     
    232236        if (esr.illegal_register_address)
    233237                printf("Illegal Register Address\n");
    234 
     238       
    235239        return !esr.err_bitmap;
    236240}
     
    241245 *
    242246 * @return 0 on failure, 1 on success.
     247 *
    243248 */
    244249int l_apic_broadcast_custom_ipi(uint8_t vector)
    245250{
    246251        icr_t icr;
    247 
     252       
    248253        icr.lo = l_apic[ICRlo];
    249254        icr.delmod = DELMOD_FIXED;
     
    253258        icr.trigger_mode = TRIGMOD_LEVEL;
    254259        icr.vector = vector;
    255 
     260       
    256261        l_apic[ICRlo] = icr.lo;
    257 
     262       
    258263        icr.lo = l_apic[ICRlo];
    259264        if (icr.delivs == DELIVS_PENDING) {
     
    262267#endif
    263268        }
    264 
     269       
    265270        return apic_poll_errors();
    266271}
     
    271276 *
    272277 * @return 0 on failure, 1 on success.
     278 *
    273279 */
    274280int l_apic_send_init_ipi(uint8_t apicid)
    275281{
     282        /*
     283         * Read the ICR register in and zero all non-reserved fields.
     284         */
    276285        icr_t icr;
    277         int i;
    278 
    279         /*
    280          * Read the ICR register in and zero all non-reserved fields.
    281          */
     286       
    282287        icr.lo = l_apic[ICRlo];
    283288        icr.hi = l_apic[ICRhi];
     
    293298        l_apic[ICRhi] = icr.hi;
    294299        l_apic[ICRlo] = icr.lo;
    295 
     300       
    296301        /*
    297302         * According to MP Specification, 20us should be enough to
     
    299304         */
    300305        delay(20);
    301 
     306       
    302307        if (!apic_poll_errors())
    303308                return 0;
    304 
     309       
    305310        icr.lo = l_apic[ICRlo];
    306311        if (icr.delivs == DELIVS_PENDING) {
     
    309314#endif
    310315        }
    311 
     316       
    312317        icr.delmod = DELMOD_INIT;
    313318        icr.destmod = DESTMOD_PHYS;
     
    317322        icr.vector = 0;
    318323        l_apic[ICRlo] = icr.lo;
    319 
     324       
    320325        /*
    321326         * Wait 10ms as MP Specification specifies.
    322327         */
    323328        delay(10000);
    324 
     329       
    325330        if (!is_82489DX_apic(l_apic[LAVR])) {
    326331                /*
    327332                 * If this is not 82489DX-based l_apic we must send two STARTUP IPI's.
    328333                 */
    329                 for (i = 0; i<2; i++) {
     334                unsigned int i;
     335                for (i = 0; i < 2; i++) {
    330336                        icr.lo = l_apic[ICRlo];
    331337                        icr.vector = (uint8_t) (((uintptr_t) ap_boot) >> 12); /* calculate the reset vector */
     
    346352void l_apic_init(void)
    347353{
     354        /* Initialize LVT Error register. */
    348355        lvt_error_t error;
    349         lvt_lint_t lint;
    350         tpr_t tpr;
    351         svr_t svr;
    352         icr_t icr;
    353         tdcr_t tdcr;
    354         lvt_tm_t tm;
    355         ldr_t ldr;
    356         dfr_t dfr;
    357         uint32_t t1, t2;
    358 
    359         /* Initialize LVT Error register. */
     356       
    360357        error.value = l_apic[LVT_Err];
    361358        error.masked = true;
    362359        l_apic[LVT_Err] = error.value;
    363 
     360       
    364361        /* Initialize LVT LINT0 register. */
     362        lvt_lint_t lint;
     363       
    365364        lint.value = l_apic[LVT_LINT0];
    366365        lint.masked = true;
    367366        l_apic[LVT_LINT0] = lint.value;
    368 
     367       
    369368        /* Initialize LVT LINT1 register. */
    370369        lint.value = l_apic[LVT_LINT1];
    371370        lint.masked = true;
    372371        l_apic[LVT_LINT1] = lint.value;
    373 
     372       
    374373        /* Task Priority Register initialization. */
     374        tpr_t tpr;
     375       
    375376        tpr.value = l_apic[TPR];
    376377        tpr.pri_sc = 0;
     
    379380       
    380381        /* Spurious-Interrupt Vector Register initialization. */
     382        svr_t svr;
     383       
    381384        svr.value = l_apic[SVR];
    382385        svr.vector = VECTOR_APIC_SPUR;
     
    384387        svr.focus_checking = true;
    385388        l_apic[SVR] = svr.value;
    386 
     389       
    387390        if (CPU->arch.family >= 6)
    388391                enable_l_apic_in_msr();
    389392       
    390393        /* Interrupt Command Register initialization. */
     394        icr_t icr;
     395       
    391396        icr.lo = l_apic[ICRlo];
    392397        icr.delmod = DELMOD_INIT;
     
    398403       
    399404        /* Timer Divide Configuration Register initialization. */
     405        tdcr_t tdcr;
     406       
    400407        tdcr.value = l_apic[TDCR];
    401408        tdcr.div_value = DIVIDE_1;
    402409        l_apic[TDCR] = tdcr.value;
    403 
     410       
    404411        /* Program local timer. */
     412        lvt_tm_t tm;
     413       
    405414        tm.value = l_apic[LVT_Tm];
    406415        tm.vector = VECTOR_CLK;
     
    408417        tm.masked = false;
    409418        l_apic[LVT_Tm] = tm.value;
    410 
     419       
    411420        /*
    412421         * Measure and configure the timer to generate timer
    413422         * interrupt with period 1s/HZ seconds.
    414423         */
     424        uint32_t t1 = l_apic[CCRT];
     425        l_apic[ICRT] = 0xffffffff;
     426       
     427        while (l_apic[CCRT] == t1);
     428       
    415429        t1 = l_apic[CCRT];
    416         l_apic[ICRT] = 0xffffffff;
    417 
    418         while (l_apic[CCRT] == t1)
    419                 ;
    420                
    421         t1 = l_apic[CCRT];
    422         delay(1000000/HZ);
    423         t2 = l_apic[CCRT];
    424        
    425         l_apic[ICRT] = t1-t2;
     430        delay(1000000 / HZ);
     431        uint32_t t2 = l_apic[CCRT];
     432       
     433        l_apic[ICRT] = t1 - t2;
    426434       
    427435        /* Program Logical Destination Register. */
    428436        ASSERT(CPU->id < 8);
     437        ldr_t ldr;
     438       
    429439        ldr.value = l_apic[LDR];
    430440        ldr.id = (uint8_t) (1 << CPU->id);
     
    432442       
    433443        /* Program Destination Format Register for Flat mode. */
     444        dfr_t dfr;
     445       
    434446        dfr.value = l_apic[DFR];
    435447        dfr.model = MODEL_FLAT;
     
    447459{
    448460#ifdef LAPIC_VERBOSE
     461        printf("LVT on cpu%" PRIs ", LAPIC ID: %" PRIu8 "\n", CPU->id, l_apic_id());
     462       
    449463        lvt_tm_t tm;
    450         lvt_lint_t lint;
    451         lvt_error_t error;     
    452        
    453         printf("LVT on cpu%d, LAPIC ID: %d\n", CPU->id, l_apic_id());
    454 
    455464        tm.value = l_apic[LVT_Tm];
    456465        printf("LVT Tm: vector=%hhd, %s, %s, %s\n", tm.vector, delivs_str[tm.delivs], mask_str[tm.masked], tm_mode_str[tm.mode]);
     466       
     467        lvt_lint_t lint;
    457468        lint.value = l_apic[LVT_LINT0];
    458469        printf("LVT LINT0: vector=%hhd, %s, %s, %s, irr=%d, %s, %s\n", tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs], intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode], mask_str[lint.masked]);
    459470        lint.value = l_apic[LVT_LINT1];
    460471        printf("LVT LINT1: vector=%hhd, %s, %s, %s, irr=%d, %s, %s\n", tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs], intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode], mask_str[lint.masked]); 
     472       
     473        lvt_error_t error;
    461474        error.value = l_apic[LVT_Err];
    462475        printf("LVT Err: vector=%hhd, %s, %s\n", error.vector, delivs_str[error.delivs], mask_str[error.masked]);
     
    467480 *
    468481 * @return Local APIC ID.
     482 *
    469483 */
    470484uint8_t l_apic_id(void)
     
    481495 *
    482496 * @return Content of the addressed IO APIC register.
     497 *
    483498 */
    484499uint32_t io_apic_read(uint8_t address)
     
    495510 *
    496511 * @param address IO APIC register address.
    497  * @param x Content to be written to the addressed IO APIC register.
    498  */
    499 void io_apic_write(uint8_t address, uint32_t x)
     512 * @param val     Content to be written to the addressed IO APIC register.
     513 *
     514 */
     515void io_apic_write(uint8_t address, uint32_t val)
    500516{
    501517        io_regsel_t regsel;
     
    504520        regsel.reg_addr = address;
    505521        io_apic[IOREGSEL] = regsel.value;
    506         io_apic[IOWIN] = x;
     522        io_apic[IOWIN] = val;
    507523}
    508524
    509525/** Change some attributes of one item in I/O Redirection Table.
    510526 *
    511  * @param pin IO APIC pin number.
    512  * @param dest Interrupt destination address.
    513  * @param v Interrupt vector to trigger.
     527 * @param pin   IO APIC pin number.
     528 * @param dest  Interrupt destination address.
     529 * @param vec  Interrupt vector to trigger.
    514530 * @param flags Flags.
    515  */
    516 void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t v, int flags)
    517 {
    518         io_redirection_reg_t reg;
    519         int dlvr = DELMOD_FIXED;
     531 *
     532 */
     533void io_apic_change_ioredtbl(uint8_t pin, uint8_t dest, uint8_t vec,
     534    unsigned int flags)
     535{
     536        unsigned int dlvr;
    520537       
    521538        if (flags & LOPRI)
    522539                dlvr = DELMOD_LOWPRI;
    523 
     540        else
     541                dlvr = DELMOD_FIXED;
     542       
     543        io_redirection_reg_t reg;
    524544        reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    525545        reg.hi = io_apic_read((uint8_t) (IOREDTBL + pin * 2 + 1));
     
    530550        reg.intpol = POLARITY_HIGH;
    531551        reg.delmod = dlvr;
    532         reg.intvec = v;
    533 
     552        reg.intvec = vec;
     553       
    534554        io_apic_write((uint8_t) (IOREDTBL + pin * 2), reg.lo);
    535555        io_apic_write((uint8_t) (IOREDTBL + pin * 2 + 1), reg.hi);
     
    539559 *
    540560 * @param irqmask Bitmask of IRQs to be masked (0 = do not mask, 1 = mask).
     561 *
    541562 */
    542563void io_apic_disable_irqs(uint16_t irqmask)
    543564{
    544         io_redirection_reg_t reg;
    545565        unsigned int i;
    546         int pin;
    547        
    548566        for (i = 0; i < 16; i++) {
    549567                if (irqmask & (1 << i)) {
     
    552570                         * mapping for the respective IRQ number.
    553571                         */
    554                         pin = smp_irq_to_pin(i);
     572                        int pin = smp_irq_to_pin(i);
    555573                        if (pin != -1) {
     574                                io_redirection_reg_t reg;
     575                               
    556576                                reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    557577                                reg.masked = true;
     
    566586 *
    567587 * @param irqmask Bitmask of IRQs to be unmasked (0 = do not unmask, 1 = unmask).
     588 *
    568589 */
    569590void io_apic_enable_irqs(uint16_t irqmask)
    570591{
    571592        unsigned int i;
    572         int pin;
    573         io_redirection_reg_t reg;       
    574        
    575593        for (i = 0; i < 16; i++) {
    576594                if (irqmask & (1 << i)) {
     
    579597                         * mapping for the respective IRQ number.
    580598                         */
    581                         pin = smp_irq_to_pin(i);
     599                        int pin = smp_irq_to_pin(i);
    582600                        if (pin != -1) {
     601                                io_redirection_reg_t reg;
     602                               
    583603                                reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    584604                                reg.masked = false;
Note: See TracChangeset for help on using the changeset viewer.