Skip to contentSkip to conversation

ev64260 bi_rec patch

PATCH Mark A. Greer 1 participant 2 messages Mar 29, 2002 Network drivers

lore
Share & tools
lore
#0 lore raw

I have other things to do so I won't be able to finish today. In case someone wants to work on this over the weekend, attached is a patch of what I have so far. It implements the example bi_rec's emailed before for the ev64260 board. Feel free to use it or do a better job.

Comments:
1) I added 2 new routines to arch/ppc/kernel/setup.c:
- find_bi_rec() searches that level of bi_rec's for the specified tag (i.e., it does not scan nested ones)
- find_bi_rec_dev() searches that level for a BI_DEVICE bi_rec that has bi_rec's nested inside it with the specified BI_DEV_TYPE and BI_DEV_ID. It returns a ptr to the first bi_rec inside that BI_DEVICE bi_rec that matches. Is there a better place than setup.c for these routines?

2) Each routine takes a bi_rec as a starting point so you can use the same routine by simply adding bi_rec->size to your bi_rec ptr that was returned and call that routine again.

3) I didn't bother changing parse_bootinfo() to use find_bi_rec() because there was no point.

4) I modified arch/ppc/boot/common/misc-simple.c:decompress_kernel() to call add_extra_bi_recs(). A stub for that routine is in arch/ppc/boot/simple/bi_rec-stub.c for all boards excepts ones with CONFIG_GT64260 defined (in which case, the routine is in arch/ppc/boot/simple/bi_rec-gt64260.c). As others want to add bi_rec's in the linuxppc bootloader, they can make their own version of that routine.

4) I don't have hardware so none of this code has been tested.

Mark

===== arch/ppc/boot/common/misc-simple.c 1.20 vs edited =====

arch/ppc/boot/common/misc-simple.c +5 -0
@@ -75,6 +75,7 @@
 	int timer = 0;
 	char *cp, ch;
 	struct bi_record *rec, *birecs;
+	extern struct bi_record *add_extra_bi_recs(struct bi_record *);
 
 	serial_fixups();
 	com_port = serial_init(0, NULL);
@@ -197,6 +198,7 @@
 	rec->tag = BI_CMD_LINE;
 	memcpy( (char *)rec->data, cmd_line, strlen(cmd_line)+1);
 	rec->size = sizeof(struct bi_record) + strlen(cmd_line) + 1;
+	rec->size = _ALIGN(rec->size, 4); /* Make multiple of 4 */
 	rec = (struct bi_record *)((unsigned long)rec + rec->size);
 
 	if ( initrd_size ) {
@@ -205,9 +207,12 @@
 		rec->data[1] = initrd_size;
 		rec->size = sizeof(struct bi_record) + 2 *
 			sizeof(unsigned long);
+		rec->size = _ALIGN(rec->size, 4); /* Make multiple of 4 */
 		rec = (struct bi_record *)((unsigned long)rec +
 				rec->size);
 	}
+
+	rec = add_extra_bi_recs(rec);
 
 	rec->tag = BI_LAST;
 	rec->size = sizeof(struct bi_record);

===== arch/ppc/boot/simple/Makefile 1.3 vs edited =====

arch/ppc/boot/simple/Makefile +5 -0
@@ -19,6 +19,11 @@
 # Normally, we use the 'misc-simple.c' file for decompress_kernel and
 # whatnot.  Sometimes we need to override this however.
 MISC				:= ../common/misc-simple.o
+ifeq ($(CONFIG_GT64260),y)
+MISC				+= bi_rec-gt64260.o
+else
+MISC				+= bi_rec-stub.o
+endif
 ifeq ($(CONFIG_TREEBOOT),y)
 ZIMAGE				:= zImage-TREE
 ZIMAGEINITRD			:= zImage.initrd-TREE

===== arch/ppc/boot/simple/bi_rec-gt64260.c 1.1 vs edited =====

arch/ppc/boot/simple/bi_rec-gt64260.c +173 -0

173 lines not on this page · raw message

===== arch/ppc/boot/simple/bi_rec-stub.c 1.1 vs edited =====

arch/ppc/boot/simple/bi_rec-stub.c +20 -0
@@ -0,0 +1,20 @@
+/*
+ * arch/ppc/boot/simple/bi_rec-stub.c
+ *
+ * Author: Mark A. Greer <[email protected]>
+ *
+ * Copyright 2002 MontaVista Software Inc.
+ *
+ * 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 the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#include <linux/types.h>
+#include <asm/bootinfo.h>
+
+struct bi_record *
+add_extra_bi_recs(struct bi_record *rec)
+{
+	return rec;
+}

===== arch/ppc/boot/simple/misc-ev64260.S 1.5 vs edited =====

arch/ppc/boot/simple/misc-ev64260.S +7 -0
@@ -60,4 +60,11 @@
         stwbrx  r26,0,(r25)
 	sync
 
+        addis	r25,0,EV64260_BRIDGE_REG_BASE@h
+	lis	r24,gt64260_base@h
+	ori	r24,r24,gt64260_base@l
+	stw	r25,0(r24)
+
         blr
+
+	.comm	gt64260_base,4,4

===== arch/ppc/kernel/gt64260_common.c 1.11 vs edited =====

arch/ppc/kernel/gt64260_common.c +22 -0
@@ -55,9 +55,11 @@
 #include <asm/pci-bridge.h>
 #include <asm/gt64260.h>
 #include <asm/delay.h>
+#include <asm/bootinfo.h>
 
 
 u32	gt64260_base; /* Virtual base address of 64260's regs */
+u32	gt64260_phys_base; /* Physical base address of 64260's regs */
 u32	gt64260_revision; /* Revision of the chip */
 u8	gt64260_pci_exclude_bridge = TRUE;
 
@@ -1666,6 +1668,26 @@
 
 	return total;
 } /* gt64260_get_mem_size() */
+
+/*
+ * gt64260_parse_bootinfo()
+ *
+ * Parse gt64260-specific bi_recs passed in to kernel.
+ */
+void __init
+gt64260_parse_bootinfo(struct bi_record *rec)
+{
+	if ((rec = find_bi_rec(rec, BI_GT64260_BASE)) != NULL) {
+		gt64260_phys_base = (u32)rec->data[0];
+	}
+	else {
+		printk("Missing BI_GT64260_BASE bi_rec, assuming 0x%x\n",
+			GT64260_INTERNAL_SPACE_DEFAULT_ADDR);
+		gt64260_phys_base = GT64260_INTERNAL_SPACE_DEFAULT_ADDR;
+	}
+
+	return;
+}
 
 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
 /*

===== arch/ppc/kernel/setup.c 1.100 vs edited =====

arch/ppc/kernel/setup.c +43 -0

49 lines not on this page · raw message

===== arch/ppc/platforms/ev64260_setup.c 1.14 vs edited =====

arch/ppc/platforms/ev64260_setup.c +8 -5
@@ -100,12 +100,11 @@
 ev64260_setup_bridge(void)
 {
 	gt64260_bridge_info_t		info;
-	int				window;
 
 	GT64260_BRIDGE_INFO_DEFAULT(&info, ev64260_find_end_of_memory());
 
 	/* Lookup PCI host bridges */
-	if (gt64260_find_bridges(EV64260_BRIDGE_REG_BASE,
+	if (gt64260_find_bridges(gt64260_phys_base,
 				 &info,
 				 ev64260_map_irq)) {
 		printk("Bridge initialization failed.\n");
@@ -322,7 +321,7 @@
 
 	if (mem_size == 0) {
 		/* Next 2 lines are a kludge for gt64260_get_mem_size() */
-		gt64260_base = EV64260_BRIDGE_REG_BASE;
+		gt64260_base = gt64260_phys_base;
 		ev64260_set_bat();
 		mem_size = gt64260_get_mem_size();
 	}
@@ -498,7 +497,11 @@
 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
 	      unsigned long r6, unsigned long r7)
 {
-	parse_bootinfo(find_bootinfo());
+	struct bi_record	*rec;
+
+	rec = find_bootinfo();
+	parse_bootinfo(rec);
+	gt64260_parse_bootinfo(rec);
 
 	isa_mem_base = 0;
 
@@ -530,7 +533,7 @@
 #ifdef	CONFIG_SERIAL_TEXT_DEBUG
 	ev64260_set_bat();
 #ifdef	CONFIG_GT64260_CONSOLE
-	gt64260_base = EV64260_BRIDGE_REG_BASE;
+	gt64260_base = gt64260_phys_base;
 	ppc_md.progress = gt64260_mpsc_progress; /* embedded UART */
 #else
 	ppc_md.progress = ev64260_16550_progress; /* Dev module DUART */

===== drivers/net/gt64260_eth.c 1.8 vs edited =====

drivers/net/gt64260_eth.c +34 -73

152 lines not on this page · raw message

===== include/asm-ppc/bootinfo.h 1.13 vs edited =====

include/asm-ppc/bootinfo.h +14 -0
@@ -33,7 +33,21 @@
 #define BI_MACHTYPE		0x1016
 #define BI_MEMSIZE		0x1017
 
+/* BI_DEVICE is a bi_rec that contains nested bi_recs for that device */
+#define BI_DEVICE		0x1018	/* Nest device bi_rec */
+#define BI_DEV_TYPE		0x1019	/* Type of device */
+#define BI_DEV_TYPE_TULIP	0x0001	/* Device is a Dec/Intel 21x4x */
+#define BI_DEV_TYPE_8255x	0x0002	/* Device is an Intel 8255x */
+#define BI_DEV_TYPE_GT_ETH	0x0003	/* Device is a GT64260 enet ctlr */
+#define BI_DEV_ID		0x101a	/* ID of device (device-specific) */
+#define BI_MAC_ADDR		0x101b	/* MAC addr of network device */
+
+#define	BI_GT64260_BASE		0x101c	/* Base addr of GT-64260 host bridge */
+
 extern struct bi_record *find_bootinfo(void);
+extern struct bi_record *find_bi_rec(struct bi_record *rec, unsigned long tag);
+extern struct bi_record *find_bi_rec_dev(struct bi_record *rec,
+		unsigned long dev_type, unsigned long dev_id);
 extern void parse_bootinfo(struct bi_record *rec);
 
 #endif /* CONFIG_APUS */

===== include/asm-ppc/gt64260.h 1.12 vs edited =====

include/asm-ppc/gt64260.h +4 -0
@@ -26,10 +26,12 @@
 #include <asm/uaccess.h>
 #include <asm/machdep.h>
 #include <asm/pci-bridge.h>
+#include <asm/bootinfo.h>
 #include <asm/gt64260_defs.h>
 
 
 extern u32     gt64260_base;
+extern u32     gt64260_phys_base;
 extern u32     gt64260_irq_base;     /* We handle the next 96 IRQs from here */
 extern u32     gt64260_revision;
 extern u8      gt64260_pci_exclude_bridge;
@@ -329,6 +331,8 @@
 int gt64260_get_base(u32 *base);
 int gt64260_pci_exclude_device(u8 bus, u8 devfn);
 ulong gt64260_get_mem_size(void);
+void gt64260_parse_bootinfo(struct bi_record *rec);
+
 
 void gt64260_init_irq(void);
 int gt64260_get_irq(struct pt_regs *regs);