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

Subversion Repositories openrisc

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

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):    jskov
45
// Contributors: jskov
46
// Date:         2000-02-04
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) | LBAT_PP_RW;
92
    if (flags & CYGARC_MEMDESC_CI)
93
        lbat |= LBAT_I;
94
    if (flags & CYGARC_MEMDESC_GUARDED)
95
        lbat |= LBAT_G;
96
 
97
    // There are 4 BATs, size is programmable.
98
    while (id < 4 && size > 0) {
99
        cyg_uint32 blk_size = 128*1024;
100
        cyg_uint32 bl = 0;
101
        while (blk_size < 256*1024*1024 && blk_size < size) {
102
            blk_size *= 2;
103
            bl = (bl << 1) | 1;
104
        }
105
        ubat = (ubat & ~UBAT_BLMASK) | (bl << 2);
106
 
107
        switch (id) {
108
        case 0:
109
            CYGARC_MTSPR (IBAT0U, ubat);
110
            CYGARC_MTSPR (IBAT0L, lbat);
111
            CYGARC_MTSPR (DBAT0U, ubat);
112
            CYGARC_MTSPR (DBAT0L, lbat);
113
            break;
114
        case 1:
115
            CYGARC_MTSPR (IBAT1U, ubat);
116
            CYGARC_MTSPR (IBAT1L, lbat);
117
            CYGARC_MTSPR (DBAT1U, ubat);
118
            CYGARC_MTSPR (DBAT1L, lbat);
119
            break;
120
        case 2:
121
            CYGARC_MTSPR (IBAT2U, ubat);
122
            CYGARC_MTSPR (IBAT2L, lbat);
123
            CYGARC_MTSPR (DBAT2U, ubat);
124
            CYGARC_MTSPR (DBAT2L, lbat);
125
            break;
126
        case 3:
127
            CYGARC_MTSPR (IBAT3U, ubat);
128
            CYGARC_MTSPR (IBAT3L, lbat);
129
            CYGARC_MTSPR (DBAT3U, ubat);
130
            CYGARC_MTSPR (DBAT3L, lbat);
131
            break;
132
        }
133
 
134
        size -= blk_size;
135
        id++;
136
    }
137
 
138
    return id;
139
}
140
 
141
 
142
// Initialize MMU to a sane (NOP) state.
143
void
144
cyg_hal_clear_MMU (void)
145
{
146
    cyg_uint32 ubat, lbat;
147
 
148
    // Initialize BATs with 0 -- VS&VP are unset, making all matches fail
149
    ubat = 0;
150
    lbat = 0;
151
 
152
    CYGARC_MTSPR (IBAT0U, ubat);
153
    CYGARC_MTSPR (IBAT0L, lbat);
154
    CYGARC_MTSPR (DBAT0U, ubat);
155
    CYGARC_MTSPR (DBAT0L, lbat);
156
    CYGARC_MTSPR (IBAT1U, ubat);
157
    CYGARC_MTSPR (IBAT1L, lbat);
158
    CYGARC_MTSPR (DBAT1U, ubat);
159
    CYGARC_MTSPR (DBAT1L, lbat);
160
    CYGARC_MTSPR (IBAT2U, ubat);
161
    CYGARC_MTSPR (IBAT2L, lbat);
162
    CYGARC_MTSPR (DBAT2U, ubat);
163
    CYGARC_MTSPR (DBAT2L, lbat);
164
    CYGARC_MTSPR (IBAT3U, ubat);
165
    CYGARC_MTSPR (IBAT3L, lbat);
166
    CYGARC_MTSPR (DBAT3U, ubat);
167
    CYGARC_MTSPR (DBAT3L, lbat);
168
}
169
 
170
//--------------------------------------------------------------------------
171
// 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.