blob: 9581a1939e61a754bc371604dc163c06c3011c7b [file] [log] [blame]
Conrad Groblera824af62019-03-22 17:33:23 +00001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "hf/arch/std.h"
18#include "hf/arch/vm/registers.h"
19
20#include "hf/spci.h"
21
22#include "vmapi/hf/call.h"
23
24#include "hftest.h"
25#include "primary_with_secondary.h"
26#include "util.h"
27
28/**
29 * Test that floating point registers are saved and restored by
30 * filling them with one value here and a different value in the
31 * service.
32 */
33TEST(floating_point, fp_fill)
34{
35 const double first = 1.2;
36 const double second = -2.3;
37 struct hf_vcpu_run_return run_res;
38 struct mailbox_buffers mb = set_up_mailbox();
39
40 fill_fp_registers(first);
41 SERVICE_SELECT(SERVICE_VM0, "fp_fill", mb.send);
42 run_res = hf_vcpu_run(SERVICE_VM0, 0);
43 EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
44 EXPECT_EQ(check_fp_register(first), true);
45
46 fill_fp_registers(second);
47 run_res = hf_vcpu_run(SERVICE_VM0, 0);
48 EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
49 EXPECT_EQ(check_fp_register(second), true);
50}