source: rtems/c/src/lib/libcpu/powerpc/mpc55xx/include/mpc55xx.h @ 359e537

4.104.115
Last change on this file since 359e537 was 359e537, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 05:09:41

Whitespace removal.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief Documentation for this file
7 */
8
9/*
10 * Copyright (c) 2008
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 */
20
21/**
22 * @defgroup mpc55xx BSP for MPC55xx boards
23 */
24
25/**
26 * @defgroup mpc55xx_config Configuration files
27 *
28 * @ingroup mpc55xx
29 *
30 * Makefiles, configure scripts etc.
31 */
32
33/**
34 * @page mpc55xx_ext_doc External Documentation
35 *
36 * @section mpc55xx_ext_doc_mpc5567rm_1 MPC5567 Microcontroller Reference Manual (Rev. 1, January 2007, Volume 1 of 2)
37 * @section mpc55xx_ext_doc_mpc5567rm_2 MPC5567 Microcontroller Reference Manual (Rev. 1, January 2007, Volume 2 of 2)
38 */
39
40#ifndef LIBCPU_POWERPC_MPC55XX_H
41#define LIBCPU_POWERPC_MPC55XX_H
42
43#include <stddef.h>
44#include <stdint.h>
45
46/* Defined in copy.S */
47int mpc55xx_copy_8( const void *src, void *dest, size_t n);
48
49/* Defined in copy.S */
50int mpc55xx_zero_8( void *dest, size_t n);
51
52/* Defined in copy.S */
53int mpc55xx_zero_32( void *dest, size_t n);
54
55/* Defined in fmpll.S */
56void mpc55xx_fmpll_reset_config();
57
58/* Defined in fmpll.S */
59void mpc55xx_fmpll_wait_for_lock();
60
61/* Defined in fmpll.S */
62int mpc55xx_get_system_clock();
63
64/* Defined in fmpll.S */
65void mpc55xx_system_reset();
66
67/* Defined in flash.S */
68void mpc55xx_flash_config();
69
70#define MPC55XX_CACHE_ALIGNED_MASK ((uintptr_t) 0x1f)
71
72#define MPC55XX_CACHE_LINE_SIZE 32
73
74/**
75 * @brief Returns true if the buffer starting at @a s of size @a n is cache aligned.
76 */
77static inline int mpc55xx_is_cache_aligned( const void *s, size_t n)
78{
79        return !(((uintptr_t) s & MPC55XX_CACHE_ALIGNED_MASK) || (n & MPC55XX_CACHE_ALIGNED_MASK));
80}
81
82static inline void* mpc55xx_cache_aligned_start( const void *s)
83{
84        return ((uintptr_t) s & MPC55XX_CACHE_ALIGNED_MASK) ? (((uintptr_t) s & ~MPC55XX_CACHE_ALIGNED_MASK) + MPC55XX_CACHE_LINE_SIZE) : s;
85}
86
87static inline size_t mpc55xx_non_cache_aligned_size( const void *s)
88{
89        return (uintptr_t) mpc55xx_cache_aligned_start( s) - (uintptr_t) s;
90}
91
92static inline size_t mpc55xx_cache_aligned_size( const void *s, size_t n)
93{
94        return (n - mpc55xx_non_cache_aligned_size( s)) & ~MPC55XX_CACHE_ALIGNED_MASK;
95}
96
97/**
98 * @brief Returns the number of leading zeros.
99 */
100static inline uint32_t mpc55xx_count_leading_zeros( uint32_t value)
101{
102        uint32_t count;
103        asm (
104                "cntlzw %0, %1;"
105                : "=r" (count)
106                : "r" (value)
107        );
108        return count;
109}
110
111#endif /* LIBCPU_POWERPC_MPC55XX_H */
Note: See TracBrowser for help on using the repository browser.