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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [mpc8260/] [v2_0/] [src/] [var_misc.c] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      var_misc.c
4
//
5
//      HAL implementation miscellaneous functions
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
// Copyright (C) 2002 Gary Thomas
13
//
14
// eCos is free software; you can redistribute it and/or modify it under
15
// the terms of the GNU General Public License as published by the Free
16
// Software Foundation; either version 2 or (at your option) any later version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License along
24
// with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
//
27
// As a special exception, if other files instantiate templates or use macros
28
// or inline functions from this file, or you compile this file and link it
29
// with other works to produce a work based on this file, this file does not
30
// by itself cause the resulting work to be covered by the GNU General Public
31
// License. However the source code for this file must still be made available
32
// in accordance with section (3) of the GNU General Public License.
33
//
34
// This exception does not invalidate any other reasons why a work based on
35
// this file might be covered by the GNU General Public License.
36
//
37
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
// at http://sources.redhat.com/ecos/ecos-license/
39
// -------------------------------------------
40
//####ECOSGPLCOPYRIGHTEND####
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    pfine
45
// Contributors: jskov
46
// Date:         2001-12-12
47
// Purpose:      HAL miscellaneous functions
48
// Description:  This file contains miscellaneous functions provided by the
49
//               HAL.
50
//
51
//####DESCRIPTIONEND####
52
//
53
//==========================================================================
54
 
55
#include <pkgconf/hal.h>
56
 
57
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
58
#include <cyg/hal/ppc_regs.h>
59
#include <cyg/infra/cyg_type.h>
60
 
61
#include <cyg/hal/hal_mem.h>
62
 
63
//--------------------------------------------------------------------------
64
void hal_variant_init(void)
65
{
66
}
67
 
68
 
69
//--------------------------------------------------------------------------
70
// Variant specific idle thread action.
71
bool
72
hal_variant_idle_thread_action( cyg_uint32 count )
73
{
74
    // Let architecture idle thread action run
75
    return true;
76
}
77
 
78
//---------------------------------------------------------------------------
79
// Use MMU resources to map memory regions.  
80
// Takes and returns an int used to ID the MMU resource to use. This ID
81
// is increased as resources are used and should be used for subsequent
82
// invocations.
83
int
84
cyg_hal_map_memory (int id,CYG_ADDRESS virt, CYG_ADDRESS phys,
85
                    cyg_int32 size, cyg_uint8 flags)
86
{
87
    // Use BATs to map the memory.
88
    cyg_uint32 ubat, lbat;
89
 
90
    ubat = (virt & UBAT_BEPIMASK) | UBAT_VS | UBAT_VP;
91
    lbat = (phys & LBAT_BRPNMASK);
92
    if (flags & CYGARC_MEMDESC_CI)
93
        lbat |= LBAT_I;
94
    if (flags & CYGARC_MEMDESC_GUARDED)
95
        lbat |= LBAT_G;
96
#define IWASPATRICK
97
#ifdef IWASPATRICK
98
    lbat |= LBAT_PP_RW; // Always enable for Read-Write
99
#else
100
    if (flags & CYGARC_MEMDESC_RO) // Memory is Read Only
101
        lbat |= LBAT_PP_RO;
102
    if (flags & CYGARC_MEMDESC_RW) // Memory is RW 
103
        lbat |= LBAT_PP_RW;
104
#endif
105
    // There are 4 BATs, size is programmable.
106
    while (id < 4 && size > 0) {
107
        cyg_uint32 blk_size = 128*1024;
108
        cyg_uint32 bl = 0;
109
        while (blk_size < 256*1024*1024 && blk_size < size) {
110
            blk_size *= 2;
111
            bl = (bl << 1) | 1;
112
        }
113
        ubat = (ubat & ~UBAT_BLMASK) | (bl << 2);
114
 
115
        switch (id) {
116
        case 0:
117
            CYGARC_MTSPR (IBAT0U, ubat);
118
            CYGARC_MTSPR (IBAT0L, lbat);
119
            CYGARC_MTSPR (DBAT0U, ubat);
120
            CYGARC_MTSPR (DBAT0L, lbat);
121
            break;
122
        case 1:
123
            CYGARC_MTSPR (IBAT1U, ubat);
124
            CYGARC_MTSPR (IBAT1L, lbat);
125
            CYGARC_MTSPR (DBAT1U, ubat);
126
            CYGARC_MTSPR (DBAT1L, lbat);
127
            break;
128
        case 2:
129
            CYGARC_MTSPR (IBAT2U, ubat);
130
            CYGARC_MTSPR (IBAT2L, lbat);
131
            CYGARC_MTSPR (DBAT2U, ubat);
132
            CYGARC_MTSPR (DBAT2L, lbat);
133
            break;
134
        case 3:
135
            CYGARC_MTSPR (IBAT3U, ubat);
136
            CYGARC_MTSPR (IBAT3L, lbat);
137
            CYGARC_MTSPR (DBAT3U, ubat);
138
            CYGARC_MTSPR (DBAT3L, lbat);
139
            break;
140
        }
141
 
142
        size -= blk_size;
143
        id++;
144
    }
145
 
146
    return id;
147
}
148
 
149
 
150
// Initialize MMU to a sane (NOP) state.
151
void
152
cyg_hal_clear_MMU (void)
153
{
154
    cyg_uint32 ubat, lbat;
155
 
156
    // Initialize BATs with 0 -- VS&VP are unset, making all matches fail
157
    ubat = 0;
158
    lbat = 0;
159
 
160
    CYGARC_MTSPR (IBAT0U, ubat);
161
    CYGARC_MTSPR (IBAT0L, lbat);
162
    CYGARC_MTSPR (DBAT0U, ubat);
163
    CYGARC_MTSPR (DBAT0L, lbat);
164
    CYGARC_MTSPR (IBAT1U, ubat);
165
    CYGARC_MTSPR (IBAT1L, lbat);
166
    CYGARC_MTSPR (DBAT1U, ubat);
167
    CYGARC_MTSPR (DBAT1L, lbat);
168
    CYGARC_MTSPR (IBAT2U, ubat);
169
    CYGARC_MTSPR (IBAT2L, lbat);
170
    CYGARC_MTSPR (DBAT2U, ubat);
171
    CYGARC_MTSPR (DBAT2L, lbat);
172
    CYGARC_MTSPR (IBAT3U, ubat);
173
    CYGARC_MTSPR (IBAT3L, lbat);
174
    CYGARC_MTSPR (DBAT3U, ubat);
175
    CYGARC_MTSPR (DBAT3L, lbat);
176
}
177
 
178
//--------------------------------------------------------------------------
179
// End of var_misc.c

powered by: WebSVN 2.1.0

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