-
Notifications
You must be signed in to change notification settings - Fork 8
/
mmiodev_TxNoramMarker.c
executable file
·54 lines (35 loc) · 1.31 KB
/
mmiodev_TxNoramMarker.c
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
//(c) uARM project https://github.com/uARM-Palm/uARM [email protected]
#include "mmiodev_TxNoRamMarker.h"
#include <string.h>
#include <stdlib.h>
#include "util.h"
#define TX_NO_RAM_MARKER_BASE 0xA5FFFFFCul
#define TX_NO_RAM_MARKER_SIZE 0x04
struct TxNoRamMarker {
uint32_t written;
};
static bool txNoRamMarkerPrvMemAccessF(void* userData, uint32_t pa, uint_fast8_t size, bool write, void* buf)
{
struct TxNoRamMarker *mrkr = (struct TxNoRamMarker*)userData;
uint32_t val;
pa -= TX_NO_RAM_MARKER_BASE;
if (size != 4 || pa) {
fprintf(stderr, "%s: Unexpected %s of %u bytes to 0x%08lx\n", __func__, write ? "write" : "read", size, (unsigned long)pa);
return false;
}
if (write)
mrkr->written = *(uint32_t*)buf;
else
*(uint32_t*)buf = ~mrkr->written; //we need to be sure written value mismatches read
return true;
}
struct TxNoRamMarker* txNoRamMarkerInit(struct ArmMem *physMem)
{
struct TxNoRamMarker* mrkr = (struct TxNoRamMarker*)malloc(sizeof(*mrkr));
if (!mrkr)
ERR("cannot alloc TX's 'NO RAM HERE' MARKER\n");
memset(mrkr, 0, sizeof (*mrkr));
if (!memRegionAdd(physMem, TX_NO_RAM_MARKER_BASE, TX_NO_RAM_MARKER_SIZE, txNoRamMarkerPrvMemAccessF, mrkr))
ERR("cannot add TX's 'NO RAM HERE' MARKER to MEM\n");
return mrkr;
}