2008-12-28 14:35:37 +01:00
|
|
|
#ifndef __MEMORY_H__
|
|
|
|
#define __MEMORY_H__
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#define ALIGN_FORWARD(x,align) \
|
|
|
|
((typeof(x))((((u32)(x)) + (align) - 1) & (~(align-1))))
|
|
|
|
|
|
|
|
#define ALIGN_BACKWARD(x,align) \
|
|
|
|
((typeof(x))(((u32)(x)) & (~(align-1))))
|
|
|
|
|
|
|
|
enum AHBDEV {
|
|
|
|
MEMORY = 0,
|
2009-03-07 06:42:07 +01:00
|
|
|
NAND,
|
2008-12-28 14:35:37 +01:00
|
|
|
RAW0 = 0x100,
|
|
|
|
RAWF = 0x10F,
|
|
|
|
};
|
|
|
|
|
2009-01-16 09:07:33 +01:00
|
|
|
void dc_flushrange(const void *start, u32 size);
|
2008-12-28 14:35:37 +01:00
|
|
|
void dc_invalidaterange(void *start, u32 size);
|
|
|
|
void dc_flushall(void);
|
|
|
|
void ic_invalidateall(void);
|
|
|
|
void magic_bullshit(int type);
|
|
|
|
void ahb_memflush(enum AHBDEV dev);
|
|
|
|
void mem_protect(int enable, void *start, void *end);
|
|
|
|
void mem_setswap(int enable);
|
|
|
|
|
2009-01-16 08:53:03 +01:00
|
|
|
void mem_initialize(void);
|
|
|
|
void mem_shutdown(void);
|
|
|
|
|
2009-03-06 05:25:28 +01:00
|
|
|
u32 dma_addr(void *);
|
|
|
|
|
2009-01-16 08:53:03 +01:00
|
|
|
static inline u32 get_cr(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c1, c0, 0" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
static inline u32 get_ttbr(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c2, c0, 0" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
static inline u32 get_dacr(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c3, c0, 0" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
static inline void set_cr(u32 data)
|
|
|
|
{
|
|
|
|
__asm__ volatile ( "mcr\tp15, 0, %0, c1, c0, 0" :: "r" (data) );
|
|
|
|
}
|
|
|
|
static inline void set_ttbr(u32 data)
|
|
|
|
{
|
|
|
|
__asm__ volatile ( "mcr\tp15, 0, %0, c2, c0, 0" :: "r" (data) );
|
|
|
|
}
|
|
|
|
static inline void set_dacr(u32 data)
|
|
|
|
{
|
|
|
|
__asm__ volatile ( "mcr\tp15, 0, %0, c3, c0, 0" :: "r" (data) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 get_dfsr(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c5, c0, 0" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
static inline u32 get_ifsr(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c5, c0, 1" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
static inline u32 get_far(void)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
__asm__ volatile ( "mrc\tp15, 0, %0, c6, c0, 0" : "=r" (data) );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-28 14:35:37 +01:00
|
|
|
#endif
|