OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [glue/] [arm/] [memory.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Includes memory-related architecture specific definitions and their
3
 * corresponding generic wrappers.
4
 *
5
 * Copyright (C) 2007 Bahadir Balban
6
 */
7
#ifndef __GLUE_ARM_MEMORY_H__
8
#define __GLUE_ARM_MEMORY_H__
9
 
10
#include INC_GLUE(memlayout.h) /* Important generic definitions */
11
#include INC_SUBARCH(mm.h)
12
 
13
/* Generic definitions */
14
#define PFN_SHIFT                       12
15
#define PAGE_BITS                       PFN_SHIFT
16
#define PAGE_SIZE                       SZ_4K
17
#define PAGE_MASK                       (PAGE_SIZE - 1)
18
 
19
/* Aligns to the upper page (ceiling) FIXME: Must add a wraparound checker. */
20
#define page_align_up(addr)             ((((unsigned long)(addr)) + PAGE_MASK) & \
21
                                         (~PAGE_MASK))
22
 
23
/* Aligns to the lower page (floor) */
24
#define page_align(addr)                (((unsigned long)(addr)) &  \
25
                                         (~PAGE_MASK))
26
 
27
#define is_aligned(val, size)           (!(((unsigned long)(val)) & (((unsigned long)size) - 1)))
28
#define is_page_aligned(val)            (!(((unsigned long)(val)) & PAGE_MASK))
29
#define page_boundary(x)                is_page_aligned(x)
30
 
31
/*
32
 * Align to given size.
33
 *
34
 * Note it must be an alignable size i.e. one that is a power of two.
35
 * E.g. 0x1000 would work but 0x1010 would not.
36
 */
37
#define align(addr, size)               (((unsigned int)(addr)) & (~((unsigned long)size-1)))
38
#define align_up(addr, size)            ((((unsigned long)(addr)) + \
39
                                        ((size) - 1)) & (~(((unsigned long)size) - 1)))
40
 
41
/* The bytes left until the end of the page that x is in */
42
#define TILL_PAGE_ENDS(x)       (PAGE_SIZE - ((unsigned long)(x) & PAGE_MASK))
43
 
44
/* Extract page frame number from address and vice versa. */
45
#define __pfn(x)                (((unsigned long)(x)) >> PAGE_BITS)
46
#define __pfn_to_addr(x)        (((unsigned long)(x)) << PAGE_BITS)
47
 
48
/* Extract physical address from page table entry (pte) */
49
#define __pte_to_addr(x)        (((unsigned long)(x)) & ~PAGE_MASK)
50
 
51
/* Minimum excess needed for word alignment */
52
#define SZ_WORD                         sizeof(unsigned int)
53
#define WORD_BITS                       32
54
#define WORD_BITS_LOG2                  5
55
#define BITWISE_GETWORD(x)      ((x) >> WORD_BITS_LOG2) /* Divide by 32 */
56
#define BITWISE_GETBIT(x)       (1 << ((x) % WORD_BITS))
57
 
58
/* Minimum stack alignment restriction across functions, exceptions */
59
#define STACK_ALIGNMENT                         8
60
 
61
/* Endianness conversion */
62
static inline void be32_to_cpu(unsigned int x)
63
{
64
        char *p = (char *)&x;
65
        char tmp;
66
 
67
        /* Swap bytes */
68
        tmp = p[0];
69
        p[0] = p[3];
70
        p[3] = tmp;
71
 
72
        tmp = p[1];
73
        p[1] = p[2];
74
        p[2] = tmp;
75
}
76
 
77
struct ktcb;
78
void task_init_registers(struct ktcb *task, unsigned long pc);
79
 
80
#endif /* __GLUE_ARM_MEMORY_H__ */
81
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.