Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm Contribution from Petri Laakso:



details:   https://anonhg.NetBSD.org/src/rev/d5fc5667cf86
branches:  trunk
changeset: 785110:d5fc5667cf86
user:      jkunz <jkunz%NetBSD.org@localhost>
date:      Sat Feb 23 16:22:38 2013 +0000

description:
Contribution from Petri Laakso:
- Support for passing kernel arguments.
- entropy_init() removed as OLINUXINO doesn't generate entropy bits without
  user interaction.
- FIFO contents are flushed when DEBUG is enabled.

diffstat:

 sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c |   50 +--
 sys/arch/evbarm/stand/bootimx23/Makefile                  |    9 +-
 sys/arch/evbarm/stand/bootimx23/args_prep.c               |  182 ++++++++++++++
 sys/arch/evbarm/stand/bootimx23/boot_prep.c               |    4 +-
 sys/arch/evbarm/stand/bootimx23/common.c                  |   21 +-
 sys/arch/evbarm/stand/bootimx23/common.h                  |   10 +-
 6 files changed, 231 insertions(+), 45 deletions(-)

diffs (truncated from 403 to 300 lines):

diff -r e7cc4e99ebc2 -r d5fc5667cf86 sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c
--- a/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c Sat Feb 23 14:58:11 2013 +0000
+++ b/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c Sat Feb 23 16:22:38 2013 +0000
@@ -1,4 +1,4 @@
-/* $Id: imx23_olinuxino_machdep.c,v 1.1 2012/11/20 19:08:45 jkunz Exp $ */
+/* $Id: imx23_olinuxino_machdep.c,v 1.2 2013/02/23 16:22:38 jkunz Exp $ */
 
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
 #include <sys/param.h>
 #include <sys/reboot.h>
 #include <sys/rnd.h>
+#include <sys/systm.h>
 #include <sys/termios.h>
 #include <sys/types.h>
 
@@ -94,11 +95,11 @@
 static vm_offset_t physical_freestart;
 static vm_offset_t physical_freeend;
 static u_int free_pages;
-//static rndsave_t imx23_boot_rsp;
 
 BootConfig bootconfig;
 vm_offset_t physical_start;
 vm_offset_t physical_end;
+static char kernel_boot_args[MAX_BOOT_STRING];
 char *boot_args;
 paddr_t msgbufphys;
 
@@ -142,6 +143,9 @@
 #define        KERNEL_VM_BASE  (KERNEL_BASE + 0x01000000)
 #define KERNEL_VM_SIZE         (0xf0000000 - KERNEL_VM_BASE)
 
+#define L1_PAGE_TABLE (DRAM_BASE + MEMSIZE * 1024 * 1024 - L1_TABLE_SIZE)
+#define BOOTIMX23_ARGS (L1_PAGE_TABLE - MAX_BOOT_STRING - 1)
+
 #define REG_RD(reg) *(volatile uint32_t *)(reg)
 #define REG_WR(reg, val)                                               \
 do {                                                                   \
@@ -163,7 +167,6 @@
        cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
 
        consinit();
-       //entropy_init();
 
        /* Talk to the user. */
 #define BDSTR(s)       _BDSTR(s)
@@ -172,7 +175,14 @@
 #undef BDSTR
 #undef _BDSTR
 
-       boot_args[0] = '\0';
+       /* Copy boot arguments passed from bootimx23. */
+       boot_args = (char *)BOOTIMX23_ARGS;
+       memcpy(kernel_boot_args, boot_args, MAX_BOOT_STRING);
+       boot_args = kernel_boot_args;
+#ifdef VERBOSE_INIT_ARM
+       printf("boot_args: %s\n", boot_args);
+#endif
+       parse_mi_bootargs(boot_args);
 
 #ifdef VERBOSE_INIT_ARM
        printf("initarm: Configuring system ...\n");
@@ -520,38 +530,6 @@
 }
 
 /*
- * Generate initial random bits for rnd_init().
- */
-#ifdef notyet
-static void
-entropy_init(void)
-{
-       uint32_t tmp;
-       int loop, index;
-
-       /* Test if HW_DIGCTL_ENTROPY is feeding random numbers. */
-       tmp = REG_RD(HW_DIGCTL_BASE + HW_DIGCTL_ENTROPY);
-       if (tmp == REG_RD(HW_DIGCTL_BASE + HW_DIGCTL_ENTROPY))
-               return;
-
-       index = 0;
-       for (loop = 0; loop < RND_SAVEWORDS; loop++) {
-               imx23_boot_rsp.data[index++] = (uint8_t)(tmp);
-               imx23_boot_rsp.data[index++] = (uint8_t)(tmp>>8);
-               imx23_boot_rsp.data[index++] = (uint8_t)(tmp>>16);
-               imx23_boot_rsp.data[index++] = (uint8_t)(tmp>>24);
-               imx23_boot_rsp.entropy += 32;
-               tmp = REG_RD(HW_DIGCTL_BASE + HW_DIGCTL_ENTROPY);
-       }
-
-       extern rndsave_t *boot_rsp;
-       boot_rsp = &imx23_boot_rsp;
-
-       return;
-}
-#endif
-
-/*
  * Initialize console.
  */
 static struct plcom_instance imx23_pi = {
diff -r e7cc4e99ebc2 -r d5fc5667cf86 sys/arch/evbarm/stand/bootimx23/Makefile
--- a/sys/arch/evbarm/stand/bootimx23/Makefile  Sat Feb 23 14:58:11 2013 +0000
+++ b/sys/arch/evbarm/stand/bootimx23/Makefile  Sat Feb 23 16:22:38 2013 +0000
@@ -1,15 +1,16 @@
-# $Id: Makefile,v 1.4 2013/02/06 07:19:19 matt Exp $
+# $Id: Makefile,v 1.5 2013/02/23 16:22:39 jkunz Exp $
 
 S=             ${.CURDIR}/../../../../
 PROG=          bootimx23
-SRCS=          boot_prep.c power_prep.c clock_prep.c emi_prep.c \
-               pinctrl_prep.c common.c
+SRCS=          args_prep.c boot_prep.c clock_prep.c common.c emi_prep.c \
+               pinctrl_prep.c power_prep.c
 
 .include <bsd.own.mk>
 
 CLEANFILES+=   ${PROG}
 CFLAGS+=       -Wall -Wno-main -ffreestanding -march=armv5te -mtune=arm926ej-s
-CPPFLAGS+=     -D_STANDALONE
+CPPFLAGS+=     -D_STANDALONE -DMEMSIZE=64
+CPPFLAGS+=     -DKERNEL_BOOT_ARGS=\"root=ld0a\"
 CPPFLAGS+=     -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S} -I${S}/arch
 CPPFLAGS+=     -mabi=apcs-gnu -mfloat-abi=soft
 #CPPFLAGS+=    -DDEBUG
diff -r e7cc4e99ebc2 -r d5fc5667cf86 sys/arch/evbarm/stand/bootimx23/args_prep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbarm/stand/bootimx23/args_prep.c       Sat Feb 23 16:22:38 2013 +0000
@@ -0,0 +1,182 @@
+/* $Id: args_prep.c,v 1.1 2013/02/23 16:22:39 jkunz Exp $ */
+
+/*
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Petri Laakso.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* (c) for ngets() below:
+ *
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)gets.c      8.1 (Berkeley) 6/11/93
+ */
+
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+#include <lib/libsa/stand.h>
+#include <lib/libkern/libkern.h>
+
+#include <arm/arm32/pte.h>
+#define _LOCORE
+#include <arm/imx/imx23var.h>
+#undef _LOCORE
+#include <evbarm/bootconfig.h>
+
+#include <arm/imx/imx23_digctlreg.h>
+#include <arm/imx/imx23_uartdbgreg.h>
+
+#include "common.h"
+
+static void ngets(char *, int);
+
+#define L1_PAGE_TABLE (DRAM_BASE + MEMSIZE * 1024 * 1024 - L1_TABLE_SIZE)
+#define BOOTIMX23_ARGS (L1_PAGE_TABLE - MAX_BOOT_STRING - 1)
+
+#define PROMPT_DELAY 5000000 /* Wait 5 seconds user to press any key. */
+
+int
+args_prep(void)
+{
+       u_int prompt;
+       char *boot_args = (char *)BOOTIMX23_ARGS;
+
+       /* Copy default boot arguments. */
+       memset((void *)boot_args, 0x00, MAX_BOOT_STRING);
+       strcpy(boot_args, KERNEL_BOOT_ARGS);
+
+       prompt = 0;
+
+       /* Enable debug UART data reception which was not enabled by the ROM. */
+       uint16_t cr = REG_RD_HW(HW_UARTDBG_BASE + HW_UARTDBGCR);
+       cr |= HW_UARTDBGCR_RXE;
+       REG_WR_HW(HW_UARTDBG_BASE + HW_UARTDBGCR, cr);
+
+       printf("Press any key to drop into boot prompt...\n\r");
+
+       REG_WR(HW_DIGCTL_BASE + HW_DIGCTL_MICROSECONDS_CLR, 0xFFFFFFFF);
+
+       while (REG_RD(HW_DIGCTL_BASE + HW_DIGCTL_MICROSECONDS) < PROMPT_DELAY) {
+               if (!(REG_RD_HW(HW_UARTDBG_BASE + HW_UARTDBGFR) &
+                   HW_UARTDBGFR_RXFE)) {
+                       /* RX FIFO is not empty, some key was pressed. */
+                       REG_RD(HW_UARTDBG_BASE + HW_UARTDBGDR); /* Flush. */
+                       prompt = 1;
+                       break;
+               }
+       }
+       
+       if (prompt) {
+               memset((void *)boot_args, 0x00, MAX_BOOT_STRING);
+               printf("boot: ");
+               ngets(boot_args, MAX_BOOT_STRING);
+       }
+
+       return 0;
+}
+
+/*
+ * gets() with constrained input length.
+ *
+ * Copied from: sys/arch/ia64/stand/common/gets.c
+ */
+static void
+ngets(char *buf, int n)
+{
+       int c;
+       char *lp;
+
+       for (lp = buf;;) {
+               switch (c = getchar() & 0177) {
+               case '\n':
+               case '\r':
+                       *lp = '\0';
+                       putchar('\n');
+                       return;
+               case '\b':
+               case '\177':
+                       if (lp > buf) {
+                               lp--;
+                               putchar('\b');
+                               putchar(' ');
+                               putchar('\b');
+                       }
+                       break;
+               case 'r'&037: {
+                       char *p;
+
+                       putchar('\n');
+                       for (p = buf; p < lp; ++p)
+                               putchar(*p);
+                       break;
+               }
+               case 'u'&037:



Home | Main Index | Thread Index | Old Index