Changeset 9d47440 in mainline for kernel/arch


Ignore:
Timestamp:
2011-05-21T16:23:17Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ff03f3
Parents:
8d308b9 (diff), 13f2461 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/arch
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/mm/as.h

    r8d308b9 r9d47440  
    4343#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
    4444
    45 #define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
    46 
    4745typedef struct {
    4846} as_arch_t;
  • kernel/arch/amd64/include/mm/as.h

    r8d308b9 r9d47440  
    4343#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xffff800000000000)
    4444#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffffffffffff)
    45 
    46 #define USER_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
    47 #define USER_ADDRESS_SPACE_END_ARCH    UINT64_C(0x00007fffffffffff)
    48 
    49 #define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
     45#define USER_ADDRESS_SPACE_START_ARCH    UINT64_C(0x0000000000000000)
     46#define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0x00007fffffffffff)
    5047
    5148#define as_constructor_arch(as, flags)  (as != as)
  • kernel/arch/amd64/src/proc/scheduler.c

    r8d308b9 r9d47440  
    5656{
    5757        CPU->arch.tss->rsp0 =
    58             (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE];
     58            (uintptr_t) &THREAD->kstack[STACK_SIZE];
    5959       
    6060        /*
  • kernel/arch/amd64/src/userspace.c

    r8d308b9 r9d47440  
    6666                "iretq\n"
    6767                :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    68                    [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
     68                   [stack_size] "r" (kernel_uarg->uspace_stack + STACK_SIZE),
    6969                   [ipl] "r" (ipl),
    7070                   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
  • kernel/arch/arm32/include/mm/as.h

    r8d308b9 r9d47440  
    3737#define KERN_arm32_AS_H_
    3838
    39 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
     39#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    4040
    41 #define KERNEL_ADDRESS_SPACE_START_ARCH     (unsigned long) 0x80000000
    42 #define KERNEL_ADDRESS_SPACE_END_ARCH       (unsigned long) 0xffffffff
    43 #define USER_ADDRESS_SPACE_START_ARCH       (unsigned long) 0x00000000
    44 #define USER_ADDRESS_SPACE_END_ARCH         (unsigned long) 0x7fffffff
    45 
    46 #define USTACK_ADDRESS_ARCH     (0x80000000 - PAGE_SIZE)
     41#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
     42#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0xffffffff)
     43#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
     44#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
    4745
    4846typedef struct {
  • kernel/arch/arm32/src/arm32.c

    r8d308b9 r9d47440  
    134134        uint8_t *stck;
    135135       
    136         stck = &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];
     136        stck = &THREAD->kstack[STACK_SIZE - SP_DELTA];
    137137        supervisor_sp = (uintptr_t) stck;
    138138}
  • kernel/arch/arm32/src/userspace.c

    r8d308b9 r9d47440  
    3838
    3939/** Struct for holding all general purpose registers.
    40  * 
     40 *
    4141 *  Used to set registers when going to userspace.
    4242 */
     
    6060} ustate_t;
    6161
    62 /** Changes processor mode and jumps to the address specified in the first
    63  * parameter.
     62/** Change processor mode
    6463 *
    65  *  @param kernel_uarg   Userspace settings (entry point, stack, ...).
     64 * @param kernel_uarg Userspace settings (entry point, stack, ...).
     65 *
    6666 */
    6767void userspace(uspace_arg_t *kernel_uarg)
     
    7979
    8080        /* clear other registers */
    81         ustate.r3  = ustate.r4  = ustate.r5 = ustate.r6 = ustate.r7 =
    82             ustate.r8 = ustate.r9 = ustate.r10 = ustate.r11 = ustate.r12 =
    83             ustate.lr = 0;
     81        ustate.r3 = 0;
     82        ustate.r4 = 0;
     83        ustate.r5 = 0;
     84        ustate.r6 = 0;
     85        ustate.r7 = 0;
     86        ustate.r8 = 0;
     87        ustate.r9 = 0;
     88        ustate.r10 = 0;
     89        ustate.r11 = 0;
     90        ustate.r12 = 0;
     91        ustate.lr = 0;
    8492
    8593        /* set user stack */
    86         ustate.sp = ((uint32_t)kernel_uarg->uspace_stack) + PAGE_SIZE;
     94        ustate.sp = ((uint32_t)kernel_uarg->uspace_stack) + STACK_SIZE;
    8795
    8896        /* set where uspace execution starts */
  • kernel/arch/ia32/include/mm/as.h

    r8d308b9 r9d47440  
    4343#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
    4444
    45 #define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
    46 
    4745typedef struct {
    4846} as_arch_t;
  • kernel/arch/ia32/src/proc/scheduler.c

    r8d308b9 r9d47440  
    5858void before_thread_runs_arch(void)
    5959{
    60         uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE];
     60        uintptr_t kstk = (uintptr_t) &THREAD->kstack[STACK_SIZE];
    6161       
    6262        if (CPU->arch.fi.bits.sep) {
  • kernel/arch/ia32/src/userspace.c

    r8d308b9 r9d47440  
    7676                :
    7777                : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    78                   [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
     78                  [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + STACK_SIZE),
    7979                  [ipl] "r" (ipl),
    8080                  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
  • kernel/arch/ia64/include/arch.h

    r8d308b9 r9d47440  
    3636#define KERN_ia64_ARCH_H_
    3737
    38 #define LOADED_PROG_STACK_PAGES_NO 2
    39 
    4038#include <arch/drivers/ski.h>
    4139
  • kernel/arch/ia64/include/asm.h

    r8d308b9 r9d47440  
    122122}
    123123
    124 /** Return base address of current stack
    125  *
    126  * Return the base address of the current stack.
    127  * The stack is assumed to be STACK_SIZE long.
    128  * The stack must start on page boundary.
    129  *
     124/** Return base address of current memory stack.
     125 *
     126 * The memory stack is assumed to be STACK_SIZE / 2 long. Note that there is
     127 * also the RSE stack, which takes up the upper half of STACK_SIZE.
     128 * The memory stack must start on page boundary.
    130129 */
    131130NO_TRACE static inline uintptr_t get_stack_base(void)
    132131{
    133         uint64_t v;
    134        
    135         /*
    136          * I'm not sure why but this code inlines badly
    137          * in scheduler, resulting in THE shifting about
    138          * 16B and causing kernel panic.
    139          *
    140          * asm volatile (
    141          *     "and %[value] = %[mask], r12"
    142          *     : [value] "=r" (v)
    143          *     : [mask] "r" (~(STACK_SIZE - 1))
    144          * );
    145          * return v;
    146          *
    147          * The following code has the same semantics but
    148          * inlines correctly.
    149          *
    150          */
     132        uint64_t value;
    151133       
    152134        asm volatile (
    153135                "mov %[value] = r12"
    154                 : [value] "=r" (v)
    155         );
    156        
    157         return (v & (~(STACK_SIZE - 1)));
     136                : [value] "=r" (value)
     137        );
     138       
     139        return (value & (~(STACK_SIZE / 2 - 1)));
    158140}
    159141
  • kernel/arch/ia64/include/context.h

    r8d308b9 r9d47440  
    4949#define SP_DELTA        (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    5050
    51 /* RSE stack starts at the bottom of memory stack. */
     51/* RSE stack starts at the bottom of memory stack, hence the division by 2. */
    5252#define context_set(c, _pc, stack, size)                                                                \
    5353        do {                                                                                            \
    5454                (c)->pc = (uintptr_t) _pc;                                                              \
    55                 (c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size), REGISTER_STACK_ALIGNMENT);            \
     55                (c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size / 2), REGISTER_STACK_ALIGNMENT);        \
    5656                (c)->ar_pfs &= PFM_MASK;                                                                \
    57                 (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - SP_DELTA;           \
     57                (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size / 2), STACK_ALIGNMENT) - SP_DELTA;       \
    5858        } while (0);
    5959
  • kernel/arch/ia64/include/mm/as.h

    r8d308b9 r9d47440  
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    3939
    40 #define KERNEL_ADDRESS_SPACE_START_ARCH  ((unsigned long) 0xe000000000000000ULL)
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH    ((unsigned long) 0xffffffffffffffffULL)
    42 #define USER_ADDRESS_SPACE_START_ARCH    ((unsigned long) 0x0000000000000000ULL)
    43 #define USER_ADDRESS_SPACE_END_ARCH      ((unsigned long) 0xdfffffffffffffffULL)
     40#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xe000000000000000)
     41#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffffffffffff)
     42#define USER_ADDRESS_SPACE_START_ARCH    UINT64_C(0x0000000000000000)
     43#define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0xdfffffffffffffff)
    4444
    45 #define USTACK_ADDRESS_ARCH  0x0000000ff0000000ULL
     45#define USTACK_ADDRESS_ARCH  UINT64_C(0x0000000ff0000000)
    4646
    4747typedef struct {
  • kernel/arch/ia64/include/mm/frame.h

    r8d308b9 r9d47440  
    4949#define physmem_print()
    5050
    51 #define ARCH_STACK_FRAMES TWO_FRAMES
    52 
    5351#endif /* __ASM__ */
    5452#endif /* KERNEL */
  • kernel/arch/ia64/src/ia64.c

    r8d308b9 r9d47440  
    249249        rsc.mode = 3;                   /* eager mode */
    250250
     251        /*
     252         * Switch to userspace.
     253         *
     254         * When calculating stack addresses, mind the stack split between the
     255         * memory stack and the RSE stack. Each occuppies STACK_SIZE / 2 bytes.
     256         */
    251257        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    252             ((uintptr_t) kernel_uarg->uspace_stack) + PAGE_SIZE -
     258            ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2 -
    253259            ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
    254             ((uintptr_t) kernel_uarg->uspace_stack) + PAGE_SIZE,
     260            ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2,
    255261            (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value);
    256262
  • kernel/arch/ia64/src/proc/scheduler.c

    r8d308b9 r9d47440  
    7979         * Record address of kernel stack to bank 0 r23.
    8080         * These values will be found there after switch from userspace.
     81         *
     82         * Mind the 1:1 split of the entire STACK_SIZE long region between the
     83         * memory stack and the RSE stack.
    8184         */
    8285        asm volatile (
     
    8689                "bsw.1\n"
    8790                :
    88                 : "r" (&THREAD->kstack[THREAD_STACK_SIZE]),
    89                   "r" (&THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA])
     91                : "r" (&THREAD->kstack[STACK_SIZE / 2]),
     92                  "r" (&THREAD->kstack[STACK_SIZE / 2 - SP_DELTA])
    9093                );
    9194}
  • kernel/arch/mips32/include/mm/as.h

    r8d308b9 r9d47440  
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    3939
    40 #define KERNEL_ADDRESS_SPACE_START_ARCH         (unsigned long) 0x80000000
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH           (unsigned long) 0x9fffffff
    42 #define USER_ADDRESS_SPACE_START_ARCH           (unsigned long) 0x00000000
    43 #define USER_ADDRESS_SPACE_END_ARCH             (unsigned long) 0x7fffffff
    44 
    45 #define USTACK_ADDRESS_ARCH     (0x80000000 - PAGE_SIZE)
     40#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
     41#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0x9fffffff)
     42#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
     43#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
    4644
    4745typedef struct {
  • kernel/arch/mips32/src/debugger.c

    r8d308b9 r9d47440  
    7979static cmd_info_t addbkpt_info = {
    8080        .name = "addbkpt",
    81         .description = "Add bkpoint (break on J/Branch insts unsupported).",
     81        .description = "Add bkpoint (break on j/branch insts unsupported).",
    8282        .func = cmd_add_breakpoint,
    8383        .argc = 1,
  • kernel/arch/mips32/src/mips32.c

    r8d308b9 r9d47440  
    220220            cp0_status_um_bit | cp0_status_ie_enabled_bit));
    221221        cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
    222         userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + PAGE_SIZE),
     222        userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE),
    223223            (uintptr_t) kernel_uarg->uspace_uarg,
    224224            (uintptr_t) kernel_uarg->uspace_entry);
     
    235235void before_thread_runs_arch(void)
    236236{
    237         supervisor_sp = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE -
    238             SP_DELTA];
     237        supervisor_sp =
     238            (uintptr_t) &THREAD->kstack[STACK_SIZE - SP_DELTA];
    239239}
    240240
  • kernel/arch/ppc32/include/boot/boot.h

    r8d308b9 r9d47440  
    3737
    3838#define BOOT_OFFSET  0x8000
    39 
    40 /* Temporary stack size for boot process */
    41 #define TEMP_STACK_SIZE  0x1000
    4239
    4340#define TASKMAP_MAX_RECORDS        32
  • kernel/arch/ppc32/include/interrupt.h

    r8d308b9 r9d47440  
    4545#define VECTOR_EXTERNAL             4
    4646#define VECTOR_DECREMENTER          8
     47#define VECTOR_ITLB_MISS            13
     48#define VECTOR_DTLB_MISS_LOAD       14
     49#define VECTOR_DTLB_MISS_STORE      15
    4750
    4851extern void start_decrementer(void);
  • kernel/arch/ppc32/include/istate.h

    r8d308b9 r9d47440  
    7373        uint32_t cr;
    7474        uint32_t pc;
    75         uint32_t srr1;
     75        uint32_t msr;
    7676        uint32_t lr;
    7777        uint32_t ctr;
     
    9090/** Return true if exception happened while in userspace
    9191 *
    92  * The contexts of MSR register was stored in SRR1.
    93  *
    9492 */
    9593NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    9694{
    97         return (istate->srr1 & MSR_PR) != 0;
     95        return (istate->msr & MSR_PR) != 0;
    9896}
    9997
  • kernel/arch/ppc32/include/mm/as.h

    r8d308b9 r9d47440  
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    3939
    40 #define KERNEL_ADDRESS_SPACE_START_ARCH  ((unsigned long) 0x80000000)
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH    ((unsigned long) 0xffffffff)
    42 #define USER_ADDRESS_SPACE_START_ARCH    ((unsigned long) 0x00000000)
    43 #define USER_ADDRESS_SPACE_END_ARCH      ((unsigned long) 0x7fffffff)
    44 
    45 #define USTACK_ADDRESS_ARCH  (0x7fffffff - (PAGE_SIZE - 1))
     40#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
     41#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0xffffffff)
     42#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
     43#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
    4644
    4745typedef struct {
  • kernel/arch/ppc32/include/mm/tlb.h

    r8d308b9 r9d47440  
    7777extern void pht_init(void);
    7878extern void pht_refill(unsigned int, istate_t *);
    79 
    80 extern bool pht_refill_real(unsigned int, istate_t *)
    81     __attribute__ ((section("K_UNMAPPED_TEXT_START")));
    82 extern void tlb_refill_real(unsigned int, uint32_t, ptehi_t, ptelo_t,
    83     istate_t *) __attribute__ ((section("K_UNMAPPED_TEXT_START")));
     79extern void tlb_refill(unsigned int, istate_t *);
    8480
    8581#endif
  • kernel/arch/ppc32/src/boot/boot.S

    r8d308b9 r9d47440  
    2828
    2929#include <arch/asm/regname.h>
    30 #include <arch/boot/boot.h>
     30#include <config.h>
    3131
    3232.section K_TEXT_START, "ax"
     
    5656.align 12
    5757kernel_stack_bottom:
    58         .space TEMP_STACK_SIZE
     58        .space STACK_SIZE
    5959kernel_stack:
  • kernel/arch/ppc32/src/exception.S

    r8d308b9 r9d47440  
    142142        CONTEXT_STORE
    143143       
    144         b data_storage
     144        li r3, 2
     145        b jump_to_kernel
    145146
    146147.org 0x400
     
    149150        CONTEXT_STORE
    150151       
    151         b instruction_storage
     152        li r3, 3
     153        b jump_to_kernel
    152154
    153155.org 0x500
     
    227229        CONTEXT_STORE
    228230       
    229         b tlb_miss
     231        li r3, 13
     232        b jump_to_kernel
    230233
    231234.org 0x1100
     
    234237        CONTEXT_STORE
    235238       
    236         b tlb_miss
     239        li r3, 14
     240        b jump_to_kernel
    237241
    238242.org 0x1200
     
    241245        CONTEXT_STORE
    242246       
    243         b tlb_miss
     247        li r3, 15
     248        b jump_to_kernel
    244249
    245250.org 0x4000
    246 data_storage:
    247         li r3, 2
    248         mr r4, sp
    249         addi r4, r4, 8
    250         bl pht_refill_real
    251        
    252         cmpwi r3, 0
    253         bne iret_real
    254        
    255         li r3, 2
    256         b jump_to_kernel
    257 
    258 instruction_storage:
    259         li r3, 3
    260         mr r4, sp
    261         addi r4, r4, 8
    262         bl pht_refill_real
    263        
    264         cmpwi r3, 0
    265         bne iret_real
    266        
    267         li r3, 3
    268         b jump_to_kernel
    269 
    270 tlb_miss:
    271         li r3, 16
    272         mfspr r4, tlbmiss
    273         mfspr r5, ptehi
    274         mfspr r6, ptelo
    275         mr r7, sp
    276         addi r7, r7, 20
    277        
    278         bl tlb_refill_real
    279         b iret_real
    280 
    281251jump_to_kernel:
    282252        lis r12, iret@ha
     
    313283        addis sp, sp, 0x8000
    314284        rfi
    315 
    316 iret_real:
    317         lwz r0, 8(sp)
    318         lwz r2, 12(sp)
    319         lwz r3, 16(sp)
    320         lwz r4, 20(sp)
    321         lwz r5, 24(sp)
    322         lwz r6, 28(sp)
    323         lwz r7, 32(sp)
    324         lwz r8, 36(sp)
    325         lwz r9, 40(sp)
    326         lwz r10, 44(sp)
    327         lwz r11, 48(sp)
    328         lwz r13, 52(sp)
    329         lwz r14, 56(sp)
    330         lwz r15, 60(sp)
    331         lwz r16, 64(sp)
    332         lwz r17, 68(sp)
    333         lwz r18, 72(sp)
    334         lwz r19, 76(sp)
    335         lwz r20, 80(sp)
    336         lwz r21, 84(sp)
    337         lwz r22, 88(sp)
    338         lwz r23, 92(sp)
    339         lwz r24, 96(sp)
    340         lwz r25, 100(sp)
    341         lwz r26, 104(sp)
    342         lwz r27, 108(sp)
    343         lwz r28, 112(sp)
    344         lwz r29, 116(sp)
    345         lwz r30, 120(sp)
    346         lwz r31, 124(sp)
    347        
    348         lwz r12, 128(sp)
    349         mtcr r12
    350        
    351         lwz r12, 132(sp)
    352         mtsrr0 r12
    353        
    354         lwz r12, 136(sp)
    355         mtsrr1 r12
    356        
    357         lwz r12, 140(sp)
    358         mtlr r12
    359        
    360         lwz r12, 144(sp)
    361         mtctr r12
    362        
    363         lwz r12, 148(sp)
    364         mtxer r12
    365        
    366         lwz r12, 156(sp)
    367         lwz sp, 160(sp)
    368        
    369         rfi
  • kernel/arch/ppc32/src/interrupt.c

    r8d308b9 r9d47440  
    153153        exc_register(VECTOR_DECREMENTER, "timer", true,
    154154            exception_decrementer);
     155        exc_register(VECTOR_ITLB_MISS, "itlb_miss", true,
     156            tlb_refill);
     157        exc_register(VECTOR_DTLB_MISS_LOAD, "dtlb_miss_load", true,
     158            tlb_refill);
     159        exc_register(VECTOR_DTLB_MISS_STORE, "dtlb_miss_store", true,
     160            tlb_refill);
    155161}
    156162
  • kernel/arch/ppc32/src/mm/tlb.c

    r8d308b9 r9d47440  
    4444#include <symtab.h>
    4545
    46 static unsigned int seed = 10;
    47 static unsigned int seed_real
    48     __attribute__ ((section("K_UNMAPPED_DATA_START"))) = 42;
     46static unsigned int seed = 42;
    4947
    5048/** Try to find PTE for faulting address
     
    225223                switch (pfrc) {
    226224                case AS_PF_FAULT:
    227                         goto fail;
    228                         break;
     225                        page_table_unlock(as, true);
     226                        pht_refill_fail(badvaddr, istate);
     227                        return;
    229228                case AS_PF_DEFER:
    230229                        /*
     
    244243       
    245244        page_table_unlock(as, true);
    246         return;
    247        
    248 fail:
    249         page_table_unlock(as, true);
    250         pht_refill_fail(badvaddr, istate);
    251 }
    252 
    253 /** Process Instruction/Data Storage Exception in Real Mode
    254  *
    255  * @param n      Exception vector number.
    256  * @param istate Interrupted register context.
    257  *
    258  */
    259 bool pht_refill_real(unsigned int n, istate_t *istate)
    260 {
    261         uintptr_t badvaddr;
    262        
    263         if (n == VECTOR_DATA_STORAGE)
    264                 badvaddr = istate->dar;
    265         else
    266                 badvaddr = istate->pc;
    267        
    268         uint32_t physmem = physmem_top();
    269        
    270         if ((badvaddr < PA2KA(0)) || (badvaddr >= PA2KA(physmem)))
    271                 return false;
    272        
    273         uint32_t page = (badvaddr >> 12) & 0xffff;
    274         uint32_t api = (badvaddr >> 22) & 0x3f;
    275        
    276         uint32_t vsid = sr_get(badvaddr);
    277         uint32_t sdr1 = sdr1_get();
    278        
    279         // FIXME: compute size of PHT exactly
    280         phte_t *phte_real = (phte_t *) (sdr1 & 0xffff0000);
    281        
    282         /* Primary hash (xor) */
    283         uint32_t h = 0;
    284         uint32_t hash = vsid ^ page;
    285         uint32_t base = (hash & 0x3ff) << 3;
    286         uint32_t i;
    287         bool found = false;
    288        
    289         /* Find colliding PTE in PTEG */
    290         for (i = 0; i < 8; i++) {
    291                 if ((phte_real[base + i].v)
    292                     && (phte_real[base + i].vsid == vsid)
    293                     && (phte_real[base + i].api == api)
    294                     && (phte_real[base + i].h == 0)) {
    295                         found = true;
    296                         break;
    297                 }
    298         }
    299        
    300         if (!found) {
    301                 /* Find unused PTE in PTEG */
    302                 for (i = 0; i < 8; i++) {
    303                         if (!phte_real[base + i].v) {
    304                                 found = true;
    305                                 break;
    306                         }
    307                 }
    308         }
    309        
    310         if (!found) {
    311                 /* Secondary hash (not) */
    312                 uint32_t base2 = (~hash & 0x3ff) << 3;
    313                
    314                 /* Find colliding PTE in PTEG */
    315                 for (i = 0; i < 8; i++) {
    316                         if ((phte_real[base2 + i].v)
    317                             && (phte_real[base2 + i].vsid == vsid)
    318                             && (phte_real[base2 + i].api == api)
    319                             && (phte_real[base2 + i].h == 1)) {
    320                                 found = true;
    321                                 base = base2;
    322                                 h = 1;
    323                                 break;
    324                         }
    325                 }
    326                
    327                 if (!found) {
    328                         /* Find unused PTE in PTEG */
    329                         for (i = 0; i < 8; i++) {
    330                                 if (!phte_real[base2 + i].v) {
    331                                         found = true;
    332                                         base = base2;
    333                                         h = 1;
    334                                         break;
    335                                 }
    336                         }
    337                 }
    338                
    339                 if (!found) {
    340                         /* Use secondary hash to avoid collisions
    341                            with usual PHT refill handler. */
    342                         i = RANDI(seed_real) % 8;
    343                         base = base2;
    344                         h = 1;
    345                 }
    346         }
    347        
    348         phte_real[base + i].v = 1;
    349         phte_real[base + i].vsid = vsid;
    350         phte_real[base + i].h = h;
    351         phte_real[base + i].api = api;
    352         phte_real[base + i].rpn = KA2PA(badvaddr) >> 12;
    353         phte_real[base + i].r = 0;
    354         phte_real[base + i].c = 0;
    355         phte_real[base + i].wimg = 0;
    356         phte_real[base + i].pp = 2; // FIXME
    357        
    358         return true;
    359 }
    360 
    361 /** Process ITLB/DTLB Miss Exception in Real Mode
    362  *
    363  *
    364  */
    365 void tlb_refill_real(unsigned int n, uint32_t tlbmiss, ptehi_t ptehi,
    366     ptelo_t ptelo, istate_t *istate)
    367 {
     245}
     246
     247void tlb_refill(unsigned int n, istate_t *istate)
     248{
     249        uint32_t tlbmiss;
     250        ptehi_t ptehi;
     251        ptelo_t ptelo;
     252       
     253        asm volatile (
     254                "mfspr %[tlbmiss], 980\n"
     255                "mfspr %[ptehi], 981\n"
     256                "mfspr %[ptelo], 982\n"
     257                : [tlbmiss] "=r" (tlbmiss),
     258                  [ptehi] "=r" (ptehi),
     259                  [ptelo] "=r" (ptelo)
     260        );
     261       
    368262        uint32_t badvaddr = tlbmiss & 0xfffffffc;
    369263        uint32_t physmem = physmem_top();
  • kernel/arch/ppc32/src/ppc32.c

    r8d308b9 r9d47440  
    265265{
    266266        userspace_asm((uintptr_t) kernel_uarg->uspace_uarg,
    267             (uintptr_t) kernel_uarg->uspace_stack +
    268             THREAD_STACK_SIZE - SP_DELTA,
     267            (uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE - SP_DELTA,
    269268            (uintptr_t) kernel_uarg->uspace_entry);
    270269       
  • kernel/arch/ppc32/src/proc/scheduler.c

    r8d308b9 r9d47440  
    5555        asm volatile (
    5656                "mtsprg0 %[ksp]\n"
    57                 :: [ksp] "r" (KA2PA(&THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA]))
     57                :: [ksp] "r" (KA2PA(&THREAD->kstack[STACK_SIZE - SP_DELTA]))
    5858        );
    5959}
  • kernel/arch/sparc64/include/mm/sun4u/as.h

    r8d308b9 r9d47440  
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    3838#include <arch/mm/tte.h>
    3939
    40 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      1
     40#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  1
    4141
    42 #define KERNEL_ADDRESS_SPACE_START_ARCH         (unsigned long) 0x0000000000000000
    43 #define KERNEL_ADDRESS_SPACE_END_ARCH           (unsigned long) 0xffffffffffffffff
    44 #define USER_ADDRESS_SPACE_START_ARCH           (unsigned long) 0x0000000000000000
    45 #define USER_ADDRESS_SPACE_END_ARCH             (unsigned long) 0xffffffffffffffff
    46 
    47 #define USTACK_ADDRESS_ARCH     (0xffffffffffffffffULL - (PAGE_SIZE - 1))
     42#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
     43#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffffffffffff)
     44#define USER_ADDRESS_SPACE_START_ARCH    UINT64_C(0x0000000000000000)
     45#define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0xffffffffffffffff)
    4846
    4947#ifdef CONFIG_TSB
  • kernel/arch/sparc64/include/mm/sun4v/as.h

    r8d308b9 r9d47440  
    4040#include <arch/mm/tsb.h>
    4141
    42 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      1
     42#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  1
    4343
    44 #define KERNEL_ADDRESS_SPACE_START_ARCH         (unsigned long) 0x0000000000000000
    45 #define KERNEL_ADDRESS_SPACE_END_ARCH           (unsigned long) 0xffffffffffffffff
    46 #define USER_ADDRESS_SPACE_START_ARCH           (unsigned long) 0x0000000000000000
    47 #define USER_ADDRESS_SPACE_END_ARCH             (unsigned long) 0xffffffffffffffff
    48 
    49 #define USTACK_ADDRESS_ARCH     (0xffffffffffffffffULL - (PAGE_SIZE - 1))
     44#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
     45#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT64_C(0xffffffffffffffff)
     46#define USER_ADDRESS_SPACE_START_ARCH    UINT64_C(0x0000000000000000)
     47#define USER_ADDRESS_SPACE_END_ARCH      UINT64_C(0xffffffffffffffff)
    5048
    5149#ifdef CONFIG_TSB
  • kernel/arch/sparc64/src/mm/sun4u/as.c

    r8d308b9 r9d47440  
    4747#include <bitops.h>
    4848#include <macros.h>
     49#include <memstr.h>
    4950
    5051#endif /* CONFIG_TSB */
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    r8d308b9 r9d47440  
    5050#include <bitops.h>
    5151#include <macros.h>
     52#include <memstr.h>
    5253
    5354#endif /* CONFIG_TSB */
Note: See TracChangeset for help on using the changeset viewer.