idt_machdep.c revision 178173
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/mips32/idt/idt_machdep.c 178173 2008-04-13 07:44:55Z 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 79178173Simpplatform_halt(void) 80178173Simp{ 81178173Simp 82178173Simp} 83178173Simp 84178173Simp 85178173Simpvoid 86178173Simpplatform_identify(void) 87178173Simp{ 88178173Simp 89178173Simp} 90178173Simp 91178173Simpvoid 92178173Simpplatform_reset(void) 93178173Simp{ 94178173Simp volatile unsigned int * p = (void *)0xb8008000; 95178173Simp /* 96178173Simp * TODO: we should take care of TLB stuff here. Otherwise 97178173Simp * board does not boots properly next time 98178173Simp */ 99178173Simp 100178173Simp /* Write 0x8000_0001 to the Reset register */ 101178173Simp *p = 0x80000001; 102178173Simp 103178173Simp __asm __volatile("li $25, 0xbfc00000"); 104178173Simp __asm __volatile("j $25"); 105178173Simp} 106178173Simp 107178173Simpvoid 108178173Simpplatform_trap_enter(void) 109178173Simp{ 110178173Simp 111178173Simp} 112178173Simp 113178173Simpvoid 114178173Simpplatform_trap_exit(void) 115178173Simp{ 116178173Simp 117178173Simp} 118178173Simp 119178173Simpvoid 120178173Simpplatform_start(__register_t a0, __register_t a1, 121178173Simp __register_t a2 __unused, __register_t a3 __unused) 122178173Simp{ 123178173Simp uint64_t platform_counter_freq; 124178173Simp vm_offset_t kernend; 125178173Simp int argc = a0; 126178173Simp char **argv = (char **)a1; 127178173Simp int i, mem; 128178173Simp 129178173Simp 130178173Simp /* clear the BSS and SBSS segments */ 131178173Simp kernend = round_page((vm_offset_t)&end); 132178173Simp memset(&edata, 0, kernend - (vm_offset_t)(&edata)); 133178173Simp 134178173Simp /* 135178173Simp * Looking for mem=XXM argument 136178173Simp */ 137178173Simp mem = 0; /* Just something to start with */ 138178173Simp for (i=0; i < argc; i++) { 139178173Simp if (strncmp(argv[i], "mem=", 4) == 0) { 140178173Simp mem = strtol(argv[i] + 4, NULL, 0); 141178173Simp break; 142178173Simp } 143178173Simp } 144178173Simp 145178173Simp bootverbose = 1; 146178173Simp if (mem > 0) 147178173Simp realmem = btoc(mem << 20); 148178173Simp else 149178173Simp realmem = btoc(32 << 20); 150178173Simp 151178173Simp for (i = 0; i < 10; i++) { 152178173Simp phys_avail[i] = 0; 153178173Simp } 154178173Simp 155178173Simp /* phys_avail regions are in bytes */ 156178173Simp phys_avail[0] = MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); 157178173Simp phys_avail[1] = ctob(realmem); 158178173Simp 159178173Simp physmem = realmem; 160178173Simp 161178173Simp /* 162178173Simp * ns8250 uart code uses DELAY so ticker should be inititalized 163178173Simp * before cninit. And tick_init_params refers to hz, so * init_param1 164178173Simp * should be called first. 165178173Simp */ 166178173Simp init_param1(); 167178173Simp /* TODO: parse argc,argv */ 168178173Simp platform_counter_freq = 330000000UL; 169178173Simp mips_timer_init_params(platform_counter_freq, 1); 170178173Simp cninit(); 171178173Simp /* Panic here, after cninit */ 172178173Simp if (mem == 0) 173178173Simp panic("No mem=XX parameter in arguments"); 174178173Simp 175178173Simp printf("cmd line: "); 176178173Simp for (i=0; i < argc; i++) 177178173Simp printf("%s ", argv[i]); 178178173Simp printf("\n"); 179178173Simp 180178173Simp init_param2(physmem); 181178173Simp mips_cpu_init(); 182178173Simp pmap_bootstrap(); 183178173Simp mips_proc0_init(); 184178173Simp mutex_init(); 185178173Simp#ifdef DDB 186178173Simp kdb_init(); 187178173Simp#endif 188178173Simp} 189