##// END OF EJS Templates
Added host endianness management for AHB Uart Plugin.
jeandet -
r42:b9dafb3bcaed default
parent child
Show More
@@ -318,13 +318,17 unsigned int ahbuartplugin::Read(unsigne
318 }
318 }
319 for(int i=0;(unsigned int)i<cnt;i++)
319 for(int i=0;(unsigned int)i<cnt;i++)
320 {
320 {
321 for(int j =0;j<4;j++)
321 #if __BYTE_ORDER == __LITTLE_ENDIAN
322 {
322 // for(int j =0;j<4;j++)
323 Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256;
323 // {
324 // Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256;
325 // }
326 Value[i]= socexplorerBswap32(((uint32_t*)result)[i]);
327 #elif __BYTE_ORDER == __BIG_ENDIAN
328 Value[i]= ((uint32_t*)result)[i];
329 #endif
324 }
330 }
325 read = cnt*4;
331 read = cnt*4;
326
327 }
328 if(cnt>128)
332 if(cnt>128)
329 SocExplorerEngine::deleteProgressBar(progress);
333 SocExplorerEngine::deleteProgressBar(progress);
330 free(result);
334 free(result);
@@ -365,10 +369,17 unsigned int ahbuartplugin::Write(unsign
365 CMD[4] = (char)(((unsigned int)address)&0xFF);
369 CMD[4] = (char)(((unsigned int)address)&0xFF);
366 for(int i=0;i<32;i++)
370 for(int i=0;i<32;i++)
367 {
371 {
372 #if __BYTE_ORDER == __LITTLE_ENDIAN
368 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
373 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
369 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
374 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
370 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
375 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
371 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
376 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
377 #elif __BYTE_ORDER == __BIG_ENDIAN
378 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset])&0xFF);
379 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
380 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
381 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
382 #endif
372 }
383 }
373 SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0);
384 SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0);
374 writen+=32;
385 writen+=32;
@@ -392,10 +403,17 unsigned int ahbuartplugin::Write(unsign
392 CMD[4] = (char)(((unsigned int)address)&0xFF);
403 CMD[4] = (char)(((unsigned int)address)&0xFF);
393 for(int i=0;(unsigned int) i<(count);i++)
404 for(int i=0;(unsigned int) i<(count);i++)
394 {
405 {
406 #if __BYTE_ORDER == __LITTLE_ENDIAN
395 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
407 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
396 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
408 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
397 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
409 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
398 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
410 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
411 #elif __BYTE_ORDER == __BIG_ENDIAN
412 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset])&0xFF);
413 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
414 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
415 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
416 #endif
399 }
417 }
400 SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0);
418 SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0);
401 writen+=count;
419 writen+=count;
General Comments 0
You need to be logged in to leave comments. Login now