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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [armnommu/] [mm/] [mm-rpc.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * arch/arm/mm/mm-rpc.c
3
 *
4
 * Extra MM routines for RiscPC architecture
5
 *
6
 * Copyright (C) 1998 Russell King
7
 */
8
 
9
#include <linux/sched.h>
10
#include <linux/malloc.h>
11
#include <linux/mman.h>
12
 
13
#include <asm/pgtable.h>
14
#include <asm/setup.h>
15
 
16
#define NR_DRAM_BANKS   4
17
#define NR_VRAM_BANKS   1
18
 
19
#define NR_BANKS        (NR_DRAM_BANKS + NR_VRAM_BANKS)
20
 
21
#define FIRST_BANK      0
22
#define FIRST_DRAM_BANK 0
23
#define FIRST_VRAM_BANK NR_DRAM_BANKS
24
 
25
#define BANK_SHIFT      26
26
#define FIRST_DRAM_ADDR 0x10000000
27
 
28
#define PHYS_TO_BANK(x) (((x) >> BANK_SHIFT) & (NR_DRAM_BANKS - 1))
29
#define BANK_TO_PHYS(x) ((FIRST_DRAM_ADDR) + \
30
                            (((x) - FIRST_DRAM_BANK) << BANK_SHIFT))
31
 
32
struct ram_bank {
33
        unsigned int virt_addr;         /* virtual address of the *end* of this bank + 1 */
34
          signed int phys_offset;       /* offset to physical address of this bank */
35
};
36
 
37
static struct ram_bank rambank[NR_BANKS];
38
 
39
/*
40
 * Return the physical (0x10000000 -> 0x20000000) address of
41
 * the virtual (0xc0000000 -> 0xd0000000) address
42
 */
43
unsigned long __virt_to_phys(unsigned long vpage)
44
{
45
        unsigned int bank = FIRST_BANK;
46
 
47
        while (vpage >= rambank[bank].virt_addr && bank < NR_BANKS)
48
                bank ++;
49
 
50
        return vpage - rambank[bank].phys_offset;
51
}
52
 
53
/*
54
 * Return the virtual (0xc0000000 -> 0xd0000000) address of
55
 * the physical (0x10000000 -> 0x20000000) address
56
 */
57
unsigned long __phys_to_virt(unsigned long phys)
58
{
59
        unsigned int bank;
60
 
61
        if (phys > FIRST_DRAM_ADDR)
62
                bank = PHYS_TO_BANK(phys);
63
        else
64
                bank = FIRST_VRAM_BANK;
65
 
66
        return phys + rambank[bank].phys_offset;
67
}
68
 
69
void init_dram_banks(struct param_struct *params)
70
{
71
        unsigned int bank;
72
        unsigned int bytes = 0;
73
 
74
        for (bank = FIRST_DRAM_BANK; bank < NR_DRAM_BANKS; bank++) {
75
                rambank[bank].phys_offset = PAGE_OFFSET + bytes
76
                                                - BANK_TO_PHYS(bank);
77
 
78
                bytes += params->u1.s.pages_in_bank[bank - FIRST_DRAM_BANK] * PAGE_SIZE;
79
 
80
                rambank[bank].virt_addr   = PAGE_OFFSET + bytes;
81
        }
82
 
83
        rambank[FIRST_VRAM_BANK].phys_offset = 0xd6000000;
84
        rambank[FIRST_VRAM_BANK].virt_addr   = 0xe0000000;
85
 
86
//      current->tss.memmap = __virt_to_phys((unsigned long)swapper_pg_dir);
87
}

powered by: WebSVN 2.1.0

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