1 /**
2 * \ingroup MODULMACROSXV2
3 *
4 * \file SendJtagMailboxXv2.c
5 *
6 * \brief <FILEBRIEF>
7 *
8 */
9 /*
10 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
11 *
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42 #include "arch.h"
43 #include "edt.h"
44 #include "hal.h"
45 #include "stream.h"
46 #include "error_def.h"
47 #include "JtagId.h"
48 #ifdef DB_PRINT
49 #include "debug.h"
50 #endif
51
52 /**
53 WriteMemBytesXv2
54 Write bytes to a memory mapped location.
55 inData: <addr(32)> <length(32)> <data(8)>{*}
56 outData: -
57 addr: the address to start writing to
58 length: number of bytes to write
59 data: data to write to the given location
60 */
HAL_FUNCTION(_hal_SendJtagMailboxXv2)61 HAL_FUNCTION(_hal_SendJtagMailboxXv2)
62 {
63 static unsigned short MailBoxMode;
64 static unsigned short DATA1 = 0x0, DATA2 = 0x0;
65 unsigned char jtagMailboxIn = 0;
66
67 if(STREAM_get_word(&MailBoxMode) != 0)
68 {
69 return(HALERR_UNDEFINED_ERROR);
70 }
71 // get length ot be flashed
72 if(STREAM_get_word(&DATA1) != 0)
73 {
74 return(HALERR_UNDEFINED_ERROR);
75 }
76 if(STREAM_get_word(&DATA2) == -1)
77 {
78 return(HALERR_UNDEFINED_ERROR);
79 }
80 IHIL_EntrySequences(RSTLOW);
81 IHIL_TapReset();
82
83 if(MailBoxMode == 0x11)// 32Bit Mode
84 {
85 jtagMailboxIn = i_WriteJmbIn32(DATA1,DATA2);
86 }
87 else // 16 Bit Mode
88 {
89 jtagMailboxIn = i_WriteJmbIn(DATA1);
90 }
91 // check if mailbox input was ok
92 if(jtagMailboxIn)
93 {
94 return(HALERR_UNDEFINED_ERROR);
95 }
96 IHIL_SetReset(1);
97 IHIL_Delay_1ms(40);
98
99 IHIL_EntrySequences(RSTHIGH);
100 IHIL_Delay_1ms(200);
101 IHIL_TapReset();
102
103
104 if (jtagIdIsXv2(cntrl_sig_capture()))
105 {
106 return 0;
107 }
108 return HALERR_UNDEFINED_ERROR;
109 }
110