1 // Copyright (C) 2023 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 16 #ifndef _COMPLIANCE_MODEL_H 17 #define _COMPLIANCE_MODEL_H 18 19 #define RVMODEL_DATA_SECTION 20 21 // For all 8-byte records between begin_signature and end_signature we call 22 // syscall(/* SYS_write */ 64, /* stderr */ 2, /* data_pointer */, /* size */ 8) 23 // to write it to stderr. This way stdout can still be used for tracing/debugging. 24 // After that we call syscall(/* SYS_exit */ 93, /* exit code */ 0) 25 // RV_COMPLIANCE_HALT 26 #define RVMODEL_HALT \ 27 li a7, 64; \ 28 li a0, 2; \ 29 lui a1, % hi(begin_signature); \ 30 addi a1, a1, % lo(begin_signature); \ 31 li a2, 8; \ 32 lui a3, % hi(end_signature); \ 33 addi a3, a3, % lo(end_signature); \ 34 write_to_stderr: \ 35 ecall; \ 36 li a0, 2; \ 37 addi a1, a1, 8; \ 38 bgt a3, a1, write_to_stderr; \ 39 li a7, 93; \ 40 li a0, 0; \ 41 ecall; 42 43 #define RVMODEL_BOOT 44 45 // RV_COMPLIANCE_DATA_BEGIN 46 #define RVMODEL_DATA_BEGIN \ 47 RVMODEL_DATA_SECTION.align 8; \ 48 .global begin_signature; \ 49 begin_signature: 50 51 // We add placeholder data to ensure the compiler keeps the label in place. 52 // RV_COMPLIANCE_DATA_END 53 #define RVMODEL_DATA_END \ 54 .align 8; \ 55 .global end_signature; \ 56 end_signature: \ 57 .zero 8; 58 59 // RVTEST_IO_INIT 60 #define RVMODEL_IO_INIT 61 // RVTEST_IO_WRITE_STR 62 #define RVMODEL_IO_WRITE_STR(_R, _STR) 63 // RVTEST_IO_CHECK 64 #define RVMODEL_IO_CHECK() 65 // RVTEST_IO_ASSERT_GPR_EQ 66 #define RVMODEL_IO_ASSERT_GPR_EQ(_S, _R, _I) 67 68 // RVTEST_IO_ASSERT_SFPR_EQ 69 #define RVMODEL_IO_ASSERT_SFPR_EQ(_F, _R, _I) 70 // RVTEST_IO_ASSERT_DFPR_EQ 71 #define RVMODEL_IO_ASSERT_DFPR_EQ(_D, _R, _I) 72 73 #define RVMODEL_SET_MSW_INT 74 75 #define RVMODEL_CLEAR_MSW_INT 76 77 #define RVMODEL_CLEAR_MTIMER_INT 78 79 #define RVMODEL_CLEAR_MEXT_INT 80 81 #endif // _COMPLIANCE_MODEL_H 82