Changeset 9d47440 in mainline for kernel


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
Files:
72 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 */
  • kernel/genarch/src/drivers/ega/ega.c

    r8d308b9 r9d47440  
    4141#include <mm/slab.h>
    4242#include <arch/mm/page.h>
    43 #include <synch/spinlock.h>
    4443#include <typedefs.h>
    4544#include <arch/asm.h>
  • kernel/generic/include/adt/list.h

    r8d308b9 r9d47440  
    4141/** Doubly linked list head and link type. */
    4242typedef struct link {
    43         struct link *prev;      /**< Pointer to the previous item in the list. */
    44         struct link *next;      /**< Pointer to the next item in the list. */
     43        struct link *prev;  /**< Pointer to the previous item in the list. */
     44        struct link *next;  /**< Pointer to the next item in the list. */
    4545} link_t;
    4646
     
    4848 *
    4949 * @param name Name of the new statically allocated list.
     50 *
    5051 */
    5152#define LIST_INITIALIZE(name) \
    52         link_t name = { .prev = &name, .next = &name }
     53        link_t name = { \
     54                .prev = &name, \
     55                .next = &name \
     56        }
     57
     58#define list_get_instance(link, type, member) \
     59        ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     60
     61#define list_foreach(list, iterator) \
     62        for (link_t *iterator = (list).next; \
     63            iterator != &(list); iterator = iterator->next)
    5364
    5465/** Initialize doubly-linked circular list link
     
    5768 *
    5869 * @param link Pointer to link_t structure to be initialized.
     70 *
    5971 */
    6072NO_TRACE static inline void link_initialize(link_t *link)
     
    6880 * Initialize doubly-linked circular list.
    6981 *
    70  * @param head Pointer to link_t structure representing head of the list.
    71  */
    72 NO_TRACE static inline void list_initialize(link_t *head)
    73 {
    74         head->prev = head;
    75         head->next = head;
     82 * @param list Pointer to link_t structure representing the list.
     83 *
     84 */
     85NO_TRACE static inline void list_initialize(link_t *list)
     86{
     87        list->prev = list;
     88        list->next = list;
    7689}
    7790
     
    8194 *
    8295 * @param link Pointer to link_t structure to be added.
    83  * @param head Pointer to link_t structure representing head of the list.
    84  */
    85 NO_TRACE static inline void list_prepend(link_t *link, link_t *head)
    86 {
    87         link->next = head->next;
    88         link->prev = head;
    89         head->next->prev = link;
    90         head->next = link;
     96 * @param list Pointer to link_t structure representing the list.
     97 *
     98 */
     99NO_TRACE static inline void list_prepend(link_t *link, link_t *list)
     100{
     101        link->next = list->next;
     102        link->prev = list;
     103        list->next->prev = link;
     104        list->next = link;
    91105}
    92106
     
    96110 *
    97111 * @param link Pointer to link_t structure to be added.
    98  * @param head Pointer to link_t structure representing head of the list.
    99  */
    100 NO_TRACE static inline void list_append(link_t *link, link_t *head)
    101 {
    102         link->prev = head->prev;
    103         link->next = head;
    104         head->prev->next = link;
    105         head->prev = link;
     112 * @param list Pointer to link_t structure representing the list.
     113 *
     114 */
     115NO_TRACE static inline void list_append(link_t *link, link_t *list)
     116{
     117        link->prev = list->prev;
     118        link->next = list;
     119        list->prev->next = link;
     120        list->prev = link;
     121}
     122
     123/** Insert item before another item in doubly-linked circular list.
     124 *
     125 */
     126static inline void list_insert_before(link_t *link, link_t *list)
     127{
     128        list_append(link, list);
     129}
     130
     131/** Insert item after another item in doubly-linked circular list.
     132 *
     133 */
     134static inline void list_insert_after(link_t *link, link_t *list)
     135{
     136        list_prepend(list, link);
    106137}
    107138
     
    110141 * Remove item from doubly-linked circular list.
    111142 *
    112  * @param link  Pointer to link_t structure to be removed from the list it is
    113  *              contained in.
     143 * @param link Pointer to link_t structure to be removed from the list
     144 *             it is contained in.
     145 *
    114146 */
    115147NO_TRACE static inline void list_remove(link_t *link)
     
    124156 * Query emptiness of doubly-linked circular list.
    125157 *
    126  * @param head Pointer to link_t structure representing head of the list.
    127  */
    128 NO_TRACE static inline bool list_empty(link_t *head)
    129 {
    130         return head->next == head ? true : false;
    131 }
    132 
     158 * @param list Pointer to link_t structure representing the list.
     159 *
     160 */
     161NO_TRACE static inline int list_empty(link_t *list)
     162{
     163        return (list->next == list);
     164}
     165
     166/** Get head item of a list.
     167 *
     168 * @param list Pointer to link_t structure representing the list.
     169 *
     170 * @return Head item of the list.
     171 * @return NULL if the list is empty.
     172 *
     173 */
     174static inline link_t *list_head(link_t *list)
     175{
     176        return ((list->next == list) ? NULL : list->next);
     177}
    133178
    134179/** Split or concatenate headless doubly-linked circular list
     
    139184 * concatenates splitted lists and splits concatenated lists.
    140185 *
    141  * @param part1 Pointer to link_t structure leading the first (half of the
    142  *              headless) list.
    143  * @param part2 Pointer to link_t structure leading the second (half of the
    144  *              headless) list.
     186 * @param part1 Pointer to link_t structure leading the first
     187 *              (half of the headless) list.
     188 * @param part2 Pointer to link_t structure leading the second
     189 *              (half of the headless) list.
     190 *
    145191 */
    146192NO_TRACE static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
    147193{
    148         link_t *hlp;
    149 
    150194        part1->prev->next = part2;
    151         part2->prev->next = part1;     
    152         hlp = part1->prev;
     195        part2->prev->next = part1;
     196       
     197        link_t *hlp = part1->prev;
     198       
    153199        part1->prev = part2->prev;
    154200        part2->prev = hlp;
    155201}
    156202
    157 
    158203/** Split headless doubly-linked circular list
    159204 *
    160205 * Split headless doubly-linked circular list.
    161206 *
    162  * @param part1 Pointer to link_t structure leading the first half of the
    163  *              headless list.
    164  * @param part2 Pointer to link_t structure leading the second half of the
    165  *              headless list.
     207 * @param part1 Pointer to link_t structure leading
     208 *              the first half of the headless list.
     209 * @param part2 Pointer to link_t structure leading
     210 *              the second half of the headless list.
     211 *
    166212 */
    167213NO_TRACE static inline void headless_list_split(link_t *part1, link_t *part2)
     
    174220 * Concatenate two headless doubly-linked circular lists.
    175221 *
    176  * @param part1 Pointer to link_t structure leading the first headless list.
    177  * @param part2 Pointer to link_t structure leading the second headless list.
     222 * @param part1 Pointer to link_t structure leading
     223 *              the first headless list.
     224 * @param part2 Pointer to link_t structure leading
     225 *              the second headless list.
     226 *
    178227 */
    179228NO_TRACE static inline void headless_list_concat(link_t *part1, link_t *part2)
     
    182231}
    183232
    184 #define list_get_instance(link, type, member) \
    185         ((type *)(((uint8_t *)(link)) - ((uint8_t *)&(((type *)NULL)->member))))
    186 
    187 extern bool list_member(const link_t *link, const link_t *head);
    188 extern void list_concat(link_t *head1, link_t *head2);
     233/** Get n-th item of a list.
     234 *
     235 * @param list Pointer to link_t structure representing the list.
     236 * @param n    Item number (indexed from zero).
     237 *
     238 * @return n-th item of the list.
     239 * @return NULL if no n-th item found.
     240 *
     241 */
     242static inline link_t *list_nth(link_t *list, unsigned int n)
     243{
     244        unsigned int cnt = 0;
     245       
     246        list_foreach(*list, link) {
     247                if (cnt == n)
     248                        return link;
     249               
     250                cnt++;
     251        }
     252       
     253        return NULL;
     254}
     255
     256extern int list_member(const link_t *, const link_t *);
     257extern void list_concat(link_t *, link_t *);
     258extern unsigned int list_count(const link_t *);
    189259
    190260#endif
  • kernel/generic/include/arch.h

    r8d308b9 r9d47440  
    4141#include <mm/as.h>
    4242
    43 #define DEFAULT_CONTEXT  0
     43/*
     44 * THE is not an abbreviation, but the English definite article written in
     45 * capital letters. It means the current pointer to something, e.g. thread,
     46 * processor or address space. Kind reader of this comment shall appreciate
     47 * the wit of constructs like THE->thread and similar.
     48 */
     49#define THE  ((the_t * )(get_stack_base()))
    4450
    4551#define CPU                  THE->cpu
     
    4753#define TASK                 THE->task
    4854#define AS                   THE->as
    49 #define CONTEXT              (THE->task ? THE->task->context : DEFAULT_CONTEXT)
    5055#define PREEMPTION_DISABLED  THE->preemption_disabled
     56#define MAGIC                UINT32_C(0xfacefeed)
    5157
    52 #define context_check(ctx1, ctx2)  ((ctx1) == (ctx2))
     58#define container_check(ctn1, ctn2)  ((ctn1) == (ctn2))
     59
     60#define DEFAULT_CONTAINER  0
     61#define CONTAINER \
     62        ((THE->task) ? (THE->task->container) : (DEFAULT_CONTAINER))
    5363
    5464/**
     
    6373        cpu_t *cpu;                  /**< Executing cpu. */
    6474        as_t *as;                    /**< Current address space. */
     75        uint32_t magic;              /**< Magic value */
    6576} the_t;
    66 
    67 /*
    68  * THE is not an abbreviation, but the English definite article written in
    69  * capital letters. It means the current pointer to something, e.g. thread,
    70  * processor or address space. Kind reader of this comment shall appreciate
    71  * the wit of constructs like THE->thread and similar.
    72  */
    73 #define THE  ((the_t * )(get_stack_base()))
    7477
    7578extern void the_initialize(the_t *);
  • kernel/generic/include/config.h

    r8d308b9 r9d47440  
    3636#define KERN_CONFIG_H_
    3737
    38 #include <typedefs.h>
    3938#include <arch/mm/page.h>
    4039
    41 #define STACK_SIZE  PAGE_SIZE
     40#define ONE_FRAME    0
     41#define TWO_FRAMES   1
     42#define FOUR_FRAMES  2
     43
     44#define STACK_FRAMES  TWO_FRAMES
     45#define STACK_SIZE    ((1 << STACK_FRAMES) << PAGE_WIDTH)
    4246
    4347#define CONFIG_INIT_TASKS        32
    4448#define CONFIG_TASK_NAME_BUFLEN  32
     49
     50#ifndef __ASM__
     51
     52#include <typedefs.h>
    4553
    4654typedef struct {
     
    8088extern ballocs_t ballocs;
    8189
     90#endif /* __ASM__ */
     91
    8292#endif
    8393
  • kernel/generic/include/cpu.h

    r8d308b9 r9d47440  
    4141#include <arch/cpu.h>
    4242#include <arch/context.h>
    43 
    44 #define CPU_STACK_SIZE  STACK_SIZE
    4543
    4644/** CPU structure.
  • kernel/generic/include/ipc/event.h

    r8d308b9 r9d47440  
    4141#include <ipc/ipc.h>
    4242
     43typedef void (*event_callback_t)(void);
     44
    4345/** Event notification structure. */
    4446typedef struct {
     
    5153        /** Counter. */
    5254        size_t counter;
     55       
     56        /** Masked flag. */
     57        bool masked;
     58        /** Unmask callback. */
     59        event_callback_t unmask_callback;
    5360} event_t;
    5461
    5562extern void event_init(void);
     63extern void event_cleanup_answerbox(answerbox_t *);
     64extern void event_set_unmask_callback(event_type_t, event_callback_t);
     65
     66#define event_notify_0(e, m) \
     67        event_notify((e), (m), 0, 0, 0, 0, 0)
     68#define event_notify_1(e, m, a1) \
     69        event_notify((e), (m), (a1), 0, 0, 0, 0)
     70#define event_notify_2(e, m, a1, a2) \
     71        event_notify((e), (m), (a1), (a2), 0, 0, 0)
     72#define event_notify_3(e, m, a1, a2, a3) \
     73        event_notify((e), (m), (a1), (a2), (a3), 0, 0)
     74#define event_notify_4(e, m, a1, a2, a3, a4) \
     75        event_notify((e), (m), (a1), (a2), (a3), (a4), 0)
     76#define event_notify_5(e, m, a1, a2, a3, a4, a5) \
     77        event_notify((e), (m), (a1), (a2), (a3), (a4), (a5))
     78
     79extern int event_notify(event_type_t, bool, sysarg_t, sysarg_t, sysarg_t,
     80    sysarg_t, sysarg_t);
     81
    5682extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t);
    57 extern bool event_is_subscribed(event_type_t);
    58 extern void event_cleanup_answerbox(answerbox_t *);
    59 
    60 #define event_notify_0(e) \
    61         event_notify((e), 0, 0, 0, 0, 0)
    62 #define event_notify_1(e, a1) \
    63         event_notify((e), (a1), 0, 0, 0, 0)
    64 #define event_notify_2(e, a1, a2) \
    65         event_notify((e), (a1), (a2), 0, 0, 0)
    66 #define event_notify_3(e, a1, a2, a3) \
    67         event_notify((e), (a1), (a2), (a3), 0, 0)
    68 #define event_notify_4(e, a1, a2, a3, a4) \
    69         event_notify((e), (a1), (a2), (a3), (a4), 0)
    70 #define event_notify_5(e, a1, a2, a3, a4, a5) \
    71         event_notify((e), (a1), (a2), (a3), (a4), (a5))
    72 
    73 extern void event_notify(event_type_t, sysarg_t, sysarg_t, sysarg_t,
    74     sysarg_t, sysarg_t);
     83extern sysarg_t sys_event_unmask(sysarg_t);
    7584
    7685#endif
  • kernel/generic/include/ipc/event_types.h

    r8d308b9 r9d47440  
    3939        /** New data available in kernel log */
    4040        EVENT_KLOG = 0,
    41         /** Returning from kernel console to userspace */
     41        /** Returning from kernel console to uspace */
    4242        EVENT_KCONSOLE,
    4343        /** A task/thread has faulted and will be terminated */
  • kernel/generic/include/mm/as.h

    r8d308b9 r9d47440  
    8484#define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
    8585
    86 #define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
     86#ifdef USTACK_ADDRESS_ARCH
     87        #define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
     88#else
     89        #define USTACK_ADDRESS  (USER_ADDRESS_SPACE_END - (STACK_SIZE - 1))
     90#endif
    8791
    8892/** Kernel address space. */
  • kernel/generic/include/mm/frame.h

    r8d308b9 r9d47440  
    4444#include <arch/mm/page.h>
    4545#include <arch/mm/frame.h>
    46 
    47 #define ONE_FRAME    0
    48 #define TWO_FRAMES   1
    49 #define FOUR_FRAMES  2
    50 
    51 
    52 #ifdef ARCH_STACK_FRAMES
    53         #define STACK_FRAMES  ARCH_STACK_FRAMES
    54 #else
    55         #define STACK_FRAMES  ONE_FRAME
    56 #endif
    5746
    5847/** Maximum number of zones in the system. */
  • kernel/generic/include/mm/page.h

    r8d308b9 r9d47440  
    3838#include <typedefs.h>
    3939#include <mm/as.h>
    40 #include <memstr.h>
     40#include <arch/mm/page.h>
     41
     42#define P2SZ(pages) \
     43        ((pages) << PAGE_WIDTH)
    4144
    4245/** Operations to manipulate page mappings. */
  • kernel/generic/include/proc/task.h

    r8d308b9 r9d47440  
    7878        /** Unique identity of task. */
    7979        task_id_t taskid;
    80         /** Task security context. */
    81         context_id_t context;
     80        /** Task security container. */
     81        container_id_t container;
    8282       
    8383        /** Number of references (i.e. threads). */
  • kernel/generic/include/proc/thread.h

    r8d308b9 r9d47440  
    4949#include <sysinfo/abi.h>
    5050
    51 #define THREAD_STACK_SIZE   STACK_SIZE
    5251#define THREAD_NAME_BUFLEN  20
    5352
  • kernel/generic/include/proc/uarg.h

    r8d308b9 r9d47440  
    4040        void *uspace_entry;
    4141        void *uspace_stack;
    42 
     42       
    4343        void (* uspace_thread_function)();
    4444        void *uspace_thread_arg;
  • kernel/generic/include/synch/waitq.h

    r8d308b9 r9d47440  
    6262        int missed_wakeups;
    6363       
    64         /** List of sleeping threads for wich there was no missed_wakeup. */
     64        /** List of sleeping threads for which there was no missed_wakeup. */
    6565        link_t head;
    6666} waitq_t;
  • kernel/generic/include/syscall/syscall.h

    r8d308b9 r9d47440  
    7575       
    7676        SYS_EVENT_SUBSCRIBE,
     77        SYS_EVENT_UNMASK,
    7778       
    7879        SYS_CAP_GRANT,
  • kernel/generic/include/typedefs.h

    r8d308b9 r9d47440  
    6464typedef uint64_t thread_id_t;
    6565typedef uint64_t task_id_t;
    66 typedef uint32_t context_id_t;
     66typedef uint32_t container_id_t;
    6767
    6868typedef int32_t inr_t;
  • kernel/generic/src/adt/list.c

    r8d308b9 r9d47440  
    5252 *
    5353 */
    54 bool list_member(const link_t *link, const link_t *head)
     54int list_member(const link_t *link, const link_t *head)
    5555{
    5656        bool found = false;
  • kernel/generic/src/console/cmd.c

    r8d308b9 r9d47440  
    11071107        release_console();
    11081108       
    1109         event_notify_0(EVENT_KCONSOLE);
     1109        event_notify_0(EVENT_KCONSOLE, false);
    11101110        indev_pop_character(stdin);
    11111111       
  • kernel/generic/src/console/console.c

    r8d308b9 r9d47440  
    5353#include <str.h>
    5454
    55 #define KLOG_PAGES    4
     55#define KLOG_PAGES    8
    5656#define KLOG_LENGTH   (KLOG_PAGES * PAGE_SIZE / sizeof(wchar_t))
    57 #define KLOG_LATENCY  8
    5857
    5958/** Kernel log cyclic buffer */
     
    6160
    6261/** Kernel log initialized */
    63 static bool klog_inited = false;
     62static atomic_t klog_inited = {false};
    6463
    6564/** First kernel log characters */
     
    7675
    7776/** Kernel log spinlock */
    78 SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "*klog_lock");
     77SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "klog_lock");
    7978
    8079/** Physical memory area used for klog buffer */
     
    166165        sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES);
    167166       
    168         spinlock_lock(&klog_lock);
    169         klog_inited = true;
    170         spinlock_unlock(&klog_lock);
     167        event_set_unmask_callback(EVENT_KLOG, klog_update);
     168        atomic_set(&klog_inited, true);
    171169}
    172170
     
    263261void klog_update(void)
    264262{
     263        if (!atomic_get(&klog_inited))
     264                return;
     265       
    265266        spinlock_lock(&klog_lock);
    266267       
    267         if ((klog_inited) && (event_is_subscribed(EVENT_KLOG)) && (klog_uspace > 0)) {
    268                 event_notify_3(EVENT_KLOG, klog_start, klog_len, klog_uspace);
    269                 klog_uspace = 0;
     268        if (klog_uspace > 0) {
     269                if (event_notify_3(EVENT_KLOG, true, klog_start, klog_len,
     270                    klog_uspace) == EOK)
     271                        klog_uspace = 0;
    270272        }
    271273       
     
    275277void putchar(const wchar_t ch)
    276278{
     279        bool ordy = ((stdout) && (stdout->op->write));
     280       
    277281        spinlock_lock(&klog_lock);
    278282       
    279         if ((klog_stored > 0) && (stdout) && (stdout->op->write)) {
    280                 /* Print charaters stored in kernel log */
    281                 size_t i;
    282                 for (i = klog_len - klog_stored; i < klog_len; i++)
    283                         stdout->op->write(stdout, klog[(klog_start + i) % KLOG_LENGTH], silent);
    284                 klog_stored = 0;
     283        /* Print charaters stored in kernel log */
     284        if (ordy) {
     285                while (klog_stored > 0) {
     286                        wchar_t tmp = klog[(klog_start + klog_len - klog_stored) % KLOG_LENGTH];
     287                        klog_stored--;
     288                       
     289                        /*
     290                         * We need to give up the spinlock for
     291                         * the physical operation of writting out
     292                         * the character.
     293                         */
     294                        spinlock_unlock(&klog_lock);
     295                        stdout->op->write(stdout, tmp, silent);
     296                        spinlock_lock(&klog_lock);
     297                }
    285298        }
    286299       
     
    292305                klog_start = (klog_start + 1) % KLOG_LENGTH;
    293306       
    294         if ((stdout) && (stdout->op->write))
     307        if (!ordy) {
     308                if (klog_stored < klog_len)
     309                        klog_stored++;
     310        }
     311       
     312        /* The character is stored for uspace */
     313        if (klog_uspace < klog_len)
     314                klog_uspace++;
     315       
     316        spinlock_unlock(&klog_lock);
     317       
     318        if (ordy) {
     319                /*
     320                 * Output the character. In this case
     321                 * it should be no longer buffered.
     322                 */
    295323                stdout->op->write(stdout, ch, silent);
    296         else {
     324        } else {
    297325                /*
    298326                 * No standard output routine defined yet.
     
    304332                 * Note that the early_putc() function might be
    305333                 * a no-op on certain hardware configurations.
    306                  *
    307334                 */
    308335                early_putchar(ch);
    309                
    310                 if (klog_stored < klog_len)
    311                         klog_stored++;
    312         }
    313        
    314         /* The character is stored for uspace */
    315         if (klog_uspace < klog_len)
    316                 klog_uspace++;
    317        
    318         /* Check notify uspace to update */
    319         bool update;
    320         if ((klog_uspace > KLOG_LATENCY) || (ch == '\n'))
    321                 update = true;
    322         else
    323                 update = false;
    324        
    325         spinlock_unlock(&klog_lock);
    326        
    327         if (update)
     336        }
     337       
     338        /* Force notification on newline */
     339        if (ch == '\n')
    328340                klog_update();
    329341}
  • kernel/generic/src/ddi/ddi.c

    r8d308b9 r9d47440  
    224224        task_t *task = task_find_by_id(id);
    225225       
    226         if ((!task) || (!context_check(CONTEXT, task->context))) {
     226        if ((!task) || (!container_check(CONTAINER, task->container))) {
    227227                /*
    228228                 * There is no task with the specified ID
  • kernel/generic/src/debug/panic.c

    r8d308b9 r9d47440  
    9595        printf("\n");
    9696       
     97        printf("THE=%p: ", THE);
     98        if (THE != NULL) {
     99                printf("pe=%" PRIun " thr=%p task=%p cpu=%p as=%p"
     100                    " magic=%#" PRIx32 "\n", THE->preemption_disabled,
     101                    THE->thread, THE->task, THE->cpu, THE->as, THE->magic);
     102        } else
     103                printf("invalid\n");
     104       
    97105        if (istate) {
    98106                istate_decode(istate);
  • kernel/generic/src/interrupt/interrupt.c

    r8d308b9 r9d47440  
    205205         * stack.
    206206         */
    207         return (istate_t *) ((uint8_t *) thread->kstack + THREAD_STACK_SIZE -
    208             sizeof(istate_t));
     207        return (istate_t *) ((uint8_t *)
     208            thread->kstack + STACK_SIZE - sizeof(istate_t));
    209209}
    210210
  • kernel/generic/src/ipc/event.c

    r8d308b9 r9d47440  
    4848static event_t events[EVENT_END];
    4949
    50 /** Initialize kernel events. */
     50/** Initialize kernel events.
     51 *
     52 */
    5153void event_init(void)
    5254{
    53         unsigned int i;
    54        
    55         for (i = 0; i < EVENT_END; i++) {
     55        for (unsigned int i = 0; i < EVENT_END; i++) {
    5656                spinlock_initialize(&events[i].lock, "event.lock");
    5757                events[i].answerbox = NULL;
    5858                events[i].counter = 0;
    5959                events[i].imethod = 0;
     60                events[i].masked = false;
     61                events[i].unmask_callback = NULL;
    6062        }
    6163}
    6264
     65/** Unsubscribe kernel events associated with an answerbox
     66 *
     67 * @param answerbox Answerbox to be unsubscribed.
     68 *
     69 */
     70void event_cleanup_answerbox(answerbox_t *answerbox)
     71{
     72        for (unsigned int i = 0; i < EVENT_END; i++) {
     73                spinlock_lock(&events[i].lock);
     74               
     75                if (events[i].answerbox == answerbox) {
     76                        events[i].answerbox = NULL;
     77                        events[i].counter = 0;
     78                        events[i].imethod = 0;
     79                        events[i].masked = false;
     80                }
     81               
     82                spinlock_unlock(&events[i].lock);
     83        }
     84}
     85
     86/** Define a callback function for the event unmask event.
     87 *
     88 * @param evno     Event type.
     89 * @param callback Callback function to be called when
     90 *                 the event is unmasked.
     91 *
     92 */
     93void event_set_unmask_callback(event_type_t evno, event_callback_t callback)
     94{
     95        ASSERT(evno < EVENT_END);
     96       
     97        spinlock_lock(&events[evno].lock);
     98        events[evno].unmask_callback = callback;
     99        spinlock_unlock(&events[evno].lock);
     100}
     101
     102/** Send kernel notification event
     103 *
     104 * @param evno Event type.
     105 * @param mask Mask further notifications after a successful
     106 *             sending.
     107 * @param a1   First argument.
     108 * @param a2   Second argument.
     109 * @param a3   Third argument.
     110 * @param a4   Fourth argument.
     111 * @param a5   Fifth argument.
     112 *
     113 * @return EOK if notification was successfully sent.
     114 * @return ENOMEM if the notification IPC message failed to allocate.
     115 * @return EBUSY if the notifications of the given type are
     116 *         currently masked.
     117 * @return ENOENT if the notifications of the given type are
     118 *         currently not subscribed.
     119 *
     120 */
     121int event_notify(event_type_t evno, bool mask, sysarg_t a1, sysarg_t a2,
     122    sysarg_t a3, sysarg_t a4, sysarg_t a5)
     123{
     124        ASSERT(evno < EVENT_END);
     125       
     126        spinlock_lock(&events[evno].lock);
     127       
     128        int ret;
     129       
     130        if (events[evno].answerbox != NULL) {
     131                if (!events[evno].masked) {
     132                        call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     133                       
     134                        if (call) {
     135                                call->flags |= IPC_CALL_NOTIF;
     136                                call->priv = ++events[evno].counter;
     137                               
     138                                IPC_SET_IMETHOD(call->data, events[evno].imethod);
     139                                IPC_SET_ARG1(call->data, a1);
     140                                IPC_SET_ARG2(call->data, a2);
     141                                IPC_SET_ARG3(call->data, a3);
     142                                IPC_SET_ARG4(call->data, a4);
     143                                IPC_SET_ARG5(call->data, a5);
     144                               
     145                                irq_spinlock_lock(&events[evno].answerbox->irq_lock, true);
     146                                list_append(&call->link, &events[evno].answerbox->irq_notifs);
     147                                irq_spinlock_unlock(&events[evno].answerbox->irq_lock, true);
     148                               
     149                                waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST);
     150                               
     151                                if (mask)
     152                                        events[evno].masked = true;
     153                               
     154                                ret = EOK;
     155                        } else
     156                                ret = ENOMEM;
     157                } else
     158                        ret = EBUSY;
     159        } else
     160                ret = ENOENT;
     161       
     162        spinlock_unlock(&events[evno].lock);
     163       
     164        return ret;
     165}
     166
     167/** Subscribe event notifications
     168 *
     169 * @param evno      Event type.
     170 * @param imethod   IPC interface and method to be used for
     171 *                  the notifications.
     172 * @param answerbox Answerbox to send the notifications to.
     173 *
     174 * @return EOK if the subscription was successful.
     175 * @return EEXISTS if the notifications of the given type are
     176 *         already subscribed.
     177 *
     178 */
    63179static int event_subscribe(event_type_t evno, sysarg_t imethod,
    64180    answerbox_t *answerbox)
    65181{
    66         if (evno >= EVENT_END)
    67                 return ELIMIT;
     182        ASSERT(evno < EVENT_END);
    68183       
    69184        spinlock_lock(&events[evno].lock);
     
    75190                events[evno].imethod = imethod;
    76191                events[evno].counter = 0;
     192                events[evno].masked = false;
    77193                res = EOK;
    78194        } else
     
    84200}
    85201
     202/** Unmask event notifications
     203 *
     204 * @param evno Event type to unmask.
     205 *
     206 */
     207static void event_unmask(event_type_t evno)
     208{
     209        ASSERT(evno < EVENT_END);
     210       
     211        spinlock_lock(&events[evno].lock);
     212        events[evno].masked = false;
     213        event_callback_t callback = events[evno].unmask_callback;
     214        spinlock_unlock(&events[evno].lock);
     215       
     216        /*
     217         * Check if there is an unmask callback
     218         * function defined for this event.
     219         */
     220        if (callback != NULL)
     221                callback();
     222}
     223
     224/** Event notification syscall wrapper
     225 *
     226 * @param evno    Event type to subscribe.
     227 * @param imethod IPC interface and method to be used for
     228 *                the notifications.
     229 *
     230 * @return EOK on success.
     231 * @return ELIMIT on unknown event type.
     232 * @return EEXISTS if the notifications of the given type are
     233 *         already subscribed.
     234 *
     235 */
    86236sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod)
    87237{
     238        if (evno >= EVENT_END)
     239                return ELIMIT;
     240       
    88241        return (sysarg_t) event_subscribe((event_type_t) evno, (sysarg_t)
    89242            imethod, &TASK->answerbox);
    90243}
    91244
    92 bool event_is_subscribed(event_type_t evno)
    93 {
    94         bool res;
    95        
    96         ASSERT(evno < EVENT_END);
    97        
    98         spinlock_lock(&events[evno].lock);
    99         res = events[evno].answerbox != NULL;
    100         spinlock_unlock(&events[evno].lock);
    101        
    102         return res;
    103 }
    104 
    105 
    106 void event_cleanup_answerbox(answerbox_t *answerbox)
    107 {
    108         unsigned int i;
    109        
    110         for (i = 0; i < EVENT_END; i++) {
    111                 spinlock_lock(&events[i].lock);
    112                 if (events[i].answerbox == answerbox) {
    113                         events[i].answerbox = NULL;
    114                         events[i].counter = 0;
    115                         events[i].imethod = 0;
    116                 }
    117                 spinlock_unlock(&events[i].lock);
    118         }
    119 }
    120 
    121 void event_notify(event_type_t evno, sysarg_t a1, sysarg_t a2, sysarg_t a3,
    122     sysarg_t a4, sysarg_t a5)
    123 {
    124         ASSERT(evno < EVENT_END);
    125        
    126         spinlock_lock(&events[evno].lock);
    127         if (events[evno].answerbox != NULL) {
    128                 call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    129                 if (call) {
    130                         call->flags |= IPC_CALL_NOTIF;
    131                         call->priv = ++events[evno].counter;
    132                         IPC_SET_IMETHOD(call->data, events[evno].imethod);
    133                         IPC_SET_ARG1(call->data, a1);
    134                         IPC_SET_ARG2(call->data, a2);
    135                         IPC_SET_ARG3(call->data, a3);
    136                         IPC_SET_ARG4(call->data, a4);
    137                         IPC_SET_ARG5(call->data, a5);
    138                        
    139                         irq_spinlock_lock(&events[evno].answerbox->irq_lock, true);
    140                         list_append(&call->link, &events[evno].answerbox->irq_notifs);
    141                         irq_spinlock_unlock(&events[evno].answerbox->irq_lock, true);
    142                        
    143                         waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST);
    144                 }
    145         }
    146         spinlock_unlock(&events[evno].lock);
     245/** Event notification unmask syscall wrapper
     246 *
     247 * Note that currently no tests are performed whether the calling
     248 * task is entitled to unmask the notifications. However, thanks
     249 * to the fact that notification masking is only a performance
     250 * optimization, this has probably no security implications.
     251 *
     252 * @param evno Event type to unmask.
     253 *
     254 * @return EOK on success.
     255 * @return ELIMIT on unknown event type.
     256 *
     257 */
     258sysarg_t sys_event_unmask(sysarg_t evno)
     259{
     260        if (evno >= EVENT_END)
     261                return ELIMIT;
     262       
     263        event_unmask((event_type_t) evno);
     264        return EOK;
    147265}
    148266
  • kernel/generic/src/lib/elf.c

    r8d308b9 r9d47440  
    114114        }
    115115       
    116         /* Inspect all section headers and proccess them. */
     116        /* Inspect all section headers and process them. */
    117117        for (i = 0; i < header->e_shnum; i++) {
    118118                elf_section_header_t *sechdr =
  • kernel/generic/src/main/main.c

    r8d308b9 r9d47440  
    118118#endif
    119119
    120 #define CONFIG_STACK_SIZE  ((1 << STACK_FRAMES) * STACK_SIZE)
    121 
    122120/** Main kernel routine for bootstrap CPU.
    123121 *
     
    139137        config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
    140138            hardcoded_kdata_size, PAGE_SIZE);
    141         config.stack_size = CONFIG_STACK_SIZE;
     139        config.stack_size = STACK_SIZE;
    142140       
    143141        /* Initialy the stack is placed just after the kernel */
     
    165163       
    166164        context_save(&ctx);
    167         context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
    168             THREAD_STACK_SIZE);
     165        context_set(&ctx, FADDR(main_bsp_separated_stack),
     166            config.stack_base, STACK_SIZE);
    169167        context_restore(&ctx);
    170168        /* not reached */
     
    323321        context_save(&CPU->saved_context);
    324322        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
    325             (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     323            (uintptr_t) CPU->stack, STACK_SIZE);
    326324        context_restore(&CPU->saved_context);
    327325        /* not reached */
  • kernel/generic/src/main/uinit.c

    r8d308b9 r9d47440  
    3333/**
    3434 * @file
    35  * @brief       Userspace bootstrap thread.
     35 * @brief Userspace bootstrap thread.
    3636 *
    3737 * This file contains uinit kernel thread wich is used to start every
     
    4040 * @see SYS_THREAD_CREATE
    4141 */
    42  
     42
    4343#include <main/uinit.h>
    4444#include <typedefs.h>
     
    4848#include <arch.h>
    4949#include <udebug/udebug.h>
    50 
    5150
    5251/** Thread used to bring up userspace thread.
     
    5857{
    5958        uspace_arg_t uarg;
    60 
     59       
    6160        /*
    6261         * So far, we don't have a use for joining userspace threads so we
     
    6867         */
    6968        thread_detach(THREAD);
    70 
     69       
    7170#ifdef CONFIG_UDEBUG
    7271        udebug_stoppable_end();
     
    7877        uarg.uspace_thread_function = NULL;
    7978        uarg.uspace_thread_arg = NULL;
    80 
     79       
    8180        free((uspace_arg_t *) arg);
    8281       
  • kernel/generic/src/mm/as.c

    r8d308b9 r9d47440  
    302302         * We don't want any area to have conflicts with NULL page.
    303303         */
    304         if (overlaps(addr, count << PAGE_WIDTH, (uintptr_t) NULL, PAGE_SIZE))
     304        if (overlaps(addr, P2SZ(count), (uintptr_t) NULL, PAGE_SIZE))
    305305                return false;
    306306       
     
    329329                        mutex_lock(&area->lock);
    330330                       
    331                         if (overlaps(addr, count << PAGE_WIDTH,
    332                             area->base, area->pages << PAGE_WIDTH)) {
     331                        if (overlaps(addr, P2SZ(count), area->base,
     332                            P2SZ(area->pages))) {
    333333                                mutex_unlock(&area->lock);
    334334                                return false;
     
    346346                        mutex_lock(&area->lock);
    347347                       
    348                         if (overlaps(addr, count << PAGE_WIDTH,
    349                             area->base, area->pages << PAGE_WIDTH)) {
     348                        if (overlaps(addr, P2SZ(count), area->base,
     349                            P2SZ(area->pages))) {
    350350                                mutex_unlock(&area->lock);
    351351                                return false;
     
    366366                mutex_lock(&area->lock);
    367367               
    368                 if (overlaps(addr, count << PAGE_WIDTH,
    369                     area->base, area->pages << PAGE_WIDTH)) {
     368                if (overlaps(addr, P2SZ(count), area->base,
     369                    P2SZ(area->pages))) {
    370370                        mutex_unlock(&area->lock);
    371371                        return false;
     
    380380         */
    381381        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    382                 return !overlaps(addr, count << PAGE_WIDTH,
    383                     KERNEL_ADDRESS_SPACE_START,
     382                return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
    384383                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
    385384        }
     
    474473       
    475474        btree_node_t *leaf;
    476         as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
     475        as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va,
     476            &leaf);
    477477        if (area) {
    478478                /* va is the base address of an address space area */
     
    482482       
    483483        /*
    484          * Search the leaf node and the righmost record of its left neighbour
     484         * Search the leaf node and the rightmost record of its left neighbour
    485485         * to find out whether this is a miss or va belongs to an address
    486486         * space area found there.
     
    494494               
    495495                mutex_lock(&area->lock);
    496                
     496
    497497                if ((area->base <= va) &&
    498                     (va < area->base + (area->pages << PAGE_WIDTH)))
     498                    (va <= area->base + (P2SZ(area->pages) - 1)))
    499499                        return area;
    500500               
     
    506506         * Because of its position in the B+tree, it must have base < va.
    507507         */
    508         btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf);
     508        btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree,
     509            leaf);
    509510        if (lnode) {
    510511                area = (as_area_t *) lnode->value[lnode->keys - 1];
     
    512513                mutex_lock(&area->lock);
    513514               
    514                 if (va < area->base + (area->pages << PAGE_WIDTH))
     515                if (va <= area->base + (P2SZ(area->pages) - 1))
    515516                        return area;
    516517               
     
    577578       
    578579        if (pages < area->pages) {
    579                 uintptr_t start_free = area->base + (pages << PAGE_WIDTH);
     580                uintptr_t start_free = area->base + P2SZ(pages);
    580581               
    581582                /*
     
    590591                 */
    591592                ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid,
    592                     area->base + (pages << PAGE_WIDTH), area->pages - pages);
     593                    area->base + P2SZ(pages), area->pages - pages);
    593594               
    594595                /*
     
    613614                                size_t i = 0;
    614615                               
    615                                 if (overlaps(ptr, size << PAGE_WIDTH, area->base,
    616                                     pages << PAGE_WIDTH)) {
     616                                if (overlaps(ptr, P2SZ(size), area->base,
     617                                    P2SZ(pages))) {
    617618                                       
    618                                         if (ptr + (size << PAGE_WIDTH) <= start_free) {
     619                                        if (ptr + P2SZ(size) <= start_free) {
    619620                                                /*
    620621                                                 * The whole interval fits
     
    647648                               
    648649                                for (; i < size; i++) {
    649                                         pte_t *pte = page_mapping_find(as, ptr +
    650                                             (i << PAGE_WIDTH));
     650                                        pte_t *pte = page_mapping_find(as,
     651                                            ptr + P2SZ(i));
    651652                                       
    652653                                        ASSERT(pte);
     
    657658                                            (area->backend->frame_free)) {
    658659                                                area->backend->frame_free(area,
    659                                                     ptr + (i << PAGE_WIDTH),
     660                                                    ptr + P2SZ(i),
    660661                                                    PTE_GET_FRAME(pte));
    661662                                        }
    662663                                       
    663                                         page_mapping_remove(as, ptr +
    664                                             (i << PAGE_WIDTH));
     664                                        page_mapping_remove(as, ptr + P2SZ(i));
    665665                                }
    666666                        }
     
    671671                 */
    672672               
    673                 tlb_invalidate_pages(as->asid, area->base + (pages << PAGE_WIDTH),
     673                tlb_invalidate_pages(as->asid, area->base + P2SZ(pages),
    674674                    area->pages - pages);
    675675               
     
    677677                 * Invalidate software translation caches (e.g. TSB on sparc64).
    678678                 */
    679                 as_invalidate_translation_cache(as, area->base +
    680                     (pages << PAGE_WIDTH), area->pages - pages);
     679                as_invalidate_translation_cache(as, area->base + P2SZ(pages),
     680                    area->pages - pages);
    681681                tlb_shootdown_finalize(ipl);
    682682               
     
    797797                       
    798798                        for (size = 0; size < (size_t) node->value[i]; size++) {
    799                                 pte_t *pte =
    800                                     page_mapping_find(as, ptr + (size << PAGE_WIDTH));
     799                                pte_t *pte = page_mapping_find(as,
     800                                     ptr + P2SZ(size));
    801801                               
    802802                                ASSERT(pte);
     
    807807                                    (area->backend->frame_free)) {
    808808                                        area->backend->frame_free(area,
    809                                             ptr + (size << PAGE_WIDTH), PTE_GET_FRAME(pte));
     809                                            ptr + P2SZ(size),
     810                                            PTE_GET_FRAME(pte));
    810811                                }
    811812                               
    812                                 page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
     813                                page_mapping_remove(as, ptr + P2SZ(size));
    813814                        }
    814815                }
     
    897898        }
    898899       
    899         size_t src_size = src_area->pages << PAGE_WIDTH;
     900        size_t src_size = P2SZ(src_area->pages);
    900901        unsigned int src_flags = src_area->flags;
    901902        mem_backend_t *src_backend = src_area->backend;
     
    10941095        for (cur = area->used_space.leaf_head.next;
    10951096            cur != &area->used_space.leaf_head; cur = cur->next) {
    1096                 btree_node_t *node
    1097                     = list_get_instance(cur, btree_node_t, leaf_link);
     1097                btree_node_t *node = list_get_instance(cur, btree_node_t,
     1098                    leaf_link);
    10981099                btree_key_t i;
    10991100               
     
    11031104                       
    11041105                        for (size = 0; size < (size_t) node->value[i]; size++) {
    1105                                 pte_t *pte =
    1106                                     page_mapping_find(as, ptr + (size << PAGE_WIDTH));
     1106                                pte_t *pte = page_mapping_find(as,
     1107                                    ptr + P2SZ(size));
    11071108                               
    11081109                                ASSERT(pte);
     
    11131114                               
    11141115                                /* Remove old mapping */
    1115                                 page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
     1116                                page_mapping_remove(as, ptr + P2SZ(size));
    11161117                        }
    11171118                }
     
    11591160                               
    11601161                                /* Insert the new mapping */
    1161                                 page_mapping_insert(as, ptr + (size << PAGE_WIDTH),
     1162                                page_mapping_insert(as, ptr + P2SZ(size),
    11621163                                    old_frame[frame_idx++], page_flags);
    11631164                               
     
    14811482       
    14821483        if (src_area) {
    1483                 size = src_area->pages << PAGE_WIDTH;
     1484                size = P2SZ(src_area->pages);
    14841485                mutex_unlock(&src_area->lock);
    14851486        } else
     
    15361537                if (page >= right_pg) {
    15371538                        /* Do nothing. */
    1538                 } else if (overlaps(page, count << PAGE_WIDTH, left_pg,
    1539                     left_cnt << PAGE_WIDTH)) {
     1539                } else if (overlaps(page, P2SZ(count), left_pg,
     1540                    P2SZ(left_cnt))) {
    15401541                        /* The interval intersects with the left interval. */
    15411542                        return false;
    1542                 } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
    1543                     right_cnt << PAGE_WIDTH)) {
     1543                } else if (overlaps(page, P2SZ(count), right_pg,
     1544                    P2SZ(right_cnt))) {
    15441545                        /* The interval intersects with the right interval. */
    15451546                        return false;
    1546                 } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
    1547                     (page + (count << PAGE_WIDTH) == right_pg)) {
     1547                } else if ((page == left_pg + P2SZ(left_cnt)) &&
     1548                    (page + P2SZ(count) == right_pg)) {
    15481549                        /*
    15491550                         * The interval can be added by merging the two already
     
    15531554                        btree_remove(&area->used_space, right_pg, leaf);
    15541555                        goto success;
    1555                 } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
     1556                } else if (page == left_pg + P2SZ(left_cnt)) {
    15561557                        /*
    15571558                         * The interval can be added by simply growing the left
     
    15601561                        node->value[node->keys - 1] += count;
    15611562                        goto success;
    1562                 } else if (page + (count << PAGE_WIDTH) == right_pg) {
     1563                } else if (page + P2SZ(count) == right_pg) {
    15631564                        /*
    15641565                         * The interval can be addded by simply moving base of
     
    15871588                 */
    15881589               
    1589                 if (overlaps(page, count << PAGE_WIDTH, right_pg,
    1590                     right_cnt << PAGE_WIDTH)) {
     1590                if (overlaps(page, P2SZ(count), right_pg, P2SZ(right_cnt))) {
    15911591                        /* The interval intersects with the right interval. */
    15921592                        return false;
    1593                 } else if (page + (count << PAGE_WIDTH) == right_pg) {
     1593                } else if (page + P2SZ(count) == right_pg) {
    15941594                        /*
    15951595                         * The interval can be added by moving the base of the
     
    16261626                if (page < left_pg) {
    16271627                        /* Do nothing. */
    1628                 } else if (overlaps(page, count << PAGE_WIDTH, left_pg,
    1629                     left_cnt << PAGE_WIDTH)) {
     1628                } else if (overlaps(page, P2SZ(count), left_pg,
     1629                    P2SZ(left_cnt))) {
    16301630                        /* The interval intersects with the left interval. */
    16311631                        return false;
    1632                 } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
    1633                     right_cnt << PAGE_WIDTH)) {
     1632                } else if (overlaps(page, P2SZ(count), right_pg,
     1633                    P2SZ(right_cnt))) {
    16341634                        /* The interval intersects with the right interval. */
    16351635                        return false;
    1636                 } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
    1637                     (page + (count << PAGE_WIDTH) == right_pg)) {
     1636                } else if ((page == left_pg + P2SZ(left_cnt)) &&
     1637                    (page + P2SZ(count) == right_pg)) {
    16381638                        /*
    16391639                         * The interval can be added by merging the two already
     
    16431643                        btree_remove(&area->used_space, right_pg, node);
    16441644                        goto success;
    1645                 } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
     1645                } else if (page == left_pg + P2SZ(left_cnt)) {
    16461646                        /*
    16471647                         * The interval can be added by simply growing the left
     
    16501650                        leaf->value[leaf->keys - 1] += count;
    16511651                        goto success;
    1652                 } else if (page + (count << PAGE_WIDTH) == right_pg) {
     1652                } else if (page + P2SZ(count) == right_pg) {
    16531653                        /*
    16541654                         * The interval can be addded by simply moving base of
     
    16771677                 */
    16781678               
    1679                 if (overlaps(page, count << PAGE_WIDTH, left_pg,
    1680                     left_cnt << PAGE_WIDTH)) {
     1679                if (overlaps(page, P2SZ(count), left_pg, P2SZ(left_cnt))) {
    16811680                        /* The interval intersects with the left interval. */
    16821681                        return false;
    1683                 } else if (left_pg + (left_cnt << PAGE_WIDTH) == page) {
     1682                } else if (left_pg + P2SZ(left_cnt) == page) {
    16841683                        /*
    16851684                         * The interval can be added by growing the left
     
    17161715                         */
    17171716                       
    1718                         if (overlaps(page, count << PAGE_WIDTH, left_pg,
    1719                             left_cnt << PAGE_WIDTH)) {
     1717                        if (overlaps(page, P2SZ(count), left_pg,
     1718                            P2SZ(left_cnt))) {
    17201719                                /*
    17211720                                 * The interval intersects with the left
     
    17231722                                 */
    17241723                                return false;
    1725                         } else if (overlaps(page, count << PAGE_WIDTH, right_pg,
    1726                             right_cnt << PAGE_WIDTH)) {
     1724                        } else if (overlaps(page, P2SZ(count), right_pg,
     1725                            P2SZ(right_cnt))) {
    17271726                                /*
    17281727                                 * The interval intersects with the right
     
    17301729                                 */
    17311730                                return false;
    1732                         } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
    1733                             (page + (count << PAGE_WIDTH) == right_pg)) {
     1731                        } else if ((page == left_pg + P2SZ(left_cnt)) &&
     1732                            (page + P2SZ(count) == right_pg)) {
    17341733                                /*
    17351734                                 * The interval can be added by merging the two
     
    17391738                                btree_remove(&area->used_space, right_pg, leaf);
    17401739                                goto success;
    1741                         } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
     1740                        } else if (page == left_pg + P2SZ(left_cnt)) {
    17421741                                /*
    17431742                                 * The interval can be added by simply growing
     
    17461745                                leaf->value[i - 1] += count;
    17471746                                goto success;
    1748                         } else if (page + (count << PAGE_WIDTH) == right_pg) {
     1747                        } else if (page + P2SZ(count) == right_pg) {
    17491748                                /*
    17501749                                 * The interval can be addded by simply moving
     
    18121811                        for (i = 0; i < leaf->keys; i++) {
    18131812                                if (leaf->key[i] == page) {
    1814                                         leaf->key[i] += count << PAGE_WIDTH;
     1813                                        leaf->key[i] += P2SZ(count);
    18151814                                        leaf->value[i] -= count;
    18161815                                        goto success;
     
    18221821        }
    18231822       
    1824         btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space, leaf);
     1823        btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space,
     1824            leaf);
    18251825        if ((node) && (page < leaf->key[0])) {
    18261826                uintptr_t left_pg = node->key[node->keys - 1];
    18271827                size_t left_cnt = (size_t) node->value[node->keys - 1];
    18281828               
    1829                 if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
    1830                     count << PAGE_WIDTH)) {
    1831                         if (page + (count << PAGE_WIDTH) ==
    1832                             left_pg + (left_cnt << PAGE_WIDTH)) {
     1829                if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) {
     1830                        if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) {
    18331831                                /*
    18341832                                 * The interval is contained in the rightmost
     
    18391837                                node->value[node->keys - 1] -= count;
    18401838                                goto success;
    1841                         } else if (page + (count << PAGE_WIDTH) <
    1842                             left_pg + (left_cnt << PAGE_WIDTH)) {
     1839                        } else if (page + P2SZ(count) <
     1840                            left_pg + P2SZ(left_cnt)) {
     1841                                size_t new_cnt;
     1842
    18431843                                /*
    18441844                                 * The interval is contained in the rightmost
     
    18481848                                 * new interval.
    18491849                                 */
    1850                                 size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
    1851                                     (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
     1850                                new_cnt = ((left_pg + P2SZ(left_cnt)) -
     1851                                    (page + P2SZ(count))) >> PAGE_WIDTH;
    18521852                                node->value[node->keys - 1] -= count + new_cnt;
    18531853                                btree_insert(&area->used_space, page +
    1854                                     (count << PAGE_WIDTH), (void *) new_cnt, leaf);
     1854                                    P2SZ(count), (void *) new_cnt, leaf);
    18551855                                goto success;
    18561856                        }
     
    18651865                size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
    18661866               
    1867                 if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
    1868                     count << PAGE_WIDTH)) {
    1869                         if (page + (count << PAGE_WIDTH) ==
    1870                             left_pg + (left_cnt << PAGE_WIDTH)) {
     1867                if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) {
     1868                        if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) {
    18711869                                /*
    18721870                                 * The interval is contained in the rightmost
     
    18761874                                leaf->value[leaf->keys - 1] -= count;
    18771875                                goto success;
    1878                         } else if (page + (count << PAGE_WIDTH) < left_pg +
    1879                             (left_cnt << PAGE_WIDTH)) {
     1876                        } else if (page + P2SZ(count) < left_pg +
     1877                            P2SZ(left_cnt)) {
     1878                                size_t new_cnt;
     1879
    18801880                                /*
    18811881                                 * The interval is contained in the rightmost
     
    18851885                                 * interval.
    18861886                                 */
    1887                                 size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
    1888                                     (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
     1887                                new_cnt = ((left_pg + P2SZ(left_cnt)) -
     1888                                    (page + P2SZ(count))) >> PAGE_WIDTH;
    18891889                                leaf->value[leaf->keys - 1] -= count + new_cnt;
    18901890                                btree_insert(&area->used_space, page +
    1891                                     (count << PAGE_WIDTH), (void *) new_cnt, leaf);
     1891                                    P2SZ(count), (void *) new_cnt, leaf);
    18921892                                goto success;
    18931893                        }
     
    19111911                         * to (i - 1) and i.
    19121912                         */
    1913                         if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
    1914                             count << PAGE_WIDTH)) {
    1915                                 if (page + (count << PAGE_WIDTH) ==
    1916                                     left_pg + (left_cnt << PAGE_WIDTH)) {
     1913                        if (overlaps(left_pg, P2SZ(left_cnt), page,
     1914                            P2SZ(count))) {
     1915                                if (page + P2SZ(count) ==
     1916                                    left_pg + P2SZ(left_cnt)) {
    19171917                                        /*
    19181918                                         * The interval is contained in the
     
    19231923                                        leaf->value[i - 1] -= count;
    19241924                                        goto success;
    1925                                 } else if (page + (count << PAGE_WIDTH) <
    1926                                     left_pg + (left_cnt << PAGE_WIDTH)) {
     1925                                } else if (page + P2SZ(count) <
     1926                                    left_pg + P2SZ(left_cnt)) {
     1927                                        size_t new_cnt;
     1928
    19271929                                        /*
    19281930                                         * The interval is contained in the
     
    19321934                                         * also inserting a new interval.
    19331935                                         */
    1934                                         size_t new_cnt = ((left_pg +
    1935                                             (left_cnt << PAGE_WIDTH)) -
    1936                                             (page + (count << PAGE_WIDTH))) >>
     1936                                        new_cnt = ((left_pg + P2SZ(left_cnt)) -
     1937                                            (page + P2SZ(count))) >>
    19371938                                            PAGE_WIDTH;
    19381939                                        leaf->value[i - 1] -= count + new_cnt;
    19391940                                        btree_insert(&area->used_space, page +
    1940                                             (count << PAGE_WIDTH), (void *) new_cnt,
     1941                                            P2SZ(count), (void *) new_cnt,
    19411942                                            leaf);
    19421943                                        goto success;
     
    20342035                btree_key_t i;
    20352036                for (i = 0; (ret == 0) && (i < node->keys); i++) {
     2037                        uintptr_t addr;
     2038
    20362039                        as_area_t *area = (as_area_t *) node->value[i];
    20372040                       
    20382041                        mutex_lock(&area->lock);
    20392042                       
    2040                         uintptr_t addr =
    2041                             ALIGN_UP(area->base + (area->pages << PAGE_WIDTH),
     2043                        addr = ALIGN_UP(area->base + P2SZ(area->pages),
    20422044                            PAGE_SIZE);
    20432045                       
     
    20982100                       
    20992101                        info[area_idx].start_addr = area->base;
    2100                         info[area_idx].size = FRAMES2SIZE(area->pages);
     2102                        info[area_idx].size = P2SZ(area->pages);
    21012103                        info[area_idx].flags = area->flags;
    21022104                        ++area_idx;
     
    21362138                            " (%p - %p)\n", area, (void *) area->base,
    21372139                            area->pages, (void *) area->base,
    2138                             (void *) (area->base + FRAMES2SIZE(area->pages)));
     2140                            (void *) (area->base + P2SZ(area->pages)));
    21392141                        mutex_unlock(&area->lock);
    21402142                }
  • kernel/generic/src/mm/backend_anon.c

    r8d308b9 r9d47440  
    5050#include <typedefs.h>
    5151#include <align.h>
     52#include <memstr.h>
    5253#include <arch.h>
    5354
  • kernel/generic/src/printf/vprintf.c

    r8d308b9 r9d47440  
    4141#include <typedefs.h>
    4242#include <str.h>
    43 
    44 IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(printf_lock, "*printf_lock");
    4543
    4644static int vprintf_str_write(const char *str, size_t size, void *data)
     
    9391        };
    9492       
    95         irq_spinlock_lock(&printf_lock, true);
    96         int ret = printf_core(fmt, &ps, ap);
    97         irq_spinlock_unlock(&printf_lock, true);
    98        
    99         return ret;
     93        return printf_core(fmt, &ps, ap);
    10094}
    10195
  • kernel/generic/src/proc/program.c

    r8d308b9 r9d47440  
    5454#include <proc/program.h>
    5555
    56 #ifndef LOADED_PROG_STACK_PAGES_NO
    57 #define LOADED_PROG_STACK_PAGES_NO 1
    58 #endif
    59 
    6056/**
    6157 * Points to the binary image used as the program loader. All non-initial
     
    9086       
    9187        /*
    92          * Create the data address space area.
     88         * Create the stack address space area.
    9389         */
    9490        as_area_t *area = as_area_create(as,
    9591            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
    96             LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS,
    97             AS_AREA_ATTR_NONE, &anon_backend, NULL);
     92            STACK_SIZE, USTACK_ADDRESS, AS_AREA_ATTR_NONE,
     93            &anon_backend, NULL);
    9894        if (!area)
    9995                return ENOMEM;
  • kernel/generic/src/proc/scheduler.c

    r8d308b9 r9d47440  
    376376        context_save(&CPU->saved_context);
    377377        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack),
    378             (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     378            (uintptr_t) CPU->stack, STACK_SIZE);
    379379        context_restore(&CPU->saved_context);
    380380       
  • kernel/generic/src/proc/task.c

    r8d308b9 r9d47440  
    190190        str_cpy(task->name, TASK_NAME_BUFLEN, name);
    191191       
    192         task->context = CONTEXT;
     192        task->container = CONTAINER;
    193193        task->capabilities = 0;
    194194        task->ucycles = 0;
     
    211211       
    212212        if ((ipc_phone_0) &&
    213             (context_check(ipc_phone_0->task->context, task->context)))
     213            (container_check(ipc_phone_0->task->container, task->container)))
    214214                ipc_phone_connect(&task->phones[0], ipc_phone_0);
    215215       
     
    534534        */
    535535        if (notify) {
    536                 if (event_is_subscribed(EVENT_FAULT)) {
    537                         /* Notify the subscriber that a fault occurred. */
    538                         event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
    539                             UPPER32(TASK->taskid), (sysarg_t) THREAD);
    540                
     536                /* Notify the subscriber that a fault occurred. */
     537                if (event_notify_3(EVENT_FAULT, false, LOWER32(TASK->taskid),
     538                    UPPER32(TASK->taskid), (sysarg_t) THREAD) == EOK) {
    541539#ifdef CONFIG_UDEBUG
    542540                        /* Wait for a debugging session. */
     
    586584                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %10p %10p"
    587585                    " %9" PRIu64 "%c %9" PRIu64 "%c\n", task->taskid,
    588                     task->name, task->context, task, task->as,
     586                    task->name, task->container, task, task->as,
    589587                    ucycles, usuffix, kcycles, ksuffix);
    590588#endif
     
    597595        else
    598596                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %18p %18p\n",
    599                     task->taskid, task->name, task->context, task, task->as);
     597                    task->taskid, task->name, task->container, task, task->as);
    600598#endif
    601599       
     
    627625                printf("[id    ] [threads] [calls] [callee\n");
    628626        else
    629                 printf("[id    ] [name        ] [ctx] [address ] [as      ]"
     627                printf("[id    ] [name        ] [ctn] [address ] [as      ]"
    630628                    " [ucycles ] [kcycles ]\n");
    631629#endif
     
    636634                    " [callee\n");
    637635        else
    638                 printf("[id    ] [name        ] [ctx] [address         ]"
     636                printf("[id    ] [name        ] [ctn] [address         ]"
    639637                    " [as              ]\n");
    640638#endif
  • kernel/generic/src/proc/the.c

    r8d308b9 r9d47440  
    5858        the->task = NULL;
    5959        the->as = NULL;
     60        the->magic = MAGIC;
    6061}
    6162
     
    7071NO_TRACE void the_copy(the_t *src, the_t *dst)
    7172{
     73        ASSERT(src->magic == MAGIC);
    7274        *dst = *src;
    7375}
  • kernel/generic/src/proc/thread.c

    r8d308b9 r9d47440  
    6868#include <errno.h>
    6969
    70 
    71 #ifndef LOADED_PROG_STACK_PAGES_NO
    72 #define LOADED_PROG_STACK_PAGES_NO 1
    73 #endif
    74 
    75 
    7670/** Thread states */
    7771const char *thread_states[] = {
     
    300294       
    301295        /* Not needed, but good for debugging */
    302         memsetb(thread->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 0);
     296        memsetb(thread->kstack, STACK_SIZE, 0);
    303297       
    304298        irq_spinlock_lock(&tidlock, true);
     
    308302        context_save(&thread->saved_context);
    309303        context_set(&thread->saved_context, FADDR(cushion),
    310             (uintptr_t) thread->kstack, THREAD_STACK_SIZE);
     304            (uintptr_t) thread->kstack, STACK_SIZE);
    311305       
    312306        the_initialize((the_t *) thread->kstack);
     
    605599                printf("%-8" PRIu64 " %-14s %10p %-8s %10p %-5" PRIu32 "\n",
    606600                    thread->tid, name, thread, thread_states[thread->state],
    607                     thread->task, thread->task->context);
     601                    thread->task, thread->task->container);
    608602#endif
    609603       
     
    617611                printf("%-8" PRIu64 " %-14s %18p %-8s %18p %-5" PRIu32 "\n",
    618612                    thread->tid, name, thread, thread_states[thread->state],
    619                     thread->task, thread->task->context);
     613                    thread->task, thread->task->container);
    620614#endif
    621615       
     
    658652        else
    659653                printf("[id    ] [name        ] [address ] [state ] [task    ]"
    660                     " [ctx]\n");
     654                    " [ctn]\n");
    661655#endif
    662656       
     
    667661        } else
    668662                printf("[id    ] [name        ] [address         ] [state ]"
    669                     " [task            ] [ctx]\n");
     663                    " [task            ] [ctn]\n");
    670664#endif
    671665       
  • kernel/generic/src/security/cap.c

    r8d308b9 r9d47440  
    9292        task_t *task = task_find_by_id(taskid);
    9393       
    94         if ((!task) || (!context_check(CONTEXT, task->context))) {
     94        if ((!task) || (!container_check(CONTAINER, task->container))) {
    9595                irq_spinlock_unlock(&tasks_lock, true);
    9696                return (sysarg_t) ENOENT;
     
    121121       
    122122        task_t *task = task_find_by_id(taskid);
    123         if ((!task) || (!context_check(CONTEXT, task->context))) {
     123        if ((!task) || (!container_check(CONTAINER, task->container))) {
    124124                irq_spinlock_unlock(&tasks_lock, true);
    125125                return (sysarg_t) ENOENT;
  • kernel/generic/src/synch/spinlock.c

    r8d308b9 r9d47440  
    9696                 * run in a simulator) that caused problems with both
    9797                 * printf_lock and the framebuffer lock.
    98                  *
    9998                 */
    10099                if (lock->name[0] == '*')
  • kernel/generic/src/syscall/syscall.c

    r8d308b9 r9d47440  
    161161        /* Event notification syscalls. */
    162162        (syshandler_t) sys_event_subscribe,
     163        (syshandler_t) sys_event_unmask,
    163164       
    164165        /* Capabilities related syscalls. */
Note: See TracChangeset for help on using the changeset viewer.