[parisc-linux-cvs] linux-2.6 varenet
Thibaut VARENE
varenet at parisc-linux.org
Wed Oct 27 06:54:49 MDT 2004
Le 27 oct. 04, à 14:50, Thibaut Varene a écrit :
> CVSROOT: /var/cvs
> Module name: linux-2.6
> Changes by: varenet 04/10/27 06:50:05
>
> Modified files:
> . : Makefile
> arch/parisc/kernel: drivers.c firmware.c
> include/asm-parisc: hardware.h pdc.h
>
> Log message:
> Added hooks for the Stable Storage "driver"
> kudos to willy for rewriting the device links ;)
>
here's the patch:
Index: Makefile
===================================================================
RCS file: /var/cvs/linux-2.6/Makefile,v
retrieving revision 1.277
diff -u -p -r1.277 Makefile
--- Makefile 27 Oct 2004 02:30:18 -0000 1.277
+++ Makefile 27 Oct 2004 12:41:17 -0000
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 9
-EXTRAVERSION = -bk6-pa4
+EXTRAVERSION = -bk6-pa5
NAME=Zonked Quokka
# *DOCUMENTATION*
Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/kernel/drivers.c,v
retrieving revision 1.9
diff -u -p -r1.9 drivers.c
--- arch/parisc/kernel/drivers.c 26 Oct 2004 19:52:45 -0000
1.9
+++ arch/parisc/kernel/drivers.c 27 Oct 2004 12:41:18 -0000
@@ -10,6 +10,7 @@
* Copyright (c) 2001 Matthew Wilcox for Hewlett Packard
* Copyright (c) 2001 Helge Deller <deller at gmx.de>
* Copyright (c) 2001,2002 Ryan Bradetich
+ * Copyright (c) 2004 Thibaut VARENE <varenet at parisc-linux.org>
*
* The file handles registering devices and drivers, then matching
them.
* It's the closest we get to a dating agency.
@@ -461,6 +462,106 @@ int register_parisc_device(struct parisc
return 0;
}
+
+/**
+ * match_pci_device - Matches a pci device against a given hardware
path
+ * entry.
+ * @dev: the generic device (known to be contained by a pci_dev).
+ * @index: the current BC index
+ * @modpath: the hardware path.
+ * @return: true if the device matches the hardware path.
+ */
+static int match_pci_device(struct device *dev, int index,
+ struct hardware_path *modpath)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ int id;
+
+ if (index == 5) {
+ /* we are at the end of the path, and on the actual
device */
+ unsigned int devfn = pdev->devfn;
+ return ((modpath->bc[5] == PCI_SLOT(devfn)) &&
+ (modpath->mod ==
PCI_FUNC(devfn)));
+ }
+
+ id = PCI_SLOT(pdev->devfn) | (PCI_FUNC(pdev->devfn) << 5);
+ return (modpath->bc[index] == id);
+}
+
+/**
+ * match_parisc_device - Matches a parisc device against a given
hardware
+ * path entry.
+ * @dev: the generic device (known to be contained by a parisc_device).
+ * @index: the current BC index
+ * @modpath: the hardware path.
+ * @return: true if the device matches the hardware path.
+ */
+static int match_parisc_device(struct device *dev, int index,
+ struct hardware_path *modpath)
+{
+ struct parisc_device *curr = to_parisc_device(dev);
+ char id = (index == 6) ? modpath->mod : modpath->bc[index];
+
+ return (curr->hw_path == id);
+}
+
+/**
+ * parse_tree_node - returns a device entry in the iotree
+ * @parent: the parent node in the tree
+ * @index: the current BC index
+ * @modpath: the hardware_path struct to match a device against
+ * @return: The corresponding device if found, NULL otherwise.
+ *
+ * Checks all the children of @parent for a matching @id. If none
+ * found, it returns NULL.
+ */
+static struct device *
+parse_tree_node(struct device *parent, int index, struct hardware_path
*modpath)
+{
+ struct device *device;
+
+ list_for_each_entry(device, &parent->children, node) {
+ if (device->bus == &parisc_bus_type) {
+ if (match_parisc_device(device, index, modpath))
+ return device;
+ }
+ else if (device->bus == &pci_bus_type) {
+ if (match_pci_device(device, index, modpath))
+ return device;
+ } else if (device->bus == NULL) {
+ /* we are either at the root of the tree, or on
a bus bridge */
+ printk("NULL\n");
+ struct device *new = parse_tree_node(device,
index, modpath);
+ if (new)
+ return new;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * find_device - Finds the generic device corresponding to a given
hardware path.
+ * @modpath: the hardware path.
+ * @return: The target device, NULL if not found.
+ */
+struct device *find_device(struct hardware_path *modpath)
+{
+ int i;
+ struct device *parent = &root;
+ for (i = 0; i < 6; i++) {
+ if (modpath->bc[i] == -1)
+ continue;
+ parent = parse_tree_node(parent, i, modpath);
+ if (!parent)
+ return NULL;
+ }
+ if (parent->bus == &pci_bus_type) /* pci devices already parse
MOD */
+ return parent;
+ else
+ return parse_tree_node(parent, 6, modpath);
+}
+EXPORT_SYMBOL(find_device);
#define BC_PORT_MASK 0x8
#define BC_LOWER_PORT 0x8
Index: arch/parisc/kernel/firmware.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/kernel/firmware.c,v
retrieving revision 1.14
diff -u -p -r1.14 firmware.c
--- arch/parisc/kernel/firmware.c 27 Oct 2004 02:30:19 -0000
1.14
+++ arch/parisc/kernel/firmware.c 27 Oct 2004 12:41:21 -0000
@@ -11,6 +11,7 @@
* Copyright 1999 The Puffin Group, (Alex deVries, David Kennedy)
* Copyright 2003 Grant Grundler <grundler parisc-linux org>
* Copyright 2003,2004 Ryan Bradetich <rbrad at parisc-linux.org>
+ * Copyright 2004 Thibaut VARENE <varenet at parisc-linux.org>
*
* This program is free software; you can redistribute it and/or
modify
* it under the terms of the GNU General Public License as
published by
@@ -573,6 +574,113 @@ int pdc_lan_station_id(char *lan_addr, u
}
EXPORT_SYMBOL(pdc_lan_station_id);
+/**
+ * pdc_stable_read - Read data from Stable Storage.
+ * @staddr: Stable Storage address to access.
+ * @memaddr: The memory address where Stable Storage data shall be
copied.
+ * @count: number of bytes to transfert. count is multiple of 4.
+ *
+ * This PDC call reads from the Stable Storage address supplied in
staddr
+ * and copies count bytes to the memory address memaddr.
+ * The call will fail if staddr+count > PDC_STABLE size.
+ */
+int pdc_stable_read(unsigned long staddr, void *memaddr, unsigned long
count)
+{
+ int retval;
+
+ spin_lock_irq(&pdc_lock);
+ retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_READ, staddr,
+ __pa(pdc_result), count);
+ convert_to_wide(pdc_result);
+ memcpy(memaddr, pdc_result, count);
+ spin_unlock_irq(&pdc_lock);
+
+ return retval;
+}
+EXPORT_SYMBOL(pdc_stable_read);
+
+/**
+ * pdc_stable_write - Write data to Stable Storage.
+ * @staddr: Stable Storage address to access.
+ * @memaddr: The memory address where Stable Storage data shall be
read from.
+ * @count: number of bytes to transfert. count is multiple of 4.
+ *
+ * This PDC call reads count bytes from the supplied memaddr address,
+ * and copies count bytes to the Stable Storage address staddr.
+ * The call will fail if staddr+count > PDC_STABLE size.
+ */
+int pdc_stable_write(unsigned long staddr, void *memaddr, unsigned
long count)
+{
+ int retval;
+
+ spin_lock_irq(&pdc_lock);
+ memcpy(pdc_result, memaddr, count);
+ convert_to_wide(pdc_result);
+ retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_WRITE, staddr,
+ __pa(pdc_result), count);
+ spin_unlock_irq(&pdc_lock);
+
+ return retval;
+}
+EXPORT_SYMBOL(pdc_stable_write);
+
+/**
+ * pdc_stable_get_size - Get Stable Storage size in bytes.
+ * @size: pointer where the size will be stored.
+ *
+ * This PDC call returns the number of bytes in the processor's Stable
+ * Storage, which is the number of contiguous bytes implemented in
Stable
+ * Storage starting from staddr=0. size in an unsigned 64-bit integer
+ * which is a multiple of four.
+ */
+int pdc_stable_get_size(unsigned long *size)
+{
+ int retval;
+
+ spin_lock_irq(&pdc_lock);
+ retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_RETURN_SIZE,
__pa(pdc_result));
+ *size = pdc_result[0];
+ spin_unlock_irq(&pdc_lock);
+
+ return retval;
+}
+EXPORT_SYMBOL(pdc_stable_get_size);
+
+/**
+ * pdc_stable_verify_contents - Checks that Stable Storage contents
are valid.
+ *
+ * This PDC call is meant to be used to check the integrity of the
current
+ * contents of Stable Storage.
+ */
+int pdc_stable_verify_contents(void)
+{
+ int retval;
+
+ spin_lock_irq(&pdc_lock);
+ retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_VERIFY_CONTENTS);
+ spin_unlock_irq(&pdc_lock);
+
+ return retval;
+}
+EXPORT_SYMBOL(pdc_stable_verify_contents);
+
+/**
+ * pdc_stable_initialize - Sets Stable Storage contents to zero and
initialize
+ * the validity indicator.
+ *
+ * This PDC call will erase all contents of Stable Storage. Use with
care!
+ */
+int pdc_stable_initialize(void)
+{
+ int retval;
+
+ spin_lock_irq(&pdc_lock);
+ retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_INITIALIZE);
+ spin_unlock_irq(&pdc_lock);
+
+ return retval;
+}
+EXPORT_SYMBOL(pdc_stable_initialize);
/**
* pdc_get_initiator - Get the SCSI Interface Card params (SCSI ID,
SDTR, SE or LVD)
Index: include/asm-parisc/hardware.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/hardware.h,v
retrieving revision 1.4
diff -u -p -r1.4 hardware.h
--- include/asm-parisc/hardware.h 26 Oct 2004 19:52:46 -0000
1.4
+++ include/asm-parisc/hardware.h 27 Oct 2004 12:41:26 -0000
@@ -123,6 +123,7 @@ extern char *print_pa_hwpath(struct pari
extern char *print_pci_hwpath(struct pci_dev *dev, char *path);
extern void get_pci_node_path(struct pci_dev *dev, struct
hardware_path *path);
extern void init_parisc_bus(void);
+extern struct device *find_device(struct hardware_path *modpath);
/* inventory.c: */
Index: include/asm-parisc/pdc.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/pdc.h,v
retrieving revision 1.10
diff -u -p -r1.10 pdc.h
--- include/asm-parisc/pdc.h 27 Oct 2004 02:30:19 -0000 1.10
+++ include/asm-parisc/pdc.h 27 Oct 2004 12:41:26 -0000
@@ -739,6 +739,12 @@ int pdc_mem_map_hpa(struct pdc_memory_ma
#endif /* !CONFIG_PA20 */
int pdc_lan_station_id(char *lan_addr, unsigned long net_hpa);
+int pdc_stable_read(unsigned long staddr, void *memaddr, unsigned long
count);
+int pdc_stable_write(unsigned long staddr, void *memaddr, unsigned
long count);
+int pdc_stable_get_size(unsigned long *size);
+int pdc_stable_verify_contents(void);
+int pdc_stable_initialize(void);
+
int pdc_pci_irt_size(unsigned long *num_entries, unsigned long hpa);
int pdc_pci_irt(unsigned long num_entries, unsigned long hpa, void
*tbl);
More information about the parisc-linux-cvs
mailing list