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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [sc/] [shmem.c] - Blame information for rev 1777

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

Line No. Rev Author Line
1 1626 jcastillo
/*
2
 *  $Id: shmem.c,v 1.1 2005-12-20 10:17:12 jcastillo Exp $
3
 *  Copyright (C) 1996  SpellCaster Telecommunications Inc.
4
 *
5
 *  card.c - Card functions implementing ISDN4Linux functionality
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 *
21
 *  For more information, please contact gpl-info@spellcast.com or write:
22
 *
23
 *     SpellCaster Telecommunications Inc.
24
 *     5621 Finch Avenue East, Unit #3
25
 *     Scarborough, Ontario  Canada
26
 *     M1B 2T9
27
 *     +1 (416) 297-8565
28
 *     +1 (416) 297-6433 Facsimile
29
 */
30
 
31
#define __NO_VERSION__
32
#include "includes.h"           /* This must be first */
33
#include "hardware.h"
34
#include "card.h"
35
 
36
/*
37
 * Main adapter array
38
 */
39
extern board *adapter[];
40
extern int cinst;
41
 
42
/*
43
 *
44
 */
45
void *memcpy_toshmem(int card, void *dest, const void *src, size_t n)
46
{
47
        unsigned long flags;
48
        void *ret;
49
        unsigned char ch;
50
 
51
        if(!IS_VALID_CARD(card)) {
52
                pr_debug("Invalid param: %d is not a valid card id\n", card);
53
                return NULL;
54
        }
55
 
56
        if(n > SRAM_PAGESIZE) {
57
                return NULL;
58
        }
59
 
60
        /*
61
         * determine the page to load from the address
62
         */
63
        ch = (unsigned long) dest / SRAM_PAGESIZE;
64
        pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch);
65
        /*
66
         * Block interrupts and load the page
67
         */
68
        save_flags(flags);
69
        cli();
70
 
71
        outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
72
                adapter[card]->ioport[adapter[card]->shmem_pgport]);
73
        pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
74
                ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
75
        ret = memcpy_toio(adapter[card]->rambase +
76
                ((unsigned long) dest % 0x4000), src, n);
77
        pr_debug("%s: copying %d bytes from %#x to %#x\n",adapter[card]->devicename, n,
78
                 (unsigned long) src, adapter[card]->rambase + ((unsigned long) dest %0x4000));
79
        restore_flags(flags);
80
 
81
        return ret;
82
}
83
 
84
/*
85
 * Reverse of above
86
 */
87
void *memcpy_fromshmem(int card, void *dest, const void *src, size_t n)
88
{
89
        unsigned long flags;
90
        void *ret;
91
        unsigned char ch;
92
 
93
        if(!IS_VALID_CARD(card)) {
94
                pr_debug("Invalid param: %d is not a valid card id\n", card);
95
                return NULL;
96
        }
97
 
98
        if(n > SRAM_PAGESIZE) {
99
                return NULL;
100
        }
101
 
102
        /*
103
         * determine the page to load from the address
104
         */
105
        ch = (unsigned long) src / SRAM_PAGESIZE;
106
        pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch);
107
 
108
 
109
        /*
110
         * Block interrupts and load the page
111
         */
112
        save_flags(flags);
113
        cli();
114
 
115
        outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
116
                adapter[card]->ioport[adapter[card]->shmem_pgport]);
117
        pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
118
                ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
119
        ret = memcpy_fromio(dest,(void *)(adapter[card]->rambase +
120
                ((unsigned long) src % 0x4000)), n);
121
/*      pr_debug("%s: copying %d bytes from %#x to %#x\n",
122
                adapter[card]->devicename, n,
123
                adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */
124
        restore_flags(flags);
125
 
126
        return ret;
127
}
128
 
129
void *memset_shmem(int card, void *dest, int c, size_t n)
130
{
131
        unsigned long flags;
132
        unsigned char ch;
133
        void *ret;
134
 
135
        if(!IS_VALID_CARD(card)) {
136
                pr_debug("Invalid param: %d is not a valid card id\n", card);
137
                return NULL;
138
        }
139
 
140
        if(n > SRAM_PAGESIZE) {
141
                return NULL;
142
        }
143
 
144
        /*
145
         * determine the page to load from the address
146
         */
147
        ch = (unsigned long) dest / SRAM_PAGESIZE;
148
        pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch);
149
 
150
        /*
151
         * Block interrupts and load the page
152
         */
153
        save_flags(flags);
154
        cli();
155
 
156
        outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
157
                adapter[card]->ioport[adapter[card]->shmem_pgport]);
158
        pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
159
                ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
160
        ret = memset_io(adapter[card]->rambase +
161
                ((unsigned long) dest % 0x4000), c, n);
162
        restore_flags(flags);
163
 
164
        return ret;
165
}

powered by: WebSVN 2.1.0

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