drm/i915: Fix i965 secured batchbuffer usage (CVE-2007-3851)
[linux/fpc-iii.git] / drivers / isdn / sc / shmem.c
blob034d41a61ae1e65b0ba7fe86f339840fba65ba6b
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"
27 void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
29 unsigned long flags;
30 unsigned char ch;
32 if(!IS_VALID_CARD(card)) {
33 pr_debug("Invalid param: %d is not a valid card id\n", card);
34 return;
37 if(n > SRAM_PAGESIZE) {
38 return;
42 * determine the page to load from the address
44 ch = (unsigned long) dest / SRAM_PAGESIZE;
45 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch);
47 * Block interrupts and load the page
49 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
51 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
52 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
53 memcpy_toio(sc_adapter[card]->rambase +
54 ((unsigned long) dest % 0x4000), src, n);
55 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
56 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
57 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
58 pr_debug("%s: copying %d bytes from %#lx to %#lx\n",
59 sc_adapter[card]->devicename, n,
60 (unsigned long) src,
61 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000));
65 * Reverse of above
67 void memcpy_fromshmem(int card, void *dest, const void *src, size_t n)
69 unsigned long flags;
70 unsigned char ch;
72 if(!IS_VALID_CARD(card)) {
73 pr_debug("Invalid param: %d is not a valid card id\n", card);
74 return;
77 if(n > SRAM_PAGESIZE) {
78 return;
82 * determine the page to load from the address
84 ch = (unsigned long) src / SRAM_PAGESIZE;
85 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch);
89 * Block interrupts and load the page
91 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
93 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
94 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
95 memcpy_fromio(dest,(void *)(sc_adapter[card]->rambase +
96 ((unsigned long) src % 0x4000)), n);
97 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
98 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
99 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
100 /* pr_debug("%s: copying %d bytes from %#x to %#x\n",
101 sc_adapter[card]->devicename, n,
102 sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */
105 #if 0
106 void memset_shmem(int card, void *dest, int c, size_t n)
108 unsigned long flags;
109 unsigned char ch;
111 if(!IS_VALID_CARD(card)) {
112 pr_debug("Invalid param: %d is not a valid card id\n", card);
113 return;
116 if(n > SRAM_PAGESIZE) {
117 return;
121 * determine the page to load from the address
123 ch = (unsigned long) dest / SRAM_PAGESIZE;
124 pr_debug("%s: loaded page %d\n",sc_adapter[card]->devicename,ch);
127 * Block interrupts and load the page
129 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
131 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
132 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
133 memset_io(sc_adapter[card]->rambase +
134 ((unsigned long) dest % 0x4000), c, n);
135 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
136 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
137 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
139 #endif /* 0 */