summaryrefslogtreecommitdiff
path: root/chip/it83xx/it83xx_fpu.S
blob: d98ba0fa678491f68897a2ce24efb86185bddb65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Copyright 2017 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/*
 * DLMB register = 0x80189:
 * Disable all interrupts and switching CPU's
 * ALU (Arithmetic Logic Unit) to floating point operation mode.
 * (IEEE standard 754 floating point)
 *
 * DLMB register = 0x80009:
 * Restore interrupts and ALU.
 */
	.text
	.align	2
	.global	__addsf3
	.type	__addsf3, @function
__addsf3:
	sethi  $r2, 0x80        /* r2 = 0x80000 */
	addi   $r3, $r2, 0x189  /* r3 = 0x80189 */
	addi45 $r2, 0x9         /* r2 = 0x80009 */
	mtsr   $r3, $dlmb       /* dlmb = 0x80189 */
	dsb
	/* Floating-point addition single-precision */
	add45  $r0, $r1
	mtsr   $r2, $dlmb       /* dlmb = 0x80009 */
	dsb
	ret5   $lp
	.size	__addsf3, .-__addsf3

	.text
	.align	2
	.global	__subsf3
	.type	__subsf3, @function
__subsf3:
	sethi  $r2, 0x80        /* r2 = 0x80000 */
	addi   $r3, $r2, 0x189  /* r3 = 0x80189 */
	addi45 $r2, 0x9         /* r2 = 0x80009 */
	mtsr   $r3, $dlmb       /* dlmb = 0x80189 */
	dsb
	/* Floating-point subtraction single-precision */
	sub45  $r0, $r1
	mtsr   $r2, $dlmb       /* dlmb = 0x80009 */
	dsb
	ret5   $lp
	.size	__subsf3, .-__subsf3

	.text
	.align	2
	.global	__mulsf3
	.type	__mulsf3, @function
__mulsf3:
	sethi  $r2, 0x80        /* r2 = 0x80000 */
	addi   $r3, $r2, 0x189  /* r3 = 0x80189 */
	addi45 $r2, 0x9         /* r2 = 0x80009 */
	mtsr   $r3, $dlmb       /* dlmb = 0x80189 */
	dsb
	/* Floating-point multiplication single-precision */
	mul33  $r0, $r1
	mtsr   $r2, $dlmb       /* dlmb = 0x80009 */
	dsb
	ret5   $lp
	.size	__mulsf3, .-__mulsf3

	.text
	.align	2
	.global	__divsf3
	.type	__divsf3, @function
__divsf3:
	sethi  $r2, 0x80        /* r2 = 0x80000 */
	addi   $r3, $r2, 0x189  /* r3 = 0x80189 */
	addi45 $r2, 0x9         /* r2 = 0x80009 */
	mtsr   $r3, $dlmb       /* dlmb = 0x80189 */
	dsb
	/* Floating-point division single-precision */
	divsr  $r0,$r0,$r0,$r1
	mtsr   $r2, $dlmb       /* dlmb = 0x80009 */
	dsb
	ret5   $lp
	.size	__divsf3, .-__divsf3