The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/mips/rt305x/rt305x_machdep.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (C) 2010-2011 by Aleksandr Rybalko. All rights reserved.
    3  * Copyright (C) 2007 by Oleksandr Tymoshenko. All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   17  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
   18  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   20  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   22  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   23  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   24  * THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  */
   27 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD$");
   30 
   31 #include "opt_ddb.h"
   32 
   33 #include <sys/param.h>
   34 #include <sys/conf.h>
   35 #include <sys/kernel.h>
   36 #include <sys/systm.h>
   37 #include <sys/imgact.h>
   38 #include <sys/bio.h>
   39 #include <sys/buf.h>
   40 #include <sys/bus.h>
   41 #include <sys/cpu.h>
   42 #include <sys/cons.h>
   43 #include <sys/exec.h>
   44 #include <sys/ucontext.h>
   45 #include <sys/proc.h>
   46 #include <sys/kdb.h>
   47 #include <sys/ptrace.h>
   48 #include <sys/reboot.h>
   49 #include <sys/signalvar.h>
   50 #include <sys/sysent.h>
   51 #include <sys/sysproto.h>
   52 #include <sys/user.h>
   53 
   54 #include <vm/vm.h>
   55 #include <vm/vm_object.h>
   56 #include <vm/vm_page.h>
   57 
   58 #include <machine/cache.h>
   59 #include <machine/clock.h>
   60 #include <machine/cpu.h>
   61 #include <machine/cpuinfo.h>
   62 #include <machine/cpufunc.h>
   63 #include <machine/cpuregs.h>
   64 #include <machine/hwfunc.h>
   65 #include <machine/intr_machdep.h>
   66 #include <machine/locore.h>
   67 #include <machine/md_var.h>
   68 #include <machine/pte.h>
   69 #include <machine/sigframe.h>
   70 #include <machine/trap.h>
   71 #include <machine/vmparam.h>
   72 
   73 #include <mips/rt305x/rt305xreg.h>
   74 #include <mips/rt305x/rt305x_sysctlvar.h>
   75 
   76 extern int      *edata;
   77 extern int      *end;
   78 static char     boot1_env[0x1000];
   79 
   80 
   81 void
   82 platform_cpu_init()
   83 {
   84         /* Nothing special */
   85 }
   86 
   87 static void
   88 mips_init(void)
   89 {
   90         int i;
   91         char *memsize;
   92 
   93         printf("entry: mips_init()\n");
   94 
   95         if ((memsize = kern_getenv("memsize")) != NULL)
   96                 realmem = btoc(strtol(memsize, NULL, 0) << 20);
   97         else
   98                 realmem = btoc(32 << 20);
   99         
  100 
  101         bootverbose = 1;
  102 
  103         for (i = 0; i < 10; i++) {
  104                 phys_avail[i] = 0;
  105         }
  106 
  107         /* phys_avail regions are in bytes */
  108         dump_avail[0] = phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end);
  109         dump_avail[1] = phys_avail[1] = ctob(realmem);
  110 
  111         physmem = realmem;
  112 
  113         init_param1();
  114         init_param2(physmem);
  115         mips_cpu_init();
  116         pmap_bootstrap();
  117         mips_proc0_init();
  118         mutex_init();
  119         kdb_init();
  120 #ifdef KDB
  121         if (boothowto & RB_KDB)
  122                 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
  123 #endif
  124 }
  125 
  126 void
  127 platform_reset(void)
  128 {
  129 
  130 #if !defined(MT7620) && !defined(RT5350)
  131         __asm __volatile("li    $25, 0xbf000000");
  132         __asm __volatile("j     $25");
  133 #else
  134         rt305x_sysctl_set(SYSCTL_RSTCTRL, 1);
  135         while (1);
  136 #endif
  137 }
  138 
  139 void
  140 platform_start(__register_t a0 __unused, __register_t a1 __unused, 
  141     __register_t a2 __unused, __register_t a3 __unused)
  142 {
  143         vm_offset_t kernend;
  144         uint64_t platform_counter_freq = PLATFORM_COUNTER_FREQ;
  145         int i;
  146         int argc = a0;
  147         char **argv = (char **)MIPS_PHYS_TO_KSEG0(a1);
  148         char **envp = (char **)MIPS_PHYS_TO_KSEG0(a2);
  149 
  150         /* clear the BSS and SBSS segments */
  151         kernend = (vm_offset_t)&end;
  152         memset(&edata, 0, kernend - (vm_offset_t)(&edata));
  153 
  154         mips_postboot_fixup();
  155 
  156         /* Initialize pcpu stuff */
  157         mips_pcpu0_init();
  158 
  159         mips_timer_early_init(platform_counter_freq / 2);
  160 
  161         /* initialize console so that we have printf */
  162         boothowto |= (RB_SERIAL | RB_MULTIPLE); /* Use multiple consoles */
  163         boothowto |= (RB_VERBOSE);
  164         cninit();
  165 
  166         init_static_kenv(boot1_env, sizeof(boot1_env));
  167 
  168         printf("U-Boot args (from %d args):\n", argc - 1);
  169 
  170         if (argc == 1)
  171                 printf("\tNone\n");
  172 
  173         for (i = 1; i < argc; i++) {
  174                 char *n = "argv  ", *arg;
  175 
  176                 if (i > 99)
  177                         break;
  178 
  179                 if (argv[i])
  180                 {
  181                         arg = (char *)(intptr_t)MIPS_PHYS_TO_KSEG0(argv[i]);
  182                         printf("\targv[%d] = %s\n", i, arg);
  183                         sprintf(n, "argv%d", i);
  184                         kern_setenv(n, arg);
  185                 }
  186         }
  187 
  188         printf("Environment:\n");
  189 
  190         for (i = 0; envp[i] && MIPS_IS_VALID_PTR(envp[i]); i++) {
  191                 char *n, *arg;
  192 
  193                 arg = (char *)(intptr_t)MIPS_PHYS_TO_KSEG0(envp[i]);
  194                 if (! MIPS_IS_VALID_PTR(arg))
  195                         continue;
  196                 printf("\t%s\n", arg);
  197                 n = strsep(&arg, "=");
  198                 if (arg == NULL)
  199                         kern_setenv(n, "1");
  200                 else
  201                         kern_setenv(n, arg);
  202         }
  203 
  204 
  205         mips_init();
  206         mips_timer_init_params(platform_counter_freq, 1);
  207 }

Cache object: c5b48f798bc97891ec484163510f98c9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.