• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 
3   (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4       www.systec-electronic.com
5 
6   Project:      openPOWERLINK
7 
8   Description:  Abstract Memory Interface for x86 compatible
9 
10   License:
11 
12     Redistribution and use in source and binary forms, with or without
13     modification, are permitted provided that the following conditions
14     are met:
15 
16     1. Redistributions of source code must retain the above copyright
17        notice, this list of conditions and the following disclaimer.
18 
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22 
23     3. Neither the name of SYSTEC electronic GmbH nor the names of its
24        contributors may be used to endorse or promote products derived
25        from this software without prior written permission. For written
26        permission, please contact info@systec-electronic.com.
27 
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39     POSSIBILITY OF SUCH DAMAGE.
40 
41     Severability Clause:
42 
43         If a provision of this License is or becomes illegal, invalid or
44         unenforceable in any jurisdiction, that shall not affect:
45         1. the validity or enforceability in that jurisdiction of any other
46            provision of this License; or
47         2. the validity or enforceability in other jurisdictions of that or
48            any other provision of this License.
49 
50   -------------------------------------------------------------------------
51 
52                 $RCSfile: amix86.c,v $
53 
54                 $Author: D.Krueger $
55 
56                 $Revision: 1.3 $  $Date: 2008/04/17 21:36:32 $
57 
58                 $State: Exp $
59 
60                 Build Environment:
61                     ...
62 
63   -------------------------------------------------------------------------
64 
65   Revision History:
66 
67   r.s.: first implemetation
68 
69   2006-06-13  d.k.: duplicate functions for little endian and big endian
70 
71 ****************************************************************************/
72 
73 //#include "global.h"
74 //#include "EplAmi.h"
75 #include "EplInc.h"
76 
77 #if (!defined(EPL_AMI_INLINED)) || defined(INLINE_ENABLED)
78 
79 //---------------------------------------------------------------------------
80 // typedef
81 //---------------------------------------------------------------------------
82 
83 typedef struct {
84 	WORD m_wWord;
85 
86 } twStruct;
87 
88 typedef struct {
89 	DWORD m_dwDword;
90 
91 } tdwStruct;
92 
93 typedef struct {
94 	QWORD m_qwQword;
95 
96 } tqwStruct;
97 
98 //=========================================================================//
99 //                                                                         //
100 //          P U B L I C   F U N C T I O N S                                //
101 //                                                                         //
102 //=========================================================================//
103 
104 //---------------------------------------------------------------------------
105 //
106 // Function:    AmiSetXXXToBe()
107 //
108 // Description: writes the specified value to the absolute address in
109 //              big endian
110 //
111 // Parameters:  pAddr_p                 = absolute address
112 //              xXXXVal_p               = value
113 //
114 // Returns:     (none)
115 //
116 // State:
117 //
118 //---------------------------------------------------------------------------
119 
120 //------------< write BYTE in big endian >--------------------------
121 /*
122 void  PUBLIC  AmiSetByteToBe (void FAR* pAddr_p, BYTE bByteVal_p)
123 {
124 
125    *(BYTE FAR*)pAddr_p = bByteVal_p;
126 
127 }
128 */
129 
130 //------------< write WORD in big endian >--------------------------
131 
AmiSetWordToBe(void FAR * pAddr_p,WORD wWordVal_p)132 INLINE_FUNCTION void PUBLIC AmiSetWordToBe(void FAR * pAddr_p, WORD wWordVal_p)
133 {
134 	twStruct FAR *pwStruct;
135 	twStruct wValue;
136 
137 	wValue.m_wWord = (WORD) ((wWordVal_p & 0x00FF) << 8);	//LSB to MSB
138 	wValue.m_wWord |= (WORD) ((wWordVal_p & 0xFF00) >> 8);	//MSB to LSB
139 
140 	pwStruct = (twStruct FAR *) pAddr_p;
141 	pwStruct->m_wWord = wValue.m_wWord;
142 
143 }
144 
145 //------------< write DWORD in big endian >-------------------------
146 
AmiSetDwordToBe(void FAR * pAddr_p,DWORD dwDwordVal_p)147 INLINE_FUNCTION void PUBLIC AmiSetDwordToBe(void FAR * pAddr_p,
148 					    DWORD dwDwordVal_p)
149 {
150 	tdwStruct FAR *pdwStruct;
151 	tdwStruct dwValue;
152 
153 	dwValue.m_dwDword = ((dwDwordVal_p & 0x000000FF) << 24);	//LSB to MSB
154 	dwValue.m_dwDword |= ((dwDwordVal_p & 0x0000FF00) << 8);
155 	dwValue.m_dwDword |= ((dwDwordVal_p & 0x00FF0000) >> 8);
156 	dwValue.m_dwDword |= ((dwDwordVal_p & 0xFF000000) >> 24);	//MSB to LSB
157 
158 	pdwStruct = (tdwStruct FAR *) pAddr_p;
159 	pdwStruct->m_dwDword = dwValue.m_dwDword;
160 
161 }
162 
163 //---------------------------------------------------------------------------
164 //
165 // Function:    AmiSetXXXToLe()
166 //
167 // Description: writes the specified value to the absolute address in
168 //              little endian
169 //
170 // Parameters:  pAddr_p                 = absolute address
171 //              xXXXVal_p               = value
172 //
173 // Returns:     (none)
174 //
175 // State:
176 //
177 //---------------------------------------------------------------------------
178 
179 //------------< write BYTE in little endian >--------------------------
180 /*
181 void  PUBLIC  AmiSetByteToLe (void FAR* pAddr_p, BYTE bByteVal_p)
182 {
183 
184    *(BYTE FAR*)pAddr_p = bByteVal_p;
185 
186 }
187 */
188 
189 //------------< write WORD in little endian >--------------------------
190 
AmiSetWordToLe(void FAR * pAddr_p,WORD wWordVal_p)191 INLINE_FUNCTION void PUBLIC AmiSetWordToLe(void FAR * pAddr_p, WORD wWordVal_p)
192 {
193 	twStruct FAR *pwStruct;
194 
195 	pwStruct = (twStruct FAR *) pAddr_p;
196 	pwStruct->m_wWord = wWordVal_p;
197 
198 }
199 
200 //------------< write DWORD in little endian >-------------------------
201 
AmiSetDwordToLe(void FAR * pAddr_p,DWORD dwDwordVal_p)202 INLINE_FUNCTION void PUBLIC AmiSetDwordToLe(void FAR * pAddr_p,
203 					    DWORD dwDwordVal_p)
204 {
205 	tdwStruct FAR *pdwStruct;
206 
207 	pdwStruct = (tdwStruct FAR *) pAddr_p;
208 	pdwStruct->m_dwDword = dwDwordVal_p;
209 
210 }
211 
212 //---------------------------------------------------------------------------
213 //
214 // Function:    AmiGetXXXFromBe()
215 //
216 // Description: reads the specified value from the absolute address in
217 //              big endian
218 //
219 // Parameters:  pAddr_p                 = absolute address
220 //
221 // Returns:     XXX                     = value
222 //
223 // State:
224 //
225 //---------------------------------------------------------------------------
226 
227 //------------< read BYTE in big endian >---------------------------
228 /*
229 BYTE  PUBLIC  AmiGetByteFromBe (void FAR* pAddr_p)
230 {
231 
232    return ( *(BYTE FAR*)pAddr_p );
233 
234 }
235 */
236 
237 //------------< read WORD in big endian >---------------------------
238 
AmiGetWordFromBe(void FAR * pAddr_p)239 INLINE_FUNCTION WORD PUBLIC AmiGetWordFromBe(void FAR * pAddr_p)
240 {
241 	twStruct FAR *pwStruct;
242 	twStruct wValue;
243 
244 	pwStruct = (twStruct FAR *) pAddr_p;
245 
246 	wValue.m_wWord = (WORD) ((pwStruct->m_wWord & 0x00FF) << 8);	//LSB to MSB
247 	wValue.m_wWord |= (WORD) ((pwStruct->m_wWord & 0xFF00) >> 8);	//MSB to LSB
248 
249 	return (wValue.m_wWord);
250 
251 }
252 
253 //------------< read DWORD in big endian >--------------------------
254 
AmiGetDwordFromBe(void FAR * pAddr_p)255 INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromBe(void FAR * pAddr_p)
256 {
257 	tdwStruct FAR *pdwStruct;
258 	tdwStruct dwValue;
259 
260 	pdwStruct = (tdwStruct FAR *) pAddr_p;
261 
262 	dwValue.m_dwDword = ((pdwStruct->m_dwDword & 0x000000FF) << 24);	//LSB to MSB
263 	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x0000FF00) << 8);
264 	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x00FF0000) >> 8);
265 	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0xFF000000) >> 24);	//MSB to LSB
266 
267 	return (dwValue.m_dwDword);
268 
269 }
270 
271 //---------------------------------------------------------------------------
272 //
273 // Function:    AmiGetXXXFromLe()
274 //
275 // Description: reads the specified value from the absolute address in
276 //              little endian
277 //
278 // Parameters:  pAddr_p                 = absolute address
279 //
280 // Returns:     XXX                     = value
281 //
282 // State:
283 //
284 //---------------------------------------------------------------------------
285 
286 //------------< read BYTE in little endian >---------------------------
287 /*
288 BYTE  PUBLIC  AmiGetByteFromLe (void FAR* pAddr_p)
289 {
290 
291    return ( *(BYTE FAR*)pAddr_p );
292 
293 }
294 */
295 
296 //------------< read WORD in little endian >---------------------------
297 
AmiGetWordFromLe(void FAR * pAddr_p)298 INLINE_FUNCTION WORD PUBLIC AmiGetWordFromLe(void FAR * pAddr_p)
299 {
300 	twStruct FAR *pwStruct;
301 
302 	pwStruct = (twStruct FAR *) pAddr_p;
303 	return (pwStruct->m_wWord);
304 
305 }
306 
307 //------------< read DWORD in little endian >--------------------------
308 
AmiGetDwordFromLe(void FAR * pAddr_p)309 INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromLe(void FAR * pAddr_p)
310 {
311 	tdwStruct FAR *pdwStruct;
312 
313 	pdwStruct = (tdwStruct FAR *) pAddr_p;
314 	return (pdwStruct->m_dwDword);
315 
316 }
317 
318 //---------------------------------------------------------------------------
319 //
320 // Function:    AmiSetDword24ToBe()
321 //
322 // Description: sets a 24 bit value to a buffer in big endian
323 //
324 // Parameters:  pAddr_p         = pointer to destination buffer
325 //              dwDwordVal_p    = value to set
326 //
327 // Return:      void
328 //
329 // State:       not tested
330 //
331 //---------------------------------------------------------------------------
332 
AmiSetDword24ToBe(void FAR * pAddr_p,DWORD dwDwordVal_p)333 INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe(void FAR * pAddr_p,
334 					      DWORD dwDwordVal_p)
335 {
336 
337 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[2];
338 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
339 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[0];
340 
341 }
342 
343 //---------------------------------------------------------------------------
344 //
345 // Function:    AmiSetDword24ToLe()
346 //
347 // Description: sets a 24 bit value to a buffer in little endian
348 //
349 // Parameters:  pAddr_p         = pointer to destination buffer
350 //              dwDwordVal_p    = value to set
351 //
352 // Return:      void
353 //
354 // State:       not tested
355 //
356 //---------------------------------------------------------------------------
357 
AmiSetDword24ToLe(void FAR * pAddr_p,DWORD dwDwordVal_p)358 INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe(void FAR * pAddr_p,
359 					      DWORD dwDwordVal_p)
360 {
361 
362 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[0];
363 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
364 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[2];
365 
366 }
367 
368 //---------------------------------------------------------------------------
369 //
370 // Function:    AmiGetDword24FromBe()
371 //
372 // Description: reads a 24 bit value from a buffer in big endian
373 //
374 // Parameters:  pAddr_p         = pointer to source buffer
375 //
376 // Return:      DWORD           = read value
377 //
378 // State:       not tested
379 //
380 //---------------------------------------------------------------------------
381 
AmiGetDword24FromBe(void FAR * pAddr_p)382 INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe(void FAR * pAddr_p)
383 {
384 
385 	tdwStruct dwStruct;
386 
387 	dwStruct.m_dwDword = AmiGetDwordFromBe(pAddr_p);
388 	dwStruct.m_dwDword >>= 8;
389 
390 	return (dwStruct.m_dwDword);
391 
392 }
393 
394 //---------------------------------------------------------------------------
395 //
396 // Function:    AmiGetDword24FromLe()
397 //
398 // Description: reads a 24 bit value from a buffer in little endian
399 //
400 // Parameters:  pAddr_p         = pointer to source buffer
401 //
402 // Return:      DWORD           = read value
403 //
404 // State:       not tested
405 //
406 //---------------------------------------------------------------------------
407 
AmiGetDword24FromLe(void FAR * pAddr_p)408 INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe(void FAR * pAddr_p)
409 {
410 
411 	tdwStruct dwStruct;
412 
413 	dwStruct.m_dwDword = AmiGetDwordFromLe(pAddr_p);
414 	dwStruct.m_dwDword &= 0x00FFFFFF;
415 
416 	return (dwStruct.m_dwDword);
417 
418 }
419 
420 //#ifdef USE_VAR64
421 
422 //---------------------------------------------------------------------------
423 //
424 // Function:    AmiSetQword64ToBe()
425 //
426 // Description: sets a 64 bit value to a buffer in big endian
427 //
428 // Parameters:  pAddr_p         = pointer to destination buffer
429 //              qwQwordVal_p    = quadruple word value
430 //
431 // Return:      void
432 //
433 // State:       not tested
434 //
435 //---------------------------------------------------------------------------
436 
AmiSetQword64ToBe(void FAR * pAddr_p,QWORD qwQwordVal_p)437 INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe(void FAR * pAddr_p,
438 					      QWORD qwQwordVal_p)
439 {
440 
441 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[7];
442 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[6];
443 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[5];
444 	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[4];
445 	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[3];
446 	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[2];
447 	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[1];
448 	((BYTE FAR *) pAddr_p)[7] = ((BYTE FAR *) & qwQwordVal_p)[0];
449 
450 }
451 
452 //---------------------------------------------------------------------------
453 //
454 // Function:    AmiSetQword64ToLe()
455 //
456 // Description: sets a 64 bit value to a buffer in little endian
457 //
458 // Parameters:  pAddr_p         = pointer to destination buffer
459 //              qwQwordVal_p    = quadruple word value
460 //
461 // Return:      void
462 //
463 // State:       not tested
464 //
465 //---------------------------------------------------------------------------
466 
AmiSetQword64ToLe(void FAR * pAddr_p,QWORD qwQwordVal_p)467 INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe(void FAR * pAddr_p,
468 					      QWORD qwQwordVal_p)
469 {
470 
471 	QWORD FAR *pqwDst;
472 
473 	pqwDst = (QWORD FAR *) pAddr_p;
474 	*pqwDst = qwQwordVal_p;
475 
476 }
477 
478 //---------------------------------------------------------------------------
479 //
480 // Function:    AmiGetQword64FromBe()
481 //
482 // Description: reads a 64 bit value from a buffer in big endian
483 //
484 // Parameters:  pAddr_p         = pointer to source buffer
485 //
486 // Return:      void
487 //
488 // State:       not tested
489 //
490 //---------------------------------------------------------------------------
491 
AmiGetQword64FromBe(void FAR * pAddr_p)492 INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe(void FAR * pAddr_p)
493 {
494 
495 	tqwStruct qwStruct;
496 
497 	((BYTE FAR *) & qwStruct.m_qwQword)[0] = ((BYTE FAR *) pAddr_p)[7];
498 	((BYTE FAR *) & qwStruct.m_qwQword)[1] = ((BYTE FAR *) pAddr_p)[6];
499 	((BYTE FAR *) & qwStruct.m_qwQword)[2] = ((BYTE FAR *) pAddr_p)[5];
500 	((BYTE FAR *) & qwStruct.m_qwQword)[3] = ((BYTE FAR *) pAddr_p)[4];
501 	((BYTE FAR *) & qwStruct.m_qwQword)[4] = ((BYTE FAR *) pAddr_p)[3];
502 	((BYTE FAR *) & qwStruct.m_qwQword)[5] = ((BYTE FAR *) pAddr_p)[2];
503 	((BYTE FAR *) & qwStruct.m_qwQword)[6] = ((BYTE FAR *) pAddr_p)[1];
504 	((BYTE FAR *) & qwStruct.m_qwQword)[7] = ((BYTE FAR *) pAddr_p)[0];
505 
506 	return (qwStruct.m_qwQword);
507 
508 }
509 
510 //---------------------------------------------------------------------------
511 //
512 // Function:    AmiGetQword64FromLe()
513 //
514 // Description: reads a 64 bit value from a buffer in little endian
515 //
516 // Parameters:  pAddr_p         = pointer to source buffer
517 //
518 // Return:      void
519 //
520 // State:       not tested
521 //
522 //---------------------------------------------------------------------------
523 
AmiGetQword64FromLe(void FAR * pAddr_p)524 INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe(void FAR * pAddr_p)
525 {
526 
527 	tqwStruct FAR *pqwStruct;
528 	tqwStruct qwStruct;
529 
530 	pqwStruct = (tqwStruct FAR *) pAddr_p;
531 	qwStruct.m_qwQword = pqwStruct->m_qwQword;
532 
533 	return (qwStruct.m_qwQword);
534 
535 }
536 
537 //---------------------------------------------------------------------------
538 //
539 // Function:    AmiSetQword40ToBe()
540 //
541 // Description: sets a 40 bit value to a buffer in big endian
542 //
543 // Parameters:  pAddr_p         = pointer to destination buffer
544 //              qwQwordVal_p    = quadruple word value
545 //
546 // Return:      void
547 //
548 // State:       not tested
549 //
550 //---------------------------------------------------------------------------
551 
AmiSetQword40ToBe(void FAR * pAddr_p,QWORD qwQwordVal_p)552 INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe(void FAR * pAddr_p,
553 					      QWORD qwQwordVal_p)
554 {
555 
556 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[4];
557 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[3];
558 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[2];
559 	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[1];
560 	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[0];
561 
562 }
563 
564 //---------------------------------------------------------------------------
565 //
566 // Function:    AmiSetQword40ToLe()
567 //
568 // Description: sets a 40 bit value to a buffer in little endian
569 //
570 // Parameters:  pAddr_p         = pointer to destination buffer
571 //              qwQwordVal_p    = quadruple word value
572 //
573 // Return:      void
574 //
575 // State:       not tested
576 //
577 //---------------------------------------------------------------------------
578 
AmiSetQword40ToLe(void FAR * pAddr_p,QWORD qwQwordVal_p)579 INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe(void FAR * pAddr_p,
580 					      QWORD qwQwordVal_p)
581 {
582 
583 	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
584 	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[4];
585 
586 }
587 
588 //---------------------------------------------------------------------------
589 //
590 // Function:    AmiGetQword40FromBe()
591 //
592 // Description: reads a 40 bit value from a buffer in big endian
593 //
594 // Parameters:  pAddr_p         = pointer to source buffer
595 //
596 // Return:      QWORD
597 //
598 // State:       not tested
599 //
600 //---------------------------------------------------------------------------
601 
AmiGetQword40FromBe(void FAR * pAddr_p)602 INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe(void FAR * pAddr_p)
603 {
604 
605 	tqwStruct qwStruct;
606 
607 	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
608 	qwStruct.m_qwQword >>= 24;
609 
610 	return (qwStruct.m_qwQword);
611 
612 }
613 
614 //---------------------------------------------------------------------------
615 //
616 // Function:    AmiGetQword40FromLe()
617 //
618 // Description: reads a 40 bit value from a buffer in little endian
619 //
620 // Parameters:  pAddr_p         = pointer to source buffer
621 //
622 // Return:      QWORD
623 //
624 // State:       not tested
625 //
626 //---------------------------------------------------------------------------
627 
AmiGetQword40FromLe(void FAR * pAddr_p)628 INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe(void FAR * pAddr_p)
629 {
630 
631 	tqwStruct qwStruct;
632 
633 	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
634 	qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
635 
636 	return (qwStruct.m_qwQword);
637 
638 }
639 
640 //---------------------------------------------------------------------------
641 //
642 // Function:    AmiSetQword48ToBe()
643 //
644 // Description: sets a 48 bit value to a buffer in big endian
645 //
646 // Parameters:  pAddr_p         = pointer to destination buffer
647 //              qwQwordVal_p    = quadruple word value
648 //
649 // Return:      void
650 //
651 // State:       not tested
652 //
653 //---------------------------------------------------------------------------
654 
AmiSetQword48ToBe(void FAR * pAddr_p,QWORD qwQwordVal_p)655 INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe(void FAR * pAddr_p,
656 					      QWORD qwQwordVal_p)
657 {
658 
659 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[5];
660 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[4];
661 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[3];
662 	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[2];
663 	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[1];
664 	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[0];
665 
666 }
667 
668 //---------------------------------------------------------------------------
669 //
670 // Function:    AmiSetQword48ToLe()
671 //
672 // Description: sets a 48 bit value to a buffer in little endian
673 //
674 // Parameters:  pAddr_p         = pointer to destination buffer
675 //              qwQwordVal_p    = quadruple word value
676 //
677 // Return:      void
678 //
679 // State:       not tested
680 //
681 //---------------------------------------------------------------------------
682 
AmiSetQword48ToLe(void FAR * pAddr_p,QWORD qwQwordVal_p)683 INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe(void FAR * pAddr_p,
684 					      QWORD qwQwordVal_p)
685 {
686 
687 	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
688 	((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
689 
690 }
691 
692 //---------------------------------------------------------------------------
693 //
694 // Function:    AmiGetQword48FromBe()
695 //
696 // Description: reads a 48 bit value from a buffer in big endian
697 //
698 // Parameters:  pAddr_p         = pointer to source buffer
699 //
700 // Return:      QWORD
701 //
702 // State:       not tested
703 //
704 //---------------------------------------------------------------------------
705 
AmiGetQword48FromBe(void FAR * pAddr_p)706 INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe(void FAR * pAddr_p)
707 {
708 
709 	tqwStruct qwStruct;
710 
711 	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
712 	qwStruct.m_qwQword >>= 16;
713 
714 	return (qwStruct.m_qwQword);
715 
716 }
717 
718 //---------------------------------------------------------------------------
719 //
720 // Function:    AmiGetQword48FromLe()
721 //
722 // Description: reads a 48 bit value from a buffer in little endian
723 //
724 // Parameters:  pAddr_p         = pointer to source buffer
725 //
726 // Return:      QWORD
727 //
728 // State:       not tested
729 //
730 //---------------------------------------------------------------------------
731 
AmiGetQword48FromLe(void FAR * pAddr_p)732 INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe(void FAR * pAddr_p)
733 {
734 
735 	tqwStruct qwStruct;
736 
737 	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
738 	qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
739 
740 	return (qwStruct.m_qwQword);
741 
742 }
743 
744 //---------------------------------------------------------------------------
745 //
746 // Function:    AmiSetQword56ToBe()
747 //
748 // Description: sets a 56 bit value to a buffer in big endian
749 //
750 // Parameters:  pAddr_p         = pointer to destination buffer
751 //              qwQwordVal_p    = quadruple word value
752 //
753 // Return:      void
754 //
755 // State:       not tested
756 //
757 //---------------------------------------------------------------------------
758 
AmiSetQword56ToBe(void FAR * pAddr_p,QWORD qwQwordVal_p)759 INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe(void FAR * pAddr_p,
760 					      QWORD qwQwordVal_p)
761 {
762 
763 	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[6];
764 	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[5];
765 	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[4];
766 	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[3];
767 	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[2];
768 	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[1];
769 	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[0];
770 
771 }
772 
773 //---------------------------------------------------------------------------
774 //
775 // Function:    AmiSetQword56ToLe()
776 //
777 // Description: sets a 56 bit value to a buffer in little endian
778 //
779 // Parameters:  pAddr_p         = pointer to destination buffer
780 //              qwQwordVal_p    = quadruple word value
781 //
782 // Return:      void
783 //
784 // State:       not tested
785 //
786 //---------------------------------------------------------------------------
787 
AmiSetQword56ToLe(void FAR * pAddr_p,QWORD qwQwordVal_p)788 INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe(void FAR * pAddr_p,
789 					      QWORD qwQwordVal_p)
790 {
791 
792 	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
793 	((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
794 	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[6];
795 
796 }
797 
798 //---------------------------------------------------------------------------
799 //
800 // Function:    AmiGetQword56FromBe()
801 //
802 // Description: reads a 56 bit value from a buffer in big endian
803 //
804 // Parameters:  pAddr_p         = pointer to source buffer
805 //
806 // Return:      QWORD
807 //
808 // State:       not tested
809 //
810 //---------------------------------------------------------------------------
811 
AmiGetQword56FromBe(void FAR * pAddr_p)812 INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe(void FAR * pAddr_p)
813 {
814 
815 	tqwStruct qwStruct;
816 
817 	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
818 	qwStruct.m_qwQword >>= 8;
819 
820 	return (qwStruct.m_qwQword);
821 
822 }
823 
824 //---------------------------------------------------------------------------
825 //
826 // Function:    AmiGetQword56FromLe()
827 //
828 // Description: reads a 56 bit value from a buffer in little endian
829 //
830 // Parameters:  pAddr_p         = pointer to source buffer
831 //
832 // Return:      QWORD
833 //
834 // State:       not tested
835 //
836 //---------------------------------------------------------------------------
837 
AmiGetQword56FromLe(void FAR * pAddr_p)838 INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe(void FAR * pAddr_p)
839 {
840 
841 	tqwStruct qwStruct;
842 
843 	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
844 	qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
845 
846 	return (qwStruct.m_qwQword);
847 
848 }
849 
850 //---------------------------------------------------------------------------
851 //
852 // Function:    AmiSetTimeOfDay()
853 //
854 // Description: sets a TIME_OF_DAY (CANopen) value to a buffer
855 //
856 // Parameters:  pAddr_p         = pointer to destination buffer
857 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
858 //
859 // Return:      void
860 //
861 // State:       not tested
862 //
863 //---------------------------------------------------------------------------
864 
AmiSetTimeOfDay(void FAR * pAddr_p,tTimeOfDay FAR * pTimeOfDay_p)865 INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay(void FAR * pAddr_p,
866 					    tTimeOfDay FAR * pTimeOfDay_p)
867 {
868 
869 	AmiSetDwordToLe(((BYTE FAR *) pAddr_p),
870 			pTimeOfDay_p->m_dwMs & 0x0FFFFFFF);
871 	AmiSetWordToLe(((BYTE FAR *) pAddr_p) + 4, pTimeOfDay_p->m_wDays);
872 
873 }
874 
875 //---------------------------------------------------------------------------
876 //
877 // Function:    AmiGetTimeOfDay()
878 //
879 // Description: reads a TIME_OF_DAY (CANopen) value from a buffer
880 //
881 // Parameters:  pAddr_p         = pointer to source buffer
882 //              pTimeOfDay_p    = pointer to struct TIME_OF_DAY
883 //
884 // Return:      void
885 //
886 // State:       not tested
887 //
888 //---------------------------------------------------------------------------
889 
AmiGetTimeOfDay(void FAR * pAddr_p,tTimeOfDay FAR * pTimeOfDay_p)890 INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay(void FAR * pAddr_p,
891 					    tTimeOfDay FAR * pTimeOfDay_p)
892 {
893 
894 	pTimeOfDay_p->m_dwMs =
895 	    AmiGetDwordFromLe(((BYTE FAR *) pAddr_p)) & 0x0FFFFFFF;
896 	pTimeOfDay_p->m_wDays = AmiGetWordFromLe(((BYTE FAR *) pAddr_p) + 4);
897 
898 }
899 
900 #endif
901 
902 // EOF
903 
904 // Die letzte Zeile mu� unbedingt eine leere Zeile sein, weil manche Compiler
905 // damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).
906