Commit 5fc4bcde authored by Linus Torvalds's avatar Linus Torvalds

v2.4.14.5 -> v2.4.14.6

  - Russell King: /proc/cpuinfo for ARM
  - Paul Mackerras: PPC update (cpuinfo etc)
  - Nicolas Aspert: fix Intel 8xx agptlb flush
  - Marko Myllynen: "Lindent" doesn't really need bash ;)
  - Alexander Viro: /proc/cpuinfo for s390/s390x/sh, /proc/pci cleanup
  - Alexander Viro: make lseek work on seqfiles
parent 2d46136d
......@@ -535,6 +535,12 @@ M: Remy.Card@linux.org
L: linux-kernel@vger.kernel.org
S: Maintained
EXT3 FILE SYSTEM
P: Remy Card, Stephen Tweedie
M: sct@redhat.com, akpm@zip.com.au, adilger@turbolinux.com
L: ext3-users@redhat.com
S: Maintained
FARSYNC SYNCHRONOUS DRIVER
P: Bob Dunlop
M: rjd@xyzzy.clara.co.uk
......@@ -1038,7 +1044,7 @@ S: Maintained
NETWORK DEVICE DRIVERS
P: Andrew Morton
M: andrewm@uow.edu.au
M: akpm@zip.com.au
P: Jeff Garzik
M: jgarzik@mandrakesoft.com
L: linux-net@vger.kernel.org
......
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 15
EXTRAVERSION =-pre5
EXTRAVERSION =-pre6
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
......
......@@ -1064,8 +1064,6 @@ show_cpuinfo(struct seq_file *f, void *slot)
char *sysvariation_name;
int nr_processors;
if (!cpu)
return 1;
cpu_index = (unsigned) (cpu->type - 1);
cpu_name = "Unknown";
if (cpu_index < N(cpu_names))
......
......@@ -186,8 +186,8 @@ validate_cc_value(unsigned long cc)
[EV4_CPU] = { 150000000, 300000000 },
[LCA4_CPU] = { 150000000, 300000000 }, /* guess */
[EV45_CPU] = { 200000000, 300000000 },
[EV5_CPU] = { 266000000, 333333333 },
[EV56_CPU] = { 366000000, 667000000 },
[EV5_CPU] = { 250000000, 433000000 },
[EV56_CPU] = { 333000000, 667000000 },
[PCA56_CPU] = { 400000000, 600000000 }, /* guess */
[PCA57_CPU] = { 500000000, 600000000 }, /* guess */
[EV6_CPU] = { 466000000, 600000000 },
......
/*
* linux/arch/arm/kernel/setup.c
*
* Copyright (C) 1995-2000 Russell King
* Copyright (C) 1995-2001 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
......@@ -16,6 +16,7 @@
#include <linux/blk.h>
#include <linux/console.h>
#include <linux/bootmem.h>
#include <linux/seq_file.h>
#include <linux/init.h>
#include <asm/elf.h>
......@@ -532,58 +533,53 @@ static const char *hwcap_str[] = {
NULL
};
/*
* get_cpuinfo - Get information on one CPU for use by the procfs.
*
* Prints info on the next CPU into buffer. Beware, doesn't check for
* buffer overflow. Current implementation of procfs assumes that the
* resulting data is <= 1K.
*
* Args:
* buffer -- you guessed it, the data buffer
* cpu_np -- Input: next cpu to get (start at 0). Output: Updated.
*
* Returns number of bytes written to buffer.
*/
int get_cpuinfo(char *buffer, unsigned *cpu_np)
static int c_show(struct seq_file *m, void *v)
{
char *p = buffer;
unsigned n;
int i;
/* No SMP at the moment, so just toggle 0/1 */
n = *cpu_np;
*cpu_np = 1;
if (n != 0) {
return (0);
}
p += sprintf(p, "Processor\t: %s %s rev %d (%s)\n",
proc_info.manufacturer, proc_info.cpu_name,
(int)processor_id & 15, elf_platform);
seq_printf(m, "Processor\t: %s %s rev %d (%s)\n",
proc_info.manufacturer, proc_info.cpu_name,
(int)processor_id & 15, elf_platform);
p += sprintf(p, "BogoMIPS\t: %lu.%02lu\n",
loops_per_jiffy / (500000/HZ),
(loops_per_jiffy / (5000/HZ)) % 100);
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
loops_per_jiffy / (500000/HZ),
(loops_per_jiffy / (5000/HZ)) % 100);
/* dump out the processor features */
p += sprintf(p, "Features\t: ");
seq_puts(m, "Features\t: ");
for (i = 0; hwcap_str[i]; i++)
if (elf_hwcap & (1 << i))
p += sprintf(p, "%s ", hwcap_str[i]);
seq_printf(m, "%s ", hwcap_str[i]);
seq_puts(m, "\n\n");
p += sprintf(p, "\n\n");
seq_printf(m, "Hardware\t: %s\n", machine_name);
seq_printf(m, "Revision\t: %04x\n", system_rev);
seq_printf(m, "Serial\t\t: %08x%08x\n",
system_serial_high, system_serial_low);
p += sprintf(p, "Hardware\t: %s\n", machine_name);
return 0;
}
p += sprintf(p, "Revision\t: %04x\n",
system_rev);
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos < 1 ? (void *)1 : NULL;
}
p += sprintf(p, "Serial\t\t: %08x%08x\n",
system_serial_high,
system_serial_low);
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
return NULL;
}
return p - buffer;
static void c_stop(struct seq_file *m, void *v)
{
}
struct seq_operations cpuinfo_op = {
start: c_start,
next: c_next,
stop: c_stop,
show: c_show
};
# BK Id: SCCS/s.config.in 1.43 10/16/01 15:18:50 trini
# BK Id: SCCS/s.config.in 1.45 11/08/01 07:57:40 paulus
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/config-language.txt.
......@@ -6,6 +6,7 @@
define_bool CONFIG_UID16 n
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
define_bool CONFIG_HAVE_DEC_LOCK y
mainmenu_name "Linux/PowerPC Kernel Configuration"
......
/*
* BK Id: SCCS/s.apus_setup.c 1.22 10/18/01 11:16:27 trini
* BK Id: SCCS/s.apus_setup.c 1.24 11/13/01 21:26:07 paulus
*/
/*
* linux/arch/ppc/kernel/apus_setup.c
......@@ -25,6 +25,7 @@
#include <linux/hdreg.h>
#include <linux/blk.h>
#include <linux/pci.h>
#include <linux/seq_file.h>
#ifdef CONFIG_APUS
#include <asm/logging.h>
......@@ -263,24 +264,20 @@ void __init apus_setup_arch(void)
}
int
apus_get_cpuinfo(char *buffer)
apus_show_cpuinfo(struct seq_file *m)
{
#ifdef CONFIG_APUS
extern int __map_without_bats;
extern unsigned long powerup_PCI_present;
int len;
len = sprintf(buffer, "machine\t\t: Amiga\n");
len += sprintf(buffer+len, "bus speed\t: %d%s", __bus_speed,
(__speed_test_failed) ? " [failed]\n" : "\n");
len += sprintf(buffer+len, "using BATs\t: %s\n",
(__map_without_bats) ? "No" : "Yes");
len += sprintf(buffer+len, "ram speed\t: %dns\n",
(__60nsram) ? 60 : 70);
len += sprintf(buffer+len, "PCI bridge\t: %s\n",
(powerup_PCI_present) ? "Yes" : "No");
return len;
#endif
seq_printf(m, "machine\t\t: Amiga\n");
seq_printf(m, "bus speed\t: %d%s", __bus_speed,
(__speed_test_failed) ? " [failed]\n" : "\n");
seq_printf(m, "using BATs\t: %s\n",
(__map_without_bats) ? "No" : "Yes");
seq_printf(m, "ram speed\t: %dns\n", (__60nsram) ? 60 : 70);
seq_printf(m, "PCI bridge\t: %s\n",
(powerup_PCI_present) ? "Yes" : "No");
return 0;
}
static void get_current_tb(unsigned long long *time)
......@@ -1069,8 +1066,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
ISA_DMA_THRESHOLD = 0x00ffffff;
ppc_md.setup_arch = apus_setup_arch;
ppc_md.setup_residual = NULL;
ppc_md.get_cpuinfo = apus_get_cpuinfo;
ppc_md.show_cpuinfo = apus_show_cpuinfo;
ppc_md.irq_cannonicalize = apus_irq_cannonicalize;
ppc_md.init_IRQ = apus_init_IRQ;
ppc_md.get_irq = apus_get_irq;
......
/*
* BK Id: SCCS/s.chrp_setup.c 1.36 09/08/01 15:47:42 paulus
* BK Id: SCCS/s.chrp_setup.c 1.38 11/13/01 21:26:07 paulus
*/
/*
* linux/arch/ppc/kernel/setup.c
......@@ -38,6 +38,7 @@
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/seq_file.h>
#include <asm/mmu.h>
#include <asm/processor.h>
......@@ -81,6 +82,7 @@ extern void pckbd_leds(unsigned char leds);
extern void pckbd_init_hw(void);
extern unsigned char pckbd_sysrq_xlate[128];
extern void select_adb_keyboard(void);
extern int of_show_percpuinfo(struct seq_file *, int);
extern kdev_t boot_dev;
......@@ -110,9 +112,9 @@ static const char *gg2_cachemodes[4] = {
};
int __chrp
chrp_get_cpuinfo(char *buffer)
chrp_show_cpuinfo(struct seq_file *m)
{
int i, len, sdramen;
int i, sdramen;
unsigned int t;
struct device_node *root;
const char *model = "";
......@@ -120,11 +122,10 @@ chrp_get_cpuinfo(char *buffer)
root = find_path_device("/");
if (root)
model = get_property(root, "model", NULL);
len = sprintf(buffer,"machine\t\t: CHRP %s\n", model);
seq_printf(m, "machine\t\t: CHRP %s\n", model);
/* longtrail (goldengate) stuff */
if ( !strncmp( model, "IBM,LongTrail", 13 ) )
{
if (!strncmp(model, "IBM,LongTrail", 13)) {
/* VLSI VAS96011/12 `Golden Gate 2' */
/* Memory banks */
sdramen = (in_le32((unsigned *)(GG2_PCI_CONFIG_BASE+
......@@ -159,17 +160,17 @@ chrp_get_cpuinfo(char *buffer)
model = "Reserved";
break;
}
len += sprintf(buffer+len, "memory bank %d\t: %s %s\n", i, model,
gg2_memtypes[sdramen ? 1 : ((t>>1) & 3)]);
seq_printf(m, "memory bank %d\t: %s %s\n", i, model,
gg2_memtypes[sdramen ? 1 : ((t>>1) & 3)]);
}
/* L2 cache */
t = in_le32((unsigned *)(GG2_PCI_CONFIG_BASE+GG2_PCI_CC_CTRL));
len += sprintf(buffer+len, "board l2\t: %s %s (%s)\n",
gg2_cachesizes[(t>>7) & 3],
gg2_cachetypes[(t>>2) & 3],
gg2_cachemodes[t & 3]);
seq_printf(m, "board l2\t: %s %s (%s)\n",
gg2_cachesizes[(t>>7) & 3],
gg2_cachetypes[(t>>2) & 3],
gg2_cachemodes[t & 3]);
}
return len;
return 0;
}
/*
......@@ -341,13 +342,8 @@ u_int __chrp
chrp_irq_cannonicalize(u_int irq)
{
if (irq == 2)
{
return 9;
}
else
{
return irq;
}
return irq;
}
void __init chrp_init_IRQ(void)
......@@ -513,8 +509,8 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
isa_io_base = CHRP_ISA_IO_BASE; /* default value */
ppc_md.setup_arch = chrp_setup_arch;
ppc_md.setup_residual = NULL;
ppc_md.get_cpuinfo = chrp_get_cpuinfo;
ppc_md.show_percpuinfo = of_show_percpuinfo;
ppc_md.show_cpuinfo = chrp_show_cpuinfo;
ppc_md.irq_cannonicalize = chrp_irq_cannonicalize;
#ifndef CONFIG_POWER4
ppc_md.init_IRQ = chrp_init_IRQ;
......
......@@ -24,6 +24,7 @@
#include <linux/major.h>
#include <linux/blk.h>
#include <linux/console.h>
#include <linux/seq_file.h>
#include <asm/system.h>
#include <asm/pgtable.h>
......@@ -82,9 +83,8 @@ prom_init(void)
}
int
gemini_get_cpuinfo(char *buffer)
gemini_show_cpuinfo(struct seq_file *m)
{
int len;
unsigned char reg, rev;
char *family;
unsigned int type;
......@@ -100,22 +100,20 @@ gemini_get_cpuinfo(char *buffer)
reg = readb(GEMINI_BECO);
len = sprintf( buffer, "machine\t\t: Gemini %s%d, rev %c, eco %d\n",
family, type, (rev + 'A'), (reg & 0xf));
seq_printf(m, "machine\t\t: Gemini %s%d, rev %c, eco %d\n",
family, type, (rev + 'A'), (reg & 0xf));
len = sprintf(buffer, "board\t\t: Gemini %s", family);
seq_printf(m, "board\t\t: Gemini %s", family);
if (type > 9)
len += sprintf(buffer+len, "%c", (type - 10) + 'A');
seq_printf(m, "%c", (type - 10) + 'A');
else
len += sprintf(buffer+len, "%d", type);
seq_printf(m, "%d", type);
len += sprintf(buffer+len, ", rev %c, eco %d\n",
(rev + 'A'), (reg & 0xf));
seq_printf(m, ", rev %c, eco %d\n", (rev + 'A'), (reg & 0xf));
len += sprintf(buffer+len, "clock\t\t: %dMhz\n",
gemini_get_clock_speed());
seq_printf(m, "clock\t\t: %dMhz\n", gemini_get_clock_speed());
return len;
return 0;
}
static u_char gemini_openpic_initsenses[] = {
......@@ -150,11 +148,12 @@ extern char cmd_line[];
void
gemini_heartbeat(void)
{
/* We only want to do this on 1 CPU */
if ( smp_processor_id() )
return;
static unsigned long led = GEMINI_LEDBASE+(4*8);
static char direction = 8;
/* We only want to do this on 1 CPU */
if (smp_processor_id())
return;
*(char *)led = 0;
if ( (led + direction) > (GEMINI_LEDBASE+(7*8)) ||
(led + direction) < (GEMINI_LEDBASE+(4*8)) )
......@@ -551,8 +550,7 @@ void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
#endif
ppc_md.setup_arch = gemini_setup_arch;
ppc_md.setup_residual = NULL;
ppc_md.get_cpuinfo = gemini_get_cpuinfo;
ppc_md.show_cpuinfo = gemini_show_cpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = gemini_init_IRQ;
ppc_md.get_irq = openpic_get_irq;
......
/*
* BK Id: SCCS/s.m8260_setup.c 1.28 10/18/01 11:16:28 trini
* BK Id: SCCS/s.m8260_setup.c 1.30 11/13/01 21:26:07 paulus
*/
/*
* linux/arch/ppc/kernel/setup.c
......@@ -34,6 +34,7 @@
#include <linux/blk.h>
#include <linux/ioport.h>
#include <linux/ide.h>
#include <linux/seq_file.h>
#include <asm/mmu.h>
#include <asm/processor.h>
......@@ -144,21 +145,20 @@ m8260_halt(void)
static int
m8260_setup_residual(char *buffer)
m8260_show_percpuinfo(struct seq_file *m, int i)
{
int len = 0;
bd_t *bp;
bp = (bd_t *)__res;
len += sprintf(len+buffer,"core clock\t: %d MHz\n"
"CPM clock\t: %d MHz\n"
"bus clock\t: %d MHz\n",
bp->bi_intfreq / 1000000,
bp->bi_cpmfreq / 1000000,
bp->bi_busfreq / 1000000);
return len;
seq_printf(m, "core clock\t: %d MHz\n"
"CPM clock\t: %d MHz\n"
"bus clock\t: %d MHz\n",
bp->bi_intfreq / 1000000,
bp->bi_cpmfreq / 1000000,
bp->bi_busfreq / 1000000);
return 0;
}
/* Initialize the internal interrupt controller. The number of
......@@ -240,8 +240,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
}
ppc_md.setup_arch = m8260_setup_arch;
ppc_md.setup_residual = m8260_setup_residual;
ppc_md.get_cpuinfo = NULL;
ppc_md.show_percpuinfo = m8260_show_percpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = m8260_init_IRQ;
ppc_md.get_irq = m8260_get_irq;
......
/*
* BK Id: SCCS/s.m8xx_setup.c 1.38 10/18/01 11:16:28 trini
* BK Id: SCCS/s.m8xx_setup.c 1.40 11/13/01 21:26:07 paulus
*
* linux/arch/ppc/kernel/setup.c
*
......@@ -33,6 +33,7 @@
#include <linux/blk.h>
#include <linux/ioport.h>
#include <linux/bootmem.h>
#include <linux/seq_file.h>
#include <asm/mmu.h>
#include <asm/processor.h>
......@@ -240,19 +241,18 @@ m8xx_halt(void)
static int
m8xx_setup_residual(char *buffer)
m8xx_show_percpuinfo(struct seq_file *m, int i)
{
int len = 0;
bd_t *bp;
bp = (bd_t *)__res;
len += sprintf(len+buffer,"clock\t\t: %ldMHz\n"
"bus clock\t: %ldMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
seq_printf(m, "clock\t\t: %ldMHz\n"
"bus clock\t: %ldMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
return len;
return 0;
}
/* Initialize the internal interrupt controller. The number of
......@@ -372,8 +372,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
}
ppc_md.setup_arch = m8xx_setup_arch;
ppc_md.setup_residual = m8xx_setup_residual;
ppc_md.get_cpuinfo = NULL;
ppc_md.show_percpuinfo = m8xx_show_percpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = m8xx_init_IRQ;
ppc_md.get_irq = m8xx_get_irq;
......
/*
* BK Id: SCCS/s.oak_setup.c 1.10 10/18/01 11:16:28 trini
* BK Id: SCCS/s.oak_setup.c 1.12 11/13/01 21:26:07 paulus
*/
/*
*
......@@ -23,6 +23,7 @@
#include <linux/param.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <linux/seq_file.h>
#include <asm/processor.h>
#include <asm/board.h>
......@@ -106,8 +107,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
/* Initialize machine-dependency vectors */
ppc_md.setup_arch = oak_setup_arch;
ppc_md.setup_residual = oak_setup_residual;
ppc_md.get_cpuinfo = NULL;
ppc_md.show_percpuinfo = oak_show_percpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = oak_init_IRQ;
ppc_md.get_irq = oak_get_irq;
......@@ -141,7 +141,7 @@ oak_setup_arch(void)
}
/*
* int oak_setup_residual()
* int oak_show_percpuinfo()
*
* Description:
* This routine pretty-prints the platform's internal CPU and bus clock
......@@ -159,18 +159,16 @@ oak_setup_arch(void)
* on error.
*/
int
oak_setup_residual(char *buffer)
oak_show_percpuinfo(struct seq_file *m, int i)
{
int len = 0;
bd_t *bp = (bd_t *)__res;
len += sprintf(len + buffer,
"clock\t\t: %dMHz\n"
"bus clock\t\t: %dMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
seq_printf(m, "clock\t\t: %dMHz\n"
"bus clock\t\t: %dMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
return (len);
return 0;
}
/*
......
/*
* BK Id: SCCS/s.pci.c 1.31 11/01/01 12:24:55 trini
* BK Id: SCCS/s.pci.c 1.35 11/13/01 08:19:57 trini
*/
/*
* Common pmac/prep/chrp pci routines. -- Cort
......@@ -44,6 +44,7 @@ void pcibios_make_OF_bus_map(void);
static void pcibios_fixup_resources(struct pci_dev* dev);
static void fixup_broken_pcnet32(struct pci_dev* dev);
static void fixup_rev1_53c810(struct pci_dev* dev);
#ifdef CONFIG_ALL_PPC
static void pcibios_fixup_cardbus(struct pci_dev* dev);
static u8* pci_to_OF_bus_map;
......@@ -60,15 +61,29 @@ struct pci_controller** hose_tail = &hose_head;
static int pci_bus_count;
struct pci_fixup pcibios_fixups[] = {
{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32 },
{ PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources },
{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32 },
{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810 },
{ PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources },
#ifdef CONFIG_ALL_PPC
/* We should add per-machine fixup support in xxx_setup.c or xxx_pci.c */
{ PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, pcibios_fixup_cardbus },
{ PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, pcibios_fixup_cardbus },
#endif /* CONFIG_ALL_PPC */
{ 0 }
};
static void
fixup_rev1_53c810(struct pci_dev* dev)
{
/* rev 1 ncr53c810 chips don't set the class at all which means
* they don't get their resources remapped. Fix that here.
*/
if ((dev->class == PCI_CLASS_NOT_DEFINED)) {
printk("NCR 53c810 rev 1 detected, setting PCI class.\n");
dev->class = PCI_CLASS_STORAGE_SCSI;
}
}
static void
fixup_broken_pcnet32(struct pci_dev* dev)
{
......
/*
* BK Id: SCCS/s.pmac_setup.c 1.41 10/18/01 11:16:28 trini
* BK Id: SCCS/s.pmac_setup.c 1.43 11/13/01 21:26:07 paulus
*/
/*
* linux/arch/ppc/kernel/setup.c
......@@ -49,6 +49,7 @@
#include <linux/adb.h>
#include <linux/cuda.h>
#include <linux/pmu.h>
#include <linux/seq_file.h>
#include <asm/processor.h>
#include <asm/sections.h>
......@@ -157,36 +158,56 @@ core99_init_l2(void)
}
#endif /* CONFIG_SMP */
/*
* Assume here that all clock rates are the same in a
* smp system. -- Cort
*/
int __openfirmware
of_show_percpuinfo(struct seq_file *m, int i)
{
struct device_node *cpu_node;
int *fp, s;
cpu_node = find_type_devices("cpu");
if (!cpu_node)
return 0;
for (s = 0; s < i && cpu_node->next; s++)
cpu_node = cpu_node->next;
fp = (int *) get_property(cpu_node, "clock-frequency", NULL);
if (fp)
seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000);
return 0;
}
int __pmac
pmac_get_cpuinfo(char *buffer)
pmac_show_cpuinfo(struct seq_file *m)
{
int len;
struct device_node *np;
char *pp;
int plen;
/* find motherboard type */
len = sprintf(buffer, "machine\t\t: ");
seq_printf(m, "machine\t\t: ");
np = find_devices("device-tree");
if (np != NULL) {
pp = (char *) get_property(np, "model", NULL);
if (pp != NULL)
len += sprintf(buffer+len, "%s\n", pp);
seq_printf(m, "%s\n", pp);
else
len += sprintf(buffer+len, "PowerMac\n");
seq_printf(m, "PowerMac\n");
pp = (char *) get_property(np, "compatible", &plen);
if (pp != NULL) {
len += sprintf(buffer+len, "motherboard\t:");
seq_printf(m, "motherboard\t:");
while (plen > 0) {
int l = strlen(pp) + 1;
len += sprintf(buffer+len, " %s", pp);
seq_printf(m, " %s", pp);
plen -= l;
pp += l;
}
buffer[len++] = '\n';
seq_printf(m, "\n");
}
} else
len += sprintf(buffer+len, "PowerMac\n");
seq_printf(m, "PowerMac\n");
/* find l2 cache info */
np = find_devices("l2-cache");
......@@ -197,22 +218,21 @@ pmac_get_cpuinfo(char *buffer)
get_property(np, "i-cache-size", NULL);
unsigned int *dc = (unsigned int *)
get_property(np, "d-cache-size", NULL);
len += sprintf(buffer+len, "L2 cache\t:");
seq_printf(m, "L2 cache\t:");
has_l2cache = 1;
if (get_property(np, "cache-unified", NULL) != 0 && dc) {
len += sprintf(buffer+len, " %dK unified", *dc / 1024);
seq_printf(m, " %dK unified", *dc / 1024);
} else {
if (ic)
len += sprintf(buffer+len, " %dK instruction",
*ic / 1024);
seq_printf(m, " %dK instruction", *ic / 1024);
if (dc)
len += sprintf(buffer+len, "%s %dK data",
(ic? " +": ""), *dc / 1024);
seq_printf(m, "%s %dK data",
(ic? " +": ""), *dc / 1024);
}
pp = get_property(np, "ram-type", NULL);
if (pp)
len += sprintf(buffer+len, " %s", pp);
buffer[len++] = '\n';
seq_printf(m, " %s", pp);
seq_printf(m, "\n");
}
/* find ram info */
......@@ -227,8 +247,7 @@ pmac_get_cpuinfo(char *buffer)
for (n /= sizeof(struct reg_property); n > 0; --n)
total += (reg++)->size;
len += sprintf(buffer+len, "memory\t\t: %luMB\n",
total >> 20);
seq_printf(m, "memory\t\t: %luMB\n", total >> 20);
}
}
......@@ -240,16 +259,16 @@ pmac_get_cpuinfo(char *buffer)
unsigned int *l2cr = (unsigned int *)
get_property(np, "l2cr-value", NULL);
if (l2cr != 0) {
len += sprintf(buffer+len, "l2cr override\t: 0x%x\n", *l2cr);
seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr);
}
}
/* Indicate newworld/oldworld */
len += sprintf(buffer+len, "pmac-generation\t: %s\n",
pmac_newworld ? "NewWorld" : "OldWorld");
seq_printf(m, "pmac-generation\t: %s\n",
pmac_newworld ? "NewWorld" : "OldWorld");
return len;
return 0;
}
#ifdef CONFIG_SCSI
......@@ -765,8 +784,8 @@ pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
DMA_MODE_WRITE = 2;
ppc_md.setup_arch = pmac_setup_arch;
ppc_md.setup_residual = NULL;
ppc_md.get_cpuinfo = pmac_get_cpuinfo;
ppc_md.show_cpuinfo = pmac_show_cpuinfo;
ppc_md.show_percpuinfo = of_show_percpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = pmac_pic_init;
ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */
......
/*
* BK Id: SCCS/s.ppc_ksyms.c 1.57 10/16/01 15:58:42 trini
* BK Id: SCCS/s.ppc_ksyms.c 1.59 11/04/01 22:58:20 paulus
*/
#include <linux/config.h>
#include <linux/module.h>
......@@ -58,6 +58,7 @@
/* Tell string.h we don't want memcpy etc. as cpp defines */
#define EXPORT_SYMTAB_STROPS
extern void ppc_generic_ide_fix_driveid(struct hd_driveid *id);
extern void transfer_to_handler(void);
extern void syscall_trace(void);
extern void do_IRQ(struct pt_regs *regs);
......@@ -167,6 +168,7 @@ EXPORT_SYMBOL(iopa);
EXPORT_SYMBOL(mm_ptov);
EXPORT_SYMBOL(ppc_ide_md);
EXPORT_SYMBOL(ppc_generic_ide_fix_driveid);
#ifdef CONFIG_PCI
EXPORT_SYMBOL_NOVERS(isa_io_base);
......
/*
* BK Id: SCCS/s.prep_setup.c 1.41 10/18/01 11:16:28 trini
* BK Id: SCCS/s.prep_setup.c 1.44 11/13/01 21:26:07 paulus
*/
/*
* linux/arch/ppc/kernel/setup.c
......@@ -40,6 +40,7 @@
#include <linux/timex.h>
#include <linux/pci.h>
#include <linux/ide.h>
#include <linux/seq_file.h>
#include <asm/sections.h>
#include <asm/mmu.h>
......@@ -122,107 +123,107 @@ EXPORT_SYMBOL(ppc_cs4232_dma2);
#endif
static int __prep
prep_get_cpuinfo(char *buffer)
prep_show_cpuinfo(struct seq_file *m)
{
extern char *Motherboard_map_name;
int len;
int cachew;
#ifdef CONFIG_PREP_RESIDUAL
int i;
#endif
#ifdef CONFIG_SMP
#define CD(X) (cpu_data[n].X)
#else
#define CD(X) (X)
#endif
seq_printf(m, "machine\t\t: PReP %s\n", Motherboard_map_name);
len = sprintf(buffer,"machine\t\t: PReP %s\n",Motherboard_map_name);
switch ( _prep_type )
{
switch ( _prep_type ) {
case _PREP_IBM:
if ((*(unsigned char *)0x8000080c) & (1<<6))
len += sprintf(buffer+len,"Upgrade CPU\n");
len += sprintf(buffer+len,"L2\t\t: ");
if ((*(unsigned char *)0x8000080c) & (1<<7))
{
len += sprintf(buffer+len,"not present\n");
cachew = inw(0x80c);
if (cachew & (1<<6))
seq_printf(m, "Upgrade CPU\n");
seq_printf(m, "L2\t\t: ");
if (cachew & (1<<7)) {
seq_printf(m, "not present\n");
goto no_l2;
}
len += sprintf(buffer+len,"%sKb,",
(((*(unsigned char *)0x8000080d)>>2)&1)
? "512" : "256");
len += sprintf(buffer+len,"%ssync\n",
((*(unsigned char *)0x8000080d)>>7) ? "" : "a");
seq_printf(m, "%sKb,", (cachew & (1 << 10))? "512" : "256");
seq_printf(m, "%ssync\n", (cachew & (1 << 15))? "" : "a");
break;
case _PREP_Motorola:
len += sprintf(buffer+len,"L2\t\t: ");
switch(*((unsigned char *)CACHECRBA) & L2CACHE_MASK)
{
cachew = *((unsigned char *)CACHECRBA);
seq_printf(m, "L2\t\t: ");
switch (cachew & L2CACHE_MASK) {
case L2CACHE_512KB:
len += sprintf(buffer+len,"512Kb");
seq_printf(m, "512Kb");
break;
case L2CACHE_256KB:
len += sprintf(buffer+len,"256Kb");
seq_printf(m, "256Kb");
break;
case L2CACHE_1MB:
len += sprintf(buffer+len,"1MB");
seq_printf(m, "1MB");
break;
case L2CACHE_NONE:
len += sprintf(buffer+len,"none\n");
seq_printf(m, "none\n");
goto no_l2;
break;
default:
len += sprintf(buffer+len, "%x\n",
*((unsigned char *)CACHECRBA));
seq_printf(m, "%x\n", cachew);
}
len += sprintf(buffer+len,",parity %s",
(*((unsigned char *)CACHECRBA) & L2CACHE_PARITY)
? "enabled" : "disabled");
seq_printf(m, ", parity %s",
(cachew & L2CACHE_PARITY)? "enabled" : "disabled");
len += sprintf(buffer+len, " SRAM:");
seq_printf(m, " SRAM:");
switch ( ((*((unsigned char *)CACHECRBA) & 0xf0) >> 4) & ~(0x3) )
{
case 1: len += sprintf(buffer+len,
"synchronous,parity,flow-through\n");
switch ( ((cachew & 0xf0) >> 4) & ~(0x3) ) {
case 1: seq_printf(m, "synchronous,parity,flow-through\n");
break;
case 2: len += sprintf(buffer+len,"asynchronous,no parity\n");
case 2: seq_printf(m, "asynchronous,no parity\n");
break;
case 3: len += sprintf(buffer+len,"asynchronous,parity\n");
case 3: seq_printf(m, "asynchronous,parity\n");
break;
default:len += sprintf(buffer+len,
"synchronous,pipelined,no parity\n");
default:seq_printf(m, "synchronous,pipelined,no parity\n");
break;
}
break;
default:
break;
}
no_l2:
#ifndef CONFIG_PREP_RESIDUAL
return len;
#else
if ( res->ResidualLength == 0 )
return len;
/* print info about SIMMs */
len += sprintf(buffer+len,"simms\t\t: ");
for ( i = 0 ; (res->ActualNumMemories) && (i < MAX_MEMS) ; i++ )
{
if ( res->Memories[i].SIMMSize != 0 )
len += sprintf(buffer+len,"%d:%ldM ", i,
#ifdef CONFIG_PREP_RESIDUAL
if (res->ResidualLength == 0) {
/* print info about SIMMs */
seq_printf(m, "simms\t\t: ");
for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
if (res->Memories[i].SIMMSize != 0)
seq_printf(m, "%d:%ldM ", i,
(res->Memories[i].SIMMSize > 1024) ?
res->Memories[i].SIMMSize>>20 :
res->Memories[i].SIMMSize);
}
seq_printf(m, "\n");
}
len += sprintf(buffer+len,"\n");
return len;
#endif
return 0;
}
static int __prep
prep_show_percpuinfo(struct seq_file *m, int i)
{
int len = 0;
/* PREP's without residual data will give incorrect values here */
seq_printf(m, "clock\t\t: ");
#ifdef CONFIG_PREP_RESIDUAL
if (res->ResidualLength)
seq_printf(m, "%ldMHz\n",
(res->VitalProductData.ProcessorHz > 1024) ?
res->VitalProductData.ProcessorHz>>20 :
res->VitalProductData.ProcessorHz);
else
#endif /* CONFIG_PREP_RESIDUAL */
seq_printf(m, "???\n");
return 0;
}
static void __init
......@@ -628,26 +629,6 @@ prep_power_off(void)
}
}
static int __prep
prep_setup_residual(char *buffer)
{
int len = 0;
/* PREP's without residual data will give incorrect values here */
len += sprintf(len+buffer, "clock\t\t: ");
#ifdef CONFIG_PREP_RESIDUAL
if ( res->ResidualLength )
len += sprintf(len+buffer, "%ldMHz\n",
(res->VitalProductData.ProcessorHz > 1024) ?
res->VitalProductData.ProcessorHz>>20 :
res->VitalProductData.ProcessorHz);
else
#endif /* CONFIG_PREP_RESIDUAL */
len += sprintf(len+buffer, "???\n");
return len;
}
static unsigned int __prep
prep_irq_cannonicalize(u_int irq)
{
......@@ -852,11 +833,8 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7)
{
#ifdef CONFIG_PREP_RESIDUAL
RESIDUAL *old_res = (RESIDUAL *)(r3 + KERNELBASE);
/* make a copy of residual data */
if ( r3 )
{
if ( r3 ) {
memcpy((void *)res,(void *)(r3+KERNELBASE),
sizeof(RESIDUAL));
}
......@@ -900,8 +878,8 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5,
}
ppc_md.setup_arch = prep_setup_arch;
ppc_md.setup_residual = prep_setup_residual;
ppc_md.get_cpuinfo = prep_get_cpuinfo;
ppc_md.show_percpuinfo = prep_show_percpuinfo;
ppc_md.show_cpuinfo = prep_show_cpuinfo;
ppc_md.irq_cannonicalize = prep_irq_cannonicalize;
ppc_md.init_IRQ = prep_init_IRQ;
/* this gets changed later on if we have an OpenPIC -- Cort */
......
/*
* BK Id: SCCS/s.setup.c 1.61 10/12/01 16:35:34 trini
* BK Id: SCCS/s.setup.c 1.63 11/13/01 21:26:07 paulus
*/
/*
* Common prep/pmac/chrp boot and setup code.
......@@ -16,6 +16,7 @@
#include <linux/ide.h>
#include <linux/tty.h>
#include <linux/bootmem.h>
#include <linux/seq_file.h>
#include <asm/residual.h>
#include <asm/io.h>
......@@ -136,150 +137,128 @@ extern u32 cpu_temp(unsigned long cpu);
extern u32 cpu_temp_both(unsigned long cpu);
#endif /* CONFIG_TAU */
int get_cpuinfo(char *buffer)
int show_cpuinfo(struct seq_file *m, void *v)
{
unsigned long len = 0;
unsigned long bogosum = 0;
unsigned long i;
int i = (int) v - 1;
int err = 0;
unsigned int pvr;
unsigned short maj, min;
unsigned long lpj;
if (i >= NR_CPUS) {
/* Show summary information */
#ifdef CONFIG_SMP
#define CPU_PRESENT(x) (cpu_callin_map[(x)])
#define GET_PVR ((long int)(cpu_data[i].pvr))
#define CD(x) (cpu_data[i].x)
unsigned long bogosum = 0;
for (i = 0; i < smp_num_cpus; ++i)
if (cpu_online_map & (1 << i))
bogosum += cpu_data[i].loops_per_jiffy;
seq_printf(m, "total bogomips\t: %lu.%02lu\n",
bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
#endif /* CONFIG_SMP */
if (ppc_md.show_cpuinfo != NULL)
err = ppc_md.show_cpuinfo(m);
return err;
}
#ifdef CONFIG_SMP
if (!(cpu_online_map & (1 << i)))
return 0;
pvr = cpu_data[i].pvr;
lpj = cpu_data[i].loops_per_jiffy;
seq_printf(m, "processor\t: %lu\n", i);
#else
#define CPU_PRESENT(x) ((x)==0)
#define smp_num_cpus 1
#define GET_PVR (mfspr(PVR))
#define CD(x) (x)
#endif
pvr = mfspr(PVR);
lpj = loops_per_jiffy;
#endif
for ( i = 0; i < smp_num_cpus ; i++ )
{
if ( !CPU_PRESENT(i) )
continue;
if ( i )
len += sprintf(len+buffer,"\n");
len += sprintf(len+buffer,"processor\t: %lu\n",i);
len += sprintf(len+buffer,"cpu\t\t: ");
pvr = GET_PVR;
if (cur_cpu_spec[i]->pvr_mask)
len += sprintf(len+buffer, "%s", cur_cpu_spec[i]->cpu_name);
else
len += sprintf(len+buffer, "unknown (%08x)", pvr);
seq_printf(m, "cpu\t\t: ");
if (cur_cpu_spec[i]->pvr_mask)
seq_printf(m, "%s", cur_cpu_spec[i]->cpu_name);
else
seq_printf(m, "unknown (%08x)", pvr);
#ifdef CONFIG_ALTIVEC
if (cur_cpu_spec[i]->cpu_features & CPU_FTR_ALTIVEC)
len += sprintf(len+buffer, ", altivec supported");
#endif
len += sprintf(len+buffer, "\n");
if (cur_cpu_spec[i]->cpu_features & CPU_FTR_ALTIVEC)
seq_printf(m, ", altivec supported");
#endif
seq_printf(m, "\n");
#ifdef CONFIG_TAU
if (cur_cpu_spec[i]->cpu_features & CPU_FTR_TAU) {
#ifdef CONFIG_TAU_AVERAGE /* more straightforward, but potentially misleading */
len += sprintf(len+buffer, "temperature \t: %u C (uncalibrated)\n",
cpu_temp(i));
if (cur_cpu_spec[i]->cpu_features & CPU_FTR_TAU) {
#ifdef CONFIG_TAU_AVERAGE
/* more straightforward, but potentially misleading */
seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
cpu_temp(i));
#else
/* show the actual temp sensor range */
u32 temp;
temp = cpu_temp_both(i);
len += sprintf(len+buffer, "temperature \t: %u-%u C (uncalibrated)\n",
temp & 0xff, temp >> 16);
#endif
}
/* show the actual temp sensor range */
u32 temp;
temp = cpu_temp_both(i);
seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
temp & 0xff, temp >> 16);
#endif
}
#endif /* CONFIG_TAU */
/*
* Assume here that all clock rates are the same in a
* smp system. -- Cort
*/
#if defined(CONFIG_ALL_PPC)
if ( have_of )
{
struct device_node *cpu_node;
int *fp;
cpu_node = find_type_devices("cpu");
if ( !cpu_node ) break;
{
int s;
for ( s = 0; (s < i) && cpu_node->next ;
s++, cpu_node = cpu_node->next )
/* nothing */ ;
#if 0 /* SMP Pmacs don't have all cpu nodes -- Cort */
if ( s != i )
printk("get_cpuinfo(): ran out of "
"cpu nodes.\n");
#endif
}
fp = (int *) get_property(cpu_node, "clock-frequency", NULL);
if ( !fp ) break;
len += sprintf(len+buffer, "clock\t\t: %dMHz\n",
*fp / 1000000);
}
#endif /* CONFIG_ALL_PPC */
if (ppc_md.show_percpuinfo != NULL) {
err = ppc_md.show_percpuinfo(m, i);
if (err)
return err;
}
if (ppc_md.setup_residual != NULL)
{
len += ppc_md.setup_residual(buffer + len);
}
switch (PVR_VER(pvr))
{
case 0x0020:
maj = PVR_MAJ(pvr) + 1;
min = PVR_MIN(pvr);
break;
case 0x1008:
maj = ((pvr >> 8) & 0xFF) - 1;
min = pvr & 0xFF;
break;
default:
maj = (pvr >> 8) & 0xFF;
min = pvr & 0xFF;
break;
}
switch (PVR_VER(pvr)) {
case 0x0020: /* 403 family */
maj = PVR_MAJ(pvr) + 1;
min = PVR_MIN(pvr);
break;
case 0x1008: /* 740P/750P ?? */
maj = ((pvr >> 8) & 0xFF) - 1;
min = pvr & 0xFF;
break;
default:
maj = (pvr >> 8) & 0xFF;
min = pvr & 0xFF;
break;
}
len += sprintf(len+buffer, "revision\t: %hd.%hd (pvr %04x %04x)\n",
maj, min, PVR_VER(pvr), PVR_REV(pvr));
seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
maj, min, PVR_VER(pvr), PVR_REV(pvr));
len += sprintf(buffer+len, "bogomips\t: %lu.%02lu\n",
CD(loops_per_jiffy)/(500000/HZ),
CD(loops_per_jiffy)/(5000/HZ) % 100);
bogosum += CD(loops_per_jiffy);
}
seq_printf(m, "bogomips\t: %lu.%02lu\n",
lpj / (500000/HZ), (lpj / (5000/HZ)) % 100);
#ifdef CONFIG_SMP
if ( i && smp_num_cpus > 1)
len += sprintf(buffer+len, "\n");
len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n",
bogosum/(500000/HZ),
bogosum/(5000/HZ) % 100);
#endif /* CONFIG_SMP */
seq_printf(m, "\n");
#endif
/*
* Ooh's and aah's info about zero'd pages in idle task
*/
len += sprintf(buffer+len,"zero pages\t: total: %u (%luKb) "
"current: %u (%luKb) hits: %u/%u (%u%%)\n",
atomic_read(&zero_cache_total),
(atomic_read(&zero_cache_total)*PAGE_SIZE)>>10,
atomic_read(&zero_cache_sz),
(atomic_read(&zero_cache_sz)*PAGE_SIZE)>>10,
atomic_read(&zero_cache_hits),atomic_read(&zero_cache_calls),
/* : 1 below is so we don't div by zero */
(atomic_read(&zero_cache_hits)*100) /
((atomic_read(&zero_cache_calls))?atomic_read(&zero_cache_calls):1));
if (ppc_md.get_cpuinfo != NULL)
{
len += ppc_md.get_cpuinfo(buffer+len);
}
return 0;
}
static void *c_start(struct seq_file *m, loff_t *pos)
{
int i = *pos;
return len;
return i <= NR_CPUS? (void *) (i + 1): NULL;
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
return c_start(m, pos);
}
static void c_stop(struct seq_file *m, void *v)
{
}
struct seq_operations cpuinfo_op = {
start: c_start,
next: c_next,
stop: c_stop,
show: show_cpuinfo,
};
/*
* We're called here very early in the boot. We determine the machine
* type and call the appropriate low-level setup functions.
......@@ -468,8 +447,7 @@ int parse_bootinfo(void)
extern char __bss_start[];
rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
if ( rec->tag != BI_FIRST )
{
if ( rec->tag != BI_FIRST ) {
/*
* This 0x10000 offset is a terrible hack but it will go away when
* we have the bootloader handle all the relocation and
......@@ -483,8 +461,7 @@ int parse_bootinfo(void)
rec = (struct bi_record *)((ulong)rec + rec->size) )
{
ulong *data = rec->data;
switch (rec->tag)
{
switch (rec->tag) {
case BI_CMD_LINE:
memcpy(cmd_line, (void *)data, rec->size);
break;
......
/*
* BK Id: SCCS/s.walnut_setup.c 1.8 10/18/01 11:16:28 trini
* BK Id: SCCS/s.walnut_setup.c 1.10 11/13/01 21:26:07 paulus
*/
/*
*
......@@ -23,6 +23,7 @@
#include <linux/param.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <linux/seq_file.h>
#include <asm/processor.h>
#include <asm/board.h>
......@@ -101,8 +102,7 @@ walnut_init(unsigned long r3, unsigned long r4, unsigned long r5,
/* Initialize machine-dependency vectors */
ppc_md.setup_arch = walnut_setup_arch;
ppc_md.setup_residual = walnut_setup_residual;
ppc_md.get_cpuinfo = NULL;
ppc_md.show_percpuinfo = walnut_show_percpuinfo;
ppc_md.irq_cannonicalize = NULL;
ppc_md.init_IRQ = walnut_init_IRQ;
ppc_md.get_irq = walnut_get_irq;
......@@ -136,7 +136,7 @@ walnut_setup_arch(void)
}
/*
* int walnut_setup_residual()
* int walnut_show_percpuinfo()
*
* Description:
* This routine pretty-prints the platform's internal CPU and bus clock
......@@ -154,18 +154,16 @@ walnut_setup_arch(void)
* on error.
*/
int
walnut_setup_residual(char *buffer)
walnut_show_percpuinfo(struct seq_file *m)
{
int len = 0;
bd_t *bp = (bd_t *)__res;
len += sprintf(len + buffer,
"clock\t\t: %dMHz\n"
"bus clock\t\t: %dMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
seq_printf(m, "clock\t\t: %dMHz\n"
"bus clock\t\t: %dMHz\n",
bp->bi_intfreq / 1000000,
bp->bi_busfreq / 1000000);
return (len);
return 0;
}
/*
......
# BK Id: SCCS/s.Makefile 1.7 05/17/01 18:14:22 cort
# BK Id: SCCS/s.Makefile 1.10 11/08/01 07:57:40 paulus
#
#
# Makefile for ppc-specific library files..
......@@ -8,7 +8,9 @@ USE_STANDARD_AS_RULE := true
O_TARGET := lib.o
obj-y := checksum.o string.o strcase.o
export-objs := dec_and_lock.o
obj-y := checksum.o string.o strcase.o dec_and_lock.o
obj-$(CONFIG_SMP) += locks.o
......
#include <linux/module.h>
#include <linux/spinlock.h>
#include <asm/atomic.h>
#include <asm/system.h>
/*
* This is an implementation of the notion of "decrement a
* reference count, and return locked if it decremented to zero".
*
* This implementation can be used on any architecture that
* has a cmpxchg, and where atomic->value is an int holding
* the value of the atomic (i.e. the high bits aren't used
* for a lock or anything like that).
*
* N.B. ATOMIC_DEC_AND_LOCK gets defined in include/linux/spinlock.h
* if spinlocks are empty and thus atomic_dec_and_lock is defined
* to be atomic_dec_and_test - in that case we don't need it
* defined here as well.
*/
#ifndef ATOMIC_DEC_AND_LOCK
int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
{
int counter;
int newcount;
for (;;) {
counter = atomic_read(atomic);
newcount = counter - 1;
if (!newcount)
break; /* do it the slow way */
newcount = cmpxchg(&atomic->counter, counter, newcount);
if (newcount == counter)
return 0;
}
spin_lock(lock);
if (atomic_dec_and_test(atomic))
return 1;
spin_unlock(lock);
return 0;
}
EXPORT_SYMBOL(atomic_dec_and_lock);
#endif /* ATOMIC_DEC_AND_LOCK */
......@@ -34,6 +34,7 @@
#endif
#include <linux/bootmem.h>
#include <linux/console.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/smp.h>
......@@ -478,49 +479,48 @@ void print_cpu_info(struct cpuinfo_S390 *cpuinfo)
}
/*
* get_cpuinfo - Get information on one CPU for use by procfs.
*
* Prints info on the next CPU into buffer. Beware, doesn't check for
* buffer overflow. Current implementation of procfs assumes that the
* resulting data is <= 1K.
*
* Args:
* buffer -- you guessed it, the data buffer
* cpu_np -- Input: next cpu to get (start at 0). Output: Updated.
*
* Returns number of bytes written to buffer.
* show_cpuinfo - Get information on one CPU for use by procfs.
*/
int get_cpuinfo(char *buffer, unsigned *cpu_np)
static int show_cpuinfo(struct seq_file *m, void *v)
{
struct cpuinfo_S390 *cpuinfo;
char *p = buffer;
unsigned n;
n = *cpu_np;
while (n < NR_CPUS && (cpu_online_map & (1 << n)) == 0)
n++;
if (n >= NR_CPUS) {
*cpu_np = NR_CPUS;
return (0);
}
*cpu_np = n + 1;
unsigned n = v;
if (n == 0) {
p += sprintf(p,"vendor_id : IBM/S390\n"
if (!n--) {
seq_printf(m, "vendor_id : IBM/S390\n"
"# processors : %i\n"
"bogomips per cpu: %lu.%02lu\n",
smp_num_cpus, loops_per_jiffy/(500000/HZ),
(loops_per_jiffy/(5000/HZ))%100);
} else if (cpu_online_map & (1 << n)) {
cpuinfo = &safe_get_cpu_lowcore(n).cpu_data;
seq_printf(m, "processor %i: "
"version = %02X, "
"identification = %06X, "
"machine = %04X\n",
n, cpuinfo->cpu_id.version,
cpuinfo->cpu_id.ident,
cpuinfo->cpu_id.machine);
}
cpuinfo = &safe_get_cpu_lowcore(n).cpu_data;
p += sprintf(p,"processor %i: "
"version = %02X, "
"identification = %06X, "
"machine = %04X\n",
n, cpuinfo->cpu_id.version,
cpuinfo->cpu_id.ident,
cpuinfo->cpu_id.machine);
return p - buffer;
return 0;
}
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos <= NR_CPUS ? (void)(*pos+1) : NULL;
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
return c_start(m, pos);
}
static void c_stop(struct seq_file *m, void *v)
{
}
struct seq_operations cpuinfo_op = {
start: c_start,
next: c_next,
stop: c_stop,
show: show_cpuinfo,
};
......@@ -34,6 +34,7 @@
#endif
#include <linux/bootmem.h>
#include <linux/console.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/smp.h>
......@@ -467,49 +468,48 @@ void print_cpu_info(struct cpuinfo_S390 *cpuinfo)
}
/*
* get_cpuinfo - Get information on one CPU for use by procfs.
*
* Prints info on the next CPU into buffer. Beware, doesn't check for
* buffer overflow. Current implementation of procfs assumes that the
* resulting data is <= 1K.
*
* Args:
* buffer -- you guessed it, the data buffer
* cpu_np -- Input: next cpu to get (start at 0). Output: Updated.
*
* Returns number of bytes written to buffer.
* show_cpuinfo - Get information on one CPU for use by procfs.
*/
int get_cpuinfo(char *buffer, unsigned *cpu_np)
static int show_cpuinfo(struct seq_file *m, void *v)
{
struct cpuinfo_S390 *cpuinfo;
char *p = buffer;
unsigned n;
n = *cpu_np;
while (n < NR_CPUS && (cpu_online_map & (1 << n)) == 0)
n++;
if (n >= NR_CPUS) {
*cpu_np = NR_CPUS;
return (0);
}
*cpu_np = n + 1;
unsigned n = v;
if (n == 0) {
p += sprintf(p, "vendor_id : IBM/S390\n"
if (!n--) {
seq_printf(m, "vendor_id : IBM/S390\n"
"# processors : %i\n"
"bogomips per cpu: %lu.%02lu\n",
smp_num_cpus, loops_per_jiffy/(500000/HZ),
(loops_per_jiffy/(5000/HZ))%100);
} else if (cpu_online_map & (1 << n)) {
cpuinfo = &safe_get_cpu_lowcore(n).cpu_data;
seq_printf(m, "processor %i: "
"version = %02X, "
"identification = %06X, "
"machine = %04X\n",
n, cpuinfo->cpu_id.version,
cpuinfo->cpu_id.ident,
cpuinfo->cpu_id.machine);
}
cpuinfo = &safe_get_cpu_lowcore(n).cpu_data;
p += sprintf(p, "processor %i: "
"version = %02X, "
"identification = %06X, "
"machine = %04X\n",
n, cpuinfo->cpu_id.version,
cpuinfo->cpu_id.ident,
cpuinfo->cpu_id.machine);
return p - buffer;
return 0;
}
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos <= NR_CPUS ? (void)(*pos+1) : NULL;
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
return c_start(m, pos);
}
static void c_stop(struct seq_file *m, void *v)
{
}
struct seq_operations cpuinfo_op = {
start: c_start,
next: c_next,
stop: c_stop,
show: show_cpuinfo,
};
......@@ -31,6 +31,7 @@
#include <linux/bootmem.h>
#include <linux/console.h>
#include <linux/ctype.h>
#include <linux/seq_file.h>
#include <asm/processor.h>
#include <asm/page.h>
#include <asm/pgtable.h>
......@@ -517,24 +518,22 @@ struct sh_machine_vector* __init get_mv_byname(const char* name)
* Get CPU information for use by the procfs.
*/
#ifdef CONFIG_PROC_FS
int get_cpuinfo(char *buffer)
static int show_cpuinfo(struct seq_file *m, void *v)
{
char *p = buffer;
#if defined(__sh3__)
p += sprintf(p,"cpu family\t: SH-3\n"
"cache size\t: 8K-byte\n");
seq_printf(m, "cpu family\t: SH-3\n"
"cache size\t: 8K-byte\n");
#elif defined(__SH4__)
p += sprintf(p,"cpu family\t: SH-4\n"
"cache size\t: 8K-byte/16K-byte\n");
seq_printf(m, "cpu family\t: SH-4\n"
"cache size\t: 8K-byte/16K-byte\n");
#endif
p += sprintf(p, "bogomips\t: %lu.%02lu\n\n",
seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
loops_per_jiffy/(500000/HZ),
(loops_per_jiffy/(5000/HZ)) % 100);
p += sprintf(p, "Machine: %s\n", sh_mv.mv_name);
seq_printf(m, "Machine: %s\n", sh_mv.mv_name);
#define PRINT_CLOCK(name, value) \
p += sprintf(p, name " clock: %d.%02dMHz\n", \
seq_printf(m, name " clock: %d.%02dMHz\n", \
((value) / 1000000), ((value) % 1000000)/10000)
PRINT_CLOCK("CPU", boot_cpu_data.cpu_clock);
......@@ -544,6 +543,24 @@ int get_cpuinfo(char *buffer)
#endif
PRINT_CLOCK("Peripheral module", boot_cpu_data.module_clock);
return p - buffer;
return 0;
}
static void *c_start(struct seq_file *m, loff_t *pos)
{
return (void*)(*pos == 0);
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
return NULL;
}
static void c_stop(struct seq_file *m, void *v)
{
}
struct seq_operations cpuinfo_op = {
start: c_start,
next: c_next,
stop: c_stop,
show: show_cpuinfo,
};
#endif
......@@ -2625,7 +2625,8 @@ static int __init cdrom_init(void)
#ifdef CONFIG_SYSCTL
cdrom_sysctl_register();
#endif
devfs_handle = devfs_mk_dir(NULL, "cdroms", NULL);
if (!devfs_handle)
devfs_handle = devfs_mk_dir(NULL, "cdroms", NULL);
return 0;
}
......
......@@ -1462,7 +1462,7 @@ static void intel_8xx_tlbflush(agp_memory * mem)
pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp);
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp & ~(1 << 7));
pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp);
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp & (1 << 7));
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp | (1 << 7));
}
......
......@@ -24,7 +24,6 @@
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/console.h>
#include <linux/irq.h>
#include <asm/io.h>
#include <asm/uaccess.h>
......
......@@ -11,6 +11,7 @@
#include <linux/pci.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
......@@ -302,53 +303,72 @@ static struct file_operations proc_bus_pci_operations = {
#define LONG_FORMAT "\t%16lx"
#endif
static int
get_pci_dev_info(char *buf, char **start, off_t pos, int count)
/* iterator */
static void *pci_seq_start(struct seq_file *m, loff_t *pos)
{
struct list_head *p = &pci_devices;
loff_t n = *pos;
/* XXX: surely we need some locking for traversing the list? */
while (n--) {
p = p->next;
if (p == &pci_devices)
return NULL;
}
return p;
}
static void *pci_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
struct list_head *p = v;
(*pos)++;
return p->next != &pci_devices ? p->next : NULL;
}
static void pci_seq_stop(struct seq_file *m, void *v)
{
/* release whatever locks we need */
}
static int show_device(struct seq_file *m, void *v)
{
struct list_head *p = v;
const struct pci_dev *dev;
off_t at = 0;
int len, i, cnt;
const struct pci_driver *drv;
int i;
cnt = 0;
pci_for_each_dev(dev) {
const struct pci_driver *drv = pci_dev_driver(dev);
len = sprintf(buf, "%02x%02x\t%04x%04x\t%x",
if (p == &pci_devices)
return 0;
dev = pci_dev_g(p);
drv = pci_dev_driver(dev);
seq_printf(m, "%02x%02x\t%04x%04x\t%x",
dev->bus->number,
dev->devfn,
dev->vendor,
dev->device,
dev->irq);
/* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
for(i=0; i<7; i++)
len += sprintf(buf+len, LONG_FORMAT,
dev->resource[i].start | (dev->resource[i].flags & PCI_REGION_FLAG_MASK));
for(i=0; i<7; i++)
len += sprintf(buf+len, LONG_FORMAT, dev->resource[i].start < dev->resource[i].end ?
dev->resource[i].end - dev->resource[i].start + 1 : 0);
buf[len++] = '\t';
if (drv)
len += sprintf(buf+len, "%s", drv->name);
buf[len++] = '\n';
at += len;
if (at >= pos) {
if (!*start) {
*start = buf + (pos - (at - len));
cnt = at - pos;
} else
cnt += len;
buf += len;
if (cnt >= count)
/*
* proc_file_read() gives us 1KB of slack so it's OK if the
* above printfs write a little beyond the buffer end (we
* never write more than 1KB beyond the buffer end).
*/
break;
}
}
return (count > cnt) ? cnt : count;
/* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
for(i=0; i<7; i++)
seq_printf(m, LONG_FORMAT,
dev->resource[i].start |
(dev->resource[i].flags & PCI_REGION_FLAG_MASK));
for(i=0; i<7; i++)
seq_printf(m, LONG_FORMAT,
dev->resource[i].start < dev->resource[i].end ?
dev->resource[i].end - dev->resource[i].start + 1 : 0);
seq_putc(m, '\t');
if (drv)
seq_printf(m, "%s", drv->name);
seq_putc(m, '\n');
return 0;
}
static struct seq_operations proc_bus_pci_devices_op = {
start: pci_seq_start,
next: pci_seq_next,
stop: pci_seq_stop,
show: show_device
};
static struct proc_dir_entry *proc_bus_pci_dir;
int pci_proc_attach_device(struct pci_dev *dev)
......@@ -388,10 +408,10 @@ int pci_proc_detach_device(struct pci_dev *dev)
int pci_proc_attach_bus(struct pci_bus* bus)
{
struct proc_dir_entry *de;
char name[16];
struct proc_dir_entry *de = bus->procdir;
if (!(de = bus->procdir)) {
if (!de) {
char name[16];
sprintf(name, "%02x", bus->number);
de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
if (!de)
......@@ -402,11 +422,9 @@ int pci_proc_attach_bus(struct pci_bus* bus)
int pci_proc_detach_bus(struct pci_bus* bus)
{
struct proc_dir_entry *de;
if (!(de = bus->procdir)) {
struct proc_dir_entry *de = bus->procdir;
if (de)
remove_proc_entry(de->name, proc_bus_pci_dir);
}
return 0;
}
......@@ -421,54 +439,56 @@ int pci_proc_detach_bus(struct pci_bus* bus)
* The configuration string is stored starting at buf[len]. If the
* string would exceed the size of the buffer (SIZE), 0 is returned.
*/
static int sprint_dev_config(struct pci_dev *dev, char *buf, int size)
static int show_dev_config(struct seq_file *m, void *v)
{
struct list_head *p = v;
struct pci_dev *dev;
struct pci_driver *drv;
u32 class_rev;
unsigned char latency, min_gnt, max_lat, *class;
int reg, len = 0;
int reg;
if (p == &pci_devices) {
seq_puts(m, "PCI devices found:\n");
return 0;
}
dev = pci_dev_g(p);
drv = pci_dev_driver(dev);
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
pci_read_config_byte (dev, PCI_LATENCY_TIMER, &latency);
pci_read_config_byte (dev, PCI_MIN_GNT, &min_gnt);
pci_read_config_byte (dev, PCI_MAX_LAT, &max_lat);
if (len + 160 > size)
return -1;
len += sprintf(buf + len, " Bus %2d, device %3d, function %2d:\n",
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
seq_printf(m, " Bus %2d, device %3d, function %2d:\n",
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
class = pci_class_name(class_rev >> 16);
if (class)
len += sprintf(buf+len, " %s", class);
seq_printf(m, " %s", class);
else
len += sprintf(buf+len, " Class %04x", class_rev >> 16);
len += sprintf(buf+len, ": %s (rev %d).\n", dev->name, class_rev & 0xff);
seq_printf(m, " Class %04x", class_rev >> 16);
seq_printf(m, ": %s (rev %d).\n", dev->name, class_rev & 0xff);
if (dev->irq) {
if (len + 40 > size)
return -1;
len += sprintf(buf + len, " IRQ %d.\n", dev->irq);
}
if (dev->irq)
seq_printf(m, " IRQ %d.\n", dev->irq);
if (latency || min_gnt || max_lat) {
if (len + 80 > size)
return -1;
len += sprintf(buf + len, " Master Capable. ");
seq_printf(m, " Master Capable. ");
if (latency)
len += sprintf(buf + len, "Latency=%d. ", latency);
seq_printf(m, "Latency=%d. ", latency);
else
len += sprintf(buf + len, "No bursts. ");
seq_puts(m, "No bursts. ");
if (min_gnt)
len += sprintf(buf + len, "Min Gnt=%d.", min_gnt);
seq_printf(m, "Min Gnt=%d.", min_gnt);
if (max_lat)
len += sprintf(buf + len, "Max Lat=%d.", max_lat);
len += sprintf(buf + len, "\n");
seq_printf(m, "Max Lat=%d.", max_lat);
seq_putc(m, '\n');
}
for (reg = 0; reg < 6; reg++) {
struct resource *res = dev->resource + reg;
unsigned long base, end, flags;
if (len + 40 > size)
return -1;
base = res->start;
end = res->end;
flags = res->flags;
......@@ -476,9 +496,8 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size)
continue;
if (flags & PCI_BASE_ADDRESS_SPACE_IO) {
len += sprintf(buf + len,
" I/O at 0x%lx [0x%lx].\n",
base, end);
seq_printf(m, " I/O at 0x%lx [0x%lx].\n",
base, end);
} else {
const char *pref, *type = "unknown";
......@@ -494,65 +513,58 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size)
case PCI_BASE_ADDRESS_MEM_TYPE_64:
type = "64 bit"; break;
}
len += sprintf(buf + len,
" %srefetchable %s memory at "
seq_printf(m, " %srefetchable %s memory at "
"0x%lx [0x%lx].\n", pref, type,
base,
end);
}
}
return len;
return 0;
}
/*
* Return list of PCI devices as a character string for /proc/pci.
* BUF is a buffer that is PAGE_SIZE bytes long.
*/
static int pci_read_proc(char *buf, char **start, off_t off,
int count, int *eof, void *data)
{
int nprinted, len, begin = 0;
struct pci_dev *dev;
len = sprintf(buf, "PCI devices found:\n");
static struct seq_operations proc_pci_op = {
start: pci_seq_start,
next: pci_seq_next,
stop: pci_seq_stop,
show: show_dev_config
};
*eof = 1;
pci_for_each_dev(dev) {
nprinted = sprint_dev_config(dev, buf + len, PAGE_SIZE - len);
if (nprinted < 0) {
*eof = 0;
break;
}
len += nprinted;
if (len+begin < off) {
begin += len;
len = 0;
}
if (len+begin >= off+count)
break;
}
off -= begin;
*start = buf + off;
len -= off;
if (len>count)
len = count;
if (len<0)
len = 0;
return len;
static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
{
return seq_open(file, &proc_bus_pci_devices_op);
}
static struct file_operations proc_bus_pci_dev_operations = {
open: proc_bus_pci_dev_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
static int proc_pci_open(struct inode *inode, struct file *file)
{
return seq_open(file, &proc_pci_op);
}
static struct file_operations proc_pci_operations = {
open: proc_pci_open,
read: seq_read,
llseek: seq_lseek,
release: seq_release,
};
static int __init pci_proc_init(void)
{
if (pci_present()) {
struct proc_dir_entry *entry;
struct pci_dev *dev;
proc_bus_pci_dir = proc_mkdir("pci", proc_bus);
create_proc_info_entry("devices", 0, proc_bus_pci_dir,
get_pci_dev_info);
entry = create_proc_entry("devices", 0, proc_bus_pci_dir);
if (entry)
entry->proc_fops = &proc_bus_pci_dev_operations;
pci_for_each_dev(dev) {
pci_proc_attach_device(dev);
}
create_proc_read_entry("pci", 0, NULL, pci_read_proc, NULL);
entry = create_proc_entry("pci", 0, NULL);
if (entry)
entry->proc_fops = &proc_pci_operations;
}
return 0;
}
......
......@@ -66,7 +66,7 @@ static LIST_HEAD(anon_hash_chain); /* for inodes with NULL i_sb */
* NOTE! You also have to own the lock if you change
* the i_state of an inode while it is in use..
*/
spinlock_t inode_lock = SPIN_LOCK_UNLOCKED;
static spinlock_t inode_lock = SPIN_LOCK_UNLOCKED;
/*
* Statistics gathering..
......
......@@ -160,14 +160,12 @@ printk("proc_iget: using deleted entry %s, count=%d\n", de->name, atomic_read(&d
inode->i_nlink = de->nlink;
if (de->owner)
__MOD_INC_USE_COUNT(de->owner);
if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode))
if (de->proc_iops)
inode->i_op = de->proc_iops;
if (de->proc_fops)
inode->i_fop = de->proc_fops;
else if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode))
init_special_inode(inode,de->mode,kdev_t_to_nr(de->rdev));
else {
if (de->proc_iops)
inode->i_op = de->proc_iops;
if (de->proc_fops)
inode->i_fop = de->proc_fops;
}
}
out:
......
......@@ -519,6 +519,14 @@ static struct file_operations proc_mounts_operations = {
struct proc_dir_entry *proc_root_kcore;
static void create_seq_entry(char *name, mode_t mode, struct file_operations *f)
{
struct proc_dir_entry *entry;
entry = create_proc_entry(name, mode, NULL);
if (entry)
entry->proc_fops = f;
}
void __init proc_misc_init(void)
{
struct proc_dir_entry *entry;
......@@ -568,16 +576,10 @@ void __init proc_misc_init(void)
entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
if (entry)
entry->proc_fops = &proc_kmsg_operations;
entry = create_proc_entry("mounts", 0, NULL);
if (entry)
entry->proc_fops = &proc_mounts_operations;
entry = create_proc_entry("cpuinfo", 0, NULL);
if (entry)
entry->proc_fops = &proc_cpuinfo_operations;
create_seq_entry("mounts", 0, &proc_mounts_operations);
create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
#ifdef CONFIG_MODULES
entry = create_proc_entry("ksyms", 0, NULL);
if (entry)
entry->proc_fops = &proc_ksyms_operations;
create_seq_entry("ksyms", 0, &proc_ksyms_operations);
#endif
proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL);
if (proc_root_kcore) {
......
......@@ -73,13 +73,13 @@ ssize_t seq_read(struct file *file, char *buf, size_t size, loff_t *ppos)
buf += n;
copied += n;
if (!m->count)
(*ppos)++;
m->index++;
if (!size)
goto Done;
}
/* we need at least one record in buffer */
while (1) {
pos = *ppos;
pos = m->index;
p = m->op->start(m, &pos);
err = PTR_ERR(p);
if (!p || IS_ERR(p))
......@@ -125,10 +125,12 @@ ssize_t seq_read(struct file *file, char *buf, size_t size, loff_t *ppos)
m->from = n;
else
pos++;
*ppos = pos;
m->index = pos;
Done:
if (!copied)
copied = err;
else
*ppos += copied;
up(&m->sem);
return copied;
Enomem:
......@@ -139,6 +141,54 @@ ssize_t seq_read(struct file *file, char *buf, size_t size, loff_t *ppos)
goto Done;
}
static int traverse(struct seq_file *m, loff_t offset)
{
loff_t pos = 0;
int error = 0;
void *p;
m->index = 0;
m->count = m->from = 0;
if (!offset)
return 0;
if (!m->buf) {
m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
if (!m->buf)
return -ENOMEM;
}
p = m->op->start(m, &m->index);
while (p) {
error = PTR_ERR(p);
if (IS_ERR(p))
break;
error = m->op->show(m, p);
if (error)
break;
if (m->count == m->size)
goto Eoverflow;
if (pos + m->count > offset) {
m->from = offset - pos;
m->count -= m->from;
break;
}
pos += m->count;
m->count = 0;
if (pos == offset) {
m->index++;
break;
}
p = m->op->next(m, p, &m->index);
}
m->op->stop(m, p);
return error;
Eoverflow:
m->op->stop(m, p);
kfree(m->buf);
m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
return !m->buf ? -ENOMEM : -EAGAIN;
}
/**
* seq_lseek - ->llseek() method for sequential files.
* @file, @offset, @origin: see file_operations method
......@@ -157,11 +207,19 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
case 0:
if (offset < 0)
break;
retval = offset;
if (offset != file->f_pos) {
file->f_pos = offset;
m->count = 0;
while ((retval=traverse(m, offset)) == -EAGAIN)
;
if (retval) {
/* with extreme perjudice... */
file->f_pos = 0;
m->index = 0;
m->count = 0;
} else {
retval = file->f_pos = offset;
}
}
retval = offset;
}
up(&m->sem);
return retval;
......
/*
* BK Id: SCCS/s.machdep.h 1.23 10/18/01 11:16:28 trini
* BK Id: SCCS/s.machdep.h 1.25 11/13/01 21:26:07 paulus
*/
#ifdef __KERNEL__
#ifndef _PPC_MACHDEP_H
......@@ -14,13 +14,13 @@
struct pt_regs;
struct pci_bus;
struct pci_dev;
struct seq_file;
struct machdep_calls {
void (*setup_arch)(void);
/* Optional, may be NULL. */
int (*setup_residual)(char *buffer);
/* Optional, may be NULL. */
int (*get_cpuinfo)(char *buffer);
int (*show_cpuinfo)(struct seq_file *m);
int (*show_percpuinfo)(struct seq_file *m, int i);
/* Optional, may be NULL. */
unsigned int (*irq_cannonicalize)(unsigned int irq);
void (*init_IRQ)(void);
......
......@@ -109,12 +109,12 @@ typedef struct __wait_queue_head wait_queue_head_t;
} while (0)
#define WQ_CHECK_LIST_HEAD(list) \
do { \
if (!list->next || !list->prev) \
if (!(list)->next || !(list)->prev) \
WQ_BUG(); \
} while(0)
#define WQ_NOTE_WAKER(tsk) \
do { \
tsk->__waker = (long)__builtin_return_address(0); \
(tsk)->__waker = (long)__builtin_return_address(0); \
} while (0)
#else
#define WQ_BUG()
......
#!/bin/bash
indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl $@
#!/bin/sh
indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl "$@"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment