Subversion Repositories HelenOS-historic

Rev

Rev 1702 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1702 Rev 1780
Line 103... Line 103...
103
/** Dest format models. */
103
/** Dest format models. */
104
#define MODEL_FLAT  0xf
104
#define MODEL_FLAT  0xf
105
#define MODEL_CLUSTER   0x0
105
#define MODEL_CLUSTER   0x0
106
 
106
 
107
/** Interrupt Command Register. */
107
/** Interrupt Command Register. */
108
#define ICRlo       (0x300/sizeof(__u32))
108
#define ICRlo       (0x300/sizeof(uint32_t))
109
#define ICRhi       (0x310/sizeof(__u32))
109
#define ICRhi       (0x310/sizeof(uint32_t))
110
struct icr {
110
struct icr {
111
    union {
111
    union {
112
        __u32 lo;
112
        uint32_t lo;
113
        struct {
113
        struct {
114
            __u8 vector;            /**< Interrupt Vector. */
114
            uint8_t vector;         /**< Interrupt Vector. */
115
            unsigned delmod : 3;        /**< Delivery Mode. */
115
            unsigned delmod : 3;        /**< Delivery Mode. */
116
            unsigned destmod : 1;       /**< Destination Mode. */
116
            unsigned destmod : 1;       /**< Destination Mode. */
117
            unsigned delivs : 1;        /**< Delivery status (RO). */
117
            unsigned delivs : 1;        /**< Delivery status (RO). */
118
            unsigned : 1;           /**< Reserved. */
118
            unsigned : 1;           /**< Reserved. */
119
            unsigned level : 1;     /**< Level. */
119
            unsigned level : 1;     /**< Level. */
Line 122... Line 122...
122
            unsigned shorthand : 2;     /**< Destination Shorthand. */
122
            unsigned shorthand : 2;     /**< Destination Shorthand. */
123
            unsigned : 12;          /**< Reserved. */
123
            unsigned : 12;          /**< Reserved. */
124
        } __attribute__ ((packed));
124
        } __attribute__ ((packed));
125
    };
125
    };
126
    union {
126
    union {
127
        __u32 hi;
127
        uint32_t hi;
128
        struct {
128
        struct {
129
            unsigned : 24;          /**< Reserved. */
129
            unsigned : 24;          /**< Reserved. */
130
            __u8 dest;          /**< Destination field. */
130
            uint8_t dest;           /**< Destination field. */
131
        } __attribute__ ((packed));
131
        } __attribute__ ((packed));
132
    };
132
    };
133
} __attribute__ ((packed));
133
} __attribute__ ((packed));
134
typedef struct icr icr_t;
134
typedef struct icr icr_t;
135
 
135
 
136
/* End Of Interrupt. */
136
/* End Of Interrupt. */
137
#define EOI     (0x0b0/sizeof(__u32))
137
#define EOI     (0x0b0/sizeof(uint32_t))
138
 
138
 
139
/** Error Status Register. */
139
/** Error Status Register. */
140
#define ESR     (0x280/sizeof(__u32))
140
#define ESR     (0x280/sizeof(uint32_t))
141
union esr {
141
union esr {
142
    __u32 value;
142
    uint32_t value;
143
    __u8 err_bitmap;
143
    uint8_t err_bitmap;
144
    struct {
144
    struct {
145
        unsigned send_checksum_error : 1;
145
        unsigned send_checksum_error : 1;
146
        unsigned receive_checksum_error : 1;
146
        unsigned receive_checksum_error : 1;
147
        unsigned send_accept_error : 1;
147
        unsigned send_accept_error : 1;
148
        unsigned receive_accept_error : 1;
148
        unsigned receive_accept_error : 1;
Line 154... Line 154...
154
    } __attribute__ ((packed));
154
    } __attribute__ ((packed));
155
};
155
};
156
typedef union esr esr_t;
156
typedef union esr esr_t;
157
 
157
 
158
/* Task Priority Register */
158
/* Task Priority Register */
159
#define TPR     (0x080/sizeof(__u32))
159
#define TPR     (0x080/sizeof(uint32_t))
160
union tpr {
160
union tpr {
161
    __u32 value;
161
    uint32_t value;
162
    struct {
162
    struct {
163
        unsigned pri_sc : 4;        /**< Task Priority Sub-Class. */
163
        unsigned pri_sc : 4;        /**< Task Priority Sub-Class. */
164
        unsigned pri : 4;       /**< Task Priority. */
164
        unsigned pri : 4;       /**< Task Priority. */
165
    } __attribute__ ((packed));
165
    } __attribute__ ((packed));
166
};
166
};
167
typedef union tpr tpr_t;
167
typedef union tpr tpr_t;
168
 
168
 
169
/** Spurious-Interrupt Vector Register. */
169
/** Spurious-Interrupt Vector Register. */
170
#define SVR     (0x0f0/sizeof(__u32))
170
#define SVR     (0x0f0/sizeof(uint32_t))
171
union svr {
171
union svr {
172
    __u32 value;
172
    uint32_t value;
173
    struct {
173
    struct {
174
        __u8 vector;            /**< Spurious Vector. */
174
        uint8_t vector;         /**< Spurious Vector. */
175
        unsigned lapic_enabled : 1; /**< APIC Software Enable/Disable. */
175
        unsigned lapic_enabled : 1; /**< APIC Software Enable/Disable. */
176
        unsigned focus_checking : 1;    /**< Focus Processor Checking. */
176
        unsigned focus_checking : 1;    /**< Focus Processor Checking. */
177
        unsigned : 22;          /**< Reserved. */
177
        unsigned : 22;          /**< Reserved. */
178
    } __attribute__ ((packed));
178
    } __attribute__ ((packed));
179
};
179
};
180
typedef union svr svr_t;
180
typedef union svr svr_t;
181
 
181
 
182
/** Time Divide Configuration Register. */
182
/** Time Divide Configuration Register. */
183
#define TDCR        (0x3e0/sizeof(__u32))
183
#define TDCR        (0x3e0/sizeof(uint32_t))
184
union tdcr {
184
union tdcr {
185
    __u32 value;
185
    uint32_t value;
186
    struct {
186
    struct {
187
        unsigned div_value : 4;     /**< Divide Value, bit 2 is always 0. */
187
        unsigned div_value : 4;     /**< Divide Value, bit 2 is always 0. */
188
        unsigned : 28;          /**< Reserved. */
188
        unsigned : 28;          /**< Reserved. */
189
    } __attribute__ ((packed));
189
    } __attribute__ ((packed));
190
};
190
};
191
typedef union tdcr tdcr_t;
191
typedef union tdcr tdcr_t;
192
 
192
 
193
/* Initial Count Register for Timer */
193
/* Initial Count Register for Timer */
194
#define ICRT        (0x380/sizeof(__u32))
194
#define ICRT        (0x380/sizeof(uint32_t))
195
 
195
 
196
/* Current Count Register for Timer */
196
/* Current Count Register for Timer */
197
#define CCRT        (0x390/sizeof(__u32))
197
#define CCRT        (0x390/sizeof(uint32_t))
198
 
198
 
199
/** LVT Timer register. */
199
/** LVT Timer register. */
200
#define LVT_Tm      (0x320/sizeof(__u32))
200
#define LVT_Tm      (0x320/sizeof(uint32_t))
201
union lvt_tm {
201
union lvt_tm {
202
    __u32 value;
202
    uint32_t value;
203
    struct {
203
    struct {
204
        __u8 vector;        /**< Local Timer Interrupt vector. */
204
        uint8_t vector;     /**< Local Timer Interrupt vector. */
205
        unsigned : 4;       /**< Reserved. */
205
        unsigned : 4;       /**< Reserved. */
206
        unsigned delivs : 1;    /**< Delivery status (RO). */
206
        unsigned delivs : 1;    /**< Delivery status (RO). */
207
        unsigned : 3;       /**< Reserved. */
207
        unsigned : 3;       /**< Reserved. */
208
        unsigned masked : 1;    /**< Interrupt Mask. */
208
        unsigned masked : 1;    /**< Interrupt Mask. */
209
        unsigned mode : 1;  /**< Timer Mode. */
209
        unsigned mode : 1;  /**< Timer Mode. */
Line 211... Line 211...
211
    } __attribute__ ((packed));
211
    } __attribute__ ((packed));
212
};
212
};
213
typedef union lvt_tm lvt_tm_t;
213
typedef union lvt_tm lvt_tm_t;
214
 
214
 
215
/** LVT LINT registers. */
215
/** LVT LINT registers. */
216
#define LVT_LINT0   (0x350/sizeof(__u32))
216
#define LVT_LINT0   (0x350/sizeof(uint32_t))
217
#define LVT_LINT1   (0x360/sizeof(__u32))
217
#define LVT_LINT1   (0x360/sizeof(uint32_t))
218
union lvt_lint {
218
union lvt_lint {
219
    __u32 value;
219
    uint32_t value;
220
    struct {
220
    struct {
221
        __u8 vector;            /**< LINT Interrupt vector. */
221
        uint8_t vector;         /**< LINT Interrupt vector. */
222
        unsigned delmod : 3;        /**< Delivery Mode. */
222
        unsigned delmod : 3;        /**< Delivery Mode. */
223
        unsigned : 1;           /**< Reserved. */
223
        unsigned : 1;           /**< Reserved. */
224
        unsigned delivs : 1;        /**< Delivery status (RO). */
224
        unsigned delivs : 1;        /**< Delivery status (RO). */
225
        unsigned intpol : 1;        /**< Interrupt Input Pin Polarity. */
225
        unsigned intpol : 1;        /**< Interrupt Input Pin Polarity. */
226
        unsigned irr : 1;       /**< Remote IRR (RO). */
226
        unsigned irr : 1;       /**< Remote IRR (RO). */
Line 230... Line 230...
230
    } __attribute__ ((packed));
230
    } __attribute__ ((packed));
231
};
231
};
232
typedef union lvt_lint lvt_lint_t;
232
typedef union lvt_lint lvt_lint_t;
233
 
233
 
234
/** LVT Error register. */
234
/** LVT Error register. */
235
#define LVT_Err     (0x370/sizeof(__u32))
235
#define LVT_Err     (0x370/sizeof(uint32_t))
236
union lvt_error {
236
union lvt_error {
237
    __u32 value;
237
    uint32_t value;
238
    struct {
238
    struct {
239
        __u8 vector;        /**< Local Timer Interrupt vector. */
239
        uint8_t vector;     /**< Local Timer Interrupt vector. */
240
        unsigned : 4;       /**< Reserved. */
240
        unsigned : 4;       /**< Reserved. */
241
        unsigned delivs : 1;    /**< Delivery status (RO). */
241
        unsigned delivs : 1;    /**< Delivery status (RO). */
242
        unsigned : 3;       /**< Reserved. */
242
        unsigned : 3;       /**< Reserved. */
243
        unsigned masked : 1;    /**< Interrupt Mask. */
243
        unsigned masked : 1;    /**< Interrupt Mask. */
244
        unsigned : 15;      /**< Reserved. */
244
        unsigned : 15;      /**< Reserved. */
245
    } __attribute__ ((packed));
245
    } __attribute__ ((packed));
246
};
246
};
247
typedef union lvt_error lvt_error_t;
247
typedef union lvt_error lvt_error_t;
248
 
248
 
249
/** Local APIC ID Register. */
249
/** Local APIC ID Register. */
250
#define L_APIC_ID   (0x020/sizeof(__u32))
250
#define L_APIC_ID   (0x020/sizeof(uint32_t))
251
union l_apic_id {
251
union l_apic_id {
252
    __u32 value;
252
    uint32_t value;
253
    struct {
253
    struct {
254
        unsigned : 24;      /**< Reserved. */
254
        unsigned : 24;      /**< Reserved. */
255
        __u8 apic_id;       /**< Local APIC ID. */
255
        uint8_t apic_id;        /**< Local APIC ID. */
256
    } __attribute__ ((packed));
256
    } __attribute__ ((packed));
257
};
257
};
258
typedef union l_apic_id l_apic_id_t;
258
typedef union l_apic_id l_apic_id_t;
259
 
259
 
260
/** Local APIC Version Register */
260
/** Local APIC Version Register */
261
#define LAVR        (0x030/sizeof(__u32))
261
#define LAVR        (0x030/sizeof(uint32_t))
262
#define LAVR_Mask   0xff
262
#define LAVR_Mask   0xff
263
#define is_local_apic(x)    (((x)&LAVR_Mask&0xf0)==0x1)
263
#define is_local_apic(x)    (((x)&LAVR_Mask&0xf0)==0x1)
264
#define is_82489DX_apic(x)  ((((x)&LAVR_Mask&0xf0)==0x0))
264
#define is_82489DX_apic(x)  ((((x)&LAVR_Mask&0xf0)==0x0))
265
#define is_local_xapic(x)   (((x)&LAVR_Mask)==0x14)
265
#define is_local_xapic(x)   (((x)&LAVR_Mask)==0x14)
266
 
266
 
267
/** Logical Destination Register. */
267
/** Logical Destination Register. */
268
#define  LDR        (0x0d0/sizeof(__u32))
268
#define  LDR        (0x0d0/sizeof(uint32_t))
269
union ldr {
269
union ldr {
270
    __u32 value;
270
    uint32_t value;
271
    struct {
271
    struct {
272
        unsigned : 24;      /**< Reserved. */
272
        unsigned : 24;      /**< Reserved. */
273
        __u8 id;        /**< Logical APIC ID. */
273
        uint8_t id;     /**< Logical APIC ID. */
274
    } __attribute__ ((packed));
274
    } __attribute__ ((packed));
275
};
275
};
276
typedef union ldr ldr_t;
276
typedef union ldr ldr_t;
277
 
277
 
278
/** Destination Format Register. */
278
/** Destination Format Register. */
279
#define DFR     (0x0e0/sizeof(__u32))
279
#define DFR     (0x0e0/sizeof(uint32_t))
280
union dfr {
280
union dfr {
281
    __u32 value;
281
    uint32_t value;
282
    struct {
282
    struct {
283
        unsigned : 28;      /**< Reserved, all ones. */
283
        unsigned : 28;      /**< Reserved, all ones. */
284
        unsigned model : 4; /**< Model. */
284
        unsigned model : 4; /**< Model. */
285
    } __attribute__ ((packed));
285
    } __attribute__ ((packed));
286
};
286
};
287
typedef union dfr dfr_t;
287
typedef union dfr dfr_t;
288
 
288
 
289
/* IO APIC */
289
/* IO APIC */
290
#define IOREGSEL    (0x00/sizeof(__u32))
290
#define IOREGSEL    (0x00/sizeof(uint32_t))
291
#define IOWIN       (0x10/sizeof(__u32))
291
#define IOWIN       (0x10/sizeof(uint32_t))
292
 
292
 
293
#define IOAPICID    0x00
293
#define IOAPICID    0x00
294
#define IOAPICVER   0x01
294
#define IOAPICVER   0x01
295
#define IOAPICARB   0x02
295
#define IOAPICARB   0x02
296
#define IOREDTBL    0x10
296
#define IOREDTBL    0x10
297
 
297
 
298
/** I/O Register Select Register. */
298
/** I/O Register Select Register. */
299
union io_regsel {
299
union io_regsel {
300
    __u32 value;
300
    uint32_t value;
301
    struct {
301
    struct {
302
        __u8 reg_addr;      /**< APIC Register Address. */
302
        uint8_t reg_addr;       /**< APIC Register Address. */
303
        unsigned : 24;      /**< Reserved. */
303
        unsigned : 24;      /**< Reserved. */
304
    } __attribute__ ((packed));
304
    } __attribute__ ((packed));
305
};
305
};
306
typedef union io_regsel io_regsel_t;
306
typedef union io_regsel io_regsel_t;
307
 
307
 
308
/** I/O Redirection Register. */
308
/** I/O Redirection Register. */
309
struct io_redirection_reg {
309
struct io_redirection_reg {
310
    union {
310
    union {
311
        __u32 lo;
311
        uint32_t lo;
312
        struct {
312
        struct {
313
            __u8 intvec;            /**< Interrupt Vector. */
313
            uint8_t intvec;         /**< Interrupt Vector. */
314
            unsigned delmod : 3;        /**< Delivery Mode. */
314
            unsigned delmod : 3;        /**< Delivery Mode. */
315
            unsigned destmod : 1;       /**< Destination mode. */
315
            unsigned destmod : 1;       /**< Destination mode. */
316
            unsigned delivs : 1;        /**< Delivery status (RO). */
316
            unsigned delivs : 1;        /**< Delivery status (RO). */
317
            unsigned intpol : 1;        /**< Interrupt Input Pin Polarity. */
317
            unsigned intpol : 1;        /**< Interrupt Input Pin Polarity. */
318
            unsigned irr : 1;       /**< Remote IRR (RO). */
318
            unsigned irr : 1;       /**< Remote IRR (RO). */
Line 320... Line 320...
320
            unsigned masked : 1;        /**< Interrupt Mask. */
320
            unsigned masked : 1;        /**< Interrupt Mask. */
321
            unsigned : 15;          /**< Reserved. */
321
            unsigned : 15;          /**< Reserved. */
322
        } __attribute__ ((packed));
322
        } __attribute__ ((packed));
323
    };
323
    };
324
    union {
324
    union {
325
        __u32 hi;
325
        uint32_t hi;
326
        struct {
326
        struct {
327
            unsigned : 24;          /**< Reserved. */
327
            unsigned : 24;          /**< Reserved. */
328
            __u8 dest : 8;          /**< Destination Field. */
328
            uint8_t dest : 8;           /**< Destination Field. */
329
        } __attribute__ ((packed));
329
        } __attribute__ ((packed));
330
    };
330
    };
331
   
331
   
332
} __attribute__ ((packed));
332
} __attribute__ ((packed));
333
typedef struct io_redirection_reg io_redirection_reg_t;
333
typedef struct io_redirection_reg io_redirection_reg_t;
334
 
334
 
335
 
335
 
336
/** IO APIC Identification Register. */
336
/** IO APIC Identification Register. */
337
union io_apic_id {
337
union io_apic_id {
338
    __u32 value;
338
    uint32_t value;
339
    struct {
339
    struct {
340
        unsigned : 24;      /**< Reserved. */
340
        unsigned : 24;      /**< Reserved. */
341
        unsigned apic_id : 4;   /**< IO APIC ID. */
341
        unsigned apic_id : 4;   /**< IO APIC ID. */
342
        unsigned : 4;       /**< Reserved. */
342
        unsigned : 4;       /**< Reserved. */
343
    } __attribute__ ((packed));
343
    } __attribute__ ((packed));
344
};
344
};
345
typedef union io_apic_id io_apic_id_t;
345
typedef union io_apic_id io_apic_id_t;
346
 
346
 
347
extern volatile __u32 *l_apic;
347
extern volatile uint32_t *l_apic;
348
extern volatile __u32 *io_apic;
348
extern volatile uint32_t *io_apic;
349
 
349
 
350
extern __u32 apic_id_mask;
350
extern uint32_t apic_id_mask;
351
 
351
 
352
extern void apic_init(void);
352
extern void apic_init(void);
353
 
353
 
354
extern void l_apic_init(void);
354
extern void l_apic_init(void);
355
extern void l_apic_eoi(void);
355
extern void l_apic_eoi(void);
356
extern int l_apic_broadcast_custom_ipi(__u8 vector);
356
extern int l_apic_broadcast_custom_ipi(uint8_t vector);
357
extern int l_apic_send_init_ipi(__u8 apicid);
357
extern int l_apic_send_init_ipi(uint8_t apicid);
358
extern void l_apic_debug(void);
358
extern void l_apic_debug(void);
359
extern __u8 l_apic_id(void);
359
extern uint8_t l_apic_id(void);
360
 
360
 
361
extern __u32 io_apic_read(__u8 address);
361
extern uint32_t io_apic_read(uint8_t address);
362
extern void io_apic_write(__u8 address , __u32 x);
362
extern void io_apic_write(uint8_t address , uint32_t x);
363
extern void io_apic_change_ioredtbl(int pin, int dest, __u8 v, int flags);
363
extern void io_apic_change_ioredtbl(int pin, int dest, uint8_t v, int flags);
364
extern void io_apic_disable_irqs(__u16 irqmask);
364
extern void io_apic_disable_irqs(uint16_t irqmask);
365
extern void io_apic_enable_irqs(__u16 irqmask);
365
extern void io_apic_enable_irqs(uint16_t irqmask);
366
 
366
 
367
#endif
367
#endif
368
 
368
 
369
 /** @}
369
 /** @}
370
 */
370
 */