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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [proc-armo/] [mm-init.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/proc-armo/mmap.h
3
 *
4
 * Copyright (C) 1996 Russell King
5
 *
6
 * This contains the code to setup the memory map on an ARM2/ARM250/ARM3
7
 * machine. This is both processor & architecture specific, and requires
8
 * some more work to get it to fit into our separate processor and
9
 * architecture structure.
10
 */
11
 
12
static unsigned long phys_screen_end;
13
int page_nr;
14
 
15
#define setup_processor_functions()
16
#define PTE_SIZE        (PTRS_PER_PTE * BYTES_PER_PTR)
17
 
18
static inline void setup_swapper_dir (int index, pte_t *ptep)
19
{
20
        set_pmd (pmd_offset (swapper_pg_dir + index, 0), mk_pmd (ptep));
21
}
22
 
23
/*
24
 * This routine needs more work to make it dynamically release/allocate mem!
25
 */
26
unsigned long map_screen_mem(unsigned long log_start, unsigned long kmem, int update)
27
{
28
        static int updated = 0;
29
 
30
        if (updated)
31
                return 0;
32
 
33
        updated = update;
34
 
35
        if (update) {
36
                unsigned long address = log_start, offset;
37
                pgd_t *pgdp;
38
 
39
                kmem = (kmem + 3) & ~3;
40
 
41
                pgdp = pgd_offset (&init_mm, address);                          /* +31 */
42
                offset = SCREEN_START;
43
                while (address < SCREEN1_END) {
44
                        unsigned long addr_pmd, end_pmd;
45
                        pmd_t *pmdp;
46
 
47
                        /* if (pgd_none (*pgdp)) alloc pmd */
48
                        pmdp = pmd_offset (pgdp, address);                      /* +0 */
49
                        addr_pmd = address & ~PGDIR_MASK;                       /* 088000 */
50
                        end_pmd = addr_pmd + SCREEN1_END - address;             /* 100000 */
51
                        if (end_pmd > PGDIR_SIZE)
52
                                end_pmd = PGDIR_SIZE;
53
 
54
                        do {
55
                                unsigned long addr_pte, end_pte;
56
                                pte_t *ptep;
57
 
58
                                if (pmd_none (*pmdp)) {
59
                                        pte_t *new_pte = (pte_t *)kmem;
60
                                        kmem += PTRS_PER_PTE * BYTES_PER_PTR;
61
                                        memzero (new_pte, PTRS_PER_PTE * BYTES_PER_PTR);
62
                                        set_pmd (pmdp, mk_pmd(new_pte));
63
                                }
64
 
65
                                ptep = pte_offset (pmdp, addr_pmd);             /* +11 */
66
                                addr_pte = addr_pmd & ~PMD_MASK;                /* 088000 */
67
                                end_pte = addr_pte + end_pmd - addr_pmd;        /* 100000 */
68
                                if (end_pte > PMD_SIZE)
69
                                        end_pte = PMD_SIZE;
70
 
71
                                do {
72
                                        set_pte (ptep, mk_pte(offset, PAGE_KERNEL));
73
                                        addr_pte += PAGE_SIZE;
74
                                        offset += PAGE_SIZE;
75
                                        ptep++;
76
                                } while (addr_pte < end_pte);
77
 
78
                                pmdp++;
79
                                addr_pmd = (addr_pmd + PMD_SIZE) & PMD_MASK;
80
                        } while (addr_pmd < end_pmd);
81
 
82
                        address = (address + PGDIR_SIZE) & PGDIR_MASK;
83
                        pgdp ++;
84
                }
85
 
86
                phys_screen_end = offset;
87
                flush_tlb_all ();
88
                update_mm_cache_all ();
89
        }
90
        return kmem;
91
}
92
 
93
static inline unsigned long setup_pagetables(unsigned long start_mem, unsigned long end_mem)
94
{
95
        unsigned int i;
96
        union {unsigned long l; pte_t *pte; } u;
97
 
98
        page_nr = MAP_NR(end_mem);
99
 
100
        /* map in pages for (0x0000 - 0x8000) */
101
        u.l = ((start_mem + (PTE_SIZE-1)) & ~(PTE_SIZE-1));
102
        start_mem = u.l + PTE_SIZE;
103
        memzero (u.pte, PTE_SIZE);
104
        u.pte[0] = mk_pte(PAGE_OFFSET + 491520, PAGE_READONLY);
105
        setup_swapper_dir (0, u.pte);
106
 
107
        for (i = 1; i < PTRS_PER_PGD; i++)
108
                pgd_val(swapper_pg_dir[i]) = 0;
109
 
110
        /* now map screen mem in */
111
        phys_screen_end = SCREEN2_END;
112
        map_screen_mem (SCREEN1_END - 480*1024, 0, 0);
113
 
114
        return start_mem;
115
}
116
 
117
static inline void mark_usable_memory_areas(unsigned long *start_mem, unsigned long end_mem)
118
{
119
        unsigned long smem;
120
 
121
        *start_mem = smem = PAGE_ALIGN(*start_mem);
122
 
123
        while (smem < end_mem) {
124
                clear_bit(PG_reserved, &mem_map[MAP_NR(smem)].flags);
125
                smem += PAGE_SIZE;
126
        }
127
 
128
        for (smem = phys_screen_end; smem < SCREEN2_END; smem += PAGE_SIZE)
129
                clear_bit(PG_reserved, &mem_map[MAP_NR(smem)].flags);
130
}

powered by: WebSVN 2.1.0

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