15 #include <linux/bitmap.h>
16 #include <linux/device.h>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/slab.h>
23 #include <linux/prefetch.h>
25 #include <asm/cacheflush.h>
43 static unsigned long *sq_bitmap;
45 #define store_queue_barrier() \
47 (void)__raw_readl(P4SEG_STORE_QUE); \
48 __raw_writel(0, P4SEG_STORE_QUE + 0); \
49 __raw_writel(0, P4SEG_STORE_QUE + 8); \
62 unsigned long *sq = (
unsigned long *)start;
65 for (len >>= 5; len--; sq += 8)
73 static inline void sq_mapping_list_add(
struct sq_mapping *
map)
77 spin_lock_irq(&sq_mapping_lock);
80 while ((tmp = *p) !=
NULL)
86 spin_unlock_irq(&sq_mapping_lock);
89 static inline void sq_mapping_list_del(
struct sq_mapping *map)
93 spin_lock_irq(&sq_mapping_lock);
95 for (p = &sq_mapping_list; (tmp = *
p); p = &tmp->
next)
101 spin_unlock_irq(&sq_mapping_lock);
106 #if defined(CONFIG_MMU)
116 (
unsigned long)vma->
addr + map->
size,
154 end = phys + size - 1;
181 ret = __sq_remap(map, prot);
186 pr_info(
"sqremap: %15s [%4d page%s] va 0x%08lx pa 0x%08lx\n",
188 psz, psz == 1 ?
" " :
"s",
191 sq_mapping_list_add(map);
214 for (p = &sq_mapping_list; (map = *
p); p = &map->
next)
219 printk(
"%s: bad store queue address 0x%08lx\n",
243 sq_mapping_list_del(map);
267 #define to_sq_sysfs_attr(a) container_of(a, struct sq_sysfs_attr, attr)
275 return sattr->
show(buf);
286 return sattr->
store(buf, count);
291 static ssize_t mapping_show(
char *buf)
296 for (list = &sq_mapping_list; (entry = *
list); list = &entry->
next)
297 p +=
sprintf(p,
"%08lx-%08lx [%08lx]: %s\n",
304 static ssize_t mapping_store(
const char *buf,
size_t count)
306 unsigned long base = 0,
len = 0;
308 sscanf(buf,
"%lx %lx", &base, &len);
313 int ret =
sq_remap(base, len,
"Userspace", PAGE_SHARED);
325 static struct attribute *sq_sysfs_attrs[] = {
330 static const struct sysfs_ops sq_sysfs_ops = {
331 .show = sq_sysfs_show,
332 .store = sq_sysfs_store,
335 static struct kobj_type ktype_percpu_entry = {
336 .sysfs_ops = &sq_sysfs_ops,
337 .default_attrs = sq_sysfs_attrs,
342 unsigned int cpu = dev->
id;
350 kobj = sq_kobject[
cpu];
360 unsigned int cpu = dev->
id;
370 .add_dev = sq_dev_add,
371 .remove_dev = sq_dev_remove,
374 static int __init sq_api_init(
void)
376 unsigned int nr_pages = 0x04000000 >>
PAGE_SHIFT;
404 static void __exit sq_api_exit(
void)