FreeCalypso > hg > freecalypso-sw
annotate rvinterf/asyncshell/sendsp.c @ 898:cc9d97d0e911
gsm-fw: DWNLD (static DSP patch) and L1_DYN_DSP_DWNLD moved to config mechanism
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 05 Jul 2015 02:41:39 +0000 |
parents | dab341e172de |
children | bd873572ef2c |
rev | line source |
---|---|
875
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Functions for sending GPF system primitives to the target |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <ctype.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <stdlib.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "pktmux.h" |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "limits.h" |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 send_gpf_sysprim(stackdest, primstr) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 char *stackdest, *primstr; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 unsigned intlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u_char sendpkt[MAX_PKT_TO_TARGET+1]; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 unsigned pktlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 if (strlen(stackdest) > 4) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 printf( |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 "error: stack destination arg may not exceed 4 characters\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 return(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 intlen = 12 + strlen(primstr); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 pktlen = intlen + 4; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (pktlen > MAX_PKT_TO_TARGET) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 printf("error: max pkt to target limit exceeded\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 return(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 /* fill out the packet */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 sendpkt[0] = RVT_L23_HEADER; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 sendpkt[1] = 0xB7; /* system prim */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 sendpkt[2] = intlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 sendpkt[3] = intlen >> 8; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 /* send zeros for the timestamp */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 sendpkt[4] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 sendpkt[5] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 sendpkt[6] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 sendpkt[7] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 /* as far as TI's sw is concerned, we are PCO */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 sendpkt[8] = 'P'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 sendpkt[9] = 'C'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 sendpkt[10] = 'O'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 sendpkt[11] = ' '; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 sprintf(sendpkt + 12, "%-4s%s", stackdest, primstr); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 /* send it! */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 send_pkt_to_target(sendpkt, pktlen); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 return(0); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 void |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 cmd_sendsp(args) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 char *args; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 char *cp, *np; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 for (cp = args; isspace(*cp); cp++) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 ; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 if (!*cp) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 err: printf("error: two arguments required\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 return; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 for (np = cp; *cp && !isspace(*cp); cp++) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 ; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (!*cp) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 goto err; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 *cp++ = '\0'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 while (isspace(*cp)) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 cp++; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (!*cp) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 goto err; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 gpf_rx_control(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 send_gpf_sysprim(np, cp); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 } |