Changeset 83d2d0e in mainline


Ignore:
Timestamp:
2006-03-05T20:28:31Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e1c68e0c
Parents:
bc314be8
Message:

ia64 work.

ivt.S:
Detect userspace stack in heavyweight handler and switch to kernel stack.
Remember the old stack pointer.
As for register stack, kernel stack is assumed still.
Fix alignment issues that showed when STACK_ITEMS was odd.
Fix ld8 instruction that did subtraction of 8 instead of addition of 8.

scheduler.c:
Change before_thread_runs_arch() to calculate address of top of the stack
for the interrupt handler.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • arch/ia64/include/interrupt.h

    rbc314be8 r83d2d0e  
    6060        __address cr_iip;
    6161        __u64 pr;
     62        __address sp;
    6263} __attribute__ ((packed));
    6364
  • arch/ia64/include/register.h

    rbc314be8 r83d2d0e  
    4242#define PSR_RT_MASK     (1<<27)
    4343#define PSR_IT_MASK     0x0000001000000000
     44
     45#define PSR_CPL_SHIFT           32
     46#define PSR_CPL_MASK_SHIFTED    3
    4447
    4548/** Application registers. */
  • arch/ia64/src/ivt.S

    rbc314be8 r83d2d0e  
    3030#include <arch/stack.h>
    3131#include <arch/register.h>
    32 
    33 #define STACK_ITEMS             12
    34 #define STACK_FRAME_SIZE        ((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE)
    35 
    36 #if (STACK_FRAME_SIZE % STACK_ALIGNMENT != 0)
    37 #error Memory stack must be 16-byte aligned.
     32#include <arch/mm/page.h>
     33#include <align.h>
     34
     35#define STACK_ITEMS             13
     36#define STACK_FRAME_SIZE        ALIGN_UP((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT)
     37
     38#if (STACK_ITEMS % 2 == 0)
     39#       define STACK_FRAME_BIAS 8
     40#else
     41#       define STACK_FRAME_BIAS 16
    3842#endif
    3943
     
    7175   
    7276        /*
    73          * Note that r24-r31 from bank0 can be used only as long as PSR.ic = 0.
     77         * Note that r24-r31 from bank 0 can be used only as long as PSR.ic = 0.
    7478         */
    7579        mov r24 = cr.iip
     
    8387       
    8488    /* 3. switch to kernel memory stack */
    85         /* TODO: support interruptions from userspace */
    86         /* assume kernel stack */
    87        
    88         add r31 = -8, r12 ;;
     89        mov r30 = cr.ipsr
     90        shr.u r31 = r12, VRN_SHIFT ;;
     91
     92        /*
     93         * Set p6 to true if the stack register references kernel address space.
     94         * Set p7 to false if the stack register doesn't reference kernel address space.
     95         */
     96        cmp.eq p6, p7 = VRN_KERNEL, r31 ;;
     97       
     98        (p6) shr.u r30 = r30, PSR_CPL_SHIFT ;;
     99        (p6) and r30 = PSR_CPL_MASK_SHIFTED, r30 ;;
     100
     101        /*
     102         * Set p6 to true if the interrupted context executed in kernel mode.
     103         * Set p7 to false if the interrupted context didn't execute in kernel mode.
     104         */
     105        (p6) cmp.eq p6, p7 = r30, r0 ;;
     106       
     107        /*
     108         * Now, p7 is true iff the stack needs to be switched to kernel stack.
     109         */
     110        mov r30 = r12
     111        (p7) mov r12 = R_KSTACK ;;
     112       
     113        add r31 = -STACK_FRAME_BIAS, r12 ;;
    89114        add r12 = -STACK_FRAME_SIZE, r12
    90115
    91116    /* 4. save registers in bank 0 into memory stack */
    92         st8 [r31] = r29, -8 ;;  /* save predicate registers */
    93 
    94         st8 [r31] = r24, -8 ;;  /* save cr.iip */
    95         st8 [r31] = r25, -8 ;;  /* save cr.ipsr */
    96         st8 [r31] = r26, -8 ;;  /* save cr.iipa */
    97         st8 [r31] = r27, -8 ;;  /* save cr.isr */
    98         st8 [r31] = r28, -8     /* save cr.ifa */               
     117        st8 [r31] = r30, -8 ;;          /* save old stack pointer */
     118       
     119        st8 [r31] = r29, -8 ;;          /* save predicate registers */
     120
     121        st8 [r31] = r24, -8 ;;          /* save cr.iip */
     122        st8 [r31] = r25, -8 ;;          /* save cr.ipsr */
     123        st8 [r31] = r26, -8 ;;          /* save cr.iipa */
     124        st8 [r31] = r27, -8 ;;          /* save cr.isr */
     125        st8 [r31] = r28, -8 ;;          /* save cr.ifa */
    99126
    100127    /* 5. RSE switch from interrupted context */
     
    104131        mov r26 = cr.ifs
    105132       
    106         st8 [r31] = r24, -8;;   /* save ar.rsc */
    107         st8 [r31] = r25, -8;;   /* save ar.pfs */
     133        st8 [r31] = r24, -8 ;;  /* save ar.rsc */
     134        st8 [r31] = r25, -8 ;;  /* save ar.pfs */
    108135        st8 [r31] = r26, -8     /* save ar.ifs */
    109136       
     
    121148        st8 [r31] = r27, -8 ;;  /* save ar.rnat */
    122149        st8 [r31] = r28, -8 ;;  /* save ar.bspstore */
    123         st8 [r31] = r29, -8     /* save ar.bsp */
     150        st8 [r31] = r29, -8     /* save ar.bsp */
    124151       
    125152        mov ar.rsc = r24        /* restore RSE's setting */
     
    175202
    176203    /* 18. restore predicate registers from memory stack */
    177         ld8 r29 = [r31] , -8 ;; /* load predicate registers */
     204        ld8 r29 = [r31], +8 ;;  /* load predicate registers */
    178205        mov pr = r29
    179206       
    180207    /* 19. return from interruption */
    181         add r12 = STACK_FRAME_SIZE, r12
     208        ld8 r12 = [r31]         /* load stack pointer */
    182209        rfi ;;
    183210
  • arch/ia64/src/proc/scheduler.c

    rbc314be8 r83d2d0e  
    3131#include <arch.h>
    3232#include <arch/register.h>
     33#include <arch/context.h>
    3334#include <arch/mm/tlb.h>
    3435#include <config.h>
     
    5859                "mov r23 = %0\n"
    5960                "bsw.1\n"
    60                  : : "r" (THREAD->kstack));
     61                 : : "r" (&THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA]));
    6162}
    6263
  • doc/arch/ia64

    rbc314be8 r83d2d0e  
    1212
    1313TOOLCHAIN REQUIREMENTS
    14         o binutils 2.15, 2.16
    15         o gcc 4.0.0
     14        o binutils 2.15, 2.16, 2.16.1
     15        o gcc 4.0.0, 4.0.1
    1616        o older versions may do as well, but are now obsoleted
Note: See TracChangeset for help on using the changeset viewer.