[parisc-linux-cvs] Patch 2 of 3 (boot cleanup/large memory preparation)
John Marvin
jsm@udlkern.fc.hp.com
Fri, 2 Mar 2001 03:34:11 -0700 (MST)
--- arch/parisc/kernel/iosapic.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/iosapic.c Fri Mar 2 02:03:00 2001
@@ -335,15 +335,14 @@ iosapic_load_irt(unsigned long cell_num,
ASSERT(NULL != irt);
/* FIXME ASSERT(((&pdc_io_num) & (0x3f)) == 0); enforce 32-byte alignment */
-#ifdef __LP64__
- /* Try PAT_PDC to get interrupt routing table size */
- DBG(KERN_DEBUG "calling get_irt_size\n");
- status = pdc_pat_get_irt_size( &pdc_io_num, cell_num);
- DBG(KERN_DEBUG "get_irt_size: %ld\n", status);
+ if (is_pdc_pat()) {
- switch(status) {
+ /* Use pat pdc routine to get interrupt routing table size */
+ DBG(KERN_DEBUG "calling get_irt_size\n");
+ status = pdc_pat_get_irt_size( &pdc_io_num, cell_num);
+ DBG(KERN_DEBUG "get_irt_size: %ld\n", status);
- case PDC_RET_OK: /* PAT box. Proceed to get the IRT */
+ ASSERT(status == PDC_RET_OK);
/* save the number of entries in the table */
num_entries = pdc_io_num.num;
@@ -365,54 +364,48 @@ iosapic_load_irt(unsigned long cell_num,
status = pdc_pat_get_irt( (void *) table, cell_num);
DBG(KERN_DEBUG "pdc_pat_get_irt: %ld\n", status);
ASSERT(status == PDC_RET_OK);
- break;
- case PDC_RET_NE_PROC: /* Not a PAT platform. Try PDC_PCI extensions */
-#endif /* __LP64__ */
+ goto got_irt;
+ }
- /*
- ** C3000/J5000 (and similar) platforms with "legacy" PDC
- ** will return exactly one IRT for all iosapics.
- ** So if we have one, don't need to get it again.
- */
- if (NULL != irt_cell) {
- return 0;
- }
+ /*
+ ** C3000/J5000 (and similar) platforms with "legacy" PDC
+ ** will return exactly one IRT for all iosapics.
+ ** So if we have one, don't need to get it again.
+ */
+ if (NULL != irt_cell) {
+ return 0;
+ }
- status = pdc_pci_irt_size( (void *)&pdc_io_num,
- /* elroy HPA (really a NOP) */ 0);
- DBG(KERN_WARNING "pdc_pci_irt_size: %ld\n", status);
+ status = pdc_pci_irt_size( (void *)&pdc_io_num,
+ /* elroy HPA (really a NOP) */ 0);
+ DBG(KERN_WARNING "pdc_pci_irt_size: %ld\n", status);
+
+ if (PDC_RET_OK != status) {
+ /* Not a "legacy" system with I/O SAPIC either */
+ return 0;
+ }
- if (PDC_RET_OK != status) {
- /* Not a "legacy" system with I/O SAPIC either */
- return 0;
- }
+ num_entries = pdc_io_num.num;
+ ASSERT(0UL != num_entries);
- num_entries = pdc_io_num.num;
- ASSERT(0UL != num_entries);
+ table = IOSAPIC_KALLOC(struct irt_entry, num_entries);
+ if (table == NULL) {
+ printk(KERN_WARNING MODULE_NAME ": read_irt : can not alloc mem for IRT\n");
+ return 0;
+ }
- table = IOSAPIC_KALLOC(struct irt_entry, num_entries);
- if (table == NULL) {
- printk(KERN_WARNING MODULE_NAME ": read_irt : can not alloc mem for IRT\n");
- return 0;
- }
+ status = pdc_pci_irt( (void *) &pdc_io_num,
+ (void *) NULL, /* Elroy HPA - not used */
+ (void *) table);
+
+ ASSERT(PDC_RET_OK == status);
+
+got_irt:
- status = pdc_pci_irt( (void *) &pdc_io_num,
- (void *) NULL, /* Elroy HPA - not used */
- (void *) table);
-
- ASSERT(PDC_RET_OK == status);
-#ifdef __LP64__
- break;
- default:
- printk(KERN_WARNING MODULE_NAME ": PDC_PAT_IO call failed with %ld\n", status);
- break;
- }
-#endif /* __LP64__ */
/* return interrupt table address */
*irt = table;
-
#ifdef DEBUG_IOSAPIC_IRT
{
struct irt_entry *p = table;
@@ -779,7 +772,7 @@ iosapic_set_irt_data( struct vector_info
** Extracting id_eid isn't a real clean way of getting it.
** But the encoding is the same for both PA and IA64 platforms.
*/
- if (pdc_pat) {
+ if (is_pdc_pat()) {
/*
** PAT PDC just hands it to us "right".
** vi_txn_addr comes from cpu_data[x].txn_addr.
--- arch/parisc/kernel/lba_pci.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/lba_pci.c Fri Mar 2 02:08:49 2001
@@ -784,10 +784,12 @@ lba_fixup_bus(struct pci_bus *bus)
(void) lba_cfg_read16(dev, PCI_STATUS, &status);
fbb_enable &= status;
- if (pdc_pat) {
+#ifdef __LP64__
+ if (is_pdc_pat()) {
/* Claim resources for PDC's devices */
lba_claim_dev_resources(dev);
}
+#endif
/*
** P2PB's have no IRQs. ignore them.
@@ -1281,7 +1283,7 @@ lba_driver_callback(struct hp_device *d,
/* ---------- Third : setup I/O Port and MMIO resources --------- */
#ifdef __LP64__
- if (pdc_pat) {
+ if (is_pdc_pat()) {
/* PDC PAT firmware uses PIOP region of GMMIO space. */
pci_port = &lba_pat_port_ops;
@@ -1305,7 +1307,8 @@ lba_driver_callback(struct hp_device *d,
lba_bus = lba_dev->hba.hba_bus =
pci_scan_bus( lba_dev->hba.bus_num.start, &lba_cfg_ops, (void *) lba_dev);
- if (pdc_pat) {
+#ifdef __LP64__
+ if (is_pdc_pat()) {
/* determine window sizes needed by PCI-PCI bridges */
DBG_PAT("LBA pcibios_size_bridge()\n");
@@ -1322,6 +1325,7 @@ lba_driver_callback(struct hp_device *d,
lba_dump_res(&lba_dev->hba.mem_space, 2);
#endif
}
+#endif
/*
** Once PCI register ops has walked the bus, access to config
--- arch/parisc/kernel/pci.c.old Fri Mar 2 00:41:26 2001
+++ arch/parisc/kernel/pci.c Fri Mar 2 00:42:33 2001
@@ -18,7 +18,7 @@
#include <linux/string.h> /* for memcpy() */
#include <asm/system.h>
-#include <asm/pdcpat.h> /* for pdc_pat proto */
+#include <asm/pdc.h> /* for is_pdc_pat() macro */
#ifdef CONFIG_PCI
@@ -126,7 +126,7 @@ void pcibios_fixup_bus(struct pci_bus *b
ASSERT(pci_bios != NULL);
/* If this is a PCI-PCI bridge, get the current bases */
- if (bus->self && !pdc_pat) {
+ if (bus->self && !is_pdc_pat()) {
pci_read_bridge_bases(bus);
}
--- arch/parisc/kernel/pdc.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/pdc.c Thu Mar 1 23:22:08 2001
@@ -246,3 +246,11 @@ int pdc_tod_set(unsigned long sec, unsig
{
return mem_pdc_call(PDC_TOD, PDC_TOD_WRITE, sec, usec);
}
+
+#ifdef __LP64__
+int pdc_mem_mem_table(void *r_addr, void *tbl, unsigned long entries)
+{
+ return mem_pdc_call(PDC_MEM, PDC_MEM_TABLE,__pa(r_addr),
+ __pa(tbl), entries);
+}
+#endif
--- arch/parisc/kernel/pdcpat.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/pdcpat.c Thu Mar 1 23:22:08 2001
@@ -72,3 +72,9 @@ int pdc_pat_cell_num_to_loc(void *r_addr
return mem_pdc_call(PDC_PAT_CELL, PDC_PAT_CELL_NUMBER_TO_LOC, __pa(r_addr), cell_num);
}
+int pdc_pat_pd_get_addr_map(void *r_addr, void *mem_addr, unsigned long count, unsigned long offset)
+{
+ ASSERT_ALIGN(r_addr, 8);
+ ASSERT_ALIGN(mem_addr, 8);
+ return mem_pdc_call(PDC_PAT_PD, PDC_PAT_PD_GET_ADDR_MAP, __pa(r_addr), __pa(mem_addr), count, offset);
+}
--- arch/parisc/kernel/sba_iommu.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/sba_iommu.c Thu Mar 1 23:45:04 2001
@@ -1352,16 +1352,15 @@ PAT_MOD(mod)->mod_info.ioc = PAT
static void
sba_ioc_init(struct ioc *ioc)
{
- extern unsigned long mem_max; /* arch.../setup.c */
extern void lba_init_iregs(void *, u32, u32); /* arch.../lba_pci.c */
u32 iova_space_size, iova_space_mask;
void * pdir_base;
int pdir_size, iov_order;
+ unsigned long physmem;
/*
** Determine IOVA Space size from memory size.
- ** Using "mem_max" is a kluge.
**
** Ideally, PCI drivers would register the maximum number
** of DMA they can have outstanding for each device they
@@ -1374,14 +1373,16 @@ sba_ioc_init(struct ioc *ioc)
** for DMA hints - ergo only 30 bits max.
*/
/* limit IOVA space size to 1MB-1GB */
- if (mem_max < (sba_mem_ratio*1024*1024)) {
+
+ physmem = num_physpages << PAGE_SHIFT;
+ if (physmem < (sba_mem_ratio*1024*1024)) {
iova_space_size = 1024*1024;
#ifdef __LP64__
- } else if (mem_max > (sba_mem_ratio*512*1024*1024)) {
+ } else if (physmem > (sba_mem_ratio*512*1024*1024)) {
iova_space_size = 512*1024*1024;
#endif
} else {
- iova_space_size = (u32) (mem_max/sba_mem_ratio);
+ iova_space_size = (u32) (physmem/sba_mem_ratio);
}
/*
@@ -1401,7 +1402,7 @@ sba_ioc_init(struct ioc *ioc)
ASSERT((1 << get_order(pdir_size)) == (pdir_size >> PAGE_SHIFT));
DBG_INIT("%s() hpa 0x%p mem %dMBIOV %dMB (%d bits) PDIR size 0x%0x",
- __FUNCTION__, ioc->ioc_hpa, (int) (mem_max>>20),
+ __FUNCTION__, ioc->ioc_hpa, (int) (physmem>>20),
iova_space_size>>20, iov_order + PAGE_SHIFT, pdir_size);
/* FIXME : DMA HINTs not used */
--- arch/parisc/kernel/setup.c.old Thu Mar 1 23:06:24 2001
+++ arch/parisc/kernel/setup.c Fri Mar 2 03:17:23 2001
@@ -41,7 +41,7 @@
#include <linux/kdev_t.h>
#include <linux/major.h>
#include <linux/string.h>
-#include <linux/blk.h>
+#include <linux/blk.h> /* for initrd_start and initrd_end */
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/console.h>
@@ -68,52 +68,6 @@
#define COMMAND_LINE_SIZE 1024
char saved_command_line[COMMAND_LINE_SIZE];
-/*
-** KLUGE ALERT!
-**
-** We *really* should be using a combination of request_resource()
-** and request_region()! But request_region() requires kmalloc since
-** returns a new struct resource. And kmalloc just isn't available
-** until after mem_init() is called from start_kernel().
-**
-** FIXME: assume contiguous memory initially.
-** Additional chunks of memory might be added to sysram_resource.sibling.
-*/
-static struct resource sysrom_resource = {
- name: "System ROM", start: 0x0f0000000UL, end: 0x0f00fffffUL,
- flags: IORESOURCE_BUSY | IORESOURCE_MEM,
- parent: &iomem_resource, sibling: NULL, child: NULL };
-
-static struct resource pdcdata_resource;
-
-static struct resource sysram_resource = {
- name: "System RAM", start: 0UL, end: ~0UL /* bogus */,
- flags: IORESOURCE_MEM,
- parent: &iomem_resource, sibling: &sysrom_resource, child: &pdcdata_resource};
-
-extern char _text; /* start of kernel code, defined by linker */
-extern int data_start;
-extern char _edata; /* end of data, begin BSS, defined by linker */
-extern char _end; /* end of BSS, defined by linker */
-
-static struct resource data_resource = {
- name: "kernel Data", start: virt_to_phys(&data_start), end: virt_to_phys(&_end)-1,
- flags: IORESOURCE_BUSY | IORESOURCE_MEM,
- parent: &sysram_resource, sibling: NULL, child: NULL};
-
-static struct resource code_resource = {
- name: "Kernel Code", start: virt_to_phys(&_text), end: virt_to_phys(&data_start)-1,
- flags: IORESOURCE_BUSY | IORESOURCE_MEM,
- parent: &sysram_resource, sibling: &data_resource, child: NULL};
-
-static struct resource pdcdata_resource = {
- name: "PDC data (Page Zero)", start: 0, end: 0x9ff,
- flags: IORESOURCE_BUSY | IORESOURCE_MEM,
- parent: &sysram_resource, sibling: &code_resource, child: NULL};
-
-
-
-
struct system_cpuinfo_parisc boot_cpu_data;
struct cpuinfo_parisc cpu_data[NR_CPUS];
@@ -174,7 +128,7 @@ cpu_driver_callback(struct hp_device *d,
#endif
#ifdef __LP64__
- if (pdc_pat) {
+ if (is_pdc_pat()) {
unsigned long pdc_result[32] __attribute__ ((aligned (8))) = {0,0,0,0};
ulong status;
pdc_pat_cell_mod_maddr_block_t pa_pdc_cell;
@@ -208,7 +162,7 @@ cpu_driver_callback(struct hp_device *d,
} else {
cpuid = pdc_result[0];
}
- } else
+ } else
#endif
{
txn_addr = (unsigned long) d->hpa; /* for legacy PDC */
@@ -316,7 +270,6 @@ void __init collect_boot_cpu_data(void)
boot_cpu_data.family_name = cpu_name_version[boot_cpu_data.cpu_type][1];
}
-
/*
** Set width/Enable FP coprocessor
**
@@ -381,95 +334,41 @@ init_per_cpu(int cpuid)
}
-/* start_parisc() will be called from head.S to setup our new memory_start
- and actually start our kernel !
- Memory-Layout is:
- - Kernel-Image (code+data+BSS)
- - Stack (stack-size see below!, stack-setup-code is in head.S)
- - memory_start at end of stack..
-*/
-
-unsigned long mem_start, mem_max;
-unsigned long start_pfn, max_pfn;
-extern asmlinkage void __init start_kernel(void);
-
-#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
-#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
-
-void __init start_parisc(unsigned arg0, unsigned arg1,
- unsigned arg2, unsigned arg3)
+void __init setup_cmdline(char **cmdline_p)
{
- unsigned long memory_start;
-
- /* Clear BSS */
- {
- char *p = &_edata, *q = &_end;
-
- while (p < q) {
- *p++ = 0;
- }
- }
-
- printk("The "
-#ifdef __LP64__
- "64"
-#else
- "32"
-#endif
- "-bit Kernel has started...\n");
-
- init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */
-
- memory_start = (unsigned long) &_end;
- memory_start = (memory_start + PAGE_SIZE) & PAGE_MASK;
- printk("Free memory starts at: 0x%lx\n", memory_start);
+ extern unsigned int boot_args[];
/* Collect stuff passed in from the boot loader */
+#if 1
printk(KERN_WARNING "%s(0x%x,0x%x,0x%x,0x%x)\n",
- __FUNCTION__, arg0, arg1, arg2, arg3);
+ __FUNCTION__, boot_args[0], boot_args[1], boot_args[2], boot_args[3]);
+#endif
- /* arg0 is free-mem start, arg1 is ptr to command line */
- if (arg0 < 64) {
+ /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
+ if (boot_args[0] < 64) {
/* called from hpux boot loader */
saved_command_line[0] = '\0';
} else {
- strcpy(saved_command_line, (char *)__va(arg1));
+ strcpy(saved_command_line, (char *)__va(boot_args[1]));
+#if 1
printk("PALO command line: '%s'\nPALO initrd %x-%x\n",
- saved_command_line, arg2, arg3);
+ saved_command_line, boot_args[2], boot_args[3]);
+#endif
#ifdef CONFIG_BLK_DEV_INITRD
- if (arg2 != 0) /* did palo pass us a ramdisk? */
+ if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
{
- initrd_start = (unsigned long)__va(arg2);
- initrd_end = (unsigned long)__va(arg3);
+ initrd_start = (unsigned long)__va(boot_args[2]);
+ initrd_end = (unsigned long)__va(boot_args[3]);
}
#endif
}
- mem_start = __pa(memory_start);
-#define MAX_MEM (3584*1024*1024)
- mem_max = (PAGE0->imm_max_mem > MAX_MEM ? MAX_MEM : PAGE0->imm_max_mem);
-
- collect_boot_cpu_data();
-
- /* initialize the LCD/LED after boot_cpu_data is available ! */
-#ifdef CONFIG_CHASSIS_LCD_LED
- led_init(); /* LCD/LED initialization */
-#endif
-
- do_inventory(); /* probe for hardware */
- register_driver(cpu_drivers_for); /* claim all the CPUs */
-
- if (boot_cpu_data.cpu_count == 0)
- register_fallback_cpu();
-
- printk("CPU(s): %d x %s at %d.%06d MHz\n",
- boot_cpu_data.cpu_count,
- boot_cpu_data.cpu_name,
- boot_cpu_data.cpu_hz / 1000000,
- boot_cpu_data.cpu_hz % 1000000 );
+ *cmdline_p = saved_command_line;
+}
+void __init dma_ops_init(void)
+{
switch (boot_cpu_data.cpu_type) {
case pcx:
/*
@@ -494,62 +393,43 @@ void __init start_parisc(unsigned arg0,
default:
break;
}
-
- /* Turn off space register hashing */
-
- disable_sr_hashing();
-
-#if 1
- /* KLUGE! this really belongs in kernel/resource.c! */
- iomem_resource.end = ~0UL;
-#endif
- sysram_resource.end = mem_max - 1;
- start_kernel(); /* now back to arch-generic code... */
}
void __init setup_arch(char **cmdline_p)
{
- unsigned long bootmap_size;
- unsigned long start_pfn;
- unsigned long mem_free;
-
- *cmdline_p = saved_command_line;
-
- /* initialize bootmem */
-
- start_pfn = PFN_UP(mem_start);
- max_pfn = PFN_DOWN(mem_max);
-
- bootmap_size = init_bootmem(start_pfn, max_pfn);
-
- mem_start += bootmap_size;
- mem_free = mem_max - mem_start;
-
- /* free_bootmem handles rounding nicely */
- printk("free_bootmem(0x%lx, 0x%lx)\n", (unsigned long)mem_start,
- (unsigned long)mem_free);
- free_bootmem(mem_start, mem_free);
-
-#ifdef CONFIG_BLK_DEV_INITRD
- printk("initrd: %08x-%08x\n", (int) initrd_start, (int) initrd_end);
+ init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */
- if (initrd_end != 0) {
- initrd_below_start_ok = 1;
- reserve_bootmem(__pa(initrd_start), initrd_end - initrd_start);
- }
+ printk("The "
+#ifdef __LP64__
+ "64"
+#else
+ "32"
#endif
+ "-bit Kernel has started...\n");
- EISA_bus = 0;
-
+ setup_pdc();
+ setup_cmdline(cmdline_p);
+ collect_boot_cpu_data();
+ do_memory_inventory(); /* probe for physical memory */
cache_init();
-
paging_init();
- if((unsigned long)&init_task_union&(INIT_TASK_SIZE - 1)) {
- printk("init_task_union not aligned. Please recompile the kernel after changing the first line in arch/parisc/kernel/init_task.c from \n\"#define PAD 0\" to\n\"#define PAD 1\" or vice versa\n");
- for(;;);
- }
+#ifdef CONFIG_CHASSIS_LCD_LED
+ /* initialize the LCD/LED after boot_cpu_data is available ! */
+ led_init(); /* LCD/LED initialization */
+#endif
+
+ dma_ops_init();
+ do_device_inventory(); /* probe for hardware */
+ register_driver(cpu_drivers_for); /* claim all the CPUs */
+ if (boot_cpu_data.cpu_count == 0)
+ register_fallback_cpu();
+ printk("CPU(s): %d x %s at %d.%06d MHz\n",
+ boot_cpu_data.cpu_count,
+ boot_cpu_data.cpu_name,
+ boot_cpu_data.cpu_hz / 1000000,
+ boot_cpu_data.cpu_hz % 1000000 );
#ifdef CONFIG_SERIAL_CONSOLE
/* nothing */
--- arch/parisc/kernel/smp.c.old Fri Mar 2 01:06:08 2001
+++ arch/parisc/kernel/smp.c Fri Mar 2 01:07:11 2001
@@ -484,9 +484,9 @@ smp_cpu_init(int cpunum)
/*
* Slaves start using C here. Indirectly called from smp_slave_stext.
- * Do what start_parisc() and main() do for boot strap processor (aka monarch)
+ * Do what start_kernel() and main() do for boot strap processor (aka monarch)
*/
-void __init smp_callin(unsigned long pdc_entry_point, long hpa)
+void __init smp_callin(void)
{
extern void cpu_idle(void); /* arch/parisc/kernel/process.c */
int slave_id = cpu_now_booting;