diff options
author | Ming Wei | 2015-05-14 21:23:22 -0500 |
---|---|---|
committer | Ming Wei | 2015-05-14 21:23:22 -0500 |
commit | 68e236ea5a696ed6a9af0ca5d199e4889c4075c9 (patch) | |
tree | 584fd6098cdf0f18673be151be896d889eac75c7 /src | |
parent | 0e2f00e5a84875290898a584656cbc3698c4aa2e (diff) | |
download | mpm-transport-68e236ea5a696ed6a9af0ca5d199e4889c4075c9.tar.gz mpm-transport-68e236ea5a696ed6a9af0ca5d199e4889c4075c9.tar.xz mpm-transport-68e236ea5a696ed6a9af0ca5d199e4889c4075c9.zip |
bug fix for boundary checking implementation (SDOCM00115009)
add boundary checking test case
Diffstat (limited to 'src')
-rwxr-xr-x | src/transport/hyplnk/mpm_transport_hyplnk.c | 14 | ||||
-rw-r--r-- | src/transport/test/hyplnk/hyplnk_loopback/mpm_transport_hyplnk_loopback.c | 17 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/transport/hyplnk/mpm_transport_hyplnk.c b/src/transport/hyplnk/mpm_transport_hyplnk.c index 015f1d0..77bb4c5 100755 --- a/src/transport/hyplnk/mpm_transport_hyplnk.c +++ b/src/transport/hyplnk/mpm_transport_hyplnk.c | |||
@@ -287,7 +287,7 @@ int mpm_transport_hyplnk_window_map(mpm_transport_cfg_t *sp, uint32_t addr, uint | |||
287 | uint32_t hlink_offset; | 287 | uint32_t hlink_offset; |
288 | uint8_t seg_idx = 0; | 288 | uint8_t seg_idx = 0; |
289 | mpm_transport_hyplnk_t *td = (mpm_transport_hyplnk_t *) sp->td; | 289 | mpm_transport_hyplnk_t *td = (mpm_transport_hyplnk_t *) sp->td; |
290 | uint32_t rxlen; | 290 | uint32_t seg_len, seg_offset; |
291 | 291 | ||
292 | #if TIME_PROFILE_HYPLNK_WINDOW_MAP | 292 | #if TIME_PROFILE_HYPLNK_WINDOW_MAP |
293 | clock_gettime(CLOCK_MONOTONIC, &tp_start); | 293 | clock_gettime(CLOCK_MONOTONIC, &tp_start); |
@@ -338,15 +338,17 @@ int mpm_transport_hyplnk_window_map(mpm_transport_cfg_t *sp, uint32_t addr, uint | |||
338 | } | 338 | } |
339 | else { | 339 | else { |
340 | if (td->hyplnkRxLen < 8) | 340 | if (td->hyplnkRxLen < 8) |
341 | rxlen = 0; | 341 | seg_len = 0; |
342 | else | 342 | else |
343 | rxlen = 1<<(td->hyplnkRxLen+1); | 343 | seg_len = 1<<(td->hyplnkRxLen+1); |
344 | // get the segment offset from the hlink_offset | ||
345 | seg_offset = hlink_offset & (~seg_len); | ||
344 | mpm_printf(2, "length=0x%x, hyplnkRxLen=%d\n", length, td->hyplnkRxLen); | 346 | mpm_printf(2, "length=0x%x, hyplnkRxLen=%d\n", length, td->hyplnkRxLen); |
345 | mpm_printf(2, "rxlen=0x%x, addr=0x%x, offset=0x%x\n", rxlen, td->mmap_user[user_index].addr, hlink_offset); | 347 | mpm_printf(2, "seg_len=0x%x, hlink_offset=0x%x, seg_offset=0x%x\n", seg_len, hlink_offset, seg_offset); |
346 | if ((rxlen-hlink_offset) < length) | 348 | if ((seg_len-seg_offset) < length) |
347 | { | 349 | { |
348 | td->mmap_user[user_index].addr = NULL; | 350 | td->mmap_user[user_index].addr = NULL; |
349 | mpm_printf(1, "write segment size (0x%x) larger than the available rx segement size (0x%x)\n", length, (rxlen-hlink_offset)); | 351 | mpm_printf(1, "write segment size (0x%x) larger than the available receive segement size (0x%x)\n", length, (seg_len-seg_offset)); |
350 | sem_post(&mmap_sem); | 352 | sem_post(&mmap_sem); |
351 | return -1; | 353 | return -1; |
352 | } else | 354 | } else |
diff --git a/src/transport/test/hyplnk/hyplnk_loopback/mpm_transport_hyplnk_loopback.c b/src/transport/test/hyplnk/hyplnk_loopback/mpm_transport_hyplnk_loopback.c index a826b5b..63b56f6 100644 --- a/src/transport/test/hyplnk/hyplnk_loopback/mpm_transport_hyplnk_loopback.c +++ b/src/transport/test/hyplnk/hyplnk_loopback/mpm_transport_hyplnk_loopback.c | |||
@@ -38,7 +38,9 @@ | |||
38 | #include <errno.h> | 38 | #include <errno.h> |
39 | #include "mpm_transport.h" | 39 | #include "mpm_transport.h" |
40 | 40 | ||
41 | #define TEST_BASE_HYP1 (0x0c001000) | 41 | ///#define ENABLE_HYPLNK_BOUNDARY_CHECK_TEST |
42 | |||
43 | #define TEST_BASE_HYP1 (0x0c000000) | ||
42 | #define TEST_LENGTH_HYP1 (0x1000) | 44 | #define TEST_LENGTH_HYP1 (0x1000) |
43 | #define TEST_BASE_HYP2 (0x0c008000) | 45 | #define TEST_BASE_HYP2 (0x0c008000) |
44 | #define TEST_LENGTH_HYP2 (0x2000) | 46 | #define TEST_LENGTH_HYP2 (0x2000) |
@@ -58,6 +60,10 @@ | |||
58 | 60 | ||
59 | #define MAX_LINE_LENGTH 64 | 61 | #define MAX_LINE_LENGTH 64 |
60 | 62 | ||
63 | #ifdef ENABLE_HYPLNK_BOUNDARY_CHECK_TEST | ||
64 | char large_buf[TEST_LENGTH_HYP1]; | ||
65 | #endif | ||
66 | |||
61 | int check_device_exist(char *st) | 67 | int check_device_exist(char *st) |
62 | { | 68 | { |
63 | int ret, fd; | 69 | int ret, fd; |
@@ -139,6 +145,14 @@ int main() | |||
139 | printf("testing hyperlink mpm_transport_write and mpm_transport_read\n"); | 145 | printf("testing hyperlink mpm_transport_write and mpm_transport_read\n"); |
140 | h = mpm_transport_open("dsp0-hyplnk", &ocfg); | 146 | h = mpm_transport_open("dsp0-hyplnk", &ocfg); |
141 | 147 | ||
148 | #ifdef ENABLE_HYPLNK_BOUNDARY_CHECK_TEST | ||
149 | printf("testing hyperlink mpm_transport_write boundary checking\n"); | ||
150 | if (mpm_transport_write(h, TEST_BASE_HYP1+0x3fff00, TEST_LENGTH_HYP1, large_buf, NULL)) { | ||
151 | printf("write failed at address 0x%x with len=0x%x\n", (TEST_BASE_HYP1+0x3fff00), TEST_LENGTH_HYP1); | ||
152 | mpm_transport_close(h); | ||
153 | return -1; | ||
154 | } | ||
155 | #else | ||
142 | for (i = 0; i < TEST_LENGTH_HYP1; i += 4) { | 156 | for (i = 0; i < TEST_LENGTH_HYP1; i += 4) { |
143 | val.num = TEST_BASE_HYP1 - i; | 157 | val.num = TEST_BASE_HYP1 - i; |
144 | if (mpm_transport_write(h, TEST_BASE_HYP1 + i, 4, val.buf, NULL)) { | 158 | if (mpm_transport_write(h, TEST_BASE_HYP1 + i, 4, val.buf, NULL)) { |
@@ -181,6 +195,7 @@ int main() | |||
181 | break; | 195 | break; |
182 | } | 196 | } |
183 | } | 197 | } |
198 | #endif | ||
184 | mpm_transport_close(h); | 199 | mpm_transport_close(h); |
185 | } | 200 | } |
186 | 201 | ||