source: rtems/c/src/exec/score/inline/rtems/score/address.inl @ 17508d02

4.104.114.84.95
Last change on this file since 17508d02 was 17508d02, checked in by Joel Sherrill <joel.sherrill@…>, on 07/26/00 at 19:26:28

Port of RTEMS to the Texas Instruments C3x/C4x DSP families including
a BSP (c4xsim) supporting the simulator included with gdb. This port
was done by Joel Sherrill and Jennifer Averett of OAR Corporation.
Also included with this port is a space/time optimization to eliminate
FP context switch management on CPUs without hardware or software FP.

An issue with this port was that sizeof(unsigned32) = sizeof(unsigned8)
on this CPU. This required addressing alignment checks and assumptions
as well as fixing code that assumed sizeof(unsigned32) == 4.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*  inline/address.inl
2 *
3 *  This include file contains the bodies of the routines
4 *  about addresses which are inlined.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __INLINE_ADDRESSES_inl
17#define __INLINE_ADDRESSES_inl
18
19/*PAGE
20 *
21 *  _Addresses_Add_offset
22 *
23 *  DESCRIPTION:
24 *
25 *  This function is used to add an offset to a base address.
26 *  It returns the resulting address.  This address is typically
27 *  converted to an access type before being used further.
28 */
29
30RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset (
31  void       *base,
32  unsigned32  offset
33)
34{
35  return (void *)((char *)base + offset);
36}
37
38/*PAGE
39 *
40 *  _Addresses_Subtract_offset
41 *
42 *  DESCRIPTION:
43 *
44 *  This function is used to subtract an offset from a base
45 *  address.  It returns the resulting address.  This address is
46 *  typically converted to an access type before being used further.
47 */
48
49RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset (
50  void       *base,
51  unsigned32  offset
52)
53{
54  return (void *)((char *)base - offset);
55}
56
57/*PAGE
58 *
59 *  _Addresses_Subtract
60 *
61 *  DESCRIPTION:
62 *
63 *  This function is used to subtract two addresses.  It returns the
64 *  resulting offset.
65 *
66 *  NOTE:  The cast of an address to an unsigned32 makes this code
67 *         dependent on an addresses being thirty two bits.
68 */
69
70RTEMS_INLINE_ROUTINE unsigned32 _Addresses_Subtract (
71  void *left,
72  void *right
73)
74{
75  return ((char *) left - (char *) right);
76}
77
78/*PAGE
79 *
80 *  _Addresses_Is_aligned
81 *
82 *  DESCRIPTION:
83 *
84 *  This function returns TRUE if the given address is correctly
85 *  aligned for this processor and FALSE otherwise.  Proper alignment
86 *  is based on correctness and efficiency.
87 */
88
89RTEMS_INLINE_ROUTINE boolean _Addresses_Is_aligned (
90  void *address
91)
92{
93#if (CPU_ALIGNMENT == 0)
94    return TRUE;
95#elif defined(RTEMS_CPU_HAS_16_BIT_ADDRESSES)
96    return ( ( (unsigned short)address % CPU_ALIGNMENT ) == 0 );
97#else
98    return ( ( (unsigned32)address % CPU_ALIGNMENT ) == 0 );
99#endif
100}
101
102/*PAGE
103 *
104 *  _Addresses_Is_in_range
105 *
106 *  DESCRIPTION:
107 *
108 *  This function returns TRUE if the given address is within the
109 *  memory range specified and FALSE otherwise.  base is the address
110 *  of the first byte in the memory range and limit is the address
111 *  of the last byte in the memory range.  The base address is
112 *  assumed to be lower than the limit address.
113 */
114
115RTEMS_INLINE_ROUTINE boolean _Addresses_Is_in_range (
116  void *address,
117  void *base,
118  void *limit
119)
120{
121  return ( address >= base && address <= limit );
122}
123
124#endif
125/* end of include file */
Note: See TracBrowser for help on using the repository browser.