Ignore:
Timestamp:
2006-08-30T15:50:29Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
beb3926a
Parents:
e11ae91
Message:

sparc64 work.
More bits needed to reach the userspace milestone were added.
The preemptible_handler(), still a prototype, now contains all functionality it needs.
Some sanitation was added to functions expecting page-aligned pointers to
userspace window buffer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/trap/trap_table.S

    re11ae91 ree454eb  
    4141#include <arch/trap/exception.h>
    4242#include <arch/trap/mmu.h>
     43#include <arch/mm/page.h>
    4344#include <arch/stack.h>
    4445#include <arch/regdef.h>
     
    330331
    331332        /*
     333         * Normal window spills will go to the userspace window buffer.
     334         */
     335        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate
     336
     337        /*
    332338         * Switch to kernel stack. The old stack is
    333339         * automatically saved in the old window's %sp
     
    364370         */
    3653711:
    366 
     372       
     373        /*
     374         * Other window spills will go to the userspace window buffer
     375         * and normal spills will go to the kernel stack.
     376         */
     377        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate
     378       
    367379        /*
    368380         * Copy arguments.
     
    450462         */
    451463        flushw
    452         mov %sp, %g1
     464        mov %sp, %g2
    453465        stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
    454466        stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
     
    460472        stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7]
    461473        wrpr %l0, 0, %cwp
    462         mov %g1, %sp
     474        mov %g2, %sp
    463475        ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0
    464476        ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1
     
    472484        /*
    473485         * OTHERWIN != 0 or fall-through from the OTHERWIN == 0 case.
     486         * The CWP has already been restored to the value it had prior to the SAVE
     487         * at the beginning of this function.
    474488         */
    4754890:
    476         ! TODO: restore register windows from register window memory buffer
    477 
     490        rdpr %tstate, %g1
     491        andcc %g1, TSTATE_PRIV_BIT, %g0         ! if we are not returning to userspace...,
     492        bnz 1f                                  ! ...skip restoring userspace windows
     493        nop
     494       
     495        rdpr %cwp, %g1
     496        rdpr %otherwin, %g2
     497
     498        /*
     499         * Skip all OTHERWIN windows and descend to the first window
     500         * in the userspace window buffer.
     501         */
     502        sub %g1, %g2, %g3
     503        dec %g3
     504        and %g3, NWINDOW - 1, %g3
     505        wrpr %g3, 0, %cwp
     506
     507        /*
     508         * CWP is now in the window last saved in the userspace window buffer.
     509         * Fill all windows stored in the buffer.
     510         */
     511        clr %g4
     5120:      andcc %g7, PAGE_WIDTH - 1, %g0          ! PAGE_SIZE alignment check
     513        bz 0f                                   ! %g7 is page-aligned, no more windows to refill
     514        nop
     515
     516        add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
     517        ldx [%g7 + L0_OFFSET], %l0
     518        ldx [%g7 + L1_OFFSET], %l1
     519        ldx [%g7 + L2_OFFSET], %l2
     520        ldx [%g7 + L3_OFFSET], %l3
     521        ldx [%g7 + L4_OFFSET], %l4
     522        ldx [%g7 + L5_OFFSET], %l5
     523        ldx [%g7 + L6_OFFSET], %l6
     524        ldx [%g7 + L7_OFFSET], %l7
     525        ldx [%g7 + I0_OFFSET], %i0
     526        ldx [%g7 + I1_OFFSET], %i1
     527        ldx [%g7 + I2_OFFSET], %i2
     528        ldx [%g7 + I3_OFFSET], %i3
     529        ldx [%g7 + I4_OFFSET], %i4
     530        ldx [%g7 + I5_OFFSET], %i5
     531        ldx [%g7 + I6_OFFSET], %i6
     532        ldx [%g7 + I7_OFFSET], %i7
     533
     534        dec %g3
     535        and %g3, NWINDOW - 1, %g3
     536        wrpr %g3, 0, %cwp                       ! switch to the preceeding window
     537
     538        ba 0b
     539        inc %g4
     540
     5410:
     542        /*
     543         * Switch back to the proper current window and adjust
     544         * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN.
     545         */
     546        wrpr %g1, 0, %cwp
     547        add %g4, %g2, %g2
     548        mov NWINDOW - 2, %g1
     549        sub %g1, %g2, %g1
     550       
     551        wrpr %g0, 0, %otherwin
     552        wrpr %g1, 0, %cansave                   ! NWINDOW - 2 - CANRESTORE
     553        wrpr %g2, 0, %canrestore                ! OTHERWIN + windows in the buffer
     554        wrpr %g2, 0, %cleanwin                  ! avoid information leak
     555
     556        /*
     557         * Spills and fills will be processed by the {spill,fill}_1_normal
     558         * handlers.
     559         */
     560        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
     561
     5621:
    478563        restore
    479564        retry
Note: See TracChangeset for help on using the changeset viewer.