Changeset a218709 in mainline for kernel/arch/sparc32/src/userspace.c


Ignore:
Timestamp:
2013-12-02T23:45:45Z (10 years ago)
Author:
Jakub Klama <jakub.klama@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2955bb9
Parents:
3bc42bd
Message:

Implement new userspace window trap mechanism, which utilizes MMU probe
to choose between slow (preemptive, involving inserting stack page mapping)
and fast (direct) handlers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/src/userspace.c

    r3bc42bd ra218709  
    4242void userspace(uspace_arg_t *kernel_uarg)
    4343{
    44         printf("userspace(): entry=%p, stack=%p, stacksize=%d\n", kernel_uarg->uspace_entry, kernel_uarg->uspace_stack, kernel_uarg->uspace_stack_size);
     44//      printf("userspace(): entry=%p, stack=%p, stacksize=%d\n", kernel_uarg->uspace_entry, kernel_uarg->uspace_stack, kernel_uarg->uspace_stack_size);
    4545        /* On real hardware this switches the CPU to user
    4646           space mode and jumps to kernel_uarg->uspace_entry. */
    4747
     48        uint32_t l0, l1, l2;
    4849        uint32_t psr = psr_read();
     50        uint8_t wim;
    4951
    5052        psr &= ~(1 << 7);
    5153        psr &= ~(1 << 6);
    5254
     55        /* Read invalid window variables */
     56        read_from_invalid(&l0, &l1, &l2);
     57
     58        /* Make current window invalid */
     59        wim = (psr & 0x7) + 1;
     60        wim = (1 << wim) | (1 >> (8 - wim));
     61
    5362        asm volatile (
    5463                "flush\n"
    5564                "mov %[stack], %%sp\n"
    56                 "mov %[arg], %%o1\n"
     65                "mov %[wim], %%wim\n"
     66                "ld %[v0], %%o0\n"
     67                "ld %[v1], %%o1\n"
     68                "ld %[v2], %%o2\n"
     69                "call write_to_invalid\n"
     70                "nop\n"
     71                "ld %[arg], %%o1\n"
    5772                "jmp %[entry]\n"
    5873                "mov %[psr], %%psr\n" :: [entry] "r" (kernel_uarg->uspace_entry),
    59                            [arg] "r" (kernel_uarg->uspace_uarg),
     74                           [arg] "m" (kernel_uarg->uspace_uarg),
    6075                           [psr] "r" (psr),
    61                            [stack] "r" (kernel_uarg->uspace_stack + kernel_uarg->uspace_stack_size));
     76                           [wim] "r" ((uint32_t)wim),   
     77                           [v0] "m" (l0),
     78                           [v1] "m" (l1),
     79                           [v2] "m" (l2),
     80                           [stack] "r" (kernel_uarg->uspace_stack + kernel_uarg->uspace_stack_size - 64) : "%g3", "%g4");
    6281
    6382        while (true);
Note: See TracChangeset for help on using the changeset viewer.