[parisc-linux-cvs] inventory cleanup
Matthew Wilcox
willy@ldl.fc.hp.com
Thu, 04 Oct 2001 17:15:08 -0600
Index: arch/parisc/kernel/inventory.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/inventory.c,v
retrieving revision 1.37
diff -u -p -r1.37 inventory.c
--- inventory.c 2001/10/04 00:17:52 1.37
+++ inventory.c 2001/10/04 22:39:29
@@ -9,8 +9,13 @@
* Copyright (c) 1999 The Puffin Group (David Kennedy and Alex deVries)
* Copyright (c) 2001 Matthew Wilcox for Hewlett-Packard
*
- * We query PDC for devices it knows about, and do an architected buswalk
- * in order to find devices it won't tell us about.
+ * These are the routines to discover what hardware exists in this box.
+ * This task is complicated by there being 3 different ways of
+ * performing an inventory, depending largely on the age of the box.
+ * The recommended way to do this is to check to see whether the machine
+ * is a `Snake' first, then try System Map, then try PAT. We try System
+ * Map before checking for a Snake -- this probably doesn't cause any
+ * problems, but...
*/
#include <linux/types.h>
@@ -49,9 +54,9 @@ void __init setup_pdc(void)
status = pdc_system_map_find_mods(&module_result, &module_path, 0);
if (status == PDC_RET_OK) {
- pdc_type = PDC_TYPE_SYSTEM_MAP;
- printk("Newer Box\n");
- return;
+ pdc_type = PDC_TYPE_SYSTEM_MAP;
+ printk("System Map.\n");
+ return;
}
/*
@@ -61,9 +66,7 @@ void __init setup_pdc(void)
*/
/*
- * TODO: Right now, if you try to boot a 32 bit kernel on a
- * pdc pat box, you get the "Ancient Box" panic, which isn't very
- * helpful. We should test for 64 bit capability and give a
+ * TODO: We should test for 64 bit capability and give a
* clearer message.
*/
@@ -71,24 +74,17 @@ void __init setup_pdc(void)
status = pdc_pat_cell_get_number(&cell_info);
if (status == PDC_RET_OK) {
pdc_type = PDC_TYPE_PAT;
- printk("64 bit PDC PAT Box\n");
+ printk("64 bit PAT.\n");
return;
}
#endif
- /* Here, we're going to check the model, and decide
- ** if we should even bother trying.
- */
+ /* Check the CPU's bus ID. There's probably a better test. */
status = pdc_model_info(&model);
bus_id = (model.hversion >> (4 + 7)) & 0x1f;
- /* Here, we're checking the HVERSION of the CPU.
- ** We're only checking the 0th CPU, since it'll
- ** be the same on an SMP box.
- */
-
switch (bus_id) {
case 0x4: /* 720, 730, 750, 735, 755 */
case 0x6: /* 705, 710 */
@@ -98,13 +94,13 @@ void __init setup_pdc(void)
case 0xC: /* 715/64, at least */
pdc_type = PDC_TYPE_LEGACY;
- printk("Older Legacy Box\n");
+ printk("Snake.\n");
return;
default: /* Everything else */
-
- printk("Ancient Box (bus_id = 0x%x)\n",bus_id);
- panic("This system will probably never run Linux.\n");
+
+ printk("Unsupported.\n");
+ panic("If this is a 64-bit machine, please try a 64-bit kernel.\n");
}
}
@@ -131,7 +127,7 @@ set_pmem_entry(physmem_range_t *pmem_ptr
pmem_ptr->pages = (pages4k >> PDC_PAGE_ADJ_SHIFT);
}
-void __init do_pagezero_memconfig(void)
+static void __init pagezero_memconfig(void)
{
unsigned long npages;
@@ -194,9 +190,9 @@ pat_query_module(ulong pcell_loc, ulong
}
/*
- ** save parameters in the hp_device
+ ** save parameters in the parisc_device
** (The idea being the device driver will call pdc_pat_cell_module()
- ** and store the results in it's own data structure.)
+ ** and store the results in its own data structure.)
*/
dev->pcell_loc = pcell_loc;
dev->mod_index = mod_index;
@@ -212,7 +208,7 @@ pat_query_module(ulong pcell_loc, ulong
#ifdef DEBUG_PAT
/* dump what we see so far... */
switch (PAT_GET_ENTITY(dev->mod_info)) {
- ulong i;
+ unsigned long i;
case PAT_ENTITY_PROC:
printk(KERN_DEBUG "PAT_ENTITY_PROC: id_eid 0x%lx\n",
@@ -240,7 +236,7 @@ pat_query_module(ulong pcell_loc, ulong
case PAT_ENTITY_LBA:
printk(KERN_DEBUG "PAT_ENTITY_LBA: ");
- print_ranges:
+ print_ranges:
pdc_pat_cell_module(&bytecnt, pcell_loc, mod_index,
IO_VIEW, &io_pdc_cell);
printk(KERN_DEBUG "ranges %ld\n", pa_pdc_cell.mod[1]);
@@ -273,7 +269,7 @@ pat_query_module(ulong pcell_loc, ulong
#define PAT_MAX_RANGES (4 * MAX_PHYSMEM_RANGES)
-static void __init do_pat_memconfig(void)
+static void __init pat_memconfig(void)
{
unsigned long actual_len;
struct pdc_pat_pd_addr_map_entry mem_table[PAT_MAX_RANGES+1];
@@ -298,7 +294,7 @@ static void __init do_pat_memconfig(void
printk("\n\n\n");
printk(KERN_WARNING "WARNING! Could not get full memory configuration. "
"All memory may not be used!\n\n\n");
- do_pagezero_memconfig();
+ pagezero_memconfig();
return;
}
@@ -339,7 +335,7 @@ static void __init do_pat_memconfig(void
}
}
-static int __init do_pat_inventory(void)
+static int __init pat_inventory(void)
{
int status;
ulong mod_index = 0;
@@ -367,7 +363,7 @@ static int __init do_pat_inventory(void)
}
/* We only look for extended memory ranges on a 64 bit capable box */
-static void __init do_system_map_memconfig(void)
+static void __init sprockets_memconfig(void)
{
struct pdc_memory_table_raddr r_addr;
struct pdc_memory_table mem_table[MAX_PHYSMEM_RANGES];
@@ -388,7 +384,7 @@ static void __init do_system_map_memconf
* support them yet.
*/
- do_pagezero_memconfig();
+ pagezero_memconfig();
return;
}
@@ -410,20 +406,20 @@ static void __init do_system_map_memconf
#else /* !__LP64__ */
-#define do_pat_inventory() (0)
-#define do_pat_memconfig() do { } while (0)
-#define do_system_map_memconfig() do_pagezero_memconfig()
+#define pat_inventory() (0)
+#define pat_memconfig() do { } while (0)
+#define sprockets_memconfig() pagezero_memconfig()
#endif /* !__LP64__ */
#ifndef CONFIG_PA20
-/* All of the older legacy box (32 bit only) code goes here */
+/* Code to support Snake machines (7[2350], 7[235]5, 715/Scorpio) */
-static struct parisc_device * __init
+static struct parisc_device * __init
legacy_create_device(struct pdc_memory_map *r_addr,
- struct pdc_module_path *module_path)
+ struct pdc_module_path *module_path)
{
struct parisc_device *dev;
int status = pdc_mem_map_hpa(r_addr, module_path);
@@ -439,7 +435,7 @@ legacy_create_device(struct pdc_memory_m
}
/**
- * do_legacy_inventory
+ * snake_inventory
*
* Before PDC_SYSTEM_MAP was invented, the PDC_MEM_MAP call was used.
* To use it, we initialise the mod_path.bc to 0xff and try all values of
@@ -447,7 +443,7 @@ legacy_create_device(struct pdc_memory_m
* sub-devices which are discovered by setting bc[5] to 0 and bc[4] to the
* module, then trying all possible functions.
*/
-int __init do_legacy_inventory(void)
+static int __init snake_inventory(void)
{
int mod, num = 0;
for (mod = 0; mod < 16; mod++) {
@@ -485,22 +481,24 @@ int __init do_legacy_inventory(void)
}
#else /* CONFIG_PA20 */
-#define do_legacy_inventory() 0
+#define snake_inventory() 0
#endif /* CONFIG_PA20 */
/* Common 32/64 bit based code goes here */
-/* Fixed Physical Address - Location of the Central Bus */
-#define FPA (unsigned long)(signed int)0xFFF80000
-
-/* The fixed portion is contained in hpa[14..19] for 32 bit and
-** hpa[46..51] for 64 bit. The maximum number of native devices
-** is 2^6 (64) and the offset between devices is 2^12 (0x1000).
-** - Ryan
-*/
#define MAX_NATIVE_DEVICES 64
#define NATIVE_DEVICE_OFFSET 0x1000
+/**
+ * do_native_bus_walk -- Probe a bus for devices
+ * @hpa: Base address of this bus.
+ *
+ * A native bus (eg Runway or GSC) may have up to 64 devices on it,
+ * spaced at intervals of 0x1000 bytes. PDC may not inform us of these
+ * devices, so we have to probe for them. Unfortunately, we may find
+ * devices which are not physically connected (such as extra serial &
+ * keyboard ports). This problem is not yet solved.
+ */
int do_native_bus_walk(unsigned long hpa)
{
int num = 0;
@@ -520,14 +518,14 @@ int do_native_bus_walk(unsigned long hpa
/**
* add_system_map_addresses - Add additional addresses to the parisc device.
- * @dev: The parisce device.
+ * @dev: The parisc device.
* @num_addrs: Then number of addresses to add;
* @module_instance: The system_map module instance.
*
* This function adds any additional addresses reported by the system_map
* firmware to the parisc device.
*/
-/* static */ void __init
+static void __init
add_system_map_addresses(struct parisc_device *dev, int num_addrs,
int module_instance)
{
@@ -556,51 +554,44 @@ add_system_map_addresses(struct parisc_d
}
}
+#define CENTRAL_BUS_ADDR (unsigned long)(signed int)0xFFF80000
+
/**
* do_system_map_inventory - Retrieve firmware devices via SYSTEM_MAP.
*
* This function attempts to retrieve and register all the devices firmware
* knows about via the SYSTEM_MAP PDC call.
*/
-static int __init do_system_map_inventory(void)
+static int __init system_map_inventory(void)
{
- int i, num;
- long status;
- struct parisc_device *dev;
- struct pdc_system_map_mod_info module_result;
- struct pdc_module_path module_path;
-
- /* So the idea here is to simply try one SYSTEM_MAP call. If
- ** that one works, great, otherwise do it another way
- */
- status = pdc_system_map_find_mods(&module_result, &module_path, 0);
- if (status != PDC_RET_OK)
- return 0;
+ int i, num = 0;
+ long status = PDC_RET_OK;
- num = 0;
- for (i = 0; status != PDC_RET_NE_PROC && status != PDC_RET_NE_MOD; ++i) {
+ for (i = 0; status != PDC_RET_NE_PROC && status != PDC_RET_NE_MOD; i++) {
+ struct parisc_device *dev;
+ struct pdc_system_map_mod_info module_result;
+ struct pdc_module_path module_path;
- status = pdc_system_map_find_mods(&module_result,
- &module_path, i);
+ status = pdc_system_map_find_mods(&module_result,
+ &module_path, i);
if (status != PDC_RET_OK)
continue;
- dev = alloc_pa_dev((unsigned long)module_result.mod_addr);
- if(!dev)
+ dev = alloc_pa_dev(module_result.mod_addr);
+ if (!dev)
continue;
register_parisc_device(dev);
++num;
/* if available, get the additional addresses for a module */
- if(!module_result.add_addrs)
+ if (!module_result.add_addrs)
continue;
add_system_map_addresses(dev, module_result.add_addrs, i);
}
- /* Walk the system bus */
- num += do_native_bus_walk(FPA);
+ num += do_native_bus_walk(CENTRAL_BUS_ADDR);
return num;
}
@@ -609,25 +600,25 @@ void __init do_memory_inventory(void)
switch (pdc_type) {
case PDC_TYPE_PAT:
- do_pat_memconfig();
+ pat_memconfig();
break;
case PDC_TYPE_SYSTEM_MAP:
- do_system_map_memconfig();
+ sprockets_memconfig();
break;
case PDC_TYPE_LEGACY:
- do_pagezero_memconfig();
+ pagezero_memconfig();
return;
default:
- panic("Unknown pdc_type!\n");
+ panic("Unknown PDC type!\n");
}
if (npmem_ranges == 0 || pmem_ranges[0].start_pfn != 0) {
printk(KERN_WARNING "Bad memory configuration returned!\n");
printk(KERN_WARNING "Some memory may not be used!\n");
- do_pagezero_memconfig();
+ pagezero_memconfig();
}
}
@@ -640,19 +631,19 @@ void __init do_device_inventory(void)
switch (pdc_type) {
case PDC_TYPE_PAT:
- num = do_pat_inventory();
+ num = pat_inventory();
break;
case PDC_TYPE_SYSTEM_MAP:
- num = do_system_map_inventory();
+ num = system_map_inventory();
break;
case PDC_TYPE_LEGACY:
- num = do_legacy_inventory();
+ num = snake_inventory();
break;
default:
- panic("Unknown pdc_type!\n");
+ panic("Unknown PDC type!\n");
}
if (!num) {