Changeset 1f12fab in mainline for kernel/arch/sparc32/src/trap_table.S


Ignore:
Timestamp:
2013-10-07T20:00:34Z (11 years ago)
Author:
Jakub Klama <jakub.klama@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a73ebf0
Parents:
80d9d83
Message:

First attempt to implement preemptive trap handlers
and switch to userspace. Preemptive traps are needed
for at least page faults, as page fault handling code
can trigger window underflow/overflow exceptions.

This commit also introduces userspace window buffer
for saving userspace register windows (just as in
sparc64).

These changes are unfinished and far from working
correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/src/trap_table.S

    r80d9d83 r1f12fab  
    3333.global trap_table
    3434.global reset_trap
     35.global preemptible_trap
    3536.global window_overflow_trap
    3637.global window_underflow_trap
     
    116117        rett %l2
    117118
    118 #define TRAP(_vector, _handler) \
     119preemptible_trap:
     120        /* Enable traps */
     121        mov %psr, %l0
     122        or %l0, (1 << 5), %l0
     123        mov %l0, %psr
     124
     125        /* Check whether previous mode was usermode */
     126        and %l0, (1 << 6), %l0
     127        cmp %l0, 0
     128        bne 1f
     129        nop
     130
     131        /* Set up stack */
     132        set kernel_sp, %l4
     133        ld [%l4], %sp
     134        mov %sp, %fp
     1351:      sub %sp, 112, %sp
     136
     137        /* Save trap data on stack */
     138        st %l1, [%fp - 4]
     139        st %l2, [%fp - 8]
     140        st %l0, [%fp - 12]
     141
     142        /* Jump to actual subroutine */
     143        mov 1, %o0
     144        jmp %g1
     145        sub %fp, 12, %o1
     146
     147        /* Return from handler */
     148        ld [%fp - 4], %l1
     149        ld [%fp - 8], %l2
     150        jmp %l1
     151        rett %l2
     152
     153#define STRAP(_vector, _handler) \
    119154        .org trap_table + _vector * TRAP_ENTRY_SIZE; \
    120155        mov %psr, %l0 ; \
    121156        sethi %hi(_handler), %l4 ; \
    122         jmp %l4 + %lo(_handler); \
    123         mov _vector, %l3 ;
     157        jmp %lo(_handler) + %l4 ; \
     158        nop
     159
     160#define TRAP(_vector, _handler) \
     161        .org trap_table + _vector * TRAP_ENTRY_SIZE; \
     162        sethi %hi(_handler), %g1 ; \
     163        b preemptible_trap ; \
     164        or %g1, %lo(_handler), %g1 ;
    124165
    125166#define INTERRUPT(_vector, _priority) \
     
    141182        TRAP(0x3, privileged_instruction)
    142183        TRAP(0x4, fp_disabled)
    143         TRAP(0x5, window_overflow_trap)
    144         TRAP(0x6, window_underflow_trap)
     184        STRAP(0x5, window_overflow_trap)
     185        STRAP(0x6, window_underflow_trap)
    145186        TRAP(0x7, mem_address_not_aligned)
    146187        TRAP(0x8, fp_exception)
Note: See TracChangeset for help on using the changeset viewer.