Changeset cfa70add in mainline


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

sparc64 update.

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

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/loader/Makefile

    r002e613 rcfa70add  
    5858
    5959COMPONENTS = \
    60         $(KERNELDIR)/kernel.bin
     60        $(KERNELDIR)/kernel.bin \
     61        $(USPACEDIR)/ns/ns \
     62        $(USPACEDIR)/init/init \
     63        $(USPACEDIR)/fb/fb \
     64        $(USPACEDIR)/kbd/kbd \
     65        $(USPACEDIR)/console/console \
     66        $(USPACEDIR)/tetris/tetris \
     67        $(USPACEDIR)/ipcc/ipcc \
     68        $(USPACEDIR)/klog/klog
    6169
    6270OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
  • kernel/arch/sparc64/include/asm.h

    r002e613 rcfa70add  
    331331extern void write_to_ig_g6(uint64_t val);
    332332
    333 extern void switch_to_userspace(uint64_t pc, uint64_t sp);
     333extern void switch_to_userspace(uint64_t pc, uint64_t sp, uint64_t uarg);
    334334
    335335#endif
  • kernel/arch/sparc64/include/mm/as.h

    r002e613 rcfa70add  
    4343#define USER_ADDRESS_SPACE_END_ARCH             (unsigned long) 0xffffffffffffffff
    4444
    45 #define USTACK_ADDRESS_ARCH     (0x7fffffffffffffff-(PAGE_SIZE-1))
     45#define USTACK_ADDRESS_ARCH     (0xffffffffffffffffULL-(PAGE_SIZE-1))
    4646
    4747extern void as_arch_init(void);
  • kernel/arch/sparc64/include/mm/tlb.h

    r002e613 rcfa70add  
    180180static inline void mmu_secondary_context_write(uint64_t v)
    181181{
    182         asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v);
     182        asi_u64_write(ASI_DMMU, VA_SECONDARY_CONTEXT_REG, v);
    183183        flush();
    184184}
  • kernel/arch/sparc64/include/trap/mmu.h

    r002e613 rcfa70add  
    128128.macro HANDLE_MMU_TRAPS_FROM_SPILL_OR_FILL
    129129        rdpr %tl, %g1
    130         dec %g1
    131         brz %g1, 0f                     ! if TL was 1, skip
     130        sub %g1, 1, %g2
     131        brz %g2, 0f                     ! if TL was 1, skip
    132132        nop
    133         wrpr %g1, 0, %tl                ! TL--
    134         rdpr %tt, %g2
    135         cmp %g2, TT_SPILL_1_NORMAL
    136         be 0f                           ! trap from spill_1_normal
    137         cmp %g2, TT_FILL_1_NORMAL
    138         be 0f                           ! trap from fill_1_normal
    139         inc %g1
    140         wrpr %g1, 0, %tl                ! another trap, TL++
     133        wrpr %g2, 0, %tl                ! TL--
     134        rdpr %tt, %g3
     135        cmp %g3, TT_SPILL_1_NORMAL
     136        be 0f                           ! trap from spill_1_normal?
     137        cmp %g3, TT_FILL_1_NORMAL
     138        bne,a 0f                        ! trap from fill_1_normal? (negated condition)
     139        wrpr %g1, 0, %tl                ! TL++
    1411400:
    142141.endm
  • kernel/arch/sparc64/src/asm.S

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

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

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

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

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

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

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

    r002e613 rcfa70add  
    221221         * Create the main thread.
    222222         */
    223         t1 = thread_create(uinit, kernel_uarg, task, 0, "uinit");
     223        t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit");
    224224        ASSERT(t1);
    225225       
  • uspace/libc/arch/sparc64/_link.ld.in

    r002e613 rcfa70add  
    88
    99SECTIONS {
    10         . = 0x1000;
     10        . = 0x2000;
    1111
    12         .init ALIGN(0x1000) : SUBALIGN(0x1000) {
     12        .init ALIGN(0x2000) : SUBALIGN(0x2000) {
    1313                *(.init);
    1414        } :text
     
    1818        } :text
    1919       
    20         .data ALIGN(0x1000) : SUBALIGN(0x1000) {
     20        .got ALIGN(0x2000) : SUBALIGN(0x2000) {
     21                 _gp = .;
     22                 *(.got*);
     23        } :data
     24        .data ALIGN(0x2000) : SUBALIGN(0x2000) {
    2125                *(.data);
    2226                *(.sdata);
     
    3842        } :data
    3943
    40         . = ALIGN(0x1000);
     44        . = ALIGN(0x2000);
    4145        _heap = .;
    4246       
  • uspace/libc/arch/sparc64/include/atomic.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2005 Martin Decky
     2 * Copyright (C) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ATOMIC_H__
    36 #define __sparc64_ATOMIC_H__
     35#ifndef LIBC_sparc64_ATOMIC_H_
     36#define LIBC_sparc64_ATOMIC_H_
     37
     38#include <types.h>
     39
     40/** Atomic add operation.
     41 *
     42 * Use atomic compare and swap operation to atomically add signed value.
     43 *
     44 * @param val Atomic variable.
     45 * @param i Signed value to be added.
     46 *
     47 * @return Value of the atomic variable as it existed before addition.
     48 */
     49static inline long atomic_add(atomic_t *val, int i)
     50{
     51        uint64_t a, b;
     52        volatile uint64_t x = (uint64_t) &val->count;
     53
     54        __asm__ volatile (
     55                "0:\n"
     56                "ldx %0, %1\n"
     57                "add %1, %3, %2\n"
     58                "casx %0, %1, %2\n"
     59                "cmp %1, %2\n"
     60                "bne 0b\n"              /* The operation failed and must be attempted again if a != b. */
     61                "nop\n"
     62                : "=m" (*((uint64_t *)x)), "=r" (a), "=r" (b)
     63                : "r" (i)
     64        );
     65
     66        return a;
     67}
     68
     69static inline long atomic_preinc(atomic_t *val)
     70{
     71        return atomic_add(val, 1) + 1;
     72}
     73
     74static inline long atomic_postinc(atomic_t *val)
     75{
     76        return atomic_add(val, 1);
     77}
     78
     79static inline long atomic_predec(atomic_t *val)
     80{
     81        return atomic_add(val, -1) - 1;
     82}
     83
     84static inline long atomic_postdec(atomic_t *val)
     85{
     86        return atomic_add(val, -1);
     87}
    3788
    3889static inline void atomic_inc(atomic_t *val)
    3990{
     91        (void) atomic_add(val, 1);
    4092}
    4193
    4294static inline void atomic_dec(atomic_t *val)
    4395{
    44 }
    45 
    46 static inline long atomic_postinc(atomic_t *val)
    47 {
    48         atomic_inc(val);
    49         return val->count - 1;
    50 }
    51 
    52 static inline long atomic_postdec(atomic_t *val)
    53 {
    54         atomic_dec(val);
    55         return val->count + 1;
    56 }
    57 
    58 static inline long atomic_preinc(atomic_t *val)
    59 {
    60         atomic_inc(val);
    61         return val->count;
    62 }
    63 
    64 static inline long atomic_predec(atomic_t *val)
    65 {
    66         atomic_dec(val);
    67         return val->count;
     96        (void) atomic_add(val, -1);
    6897}
    6998
  • uspace/libc/arch/sparc64/include/config.h

    r002e613 rcfa70add  
    2727 */
    2828
    29 /** @addtogroup libsparc64
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3636#define LIBC_sparc64_CONFIG_H_
    3737
    38 #define PAGE_WIDTH      12
     38#define PAGE_WIDTH      13
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
    4040
  • uspace/libc/arch/sparc64/include/context_offset.h

    r002e613 rcfa70add  
     1/* This file is automatically generated by gencontext.c. */
    12/* struct context */
     3#define OFFSET_SP       0x0
     4#define OFFSET_PC       0x8
     5#define OFFSET_I0       0x10
     6#define OFFSET_I1       0x18
     7#define OFFSET_I2       0x20
     8#define OFFSET_I3       0x28
     9#define OFFSET_I4       0x30
     10#define OFFSET_I5       0x38
     11#define OFFSET_FP       0x40
     12#define OFFSET_I7       0x48
     13#define OFFSET_L0       0x50
     14#define OFFSET_L1       0x58
     15#define OFFSET_L2       0x60
     16#define OFFSET_L3       0x68
     17#define OFFSET_L4       0x70
     18#define OFFSET_L5       0x78
     19#define OFFSET_L6       0x80
     20#define OFFSET_L7       0x88
     21#define OFFSET_TP       0x90
    222
    3 /** @}
    4  */
  • uspace/libc/arch/sparc64/include/endian.h

    r002e613 rcfa70add  
    2727 */
    2828
    29  /** @addtogroup libcsparc64   
     29/** @addtogroup libcsparc64     
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ENDIAN_H__
    36 #define __sparc64_ENDIAN_H__
     35#ifndef LIBC_sparc64_ENDIAN_H_
     36#define LIBC_sparc64_ENDIAN_H_
    3737
    3838#ifndef __LIBC__ENDIAN_H__
     
    4444#endif
    4545
    46  /** @}
     46/** @}
    4747 */
    48 
  • uspace/libc/arch/sparc64/include/limits.h

    r002e613 rcfa70add  
    3333 */
    3434
    35 #ifndef __sparc64__LIMITS_H__
    36 #define __sparc64__LIMITS_H__
     35#ifndef LIBC_sparc64__LIMITS_H_
     36#define LIBC_sparc64__LIMITS_H_
    3737
    3838#define LONG_MIN MIN_INT64
  • uspace/libc/arch/sparc64/include/psthread.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2006 Martin Decky
     2 * Copyright (C) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __LIBC__sparc64__PSTHREAD_H__
    36 #define __LIBC__sparc64__PSTHREAD_H__
     35#ifndef LIBC_sparc64_PSTHREAD_H_
     36#define LIBC_sparc64_PSTHREAD_H_
    3737
     38#include <libarch/stack.h>
    3839#include <types.h>
     40#include <align.h>
    3941
    40 /* We define our own context_set, because we need to set
    41  * the TLS pointer to the tcb+0x7000
    42  *
    43  * See tls_set in thread.h
     42#define SP_DELTA        STACK_WINDOW_SAVE_AREA_SIZE
     43
     44#ifdef context_set
     45#undef context_set
     46#endif
     47
     48#define context_set(c, _pc, stack, size, ptls)                                                          \
     49        (c)->pc = ((uintptr_t) _pc) - 8;                                                                \
     50        (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);    \
     51        (c)->fp = -STACK_BIAS;                                                                          \
     52        (c)->tp = ptls
     53       
     54/*
     55 * Only save registers that must be preserved across
     56 * function calls.
    4457 */
    45 #define context_set(c, _pc, stack, size, ptls)                  \
    46         (c)->pc = (sysarg_t) (_pc);                             \
    47         (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
    48         (c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t);
    49 
    50 #define SP_DELTA        16
    51 
    5258typedef struct {
    53         uint64_t sp;
    54         uint64_t pc;
    55        
    56         uint64_t tls;
    57 } __attribute__ ((packed)) context_t;
     59        uintptr_t sp;           /* %o6 */
     60        uintptr_t pc;           /* %o7 */
     61        uint64_t i0;
     62        uint64_t i1;
     63        uint64_t i2;
     64        uint64_t i3;
     65        uint64_t i4;
     66        uint64_t i5;
     67        uintptr_t fp;           /* %i6 */
     68        uintptr_t i7;
     69        uint64_t l0;
     70        uint64_t l1;
     71        uint64_t l2;
     72        uint64_t l3;
     73        uint64_t l4;
     74        uint64_t l5;
     75        uint64_t l6;
     76        uint64_t l7;
     77        uint64_t tp;            /* %g7 */
     78} context_t;
    5879
    5980#endif
  • uspace/libc/arch/sparc64/include/stackarg.h

    r002e613 rcfa70add  
    3333 */
    3434
    35 #ifndef __LIBC__STACKARG_H__
    36 #define __LIBC__STACKARG_H__
     35#ifndef LIBC_sparc64_STACKARG_H_
     36#define LIBC_sparc64_STACKARG_H_
    3737
    3838#endif
    3939
    40 
    4140/** @}
    4241 */
  • uspace/libc/arch/sparc64/include/syscall.h

    r002e613 rcfa70add  
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
  • uspace/libc/arch/sparc64/include/thread.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2006 Martin Decky
     2 * Copyright (C) 2006 Ondrej Palkovsky
     3 * Copyright (C) 2006 Jakub Jermar
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup libcsparc64     
     30/** @addtogroup libcsparc64
    3031 * @{
    3132 */
    32 /** @file
     33/**
     34 * @file
     35 * @brief       sparc64 TLS functions.
     36 *
     37 * The implementation is based on the IA-32 implementation which was also
     38 * designed by Sun and is virtually the same, except the TCB is stored in
     39 * %g7 (of the normal set).
    3340 */
    3441
    35 #ifndef __LIBC__sparc64__THREAD_H__
    36 #define __LIBC__sparc64__THREAD_H__
    37 
    38 #define PPC_TP_OFFSET 0x7000
     42#ifndef LIBC_sparc64_THREAD_H_
     43#define LIBC_sparc64_THREAD_H_
    3944
    4045typedef struct {
     46        void *self;
    4147        void *pst_data;
    4248} tcb_t;
     
    4450static inline void __tcb_set(tcb_t *tcb)
    4551{
    46         void *tp = tcb;
    47         tp += PPC_TP_OFFSET + sizeof(tcb_t);
     52        __asm__ volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7");
    4853}
    4954
    50 static inline tcb_t *__tcb_get(void)
     55static inline tcb_t * __tcb_get(void)
    5156{
    52         return (tcb_t *)(PPC_TP_OFFSET - sizeof(tcb_t));
     57        void *retval;
     58
     59        __asm__ volatile ("mov %%g7, %0\n" : "=r" (retval));
     60
     61        return retval;
    5362}
    5463
  • uspace/libc/arch/sparc64/include/types.h

    r002e613 rcfa70add  
    3636#define LIBC_sparc64_TYPES_H_
    3737
    38 typedef unsigned int sysarg_t;
    39 typedef unsigned int size_t;
    40 typedef signed int ssize_t;
     38typedef unsigned long sysarg_t;
     39typedef unsigned long size_t;
     40typedef signed long ssize_t;
    4141typedef ssize_t off_t;
    4242
    43 typedef char int8_t;
     43typedef signed char int8_t;
    4444typedef short int int16_t;
    4545typedef int int32_t;
  • uspace/libc/arch/sparc64/src/entry.s

    r002e613 rcfa70add  
    3838#
    3939__entry:
     40        sethi %hi(_gp), %l7
     41        call __main
     42        or %l7, %lo(_gp), %l7
     43        call __io_init
     44        nop
     45        call main
     46        nop
     47        call __exit
     48        nop
    4049
    4150__entry_driver:
     51        sethi %hi(_gp), %l7
     52        call __main
     53        or %l7, %lo(_gp), %l7
     54        call main
     55        nop
     56        call __exit
     57        nop
  • uspace/libc/arch/sparc64/src/psthread.S

    r002e613 rcfa70add  
    11#
    2 # Copyright (C) 2006 Martin Decky
     2# Copyright (C) 2005 Jakub Jermar
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 .text
     29#include <libarch/context_offset.h>
     30
     31/**
     32 * Both context_save_arch() and context_restore_arch() are
     33 * leaf-optimized procedures. This kind of optimization
     34 * is very important and prevents any implicit window
     35 * spill/fill/clean traps in these very core kernel
     36 * functions.
     37 */
     38       
     39.text   
    3040
    3141.global context_save
    3242.global context_restore
    3343
    34 #include <libarch/context_offset.h>
     44.macro CONTEXT_STORE r
     45        stx %sp, [\r + OFFSET_SP]
     46        stx %o7, [\r + OFFSET_PC]
     47        stx %i0, [\r + OFFSET_I0]
     48        stx %i1, [\r + OFFSET_I1]
     49        stx %i2, [\r + OFFSET_I2]
     50        stx %i3, [\r + OFFSET_I3]
     51        stx %i4, [\r + OFFSET_I4]
     52        stx %i5, [\r + OFFSET_I5]
     53        stx %fp, [\r + OFFSET_FP]
     54        stx %i7, [\r + OFFSET_I7]
     55        stx %l0, [\r + OFFSET_L0]
     56        stx %l1, [\r + OFFSET_L1]
     57        stx %l2, [\r + OFFSET_L2]
     58        stx %l3, [\r + OFFSET_L3]
     59        stx %l4, [\r + OFFSET_L4]
     60        stx %l5, [\r + OFFSET_L5]
     61        stx %l6, [\r + OFFSET_L6]
     62        stx %l7, [\r + OFFSET_L7]
     63        stx %g7, [\r + OFFSET_TP]
     64.endm
     65
     66.macro CONTEXT_LOAD r
     67        ldx [\r + OFFSET_SP], %sp
     68        ldx [\r + OFFSET_PC], %o7
     69        ldx [\r + OFFSET_I0], %i0
     70        ldx [\r + OFFSET_I1], %i1
     71        ldx [\r + OFFSET_I2], %i2
     72        ldx [\r + OFFSET_I3], %i3
     73        ldx [\r + OFFSET_I4], %i4
     74        ldx [\r + OFFSET_I5], %i5
     75        ldx [\r + OFFSET_FP], %fp
     76        ldx [\r + OFFSET_I7], %i7
     77        ldx [\r + OFFSET_L0], %l0
     78        ldx [\r + OFFSET_L1], %l1
     79        ldx [\r + OFFSET_L2], %l2
     80        ldx [\r + OFFSET_L3], %l3
     81        ldx [\r + OFFSET_L4], %l4
     82        ldx [\r + OFFSET_L5], %l5
     83        ldx [\r + OFFSET_L6], %l6
     84        ldx [\r + OFFSET_L7], %l7
     85        ldx [\r + OFFSET_TP], %g7
     86.endm
    3587
    3688context_save:
    37 
     89        CONTEXT_STORE %o0
     90        retl
     91        mov 1, %o0              ! context_save_arch returns 1
    3892
    3993context_restore:
     94        #
     95        # Flush all active windows.
     96        # This is essential, because CONTEXT_LOAD overwrites
     97        # %sp of CWP - 1 with the value written to %fp of CWP.
     98        # Flushing all active windows mitigates this problem
     99        # as CWP - 1 becomes the overlap window.
     100        #               
     101        flushw
     102       
     103        CONTEXT_LOAD %o0
     104        retl
     105        xor %o0, %o0, %o0       ! context_restore_arch returns 0
  • uspace/libc/arch/sparc64/src/thread.c

    r002e613 rcfa70add  
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64 sparc64
     30 * @ingroup lc
    3031 * @{
    3132 */
    3233/** @file
     34 *
    3335 */
    3436
     
    4042 * @param data Start of data section
    4143 * @return pointer to tcb_t structure
    42  *
    4344 */
    4445tcb_t * __alloc_tls(void **data, size_t size)
    4546{
    46         tcb_t *result;
     47        tcb_t *tcb;
     48       
     49        *data = malloc(sizeof(tcb_t) + size);
    4750
    48         result = malloc(sizeof(tcb_t) + size);
    49         *data = ((void *)result) + sizeof(tcb_t);
    50         return result;
     51        tcb = (tcb_t *) (*data + size);
     52        tcb->self = tcb;
     53
     54        return tcb;
    5155}
    5256
    5357void __free_tls_arch(tcb_t *tcb, size_t size)
    5458{
    55         free(tcb);
     59        void *start = ((void *)tcb) - size;
     60        free(start);
    5661}
    5762
  • uspace/libc/arch/sparc64/src/thread_entry.s

    r002e613 rcfa70add  
    11#
    2 # Copyright (C) 2006 Martin Decky
     2# Copyright (C) 2006 Jakub Jermar
    33# All rights reserved.
    44#
     
    3535#
    3636__thread_entry:
    37 
     37        sethi %hi(_gp), %l7     
     38        call __thread_main              ! %o0 contains address of uarg
     39        or %l7, %lo(_gp), %l7
     40       
     41        ! not reached
     42       
    3843.end __thread_entry
Note: See TracChangeset for help on using the changeset viewer.