Deleted Added
sdiff udiff text old ( 82016 ) new ( 82902 )
full compact
1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * 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 AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/sparc64/sparc64/machdep.c 82016 2001-08-21 00:07:37Z jake $
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/cons.h>
34#include <sys/kernel.h>
35#include <sys/linker.h>
36#include <sys/lock.h>
37#include <sys/mutex.h>
38#include <sys/pcpu.h>
39#include <sys/proc.h>
40#include <sys/bio.h>
41#include <sys/buf.h>
42#include <sys/ptrace.h>
43#include <sys/signalvar.h>
44#include <sys/sysproto.h>
45#include <sys/timetc.h>
46#include <sys/user.h>
47
48#include <dev/ofw/openfirm.h>
49
50#include <vm/vm.h>
51#include <vm/vm_param.h>
52#include <vm/vm_kern.h>
53#include <vm/vm_object.h>
54#include <vm/vm_page.h>
55#include <vm/vm_map.h>
56#include <vm/vm_pager.h>
57#include <vm/vm_extern.h>
58
59#include <ddb/ddb.h>
60
61#include <machine/bootinfo.h>
62#include <machine/clock.h>
63#include <machine/frame.h>
64#include <machine/intr_machdep.h>
65#include <machine/md_var.h>
66#include <machine/pmap.h>
67#include <machine/pstate.h>
68#include <machine/reg.h>
69#include <machine/tick.h>
70#include <machine/tstate.h>
71
72typedef int ofw_vec_t(void *);
73
74extern char tl0_base[];
75
76extern char _end[];
77
78int physmem = 0;
79int cold = 1;
80long dumplo;
81int Maxmem = 0;
82
83struct mtx Giant;
84struct mtx sched_lock;
85
86struct globaldata __globaldata;
87#define GLOBALSTACK_SZ 128
88u_long __globalstack[GLOBALSTACK_SZ];
89/*
90 * This needs not be aligned as the other user areas, provided that process 0
91 * does not have an fp state (which it doesn't normally).
92 * This constraint is only here for debugging.
93 */
94char user0[UPAGES * PAGE_SIZE] __attribute__ ((aligned (64)));
95struct user *proc0paddr;
96
97vm_offset_t clean_sva;
98vm_offset_t clean_eva;
99
100u_long ofw_vec;
101u_long ofw_tba;
102
103static vm_offset_t buffer_sva;
104static vm_offset_t buffer_eva;
105static vm_offset_t pager_sva;
106static vm_offset_t pager_eva;
107
108static struct timecounter tick_tc;
109
110static timecounter_get_t tick_get_timecount;
111void sparc64_init(struct bootinfo *bi, ofw_vec_t *vec);
112
113static void cpu_startup(void *);
114SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
115
116static void
117cpu_startup(void *arg)
118{
119 vm_offset_t physmem_est;
120 vm_offset_t minaddr;
121 vm_offset_t maxaddr;
122 phandle_t child;
123 phandle_t root;
124 vm_offset_t va;
125 vm_size_t size;
126 char name[32];
127 char type[8];
128 u_int clock;
129 int factor;
130 caddr_t p;
131 int i;
132
133 root = OF_peer(0);
134 for (child = OF_child(root); child != 0; child = OF_peer(child)) {
135 OF_getprop(child, "device_type", type, sizeof(type));
136 if (strcmp(type, "cpu") == 0)
137 break;
138 }
139 if (child == 0)
140 panic("cpu_startup: no cpu\n");
141 OF_getprop(child, "name", name, sizeof(name));
142 OF_getprop(child, "clock-frequency", &clock, sizeof(clock));
143
144 tick_tc.tc_get_timecount = tick_get_timecount;
145 tick_tc.tc_poll_pps = NULL;
146 tick_tc.tc_counter_mask = ~0u;
147 tick_tc.tc_frequency = clock;
148 tick_tc.tc_name = "tick";
149 tc_init(&tick_tc);

--- 5 unchanged lines hidden (view full) ---

155 (clock + 4999) / 1000000, ((clock + 4999) / 10000) % 100);
156#if 0
157 ver = rdpr(ver);
158 printf("manuf: %#lx impl: %#lx mask: %#lx maxtl: %#lx maxwin: %#lx\n",
159 VER_MANUF(ver), VER_IMPL(ver), VER_MASK(ver), VER_MAXTL(ver),
160 VER_MAXWIN(ver));
161#endif
162
163 /*
164 * XXX make most of this MI and move to sys/kern.
165 */
166
167 /*
168 * Calculate callout wheel size.
169 */
170 for (callwheelsize = 1, callwheelbits = 0; callwheelsize < ncallout;

--- 69 unchanged lines hidden (view full) ---

240 callout[i].c_flags = CALLOUT_LOCAL_ALLOC;
241 SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle);
242 }
243
244 for (i = 0; i < callwheelsize; i++)
245 TAILQ_INIT(&callwheel[i]);
246
247 mtx_init(&callout_lock, "callout", MTX_SPIN | MTX_RECURSE);
248
249 bufinit();
250 vm_pager_bufferinit();
251
252 globaldata_register(globalp);
253
254 tick_start(clock, tick_hardclock);
255}
256
257unsigned
258tick_get_timecount(struct timecounter *tc)
259{
260 return ((unsigned)rd(tick));
261}
262

--- 75 unchanged lines hidden (view full) ---

338 * globaldata is tied to %g7. We could therefore also use assignments to
339 * globaldata here.
340 * The alternate %g6 additionally points to a small per-cpu stack that
341 * is used to temporarily store global registers in special spill
342 * handlers.
343 */
344 ps = rdpr(pstate);
345 wrpr(pstate, ps, PSTATE_AG);
346 __asm __volatile("mov %0, %%g7" : : "r" (&__globaldata));
347 __asm __volatile("mov %0, %%g6" : :
348 "r" (&__globalstack[GLOBALSTACK_SZ - 1]));
349 wrpr(pstate, ps, PSTATE_IG);
350 __asm __volatile("mov %0, %%g7" : : "r" (&__globaldata));
351 wrpr(pstate, ps, 0);
352
353 /*
354 * Initialize curproc so that mutexes work.
355 */
356 PCPU_SET(curproc, &proc0);

--- 15 unchanged lines hidden (view full) ---

372{
373 ofw_tba = rdpr(tba);
374 ofw_vec = (u_long)vec;
375}
376
377void
378sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
379{
380 TODO;
381}
382
383#ifndef _SYS_SYSPROTO_H_
384struct sigreturn_args {
385 ucontext_t *ucp;
386};
387#endif
388
389int
390sigreturn(struct proc *p, struct sigreturn_args *uap)
391{
392 TODO;
393 return (0);
394}
395
396void
397cpu_halt(void)
398{
399 TODO;
400}
401

--- 12 unchanged lines hidden (view full) ---

414 TODO;
415 return (0);
416}
417
418void
419setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings)
420{
421 struct pcb *pcb;
422 struct wsframe *fp;
423
424 /* Round the stack down to a multiple of 16 bytes. */
425 stack = ((stack) / 16) * 16;
426 pcb = &p->p_addr->u_pcb;
427 /* XXX: honor the real number of windows... */
428 bzero(pcb->pcb_wscratch, sizeof(pcb->pcb_wscratch));
429 /* The inital window for the process (%cw = 0). */
430 fp = &pcb->pcb_wscratch[0];
431 pcb->pcb_cwp = 1;
432 pcb->pcb_ws_inuse = 1;
433 pcb->pcb_inwinop = 0;
434 /* Make sure the frames that are frobbed are actually flushed. */
435 __asm __volatile("flushw");
436 mtx_lock_spin(&sched_lock);
437 fp_init_proc(pcb);
438 /* Setup state in the trap frame. */
439 p->p_frame->tf_tstate = TSTATE_IE;
440 p->p_frame->tf_tpc = entry;
441 p->p_frame->tf_tnpc = entry + 4;

--- 4 unchanged lines hidden (view full) ---

446 * - the initial %fp should be 0
447 * - the initial %sp should point to the top frame, which should be
448 * 16-byte-aligned
449 * - %g1, if != 0, passes a function pointer which should be registered
450 * with atexit().
451 */
452 bzero(p->p_frame->tf_out, sizeof(p->p_frame->tf_out));
453 bzero(p->p_frame->tf_global, sizeof(p->p_frame->tf_global));
454 p->p_frame->tf_out[6] = stack - SPOFF - sizeof(struct frame);
455 wr(y, 0, 0);
456 /* shouldn't be needed */
457 fp->wsf_sp = stack - SPOFF - sizeof(struct frame);
458 fp->wsf_inuse = 1;
459 mtx_unlock_spin(&sched_lock);
460}
461
462void
463Debugger(const char *msg)
464{
465
466 printf("Debugger(\"%s\")\n", msg);

--- 44 unchanged lines hidden ---