Changeset 1065603e in mainline


Ignore:
Timestamp:
2006-03-14T20:09:27Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5f62ef9
Parents:
e4ddfa8
Message:

Fix bug in switch to userspace on ia64: ensure start in bank 1.
Fix bug in tlb_invalidate_all() that cause interrupts to be unconditionally enabled.
Optimize context switching by discarding packed attribute of context structures.

Location:
arch/ia64
Files:
9 edited

Legend:

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

    re4ddfa8 r1065603e  
    9898       
    9999        ipl_t ipl;
    100 } __attribute__ ((packed));
     100};
    101101
    102102#endif
  • arch/ia64/include/interrupt.h

    re4ddfa8 r1065603e  
    7272        __u64 in3;
    7373        __u64 in4;
    74 } __attribute__ ((packed));
     74};
    7575
    7676extern void *ivt;
  • arch/ia64/src/asm.S

    re4ddfa8 r1065603e  
    6161switch_to_userspace:
    6262        alloc loc0 = ar.pfs, 5, 3, 0, 0
    63         rsm (PSR_IC_MASK | PSR_I_MASK)          /* disable interruption collection  and interrupts */
     63        rsm (PSR_IC_MASK | PSR_I_MASK)          /* disable interruption collection and interrupts */
    6464        srlz.d ;;
    6565        srlz.i ;;
  • arch/ia64/src/fpu_context.c

    re4ddfa8 r1065603e  
    2929
    3030#include <fpu_context.h>
     31#include <print.h>
    3132
    3233void fpu_context_save(fpu_context_t *fctx){
     34                return;
    3335                asm volatile(
    3436                        "stf.spill [%2]=f2,0x80\n"
     
    187189void fpu_context_restore(fpu_context_t *fctx)
    188190{
    189 
     191                return;
    190192                asm volatile(
    191193                        "ldf.fill f2=[%2],0x80\n"
  • arch/ia64/src/ia64.c

    re4ddfa8 r1065603e  
    7878        psr.ic = true;
    7979        psr.ri = 0;                             /* start with instruction #0 */
     80        psr.bn = 1;                             /* start in bank 0 */
    8081
    8182        __asm__ volatile ("mov %0 = ar.rsc\n" : "=r" (rsc.value));
  • arch/ia64/src/ivt.S

    re4ddfa8 r1065603e  
    316316        mov loc46 = r31
    317317
    318         /*preserve Floating point status register*/
     318        /* preserve Floating point status register */
    319319        mov loc47 = ar.fpsr
    320320   
     
    376376        mov r31 = loc46
    377377       
    378 
    379         /*restore Floating point status register*/
     378        /* restore Floating point status register */
    380379        mov ar.fpsr = loc47
    381380       
  • arch/ia64/src/mm/tlb.c

    re4ddfa8 r1065603e  
    4343#include <typedefs.h>
    4444#include <panic.h>
     45#include <print.h>
    4546#include <arch.h>
    46 
    47 
    4847
    4948/** Invalidate all TLB entries. */
    5049void tlb_invalidate_all(void)
    5150{
     51                ipl_t ipl;
    5252                __address adr;
    53                 __u32 count1,count2,stride1,stride2;
     53                __u32 count1, count2, stride1, stride2;
    5454               
    5555                int i,j;
    5656               
    57                 adr=PAL_PTCE_INFO_BASE();
    58                 count1=PAL_PTCE_INFO_COUNT1();
    59                 count2=PAL_PTCE_INFO_COUNT2();
    60                 stride1=PAL_PTCE_INFO_STRIDE1();
    61                 stride2=PAL_PTCE_INFO_STRIDE2();
     57                adr = PAL_PTCE_INFO_BASE();
     58                count1 = PAL_PTCE_INFO_COUNT1();
     59                count2 = PAL_PTCE_INFO_COUNT2();
     60                stride1 = PAL_PTCE_INFO_STRIDE1();
     61                stride2 = PAL_PTCE_INFO_STRIDE2();
    6262               
    63                 interrupts_disable();
    64 
    65                 for(i=0;i<count1;i++)
    66                 {
    67                         for(j=0;j<count2;j++)
    68                         {
    69                                 asm volatile
    70                                 (
    71                                         "ptc.e %0;;"
     63                ipl = interrupts_disable();
     64
     65                for(i = 0; i < count1; i++) {
     66                        for(j = 0; j < count2; j++) {
     67                                __asm__ volatile (
     68                                        "ptc.e %0 ;;"
    7269                                        :
    73                                         :"r" (adr)
     70                                        : "r" (adr)
    7471                                );
    75                                 adr+=stride2;
     72                                adr += stride2;
    7673                        }
    77                         adr+=stride1;
     74                        adr += stride1;
    7875                }
    7976
    80                 interrupts_enable();
     77                interrupts_restore(ipl);
    8178
    8279                srlz_d();
     
    9087void tlb_invalidate_asid(asid_t asid)
    9188{
    92         /* TODO */
    9389        tlb_invalidate_all();
    9490}
     
    9793void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt)
    9894{
    99 
    100 
    10195        region_register rr;
    10296        bool restore_rr = false;
    103         int b=0;
    104         int c=cnt;
     97        int b = 0;
     98        int c = cnt;
    10599
    106100        __address va;
    107         va=page;
     101        va = page;
    108102
    109103        rr.word = rr_read(VA2VRN(va));
     
    122116        }
    123117       
    124         while(c>>=1)    b++;
    125         b>>=1;
     118        while(c >>= 1)
     119                b++;
     120        b >>= 1;
    126121        __u64 ps;
    127122       
    128         switch(b)
    129         {
     123        switch (b) {
    130124                case 0: /*cnt 1-3*/
    131                 {
    132                         ps=PAGE_WIDTH;
    133                         break;
    134                 }
     125                        ps = PAGE_WIDTH;
     126                        break;
    135127                case 1: /*cnt 4-15*/
    136                 {
    137128                        /*cnt=((cnt-1)/4)+1;*/
    138                         ps=PAGE_WIDTH+2;
    139                         va&=~((1<<ps)-1);
    140                         break;
    141                 }
     129                        ps = PAGE_WIDTH+2;
     130                        va &= ~((1<<ps)-1);
     131                        break;
    142132                case 2: /*cnt 16-63*/
    143                 {
    144133                        /*cnt=((cnt-1)/16)+1;*/
    145                         ps=PAGE_WIDTH+4;
    146                         va&=~((1<<ps)-1);
    147                         break;
    148                 }
     134                        ps = PAGE_WIDTH+4;
     135                        va &= ~((1<<ps)-1);
     136                        break;
    149137                case 3: /*cnt 64-255*/
    150                 {
    151138                        /*cnt=((cnt-1)/64)+1;*/
    152                         ps=PAGE_WIDTH+6;
    153                         va&=~((1<<ps)-1);
    154                         break;
    155                 }
     139                        ps = PAGE_WIDTH+6;
     140                        va &= ~((1<<ps)-1);
     141                        break;
    156142                case 4: /*cnt 256-1023*/
    157                 {
    158143                        /*cnt=((cnt-1)/256)+1;*/
    159                         ps=PAGE_WIDTH+8;
    160                         va&=~((1<<ps)-1);
    161                         break;
    162                 }
     144                        ps = PAGE_WIDTH+8;
     145                        va &= ~((1<<ps)-1);
     146                        break;
    163147                case 5: /*cnt 1024-4095*/
    164                 {
    165148                        /*cnt=((cnt-1)/1024)+1;*/
    166                         ps=PAGE_WIDTH+10;
    167                         va&=~((1<<ps)-1);
    168                         break;
    169                 }
     149                        ps = PAGE_WIDTH+10;
     150                        va &= ~((1<<ps)-1);
     151                        break;
    170152                case 6: /*cnt 4096-16383*/
    171                 {
    172153                        /*cnt=((cnt-1)/4096)+1;*/
    173                         ps=PAGE_WIDTH+12;
    174                         va&=~((1<<ps)-1);
    175                         break;
    176                 }
     154                        ps = PAGE_WIDTH+12;
     155                        va &= ~((1<<ps)-1);
     156                        break;
    177157                case 7: /*cnt 16384-65535*/
    178158                case 8: /*cnt 65536-(256K-1)*/
    179                 {
    180159                        /*cnt=((cnt-1)/16384)+1;*/
    181                         ps=PAGE_WIDTH+14;
    182                         va&=~((1<<ps)-1);
    183                         break;
    184                 }
     160                        ps = PAGE_WIDTH+14;
     161                        va &= ~((1<<ps)-1);
     162                        break;
    185163                default:
    186                 {
    187164                        /*cnt=((cnt-1)/(16384*16))+1;*/
    188165                        ps=PAGE_WIDTH+18;
    189166                        va&=~((1<<ps)-1);
    190167                        break;
    191                 }
    192168        }
    193169        /*cnt+=(page!=va);*/
    194         for(;va<(page+cnt*(PAGE_SIZE));va+=(1<<ps))     {
    195                 __asm__ volatile
    196                 (
     170        for(; va<(page+cnt*(PAGE_SIZE)); va += (1<<ps)) {
     171                __asm__ volatile (
    197172                        "ptc.l %0,%1;;"
    198173                        :
    199                         : "r"(va), "r"(ps<<2)
     174                        : "r" (va), "r" (ps<<2)
    200175                );
    201176        }
     
    203178        srlz_i();
    204179       
    205        
    206180        if (restore_rr) {
    207181                rr_write(VA2VRN(va), rr.word);
     
    209183                srlz_i();
    210184        }
    211 
    212 
    213185}
    214186
     
    507479                 */
    508480                if (!as_page_fault(va)) {
    509                         panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid);
     481                        panic("%s: va=%P, rid=%d, iip=%P\n", __FUNCTION__, va, rid, istate->cr_iip);
    510482                }
    511483        }
     
    613585        } else {
    614586                if (!as_page_fault(va)) {
    615                         panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid);
     587                        panic("%s: va=%P, rid=%d\n", __FUNCTION__, va, rr.map.rid);
    616588                }
    617589        }
  • arch/ia64/src/proc/scheduler.c

    re4ddfa8 r1065603e  
    6363                "bsw.1\n"
    6464                :
    65                 : /*"r" (((__address) THREAD->kstack) + ALIGN_UP(sizeof(the_t), REGISTER_STACK_ALIGNMENT)),*/
    66                   "r" (&THREAD->kstack[THREAD_STACK_SIZE]),
     65                : "r" (&THREAD->kstack[THREAD_STACK_SIZE]),
    6766                  "r" (&THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA])
    6867                );
  • arch/ia64/src/start.S

    re4ddfa8 r1065603e  
    9393         */
    9494
    95 
    9695        # switch to register bank 1
    9796        bsw.1
Note: See TracChangeset for help on using the changeset viewer.