From ff4c02e4be00dccfb4b7baa8e56300b6ab3e290a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 18 Nov 2008 17:48:22 +0800 Subject: Blackfin arch: unify cplbinfo files Merge MPU and noMPU version of CPLB info code to one common version. Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- arch/blackfin/kernel/cplbinfo.c | 200 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 arch/blackfin/kernel/cplbinfo.c (limited to 'arch/blackfin/kernel/cplbinfo.c') diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c new file mode 100644 index 00000000000..dc584fe18e5 --- /dev/null +++ b/arch/blackfin/kernel/cplbinfo.c @@ -0,0 +1,200 @@ +/* + * arch/blackfin/kernel/cplbinfo.c - display CPLB status + * + * Copyright 2004-2008 Analog Devices Inc. + * Licensed under the GPL-2 or later. + */ + +#include +#include +#include +#include +#include + +#include +#include + +typedef enum { ICPLB, DCPLB } cplb_type; + +static char page_strtbl[][3] = { "1K", "4K", "1M", "4M" }; +#define page(flags) (((flags) & 0x30000) >> 16) +#define strpage(flags) page_strtbl[page(flags)] + +#ifdef CONFIG_MPU + +static char *cplb_print_entry(char *buf, cplb_type type, unsigned int cpu) +{ + struct cplb_entry *tbl; + int switched; + int i; + + if (type == ICPLB) { + tbl = icplb_tbl[cpu]; + switched = first_switched_icplb; + } else { + tbl = dcplb_tbl[cpu]; + switched = first_switched_dcplb; + } + + buf += sprintf(buf, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n"); + for (i = 0; i < MAX_CPLBS; ++i) { + unsigned long data = tbl[i].data; + unsigned long addr = tbl[i].addr; + + if (!(data & CPLB_VALID)) + continue; + + buf += sprintf(buf, + "%d\t0x%08lx\t%05lx\t%s\t%c\t%c\t%c\t%c\n", + i, addr, data, strpage(data), + (data & CPLB_USER_RD) ? 'Y' : 'N', + (data & CPLB_USER_WR) ? 'Y' : 'N', + (data & CPLB_SUPV_WR) ? 'Y' : 'N', + i < switched ? 'N' : 'Y'); + } + buf += sprintf(buf, "\n"); + + return buf; +} + +#else + +static int page_size_table[4] = { + 0x00000400, /* 1K */ + 0x00001000, /* 4K */ + 0x00100000, /* 1M */ + 0x00400000 /* 4M */ +}; + +static int cplb_find_entry(unsigned long *cplb_addr, + unsigned long *cplb_data, unsigned long addr, + unsigned long data) +{ + int i; + + for (i = 0; i < 16; ++i) + if (addr >= cplb_addr[i] && + addr < cplb_addr[i] + page_size_table[page(cplb_data[i])] && + cplb_data[i] == data) + return i; + + return -1; +} + +static char *cplb_print_entry(char *buf, cplb_type type, unsigned int cpu) +{ + unsigned long *p_addr, *p_data, *p_icount, *p_ocount; + unsigned long *cplb_addr, *cplb_data; + int entry = 0, used_cplb = 0; + + if (type == ICPLB) { + p_addr = ipdt_tables[cpu]; + p_data = ipdt_tables[cpu] + 1; + p_icount = ipdt_swapcount_tables[cpu]; + p_ocount = ipdt_swapcount_tables[cpu] + 1; + cplb_addr = (unsigned long *)ICPLB_ADDR0; + cplb_data = (unsigned long *)ICPLB_DATA0; + } else { + p_addr = dpdt_tables[cpu]; + p_data = dpdt_tables[cpu] + 1; + p_icount = dpdt_swapcount_tables[cpu]; + p_ocount = dpdt_swapcount_tables[cpu] + 1; + cplb_addr = (unsigned long *)DCPLB_ADDR0; + cplb_data = (unsigned long *)DCPLB_DATA0; + } + + buf += sprintf(buf, "Address\t\tData\tSize\tValid\tLocked\tSwapin\tiCount\toCount\n"); + + while (*p_addr != 0xffffffff) { + entry = cplb_find_entry(cplb_addr, cplb_data, *p_addr, *p_data); + if (entry >= 0) + used_cplb |= 1 << entry; + + buf += sprintf(buf, + "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", + *p_addr, *p_data, strpage(*p_data), + (*p_data & CPLB_VALID) ? 'Y' : 'N', + (*p_data & CPLB_LOCK) ? 'Y' : 'N', entry, *p_icount, + *p_ocount); + + p_addr += 2; + p_data += 2; + p_icount += 2; + p_ocount += 2; + } + + if (used_cplb != 0xffff) { + buf += sprintf(buf, "Unused/mismatched CPLBs:\n"); + + for (entry = 0; entry < 16; ++entry) + if (0 == ((1 << entry) & used_cplb)) { + int flags = cplb_data[entry]; + buf += sprintf(buf, + "%2d: 0x%08lx\t0x%05x\t%s\t%c\t%c\n", + entry, cplb_addr[entry], flags, strpage(flags), + (flags & CPLB_VALID) ? 'Y' : 'N', + (flags & CPLB_LOCK) ? 'Y' : 'N'); + } + } + + buf += sprintf(buf, "\n"); + + return buf; +} + +#endif + +static int cplbinfo_proc_output(char *buf, void *data) +{ + unsigned int cpu = (unsigned int)data; + char *p = buf; + + if (bfin_read_IMEM_CONTROL() & ENICPLB) { + p += sprintf(p, "Instruction CPLB entry:\n"); + p = cplb_print_entry(p, ICPLB, cpu); + } else + p += sprintf(p, "Instruction CPLB is disabled.\n\n"); + + if (bfin_read_DMEM_CONTROL() & ENDCPLB) { + p += sprintf(p, "Data CPLB entry:\n"); + p = cplb_print_entry(p, DCPLB, cpu); + } else + p += sprintf(p, "Data CPLB is disabled.\n\n"); + + return p - buf; +} + +static int cplbinfo_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = cplbinfo_proc_output(page, data); + if (len <= off + count) + *eof = 1; + *start = page + off; + len -= off; + return max(min(len, count), 0); +} + +static int __init cplbinfo_init(void) +{ + struct proc_dir_entry *parent, *entry; + unsigned int cpu; + unsigned char str[10]; + + parent = proc_mkdir("cplbinfo", NULL); + if (!parent) + return -ENOMEM; + + for_each_online_cpu(cpu) { + sprintf(str, "cpu%u", cpu); + entry = create_proc_entry(str, 0, parent); + if (!entry) + return -ENOMEM; + + entry->read_proc = cplbinfo_read_proc; + entry->data = (void *)cpu; + } + + return 0; +} +late_initcall(cplbinfo_init); -- cgit v1.2.3 From cb15e57cc7d68e524f709c9a541b4900df80df16 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 18 Nov 2008 17:48:22 +0800 Subject: Blackfin arch: noMMU CPLB lookup tables can be in L1 SRAM - unify duplicate page_size_table definitions - make sure it is placed alongside the other cplb switching code Pointed-out-by: Michael McTernan Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- arch/blackfin/kernel/cplbinfo.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'arch/blackfin/kernel/cplbinfo.c') diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c index dc584fe18e5..723839da14a 100644 --- a/arch/blackfin/kernel/cplbinfo.c +++ b/arch/blackfin/kernel/cplbinfo.c @@ -59,12 +59,7 @@ static char *cplb_print_entry(char *buf, cplb_type type, unsigned int cpu) #else -static int page_size_table[4] = { - 0x00000400, /* 1K */ - 0x00001000, /* 4K */ - 0x00100000, /* 1M */ - 0x00400000 /* 4M */ -}; +extern int page_size_table[]; static int cplb_find_entry(unsigned long *cplb_addr, unsigned long *cplb_data, unsigned long addr, -- cgit v1.2.3 From a024d41bfeda183093c3e3af50e433d8de297f8b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 7 Jan 2009 23:14:39 +0800 Subject: Blackfin arch: rewrite cplbinfo to use seq files Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- arch/blackfin/kernel/cplbinfo.c | 316 ++++++++++++++++++++++++---------------- 1 file changed, 191 insertions(+), 125 deletions(-) (limited to 'arch/blackfin/kernel/cplbinfo.c') diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c index 723839da14a..1d3bbec1a19 100644 --- a/arch/blackfin/kernel/cplbinfo.c +++ b/arch/blackfin/kernel/cplbinfo.c @@ -5,189 +5,255 @@ * Licensed under the GPL-2 or later. */ +#include #include #include #include #include +#include #include #include #include -typedef enum { ICPLB, DCPLB } cplb_type; - -static char page_strtbl[][3] = { "1K", "4K", "1M", "4M" }; +static char const page_strtbl[][3] = { "1K", "4K", "1M", "4M" }; #define page(flags) (((flags) & 0x30000) >> 16) #define strpage(flags) page_strtbl[page(flags)] #ifdef CONFIG_MPU -static char *cplb_print_entry(char *buf, cplb_type type, unsigned int cpu) -{ +struct cplbinfo_data { + loff_t pos; + char cplb_type; + u32 mem_control; struct cplb_entry *tbl; int switched; - int i; +}; - if (type == ICPLB) { - tbl = icplb_tbl[cpu]; - switched = first_switched_icplb; - } else { - tbl = dcplb_tbl[cpu]; - switched = first_switched_dcplb; - } +static void cplbinfo_print_header(struct seq_file *m) +{ + seq_printf(m, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n"); +} - buf += sprintf(buf, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n"); - for (i = 0; i < MAX_CPLBS; ++i) { - unsigned long data = tbl[i].data; - unsigned long addr = tbl[i].addr; - - if (!(data & CPLB_VALID)) - continue; - - buf += sprintf(buf, - "%d\t0x%08lx\t%05lx\t%s\t%c\t%c\t%c\t%c\n", - i, addr, data, strpage(data), - (data & CPLB_USER_RD) ? 'Y' : 'N', - (data & CPLB_USER_WR) ? 'Y' : 'N', - (data & CPLB_SUPV_WR) ? 'Y' : 'N', - i < switched ? 'N' : 'Y'); - } - buf += sprintf(buf, "\n"); +static int cplbinfo_nomore(struct cplbinfo_data *cdata) +{ + return cdata->pos >= MAX_CPLBS; +} + +static int cplbinfo_show(struct seq_file *m, void *p) +{ + struct cplbinfo_data *cdata; + unsigned long data, addr; + loff_t pos; + + cdata = p; + pos = cdata->pos; + addr = cdata->tbl[pos].addr; + data = cdata->tbl[pos].data; + + seq_printf(m, + "%d\t0x%08lx\t%05lx\t%s\t%c\t%c\t%c\t%c\n", + (int)pos, addr, data, strpage(data), + (data & CPLB_USER_RD) ? 'Y' : 'N', + (data & CPLB_USER_WR) ? 'Y' : 'N', + (data & CPLB_SUPV_WR) ? 'Y' : 'N', + pos < cdata->switched ? 'N' : 'Y'); - return buf; + return 0; +} + +static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) +{ + if (cdata->cplb_type == 'I') { + cdata->mem_control = bfin_read_IMEM_CONTROL(); + cdata->tbl = icplb_tbl[cpu]; + cdata->switched = first_switched_icplb; + } else { + cdata->mem_control = bfin_read_DMEM_CONTROL(); + cdata->tbl = dcplb_tbl[cpu]; + cdata->switched = first_switched_dcplb; + } } #else +struct cplbinfo_data { + loff_t pos; + char cplb_type; + u32 mem_control; + unsigned long *pdt_tables, *pdt_swapcount; + unsigned long cplb_addr, cplb_data; +}; + extern int page_size_table[]; -static int cplb_find_entry(unsigned long *cplb_addr, - unsigned long *cplb_data, unsigned long addr, - unsigned long data) +static int cplb_find_entry(unsigned long addr_tbl, unsigned long data_tbl, + unsigned long addr_find, unsigned long data_find) { int i; - for (i = 0; i < 16; ++i) - if (addr >= cplb_addr[i] && - addr < cplb_addr[i] + page_size_table[page(cplb_data[i])] && - cplb_data[i] == data) + for (i = 0; i < 16; ++i) { + unsigned long cplb_addr = bfin_read32(addr_tbl + i * 4); + unsigned long cplb_data = bfin_read32(data_tbl + i * 4); + if (addr_find >= cplb_addr && + addr_find < cplb_addr + page_size_table[page(cplb_data)] && + cplb_data == data_find) return i; + } return -1; } -static char *cplb_print_entry(char *buf, cplb_type type, unsigned int cpu) +static void cplbinfo_print_header(struct seq_file *m) { - unsigned long *p_addr, *p_data, *p_icount, *p_ocount; - unsigned long *cplb_addr, *cplb_data; - int entry = 0, used_cplb = 0; - - if (type == ICPLB) { - p_addr = ipdt_tables[cpu]; - p_data = ipdt_tables[cpu] + 1; - p_icount = ipdt_swapcount_tables[cpu]; - p_ocount = ipdt_swapcount_tables[cpu] + 1; - cplb_addr = (unsigned long *)ICPLB_ADDR0; - cplb_data = (unsigned long *)ICPLB_DATA0; - } else { - p_addr = dpdt_tables[cpu]; - p_data = dpdt_tables[cpu] + 1; - p_icount = dpdt_swapcount_tables[cpu]; - p_ocount = dpdt_swapcount_tables[cpu] + 1; - cplb_addr = (unsigned long *)DCPLB_ADDR0; - cplb_data = (unsigned long *)DCPLB_DATA0; - } - - buf += sprintf(buf, "Address\t\tData\tSize\tValid\tLocked\tSwapin\tiCount\toCount\n"); + seq_printf(m, "Address\t\tData\tSize\tValid\tLocked\tSwapin\tiCount\toCount\n"); +} - while (*p_addr != 0xffffffff) { - entry = cplb_find_entry(cplb_addr, cplb_data, *p_addr, *p_data); - if (entry >= 0) - used_cplb |= 1 << entry; +static int cplbinfo_nomore(struct cplbinfo_data *cdata) +{ + return cdata->pdt_tables[cdata->pos * 2] == 0xffffffff; +} - buf += sprintf(buf, - "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", - *p_addr, *p_data, strpage(*p_data), - (*p_data & CPLB_VALID) ? 'Y' : 'N', - (*p_data & CPLB_LOCK) ? 'Y' : 'N', entry, *p_icount, - *p_ocount); +static int cplbinfo_show(struct seq_file *m, void *p) +{ + struct cplbinfo_data *cdata; + unsigned long data, addr; + int entry; + loff_t pos; + + cdata = p; + pos = cdata->pos * 2; + addr = cdata->pdt_tables[pos]; + data = cdata->pdt_tables[pos + 1]; + entry = cplb_find_entry(cdata->cplb_addr, cdata->cplb_data, addr, data); + + seq_printf(m, + "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", + addr, data, strpage(data), + (data & CPLB_VALID) ? 'Y' : 'N', + (data & CPLB_LOCK) ? 'Y' : 'N', entry, + cdata->pdt_swapcount[pos], + cdata->pdt_swapcount[pos + 1]); - p_addr += 2; - p_data += 2; - p_icount += 2; - p_ocount += 2; - } + return 0; +} - if (used_cplb != 0xffff) { - buf += sprintf(buf, "Unused/mismatched CPLBs:\n"); - - for (entry = 0; entry < 16; ++entry) - if (0 == ((1 << entry) & used_cplb)) { - int flags = cplb_data[entry]; - buf += sprintf(buf, - "%2d: 0x%08lx\t0x%05x\t%s\t%c\t%c\n", - entry, cplb_addr[entry], flags, strpage(flags), - (flags & CPLB_VALID) ? 'Y' : 'N', - (flags & CPLB_LOCK) ? 'Y' : 'N'); - } +static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) +{ + if (cdata->cplb_type == 'I') { + cdata->mem_control = bfin_read_IMEM_CONTROL(); + cdata->pdt_tables = ipdt_tables[cpu]; + cdata->pdt_swapcount = ipdt_swapcount_tables[cpu]; + cdata->cplb_addr = ICPLB_ADDR0; + cdata->cplb_data = ICPLB_DATA0; + } else { + cdata->mem_control = bfin_read_DMEM_CONTROL(); + cdata->pdt_tables = dpdt_tables[cpu]; + cdata->pdt_swapcount = dpdt_swapcount_tables[cpu]; + cdata->cplb_addr = DCPLB_ADDR0; + cdata->cplb_data = DCPLB_DATA0; } +} - buf += sprintf(buf, "\n"); +#endif - return buf; +static void *cplbinfo_start(struct seq_file *m, loff_t *pos) +{ + struct cplbinfo_data *cdata = m->private; + + if (!*pos) { + seq_printf(m, "%cCPLBs are %sabled: 0x%x\n", cdata->cplb_type, + (cdata->mem_control & ENDCPLB ? "en" : "dis"), + cdata->mem_control); + cplbinfo_print_header(m); + } else if (cplbinfo_nomore(cdata)) + return NULL; + + get_cpu(); + return cdata; } -#endif +static void *cplbinfo_next(struct seq_file *m, void *p, loff_t *pos) +{ + struct cplbinfo_data *cdata = p; + cdata->pos = ++(*pos); + if (cplbinfo_nomore(cdata)) + return NULL; + else + return cdata; +} -static int cplbinfo_proc_output(char *buf, void *data) +static void cplbinfo_stop(struct seq_file *m, void *p) { - unsigned int cpu = (unsigned int)data; - char *p = buf; - - if (bfin_read_IMEM_CONTROL() & ENICPLB) { - p += sprintf(p, "Instruction CPLB entry:\n"); - p = cplb_print_entry(p, ICPLB, cpu); - } else - p += sprintf(p, "Instruction CPLB is disabled.\n\n"); - - if (bfin_read_DMEM_CONTROL() & ENDCPLB) { - p += sprintf(p, "Data CPLB entry:\n"); - p = cplb_print_entry(p, DCPLB, cpu); - } else - p += sprintf(p, "Data CPLB is disabled.\n\n"); - - return p - buf; + put_cpu(); } -static int cplbinfo_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static const struct seq_operations cplbinfo_sops = { + .start = cplbinfo_start, + .next = cplbinfo_next, + .stop = cplbinfo_stop, + .show = cplbinfo_show, +}; + +static int cplbinfo_open(struct inode *inode, struct file *file) { - int len = cplbinfo_proc_output(page, data); - if (len <= off + count) - *eof = 1; - *start = page + off; - len -= off; - return max(min(len, count), 0); + char buf[256], *path, *p; + unsigned int cpu; + char *s_cpu, *s_cplb; + int ret; + struct seq_file *m; + struct cplbinfo_data *cdata; + + path = d_path(&file->f_path, buf, sizeof(buf)); + if (IS_ERR(path)) + return PTR_ERR(path); + s_cpu = strstr(path, "/cpu"); + s_cplb = strrchr(path, '/'); + if (!s_cpu || !s_cplb) + return -EINVAL; + + cpu = simple_strtoul(s_cpu + 4, &p, 10); + if (!cpu_online(cpu)) + return -ENODEV; + + ret = seq_open_private(file, &cplbinfo_sops, sizeof(*cdata)); + if (ret) + return ret; + m = file->private_data; + cdata = m->private; + + cdata->pos = 0; + cdata->cplb_type = toupper(s_cplb[1]); + cplbinfo_seq_init(cdata, cpu); + + return 0; } +static const struct file_operations cplbinfo_fops = { + .open = cplbinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, +}; + static int __init cplbinfo_init(void) { - struct proc_dir_entry *parent, *entry; + struct proc_dir_entry *cplb_dir, *cpu_dir; + char buf[10]; unsigned int cpu; - unsigned char str[10]; - parent = proc_mkdir("cplbinfo", NULL); - if (!parent) + cplb_dir = proc_mkdir("cplbinfo", NULL); + if (!cplb_dir) return -ENOMEM; - for_each_online_cpu(cpu) { - sprintf(str, "cpu%u", cpu); - entry = create_proc_entry(str, 0, parent); - if (!entry) + for_each_possible_cpu(cpu) { + sprintf(buf, "cpu%i", cpu); + cpu_dir = proc_mkdir(buf, cplb_dir); + if (!cpu_dir) return -ENOMEM; - entry->read_proc = cplbinfo_read_proc; - entry->data = (void *)cpu; + proc_create("icplb", S_IRUGO, cpu_dir, &cplbinfo_fops); + proc_create("dcplb", S_IRUGO, cpu_dir, &cplbinfo_fops); } return 0; -- cgit v1.2.3 From dbdf20db537a5369c65330f878ad4905020a8bfa Mon Sep 17 00:00:00 2001 From: Bernd Schmidt Date: Wed, 7 Jan 2009 23:14:38 +0800 Subject: Blackfin arch: Faster C implementation of no-MPU CPLB handler This is a mixture ofcMichael McTernan's patch and the existing cplb-mpu code. We ditch the old cplb-nompu implementation, which is a good example of why a good algorithm in a HLL is preferrable to a bad algorithm written in assembly. Rather than try to construct a table of all posible CPLBs and search it, we just create a (smaller) table of memory regions and their attributes. Some of the data structures are now unified for both the mpu and nompu cases. A lot of needless complexity in cplbinit.c is removed. Further optimizations: * compile cplbmgr.c with a lot of -ffixed-reg options, and omit saving these registers on the stack when entering a CPLB exception. * lose cli/nop/nop/sti sequences for some workarounds - these don't * make sense in an exception context Additional code unification should be possible after this. [Mike Frysinger : - convert CPP if statements to C if statements - remove redundant statements - use a do...while loop rather than a for loop to get slightly better optimization and to avoid gcc "may be used uninitialized" warnings ... we know that the [id]cplb_nr_bounds variables will never be 0, so this is OK - the no-mpu code was the last user of MAX_MEM_SIZE and with that rewritten, we can punt it - add some BUG_ON() checks to make sure we dont overflow the small cplb_bounds array - add i/d cplb entries for the bootrom because there is functions/data in there we want to access - we do not need a NULL trailing entry as any time we access the bounds arrays, we use the nr_bounds variable ] Signed-off-by: Michael McTernan Signed-off-by: Mike Frysinger Signed-off-by: Bernd Schmidt Signed-off-by: Bryan Wu --- arch/blackfin/kernel/cplbinfo.c | 84 ----------------------------------------- 1 file changed, 84 deletions(-) (limited to 'arch/blackfin/kernel/cplbinfo.c') diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c index 1d3bbec1a19..64d78300dd0 100644 --- a/arch/blackfin/kernel/cplbinfo.c +++ b/arch/blackfin/kernel/cplbinfo.c @@ -20,8 +20,6 @@ static char const page_strtbl[][3] = { "1K", "4K", "1M", "4M" }; #define page(flags) (((flags) & 0x30000) >> 16) #define strpage(flags) page_strtbl[page(flags)] -#ifdef CONFIG_MPU - struct cplbinfo_data { loff_t pos; char cplb_type; @@ -75,88 +73,6 @@ static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) } } -#else - -struct cplbinfo_data { - loff_t pos; - char cplb_type; - u32 mem_control; - unsigned long *pdt_tables, *pdt_swapcount; - unsigned long cplb_addr, cplb_data; -}; - -extern int page_size_table[]; - -static int cplb_find_entry(unsigned long addr_tbl, unsigned long data_tbl, - unsigned long addr_find, unsigned long data_find) -{ - int i; - - for (i = 0; i < 16; ++i) { - unsigned long cplb_addr = bfin_read32(addr_tbl + i * 4); - unsigned long cplb_data = bfin_read32(data_tbl + i * 4); - if (addr_find >= cplb_addr && - addr_find < cplb_addr + page_size_table[page(cplb_data)] && - cplb_data == data_find) - return i; - } - - return -1; -} - -static void cplbinfo_print_header(struct seq_file *m) -{ - seq_printf(m, "Address\t\tData\tSize\tValid\tLocked\tSwapin\tiCount\toCount\n"); -} - -static int cplbinfo_nomore(struct cplbinfo_data *cdata) -{ - return cdata->pdt_tables[cdata->pos * 2] == 0xffffffff; -} - -static int cplbinfo_show(struct seq_file *m, void *p) -{ - struct cplbinfo_data *cdata; - unsigned long data, addr; - int entry; - loff_t pos; - - cdata = p; - pos = cdata->pos * 2; - addr = cdata->pdt_tables[pos]; - data = cdata->pdt_tables[pos + 1]; - entry = cplb_find_entry(cdata->cplb_addr, cdata->cplb_data, addr, data); - - seq_printf(m, - "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", - addr, data, strpage(data), - (data & CPLB_VALID) ? 'Y' : 'N', - (data & CPLB_LOCK) ? 'Y' : 'N', entry, - cdata->pdt_swapcount[pos], - cdata->pdt_swapcount[pos + 1]); - - return 0; -} - -static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) -{ - if (cdata->cplb_type == 'I') { - cdata->mem_control = bfin_read_IMEM_CONTROL(); - cdata->pdt_tables = ipdt_tables[cpu]; - cdata->pdt_swapcount = ipdt_swapcount_tables[cpu]; - cdata->cplb_addr = ICPLB_ADDR0; - cdata->cplb_data = ICPLB_DATA0; - } else { - cdata->mem_control = bfin_read_DMEM_CONTROL(); - cdata->pdt_tables = dpdt_tables[cpu]; - cdata->pdt_swapcount = dpdt_swapcount_tables[cpu]; - cdata->cplb_addr = DCPLB_ADDR0; - cdata->cplb_data = DCPLB_DATA0; - } -} - -#endif - static void *cplbinfo_start(struct seq_file *m, loff_t *pos) { struct cplbinfo_data *cdata = m->private; -- cgit v1.2.3