1 /* MN10300 Low level FPU management operations
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <linux/linkage.h>
12 #include <asm/cpu-regs.h>
14 #include <asm/thread_info.h>
15 #include <asm/asm-offsets.h>
16 #include <asm/frame.inc>
18 .macro FPU_INIT_STATE_ALL
54 .macro FPU_SAVE_ALL areg,dreg
91 .macro FPU_RESTORE_ALL areg,dreg
128 ###############################################################################
130 # void fpu_init_state(void)
131 # - initialise the FPU
133 ###############################################################################
134 .globl fpu_init_state
135 .type fpu_init_state,@function
140 #ifdef CONFIG_MN10300_PROC_MN103E010
146 #ifdef CONFIG_MN10300_PROC_MN103E010
154 .size fpu_init_state,.-fpu_init_state
156 ###############################################################################
158 # void fpu_save(struct fpu_state_struct *)
159 # - save the fpu state
160 # - note that an FPU Operational exception might occur during this process
162 ###############################################################################
164 .type fpu_save,@function
167 or EPSW_FE,epsw /* enable the FPU so we can access it */
169 #ifdef CONFIG_MN10300_PROC_MN103E010
175 #ifdef CONFIG_MN10300_PROC_MN103E010
183 .size fpu_save,.-fpu_save
185 ###############################################################################
187 # void fpu_disabled(void)
188 # - handle an exception due to the FPU being disabled
189 # when CONFIG_FPU is enabled
191 ###############################################################################
192 .type fpu_disabled,@function
195 or EPSW_nAR|EPSW_FE,epsw
201 mov (a1),d1 /* get epsw of user context */
202 and ~(THREAD_SIZE-1),a1 /* a1: (thread_info *ti) */
203 mov (TI_task,a1),a2 /* a2: (task_struct *tsk) */
205 beq fpu_used_in_kernel
209 mov (TASK_THREAD+THREAD_FPU_FLAGS,a2),d1
210 #ifndef CONFIG_LAZY_SAVE_FPU
211 or __THREAD_HAS_FPU,d1
212 mov d1,(TASK_THREAD+THREAD_FPU_FLAGS,a2)
213 #else /* !CONFIG_LAZY_SAVE_FPU */
214 mov (fpu_state_owner),a0
216 beq fpu_regs_save_end
218 mov (TASK_THREAD+THREAD_UREGS,a0),a1
219 add TASK_THREAD+THREAD_FPU_STATE,a0
227 mov a2,(fpu_state_owner)
228 #endif /* !CONFIG_LAZY_SAVE_FPU */
230 btst __THREAD_USING_FPU,d1
232 add TASK_THREAD+THREAD_FPU_STATE,a2
233 FPU_RESTORE_ALL a2,d0
238 add TASK_THREAD+THREAD_FPU_FLAGS,a2
239 bset __THREAD_USING_FPU,(0,a2)
243 and ~(EPSW_nAR|EPSW_FE),epsw
250 mov d0,(REG_ORIG_D0,fp)
255 call fpu_disabled_in_kernel[],0
256 jmp ret_from_exception
258 .size fpu_disabled,.-fpu_disabled