Changeset 6a27d63 in mainline


Ignore:
Timestamp:
2005-05-11T21:53:09Z (20 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c884ef1
Parents:
6ba143d
Message:

Finished FPU lazy context switching - first version. I have not tested it and there are many things which must be changed when
it runs first time OK.

Files:
9 edited

Legend:

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

    r6ba143d r6a27d63  
    7777extern void null_interrupt(__u8 n, __u32 stack[]);
    7878extern void gp_fault(__u8 n, __u32 stack[]);
     79extern void nm_fault(__u8 n, __u32 stack[]);
    7980extern void page_fault(__u8 n, __u32 stack[]);
    8081extern void syscall(__u8 n, __u32 stack[]);
  • arch/ia32/src/fpu_context.c

    r6ba143d r6a27d63  
    4141void fpu_context_restore(fpu_context_t *fctx)
    4242{
    43         if(THREAD==CPU->arch.fpu_owner) reset_TS_flag();
    44         else set_TS_flag();
     43        if(THREAD==CPU->arch.fpu_owner) {reset_TS_flag(); }
     44        else {set_TS_flag(); ((CPU->arch).fpu_owner)->fpu_context_engaged=1;}
    4545}
    4646
     
    4848void fpu_lazy_context_save(fpu_context_t *fctx)
    4949{
    50 /*
    51         pushl %eax
    52         mov 8(%esp),%eax
    53         fxsave (%eax)
    54         popl %eax
    55         ret
    56 */     
     50    asm(
     51        "mov %0,%%eax;"
     52        "fxsave (%%eax);"
     53        "ret;"
     54        :"=m"(fctx)
     55        :
     56        :"%eax"
     57    ); 
    5758}
    5859
    5960void fpu_lazy_context_restore(fpu_context_t *fctx)
    6061{
    61 /*
    62         pushl %eax
    63         mov 8(%esp),%eax
    64         fxrstor (%eax)
    65         popl %eax
    66         ret
    67 */     
     62    asm(
     63        "mov %0,%%eax;"
     64        "fxrstor (%%eax);"
     65        "ret;"
     66        :"=m"(fctx)
     67        :
     68        :"%eax"
     69    );
    6870}
     71
     72void fpu_init(void)
     73{
     74    asm(
     75        "fninit;"
     76    );
     77}
     78
  • arch/ia32/src/interrupt.c

    r6ba143d r6a27d63  
    8686}
    8787
     88void nm_fault(__u8 n, __u32 stack[])
     89{
     90
     91        if (((CPU->arch).fpu_owner)!=NULL)
     92        { 
     93                fpu_lazy_context_save(&(((CPU->arch).fpu_owner)->saved_fpu_context));
     94                ((CPU->arch).fpu_owner)->fpu_context_engaged=0; /* Enables migration */
     95        }
     96       
     97        if(THREAD->fpu_context_exists) fpu_lazy_context_restore(&(THREAD->saved_fpu_context));
     98        else {fpu_init();THREAD->fpu_context_exists=1;}
     99
     100        (CPU->arch).fpu_owner=THREAD;
     101
     102        reset_TS_flag();
     103       
     104//      panic("#NM fault\n");
     105}
     106
     107
     108
    88109void page_fault(__u8 n, __u32 stack[])
    89110{
  • arch/ia32/src/pm.c

    r6ba143d r6a27d63  
    121121        }
    122122        trap_register(13, gp_fault);
     123        trap_register( 7, nm_fault);
    123124}
    124125
  • doc/TODO

    r6ba143d r6a27d63  
    1212+ save/restore floating point context on context switch
    1313  + [ia32] lazy context switch using TS flag
     14+ [ia32] MMX,SSE1-.. initialization
    1415+ [ia32] review privilege separation
    1516  + zero IOPL in EFLAGS
     
    1920+ make emulated architectures also work on real hardware
    2021+ bring in support for other architectures (e.g. PowerPC)
     22
     23
  • include/fpu_context.h

    r6ba143d r6a27d63  
    1111extern void fpu_lazy_context_save(fpu_context_t *);
    1212extern void fpu_lazy_context_restore(fpu_context_t *);
    13 
     13extern void fpu_init(void);
    1414
    1515
  • include/proc/thread.h

    r6ba143d r6a27d63  
    7575        context_t sleep_timeout_context;
    7676        fpu_context_t saved_fpu_context;                       
     77        int fpu_context_exists;               
     78        int fpu_context_engaged;               /* Defined only if thread doesn't run. It means that fpu context is in CPU
     79                                                that last time executes this thread. This disables migration */         
    7780       
    7881       
  • src/proc/scheduler.c

    r6ba143d r6a27d63  
    268268                            list_remove(&THREAD->threads_link);
    269269                            spinlock_unlock(&threads_lock);
     270
     271                            spinlock_lock(&THREAD->cpu->lock);
     272                            if(THREAD->cpu->arch.fpu_owner==THREAD) THREAD->cpu->arch.fpu_owner=NULL;
     273                            spinlock_unlock(&THREAD->cpu->lock);
     274
    270275                           
    271276                            free(THREAD);
     
    428433                                 * We don't want to steal CPU-wired threads neither threads already stolen.
    429434                                 * The latter prevents threads from migrating between CPU's without ever being run.
    430                                  */
     435                                 * We don't want to steal threads whose FPU context is still in CPU
     436                                 */
    431437                                spinlock_lock(&t->lock);
    432                                 if (!(t->flags & (X_WIRED | X_STOLEN))) {
     438                                if ( (!(t->flags & (X_WIRED | X_STOLEN))) && (!(t->fpu_context_engaged)) ) {
    433439                                        /*
    434440                                         * Remove t from r.
  • src/proc/thread.c

    r6ba143d r6a27d63  
    190190                t->task = task;
    191191               
     192                t->fpu_context_exists=0;
     193                t->fpu_context_engaged=0;
     194               
    192195                /*
    193196                 * Register this thread in the system-wide list.
Note: See TracChangeset for help on using the changeset viewer.