Simon Glass | c4e5826 | 2024-08-27 19:44:29 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Tests for msr command |
| 4 | * |
| 5 | * Copyright 2024 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <test/cmd.h> |
| 10 | #include <test/ut.h> |
| 11 | |
| 12 | static int cmd_test_msr(struct unit_test_state *uts) |
| 13 | { |
| 14 | ut_assertok(run_commandf("msr read 200")); |
| 15 | ut_assert_nextline("00000000 ffe00006"); |
| 16 | ut_assert_console_end(); |
| 17 | |
| 18 | /* change the first variable msr and see it reflected in the mtrr cmd */ |
| 19 | ut_assertok(run_commandf("mtrr")); |
| 20 | ut_assert_nextline("CPU 65537:"); |
| 21 | ut_assert_nextlinen("Reg"); |
| 22 | ut_assert_nextlinen("0 Y Back 00000000ffe00000"); |
| 23 | ut_assertok(console_record_reset_enable()); |
| 24 | |
| 25 | /* change the type from 6 to 5 */ |
| 26 | ut_assertok(run_commandf("msr write 200 0 ffe00005")); |
| 27 | ut_assert_console_end(); |
| 28 | |
| 29 | /* Now it shows 'Protect' */ |
| 30 | ut_assertok(run_commandf("mtrr")); |
| 31 | ut_assert_nextline("CPU 65537:"); |
| 32 | ut_assert_nextlinen("Reg"); |
| 33 | ut_assert_nextlinen("0 Y Protect 00000000ffe00000"); |
| 34 | ut_assertok(console_record_reset_enable()); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | CMD_TEST(cmd_test_msr, UTF_CONSOLE); |