Author: mcayland Date: Tue Dec 28 22:41:11 2010 New Revision: 989 URL: http://tracker.coreboot.org/trac/openbios/changeset/989
Log: Move pa2va() and va2pa() inline functions from the io.h header files to lib.c for both SPARC32 and SPARC64.
Also introduce the correct phys_addr_t type for physical addresses.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/sparc32/lib.c trunk/openbios-devel/arch/sparc64/lib.c trunk/openbios-devel/include/arch/sparc32/io.h trunk/openbios-devel/include/arch/sparc64/io.h trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc32/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/lib.c Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/arch/sparc32/lib.c Tue Dec 28 22:41:11 2010 (r989) @@ -87,6 +87,27 @@ } ofmem; #define ALLOC_BLOCK (64 * 1024)
+/* Private functions for mapping between physical/virtual addresses */ +inline phys_addr_t +va2pa(unsigned long va) +{ + if ((va >= (unsigned long)&_start) && + (va < (unsigned long)&_end)) + return va - va_shift; + else + return va; +} + +inline unsigned long +pa2va(phys_addr_t pa) +{ + if ((pa + va_shift >= (unsigned long)&_start) && + (pa + va_shift < (unsigned long)&_end)) + return pa + va_shift; + else + return pa; +} + // XXX should be posix_memalign static int posix_memalign2(void **memptr, size_t alignment, size_t size)
Modified: trunk/openbios-devel/arch/sparc64/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/lib.c Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/arch/sparc64/lib.c Tue Dec 28 22:41:11 2010 (r989) @@ -36,6 +36,27 @@ return i; }
+/* Private functions for mapping between physical/virtual addresses */ +inline phys_addr_t +va2pa(unsigned long va) +{ + if ((va >= (unsigned long)&_start) && + (va < (unsigned long)&_end)) + return va - va_shift; + else + return va; +} + +inline unsigned long +pa2va(phys_addr_t pa) +{ + if ((pa + va_shift >= (unsigned long)&_start) && + (pa + va_shift < (unsigned long)&_end)) + return pa + va_shift; + else + return pa; +} + void *malloc(int size) { return ofmem_malloc(size);
Modified: trunk/openbios-devel/include/arch/sparc32/io.h ============================================================================== --- trunk/openbios-devel/include/arch/sparc32/io.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/arch/sparc32/io.h Tue Dec 28 22:41:11 2010 (r989) @@ -8,26 +8,6 @@ // Defined in ldscript extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
-static inline unsigned long -va2pa(unsigned long va) -{ - if ((va >= (unsigned long)&_start) && - (va < (unsigned long)&_end)) - return va - va_shift; - else - return va; -} - -static inline unsigned long -pa2va(unsigned long pa) -{ - if ((pa + va_shift >= (unsigned long)&_start) && - (pa + va_shift < (unsigned long)&_end)) - return pa + va_shift; - else - return pa; -} - // XXX check use and merge #define phys_to_virt(phys) ((void *) ((unsigned long) (phys))) #define virt_to_phys(virt) ((unsigned long) (virt))
Modified: trunk/openbios-devel/include/arch/sparc64/io.h ============================================================================== --- trunk/openbios-devel/include/arch/sparc64/io.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/arch/sparc64/io.h Tue Dec 28 22:41:11 2010 (r989) @@ -11,26 +11,6 @@ // Defined in ldscript extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
-static inline unsigned long -va2pa(unsigned long va) -{ - if ((va >= (unsigned long)&_data) && - (va < (unsigned long)&_end)) - return va - va_shift; - else - return va; -} - -static inline unsigned long -pa2va(unsigned long pa) -{ - if ((pa + va_shift >= (unsigned long)&_data) && - (pa + va_shift< (unsigned long)&_end)) - return pa + va_shift; - else - return pa; -} - // XXX check use and merge #define phys_to_virt(phys) ((void *) ((unsigned long) (phys))) #define virt_to_phys(virt) ((unsigned long) (virt))
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/ofmem.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Tue Dec 28 22:41:11 2010 (r989) @@ -75,6 +75,10 @@ extern int ofmem_map_page_range( phys_addr_t phys, ucell virt, ucell size, ucell mode );
+/* Private functions for mapping between physical/virtual addresses */ +extern inline phys_addr_t va2pa(unsigned long va); +extern inline unsigned long pa2va(phys_addr_t pa); + /* malloc interface */ extern void* ofmem_malloc( size_t size ); extern void ofmem_free( void *ptr );
On Tue, Dec 28, 2010 at 9:41 PM, repository service svn@openbios.org wrote:
Author: mcayland Date: Tue Dec 28 22:41:11 2010 New Revision: 989 URL: http://tracker.coreboot.org/trac/openbios/changeset/989
Log: Move pa2va() and va2pa() inline functions from the io.h header files to lib.c for both SPARC32 and SPARC64.
Also introduce the correct phys_addr_t type for physical addresses.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/sparc32/lib.c trunk/openbios-devel/arch/sparc64/lib.c trunk/openbios-devel/include/arch/sparc32/io.h trunk/openbios-devel/include/arch/sparc64/io.h trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc32/lib.c
--- trunk/openbios-devel/arch/sparc32/lib.c Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/arch/sparc32/lib.c Tue Dec 28 22:41:11 2010 (r989) @@ -87,6 +87,27 @@ } ofmem; #define ALLOC_BLOCK (64 * 1024)
+/* Private functions for mapping between physical/virtual addresses */ +inline phys_addr_t +va2pa(unsigned long va) +{
- if ((va >= (unsigned long)&_start) &&
- (va < (unsigned long)&_end))
- return va - va_shift;
- else
- return va;
+}
+inline unsigned long +pa2va(phys_addr_t pa) +{
- if ((pa + va_shift >= (unsigned long)&_start) &&
- (pa + va_shift < (unsigned long)&_end))
- return pa + va_shift;
- else
- return pa;
+}
// XXX should be posix_memalign static int posix_memalign2(void **memptr, size_t alignment, size_t size)
Modified: trunk/openbios-devel/arch/sparc64/lib.c
--- trunk/openbios-devel/arch/sparc64/lib.c Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/arch/sparc64/lib.c Tue Dec 28 22:41:11 2010 (r989) @@ -36,6 +36,27 @@ return i; }
+/* Private functions for mapping between physical/virtual addresses */ +inline phys_addr_t +va2pa(unsigned long va) +{
- if ((va >= (unsigned long)&_start) &&
- (va < (unsigned long)&_end))
- return va - va_shift;
- else
- return va;
+}
+inline unsigned long +pa2va(phys_addr_t pa) +{
- if ((pa + va_shift >= (unsigned long)&_start) &&
- (pa + va_shift < (unsigned long)&_end))
- return pa + va_shift;
- else
- return pa;
+}
void *malloc(int size) { return ofmem_malloc(size);
Modified: trunk/openbios-devel/include/arch/sparc32/io.h
--- trunk/openbios-devel/include/arch/sparc32/io.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/arch/sparc32/io.h Tue Dec 28 22:41:11 2010 (r989) @@ -8,26 +8,6 @@ // Defined in ldscript extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
-static inline unsigned long -va2pa(unsigned long va) -{
- if ((va >= (unsigned long)&_start) &&
- (va < (unsigned long)&_end))
- return va - va_shift;
- else
- return va;
-}
-static inline unsigned long -pa2va(unsigned long pa) -{
- if ((pa + va_shift >= (unsigned long)&_start) &&
- (pa + va_shift < (unsigned long)&_end))
- return pa + va_shift;
- else
- return pa;
-}
// XXX check use and merge #define phys_to_virt(phys) ((void *) ((unsigned long) (phys))) #define virt_to_phys(virt) ((unsigned long) (virt))
Modified: trunk/openbios-devel/include/arch/sparc64/io.h
--- trunk/openbios-devel/include/arch/sparc64/io.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/arch/sparc64/io.h Tue Dec 28 22:41:11 2010 (r989) @@ -11,26 +11,6 @@ // Defined in ldscript extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
-static inline unsigned long -va2pa(unsigned long va) -{
- if ((va >= (unsigned long)&_data) &&
- (va < (unsigned long)&_end))
- return va - va_shift;
- else
- return va;
-}
-static inline unsigned long -pa2va(unsigned long pa) -{
- if ((pa + va_shift >= (unsigned long)&_data) &&
- (pa + va_shift< (unsigned long)&_end))
- return pa + va_shift;
- else
- return pa;
-}
// XXX check use and merge #define phys_to_virt(phys) ((void *) ((unsigned long) (phys))) #define virt_to_phys(virt) ((unsigned long) (virt))
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
--- trunk/openbios-devel/include/libopenbios/ofmem.h Fri Dec 24 23:36:33 2010 (r988) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Tue Dec 28 22:41:11 2010 (r989) @@ -75,6 +75,10 @@ extern int ofmem_map_page_range( phys_addr_t phys, ucell virt, ucell size, ucell mode );
+/* Private functions for mapping between physical/virtual addresses */ +extern inline phys_addr_t va2pa(unsigned long va); +extern inline unsigned long pa2va(phys_addr_t pa);
'inline' with 'extern' does not make much sense.