1825d6ebaSTaylor Simpson /*
20d57cd61STaylor Simpson * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3825d6ebaSTaylor Simpson *
4825d6ebaSTaylor Simpson * This program is free software; you can redistribute it and/or modify
5825d6ebaSTaylor Simpson * it under the terms of the GNU General Public License as published by
6825d6ebaSTaylor Simpson * the Free Software Foundation; either version 2 of the License, or
7825d6ebaSTaylor Simpson * (at your option) any later version.
8825d6ebaSTaylor Simpson *
9825d6ebaSTaylor Simpson * This program is distributed in the hope that it will be useful,
10825d6ebaSTaylor Simpson * but WITHOUT ANY WARRANTY; without even the implied warranty of
11825d6ebaSTaylor Simpson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12825d6ebaSTaylor Simpson * GNU General Public License for more details.
13825d6ebaSTaylor Simpson *
14825d6ebaSTaylor Simpson * You should have received a copy of the GNU General Public License
15825d6ebaSTaylor Simpson * along with this program; if not, see <http://www.gnu.org/licenses/>.
16825d6ebaSTaylor Simpson */
17825d6ebaSTaylor Simpson
18825d6ebaSTaylor Simpson #include <stdio.h>
190d57cd61STaylor Simpson #include <stdint.h>
200d57cd61STaylor Simpson
210d57cd61STaylor Simpson int err;
220d57cd61STaylor Simpson
230d57cd61STaylor Simpson #include "hex_test.h"
24825d6ebaSTaylor Simpson
25825d6ebaSTaylor Simpson /*
26825d6ebaSTaylor Simpson * Make sure that two stores in the same packet honor proper
27825d6ebaSTaylor Simpson * semantics: slot 1 executes first, then slot 0.
28825d6ebaSTaylor Simpson * This is important when the addresses overlap.
29825d6ebaSTaylor Simpson */
dual_stores(int32_t * p,int8_t * q,int32_t x,int8_t y)300d57cd61STaylor Simpson static inline void dual_stores(int32_t *p, int8_t *q, int32_t x, int8_t y)
31825d6ebaSTaylor Simpson {
32825d6ebaSTaylor Simpson asm volatile("{\n\t"
33825d6ebaSTaylor Simpson " memw(%0) = %2\n\t"
34825d6ebaSTaylor Simpson " memb(%1) = %3\n\t"
35825d6ebaSTaylor Simpson "}\n"
36825d6ebaSTaylor Simpson :: "r"(p), "r"(q), "r"(x), "r"(y)
37825d6ebaSTaylor Simpson : "memory");
38825d6ebaSTaylor Simpson }
39825d6ebaSTaylor Simpson
40825d6ebaSTaylor Simpson typedef union {
410d57cd61STaylor Simpson int32_t word;
420d57cd61STaylor Simpson int8_t byte;
43825d6ebaSTaylor Simpson } Dual;
44825d6ebaSTaylor Simpson
main()45825d6ebaSTaylor Simpson int main()
46825d6ebaSTaylor Simpson {
47825d6ebaSTaylor Simpson Dual d;
48825d6ebaSTaylor Simpson
49825d6ebaSTaylor Simpson d.word = ~0;
50825d6ebaSTaylor Simpson dual_stores(&d.word, &d.byte, 0x12345678, 0xff);
510d57cd61STaylor Simpson check32(d.word, 0x123456ff);
52825d6ebaSTaylor Simpson
53825d6ebaSTaylor Simpson puts(err ? "FAIL" : "PASS");
54825d6ebaSTaylor Simpson return err;
55825d6ebaSTaylor Simpson }
56