SPARC: added libcpu lowlevel access and byteorder routines/definitions

The low level routines can be used in different occasions, it will be
required when accessing PCI.

Note the difference between byteorder.h (inlined functions) and access.S
where the functions will be declared in the library archive librtemscpu.a.
Function names starting with _ are in library and can be referenced by
function pointers.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
This commit is contained in:
Daniel Hellstrom
2012-02-08 15:57:03 +01:00
committed by Gedare Bloom
parent 67baf6071d
commit 80d01b3cf8
9 changed files with 251 additions and 2 deletions

View File

@@ -68,7 +68,9 @@ erc32sonic_rel_CPPFLAGS = $(AM_CPPFLAGS) $(erc32sonic_CPPFLAGS)
erc32sonic_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) erc32sonic_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif endif
libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel \ libbsp_a_LIBADD = \
../../../libcpu/@RTEMS_CPU@/access.rel \
../../../libcpu/@RTEMS_CPU@/cache.rel \
../../../libcpu/@RTEMS_CPU@/reg_win.rel \ ../../../libcpu/@RTEMS_CPU@/reg_win.rel \
../../../libcpu/@RTEMS_CPU@/syscall.rel ../../../libcpu/@RTEMS_CPU@/syscall.rel
if HAS_NETWORKING if HAS_NETWORKING

View File

@@ -118,6 +118,7 @@ leon_open_eth_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif endif
libbsp_a_LIBADD = \ libbsp_a_LIBADD = \
../../../libcpu/@RTEMS_CPU@/access.rel \
../../../libcpu/@RTEMS_CPU@/cache.rel \ ../../../libcpu/@RTEMS_CPU@/cache.rel \
../../../libcpu/@RTEMS_CPU@/reg_win.rel \ ../../../libcpu/@RTEMS_CPU@/reg_win.rel \
../../../libcpu/@RTEMS_CPU@/syscall.rel ../../../libcpu/@RTEMS_CPU@/syscall.rel

View File

@@ -126,7 +126,9 @@ libbsp_a_SOURCES += shmsupp/addrconv.c shmsupp/getcfg.c shmsupp/lock.c \
shmsupp/mpisr.c shmsupp/mpisr.c
endif endif
libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel \ libbsp_a_LIBADD = \
../../../libcpu/@RTEMS_CPU@/access.rel \
../../../libcpu/@RTEMS_CPU@/cache.rel \
../../../libcpu/@RTEMS_CPU@/reg_win.rel \ ../../../libcpu/@RTEMS_CPU@/reg_win.rel \
../../../libcpu/@RTEMS_CPU@/syscall.rel ../../../libcpu/@RTEMS_CPU@/syscall.rel

View File

@@ -10,6 +10,8 @@ noinst_PROGRAMS =
include_libcpudir = $(includedir)/libcpu include_libcpudir = $(includedir)/libcpu
include_libcpu_HEADERS = ../shared/include/cache.h include_libcpu_HEADERS = ../shared/include/cache.h
include_libcpu_HEADERS += include/libcpu/byteorder.h
include_libcpu_HEADERS += include/libcpu/access.h
noinst_PROGRAMS += cache.rel noinst_PROGRAMS += cache.rel
cache_rel_SOURCES = cache/cache.c cache/cache_.h \ cache_rel_SOURCES = cache/cache.c cache/cache_.h \
@@ -31,5 +33,10 @@ reg_win_rel_SOURCES = reg_win/window.S
reg_win_rel_CPPFLAGS = $(AM_CPPFLAGS) reg_win_rel_CPPFLAGS = $(AM_CPPFLAGS)
reg_win_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) reg_win_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
noinst_PROGRAMS += access.rel
access_rel_SOURCES = access/access.S access/access_le.c
access_rel_CPPFLAGS = $(AM_CPPFLAGS)
access_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
include $(srcdir)/preinstall.am include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../automake/local.am include $(top_srcdir)/../../../automake/local.am

View File

@@ -0,0 +1,81 @@
/*
* Optimized access routines for SPARC.
*
* Note the difference between byteorder.h (inlined functions) and access.S
* where the functions will be declared in the library archive librtemscpu.a.
* Function names starting with _ are in library and can be referenced by
* function pointers.
*
* _ldN, _stN standard machine endianess access (SPARC: big-endian)
* _ld_beN, _st_beN forced big-endian
* _ld_leN, _st_leN forced little-endian (defined in access_le.C)
*
* This file is written in assembly because the big-endian functions maps to
* machine dependant access methods, i.e. same function has two names.
*
* COPYRIGHT (c) 2011
* Aeroflex Gaisler.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <rtems/asm.h>
.align 4
.seg "text"
PUBLIC(_ld8)
PUBLIC(_ld16)
PUBLIC(_ld32)
PUBLIC(_ld64)
PUBLIC(_st8)
PUBLIC(_st16)
PUBLIC(_st32)
PUBLIC(_st64)
PUBLIC(_ld_be16)
PUBLIC(_ld_be32)
PUBLIC(_ld_be64)
PUBLIC(_st_be16)
PUBLIC(_st_be32)
PUBLIC(_st_be64)
SYM(_ld8):
retl
ldub [%o0], %o0
SYM(_ld_be16):
SYM(_ld16):
retl
lduh [%o0], %o0
SYM(_ld_be32):
SYM(_ld32):
retl
ld [%o0], %o0
SYM(_ld_be64):
SYM(_ld64):
retl
ldd [%o0], %o0
SYM(_st8):
retl
stub %o1, [%o0]
SYM(_st_be16):
SYM(_st16):
retl
stuh %o1, [%o0]
SYM(_st_be32):
SYM(_st32):
retl
st %o1, [%o0]
SYM(_st_be64):
SYM(_st64):
mov %o2, %o3
mov %o1, %o2
retl
std %o2, [%o0]

View File

@@ -0,0 +1,32 @@
/*
* Little-endian access routines for SPARC
*
* COPYRIGHT (c) 2011
* Aeroflex Gaisler.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <libcpu/byteorder.h>
uint16_t _ld_le16(uint16_t *addr)
{
return ld_le16(addr);
}
void _st_le16(uint16_t *addr, uint16_t val)
{
st_le16(addr, val);
}
uint32_t _ld_le32(uint32_t *addr)
{
return ld_le32(addr);
}
void _st_le32(uint32_t *addr, uint32_t val)
{
st_le32(addr, val);
}

View File

@@ -0,0 +1,50 @@
/*
* access.h - access routines for SPARC. SPARC is big endian only.
*
* COPYRIGHT (c) 2011
* Aeroflex Gaisler.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef _LIBCPU_ACCESS_H
#define _LIBCPU_ACCESS_H
#include <rtems/system.h>
#include <rtems/score/cpu.h>
#ifdef __cplusplus
extern "C" {
#endif
/* "Raw" access */
extern uint8_t _ld8(uint8_t *addr);
extern void _st8(uint8_t *addr, uint8_t val);
extern uint16_t _ld16(uint16_t *addr);
extern void _st16(uint16_t *addr, uint16_t val);
extern uint32_t _ld32(uint32_t *addr);
extern void _st32(uint32_t *addr, uint32_t val);
extern uint64_t _ld64(uint64_t *addr);
extern void _st64(uint64_t *addr, uint64_t val);
/* Aliases for Big Endian */
extern uint16_t _ld_be16(uint16_t *addr);
extern void _st_be16(uint16_t *addr, uint16_t val);
extern uint32_t _ld_be32(uint32_t *addr);
extern void _st_be32(uint32_t *addr, uint32_t val);
extern uint64_t _ld_be64(uint64_t *addr);
extern void _st_be64(uint64_t *addr, uint64_t val);
/* Little endian */
extern uint16_t _ld_le16(uint16_t *addr);
extern void _st_le16(uint16_t *addr, uint16_t val);
extern uint32_t _ld_le32(uint32_t *addr);
extern void _st_le32(uint32_t *addr, uint32_t val);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,66 @@
/*
* byteorder.h - Endian conversion for SPARC. SPARC is big endian only.
*
* COPYRIGHT (c) 2011
* Aeroflex Gaisler.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef _LIBCPU_BYTEORDER_H
#define _LIBCPU_BYTEORDER_H
#include <rtems/system.h>
#include <rtems/score/cpu.h>
#ifdef __cplusplus
extern "C" {
#endif
RTEMS_INLINE_ROUTINE uint16_t ld_le16(volatile uint16_t *addr)
{
return CPU_swap_u16(*addr);
}
RTEMS_INLINE_ROUTINE void st_le16(volatile uint16_t *addr, uint16_t val)
{
*addr = CPU_swap_u16(val);
}
RTEMS_INLINE_ROUTINE uint32_t ld_le32(volatile uint32_t *addr)
{
return CPU_swap_u32(*addr);
}
RTEMS_INLINE_ROUTINE void st_le32(volatile uint32_t *addr, uint32_t val)
{
*addr = CPU_swap_u32(val);
}
RTEMS_INLINE_ROUTINE uint16_t ld_be16(volatile uint16_t *addr)
{
return *addr;
}
RTEMS_INLINE_ROUTINE void st_be16(volatile uint16_t *addr, uint16_t val)
{
*addr = val;
}
RTEMS_INLINE_ROUTINE uint32_t ld_be32(volatile uint32_t *addr)
{
return *addr;
}
RTEMS_INLINE_ROUTINE void st_be32(volatile uint32_t *addr, uint32_t val)
{
*addr = val;
}
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -22,3 +22,11 @@ $(PROJECT_INCLUDE)/libcpu/cache.h: ../shared/include/cache.h $(PROJECT_INCLUDE)/
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache.h $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache.h
$(PROJECT_INCLUDE)/libcpu/byteorder.h: include/libcpu/byteorder.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/byteorder.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/byteorder.h
$(PROJECT_INCLUDE)/libcpu/access.h: include/libcpu/access.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/access.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/access.h