[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / isdn / sc / shmem.c
blob7bc2dfad0775f2cbdf66fd0bbdeb94eaab079f8b
1 /* $Id: shmem.c,v 1.2.10.1 2001/09/23 22:24:59 kai Exp $
3 * Copyright (C) 1996 SpellCaster Telecommunications Inc.
5 * Card functions implementing ISDN4Linux functionality
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
10 * For more information, please contact gpl-info@spellcast.com or write:
12 * SpellCaster Telecommunications Inc.
13 * 5621 Finch Avenue East, Unit #3
14 * Scarborough, Ontario Canada
15 * M1B 2T9
16 * +1 (416) 297-8565
17 * +1 (416) 297-6433 Facsimile
20 #include "includes.h" /* This must be first */
21 #include "hardware.h"
22 #include "card.h"
25 * Main adapter array
27 extern board *sc_adapter[];
28 extern int cinst;
33 void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
35 unsigned long flags;
36 unsigned char ch;
38 if(!IS_VALID_CARD(card)) {
39 pr_debug("Invalid param: %d is not a valid card id\n", card);
40 return;
43 if(n > SRAM_PAGESIZE) {
44 return;
48 * determine the page to load from the address
50 ch = (unsigned long) dest / SRAM_PAGESIZE;
51 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch);
53 * Block interrupts and load the page
55 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
57 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
58 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
59 memcpy_toio(sc_adapter[card]->rambase +
60 ((unsigned long) dest % 0x4000), src, n);
61 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
62 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
63 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
64 pr_debug("%s: copying %d bytes from %#x to %#x\n",
65 sc_adapter[card]->devicename, n,
66 (unsigned long) src,
67 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000));
71 * Reverse of above
73 void memcpy_fromshmem(int card, void *dest, const void *src, size_t n)
75 unsigned long flags;
76 unsigned char ch;
78 if(!IS_VALID_CARD(card)) {
79 pr_debug("Invalid param: %d is not a valid card id\n", card);
80 return;
83 if(n > SRAM_PAGESIZE) {
84 return;
88 * determine the page to load from the address
90 ch = (unsigned long) src / SRAM_PAGESIZE;
91 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch);
95 * Block interrupts and load the page
97 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
99 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
100 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
101 memcpy_fromio(dest,(void *)(sc_adapter[card]->rambase +
102 ((unsigned long) src % 0x4000)), n);
103 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
104 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
105 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
106 /* pr_debug("%s: copying %d bytes from %#x to %#x\n",
107 sc_adapter[card]->devicename, n,
108 sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */
111 void memset_shmem(int card, void *dest, int c, size_t n)
113 unsigned long flags;
114 unsigned char ch;
116 if(!IS_VALID_CARD(card)) {
117 pr_debug("Invalid param: %d is not a valid card id\n", card);
118 return;
121 if(n > SRAM_PAGESIZE) {
122 return;
126 * determine the page to load from the address
128 ch = (unsigned long) dest / SRAM_PAGESIZE;
129 pr_debug("%s: loaded page %d\n",sc_adapter[card]->devicename,ch);
132 * Block interrupts and load the page
134 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
136 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
137 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
138 memset_io(sc_adapter[card]->rambase +
139 ((unsigned long) dest % 0x4000), c, n);
140 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
141 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
142 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);