-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdsptrg.c
86 lines (67 loc) · 1.59 KB
/
dsptrg.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
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
#include <stdio.h>
#include <stdint.h>
#include "armdsp.h"
#include "regs-omap-l138.h"
#define readreg(addr) (*(uint32_t volatile *)(addr))
#define writereg(addr,val) (*(uint32_t volatile *)(addr) = (val))
extern int volatile vector_table[];
static void
wmb (void)
{
/*
* reading any memory mapped reg drains write buffer
* see Cache User's Guide section 2.6
*/
readreg (L1PCFG);
}
/*
* low level communication between arm and dsp
* called on the dsp side by ti's rtssrc/SHARED/trgdrv.c
* they mate with armdsp/armhost.c
*/
void
writemsg (unsigned char command,
const unsigned char *params,
const char *data,
unsigned int length)
{
struct armdsp_trgbuf volatile *trgbuf;
uint8_t *p;
if (1 + 8 + length > ARMDSP_COMM_TRGBUF_SIZE)
exit (1);
trgbuf = (struct armdsp_trgbuf volatile *)
((unsigned char *)vector_table + ARMDSP_COMM_TRGBUF);
p = (uint8_t *)trgbuf->buf;
*p++ = command;
memcpy (p, params, 8);
p += 8;
memcpy (p, data, length);
p += length;
trgbuf->length = p - trgbuf->buf;
wmb ();
trgbuf->owner = ARMDSP_TRGBUF_OWNER_ARM;
writereg (SYSCFG0_CHIPSIG, 1); /* CHIPINT0 to arm */
}
void
readmsg (unsigned char *params, char *data)
{
struct armdsp_trgbuf volatile *trgbuf;
uint32_t length;
uint8_t *inp;
trgbuf = (struct armdsp_trgbuf volatile *)
((unsigned char *)vector_table + ARMDSP_COMM_TRGBUF);
while (1) {
if (trgbuf->owner == ARMDSP_TRGBUF_OWNER_DSP)
break;
}
length = trgbuf->length;
if (length < 8)
exit (1);
inp = (uint8_t *)trgbuf->buf;
memcpy (params, inp, 8);
if (data) {
inp += 8;
length -= 8;
memcpy (data, inp, length);
}
}