machdep.c revision 178471
1178172Simp    /*	$OpenBSD: machdep.c,v 1.33 1998/09/15 10:58:54 pefo Exp $	*/
2178172Simp/* tracked to 1.38 */
3178172Simp/*
4178172Simp * Copyright (c) 1988 University of Utah.
5178172Simp * Copyright (c) 1992, 1993
6178172Simp *	The Regents of the University of California.  All rights reserved.
7178172Simp *
8178172Simp * This code is derived from software contributed to Berkeley by
9178172Simp * the Systems Programming Group of the University of Utah Computer
10178172Simp * Science Department, The Mach Operating System project at
11178172Simp * Carnegie-Mellon University and Ralph Campbell.
12178172Simp *
13178172Simp * Redistribution and use in source and binary forms, with or without
14178172Simp * modification, are permitted provided that the following conditions
15178172Simp * are met:
16178172Simp * 1. Redistributions of source code must retain the above copyright
17178172Simp *    notice, this list of conditions and the following disclaimer.
18178172Simp * 2. Redistributions in binary form must reproduce the above copyright
19178172Simp *    notice, this list of conditions and the following disclaimer in the
20178172Simp *    documentation and/or other materials provided with the distribution.
21178172Simp * 4. Neither the name of the University nor the names of its contributors
22178172Simp *    may be used to endorse or promote products derived from this software
23178172Simp *    without specific prior written permission.
24178172Simp *
25178172Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28178172Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35178172Simp * SUCH DAMAGE.
36178172Simp *
37178172Simp *	from: @(#)machdep.c	8.3 (Berkeley) 1/12/94
38178172Simp *	Id: machdep.c,v 1.33 1998/09/15 10:58:54 pefo Exp
39178172Simp *	JNPR: machdep.c,v 1.11.2.3 2007/08/29 12:24:49 girish
40178172Simp */
41178172Simp
42178172Simp#include <sys/cdefs.h>
43178172Simp__FBSDID("$FreeBSD: head/sys/mips/mips/machdep.c 178471 2008-04-25 05:18:50Z jeff $");
44178172Simp
45178172Simp#include "opt_md.h"
46178172Simp#include "opt_ddb.h"
47178172Simp
48178172Simp#include <sys/param.h>
49178172Simp#include <sys/proc.h>
50178172Simp#include <sys/systm.h>
51178172Simp#include <sys/buf.h>
52178172Simp#include <sys/bus.h>
53178172Simp#include <sys/conf.h>
54178172Simp#include <sys/cpu.h>
55178172Simp#include <sys/kernel.h>
56178172Simp#include <sys/linker.h>
57178172Simp#include <sys/malloc.h>
58178172Simp#include <sys/mbuf.h>
59178172Simp#include <sys/msgbuf.h>
60178172Simp#include <sys/reboot.h>
61178172Simp#include <sys/sched.h>
62178172Simp#include <sys/sysctl.h>
63178172Simp#include <sys/sysproto.h>
64178172Simp#include <sys/vmmeter.h>
65178172Simp
66178172Simp#include <vm/vm.h>
67178172Simp#include <vm/vm_kern.h>
68178172Simp#include <vm/vm_object.h>
69178172Simp#include <vm/vm_page.h>
70178172Simp#include <vm/pmap.h>
71178172Simp#include <vm/vm_map.h>
72178172Simp#include <vm/vm_pager.h>
73178172Simp#include <vm/vm_extern.h>
74178172Simp#include <sys/socket.h>
75178172Simp
76178172Simp#include <sys/user.h>
77178172Simp#include <sys/cons.h>
78178172Simp#include <sys/syslog.h>
79178172Simp#include <machine/cache.h>
80178172Simp#include <machine/cpu.h>
81178172Simp#include <machine/pltfm.h>
82178172Simp#include <net/netisr.h>
83178172Simp#include <machine/md_var.h>
84178172Simp#if 0
85178172Simp#include <machine/defs.h>
86178172Simp#endif
87178172Simp#include <machine/clock.h>
88178172Simp#include <machine/asm.h>
89178172Simp#include <machine/bootinfo.h>
90178172Simp#ifdef DDB
91178172Simp#include <sys/kdb.h>
92178172Simp#include <ddb/ddb.h>
93178172Simp#endif
94178172Simp
95178172Simp#include <sys/random.h>
96178172Simp#include <net/if.h>
97178172Simp
98178172Simp#define	BOOTINFO_DEBUG	0
99178172Simp
100178172Simpchar machine[] = "mips";
101178172SimpSYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class");
102178172Simp
103178172Simpstatic char cpu_model[30];
104178172SimpSYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model");
105178172Simp
106178172Simp#if 0 /* see comment below */
107178172Simpstatic void getmemsize(void);
108178172Simp#endif
109178172Simp
110178172Simpint cold = 1;
111178172Simpint Maxmem;
112178172Simplong realmem = 0;
113178172Simpint cpu_clock = MIPS_DEFAULT_HZ;
114178172SimpSYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
115178172Simp    &cpu_clock, 0, "CPU instruction clock rate");
116178172Simpint clocks_running = 0;
117178172Simp
118178172Simpvm_offset_t kstack0;
119178172Simp
120178172Simp#ifdef SMP
121178172Simpstruct pcpu __pcpu[32];
122178172Simpchar pcpu_boot_stack[KSTACK_PAGES * PAGE_SIZE * (MAXCPU-1)];
123178172Simp#else
124178172Simpstruct pcpu pcpu;
125178172Simpstruct pcpu *pcpup = &pcpu;
126178172Simp#endif
127178172Simp
128178172Simpvm_offset_t phys_avail[10];
129178172Simp#ifdef UNIMPLEMENTED
130178172Simpstruct platform platform;
131178172Simp#endif
132178172Simp
133178172Simpvm_paddr_t	mips_wired_tlb_physmem_start;
134178172Simpvm_paddr_t	mips_wired_tlb_physmem_end;
135178172Simpu_int		need_wired_tlb_page_pool;
136178172Simp
137178172Simpstatic void cpu_startup(void *);
138178172SimpSYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
139178172Simp
140178172Simpstruct kva_md_info kmi;
141178172Simp
142178172Simpint cpucfg;			/* Value of processor config register */
143178172Simpint num_tlbentries = 64;	/* Size of the CPU tlb */
144178172Simpint cputype;
145178172Simp
146178172Simpextern char MipsException[], MipsExceptionEnd[];
147178172Simp
148178172Simp/* TLB miss handler address and end */
149178172Simpextern char MipsTLBMiss[], MipsTLBMissEnd[];
150178172Simp
151178172Simp/* Cache error handler */
152178172Simpextern char MipsCache[], MipsCacheEnd[];
153178172Simp
154178172Simpextern char edata[], end[];
155178172Simp
156178172Simpu_int32_t bootdev;
157178172Simpstruct bootinfo bootinfo;
158178172Simp
159178172Simp
160178172Simpstatic void
161178172Simpcpu_startup(void *dummy)
162178172Simp{
163178172Simp
164178172Simp	if (boothowto & RB_VERBOSE)
165178172Simp		bootverbose++;
166178172Simp
167178172Simp	/*
168178172Simp	 * Good {morning,afternoon,evening,night}.
169178172Simp	 */
170178172Simp	printf("%s", version);
171178172Simp
172178172Simp	printf("real memory  = %lu (%luK bytes)\n", ptoa(Maxmem),
173178172Simp	    ptoa(Maxmem) / 1024);
174178172Simp	realmem = Maxmem;
175178172Simp	/*
176178172Simp	 * Display any holes after the first chunk of extended memory.
177178172Simp	 */
178178172Simp	if (bootverbose) {
179178172Simp		int indx;
180178172Simp
181178172Simp		printf("Physical memory chunk(s):\n");
182178172Simp		for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
183178172Simp			int size1 = phys_avail[indx + 1] - phys_avail[indx];
184178172Simp
185178172Simp			printf("0x%08x - 0x%08x, %u bytes (%u pages)\n",
186178172Simp			    phys_avail[indx], phys_avail[indx + 1] - 1, size1,
187178172Simp			    size1 / PAGE_SIZE);
188178172Simp		}
189178172Simp	}
190178172Simp
191178172Simp	vm_ksubmap_init(&kmi);
192178172Simp
193178172Simp	printf("avail memory = %lu (%luMB)\n", ptoa(cnt.v_free_count),
194178172Simp	    ptoa(cnt.v_free_count) / 1048576);
195178172Simp
196178172Simp	/*
197178172Simp	 * Set up buffers, so they can be used to read disk labels.
198178172Simp	 */
199178172Simp	bufinit();
200178172Simp	vm_pager_bufferinit();
201178172Simp}
202178172Simp
203178172Simp/*
204178172Simp * Shutdown the CPU as much as possible
205178172Simp */
206178172Simpvoid
207178172Simpcpu_reset(void)
208178172Simp{
209178172Simp	for (;;)
210178172Simp		;
211178172Simp}
212178172Simp
213178172Simp/* Get current clock frequency for the given cpu id. */
214178172Simpint
215178172Simpcpu_est_clockrate(int cpu_id, uint64_t *rate)
216178172Simp{
217178172Simp
218178172Simp    return (ENXIO);
219178172Simp}
220178172Simp
221178172Simp/*
222178172Simp * Shutdown the CPU as much as possible
223178172Simp */
224178172Simpvoid
225178172Simpcpu_halt(void)
226178172Simp{
227178172Simp	for (;;)
228178172Simp		;
229178172Simp}
230178172Simp
231178172Simp#ifdef PORT_TO_JMIPS
232178172Simp
233178172Simpstatic int
234178172Simpsysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS)
235178172Simp{
236178172Simp}
237178172Simp
238178172SimpSYSCTL_PROC(_machdep, CPU_ADJKERNTZ, adjkerntz, CTLTYPE_INT | CTLFLAG_RW,
239178172Simp    &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "");
240178172Simp#endif	/* PORT_TO_JMIPS */
241178172Simp
242178172Simp#ifdef PORT_TO_JMIPS
243178172Simp/* art */
244178172SimpSYSCTL_INT(_machdep, CPU_DISRTCSET, disable_rtc_set, CTLFLAG_RW,
245178172Simp    &disable_rtc_set, 0, "");
246178172Simp#endif	/* PORT_TO_JMIPS */
247178172Simp
248178172SimpSYSCTL_STRUCT(_machdep, CPU_BOOTINFO, bootinfo, CTLFLAG_RD, &bootinfo,
249178172Simp    bootinfo, "");
250178172Simp
251178172Simp#ifdef PORT_TO_JMIPS
252178172Simp/* dchu */
253178172SimpSYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock, CTLFLAG_RW,
254178172Simp    &wall_cmos_clock, 0, "");
255178172Simp#endif	/* PORT_TO_JMIPS */
256178172Simp
257178172Simp/*
258178172Simp * Initialize mips and configure to run kernel
259178172Simp */
260178172Simp
261178172Simpvoid
262178172Simpmips_proc0_init(void)
263178172Simp{
264178172Simp	proc_linkup(&proc0, &thread0);
265178172Simp	thread0.td_kstack = kstack0;
266178172Simp	thread0.td_kstack_pages = KSTACK_PAGES - 1;
267178172Simp	if (thread0.td_kstack & (1 << PAGE_SHIFT))
268178172Simp		thread0.td_md.md_realstack = thread0.td_kstack + PAGE_SIZE;
269178172Simp	else
270178172Simp		thread0.td_md.md_realstack = thread0.td_kstack;
271178172Simp	/* Initialize pcpu info of cpu-zero */
272178172Simp#ifdef SMP
273178172Simp	pcpu_init(&__pcpu[0], 0, sizeof(struct pcpu));
274178172Simp#else
275178172Simp	pcpu_init(pcpup, 0, sizeof(struct pcpu));
276178172Simp#endif
277178172Simp	/*
278178172Simp	 * Do not use cpu_thread_alloc to initialize these fields
279178172Simp	 * thread0 is the only thread that has kstack located in KSEG0
280178172Simp	 * while cpu_thread_alloc handles kstack allocated in KSEG2.
281178172Simp	 */
282178172Simp	thread0.td_pcb = (struct pcb *)(thread0.td_md.md_realstack +
283178172Simp	    (thread0.td_kstack_pages - 1) * PAGE_SIZE) - 1;
284178172Simp	thread0.td_frame = &thread0.td_pcb->pcb_regs;
285178172Simp	/*
286178172Simp	 * There is no need to initialize md_upte array for thread0 as it's
287178172Simp	 * located in .bss section and should be explicitly zeroed during
288178172Simp	 * kernel initialization.
289178172Simp	 */
290178172Simp
291178172Simp	PCPU_SET(curthread, &thread0);
292178172Simp	PCPU_SET(curpcb, thread0.td_pcb);
293178172Simp}
294178172Simp
295178172Simpstruct msgbuf *msgbufp=0;
296178172Simp
297178172Simp#if 0
298178172Simp/*
299178172Simp * This code has been moved to the platform_init code.  The only
300178172Simp * thing that's beign done here that hasn't been moved is the wired tlb
301178172Simp * pool stuff.  I'm still trying to understand that feature..., since
302178172Simp * it maps from the end the kernel to 0x08000000 somehow.  But the stuff
303178172Simp * was stripped out, so it is hard to say what's going on....
304178172Simp */
305178172Simpu_int32_t	 freemem_start;
306178172Simp
307178172Simpstatic void
308178172Simpgetmemsize()
309178172Simp{
310178172Simp	vm_offset_t kern_start, kern_end;
311178172Simp	vm_offset_t AllowMem, memsize;
312178172Simp	const char *cp;
313178172Simp	size_t sz;
314178172Simp	int phys_avail_cnt;
315178172Simp
316178172Simp	/* Determine memory layout */
317178172Simp	phys_avail_cnt = 0;
318178172Simp	kern_start = mips_trunc_page(MIPS_CACHED_TO_PHYS(btext));
319178172Simp	if (kern_start < freemem_start)
320178172Simppanic("kernel load address too low, overlapping with memory reserved for FPC IPC\n");
321178172Simp
322178172Simp	if (kern_start > freemem_start) {
323178172Simp		phys_avail[phys_avail_cnt++] = freemem_start;
324178172Simp		/*
325178172Simp		 * Since the stack is setup just before kern_start,
326178172Simp		 * leave some space for stack to grow
327178172Simp		 */
328178172Simp		phys_avail[phys_avail_cnt++] = kern_start - PAGE_SIZE * 3;
329178172Simp		MIPS_DEBUG_PRINT("phys_avail : %p - %p",	\
330178172Simp		    phys_avail[phys_avail_cnt-2], phys_avail[phys_avail_cnt-1]);
331178172Simp	}
332178172Simp
333178172Simp	kern_end = (vm_offset_t) end;
334178172Simp	kern_end = (vm_offset_t) mips_round_page(kern_end);
335178172Simp	MIPS_DEBUG_PRINT("kern_start : 0x%x, kern_end : 0x%x", btext, kern_end);
336178172Simp	phys_avail[phys_avail_cnt++] = MIPS_CACHED_TO_PHYS(kern_end);
337178172Simp
338178172Simp	if (need_wired_tlb_page_pool) {
339178172Simp		mips_wired_tlb_physmem_start = MIPS_CACHED_TO_PHYS(kern_end);
340178172Simp		mips_wired_tlb_physmem_end = 0x08000000;
341178172Simp		MIPS_DEBUG_PRINT("%s: unmapped page start [0x%x]  end[0x%x]\n",\
342178172Simp		   __FUNCTION__, mips_wired_tlb_physmem_start, \
343178172Simp		   mips_wired_tlb_physmem_end);
344178172Simp		if (mips_wired_tlb_physmem_start > mips_wired_tlb_physmem_end)
345178172Simp		panic("Error in Page table page physical address assignment\n");
346178172Simp	}
347178172Simp
348178172Simp	if (bootinfo.bi_memsizes_valid)
349178172Simp		memsize = bootinfo.bi_basemem * 1024;
350178172Simp	else {
351178172Simp		memsize = SDRAM_MEM_SIZE;
352178172Simp	}
353178172Simp
354178172Simp	/*
355178172Simp	 * hw.physmem is a size in bytes; we also allow k, m, and g suffixes
356178172Simp	 * for the appropriate modifiers.
357178172Simp	 */
358178172Simp	if ((cp = getenv("hw.physmem")) != NULL) {
359178172Simp		vm_offset_t sanity;
360178172Simp		char *ep;
361178172Simp
362178172Simp		sanity = AllowMem = strtouq(cp, &ep, 0);
363178172Simp		if ((ep != cp) && (*ep != 0)) {
364178172Simp			switch(*ep) {
365178172Simp			case 'g':
366178172Simp			case 'G':
367178172Simp				AllowMem <<= 10;
368178172Simp			case 'm':
369178172Simp			case 'M':
370178172Simp				AllowMem <<= 10;
371178172Simp			case 'k':
372178172Simp			case 'K':
373178172Simp				AllowMem <<= 10;
374178172Simp				break;
375178172Simp			default:
376178172Simp				AllowMem = sanity = 0;
377178172Simp			}
378178172Simp			if (AllowMem < sanity)
379178172Simp				AllowMem = 0;
380178172Simp		}
381178172Simp		if (!AllowMem || (AllowMem < (kern_end - KERNBASE)))
382178172Simp			printf("Ignoring invalid hw.physmem size of '%s'\n", cp);
383178172Simp	} else
384178172Simp		AllowMem = 0;
385178172Simp
386178172Simp	if (AllowMem)
387178172Simp		memsize = (memsize > AllowMem) ? AllowMem : memsize;
388178172Simp
389178172Simp	phys_avail[phys_avail_cnt++] = SDRAM_ADDR_START + memsize;
390178172Simp	MIPS_DEBUG_PRINT("phys_avail : 0x%x - 0x%x",	\
391178172Simp	    phys_avail[phys_avail_cnt-2], phys_avail[phys_avail_cnt-1]);
392178172Simp	phys_avail[phys_avail_cnt] = 0;
393178172Simp
394178172Simp	physmem = btoc(memsize);
395178172Simp	Maxmem = physmem;
396178172Simp
397178172Simp	/*
398178172Simp	 * Initialize error message buffer (at high end of memory).
399178172Simp	 */
400178172Simp	sz = round_page(MSGBUF_SIZE);
401178172Simp	msgbufp = (struct msgbuf *) pmap_steal_memory(sz);
402178172Simp	msgbufinit(msgbufp, sz);
403178172Simp	printf("%s: msgbufp[size=%d] = 0x%p\n", __FUNCTION__, sz, msgbufp);
404178172Simp}
405178172Simp#endif
406178172Simp
407178172Simp/*
408178172Simp * Initialize the hardware exception vectors, and the jump table used to
409178172Simp * call locore cache and TLB management functions, based on the kind
410178172Simp * of CPU the kernel is running on.
411178172Simp */
412178172Simpvoid
413178172Simpmips_vector_init(void)
414178172Simp{
415178172Simp	/*
416178172Simp	 * Copy down exception vector code.
417178172Simp	 */
418178172Simp	if (MipsTLBMissEnd - MipsTLBMiss > 0x80)
419178172Simp		panic("startup: UTLB code too large");
420178172Simp
421178172Simp	if (MipsCacheEnd - MipsCache > 0x80)
422178172Simp		panic("startup: Cache error code too large");
423178172Simp
424178172Simp	bcopy(MipsTLBMiss, (void *)TLB_MISS_EXC_VEC,
425178172Simp	      MipsTLBMissEnd - MipsTLBMiss);
426178172Simp
427178172Simp#ifdef TARGET_OCTEON
428178172Simp/* Fake, but sufficient, for the 32-bit with 64-bit hardware addresses  */
429178172Simp	bcopy(MipsTLBMiss, (void *)XTLB_MISS_EXC_VEC,
430178172Simp	      MipsTLBMissEnd - MipsTLBMiss);
431178172Simp#endif
432178172Simp
433178172Simp	bcopy(MipsException, (void *)GEN_EXC_VEC,
434178172Simp	      MipsExceptionEnd - MipsException);
435178172Simp
436178172Simp	bcopy(MipsCache, (void *)CACHE_ERR_EXC_VEC,
437178172Simp	      MipsCacheEnd - MipsCache);
438178172Simp
439178172Simp	/*
440178172Simp	 * Clear out the I and D caches.
441178172Simp	 */
442178172Simp	mips_icache_sync_all();
443178172Simp	mips_dcache_wbinv_all();
444178172Simp
445178172Simp	/*
446178172Simp	 * Mask all interrupts. Each interrupt will be enabled
447178172Simp	 * when handler is installed for it
448178172Simp	 */
449178172Simp	set_intr_mask (ALL_INT_MASK);
450178172Simp	/* Clear BEV in SR so we start handling our own exceptions */
451178172Simp	mips_cp0_status_write(mips_cp0_status_read() & ~SR_BOOT_EXC_VEC);
452178172Simp
453178172Simp}
454178172Simp
455178172Simp/*
456178172Simp * Initialise a struct pcpu.
457178172Simp */
458178172Simpvoid
459178172Simpcpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
460178172Simp{
461178172Simp#ifdef SMP
462178172Simp	if (cpuid != 0)
463178172Simp		pcpu->pc_boot_stack = (void *)(pcpu_boot_stack + cpuid *
464178172Simp		    (KSTACK_PAGES * PAGE_SIZE));
465178172Simp#endif
466178172Simp	pcpu->pc_next_asid = 1;
467178172Simp	pcpu->pc_asid_generation = 1;
468178172Simp}
469178172Simp
470178172Simpint
471178172Simpsysarch(struct thread *td, register struct sysarch_args *uap)
472178172Simp{
473178172Simp	return (ENOSYS);
474178172Simp}
475178172Simp
476178172Simpint
477178172Simpfill_dbregs(struct thread *td, struct dbreg *dbregs)
478178172Simp{
479178172Simp
480178172Simp	/* No debug registers on mips */
481178172Simp	return (ENOSYS);
482178172Simp}
483178172Simp
484178172Simpint
485178172Simpset_dbregs(struct thread *td, struct dbreg *dbregs)
486178172Simp{
487178172Simp
488178172Simp	/* No debug registers on mips */
489178172Simp	return (ENOSYS);
490178172Simp}
491178172Simp
492178172Simpint spinco;
493178172Simpvoid
494178172Simpspinlock_enter(void)
495178172Simp{
496178172Simp	struct thread *td;
497178172Simp
498178172Simp	td = curthread;
499178172Simp	if (td->td_md.md_spinlock_count == 0)
500178172Simp		td->td_md.md_saved_intr = disableintr();
501178172Simp	td->td_md.md_spinlock_count++;
502178172Simp	critical_enter();
503178172Simp}
504178172Simp
505178172Simpvoid
506178172Simpspinlock_exit(void)
507178172Simp{
508178172Simp	struct thread *td;
509178172Simp
510178172Simp	td = curthread;
511178172Simp	critical_exit();
512178172Simp	td->td_md.md_spinlock_count--;
513178172Simp	if (td->td_md.md_spinlock_count == 0)
514178172Simp		restoreintr(td->td_md.md_saved_intr);
515178172Simp}
516178172Simp
517178172Simpu_int32_t
518178172Simpget_cyclecount(void)
519178172Simp{
520178172Simp	u_int32_t count;
521178172Simp
522178172Simp	mfc0_macro(count, 9);
523178172Simp	return (count);
524178172Simp}
525178172Simp
526178172Simp/*
527178172Simp * call platform specific code to halt (until next interrupt) for the idle loop
528178172Simp */
529178172Simpvoid
530178471Sjeffcpu_idle(int busy)
531178172Simp{
532178172Simp	if (mips_cp0_status_read() & SR_INT_ENAB)
533178172Simp		__asm __volatile ("wait");
534178172Simp	else
535178172Simp		panic("ints disabled in idleproc!");
536178172Simp}
537178172Simp
538178471Sjeffint
539178471Sjeffcpu_idle_wakeup(int cpu)
540178471Sjeff{
541178471Sjeff
542178471Sjeff	return (0);
543178471Sjeff}
544178471Sjeff
545178172Simpvoid
546178172Simpdumpsys(struct dumperinfo *di __unused)
547178172Simp{
548178172Simp
549178172Simp	printf("Kernel dumps not implemented on this architecture\n");
550178172Simp}
551