Changeset f76fed4 in mainline
- Timestamp:
- 2006-03-03T00:20:31Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 09c18f7
- Parents:
- ddcf365
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/src/fpu_context.c
rddcf365 rf76fed4 35 35 void fpu_context_save(fpu_context_t *fctx) 36 36 { 37 /* Align on 16-byte boundary */38 if (((__u64)fctx) & 0xf)39 fctx = (fpu_context_t *)((((__u64)fctx) | 0xf) + 1);40 41 37 __asm__ volatile ( 42 38 "fxsave %0" … … 48 44 void fpu_context_restore(fpu_context_t *fctx) 49 45 { 50 /* Align on 16-byte boundary */51 if (((__u64)fctx) & 0xf)52 fctx = (fpu_context_t *)((((__u64)fctx) | 0xf) + 1);53 46 __asm__ volatile ( 54 47 "fxrstor %0" … … 57 50 } 58 51 59 void fpu_init( fpu_context_t *fctx)52 void fpu_init() 60 53 { 61 54 /* TODO: Zero all SSE, MMX etc. registers */ -
arch/ia32/include/fpu_context.h
rddcf365 rf76fed4 32 32 #include <arch/types.h> 33 33 34 #define ARCH_HAS_FPU 35 #define FPU_CONTEXT_ALIGN 16 36 34 37 struct fpu_context { 35 38 /* TODO: We need malloc that aligns structures on 16-byte boundary */ 36 __u8 fpu[512 +16]; /* FXSAVE & FXRSTOR storage area */39 __u8 fpu[512]; /* FXSAVE & FXRSTOR storage area */ 37 40 }; 38 41 -
arch/ia32/src/fpu_context.c
rddcf365 rf76fed4 49 49 } 50 50 51 void fpu_init( fpu_context_t *fctx)51 void fpu_init() 52 52 { 53 53 __asm__ volatile ( -
arch/mips32/include/fpu_context.h
rddcf365 rf76fed4 32 32 #include <arch/types.h> 33 33 34 #define ARCH_HAS_FPU 35 #define FPU_CONTEXT_ALIGN sizeof(__native) 36 34 37 struct fpu_context { 35 38 __native dregs[32]; -
arch/mips32/src/fpu_context.c
rddcf365 rf76fed4 51 51 } 52 52 53 void fpu_init( fpu_context_t *fctx)53 void fpu_init() 54 54 { 55 55 /* TODO: Zero all registers */ -
generic/include/fpu_context.h
rddcf365 rf76fed4 34 34 #include <typedefs.h> 35 35 36 #if defined(CONFIG_FPU_LAZY) && !defined(ARCH_HAS_FPU) 37 # error "CONFIG_FPU_LAZY defined, but no ARCH_HAS_FPU" 38 #endif 39 36 40 extern void fpu_context_save(fpu_context_t *); 37 41 extern void fpu_context_restore(fpu_context_t *); 38 extern void fpu_init( fpu_context_t *);42 extern void fpu_init(void); 39 43 extern void fpu_enable(void); 40 44 extern void fpu_disable(void); -
generic/include/proc/thread.h
rddcf365 rf76fed4 40 40 #include <config.h> 41 41 #include <adt/list.h> 42 #include <mm/slab.h> 42 43 43 44 #define THREAD_STACK_SIZE STACK_SIZE … … 83 84 volatile int timeout_pending; /**< Flag signalling sleep timeout in progress. */ 84 85 85 fpu_context_t saved_fpu_context;86 fpu_context_t *saved_fpu_context; 86 87 int fpu_context_exists; 87 88 … … 136 137 extern void thread_destroy(thread_t *t); 137 138 139 140 /* Fpu context slab cache */ 141 extern slab_cache_t *fpu_context_slab; 142 138 143 #endif -
generic/src/proc/scheduler.c
rddcf365 rf76fed4 64 64 { 65 65 before_thread_runs_arch(); 66 66 #ifdef CONFIG_FPU_LAZY 67 67 if(THREAD==CPU->fpu_owner) 68 68 fpu_enable(); 69 69 else 70 70 fpu_disable(); 71 71 #else 72 72 fpu_enable(); 73 73 if (THREAD->fpu_context_exists) 74 fpu_context_restore( &(THREAD->saved_fpu_context));74 fpu_context_restore(THREAD->saved_fpu_context); 75 75 else { 76 fpu_init( &(THREAD->saved_fpu_context));76 fpu_init(); 77 77 THREAD->fpu_context_exists=1; 78 78 } 79 79 #endif 80 80 } 81 81 … … 103 103 if (CPU->fpu_owner != NULL) { 104 104 spinlock_lock(&CPU->fpu_owner->lock); 105 fpu_context_save( &CPU->fpu_owner->saved_fpu_context);105 fpu_context_save(CPU->fpu_owner->saved_fpu_context); 106 106 /* don't prevent migration */ 107 107 CPU->fpu_owner->fpu_context_engaged=0; … … 111 111 spinlock_lock(&THREAD->lock); 112 112 if (THREAD->fpu_context_exists) { 113 fpu_context_restore( &THREAD->saved_fpu_context);113 fpu_context_restore(THREAD->saved_fpu_context); 114 114 } else { 115 fpu_init(&(THREAD->saved_fpu_context)); 115 /* Allocate FPU context */ 116 if (!THREAD->saved_fpu_context) { 117 /* Might sleep */ 118 spinlock_unlock(&THREAD->lock); 119 THREAD->saved_fpu_context = slab_alloc(fpu_context_slab, 120 0); 121 spinlock_lock(&THREAD->lock); 122 } 123 fpu_init(); 116 124 THREAD->fpu_context_exists=1; 117 125 } … … 275 283 if (THREAD) { 276 284 spinlock_lock(&THREAD->lock); 277 278 fpu_context_save( &(THREAD->saved_fpu_context));279 285 #ifndef CONFIG_FPU_LAZY 286 fpu_context_save(THREAD->saved_fpu_context); 287 #endif 280 288 if (!context_save(&THREAD->saved_context)) { 281 289 /* … … 422 430 as_switch(as1, as2); 423 431 } 424 TASK = THREAD->task; 432 TASK = THREAD->task; 425 433 } 426 434 427 435 THREAD->state = Running; 428 436 429 437 #ifdef SCHEDULER_VERBOSE 430 438 printf("cpu%d: tid %d (priority=%d,ticks=%d,nrdy=%d)\n", CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, atomic_get(&CPU->nrdy)); 431 439 #endif 432 440 433 441 /* … … 547 555 */ 548 556 spinlock_lock(&t->lock); 549 557 #ifdef KCPULB_VERBOSE 550 558 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, atomic_get(&CPU->nrdy), atomic_get(&nrdy) / config.cpu_active); 551 559 #endif 552 560 t->flags |= X_STOLEN; 553 561 spinlock_unlock(&t->lock); -
generic/src/proc/thread.c
rddcf365 rf76fed4 64 64 65 65 static slab_cache_t *thread_slab; 66 #ifdef ARCH_HAS_FPU 67 slab_cache_t *fpu_context_slab; 68 #endif 66 69 67 70 … … 104 107 link_initialize(&t->threads_link); 105 108 109 #ifdef ARCH_HAS_FPU 110 # ifdef CONFIG_FPU_LAZY 111 t->saved_fpu_context = NULL; 112 # else 113 t->saved_fpu_context = slab_alloc(fpu_context_slab,kmflags); 114 if (!t->saved_fpu_context) 115 return -1; 116 # endif 117 #endif 118 106 119 pfn = frame_alloc_rc(ONE_FRAME, FRAME_KA | kmflags,&status); 107 if (status) 120 if (status) { 121 #ifdef ARCH_HAS_FPU 122 if (t->saved_fpu_context) 123 slab_free(fpu_context_slab,t->saved_fpu_context); 124 #endif 108 125 return -1; 126 } 109 127 t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn)); 110 128 … … 118 136 119 137 frame_free(ADDR2PFN(KA2PA(t->kstack))); 138 #ifdef ARCH_HAS_FPU 139 if (t->saved_fpu_context) 140 slab_free(fpu_context_slab,t->saved_fpu_context); 141 #endif 120 142 return 1; /* One page freed */ 121 143 } … … 133 155 sizeof(thread_t),0, 134 156 thr_constructor, thr_destructor, 0); 157 #ifdef ARCH_HAS_FPU 158 fpu_context_slab = slab_cache_create("fpu_slab", 159 sizeof(fpu_context_t), 160 FPU_CONTEXT_ALIGN, 161 NULL, NULL, 0); 162 #endif 135 163 } 136 164
Note:
See TracChangeset
for help on using the changeset viewer.