diff options
Diffstat (limited to 'drivers/isdn/sc/shmem.c')
-rw-r--r-- | drivers/isdn/sc/shmem.c | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c new file mode 100644 index 000000000000..7bc2dfad0775 --- /dev/null +++ b/drivers/isdn/sc/shmem.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* $Id: shmem.c,v 1.2.10.1 2001/09/23 22:24:59 kai Exp $ | ||
2 | * | ||
3 | * Copyright (C) 1996 SpellCaster Telecommunications Inc. | ||
4 | * | ||
5 | * Card functions implementing ISDN4Linux functionality | ||
6 | * | ||
7 | * This software may be used and distributed according to the terms | ||
8 | * of the GNU General Public License, incorporated herein by reference. | ||
9 | * | ||
10 | * For more information, please contact gpl-info@spellcast.com or write: | ||
11 | * | ||
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 | ||
18 | */ | ||
19 | |||
20 | #include "includes.h" /* This must be first */ | ||
21 | #include "hardware.h" | ||
22 | #include "card.h" | ||
23 | |||
24 | /* | ||
25 | * Main adapter array | ||
26 | */ | ||
27 | extern board *sc_adapter[]; | ||
28 | extern int cinst; | ||
29 | |||
30 | /* | ||
31 | * | ||
32 | */ | ||
33 | void memcpy_toshmem(int card, void *dest, const void *src, size_t n) | ||
34 | { | ||
35 | unsigned long flags; | ||
36 | unsigned char ch; | ||
37 | |||
38 | if(!IS_VALID_CARD(card)) { | ||
39 | pr_debug("Invalid param: %d is not a valid card id\n", card); | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | if(n > SRAM_PAGESIZE) { | ||
44 | return; | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * determine the page to load from the address | ||
49 | */ | ||
50 | ch = (unsigned long) dest / SRAM_PAGESIZE; | ||
51 | pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); | ||
52 | /* | ||
53 | * Block interrupts and load the page | ||
54 | */ | ||
55 | spin_lock_irqsave(&sc_adapter[card]->lock, flags); | ||
56 | |||
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)); | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * Reverse of above | ||
72 | */ | ||
73 | void memcpy_fromshmem(int card, void *dest, const void *src, size_t n) | ||
74 | { | ||
75 | unsigned long flags; | ||
76 | unsigned char ch; | ||
77 | |||
78 | if(!IS_VALID_CARD(card)) { | ||
79 | pr_debug("Invalid param: %d is not a valid card id\n", card); | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | if(n > SRAM_PAGESIZE) { | ||
84 | return; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * determine the page to load from the address | ||
89 | */ | ||
90 | ch = (unsigned long) src / SRAM_PAGESIZE; | ||
91 | pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); | ||
92 | |||
93 | |||
94 | /* | ||
95 | * Block interrupts and load the page | ||
96 | */ | ||
97 | spin_lock_irqsave(&sc_adapter[card]->lock, flags); | ||
98 | |||
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); */ | ||
109 | } | ||
110 | |||
111 | void memset_shmem(int card, void *dest, int c, size_t n) | ||
112 | { | ||
113 | unsigned long flags; | ||
114 | unsigned char ch; | ||
115 | |||
116 | if(!IS_VALID_CARD(card)) { | ||
117 | pr_debug("Invalid param: %d is not a valid card id\n", card); | ||
118 | return; | ||
119 | } | ||
120 | |||
121 | if(n > SRAM_PAGESIZE) { | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * determine the page to load from the address | ||
127 | */ | ||
128 | ch = (unsigned long) dest / SRAM_PAGESIZE; | ||
129 | pr_debug("%s: loaded page %d\n",sc_adapter[card]->devicename,ch); | ||
130 | |||
131 | /* | ||
132 | * Block interrupts and load the page | ||
133 | */ | ||
134 | spin_lock_irqsave(&sc_adapter[card]->lock, flags); | ||
135 | |||
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); | ||
143 | } | ||