Changeset ed166f7 in mainline


Ignore:
Timestamp:
2006-08-31T18:53:14Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6767c1d
Parents:
e0b241f
Message:

A lot of untested sparc64 stuff:

  • Write ASID to hardware when a thread is about to run in userspace.
  • Add userspace() and switch_to_userspace() functions.
  • Handle special cases when the userspace spill/fill handler causes MMU trap.
  • Resolve some TODOs in the existing sparc64 code.
  • sparc64 has now C99 compliant header guards.
  • Formatting and indentation fixes.
Location:
kernel
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/arch.h

    re0b241f red166f7  
    3535 */
    3636
    37 #ifndef __sparc64_ARCH_H__
    38 #define __sparc64_ARCH_H__
     37#ifndef KERN_sparc64_ARCH_H_
     38#define KERN_sparc64_ARCH_H_
    3939
    4040#define ASI_AIUP        0x10    /** Access to primary context with user privileges. */
  • kernel/arch/sparc64/include/arg.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ARG_H__
    36 #define __sparc64_ARG_H__
     35#ifndef KERN_sparc64_ARG_H_
     36#define KERN_sparc64_ARG_H_
    3737
    3838#include <stdarg.h>
     
    4040#endif
    4141
    42  /** @}
     42/** @}
    4343 */
    44 
  • kernel/arch/sparc64/include/asm.h

    re0b241f red166f7  
    331331extern void write_to_ig_g6(uint64_t val);
    332332
     333extern void switch_to_userspace(uint64_t pc, uint64_t sp);
     334
    333335#endif
    334336
  • kernel/arch/sparc64/include/atomic.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_ATOMIC_H__
    36 #define __sparc64_ATOMIC_H__
     35#ifndef KERN_sparc64_ATOMIC_H_
     36#define KERN_sparc64_ATOMIC_H_
    3737
    3838#include <arch/types.h>
  • kernel/arch/sparc64/include/barrier.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_BARRIER_H__
    36 #define __sparc64_BARRIER_H__
     35#ifndef KERN_sparc64_BARRIER_H_
     36#define KERN_sparc64_BARRIER_H_
    3737
    3838/*
  • kernel/arch/sparc64/include/byteorder.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_BYTEORDER_H__
    36 #define __sparc64_BYTEORDER_H__
     35#ifndef KERN_sparc64_BYTEORDER_H_
     36#define KERN_sparc64_BYTEORDER_H_
    3737
    3838#include <arch/types.h>
     
    5151#endif
    5252
    53  /** @}
     53/** @}
    5454 */
    55 
  • kernel/arch/sparc64/include/console.h

    re0b241f red166f7  
    3737
    3838extern void kkbdpoll(void *arg);
    39 extern void ofw_sparc64_console_init(void);
    4039extern void standalone_sparc64_console_init(void);
    4140
  • kernel/arch/sparc64/include/context.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_CONTEXT_H__
    36 #define __sparc64_CONTEXT_H__
     35#ifndef KERN_sparc64_CONTEXT_H_
     36#define KERN_sparc64_CONTEXT_H_
    3737
    38 #ifndef __sparc64_STACK_H__
     38#ifndef KERN_sparc64_STACK_H_
    3939# include <arch/stack.h>
    4040#endif
    4141
    42 #ifndef __sparc64_TYPES_H__
     42#ifndef KERN_sparc64_TYPES_H_
    4343# include <arch/types.h>
    4444#endif
    4545
    46 #ifndef __ALIGN_H__
     46#ifndef KERN_ALIGN_H_
    4747# include <align.h>
    4848#endif
  • kernel/arch/sparc64/include/cpu.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_CPU_H__
    36 #define __sparc64_CPU_H__
     35#ifndef KERN_sparc64_CPU_H_
     36#define KERN_sparc64_CPU_H_
    3737
    3838#include <arch/register.h>
  • kernel/arch/sparc64/include/debug.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64debug
     29/** @addtogroup sparc64debug
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_DEBUG_H__
    36 #define __sparc64_DEBUG_H__
     35#ifndef KERN_sparc64_DEBUG_H_
     36#define KERN_sparc64_DEBUG_H_
    3737
    3838#endif
    3939
    40  /** @}
     40/** @}
    4141 */
    42 
  • kernel/arch/sparc64/include/drivers/tick.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_TICK_H__
    36 #define __sparc64_TICK_H__
     35#ifndef KERN_sparc64_TICK_H_
     36#define KERN_sparc64_TICK_H_
    3737
    3838#include <typedefs.h>
  • kernel/arch/sparc64/include/elf.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_ELF_H__
    36 #define __sparc64_ELF_H__
     35#ifndef KERN_sparc64_ELF_H_
     36#define KERN_sparc64_ELF_H_
    3737
    3838#define ELF_MACHINE             EM_SPARCV9
  • kernel/arch/sparc64/include/faddr.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_FADDR_H__
    36 #define __sparc64_FADDR_H__
     35#ifndef KERN_sparc64_FADDR_H_
     36#define KERN_sparc64_FADDR_H_
    3737
    3838#include <arch/types.h>
     
    4242#endif
    4343
    44  /** @}
     44/** @}
    4545 */
    46 
  • kernel/arch/sparc64/include/fpu_context.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_FPU_CONTEXT_H__
    36 #define __sparc64_FPU_CONTEXT_H__
     35#ifndef KERN_sparc64_FPU_CONTEXT_H_
     36#define KERN_sparc64_FPU_CONTEXT_H_
    3737
    3838#include <arch/types.h>
     
    4343#endif
    4444
    45  /** @}
     45/** @}
    4646 */
    47 
  • kernel/arch/sparc64/include/interrupt.h

    re0b241f red166f7  
    3434 */
    3535
    36 #ifndef __sparc64_INTERRUPT_H__
    37 #define __sparc64_INTERRUPT_H__
     36#ifndef KERN_sparc64_INTERRUPT_H_
     37#define KERN_sparc64_INTERRUPT_H_
    3838
    3939#include <typedefs.h>
    4040#include <arch/types.h>
     41#include <arch/regdef.h>
    4142
    4243#define IRQ_COUNT       1       /* TODO */
     
    5354static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
    5455{
    55         /* TODO */
     56        istate->tpc = retaddr;
    5657}
     58
    5759static inline int istate_from_uspace(istate_t *istate)
    5860{
    59         /* TODO */
    60         return 0;
     61        return !(istate->tstate & TSTATE_PRIV_BIT);
    6162}
     63
    6264static inline unative_t istate_get_pc(istate_t *istate)
    6365{
    64         /* TODO */
    65         return 0;
     66        return istate->tpc;
    6667}
    6768
  • kernel/arch/sparc64/include/memstr.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_MEMSTR_H__
    36 #define __sparc64_MEMSTR_H__
     35#ifndef KERN_sparc64_MEMSTR_H_
     36#define KERN_sparc64_MEMSTR_H_
    3737
    3838#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     
    4545#endif
    4646
    47  /** @}
     47/** @}
    4848 */
    49 
  • kernel/arch/sparc64/include/mm/as.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64mm     
     29/** @addtogroup sparc64mm       
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_AS_H__
    36 #define __sparc64_AS_H__
     35#ifndef KERN_sparc64_AS_H_
     36#define KERN_sparc64_AS_H_
    3737
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      1
     
    4545#define USTACK_ADDRESS_ARCH     (0x7fffffffffffffff-(PAGE_SIZE-1))
    4646
    47 #define as_install_arch(as)
    48 
    4947extern void as_arch_init(void);
    5048
    5149#endif
    5250
    53  /** @}
     51/** @}
    5452 */
    5553
  • kernel/arch/sparc64/include/mm/frame.h

    re0b241f red166f7  
    4848        struct {
    4949                unsigned : 23;
    50                 uint64_t pfn : 28;      /**< Physical Frame Number. */
    51                 unsigned offset : 13;   /**< Offset. */
     50                uint64_t pfn : 28;              /**< Physical Frame Number. */
     51                unsigned offset : 13;           /**< Offset. */
    5252        } __attribute__ ((packed));
    5353};
  • kernel/arch/sparc64/include/mm/memory_init.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64mm     
     29/** @addtogroup sparc64mm       
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_MEMORY_INIT_H__
    36 #define __sparc64_MEMORY_INIT_H__
     35#ifndef KERN_sparc64_MEMORY_INIT_H_
     36#define KERN_sparc64_MEMORY_INIT_H_
    3737
    3838#include <typedefs.h>
     
    4242#endif
    4343
    44  /** @}
     44/** @}
    4545 */
    46 
  • kernel/arch/sparc64/include/mm/mmu.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_MMU_H__
    36 #define __sparc64_MMU_H__
     35#ifndef KERN_sparc64_MMU_H_
     36#define KERN_sparc64_MMU_H_
    3737
    3838/* LSU Control Register ASI. */
  • kernel/arch/sparc64/include/mm/tlb.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_TLB_H__
    36 #define __sparc64_TLB_H__
    37 
     35#ifndef KERN_sparc64_TLB_H_
     36#define KERN_sparc64_TLB_H_
    3837
    3938#define ITLB_ENTRY_COUNT                64
  • kernel/arch/sparc64/include/mm/tte.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_TTE_H__
    36 #define __sparc64_TTE_H__
     35#ifndef KERN_sparc64_TTE_H_
     36#define KERN_sparc64_TTE_H_
    3737
    3838#define TTE_G           (1<<0)
  • kernel/arch/sparc64/include/proc/task.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64proc
     29/** @addtogroup sparc64proc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_TASK_H__
    36 #define __sparc64_TASK_H__
     35#ifndef KERN_sparc64_TASK_H_
     36#define KERN_sparc64_TASK_H_
    3737
    3838typedef struct {
     
    4444#endif
    4545
    46  /** @}
     46/** @}
    4747 */
    48 
  • kernel/arch/sparc64/include/regdef.h

    re0b241f red166f7  
    4747#define TSTATE_PSTATE_SHIFT     8
    4848#define TSTATE_PRIV_BIT         (PSTATE_PRIV_BIT<<TSTATE_PSTATE_SHIFT)
     49#define TSTATE_IE_BIT           (PSTATE_IE_BIT<<TSTATE_PSTATE_SHIFT)
    4950
    5051#define TSTATE_CWP_MASK         0x1f
  • kernel/arch/sparc64/include/trap/exception.h

    re0b241f red166f7  
    3434 */
    3535
    36 #ifndef __sparc64_EXCEPTION_H__
    37 #define __sparc64_EXCEPTION_H__
     36#ifndef KERN_sparc64_EXCEPTION_H_
     37#define KERN_sparc64_EXCEPTION_H_
    3838
    3939#define TT_INSTRUCTION_ACCESS_EXCEPTION         0x08
  • kernel/arch/sparc64/include/trap/interrupt.h

    re0b241f red166f7  
    3535 */
    3636
    37 #ifndef __sparc64_TRAP_INTERRUPT_H__
    38 #define __sparc64_TRAP_INTERRUPT_H__
     37#ifndef KERN_sparc64_TRAP_INTERRUPT_H_
     38#define KERN_sparc64_TRAP_INTERRUPT_H_
    3939
    4040#include <arch/trap/trap_table.h>
  • kernel/arch/sparc64/include/trap/mmu.h

    re0b241f red166f7  
    4343#include <arch/mm/mmu.h>
    4444#include <arch/mm/tte.h>
     45#include <arch/trap/regwin.h>
    4546
    4647#define TT_FAST_INSTRUCTION_ACCESS_MMU_MISS     0x64
     
    5152
    5253#ifdef __ASM__
     54
    5355.macro FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER
    54         /*
    55          * First, try to refill TLB from TSB.
    56          */
     56        !
     57        ! First, try to refill TLB from TSB.
     58        !
    5759        ! TODO
    5860
     
    7577         * Note that branch-delay slots are used in order to save space.
    7678         */
    77 0:
     79
    7880        mov VA_DMMU_TAG_ACCESS, %g1
    7981        ldxa [%g1] ASI_DMMU, %g1                        ! read the faulting Context and VPN
     
    8587
    8688        or %g3, (TTE_CP|TTE_P|TTE_W), %g2               ! 8K pages are the default (encoded as 0)
    87         set 1, %g3
    88         sllx %g3, TTE_V_SHIFT, %g3
    89         or %g2, %g3, %g2
     89        mov 1, %g3
     90        sllx %g3, TTE_V_SHIFT, %g3
     91        or %g2, %g3, %g2
    9092        stxa %g2, [%g0] ASI_DTLB_DATA_IN_REG            ! identity map the kernel page
    9193        retry
     
    9395        /*
    9496         * Third, catch and handle special cases when the trap is caused by
    95          * some register window trap handler.
     97         * the userspace register window spill or fill handler. In case
     98         * one of these two traps caused this trap, we just lower the trap
     99         * level and service the DTLB miss. In the end, we restart
     100         * the offending SAVE or RESTORE.
    96101         */
    971020:
    98         ! TODO
     103        HANDLE_MMU_TRAPS_FROM_SPILL_OR_FILL
    99104
    100 0:
    101105        wrpr %g0, PSTATE_PRIV_BIT | PSTATE_AG_BIT, %pstate
    102106        PREEMPTIBLE_HANDLER fast_data_access_mmu_miss
     
    104108
    105109.macro FAST_DATA_ACCESS_PROTECTION_HANDLER
     110        /*
     111         * First, try to refill TLB from TSB.
     112         */
     113        ! TODO
     114
     115        /*
     116         * The same special case as in FAST_DATA_ACCESS_MMU_MISS_HANDLER.
     117         */
     118        HANDLE_MMU_TRAPS_FROM_SPILL_OR_FILL
     119
    106120        wrpr %g0, PSTATE_PRIV_BIT | PSTATE_AG_BIT, %pstate
    107121        PREEMPTIBLE_HANDLER fast_data_access_protection
    108122.endm
     123
     124/*
     125 * Macro used to lower TL when a MMU trap is caused by
     126 * the userspace register window spill or fill handler.
     127 */
     128.macro HANDLE_MMU_TRAPS_FROM_SPILL_OR_FILL
     129        rdpr %tl, %g1
     130        dec %g1
     131        brz %g1, 0f                     ! if TL was 1, skip
     132        nop
     133        wrpr %g1, 0, %tl                ! TL--
     134        rdpr %tt, %g2
     135        cmp %g2, TT_SPILL_1_NORMAL
     136        be 0f                           ! trap from spill_1_normal
     137        cmp %g2, TT_FILL_1_NORMAL
     138        be 0f                           ! trap from fill_1_normal
     139        inc %g1
     140        wrpr %g1, 0, %tl                ! another trap, TL++
     1410:
     142.endm
     143
    109144#endif /* __ASM__ */
    110145
  • kernel/arch/sparc64/include/trap/regwin.h

    re0b241f red166f7  
    3535 */
    3636
    37 #ifndef __sparc64_REGWIN_H__
    38 #define __sparc64_REGWIN_H__
     37#ifndef KERN_sparc64_REGWIN_H_
     38#define KERN_sparc64_REGWIN_H_
    3939
    4040#include <arch/stack.h>
  • kernel/arch/sparc64/include/trap/trap.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_TRAP_H__
    36 #define __sparc64_TRAP_H__
     35#ifndef KERN_sparc64_TRAP_H_
     36#define KERN_sparc64_TRAP_H_
    3737
    3838extern void trap_init(void);
  • kernel/arch/sparc64/include/trap/trap_table.h

    re0b241f red166f7  
    3333 */
    3434
    35 #ifndef __sparc64_TRAP_TABLE_H__
    36 #define __sparc64_TRAP_TABLE_H__
    37 
    38 #ifndef __ASM__
    39 #include <arch/types.h>
    40 #endif /* __ASM__ */
     35#ifndef KERN_sparc64_TRAP_TABLE_H_
     36#define KERN_sparc64_TRAP_TABLE_H_
    4137
    4238#include <arch/stack.h>
     
    4743
    4844#ifndef __ASM__
     45
     46#include <arch/types.h>
     47
    4948struct trap_table_entry {
    5049        uint8_t octets[TRAP_TABLE_ENTRY_SIZE];
  • kernel/arch/sparc64/include/types.h

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_TYPES_H__
    36 #define __sparc64_TYPES_H__
     35#ifndef KERN_sparc64_TYPES_H_
     36#define KERN_sparc64_TYPES_H_
    3737
    3838#define NULL    0
     
    6262#endif
    6363
    64  /** @}
     64/** @}
    6565 */
    66 
  • kernel/arch/sparc64/src/asm.S

    re0b241f red166f7  
    2929#include <arch/stack.h>
    3030#include <arch/regdef.h>
     31#include <arch/mm/mmu.h>
    3132
    3233.text
     
    144145read_from_ag_g7:
    145146        READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
     147
     148
     149/** Switch to userspace.
     150 *
     151 * %o0  Userspace entry address.
     152 * %o1  Userspace stack pointer address.
     153 */
     154.global switch_to_userspace
     155switch_to_userspace:
     156        flushw
     157        wrpr %g0, 0, %cleanwin          ! avoid information leak
     158        save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     159
     160        clr %i2
     161        clr %i3
     162        clr %i4
     163        clr %i5
     164        clr %i6
     165
     166        wrpr %g0, 1, %tl                ! enforce mapping via nucleus
     167
     168        rdpr %cwp, %g1
     169        wrpr %g1, TSTATE_IE_BIT, %tstate
     170        wrpr %i0, 0, %tnpc
     171       
     172        /*
     173         * Set primary context according to secondary context.
     174         * Secondary context has been already installed by
     175         * higher-level functions.
     176         */
     177        wr %g0, ASI_DMMU, %asi
     178        ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
     179        stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
     180        flush %i7
     181       
     182        done                            ! jump to userspace
  • kernel/arch/sparc64/src/ddi/ddi.c

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64ddi
     29/** @addtogroup sparc64ddi
    3030 * @{
    3131 */
     
    5353}
    5454
    55  /** @}
     55/** @}
    5656 */
    57 
  • kernel/arch/sparc64/src/dummy.s

    re0b241f red166f7  
    4040.global fpu_enable
    4141.global fpu_init
    42 .global userspace
    4342.global sys_tls_set
    4443
     
    5655fpu_enable:
    5756fpu_init:
    58 userspace:
    5957sys_tls_set:
    6058
  • kernel/arch/sparc64/src/mm/as.c

    re0b241f red166f7  
    2727 */
    2828
    29  /** @addtogroup sparc64mm
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    3434
    3535#include <arch/mm/as.h>
     36#include <arch/mm/tlb.h>
    3637#include <genarch/mm/as_ht.h>
    3738#include <genarch/mm/asid_fifo.h>
     
    4445}
    4546
    46  /** @}
     47void as_install_arch(as_t *as)
     48{
     49        tlb_context_reg_t ctx;
     50       
     51        /*
     52         * Write ASID to secondary context register.
     53         * The primary context register has to be set
     54         * from TL>0 so it will be filled from the
     55         * secondary context register from the TL=1
     56         * code just before switch to userspace.
     57         */
     58        ctx.v = 0;
     59        ctx.context = as->asid;
     60        mmu_secondary_context_write(ctx.v);
     61}
     62
     63/** @}
    4764 */
    4865
  • kernel/arch/sparc64/src/mm/tlb.c

    re0b241f red166f7  
    375375void tlb_invalidate_asid(asid_t asid)
    376376{
    377         /* TODO: write asid to some Context register and encode the register in second parameter below. */
    378         itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_NUCLEUS, 0);
    379         dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_NUCLEUS, 0);
     377        tlb_context_reg_t sc_save, ctx;
     378       
     379        ctx.v = sc_save.v = mmu_secondary_context_read();
     380        ctx.context = asid;
     381        mmu_secondary_context_write(ctx.v);
     382       
     383        itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_SECONDARY, 0);
     384        dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_SECONDARY, 0);
     385       
     386        mmu_secondary_context_write(sc_save.v);
    380387}
    381388
     
    389396{
    390397        int i;
     398        tlb_context_reg_t sc_save, ctx;
     399       
     400        ctx.v = sc_save.v = mmu_secondary_context_read();
     401        ctx.context = asid;
     402        mmu_secondary_context_write(ctx.v);
    391403       
    392404        for (i = 0; i < cnt; i++) {
    393                 /* TODO: write asid to some Context register and encode the register in second parameter below. */
    394                 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, page + i * PAGE_SIZE);
    395                 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, page + i * PAGE_SIZE);
    396         }
     405                itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, page + i * PAGE_SIZE);
     406                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, page + i * PAGE_SIZE);
     407        }
     408       
     409        mmu_secondary_context_write(sc_save.v);
    397410}
    398411
  • kernel/arch/sparc64/src/proc/scheduler.c

    re0b241f red166f7  
    9292                 * in the userspace window buffer to %g7 in the alternate and interrupt sets.
    9393                 */
    94                 write_to_ig_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS);
    95                 write_to_ag_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS);
     94                uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE
     95                        - (STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT));
     96                write_to_ig_g6(sp);
     97                write_to_ag_g6(sp);
    9698                write_to_ag_g7((uintptr_t) THREAD->arch.uspace_window_buffer);
    9799        }
  • kernel/arch/sparc64/src/sparc64.c

    re0b241f red166f7  
    3535#include <arch.h>
    3636#include <debug.h>
     37#include <config.h>
    3738#include <arch/trap/trap.h>
    3839#include <arch/console.h>
     
    4243#include <arch/boot/boot.h>
    4344#include <arch/arch.h>
    44 #include <arch/mm/tlb.h>
    45 #include <mm/asid.h>
     45#include <arch/mm/page.h>
     46#include <arch/stack.h>
     47#include <userspace.h>
    4648
    4749bootinfo_t bootinfo;
     
    9294}
    9395
     96/** Switch to userspace. */
     97void userspace(uspace_arg_t *kernel_uarg)
     98{
     99        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
     100                ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
     101                - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS));
     102
     103        for (;;)
     104                ;
     105        /* not reached */
     106}
     107
    94108/** @}
    95109 */
  • kernel/arch/sparc64/src/start.S

    re0b241f red166f7  
    6969        wrpr %g1, 0, %pstate
    7070
    71         wrpr %r0, 0, %pil               ! intialize %pil
     71        wrpr %g0, 0, %pil               ! intialize %pil
    7272
    7373        /*
  • kernel/arch/sparc64/src/trap/trap_table.S

    re0b241f red166f7  
    4141#include <arch/trap/exception.h>
    4242#include <arch/trap/mmu.h>
     43#include <arch/mm/mmu.h>
    4344#include <arch/mm/page.h>
    4445#include <arch/stack.h>
     
    349350        wrpr %l0, %otherwin
    350351        wrpr %g0, %cansave
    351         wrpr %g0, NWINDOW-1, %cleanwin
     352        wrpr %g0, NWINDOW - 1, %cleanwin
    352353
    353354        /*
     
    355356         */
    356357        mov VA_PRIMARY_CONTEXT_REG, %l0
    357         stxa %g0, [%l0] ASI_DMMU
    358         set kernel_image_start, %l0
    359         flush %l0
     358        stxa %g0, [%l0] ASI_DMMU
     359        rd %pc, %l0
     360        flush %l0
    360361
    361362        ba 1f
     
    498499         */
    499500        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
     501
     502        /*
     503         * Set primary context according to secondary context.
     504         */
     505        wr %g0, ASI_DMMU, %asi
     506        ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
     507        stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
     508        flush %o7
    500509       
    501510        rdpr %cwp, %g1
  • kernel/generic/include/align.h

    re0b241f red166f7  
    2727 */
    2828
    29 
    3029/** @addtogroup generic
    3130 * @ingroup others
    3231 * @{
    3332 */
    34 /** @file
     33/**
     34 * @file
     35 * @brief       Macros for making values and addresses aligned.
    3536 */
    3637
    37 #ifndef __ALIGN_H__
    38 #define __ALIGN_H__
     38#ifndef KERN_ALIGN_H_
     39#define KERN_ALIGN_H_
    3940
    4041/** Align to the nearest lower address.
Note: See TracChangeset for help on using the changeset viewer.