summaryrefslogtreecommitdiff
path: root/core/cortex-m/fpu.c
blob: 806b05438efe3825d613bf229468a92805615b0b (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
/* Copyright (c) 2012 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.
 */

/* FPU module for Chrome EC operating system */

#include "task.h"

void enable_fpu(void)
{
	interrupt_disable();
	asm volatile("mrs r0, control;"
		     "orr r0, r0, #(1 << 2);"
		     "msr control, r0;"
		     "isb;");
}

void disable_fpu(int32_t v)
{
	/* Optimization barrier to force compiler generate floating point
	 * calculation code for 'v' before disabling FPU. */
	asm volatile("" : : "r" (v) : "memory");
	asm volatile("mrs r0, control;"
		     "bic r0, r0, #(1 << 2);"
		     "msr control, r0;"
		     "isb;");
	interrupt_enable();
}