2 * $Id: shmem.c,v 1.2 1996/11/20 17:49:56 fritz Exp $
3 * Copyright (C) 1996 SpellCaster Telecommunications Inc.
5 * card.c - Card functions implementing ISDN4Linux functionality
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.
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.
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.
21 * For more information, please contact gpl-info@spellcast.com or write:
23 * SpellCaster Telecommunications Inc.
24 * 5621 Finch Avenue East, Unit #3
25 * Scarborough, Ontario Canada
28 * +1 (416) 297-6433 Facsimile
31 #define __NO_VERSION__
32 #include "includes.h" /* This must be first */
39 extern board
*adapter
[];
45 void *memcpy_toshmem(int card
, void *dest
, const void *src
, size_t n
)
51 if(!IS_VALID_CARD(card
)) {
52 pr_debug("Invalid param: %d is not a valid card id\n", card
);
56 if(n
> SRAM_PAGESIZE
) {
61 * determine the page to load from the address
63 ch
= (unsigned long) dest
/ SRAM_PAGESIZE
;
64 pr_debug("%s: loaded page %d\n",adapter
[card
]->devicename
,ch
);
66 * Block interrupts and load the page
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));
87 void *memcpy_fromshmem(int card
, void *dest
, const void *src
, size_t n
)
93 if(!IS_VALID_CARD(card
)) {
94 pr_debug("Invalid param: %d is not a valid card id\n", card
);
98 if(n
> SRAM_PAGESIZE
) {
103 * determine the page to load from the address
105 ch
= (unsigned long) src
/ SRAM_PAGESIZE
;
106 pr_debug("%s: loaded page %d\n",adapter
[card
]->devicename
,ch
);
110 * Block interrupts and load the page
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
);
129 void *memset_shmem(int card
, void *dest
, int c
, size_t n
)
135 if(!IS_VALID_CARD(card
)) {
136 pr_debug("Invalid param: %d is not a valid card id\n", card
);
140 if(n
> SRAM_PAGESIZE
) {
145 * determine the page to load from the address
147 ch
= (unsigned long) dest
/ SRAM_PAGESIZE
;
148 pr_debug("%s: loaded page %d\n",adapter
[card
]->devicename
,ch
);
151 * Block interrupts and load the page
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
);