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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      cpm.c
4
//
5
//      PowerPC QUICC2 support functions
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 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):    Gary Thomas 
43
// Contributors: 
44
// Date:         2003-03-04
45
// Purpose:      Common support for the QUICC2/CPM
46
// Description:  
47
//               
48
// Usage:
49
// Notes:        
50
//
51
//####DESCRIPTIONEND####
52
//
53
//==========================================================================
54
 
55
#include <pkgconf/hal.h>
56
#include <cyg/infra/cyg_type.h>
57
#include <cyg/infra/cyg_ass.h>
58
#include <cyg/hal/hal_arch.h>
59
#include <string.h>           // memset
60
 
61
// eCos headers decribing PowerQUICC2:
62
#include <cyg/hal/mpc8xxx.h>
63
 
64
// Information about DPRAM usage
65
// This lets the CPM/DPRAM information be shared by all environments
66
//
67
static struct dpram_info {
68
    unsigned int offset, len;
69
} CPM_DPRAM[] = {
70
    { DPRAM_BD_OFFSET, 0x1000 },
71
    { 0xB000, 0x1000 },
72
    { 0, 0}
73
};
74
static int *nextBd = (int *)(CYGHWR_HAL_VSR_TABLE + 0x1F0);
75
static struct dpram_info **info = (struct dpram_info **)(CYGHWR_HAL_VSR_TABLE + 0x1F4);
76
 
77
/*
78
 * Reset the communications processor
79
 */
80
 
81
void
82
_mpc8xxx_reset_cpm(void)
83
{
84
    static int init_done = 0;
85
 
86
    if (init_done) return;
87
    init_done++;
88
 
89
    IMM->cpm_cpcr = CPCR_RST | CPCR_FLG;
90
    while (IMM->cpm_cpcr & CPCR_FLG)
91
        CYG_EMPTY_STATEMENT;
92
 
93
    *nextBd = CPM_DPRAM[0].offset;
94
    *info = CPM_DPRAM;
95
    // Set up SMCx offsets
96
    IMM->pram.standard.smc1 = DPRAM_SMC1_OFFSET;
97
    IMM->pram.standard.smc2 = DPRAM_SMC2_OFFSET;
98
}
99
 
100
//
101
// Allocate a chunk of memory in the shared CPM memory, typically
102
// used for buffer descriptors, etc.  The length will be aligned
103
// to a multiple of 8 bytes.  This is somewhat complicated on the 
104
// QUICC2/CPM since there are multiple regions of shared DPRAM
105
// which are legal to use, of varying size and spread all over.
106
//
107
unsigned int
108
_mpc8xxx_allocBd(int len)
109
{
110
    struct dpram_info *ip = *info;
111
    unsigned int bd;
112
 
113
    bd = *nextBd;
114
    len = (len + 7) & ~7;  // Multiple of 8 bytes
115
    *nextBd += len;
116
    if (*nextBd >= (ip->offset+ip->len)) {
117
        ip++;
118
        *nextBd = ip->offset;
119
        *info = ip;
120
    }
121
    return bd;
122
}
123
 
124
// EOF cpm.c

powered by: WebSVN 2.1.0

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