Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2007 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * Author: Sergei Poselenov <sposelenov@emcraft.com> |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | |
| 11 | /* |
| 12 | * FPU test |
| 13 | * |
| 14 | * This test checks the arithmetic logic unit (ALU) of CPU. |
| 15 | * It tests independently various groups of instructions using |
| 16 | * run-time modification of the code to reduce the memory footprint. |
| 17 | * For more details refer to post/cpu/ *.c files. |
| 18 | */ |
| 19 | |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 20 | #include <post.h> |
| 21 | |
Kumar Gala | fe6555b | 2011-01-25 03:00:08 -0600 | [diff] [blame] | 22 | GNU_FPOST_ATTR |
| 23 | |
Tom Rini | 3dd5d4a | 2022-12-04 10:14:17 -0500 | [diff] [blame] | 24 | #if CFG_POST & CFG_SYS_POST_FPU |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 25 | |
| 26 | #include <watchdog.h> |
| 27 | |
| 28 | extern int fpu_status (void); |
| 29 | extern void fpu_enable (void); |
| 30 | extern void fpu_disable (void); |
| 31 | |
| 32 | extern int fpu_post_test_math1 (void); |
| 33 | extern int fpu_post_test_math2 (void); |
| 34 | extern int fpu_post_test_math3 (void); |
| 35 | extern int fpu_post_test_math4 (void); |
| 36 | extern int fpu_post_test_math5 (void); |
| 37 | extern int fpu_post_test_math6 (void); |
| 38 | extern int fpu_post_test_math7 (void); |
| 39 | |
| 40 | int fpu_post_test (int flags) |
| 41 | { |
| 42 | int fpu = fpu_status (); |
| 43 | |
| 44 | int ret = 0; |
| 45 | |
Stefan Roese | 80877fa | 2022-09-02 14:10:46 +0200 | [diff] [blame] | 46 | schedule(); |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 47 | |
| 48 | if (!fpu) |
| 49 | fpu_enable (); |
| 50 | |
| 51 | if (ret == 0) |
| 52 | ret = fpu_post_test_math1 (); |
| 53 | if (ret == 0) |
| 54 | ret = fpu_post_test_math2 (); |
| 55 | if (ret == 0) |
| 56 | ret = fpu_post_test_math3 (); |
| 57 | if (ret == 0) |
| 58 | ret = fpu_post_test_math4 (); |
| 59 | if (ret == 0) |
| 60 | ret = fpu_post_test_math5 (); |
| 61 | if (ret == 0) |
| 62 | ret = fpu_post_test_math6 (); |
| 63 | if (ret == 0) |
| 64 | ret = fpu_post_test_math7 (); |
| 65 | |
| 66 | if (!fpu) |
| 67 | fpu_disable (); |
| 68 | |
Stefan Roese | 80877fa | 2022-09-02 14:10:46 +0200 | [diff] [blame] | 69 | schedule(); |
Sergei Poselenov | 3190dbe | 2007-07-05 08:17:37 +0200 | [diff] [blame] | 70 | |
| 71 | return ret; |
| 72 | } |
| 73 | |
Tom Rini | 3dd5d4a | 2022-12-04 10:14:17 -0500 | [diff] [blame] | 74 | #endif /* CFG_POST & CFG_SYS_POST_FPU */ |