Changeset cfa70add in mainline for kernel/arch/sparc64/src


Ignore:
Timestamp:
2006-09-03T23:37:14Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd85ae5
Parents:
002e613
Message:

sparc64 update.

  • Prototype userspace layer implementation that at least relates to sparc64 and compiles cleanly.
  • Fixes for kernel's preemptible_handler and code related to running userspace.
  • Enable userspace. Several dozen instructions are now run in userspace! We are pretty near the userspace milestone for sparc64.
Location:
kernel/arch/sparc64/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/asm.S

    r002e613 rcfa70add  
    151151 * %o0  Userspace entry address.
    152152 * %o1  Userspace stack pointer address.
     153 * %o2  Userspace address of uarg structure.
    153154 */
    154155.global switch_to_userspace
     
    157158        wrpr %g0, 0, %cleanwin          ! avoid information leak
    158159        save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     160
     161        mov %i3, %o0                    ! uarg
    159162
    160163        clr %i2
     
    179182        stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
    180183        flush %i7
     184
     185        /*
     186         * Spills and fills will be handled by the userspace handlers.
     187         */
     188        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
    181189       
    182190        done                            ! jump to userspace
  • kernel/arch/sparc64/src/context.S

    r002e613 rcfa70add  
    2828
    2929#include <arch/context_offset.h>
    30 #include <arch/stack.h>
    3130
    3231/**
  • kernel/arch/sparc64/src/mm/tlb.c

    r002e613 rcfa70add  
    137137        data.cp = t->c;
    138138        data.cv = t->c;
    139         data.p = t->p;
     139        data.p = t->k;          /* p like privileged */
    140140        data.w = ro ? false : t->w;
    141141        data.g = t->g;
     
    167167        data.cp = t->c;
    168168        data.cv = t->c;
    169         data.p = t->p;
     169        data.p = t->k;          /* p like privileged */
    170170        data.w = false;
    171171        data.g = t->g;
  • kernel/arch/sparc64/src/proc/scheduler.c

    r002e613 rcfa70add  
    127127                ASSERT(THREAD->arch.uspace_window_buffer);
    128128               
    129                 flushw();       /* force all userspace windows into memory */
    130                
    131129                uintptr_t uw_buf = ALIGN_DOWN((uintptr_t) THREAD->arch.uspace_window_buffer, PAGE_SIZE);
    132130                if (!overlaps(uw_buf, PAGE_SIZE, base, 1<<KERNEL_PAGE_WIDTH)) {
  • kernel/arch/sparc64/src/sparc64.c

    r002e613 rcfa70add  
    4848
    4949bootinfo_t bootinfo;
     50
     51void arch_pre_main(void)
     52{
     53        /* Setup usermode */
     54        init.cnt = bootinfo.taskmap.count;
     55       
     56        uint32_t i;
     57
     58        for (i = 0; i < bootinfo.taskmap.count; i++) {
     59                init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
     60                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
     61        }
     62}
    5063
    5164void arch_pre_mm_init(void)
     
    99112        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    100113                ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
    101                 - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS));
     114                - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
     115                (uintptr_t) kernel_uarg->uspace_uarg);
    102116
    103117        for (;;)
  • kernel/arch/sparc64/src/start.S

    r002e613 rcfa70add  
    209209        ! set TL back to 0
    210210        wrpr %g0, 0, %tl
     211
     212        call arch_pre_main
     213        nop
    211214       
    212215        call main_bsp
  • kernel/arch/sparc64/src/trap/trap_table.S

    r002e613 rcfa70add  
    219219        SPILL_TO_USPACE_WINDOW_BUFFER
    220220
     221/* TT = 0xa0, TL = 0, spill_0_other handler */
     222.org trap_table + TT_SPILL_0_OTHER*ENTRY_SIZE
     223.global spill_0_other
     224spill_0_other:
     225        SPILL_TO_USPACE_WINDOW_BUFFER
     226
    221227/* TT = 0xc0, TL = 0, fill_0_normal handler */
    222228.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
     
    548554
    549555        /*
    550          * Mark the CANSAVE windows as OTHER windows.
     556         * Mark the CANRESTORE windows as OTHER windows.
    551557         * Set CLEANWIN to NWINDOW-1 so that clean_window traps do not occur.
    552558         */
    553         rdpr %cansave, %l0
     559        rdpr %canrestore, %l0
    554560        wrpr %l0, %otherwin
    555         wrpr %g0, %cansave
     561        wrpr %g0, %canrestore
    556562        wrpr %g0, NWINDOW - 1, %cleanwin
    557563
     
    642648        /*
    643649         * If OTHERWIN is zero, then all the userspace windows have been
    644          * spilled to kernel memory (i.e. register window buffer). If
    645          * OTHERWIN is non-zero, then some userspace windows are still
     650         * spilled to kernel memory (i.e. register window buffer). Moreover,
     651         * if the scheduler was called in the meantime, all valid windows
     652         * belonging to other threads were spilled by context_restore().
     653         * If OTHERWIN is non-zero, then some userspace windows are still
    646654         * valid. Others might have been spilled. However, the CWP pointer
    647655         * needs no fixing because the scheduler had not been called.
     
    660668        and %g1, TSTATE_CWP_MASK, %l0
    661669        inc %l0
    662         and %l0, TSTATE_CWP_MASK, %l0   ! %l0 mod NWINDOW
     670        and %l0, NWINDOW - 1, %l0       ! %l0 mod NWINDOW
    663671        rdpr %cwp, %l1
    664672        cmp %l0, %l1
     
    668676        /*
    669677         * Fix CWP.
    670          * Just for reminder, the input registers in the current window
    671          * are the output registers of the window to which we want to
    672          * restore. Because the fill trap fills only input and local
     678         * In order to recapitulate, the input registers in the current
     679         * window are the output registers of the window to which we want
     680         * to restore. Because the fill trap fills only input and local
    673681         * registers of a window, we need to preserve those output
    674682         * registers manually.
    675683         */
    676         flushw
    677684        mov %sp, %g2
    678685        stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
     
    739746         */
    740747        clr %g4
    741 0:      andcc %g7, PAGE_WIDTH - 1, %g0          ! PAGE_SIZE alignment check
     748        set PAGE_SIZE - 1, %g5
     7490:      andcc %g7, %g5, %g0                     ! PAGE_SIZE alignment check
    742750        bz 0f                                   ! %g7 is page-aligned, no more windows to refill
    743751        nop
Note: See TracChangeset for help on using the changeset viewer.