1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_PXA250_PLATFORM_PLF_MMAP_H
|
2 |
|
|
#define CYGONCE_HAL_PXA250_PLATFORM_PLF_MMAP_H
|
3 |
|
|
/*=============================================================================
|
4 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
5 |
|
|
// -------------------------------------------
|
6 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
7 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
8 |
|
|
//
|
9 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
10 |
|
|
// the terms of the GNU General Public License as published by the Free
|
11 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
12 |
|
|
// version.
|
13 |
|
|
//
|
14 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
15 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
16 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
17 |
|
|
// for more details.
|
18 |
|
|
//
|
19 |
|
|
// You should have received a copy of the GNU General Public License
|
20 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
21 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
22 |
|
|
//
|
23 |
|
|
// As a special exception, if other files instantiate templates or use
|
24 |
|
|
// macros or inline functions from this file, or you compile this file
|
25 |
|
|
// and link it with other works to produce a work based on this file,
|
26 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
27 |
|
|
// the GNU General Public License. However the source code for this file
|
28 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
29 |
|
|
// General Public License v2.
|
30 |
|
|
//
|
31 |
|
|
// This exception does not invalidate any other reasons why a work based
|
32 |
|
|
// on this file might be covered by the GNU General Public License.
|
33 |
|
|
// -------------------------------------------
|
34 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
35 |
|
|
//=============================================================================
|
36 |
|
|
//#####DESCRIPTIONBEGIN####
|
37 |
|
|
//
|
38 |
|
|
// Author(s): hmt
|
39 |
|
|
// Contributors: hmt
|
40 |
|
|
// Date: 2001-01-04
|
41 |
|
|
// Purpose: Intel PXA250 series platform-specific memory mapping macros
|
42 |
|
|
// Description: Macros to convert a cached, virtual address to
|
43 |
|
|
// 1) an uncached adddress for the same memory (if available)
|
44 |
|
|
// 2) the equivalent physical address for giving to external
|
45 |
|
|
// hardware eg. DMA engines.
|
46 |
|
|
//
|
47 |
|
|
// NB: this mapping is expressed here statically, independent
|
48 |
|
|
// of the actual mapping installed in the MMAP table. So if
|
49 |
|
|
// someone changes that, or its initialisation is changed,
|
50 |
|
|
// then this module must change. This is intended to be
|
51 |
|
|
// efficient at a cost of generality. It is also intended to
|
52 |
|
|
// be called with constants (such as &my_struct) as input
|
53 |
|
|
// args, so that all the work can be done at compile time,
|
54 |
|
|
// with optimization on.
|
55 |
|
|
//
|
56 |
|
|
// Usage: #include <cyg/hal/hal_cache.h>
|
57 |
|
|
// (which includes this file itself)
|
58 |
|
|
//
|
59 |
|
|
//####DESCRIPTIONEND####
|
60 |
|
|
//
|
61 |
|
|
//===========================================================================*/
|
62 |
|
|
|
63 |
|
|
#include <cyg/hal/hal_misc.h>
|
64 |
|
|
|
65 |
|
|
// Get the pagesize for a particular virtual address:
|
66 |
|
|
|
67 |
|
|
// This does not depend on the vaddr.
|
68 |
|
|
#define HAL_MM_PAGESIZE( vaddr, pagesize ) CYG_MACRO_START \
|
69 |
|
|
(pagesize) = SZ_1M; \
|
70 |
|
|
CYG_MACRO_END
|
71 |
|
|
|
72 |
|
|
// Get the physical address from a virtual address:
|
73 |
|
|
|
74 |
|
|
// Only RAM and ROM are mapped; we just pass through all other values,
|
75 |
|
|
// rather than detecting nonexistent areas here.
|
76 |
|
|
|
77 |
|
|
#define HAL_VIRT_TO_PHYS_ADDRESS( vaddr, paddr ) CYG_MACRO_START \
|
78 |
|
|
cyg_uint32 _v_ = (cyg_uint32)(vaddr); \
|
79 |
|
|
if ( 64 * SZ_1M > _v_ ) /* 64Mb of SDRAM Bank 0 from 0-32Mb */ \
|
80 |
|
|
_v_ += 0xa00u * SZ_1M; \
|
81 |
|
|
else if ( 0x500u * SZ_1M > _v_ ) /* Space between RAM and mapped ROM */\
|
82 |
|
|
/* no change */ ; \
|
83 |
|
|
else if ( 0x520u * SZ_1M > _v_ ) /* Mapped boot ROM size 32Mb */ \
|
84 |
|
|
_v_ -= 0x500u * SZ_1M; \
|
85 |
|
|
else /* Rest of it */ \
|
86 |
|
|
/* no change */ ; \
|
87 |
|
|
(paddr) = _v_; \
|
88 |
|
|
CYG_MACRO_END
|
89 |
|
|
|
90 |
|
|
// Get the virtual address for a physical address:
|
91 |
|
|
|
92 |
|
|
// Only RAM and ROM are mapped; we just pass through all other values,
|
93 |
|
|
// rather than detecting nonexistent areas here.
|
94 |
|
|
|
95 |
|
|
#define HAL_PHYS_TO_VIRT_ADDRESS( paddr, vaddr ) CYG_MACRO_START \
|
96 |
|
|
cyg_uint32 _p_ = (cyg_uint32)(paddr); \
|
97 |
|
|
if ( 32 * SZ_1M > _p_ ) /* 32Mb Boot ROM mapped to 0x500Mb */ \
|
98 |
|
|
_p_ += 0x500u * SZ_1M; \
|
99 |
|
|
else if ( 0xa00u * SZ_1M > _p_ ) /* Space between ROM and SDRAM */ \
|
100 |
|
|
/* no change */ ; \
|
101 |
|
|
else if ( 0xa40u * SZ_1M > _p_ ) /* Raw RAM size 64Mb */ \
|
102 |
|
|
_p_ -= 0xa00u * SZ_1M; \
|
103 |
|
|
else /* Rest of it */ \
|
104 |
|
|
/* no change */ ; \
|
105 |
|
|
(vaddr) = _p_ ; \
|
106 |
|
|
CYG_MACRO_END
|
107 |
|
|
|
108 |
|
|
// Get a non-cacheable address for accessing the same store as a virtual
|
109 |
|
|
// (assumed cachable) address:
|
110 |
|
|
|
111 |
|
|
// Only RAM is mapped: ROM is only available cachable, everything else is
|
112 |
|
|
// not cachable anyway.
|
113 |
|
|
|
114 |
|
|
#define HAL_VIRT_TO_UNCACHED_ADDRESS( vaddr, uaddr ) CYG_MACRO_START \
|
115 |
|
|
cyg_uint32 _v_ = (cyg_uint32)(vaddr); \
|
116 |
|
|
if ( 64 * SZ_1M > _v_ ) /* 64Mb of SDRAM Bank 0 from 0-64Mb */ \
|
117 |
|
|
_v_ += 0xc00u * SZ_1M; \
|
118 |
|
|
else /* Everything else is already uncacheable or is ROM */ \
|
119 |
|
|
/* no change */ ; \
|
120 |
|
|
(uaddr) = _v_ ; \
|
121 |
|
|
CYG_MACRO_END
|
122 |
|
|
|
123 |
|
|
//---------------------------------------------------------------------------
|
124 |
|
|
#endif // CYGONCE_HAL_SA11X0_PLATFORM_PLF_MMAP_H
|
125 |
|
|
// EOF plf_mmap.h
|