idt_machdep.c revision 202849
1178173Simp/*- 2178173Simp * Copyright (C) 2007 by Oleksandr Tymoshenko. All rights reserved. 3178173Simp * 4178173Simp * Redistribution and use in source and binary forms, with or without 5178173Simp * modification, are permitted provided that the following conditions 6178173Simp * are met: 7178173Simp * 1. Redistributions of source code must retain the above copyright 8178173Simp * notice, this list of conditions and the following disclaimer. 9178173Simp * 2. Redistributions in binary form must reproduce the above copyright 10178173Simp * notice, this list of conditions and the following disclaimer in the 11178173Simp * documentation and/or other materials provided with the distribution. 12178173Simp * 13178173Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14178173Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15178173Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16178173Simp * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 17178173Simp * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18178173Simp * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19178173Simp * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20178173Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21178173Simp * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 22178173Simp * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23178173Simp * THE POSSIBILITY OF SUCH DAMAGE. 24178173Simp * 25178173Simp * $Id: $ 26178173Simp * 27178173Simp */ 28178173Simp 29178173Simp#include <sys/cdefs.h> 30178173Simp__FBSDID("$FreeBSD: head/sys/mips/idt/idt_machdep.c 202849 2010-01-23 00:18:12Z imp $"); 31178173Simp 32178173Simp#include "opt_ddb.h" 33178173Simp 34178173Simp#include <sys/param.h> 35178173Simp#include <sys/conf.h> 36178173Simp#include <sys/kernel.h> 37178173Simp#include <sys/systm.h> 38178173Simp#include <sys/imgact.h> 39178173Simp#include <sys/bio.h> 40178173Simp#include <sys/buf.h> 41178173Simp#include <sys/bus.h> 42178173Simp#include <sys/cpu.h> 43178173Simp#include <sys/cons.h> 44178173Simp#include <sys/exec.h> 45178173Simp#include <sys/ucontext.h> 46178173Simp#include <sys/proc.h> 47178173Simp#include <sys/kdb.h> 48178173Simp#include <sys/ptrace.h> 49178173Simp#include <sys/reboot.h> 50178173Simp#include <sys/signalvar.h> 51178173Simp#include <sys/sysent.h> 52178173Simp#include <sys/sysproto.h> 53178173Simp#include <sys/user.h> 54178173Simp 55178173Simp#include <vm/vm.h> 56178173Simp#include <vm/vm_object.h> 57178173Simp#include <vm/vm_page.h> 58178173Simp#include <vm/vm_pager.h> 59178173Simp 60178173Simp#include <machine/cache.h> 61178173Simp#include <machine/clock.h> 62178173Simp#include <machine/cpu.h> 63178173Simp#include <machine/cpuinfo.h> 64178173Simp#include <machine/cpufunc.h> 65178173Simp#include <machine/cpuregs.h> 66178173Simp#include <machine/hwfunc.h> 67178173Simp#include <machine/intr_machdep.h> 68178173Simp#include <machine/locore.h> 69178173Simp#include <machine/md_var.h> 70178173Simp#include <machine/pte.h> 71178173Simp#include <machine/sigframe.h> 72178173Simp#include <machine/trap.h> 73178173Simp#include <machine/vmparam.h> 74178173Simp 75178173Simpextern int *edata; 76178173Simpextern int *end; 77178173Simp 78178173Simpvoid 79202027Simpplatform_cpu_init() 80202027Simp{ 81202027Simp /* Nothing special */ 82202027Simp} 83202027Simp 84202027Simpvoid 85178173Simpplatform_halt(void) 86178173Simp{ 87178173Simp 88178173Simp} 89178173Simp 90178173Simp 91178173Simpvoid 92178173Simpplatform_identify(void) 93178173Simp{ 94178173Simp 95178173Simp} 96178173Simp 97178173Simpvoid 98178173Simpplatform_reset(void) 99178173Simp{ 100178173Simp volatile unsigned int * p = (void *)0xb8008000; 101178173Simp /* 102178173Simp * TODO: we should take care of TLB stuff here. Otherwise 103178173Simp * board does not boots properly next time 104178173Simp */ 105178173Simp 106178173Simp /* Write 0x8000_0001 to the Reset register */ 107178173Simp *p = 0x80000001; 108178173Simp 109178173Simp __asm __volatile("li $25, 0xbfc00000"); 110178173Simp __asm __volatile("j $25"); 111178173Simp} 112178173Simp 113178173Simpvoid 114178173Simpplatform_trap_enter(void) 115178173Simp{ 116178173Simp 117178173Simp} 118178173Simp 119178173Simpvoid 120178173Simpplatform_trap_exit(void) 121178173Simp{ 122178173Simp 123178173Simp} 124178173Simp 125178173Simpvoid 126178173Simpplatform_start(__register_t a0, __register_t a1, 127178173Simp __register_t a2 __unused, __register_t a3 __unused) 128178173Simp{ 129178173Simp uint64_t platform_counter_freq; 130178173Simp vm_offset_t kernend; 131178173Simp int argc = a0; 132178173Simp char **argv = (char **)a1; 133178173Simp int i, mem; 134178173Simp 135178173Simp 136178173Simp /* clear the BSS and SBSS segments */ 137178173Simp kernend = round_page((vm_offset_t)&end); 138178173Simp memset(&edata, 0, kernend - (vm_offset_t)(&edata)); 139178173Simp 140202027Simp /* Initialize pcpu stuff */ 141202027Simp mips_pcpu0_init(); 142202027Simp 143178173Simp /* 144178173Simp * Looking for mem=XXM argument 145178173Simp */ 146178173Simp mem = 0; /* Just something to start with */ 147178173Simp for (i=0; i < argc; i++) { 148178173Simp if (strncmp(argv[i], "mem=", 4) == 0) { 149178173Simp mem = strtol(argv[i] + 4, NULL, 0); 150178173Simp break; 151178173Simp } 152178173Simp } 153178173Simp 154178173Simp bootverbose = 1; 155178173Simp if (mem > 0) 156178173Simp realmem = btoc(mem << 20); 157178173Simp else 158178173Simp realmem = btoc(32 << 20); 159178173Simp 160178173Simp for (i = 0; i < 10; i++) { 161178173Simp phys_avail[i] = 0; 162178173Simp } 163178173Simp 164178173Simp /* phys_avail regions are in bytes */ 165178173Simp phys_avail[0] = MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); 166178173Simp phys_avail[1] = ctob(realmem); 167178173Simp 168178173Simp physmem = realmem; 169178173Simp 170178173Simp /* 171178173Simp * ns8250 uart code uses DELAY so ticker should be inititalized 172178173Simp * before cninit. And tick_init_params refers to hz, so * init_param1 173178173Simp * should be called first. 174178173Simp */ 175178173Simp init_param1(); 176178173Simp /* TODO: parse argc,argv */ 177178173Simp platform_counter_freq = 330000000UL; 178178173Simp mips_timer_init_params(platform_counter_freq, 1); 179178173Simp cninit(); 180178173Simp /* Panic here, after cninit */ 181178173Simp if (mem == 0) 182178173Simp panic("No mem=XX parameter in arguments"); 183178173Simp 184178173Simp printf("cmd line: "); 185178173Simp for (i=0; i < argc; i++) 186178173Simp printf("%s ", argv[i]); 187178173Simp printf("\n"); 188178173Simp 189178173Simp init_param2(physmem); 190178173Simp mips_cpu_init(); 191178173Simp pmap_bootstrap(); 192178173Simp mips_proc0_init(); 193178173Simp mutex_init(); 194178173Simp kdb_init(); 195202849Simp#ifdef KDB 196202849Simp if (boothowto & RB_KDB) 197202849Simp kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); 198178173Simp#endif 199178173Simp} 200