Changeset b808660 in mainline for kernel/arch/ia32/src/pm.c


Ignore:
Timestamp:
2010-07-08T20:03:52Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bee2d4c
Parents:
9097982f
Message:

Do not align ia32 int handlers on any pre-defined power-of-two boundary but
rather define each one as a separate procedure with its own global label. The
label is used to populate the IDT and it also helps to maintain consistency
between C and assembly.

The old way was very error-prone because one did not get a warning when a
handler exceeded the size limit given by the alignment, which usually resulted
in very weird crashes.

In principle, the old way was also rather wasteful as the handler had to be
aligned on a power-of-two address. With the int handler size around 160 bytes,
the bytes 160 - 255 in each handler were simply wasted. In practice, however,
the image.iso size did not change (I'd expect it to drop by around 8K).

The old way did not detect a mistmatch between the C code idea of how many IDT
entries there are and the assembly language code idea of the same thing. It was
possible to initialize an IDT entry to point to some garbage and nobody would
notice until the int occurred.

The new method was a bit tiresome to write as there was a lot of copy'n'paste.
But since it was a one-time effort, I lumped it. If you know of a way to write a
for-loop in C preprocessor or use GAS assmebler macros in a sensible way, I will
gladly use your improvement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/pm.c

    r9097982f rb808660  
    139139                        d->access |= DPL_USER;
    140140                }
    141                
    142                 idt_setoffset(d, ((uintptr_t) interrupt_handlers) +
    143                     i * interrupt_handler_size);
    144141        }
    145 }
    146 
     142
     143        d = &idt[0];
     144        idt_setoffset(d++, (uintptr_t) &int_0);
     145        idt_setoffset(d++, (uintptr_t) &int_1);
     146        idt_setoffset(d++, (uintptr_t) &int_2);
     147        idt_setoffset(d++, (uintptr_t) &int_3);
     148        idt_setoffset(d++, (uintptr_t) &int_4);
     149        idt_setoffset(d++, (uintptr_t) &int_5);
     150        idt_setoffset(d++, (uintptr_t) &int_6);
     151        idt_setoffset(d++, (uintptr_t) &int_7);
     152        idt_setoffset(d++, (uintptr_t) &int_8);
     153        idt_setoffset(d++, (uintptr_t) &int_9);
     154        idt_setoffset(d++, (uintptr_t) &int_10);
     155        idt_setoffset(d++, (uintptr_t) &int_11);
     156        idt_setoffset(d++, (uintptr_t) &int_12);
     157        idt_setoffset(d++, (uintptr_t) &int_13);
     158        idt_setoffset(d++, (uintptr_t) &int_14);
     159        idt_setoffset(d++, (uintptr_t) &int_15);
     160        idt_setoffset(d++, (uintptr_t) &int_16);
     161        idt_setoffset(d++, (uintptr_t) &int_17);
     162        idt_setoffset(d++, (uintptr_t) &int_18);
     163        idt_setoffset(d++, (uintptr_t) &int_19);
     164        idt_setoffset(d++, (uintptr_t) &int_20);
     165        idt_setoffset(d++, (uintptr_t) &int_21);
     166        idt_setoffset(d++, (uintptr_t) &int_22);
     167        idt_setoffset(d++, (uintptr_t) &int_23);
     168        idt_setoffset(d++, (uintptr_t) &int_24);
     169        idt_setoffset(d++, (uintptr_t) &int_25);
     170        idt_setoffset(d++, (uintptr_t) &int_26);
     171        idt_setoffset(d++, (uintptr_t) &int_27);
     172        idt_setoffset(d++, (uintptr_t) &int_28);
     173        idt_setoffset(d++, (uintptr_t) &int_29);
     174        idt_setoffset(d++, (uintptr_t) &int_30);
     175        idt_setoffset(d++, (uintptr_t) &int_31);
     176        idt_setoffset(d++, (uintptr_t) &int_32);
     177        idt_setoffset(d++, (uintptr_t) &int_33);
     178        idt_setoffset(d++, (uintptr_t) &int_34);
     179        idt_setoffset(d++, (uintptr_t) &int_35);
     180        idt_setoffset(d++, (uintptr_t) &int_36);
     181        idt_setoffset(d++, (uintptr_t) &int_37);
     182        idt_setoffset(d++, (uintptr_t) &int_38);
     183        idt_setoffset(d++, (uintptr_t) &int_39);
     184        idt_setoffset(d++, (uintptr_t) &int_40);
     185        idt_setoffset(d++, (uintptr_t) &int_41);
     186        idt_setoffset(d++, (uintptr_t) &int_42);
     187        idt_setoffset(d++, (uintptr_t) &int_43);
     188        idt_setoffset(d++, (uintptr_t) &int_44);
     189        idt_setoffset(d++, (uintptr_t) &int_45);
     190        idt_setoffset(d++, (uintptr_t) &int_46);
     191        idt_setoffset(d++, (uintptr_t) &int_47);
     192        idt_setoffset(d++, (uintptr_t) &int_48);
     193        idt_setoffset(d++, (uintptr_t) &int_49);
     194        idt_setoffset(d++, (uintptr_t) &int_50);
     195        idt_setoffset(d++, (uintptr_t) &int_51);
     196        idt_setoffset(d++, (uintptr_t) &int_52);
     197        idt_setoffset(d++, (uintptr_t) &int_53);
     198        idt_setoffset(d++, (uintptr_t) &int_54);
     199        idt_setoffset(d++, (uintptr_t) &int_55);
     200        idt_setoffset(d++, (uintptr_t) &int_56);
     201        idt_setoffset(d++, (uintptr_t) &int_57);
     202        idt_setoffset(d++, (uintptr_t) &int_58);
     203        idt_setoffset(d++, (uintptr_t) &int_59);
     204        idt_setoffset(d++, (uintptr_t) &int_60);
     205        idt_setoffset(d++, (uintptr_t) &int_61);
     206        idt_setoffset(d++, (uintptr_t) &int_62);
     207        idt_setoffset(d++, (uintptr_t) &int_63);
     208}
    147209
    148210/* Clean IOPL(12,13) and NT(14) flags in EFLAGS register */
Note: See TracChangeset for help on using the changeset viewer.