4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Provide SRAM support for the NV Disk |
---|
5 | * @ingroup libblock |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * RTEMS Project (http://www.rtems.org/) |
---|
10 | * |
---|
11 | * Copyright 2007 Chris Johns (chrisj@rtems.org) |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <stdio.h> |
---|
19 | #include <string.h> |
---|
20 | #include <errno.h> |
---|
21 | |
---|
22 | #include <rtems.h> |
---|
23 | |
---|
24 | #include <rtems/nvdisk-sram.h> |
---|
25 | |
---|
26 | #ifndef NVDISK_SRAM_ERROR_TRACE |
---|
27 | #define NVDISK_SRAM_ERROR_TRACE (0) |
---|
28 | #endif |
---|
29 | |
---|
30 | static int |
---|
31 | rtems_nvdisk_sram_read (uint32_t device __attribute__((unused)), |
---|
32 | uint32_t flags __attribute__((unused)), |
---|
33 | void* base, |
---|
34 | uint32_t offset, |
---|
35 | void* buffer, |
---|
36 | size_t size) |
---|
37 | { |
---|
38 | memcpy (buffer, (base + offset), size); |
---|
39 | return 0; |
---|
40 | } |
---|
41 | |
---|
42 | static int |
---|
43 | rtems_nvdisk_sram_write (uint32_t device __attribute__((unused)), |
---|
44 | uint32_t flags __attribute__((unused)), |
---|
45 | void* base, |
---|
46 | uint32_t offset, |
---|
47 | const void* buffer, |
---|
48 | size_t size) |
---|
49 | { |
---|
50 | memcpy ((base + offset), buffer, size); |
---|
51 | return 0; |
---|
52 | } |
---|
53 | |
---|
54 | static int |
---|
55 | rtems_nvdisk_sram_verify (uint32_t device __attribute__((unused)), |
---|
56 | uint32_t flags __attribute__((unused)), |
---|
57 | void* base, |
---|
58 | uint32_t offset, |
---|
59 | const void* buffer, |
---|
60 | size_t size) |
---|
61 | { |
---|
62 | return memcmp ((base + offset), buffer, size) == 0 ? 0 : EIO; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | const rtems_nvdisk_driver_handlers rtems_nvdisk_sram_handlers = |
---|
67 | { |
---|
68 | .read = rtems_nvdisk_sram_read, |
---|
69 | .write = rtems_nvdisk_sram_write, |
---|
70 | .verify = rtems_nvdisk_sram_verify |
---|
71 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.