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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [mpc8xxx/] [current/] [src/] [var_misc.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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