xref: /OK3568_Linux_fs/kernel/arch/m68k/fpsp040/x_unsupp.S (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun|
2*4882a593Smuzhiyun|	x_unsupp.sa 3.3 7/1/91
3*4882a593Smuzhiyun|
4*4882a593Smuzhiyun|	fpsp_unsupp --- FPSP handler for unsupported data type exception
5*4882a593Smuzhiyun|
6*4882a593Smuzhiyun| Trap vector #55	(See table 8-1 Mc68030 User's manual).
7*4882a593Smuzhiyun| Invoked when the user program encounters a data format (packed) that
8*4882a593Smuzhiyun| hardware does not support or a data type (denormalized numbers or un-
9*4882a593Smuzhiyun| normalized numbers).
10*4882a593Smuzhiyun| Normalizes denorms and unnorms, unpacks packed numbers then stores
11*4882a593Smuzhiyun| them back into the machine to let the 040 finish the operation.
12*4882a593Smuzhiyun|
13*4882a593Smuzhiyun| Unsupp calls two routines:
14*4882a593Smuzhiyun|	1. get_op -  gets the operand(s)
15*4882a593Smuzhiyun|	2. res_func - restore the function back into the 040 or
16*4882a593Smuzhiyun|			if fmove.p fpm,<ea> then pack source (fpm)
17*4882a593Smuzhiyun|			and store in users memory <ea>.
18*4882a593Smuzhiyun|
19*4882a593Smuzhiyun|  Input: Long fsave stack frame
20*4882a593Smuzhiyun|
21*4882a593Smuzhiyun|
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun|		Copyright (C) Motorola, Inc. 1990
24*4882a593Smuzhiyun|			All Rights Reserved
25*4882a593Smuzhiyun|
26*4882a593Smuzhiyun|       For details on the license for this file, please see the
27*4882a593Smuzhiyun|       file, README, in this same directory.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunX_UNSUPP:	|idnt    2,1 | Motorola 040 Floating Point Software Package
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun	|section	8
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun#include "fpsp.h"
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun	|xref	get_op
36*4882a593Smuzhiyun	|xref	res_func
37*4882a593Smuzhiyun	|xref	gen_except
38*4882a593Smuzhiyun	|xref	fpsp_fmt_error
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun	.global	fpsp_unsupp
41*4882a593Smuzhiyunfpsp_unsupp:
42*4882a593Smuzhiyun|
43*4882a593Smuzhiyun	link		%a6,#-LOCAL_SIZE
44*4882a593Smuzhiyun	fsave		-(%a7)
45*4882a593Smuzhiyun	moveml		%d0-%d1/%a0-%a1,USER_DA(%a6)
46*4882a593Smuzhiyun	fmovemx	%fp0-%fp3,USER_FP0(%a6)
47*4882a593Smuzhiyun	fmoveml	%fpcr/%fpsr/%fpiar,USER_FPCR(%a6)
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun	moveb		(%a7),VER_TMP(%a6) |save version number
51*4882a593Smuzhiyun	moveb		(%a7),%d0		|test for valid version num
52*4882a593Smuzhiyun	andib		#0xf0,%d0		|test for $4x
53*4882a593Smuzhiyun	cmpib		#VER_4,%d0	|must be $4x or exit
54*4882a593Smuzhiyun	bnel		fpsp_fmt_error
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun	fmovel		#0,%FPSR		|clear all user status bits
57*4882a593Smuzhiyun	fmovel		#0,%FPCR		|clear all user control bits
58*4882a593Smuzhiyun|
59*4882a593Smuzhiyun|	The following lines are used to ensure that the FPSR
60*4882a593Smuzhiyun|	exception byte and condition codes are clear before proceeding,
61*4882a593Smuzhiyun|	except in the case of fmove, which leaves the cc's intact.
62*4882a593Smuzhiyun|
63*4882a593Smuzhiyununsupp_con:
64*4882a593Smuzhiyun	movel		USER_FPSR(%a6),%d1
65*4882a593Smuzhiyun	btst		#5,CMDREG1B(%a6)	|looking for fmove out
66*4882a593Smuzhiyun	bne		fmove_con
67*4882a593Smuzhiyun	andl		#0xFF00FF,%d1	|clear all but aexcs and qbyte
68*4882a593Smuzhiyun	bras		end_fix
69*4882a593Smuzhiyunfmove_con:
70*4882a593Smuzhiyun	andl		#0x0FFF40FF,%d1	|clear all but cc's, snan bit, aexcs, and qbyte
71*4882a593Smuzhiyunend_fix:
72*4882a593Smuzhiyun	movel		%d1,USER_FPSR(%a6)
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun	st		UFLG_TMP(%a6)	|set flag for unsupp data
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun	bsrl		get_op		|everything okay, go get operand(s)
77*4882a593Smuzhiyun	bsrl		res_func	|fix up stack frame so can restore it
78*4882a593Smuzhiyun	clrl		-(%a7)
79*4882a593Smuzhiyun	moveb		VER_TMP(%a6),(%a7) |move idle fmt word to top of stack
80*4882a593Smuzhiyun	bral		gen_except
81*4882a593Smuzhiyun|
82*4882a593Smuzhiyun	|end
83