ReadMemBytes.c
1 /**
2 * \ingroup MODULMACROS
3 *
4 * \file ReadMemBytes.c
5 *
6 * \brief Read bytes from a memory mapped location
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "stream.h"
47
48 /**
49 ReadMemBytes
50 Read bytes from a memory mapped location.
51 inData: <addr(32)> <length(32)>
52 outData: <data(8)>{*}
53 addr: the address to start reading from
54 length: number of bytes to read
55 data: requested data
56 */
57
HAL_FUNCTION(_hal_ReadMemBytes)58 HAL_FUNCTION(_hal_ReadMemBytes)
59 {
60 short ret_value = 0;
61 unsigned long i;
62 unsigned long lAddr;
63 unsigned long lLen;
64
65 if(STREAM_get_long(&lAddr) != 0)
66 {
67 ret_value = HALERR_READ_MEM_BYTES_NO_ADDRESS;
68 goto exit;
69 }
70 if(STREAM_get_long(&lLen) < 0)
71 {
72 ret_value = HALERR_READ_MEM_BYTES_NO_SIZE;
73 goto exit;
74 }
75 halt_cpu();
76 IHIL_Tclk(0);
77 cntrl_sig_16bit();
78 SetReg_16Bits(0x2419);
79
80 lLen *= 2; //DLL always sends size in word
81 for(i = 0; i < lLen; i++)
82 {
83 addr_16bit();
84 SetReg_16Bits((unsigned short)lAddr);
85 data_to_addr();
86 IHIL_Tclk(1);
87 IHIL_Tclk(0);
88 STREAM_put_byte((unsigned char)(SetReg_16Bits(0) & 0xFF));
89 lAddr += 1;
90 }
91 release_cpu();
92 exit:
93 return(ret_value);
94 }
95
96
ReadMemBytesX.c
1 /**
2 * \ingroup MODULMACROSX
3 *
4 * \file ReadMemBytesX.c
5 *
6 * \brief Read bytes from a memory mapped location
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "stream.h"
47 #ifdef DB_PRINT
48 #include "debug.h"
49 #endif
50
HAL_FUNCTION(_hal_ReadMemBytesX)51 HAL_FUNCTION(_hal_ReadMemBytesX)
52 {
53 unsigned long i;
54 unsigned long lAddr;
55 unsigned long lLen;
56
57 if(STREAM_get_long(&lAddr) != 0)
58 {
59 return HALERR_READ_MEM_WORD_NO_ADDRESS;
60 }
61 if(STREAM_get_long(&lLen) < 0)
62 {
63 return HALERR_READ_MEM_WORD_NO_SIZE;
64 }
65
66 halt_cpu();
67 IHIL_Tclk(0);
68 cntrl_sig_low_byte();
69 SetReg_16Bits(0x19);
70
71 lLen *= 2; //DLL always sends size in word
72 for(i = 0; i < lLen; i++)
73 {
74 addr_16bit();
75 SetReg_20Bits(lAddr);
76 data_to_addr();
77 IHIL_Tclk(1);
78 IHIL_Tclk(0);
79 STREAM_put_byte((unsigned char)(SetReg_16Bits(0) & 0xFF));
80 lAddr += 1;
81 }
82 IHIL_Tclk(1);
83
84 release_cpu();
85 return 0;
86 }
87
88
ReadMemBytesXv2.c
1 /**
2 * \ingroup MODULMACROSXV2
3 *
4 * \file ReadMemBytesXv2.c
5 *
6 * \brief Read bytes from a memory mapped location
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 #ifdef DB_PRINT
48 #include "debug.h"
49 #endif
50
51 /**
52 ReadMemBytesXv2
53 Read bytes from a memory mapped location.
54 inData: <addr(32)> <length(32)>
55 outData: <data(8)>{*}
56 addr: the address to start reading from
57 length: number of bytes to read
58 data: requested data
59 */
60
HAL_FUNCTION(_hal_ReadMemBytesXv2)61 HAL_FUNCTION(_hal_ReadMemBytesXv2)
62 {
63 //! \todo not supported for Xv2
64 return HALERR_UNDEFINED_ERROR;
65 }
66
67
ReadMemQuick.c
1 /**
2 * \ingroup <FILEGROUP>
3 *
4 * \file ReadMemQuick.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location in data quick mode
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "stream.h"
47 #ifdef DB_PRINT
48 #include "debug.h"
49 #endif
50
51 /**
52 ReadMemQuick
53 Read words (16bit values) from a memory mapped location in data quick mode.
54 inData: <addr(32)> <length(32)>
55 outData: <data(16)>{*}
56 addr: the address to start reading from
57 length: number of words to read
58 data: requested data
59 */
60
61
HAL_FUNCTION(_hal_ReadMemQuick)62 HAL_FUNCTION(_hal_ReadMemQuick)
63 {
64 unsigned long i;
65 unsigned long lAddr;
66 unsigned long lLen;
67 unsigned short Pc;
68
69 STREAM_get_long(&lAddr);
70 STREAM_get_long(&lLen);
71
72 Pc = (unsigned short)((lAddr-2 & 0xFFFF));
73
74 instrLoad();
75
76 SetPc(Pc);
77
78 halt_cpu();
79
80 data_quick();
81
82 for (i = 0; i < lLen; i++)
83 {
84 IHIL_Tclk(1);
85 IHIL_Tclk(0);
86 STREAM_put_word(SetReg_16Bits(0));
87 }
88 IHIL_Tclk(1);
89
90 release_cpu();
91
92 return 0;
93 }
94
ReadMemQuickX.c
1 /**
2 * \ingroup MODULMACROSX
3 *
4 * \file ReadMemQuickX.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location in data quick mode
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "hal_ref.h"
47 #include "stream.h"
48
HAL_FUNCTION(_hal_ReadMemQuickX)49 HAL_FUNCTION(_hal_ReadMemQuickX)
50 {
51 unsigned long i;
52 unsigned long lAddr;
53 unsigned long lLen;
54
55 STREAM_get_long(&lAddr);
56 STREAM_get_long(&lLen);
57
58 instrLoad();
59
60 SetPcX(lAddr - 2);
61
62 halt_cpu();
63
64 data_quick();
65
66 for (i = 0; i < lLen; i++)
67 {
68 IHIL_Tclk(1);
69 IHIL_Tclk(0);
70 STREAM_put_word(SetReg_16Bits(0));
71 }
72 IHIL_Tclk(1);
73
74 release_cpu();
75
76 return 0;
77 }
78
ReadMemQuickXv2.c
1 /**
2 * \ingroup MODULMACROSXV2
3 *
4 * \file ReadMemQuickXv2.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location in data quick mode
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 "hal_ref.h"
46 #include "stream.h"
47
48 /**
49 ReadMemQuickXv2
50 Read words (16bit values) from a memory mapped location in data quick mode.
51 inData: <addr(32)> <length(32)>
52 outData: <data(16)>{*}
53 addr: the address to start reading from
54 length: number of words to read
55 data: requested data
56 */
57
HAL_FUNCTION(_hal_ReadMemQuickXv2)58 HAL_FUNCTION(_hal_ReadMemQuickXv2)
59 {
60 unsigned long i;
61 unsigned long lAddr;
62 unsigned long lLen;
63 unsigned long lPc;
64 unsigned short Mova;
65 unsigned short Pc_l;
66 unsigned short id = cntrl_sig_capture();
67
68 STREAM_get_long(&lAddr);
69 STREAM_get_long(&lLen);
70 STREAM_get_long(&lPc);
71 if(id == JTAGVERSION91 || id == JTAGVERSION99 || id == JTAGVERSION98)
72 { // Set PC to "safe" address
73 lPc = SAFE_PC_ADDRESS;
74 }
75
76 Mova = 0x0080;
77 Mova += (unsigned short)((lAddr>>8) & 0x00000F00);
78 Pc_l = (unsigned short)((lAddr & 0xFFFF));
79
80 // SET PROGRAM COUNTER for QUICK ACCESS
81 SetPcXv2(Mova, Pc_l);
82 cntrl_sig_16bit();
83 SetReg_16Bits(0x0501);
84 IHIL_Tclk(1);
85 addr_capture();
86 // END OF SETTING THE PROGRAM COUNTER
87 data_quick();
88
89 // DATA QUICK LOOP
90 for (i = 0; i < lLen; i++)
91 {
92 IHIL_Tclk(1);
93 IHIL_Tclk(0);
94 STREAM_put_word( SetReg_16Bits(0));
95 }
96 // Check save State
97 cntrl_sig_capture();
98 SetReg_16Bits(0x0000);
99
100 // Restore PC
101 Mova = 0x0080;
102 Mova += (unsigned short)((lPc>>8) & 0x00000F00);
103 Pc_l = (unsigned short)((lPc & 0xFFFF));
104
105 // SET PROGRAM COUNTER for Backup
106 SetPcXv2(Mova, Pc_l);
107 cntrl_sig_16bit();
108 SetReg_16Bits(0x0501);
109 IHIL_Tclk(1);
110 addr_capture();
111
112 return 0;
113 }
114
ReadMemWords.c
1 /**
2 * \ingroup MODULMACROS
3 *
4 * \file ReadMemWords.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "hal_ref.h"
47 #include "stream.h"
48
49 extern unsigned long lAddr;
50 extern unsigned long lLen;
51
52 /**
53 ReadMemWords
54 Read words (16bit values) from a memory mapped location.
55 inData: <addr(32)> <length(32)>
56 outData: <data(16)>{*}
57 addr: the address to start reading from
58 length: number of words to read
59 data: requested data
60 */
61
HAL_FUNCTION(_hal_ReadMemWords)62 HAL_FUNCTION(_hal_ReadMemWords)
63 {
64 unsigned long i;
65 unsigned long lAddr;
66 unsigned long lLen;
67
68 if(STREAM_get_long(&lAddr) != 0)
69 {
70 return HALERR_READ_MEM_WORD_NO_ADDRESS;
71 }
72 if(STREAM_get_long(&lLen) < 0)
73 {
74 return HALERR_READ_MEM_WORD_NO_SIZE;
75 }
76
77 halt_cpu();
78 IHIL_Tclk(0);
79 for(i = 0; i < lLen; i++)
80 {
81 addr_16bit();
82 SetReg_16Bits((unsigned short)lAddr);
83 data_to_addr();
84 IHIL_Tclk(1);
85 IHIL_Tclk(0);
86 STREAM_put_word(SetReg_16Bits(0));
87 lAddr += 2;
88 }
89 IHIL_Tclk(1);
90 release_cpu();
91
92 instrLoad();
93
94 return 0;
95 }
96
ReadMemWordsX.c
1 /**
2 * \ingroup MODULMACROSX
3 *
4 * \file ReadMemWordsX.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location
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 "error_def.h"
43 #include "arch.h"
44 #include "edt.h"
45 #include "hal.h"
46 #include "hal_ref.h"
47 #include "stream.h"
48
HAL_FUNCTION(_hal_ReadMemWordsX)49 HAL_FUNCTION(_hal_ReadMemWordsX)
50 {
51 unsigned long i;
52 unsigned long lAddr;
53 unsigned long lLen;
54
55 if(STREAM_get_long(&lAddr) != 0)
56 {
57 return HALERR_READ_MEM_WORD_NO_ADDRESS;
58 }
59 if(STREAM_get_long(&lLen) < 0)
60 {
61 return HALERR_READ_MEM_WORD_NO_SIZE;
62 }
63
64 halt_cpu();
65 IHIL_Tclk(0);
66
67 for(i = 0; i < lLen; i++)
68 {
69 addr_16bit();
70 SetReg_20Bits(lAddr);
71 data_to_addr();
72 IHIL_Tclk(1);
73 IHIL_Tclk(0);
74 STREAM_put_word(SetReg_16Bits(0));
75 lAddr += 2;
76 }
77 IHIL_Tclk(1);
78
79 release_cpu();
80 return 0;
81 }
82
83
ReadMemWordsXv2.c
1 /**
2 * \ingroup MODULMACROSXV2
3 *
4 * \file ReadMemWordsXv2.c
5 *
6 * \brief Read words (16bit values) from a memory mapped location
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
47 /**
48 ReadMemWordsXv2
49 Read words (16bit values) from a memory mapped location.
50 inData: <addr(32)> <length(32)>
51 outData: <data(16)>{*}
52 addr: the address to start reading from
53 length: number of words to read
54 data: requested data
55 */
56
HAL_FUNCTION(_hal_ReadMemWordsXv2)57 HAL_FUNCTION(_hal_ReadMemWordsXv2)
58 {
59 unsigned long i;
60 unsigned long lAddr;
61 unsigned long lLen;
62
63 STREAM_get_long(&lAddr);
64 STREAM_get_long(&lLen);
65
66 IHIL_Tclk(0);
67
68 for(i = 0; i < lLen; i++)
69 {
70 addr_16bit();
71 SetReg_20Bits(lAddr);
72 IHIL_Tclk(1);
73 IHIL_Tclk(0);
74 data_capture();
75 STREAM_put_word(SetReg_16Bits(0));
76 lAddr += 2;
77 }
78 IHIL_Tclk(1);
79 // one or more cycle, so CPU is driving correct MAB
80 IHIL_TCLK();
81
82 return 0;
83 }
84
85