8
8
9
9
static spinlock_t exception_spinlock = { .head = 0U , .tail = 0U , };
10
10
11
- static struct irq_desc * irq_desc_base ;
11
+ static struct irq_desc irq_desc_array [ NR_MAX_IRQS ] ;
12
12
static uint32_t vector_to_irq [NR_MAX_VECTOR + 1 ];
13
13
14
14
spurious_handler_t spurious_handler ;
15
15
16
16
static void init_irq_desc (void )
17
17
{
18
- uint32_t i , page_num = 0 ;
19
- uint32_t desc_size = NR_MAX_IRQS * sizeof (struct irq_desc );
20
-
21
- page_num = (desc_size + CPU_PAGE_SIZE - 1U ) >> CPU_PAGE_SHIFT ;
22
-
23
- irq_desc_base = alloc_pages (page_num );
24
-
25
- ASSERT (irq_desc_base != NULL , "page alloc failed!" );
26
- (void )memset (irq_desc_base , 0 , page_num * CPU_PAGE_SIZE );
18
+ uint32_t i ;
27
19
28
20
for (i = 0U ; i < NR_MAX_IRQS ; i ++ ) {
29
- irq_desc_base [i ].irq = i ;
30
- irq_desc_base [i ].vector = VECTOR_INVALID ;
31
- spinlock_init (& irq_desc_base [i ].irq_lock );
21
+ irq_desc_array [i ].irq = i ;
22
+ irq_desc_array [i ].vector = VECTOR_INVALID ;
23
+ spinlock_init (& irq_desc_array [i ].irq_lock );
32
24
}
33
25
34
26
for (i = 0U ; i <= NR_MAX_VECTOR ; i ++ ) {
@@ -75,7 +67,7 @@ uint32_t irq_mark_used(uint32_t irq)
75
67
if (irq > NR_MAX_IRQS )
76
68
return IRQ_INVALID ;
77
69
78
- desc = irq_desc_base + irq ;
70
+ desc = & irq_desc_array [ irq ] ;
79
71
spinlock_irqsave_obtain (& desc -> irq_lock );
80
72
if (desc -> used == IRQ_NOT_ASSIGNED )
81
73
desc -> used = IRQ_ASSIGNED_NOSHARE ;
@@ -95,7 +87,7 @@ static uint32_t alloc_irq(void)
95
87
spinlock_rflags ;
96
88
97
89
for (i = irq_gsi_num (); i < NR_MAX_IRQS ; i ++ ) {
98
- desc = irq_desc_base + i ;
90
+ desc = & irq_desc_array [ i ] ;
99
91
spinlock_irqsave_obtain (& desc -> irq_lock );
100
92
if (desc -> used == IRQ_NOT_ASSIGNED ) {
101
93
desc -> used = IRQ_ASSIGNED_NOSHARE ;
@@ -112,7 +104,7 @@ static void _irq_desc_set_vector(uint32_t irq, uint32_t vr)
112
104
{
113
105
struct irq_desc * desc ;
114
106
115
- desc = irq_desc_base + irq ;
107
+ desc = & irq_desc_array [ irq ] ;
116
108
vector_to_irq [vr ] = irq ;
117
109
desc -> vector = vr ;
118
110
}
@@ -124,7 +116,7 @@ static void irq_desc_set_vector(uint32_t irq, uint32_t vr)
124
116
125
117
spinlock_rflags ;
126
118
127
- desc = irq_desc_base + irq ;
119
+ desc = & irq_desc_array [ irq ] ;
128
120
spinlock_irqsave_obtain (& desc -> irq_lock );
129
121
vector_to_irq [vr ] = irq ;
130
122
desc -> vector = vr ;
@@ -141,7 +133,7 @@ static void _irq_desc_free_vector(uint32_t irq)
141
133
if (irq > NR_MAX_IRQS )
142
134
return ;
143
135
144
- desc = irq_desc_base + irq ;
136
+ desc = & irq_desc_array [ irq ] ;
145
137
146
138
vr = desc -> vector ;
147
139
desc -> used = IRQ_NOT_ASSIGNED ;
@@ -258,7 +250,7 @@ common_register_handler(uint32_t irq,
258
250
goto OUT ;
259
251
}
260
252
261
- desc = irq_desc_base + irq ;
253
+ desc = & irq_desc_array [ irq ] ;
262
254
added = irq_desc_append_dev (desc , node , info -> share );
263
255
if (!added ) {
264
256
free (node );
@@ -306,7 +298,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri)
306
298
if (irq > NR_MAX_IRQS )
307
299
return VECTOR_INVALID ;
308
300
309
- desc = irq_desc_base + irq ;
301
+ desc = & irq_desc_array [ irq ] ;
310
302
spinlock_irqsave_obtain (& desc -> irq_lock );
311
303
if (desc -> vector != VECTOR_INVALID ) {
312
304
/* already allocated a vector */
@@ -335,7 +327,7 @@ void irq_desc_try_free_vector(uint32_t irq)
335
327
if (irq > NR_MAX_IRQS || irq < NR_LEGACY_IRQ )
336
328
return ;
337
329
338
- desc = irq_desc_base + irq ;
330
+ desc = & irq_desc_array [ irq ] ;
339
331
spinlock_irqsave_obtain (& desc -> irq_lock );
340
332
if (desc -> dev_list == NULL )
341
333
_irq_desc_free_vector (irq );
@@ -347,7 +339,7 @@ void irq_desc_try_free_vector(uint32_t irq)
347
339
uint32_t irq_to_vector (uint32_t irq )
348
340
{
349
341
if (irq < NR_MAX_IRQS )
350
- return irq_desc_base [irq ].vector ;
342
+ return irq_desc_array [irq ].vector ;
351
343
else
352
344
return VECTOR_INVALID ;
353
345
}
@@ -416,7 +408,7 @@ void dispatch_interrupt(struct intr_excp_ctx *ctx)
416
408
if (irq == IRQ_INVALID )
417
409
goto ERR ;
418
410
419
- desc = irq_desc_base + irq ;
411
+ desc = & irq_desc_array [ irq ] ;
420
412
per_cpu (irq_count , get_cpu_id ())[irq ]++ ;
421
413
422
414
if (vr != desc -> vector )
@@ -572,7 +564,7 @@ void update_irq_handler(uint32_t irq, irq_handler_t func)
572
564
if (irq >= NR_MAX_IRQS )
573
565
return ;
574
566
575
- desc = irq_desc_base + irq ;
567
+ desc = & irq_desc_array [ irq ] ;
576
568
spinlock_irqsave_obtain (& desc -> irq_lock );
577
569
desc -> irq_handler = func ;
578
570
spinlock_irqrestore_release (& desc -> irq_lock );
@@ -688,7 +680,7 @@ void get_cpu_interrupt_info(char *str, int str_max)
688
680
str += len ;
689
681
690
682
for (irq = 0U ; irq < NR_MAX_IRQS ; irq ++ ) {
691
- desc = irq_desc_base + irq ;
683
+ desc = & irq_desc_array [ irq ] ;
692
684
vector = irq_to_vector (irq );
693
685
if (desc -> used != IRQ_NOT_ASSIGNED &&
694
686
vector != VECTOR_INVALID ) {
0 commit comments