aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/memtest.h
blob: 9c31b54d00233d1e67e561b8d23d0c1fd1b95f0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
    ChibiOS/RT - Copyright (C) 2013-2014 Uladzimir Pylinsky aka barthess

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#ifndef MEMTEST_H_
#define MEMTEST_H_

/*
 * Memtest types
 */
#define MEMTEST_WALKING_ONE               (1 << 0)
#define MEMTEST_WALKING_ZERO              (1 << 1)
#define MEMTEST_OWN_ADDRESS               (1 << 2)
#define MEMTEST_MOVING_INVERSION_ZERO     (1 << 3)
#define MEMTEST_MOVING_INVERSION_55AA     (1 << 4)
#define MEMTEST_MOVING_INVERSION_RAND     (1 << 5)

/*
 * combined types for convenient
 */
#define MEMTEST_RUN_ALL                   (MEMTEST_WALKING_ONE              | \
                                           MEMTEST_WALKING_ZERO             | \
                                           MEMTEST_OWN_ADDRESS              | \
                                           MEMTEST_MOVING_INVERSION_ZERO    | \
                                           MEMTEST_MOVING_INVERSION_55AA    | \
                                           MEMTEST_MOVING_INVERSION_RAND)

/*
 * Memtest data widths
 */
#define MEMTEST_WIDTH_8   (1 << 0)
#define MEMTEST_WIDTH_16  (1 << 1)
#define MEMTEST_WIDTH_32  (1 << 2)
#define MEMTEST_WIDTH_64  (1 << 3)

typedef struct memtest_t memtest_t;
typedef uint32_t testtype;

/*
 * Error call back.
 */
typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t index,
                           size_t current_width, uint32_t got, uint32_t expect);

/*
 *
 */
struct memtest_t {
  /*
   * Pointer to the test area start. Must be word aligned.
   */
  void          *start;
  /*
   * Test area size in bytes.
   */
  size_t        size;
  /*
   * Allowable data widths mask.
   */
  uint32_t      width_mask;
  /*
   * Error callback pointer. Set to NULL if unused.
   */
  memtestecb_t  errcb;
};

/*
 *
 */
#ifdef __cplusplus
extern "C" {
#endif
  void memtest_run(memtest_t *testp, uint32_t testmask);
#ifdef __cplusplus
}
#endif

#endif /* MEMTEST_H_ */