Module Name:    src
Committed By:   gavan
Date:           Sun Aug  2 11:32:05 UTC 2009

Modified Files:
        src/sys/arch/arm/arm: bootconfig.c
        src/sys/arch/iyonix/iyonix: autoconf.c iyonix_machdep.c

Log Message:
On NetBSD/iyonix:

* Disable interrupts in otherwise-configure Nvidia graphics card
* Support genfb console, based on information supplied by the bootloader
* Support kernel args
* Support ways to choose which console to use
* Clarify argument parsing a little.

(from me and abs)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/bootconfig.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/iyonix/iyonix/autoconf.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/iyonix/iyonix/iyonix_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm/bootconfig.c
diff -u src/sys/arch/arm/arm/bootconfig.c:1.5 src/sys/arch/arm/arm/bootconfig.c:1.6
--- src/sys/arch/arm/arm/bootconfig.c:1.5	Tue Oct 24 20:25:52 2006
+++ src/sys/arch/arm/arm/bootconfig.c	Sun Aug  2 11:32:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootconfig.c,v 1.5 2006/10/24 20:25:52 bjh21 Exp $	*/
+/*	$NetBSD: bootconfig.c,v 1.6 2009/08/02 11:32:05 gavan Exp $	*/
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -38,7 +38,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: bootconfig.c,v 1.5 2006/10/24 20:25:52 bjh21 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bootconfig.c,v 1.6 2009/08/02 11:32:05 gavan Exp $");
 
 #include <sys/systm.h>
 
@@ -46,6 +46,9 @@
 
 /* 
  * Function to identify and process different types of boot argument
+ * Note, results may contain trailing data, eg:
+ * get_bootconf_option("cow=moo milk=1", "moo", BOOTOPT_TYPE_STRING, &ptr)
+ * will return ptr of "moo milk=1", *not* "moo"
  */
 
 int

Index: src/sys/arch/iyonix/iyonix/autoconf.c
diff -u src/sys/arch/iyonix/iyonix/autoconf.c:1.10 src/sys/arch/iyonix/iyonix/autoconf.c:1.11
--- src/sys/arch/iyonix/iyonix/autoconf.c:1.10	Mon Apr 28 20:23:26 2008
+++ src/sys/arch/iyonix/iyonix/autoconf.c	Sun Aug  2 11:32:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.10 2008/04/28 20:23:26 martin Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.11 2009/08/02 11:32:05 gavan Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2008/04/28 20:23:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.11 2009/08/02 11:32:05 gavan Exp $");
 
 #include "opt_md.h"
 
@@ -51,9 +51,13 @@
 
 #include <iyonix/iyonix/iyonixvar.h>
 
+#include <acorn32/include/bootconfig.h>
+
 struct device *booted_device;
 int booted_partition;
 
+extern struct bootconfig bootconfig;
+
 /*
  * Set up the root device from the boot args
  */
@@ -136,4 +140,47 @@
 			SETPROP("i82543-swdpin", swdpin);
 		}
 	}
+
+	if (device_is_a(dev, "genfb") &&
+	    device_is_a(device_parent(dev), "pci") ) {
+		prop_dictionary_t dict = device_properties(dev);
+		struct pci_attach_args *pa = aux;
+		pcireg_t bar0, bar1;
+		uint32_t fbaddr;
+		bus_space_handle_t vgah;
+
+		bar0 = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
+		bar1 = pci_conf_read(pa->pa_pc, pa->pa_tag,
+			PCI_MAPREG_START + 0x04);
+
+		/*
+		 * We need to prod the VGA card to disable interrupts, since
+		 * RISC OS has been using them and we don't know how to
+		 * handle them. This assumes that we have a NVidia
+		 * GeForce 2 MX card as supplied with the Iyonix and
+		 * as (probably) required by RISC OS in order to boot.
+		 * If you write your own RISC OS driver for a different card,
+		 * you're on your own.
+		 */
+
+/* We're guessing at the numbers here, guys */
+#define VGASIZE 0x1000
+#define IRQENABLE_ADDR 0x140
+
+		bus_space_map(pa->pa_memt, PCI_MAPREG_MEM_ADDR(bar0), 
+			VGASIZE, 0, &vgah);
+		bus_space_write_4(pa->pa_memt, vgah, 0x140, 0);
+		bus_space_unmap(pa->pa_memt, vgah, 0x1000);
+
+		fbaddr = PCI_MAPREG_MEM_ADDR(bar1);
+
+		prop_dictionary_set_bool(dict, "is_console", 1);
+		prop_dictionary_set_uint32(dict, "width",
+			bootconfig.width + 1);
+		prop_dictionary_set_uint32(dict, "height",
+			bootconfig.height + 1);
+		prop_dictionary_set_uint32(dict, "depth",
+			1 << bootconfig.log2_bpp);
+		prop_dictionary_set_uint32(dict, "address", fbaddr);
+	}
 }

Index: src/sys/arch/iyonix/iyonix/iyonix_machdep.c
diff -u src/sys/arch/iyonix/iyonix/iyonix_machdep.c:1.11 src/sys/arch/iyonix/iyonix/iyonix_machdep.c:1.12
--- src/sys/arch/iyonix/iyonix/iyonix_machdep.c:1.11	Sun Nov 30 18:21:34 2008
+++ src/sys/arch/iyonix/iyonix/iyonix_machdep.c	Sun Aug  2 11:32:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: iyonix_machdep.c,v 1.11 2008/11/30 18:21:34 martin Exp $	*/
+/*	$NetBSD: iyonix_machdep.c,v 1.12 2009/08/02 11:32:05 gavan Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iyonix_machdep.c,v 1.11 2008/11/30 18:21:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iyonix_machdep.c,v 1.12 2009/08/02 11:32:05 gavan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -146,8 +146,8 @@
 #define UND_STACK_SIZE	1
 
 struct bootconfig bootconfig;		/* Boot config storage */
-char *boot_args = NULL;
-char *boot_file = NULL;
+
+char *boot_args;
 
 vm_offset_t physical_start;
 vm_offset_t physical_freestart;
@@ -198,18 +198,36 @@
 
 char iyonix_macaddr[ETHER_ADDR_LEN];
 
+char boot_consdev[16];
+
 /* Prototypes */
 
-void	consinit(void);
 void	iyonix_pic_init(void);
 void	iyonix_read_machineid(void);
 
+void	consinit(void);
+
+static void consinit_com(const char *consdev);
+static void consinit_genfb(const char *consdev);
+static void process_kernel_args(void);
+static void parse_iyonix_bootargs(char *args);
+
 #include "com.h"
 #if NCOM > 0
 #include <dev/ic/comreg.h>
 #include <dev/ic/comvar.h>
 #endif
 
+#include "genfb.h"
+
+#if (NGENFB == 0) && (NCOM == 0)
+# error "No valid console device (com or genfb)"
+#elif defined(COMCONSOLE) || (NGENFB == 0)
+# define DEFAULT_CONSDEV "com"
+#else
+# define DEFAULT_CONSDEV "genfb"
+#endif
+
 /*
  * Define the default console speed for the machine.
  */
@@ -456,6 +474,21 @@
 	/* Calibrate the delay loop. */
 	i80321_calibrate_delay();
 
+	/* Ensure bootconfig has valid magic */
+	if (passed_bootconfig->magic != BOOTCONFIG_MAGIC)
+		printf("Bad bootconfig magic: %x\n", bootconfig.magic);
+
+	bootconfig = *passed_bootconfig;
+
+	/* Fake bootconfig structure for anything that still needs it */
+	/* XXX must make the memory description h/w independent */
+	bootconfig.dram[0].address = memstart;
+	bootconfig.dram[0].pages = memsize / PAGE_SIZE;
+	bootconfig.dramblocks = 1;
+
+	/* process arguments - can update boothowto */
+	process_kernel_args();
+
 	/*
 	 * Since we map the on-board devices VA==PA, and the kernel
 	 * is running VA==PA, it's possible for us to initialize
@@ -490,18 +523,6 @@
 	printf("initarm: Configuring system ...\n");
 #endif
 
-	/* Ensure bootconfig has valid magic */
-	if (passed_bootconfig->magic != BOOTCONFIG_MAGIC)
-		printf("Bad bootconfig magic: %x\n", bootconfig.magic);
-
-	bootconfig = *passed_bootconfig;
-
-	/* Fake bootconfig structure for anything that still needs it */
-	/* XXX must make the memory description h/w independent */
-	bootconfig.dram[0].address = memstart;
-	bootconfig.dram[0].pages = memsize / PAGE_SIZE;
-	bootconfig.dramblocks = 1;
-
 	/*
 	 * Set up the variables that define the availability of
 	 * physical memory.
@@ -808,10 +829,6 @@
 	printf("done.\n");
 #endif
 
-#ifdef BOOTHOWTO
-	boothowto = BOOTHOWTO;
-#endif
-
 #ifdef DDB
 	db_machine_init();
 	if (boothowto & RB_KDB)
@@ -820,6 +837,9 @@
 
 	iyonix_pic_init();
 
+	printf("args: %s\n", bootconfig.args);
+	printf("howto: %x\n", boothowto);
+
 	/* We return the new stack pointer address */
 	return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
 }
@@ -827,9 +847,6 @@
 void
 consinit(void)
 {
-	static const bus_addr_t comcnaddrs[] = {
-		IYONIX_UART1,		/* com0 */
-	};
 	static int consinit_called;
 
 	if (consinit_called != 0)
@@ -837,6 +854,23 @@
 
 	consinit_called = 1;
 
+	/* We let consinit_<foo> worry about device numbers */
+	if (strncmp(boot_consdev, "genfb", 5) &&
+	    strncmp(boot_consdev, "com", 3))
+	        strcpy(boot_consdev, DEFAULT_CONSDEV);
+
+	if (!strncmp(boot_consdev, "com", 3)) 
+		consinit_com(boot_consdev);
+	else
+		consinit_genfb(boot_consdev);
+}
+
+static void
+consinit_com(const char *consdev)
+{
+	static const bus_addr_t comcnaddrs[] = {
+		IYONIX_UART1,		/* com0 */
+	};
 	/*
 	 * Console devices are mapped VA==PA.  Our devmap reflects
 	 * this, so register it now so drivers can map the console
@@ -844,6 +878,9 @@
 	 */
 	pmap_devmap_register(iyonix_devmap);
 
+	/* When we support more than the first serial port as console,
+	 * we should check consdev for a number.
+	 */
 #if NCOM > 0
 	if (comcnattach(&obio_bs_tag, comcnaddrs[comcnunit], comcnspeed,
 	    COM_FREQ, COM_TYPE_NORMAL, comcnmode))
@@ -853,12 +890,56 @@
 #else
 	panic("serial console @%lx not configured", comcnaddrs[comcnunit]);
 #endif
+
 #if KGDB
 #if NCOM > 0
 	if (strcmp(kgdb_devname, "com") == 0) {
 		com_kgdb_attach(&obio_bs_tag, kgdb_devaddr, kgdb_devrate,
-				COM_FREQ, COM_TYPE_NORMAL, kgdb_devmode);
+		    COM_FREQ, COM_TYPE_NORMAL, kgdb_devmode);
 	}
 #endif	/* NCOM > 0 */
 #endif	/* KGDB */
 }
+
+static void
+consinit_genfb(const char *consdev)
+{
+	/* NOTYET */
+}
+
+static void
+process_kernel_args(void)
+{
+	char *args;
+
+	/* Ok now we will check the arguments for interesting parameters. */
+	args = bootconfig.args;
+
+#ifdef BOOTHOWTO
+	boothowto = BOOTHOWTO;
+#else
+	boothowto = 0;
+#endif
+
+	/* Only arguments itself are passed from the bootloader */
+	while (*args == ' ')
+		++args;
+
+	boot_args = args;
+	parse_mi_bootargs(boot_args);
+	parse_iyonix_bootargs(boot_args);
+}
+
+static void
+parse_iyonix_bootargs(char *args)
+{
+	char *ptr;
+
+	if (get_bootconf_option(args, "consdev", BOOTOPT_TYPE_STRING, &ptr))
+	{
+		/* ptr may have trailing clutter */
+		strlcpy(boot_consdev, ptr, sizeof(boot_consdev));
+		if ( (ptr = strchr(boot_consdev, ' ')) )
+			*ptr = 0;
+	}
+}

Reply via email to