2 * SRAM allocator for Blackfin on-chip memory
4 * Copyright 2004-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/types.h>
12 #include <linux/miscdevice.h>
13 #include <linux/ioport.h>
14 #include <linux/fcntl.h>
15 #include <linux/init.h>
16 #include <linux/poll.h>
17 #include <linux/proc_fs.h>
18 #include <linux/seq_file.h>
19 #include <linux/spinlock.h>
20 #include <linux/rtc.h>
21 #include <linux/slab.h>
22 #include <asm/blackfin.h>
23 #include <asm/mem_map.h>
24 #include "blackfin_sram.h"
26 /* the data structure for L1 scratchpad and DATA SRAM */
31 struct sram_piece
*next
;
34 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t
, l1sram_lock
);
35 static DEFINE_PER_CPU(struct sram_piece
, free_l1_ssram_head
);
36 static DEFINE_PER_CPU(struct sram_piece
, used_l1_ssram_head
);
38 #if L1_DATA_A_LENGTH != 0
39 static DEFINE_PER_CPU(struct sram_piece
, free_l1_data_A_sram_head
);
40 static DEFINE_PER_CPU(struct sram_piece
, used_l1_data_A_sram_head
);
43 #if L1_DATA_B_LENGTH != 0
44 static DEFINE_PER_CPU(struct sram_piece
, free_l1_data_B_sram_head
);
45 static DEFINE_PER_CPU(struct sram_piece
, used_l1_data_B_sram_head
);
48 #if L1_DATA_A_LENGTH || L1_DATA_B_LENGTH
49 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t
, l1_data_sram_lock
);
52 #if L1_CODE_LENGTH != 0
53 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t
, l1_inst_sram_lock
);
54 static DEFINE_PER_CPU(struct sram_piece
, free_l1_inst_sram_head
);
55 static DEFINE_PER_CPU(struct sram_piece
, used_l1_inst_sram_head
);
59 static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp
;
60 static struct sram_piece free_l2_sram_head
, used_l2_sram_head
;
63 static struct kmem_cache
*sram_piece_cache
;
65 /* L1 Scratchpad SRAM initialization function */
66 static void __init
l1sram_init(void)
69 unsigned long reserve
;
74 reserve
= sizeof(struct l1_scratch_task_info
);
77 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
) {
78 per_cpu(free_l1_ssram_head
, cpu
).next
=
79 kmem_cache_alloc(sram_piece_cache
, GFP_KERNEL
);
80 if (!per_cpu(free_l1_ssram_head
, cpu
).next
) {
81 printk(KERN_INFO
"Fail to initialize Scratchpad data SRAM.\n");
85 per_cpu(free_l1_ssram_head
, cpu
).next
->paddr
= (void *)get_l1_scratch_start_cpu(cpu
) + reserve
;
86 per_cpu(free_l1_ssram_head
, cpu
).next
->size
= L1_SCRATCH_LENGTH
- reserve
;
87 per_cpu(free_l1_ssram_head
, cpu
).next
->pid
= 0;
88 per_cpu(free_l1_ssram_head
, cpu
).next
->next
= NULL
;
90 per_cpu(used_l1_ssram_head
, cpu
).next
= NULL
;
92 /* mutex initialize */
93 spin_lock_init(&per_cpu(l1sram_lock
, cpu
));
94 printk(KERN_INFO
"Blackfin Scratchpad data SRAM: %d KB\n",
95 L1_SCRATCH_LENGTH
>> 10);
99 static void __init
l1_data_sram_init(void)
101 #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0
104 #if L1_DATA_A_LENGTH != 0
105 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
) {
106 per_cpu(free_l1_data_A_sram_head
, cpu
).next
=
107 kmem_cache_alloc(sram_piece_cache
, GFP_KERNEL
);
108 if (!per_cpu(free_l1_data_A_sram_head
, cpu
).next
) {
109 printk(KERN_INFO
"Fail to initialize L1 Data A SRAM.\n");
113 per_cpu(free_l1_data_A_sram_head
, cpu
).next
->paddr
=
114 (void *)get_l1_data_a_start_cpu(cpu
) + (_ebss_l1
- _sdata_l1
);
115 per_cpu(free_l1_data_A_sram_head
, cpu
).next
->size
=
116 L1_DATA_A_LENGTH
- (_ebss_l1
- _sdata_l1
);
117 per_cpu(free_l1_data_A_sram_head
, cpu
).next
->pid
= 0;
118 per_cpu(free_l1_data_A_sram_head
, cpu
).next
->next
= NULL
;
120 per_cpu(used_l1_data_A_sram_head
, cpu
).next
= NULL
;
122 printk(KERN_INFO
"Blackfin L1 Data A SRAM: %d KB (%d KB free)\n",
123 L1_DATA_A_LENGTH
>> 10,
124 per_cpu(free_l1_data_A_sram_head
, cpu
).next
->size
>> 10);
127 #if L1_DATA_B_LENGTH != 0
128 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
) {
129 per_cpu(free_l1_data_B_sram_head
, cpu
).next
=
130 kmem_cache_alloc(sram_piece_cache
, GFP_KERNEL
);
131 if (!per_cpu(free_l1_data_B_sram_head
, cpu
).next
) {
132 printk(KERN_INFO
"Fail to initialize L1 Data B SRAM.\n");
136 per_cpu(free_l1_data_B_sram_head
, cpu
).next
->paddr
=
137 (void *)get_l1_data_b_start_cpu(cpu
) + (_ebss_b_l1
- _sdata_b_l1
);
138 per_cpu(free_l1_data_B_sram_head
, cpu
).next
->size
=
139 L1_DATA_B_LENGTH
- (_ebss_b_l1
- _sdata_b_l1
);
140 per_cpu(free_l1_data_B_sram_head
, cpu
).next
->pid
= 0;
141 per_cpu(free_l1_data_B_sram_head
, cpu
).next
->next
= NULL
;
143 per_cpu(used_l1_data_B_sram_head
, cpu
).next
= NULL
;
145 printk(KERN_INFO
"Blackfin L1 Data B SRAM: %d KB (%d KB free)\n",
146 L1_DATA_B_LENGTH
>> 10,
147 per_cpu(free_l1_data_B_sram_head
, cpu
).next
->size
>> 10);
148 /* mutex initialize */
152 #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0
153 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
)
154 spin_lock_init(&per_cpu(l1_data_sram_lock
, cpu
));
158 static void __init
l1_inst_sram_init(void)
160 #if L1_CODE_LENGTH != 0
162 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
) {
163 per_cpu(free_l1_inst_sram_head
, cpu
).next
=
164 kmem_cache_alloc(sram_piece_cache
, GFP_KERNEL
);
165 if (!per_cpu(free_l1_inst_sram_head
, cpu
).next
) {
166 printk(KERN_INFO
"Failed to initialize L1 Instruction SRAM\n");
170 per_cpu(free_l1_inst_sram_head
, cpu
).next
->paddr
=
171 (void *)get_l1_code_start_cpu(cpu
) + (_etext_l1
- _stext_l1
);
172 per_cpu(free_l1_inst_sram_head
, cpu
).next
->size
=
173 L1_CODE_LENGTH
- (_etext_l1
- _stext_l1
);
174 per_cpu(free_l1_inst_sram_head
, cpu
).next
->pid
= 0;
175 per_cpu(free_l1_inst_sram_head
, cpu
).next
->next
= NULL
;
177 per_cpu(used_l1_inst_sram_head
, cpu
).next
= NULL
;
179 printk(KERN_INFO
"Blackfin L1 Instruction SRAM: %d KB (%d KB free)\n",
180 L1_CODE_LENGTH
>> 10,
181 per_cpu(free_l1_inst_sram_head
, cpu
).next
->size
>> 10);
183 /* mutex initialize */
184 spin_lock_init(&per_cpu(l1_inst_sram_lock
, cpu
));
189 static void __init
l2_sram_init(void)
192 free_l2_sram_head
.next
=
193 kmem_cache_alloc(sram_piece_cache
, GFP_KERNEL
);
194 if (!free_l2_sram_head
.next
) {
195 printk(KERN_INFO
"Fail to initialize L2 SRAM.\n");
199 free_l2_sram_head
.next
->paddr
=
200 (void *)L2_START
+ (_ebss_l2
- _stext_l2
);
201 free_l2_sram_head
.next
->size
=
202 L2_LENGTH
- (_ebss_l2
- _stext_l2
);
203 free_l2_sram_head
.next
->pid
= 0;
204 free_l2_sram_head
.next
->next
= NULL
;
206 used_l2_sram_head
.next
= NULL
;
208 printk(KERN_INFO
"Blackfin L2 SRAM: %d KB (%d KB free)\n",
210 free_l2_sram_head
.next
->size
>> 10);
212 /* mutex initialize */
213 spin_lock_init(&l2_sram_lock
);
217 static int __init
bfin_sram_init(void)
219 sram_piece_cache
= kmem_cache_create("sram_piece_cache",
220 sizeof(struct sram_piece
),
221 0, SLAB_PANIC
, NULL
);
230 pure_initcall(bfin_sram_init
);
232 /* SRAM allocate function */
233 static void *_sram_alloc(size_t size
, struct sram_piece
*pfree_head
,
234 struct sram_piece
*pused_head
)
236 struct sram_piece
*pslot
, *plast
, *pavail
;
238 if (size
<= 0 || !pfree_head
|| !pused_head
)
242 size
= (size
+ 3) & ~3;
244 pslot
= pfree_head
->next
;
247 /* search an available piece slot */
248 while (pslot
!= NULL
&& size
> pslot
->size
) {
256 if (pslot
->size
== size
) {
257 plast
->next
= pslot
->next
;
260 /* use atomic so our L1 allocator can be used atomically */
261 pavail
= kmem_cache_alloc(sram_piece_cache
, GFP_ATOMIC
);
266 pavail
->paddr
= pslot
->paddr
;
268 pslot
->paddr
+= size
;
272 pavail
->pid
= current
->pid
;
274 pslot
= pused_head
->next
;
277 /* insert new piece into used piece list !!! */
278 while (pslot
!= NULL
&& pavail
->paddr
< pslot
->paddr
) {
283 pavail
->next
= pslot
;
284 plast
->next
= pavail
;
286 return pavail
->paddr
;
289 /* Allocate the largest available block. */
290 static void *_sram_alloc_max(struct sram_piece
*pfree_head
,
291 struct sram_piece
*pused_head
,
292 unsigned long *psize
)
294 struct sram_piece
*pslot
, *pmax
;
296 if (!pfree_head
|| !pused_head
)
299 pmax
= pslot
= pfree_head
->next
;
301 /* search an available piece slot */
302 while (pslot
!= NULL
) {
303 if (pslot
->size
> pmax
->size
)
313 return _sram_alloc(*psize
, pfree_head
, pused_head
);
316 /* SRAM free function */
317 static int _sram_free(const void *addr
,
318 struct sram_piece
*pfree_head
,
319 struct sram_piece
*pused_head
)
321 struct sram_piece
*pslot
, *plast
, *pavail
;
323 if (!pfree_head
|| !pused_head
)
326 /* search the relevant memory slot */
327 pslot
= pused_head
->next
;
330 /* search an available piece slot */
331 while (pslot
!= NULL
&& pslot
->paddr
!= addr
) {
339 plast
->next
= pslot
->next
;
343 /* insert free pieces back to the free list */
344 pslot
= pfree_head
->next
;
347 while (pslot
!= NULL
&& addr
> pslot
->paddr
) {
352 if (plast
!= pfree_head
&& plast
->paddr
+ plast
->size
== pavail
->paddr
) {
353 plast
->size
+= pavail
->size
;
354 kmem_cache_free(sram_piece_cache
, pavail
);
356 pavail
->next
= plast
->next
;
357 plast
->next
= pavail
;
361 if (pslot
&& plast
->paddr
+ plast
->size
== pslot
->paddr
) {
362 plast
->size
+= pslot
->size
;
363 plast
->next
= pslot
->next
;
364 kmem_cache_free(sram_piece_cache
, pslot
);
370 int sram_free(const void *addr
)
373 #if L1_CODE_LENGTH != 0
374 if (addr
>= (void *)get_l1_code_start()
375 && addr
< (void *)(get_l1_code_start() + L1_CODE_LENGTH
))
376 return l1_inst_sram_free(addr
);
379 #if L1_DATA_A_LENGTH != 0
380 if (addr
>= (void *)get_l1_data_a_start()
381 && addr
< (void *)(get_l1_data_a_start() + L1_DATA_A_LENGTH
))
382 return l1_data_A_sram_free(addr
);
385 #if L1_DATA_B_LENGTH != 0
386 if (addr
>= (void *)get_l1_data_b_start()
387 && addr
< (void *)(get_l1_data_b_start() + L1_DATA_B_LENGTH
))
388 return l1_data_B_sram_free(addr
);
392 if (addr
>= (void *)L2_START
393 && addr
< (void *)(L2_START
+ L2_LENGTH
))
394 return l2_sram_free(addr
);
399 EXPORT_SYMBOL(sram_free
);
401 void *l1_data_A_sram_alloc(size_t size
)
403 #if L1_DATA_A_LENGTH != 0
408 cpu
= smp_processor_id();
409 /* add mutex operation */
410 spin_lock_irqsave(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
412 addr
= _sram_alloc(size
, &per_cpu(free_l1_data_A_sram_head
, cpu
),
413 &per_cpu(used_l1_data_A_sram_head
, cpu
));
415 /* add mutex operation */
416 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
418 pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n",
419 (long unsigned int)addr
, size
);
426 EXPORT_SYMBOL(l1_data_A_sram_alloc
);
428 int l1_data_A_sram_free(const void *addr
)
430 #if L1_DATA_A_LENGTH != 0
435 cpu
= smp_processor_id();
436 /* add mutex operation */
437 spin_lock_irqsave(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
439 ret
= _sram_free(addr
, &per_cpu(free_l1_data_A_sram_head
, cpu
),
440 &per_cpu(used_l1_data_A_sram_head
, cpu
));
442 /* add mutex operation */
443 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
450 EXPORT_SYMBOL(l1_data_A_sram_free
);
452 void *l1_data_B_sram_alloc(size_t size
)
454 #if L1_DATA_B_LENGTH != 0
459 cpu
= smp_processor_id();
460 /* add mutex operation */
461 spin_lock_irqsave(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
463 addr
= _sram_alloc(size
, &per_cpu(free_l1_data_B_sram_head
, cpu
),
464 &per_cpu(used_l1_data_B_sram_head
, cpu
));
466 /* add mutex operation */
467 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
469 pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n",
470 (long unsigned int)addr
, size
);
477 EXPORT_SYMBOL(l1_data_B_sram_alloc
);
479 int l1_data_B_sram_free(const void *addr
)
481 #if L1_DATA_B_LENGTH != 0
486 cpu
= smp_processor_id();
487 /* add mutex operation */
488 spin_lock_irqsave(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
490 ret
= _sram_free(addr
, &per_cpu(free_l1_data_B_sram_head
, cpu
),
491 &per_cpu(used_l1_data_B_sram_head
, cpu
));
493 /* add mutex operation */
494 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock
, cpu
), flags
);
501 EXPORT_SYMBOL(l1_data_B_sram_free
);
503 void *l1_data_sram_alloc(size_t size
)
505 void *addr
= l1_data_A_sram_alloc(size
);
508 addr
= l1_data_B_sram_alloc(size
);
512 EXPORT_SYMBOL(l1_data_sram_alloc
);
514 void *l1_data_sram_zalloc(size_t size
)
516 void *addr
= l1_data_sram_alloc(size
);
519 memset(addr
, 0x00, size
);
523 EXPORT_SYMBOL(l1_data_sram_zalloc
);
525 int l1_data_sram_free(const void *addr
)
528 ret
= l1_data_A_sram_free(addr
);
530 ret
= l1_data_B_sram_free(addr
);
533 EXPORT_SYMBOL(l1_data_sram_free
);
535 void *l1_inst_sram_alloc(size_t size
)
537 #if L1_CODE_LENGTH != 0
542 cpu
= smp_processor_id();
543 /* add mutex operation */
544 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock
, cpu
), flags
);
546 addr
= _sram_alloc(size
, &per_cpu(free_l1_inst_sram_head
, cpu
),
547 &per_cpu(used_l1_inst_sram_head
, cpu
));
549 /* add mutex operation */
550 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock
, cpu
), flags
);
552 pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n",
553 (long unsigned int)addr
, size
);
560 EXPORT_SYMBOL(l1_inst_sram_alloc
);
562 int l1_inst_sram_free(const void *addr
)
564 #if L1_CODE_LENGTH != 0
569 cpu
= smp_processor_id();
570 /* add mutex operation */
571 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock
, cpu
), flags
);
573 ret
= _sram_free(addr
, &per_cpu(free_l1_inst_sram_head
, cpu
),
574 &per_cpu(used_l1_inst_sram_head
, cpu
));
576 /* add mutex operation */
577 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock
, cpu
), flags
);
584 EXPORT_SYMBOL(l1_inst_sram_free
);
586 /* L1 Scratchpad memory allocate function */
587 void *l1sram_alloc(size_t size
)
593 cpu
= smp_processor_id();
594 /* add mutex operation */
595 spin_lock_irqsave(&per_cpu(l1sram_lock
, cpu
), flags
);
597 addr
= _sram_alloc(size
, &per_cpu(free_l1_ssram_head
, cpu
),
598 &per_cpu(used_l1_ssram_head
, cpu
));
600 /* add mutex operation */
601 spin_unlock_irqrestore(&per_cpu(l1sram_lock
, cpu
), flags
);
606 /* L1 Scratchpad memory allocate function */
607 void *l1sram_alloc_max(size_t *psize
)
613 cpu
= smp_processor_id();
614 /* add mutex operation */
615 spin_lock_irqsave(&per_cpu(l1sram_lock
, cpu
), flags
);
617 addr
= _sram_alloc_max(&per_cpu(free_l1_ssram_head
, cpu
),
618 &per_cpu(used_l1_ssram_head
, cpu
), psize
);
620 /* add mutex operation */
621 spin_unlock_irqrestore(&per_cpu(l1sram_lock
, cpu
), flags
);
626 /* L1 Scratchpad memory free function */
627 int l1sram_free(const void *addr
)
633 cpu
= smp_processor_id();
634 /* add mutex operation */
635 spin_lock_irqsave(&per_cpu(l1sram_lock
, cpu
), flags
);
637 ret
= _sram_free(addr
, &per_cpu(free_l1_ssram_head
, cpu
),
638 &per_cpu(used_l1_ssram_head
, cpu
));
640 /* add mutex operation */
641 spin_unlock_irqrestore(&per_cpu(l1sram_lock
, cpu
), flags
);
646 void *l2_sram_alloc(size_t size
)
652 /* add mutex operation */
653 spin_lock_irqsave(&l2_sram_lock
, flags
);
655 addr
= _sram_alloc(size
, &free_l2_sram_head
,
658 /* add mutex operation */
659 spin_unlock_irqrestore(&l2_sram_lock
, flags
);
661 pr_debug("Allocated address in l2_sram_alloc is 0x%lx+0x%lx\n",
662 (long unsigned int)addr
, size
);
669 EXPORT_SYMBOL(l2_sram_alloc
);
671 void *l2_sram_zalloc(size_t size
)
673 void *addr
= l2_sram_alloc(size
);
676 memset(addr
, 0x00, size
);
680 EXPORT_SYMBOL(l2_sram_zalloc
);
682 int l2_sram_free(const void *addr
)
688 /* add mutex operation */
689 spin_lock_irqsave(&l2_sram_lock
, flags
);
691 ret
= _sram_free(addr
, &free_l2_sram_head
,
694 /* add mutex operation */
695 spin_unlock_irqrestore(&l2_sram_lock
, flags
);
702 EXPORT_SYMBOL(l2_sram_free
);
704 int sram_free_with_lsl(const void *addr
)
706 struct sram_list_struct
*lsl
, **tmp
;
707 struct mm_struct
*mm
= current
->mm
;
710 for (tmp
= &mm
->context
.sram_list
; *tmp
; tmp
= &(*tmp
)->next
)
711 if ((*tmp
)->addr
== addr
) {
713 ret
= sram_free(addr
);
721 EXPORT_SYMBOL(sram_free_with_lsl
);
723 /* Allocate memory and keep in L1 SRAM List (lsl) so that the resources are
724 * tracked. These are designed for userspace so that when a process exits,
725 * we can safely reap their resources.
727 void *sram_alloc_with_lsl(size_t size
, unsigned long flags
)
730 struct sram_list_struct
*lsl
= NULL
;
731 struct mm_struct
*mm
= current
->mm
;
733 lsl
= kzalloc(sizeof(struct sram_list_struct
), GFP_KERNEL
);
737 if (flags
& L1_INST_SRAM
)
738 addr
= l1_inst_sram_alloc(size
);
740 if (addr
== NULL
&& (flags
& L1_DATA_A_SRAM
))
741 addr
= l1_data_A_sram_alloc(size
);
743 if (addr
== NULL
&& (flags
& L1_DATA_B_SRAM
))
744 addr
= l1_data_B_sram_alloc(size
);
746 if (addr
== NULL
&& (flags
& L2_SRAM
))
747 addr
= l2_sram_alloc(size
);
755 lsl
->next
= mm
->context
.sram_list
;
756 mm
->context
.sram_list
= lsl
;
759 EXPORT_SYMBOL(sram_alloc_with_lsl
);
761 #ifdef CONFIG_PROC_FS
762 /* Once we get a real allocator, we'll throw all of this away.
763 * Until then, we need some sort of visibility into the L1 alloc.
765 /* Need to keep line of output the same. Currently, that is 44 bytes
766 * (including newline).
768 static int _sram_proc_show(struct seq_file
*m
, const char *desc
,
769 struct sram_piece
*pfree_head
,
770 struct sram_piece
*pused_head
)
772 struct sram_piece
*pslot
;
774 if (!pfree_head
|| !pused_head
)
777 seq_printf(m
, "--- SRAM %-14s Size PID State \n", desc
);
779 /* search the relevant memory slot */
780 pslot
= pused_head
->next
;
782 while (pslot
!= NULL
) {
783 seq_printf(m
, "%p-%p %10i %5i %-10s\n",
784 pslot
->paddr
, pslot
->paddr
+ pslot
->size
,
785 pslot
->size
, pslot
->pid
, "ALLOCATED");
790 pslot
= pfree_head
->next
;
792 while (pslot
!= NULL
) {
793 seq_printf(m
, "%p-%p %10i %5i %-10s\n",
794 pslot
->paddr
, pslot
->paddr
+ pslot
->size
,
795 pslot
->size
, pslot
->pid
, "FREE");
802 static int sram_proc_show(struct seq_file
*m
, void *v
)
806 for (cpu
= 0; cpu
< num_possible_cpus(); ++cpu
) {
807 if (_sram_proc_show(m
, "Scratchpad",
808 &per_cpu(free_l1_ssram_head
, cpu
), &per_cpu(used_l1_ssram_head
, cpu
)))
810 #if L1_DATA_A_LENGTH != 0
811 if (_sram_proc_show(m
, "L1 Data A",
812 &per_cpu(free_l1_data_A_sram_head
, cpu
),
813 &per_cpu(used_l1_data_A_sram_head
, cpu
)))
816 #if L1_DATA_B_LENGTH != 0
817 if (_sram_proc_show(m
, "L1 Data B",
818 &per_cpu(free_l1_data_B_sram_head
, cpu
),
819 &per_cpu(used_l1_data_B_sram_head
, cpu
)))
822 #if L1_CODE_LENGTH != 0
823 if (_sram_proc_show(m
, "L1 Instruction",
824 &per_cpu(free_l1_inst_sram_head
, cpu
),
825 &per_cpu(used_l1_inst_sram_head
, cpu
)))
830 if (_sram_proc_show(m
, "L2", &free_l2_sram_head
, &used_l2_sram_head
))
837 static int sram_proc_open(struct inode
*inode
, struct file
*file
)
839 return single_open(file
, sram_proc_show
, NULL
);
842 static const struct file_operations sram_proc_ops
= {
843 .open
= sram_proc_open
,
846 .release
= single_release
,
849 static int __init
sram_proc_init(void)
851 struct proc_dir_entry
*ptr
;
853 ptr
= proc_create("sram", S_IRUGO
, NULL
, &sram_proc_ops
);
855 printk(KERN_WARNING
"unable to create /proc/sram\n");
860 late_initcall(sram_proc_init
);