1e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project#include <stdio.h>
2e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project#include <arpa/inet.h>  /* for htons() etc.. */
3e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
4e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectstatic char  tab[8];
5e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
6e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectstatic void
7e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectread4( int  o, unsigned val )
8e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project{
9e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned  v = htonl(val);
10e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned  v2;
11e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
12e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+0] = (char)(v >> 24);
13e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+1] = (char)(v >> 16);
14e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+2] = (char)(v >> 8);
15e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+3] = (char)(v);
16e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
17e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    printf( "read4: offset=%d value=%08x: ", o, val );
18e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    fflush(stdout);
19e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
20e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    v2 = *(unsigned*)(tab+o);
21e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
22e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    if (v2 != val) {
23e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "FAIL (%08x)\n", v2 );
24e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    } else {
25e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "ok\n" );
26e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    }
27e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project}
28e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
29e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectstatic void
30e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectwrit4( int  o, unsigned val )
31e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project{
32e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned  v = htonl(val);
33e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned  v2;
34e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
35e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    printf( "writ4: offset=%d value=%08x: ", o, val );
36e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    fflush(stdout);
37e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
38e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    *(unsigned*)(tab+o) = v;
39e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
40e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    v2 = ((unsigned)tab[o+0] << 24) |
41e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project         ((unsigned)tab[o+1] << 16) |
42e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project         ((unsigned)tab[o+2] << 8 ) |
43e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project         ((unsigned)tab[o+3]      );
44e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
45e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    if (v2 != val) {
46e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "FAIL (%08x)\n", v2 );
47e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    } else {
48e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "ok\n" );
49e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    }
50e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project}
51e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
52e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectstatic void
53e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectread2( int  o, unsigned val )
54e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project{
55e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned short v = htons(val);
56e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned short v2;
57e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
58e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+0] = (char)(v >> 8);
59e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    tab[o+1] = (char)(v);
60e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
61e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    printf( "read2: offset=%d value=%08x: ", o, val );
62e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    fflush(stdout);
63e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
64e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    v2 = *(unsigned short*)(tab+o);
65e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
66e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    if (v2 != val) {
67e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "FAIL (%04x)\n", v2 );
68e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    } else {
69e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "ok\n" );
70e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    }
71e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project}
72e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
73e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectstatic void
74e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectwrit2( int  o, unsigned val )
75e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project{
76e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned short v = htons(val);
77e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    unsigned short v2;
78e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
79e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    printf( "writ2: offset=%d value=%08x: ", o, val );
80e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    fflush(stdout);
81e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
82e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    *(unsigned short*)(tab+o) = v;
83e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
84e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    v2 = ((unsigned)tab[o+0] << 8) |
85e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project         ((unsigned)tab[o+1]       );
86e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
87e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    if (v2 != val) {
88e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "FAIL (%08x)\n", v2 );
89e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    } else {
90e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project        printf( "ok\n" );
91e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    }
92e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project}
93e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
94e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
95e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
96e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Projectint  main(void)
97e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project{
98e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read4( 0, 0x12345678 );
99e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ4( 0, 0x12345678 );
100e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read4( 1, 0x12345678 );
101e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ4( 1, 0x12345678 );
102e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read4( 2, 0x12345678 );
103e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ4( 2, 0x12345678 );
104e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read4( 3, 0x12345678 );
105e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ4( 3, 0x12345678 );
106e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
107e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read2( 0, 0x1234 );
108e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ2( 0, 0x1234 );
109e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read2( 1, 0x1234 );
110e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ2( 1, 0x1234 );
111e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read2( 2, 0x1234 );
112e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ2( 2, 0x1234 );
113e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    read2( 3, 0x1234 );
114e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    writ2( 3, 0x1234 );
115e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project
116e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project    return 0;
117e16cb84e2324f05334d18dcf5956f20f44262b62The Android Open Source Project}
118