summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2006-10-06 21:16:58 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2006-10-06 21:16:58 +0000
commita77f6519048dfcdeb5c096d064ed65ae402191c6 (patch)
tree124203d5e4c2457aeb16643de85d0acdc89d63b2 /sys/arch
parent52fbcc0a30217287f3923c2d4d95e147f2f82b50 (diff)
a few fixes to get thru the autoconf
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sh/include/db_machdep.h3
-rw-r--r--sys/arch/sh/sh/db_interface.c14
-rw-r--r--sys/arch/sh/sh/interrupt.c4
-rw-r--r--sys/arch/sh/sh/locore_subr.S4
-rw-r--r--sys/arch/sh/sh/pmap.c14
-rw-r--r--sys/arch/sh/sh/sh_machdep.c219
6 files changed, 239 insertions, 19 deletions
diff --git a/sys/arch/sh/include/db_machdep.h b/sys/arch/sh/include/db_machdep.h
index 10afa9cf335..00c485b6bc8 100644
--- a/sys/arch/sh/include/db_machdep.h
+++ b/sys/arch/sh/include/db_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: db_machdep.h,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: db_machdep.h,v 1.12 2006/05/10 06:24:03 skrll Exp $ */
/*
@@ -64,6 +64,7 @@ extern db_regs_t ddb_regs; /* register state */
#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0)
int kdb_trap(int, int, db_regs_t *);
+void db_machine_init (void);
boolean_t inst_call(int);
boolean_t inst_return(int);
boolean_t inst_trap_return(int);
diff --git a/sys/arch/sh/sh/db_interface.c b/sys/arch/sh/sh/db_interface.c
index 2fc8f75241d..d98debebcbc 100644
--- a/sys/arch/sh/sh/db_interface.c
+++ b/sys/arch/sh/sh/db_interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_interface.c,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: db_interface.c,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: db_interface.c,v 1.37 2006/09/06 00:11:49 uwe Exp $ */
/*-
@@ -73,7 +73,7 @@ void db_frame_cmd(db_expr_t, int, db_expr_t, char *);
void __db_print_symbol(db_expr_t);
char *__db_procname_by_asid(int);
-const struct db_command db_machine_command_table[] = {
+struct db_command db_machine_command_table[] = {
{ "tlb", db_tlbdump_cmd, 0, NULL },
{ "cache", db_cachedump_cmd, 0, NULL },
{ "frame", db_frame_cmd, 0, NULL },
@@ -86,6 +86,13 @@ const struct db_command db_machine_command_table[] = {
int db_active;
void
+db_machine_init(void)
+{
+
+ db_machine_commands_install(db_machine_command_table);
+}
+
+void
kdb_printtrap(u_int type, int code)
{
int i;
@@ -139,14 +146,11 @@ kdb_trap(int type, int code, db_regs_t *regs)
return 1;
}
-#if 0
void
Debugger()
{
-
__asm volatile("trapa %0" :: "i"(_SH_TRA_BREAK));
}
-#endif
#define M_BSR 0xf000
#define I_BSR 0xb000
diff --git a/sys/arch/sh/sh/interrupt.c b/sys/arch/sh/sh/interrupt.c
index 8a32d9ac7e1..ab377f13f17 100644
--- a/sys/arch/sh/sh/interrupt.c
+++ b/sys/arch/sh/sh/interrupt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interrupt.c,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: interrupt.c,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: interrupt.c,v 1.18 2006/01/25 00:02:57 uwe Exp $ */
/*-
@@ -66,6 +66,8 @@ int tmu1_intr(void *);
void tmu2_oneshot(void);
int tmu2_intr(void *);
+int netisr;
+
/*
* EVTCODE to intc_intrhand mapper.
* max #76 is SH4_INTEVT_TMU4 (0xb80)
diff --git a/sys/arch/sh/sh/locore_subr.S b/sys/arch/sh/sh/locore_subr.S
index 1f45dd721c7..83e5c565519 100644
--- a/sys/arch/sh/sh/locore_subr.S
+++ b/sys/arch/sh/sh/locore_subr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore_subr.S,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: locore_subr.S,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: locore_subr.S,v 1.28 2006/01/23 22:52:09 uwe Exp $ */
/*-
@@ -230,7 +230,7 @@ ALTENTRY(switch_exit)
.align 2
.L_switch_exit_proc_exit2:
- .long _C_LABEL(proc_exit2)
+ .long _C_LABEL(exit2)
.L_switch_exit_proc0_pcb:
.long _C_LABEL(proc0) + P_MD_PCB
.L_switch_exit_curpcb:
diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c
index 3f432895bb7..993aa056d7d 100644
--- a/sys/arch/sh/sh/pmap.c
+++ b/sys/arch/sh/sh/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */
/*-
@@ -157,6 +157,11 @@ pmap_steal_memory(vsize_t size, vaddr_t *vstart, vaddr_t *vend)
va = SH3_PHYS_TO_P1SEG(pa);
memset((caddr_t)va, 0, size);
+ if (vstart)
+ *vstart = VM_MIN_KERNEL_ADDRESS;
+ if (vend)
+ *vend = VM_MAX_KERNEL_ADDRESS;
+
return (va);
}
@@ -201,13 +206,6 @@ pmap_growkernel(vaddr_t maxkvaddr)
}
void
-pmap_virtual_space(vaddr_t *start, vaddr_t *end)
-{
- *start = VM_MIN_KERNEL_ADDRESS;
- *end = VM_MAX_KERNEL_ADDRESS;
-}
-
-void
pmap_init()
{
/* Initialize pmap module */
diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c
index 74ab7da4861..4b64aaa6648 100644
--- a/sys/arch/sh/sh/sh_machdep.c
+++ b/sys/arch/sh/sh/sh_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh_machdep.c,v 1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $OpenBSD: sh_machdep.c,v 1.2 2006/10/06 21:16:57 mickey Exp $ */
/* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */
/*-
@@ -84,9 +84,13 @@
#include <sys/signalvar.h>
#include <sys/syscallargs.h>
#include <sys/user.h>
+#include <sys/sched.h>
+#include <sys/msg.h>
#include <uvm/uvm_extern.h>
+#include <dev/cons.h>
+
#include <sh/cache.h>
#include <sh/clock.h>
#include <sh/locore.h>
@@ -94,6 +98,23 @@
#include <sh/trap.h>
#include <sh/intr.h>
+#ifdef NBUF
+int nbuf = NBUF;
+#else
+int nbuf = 0;
+#endif
+
+#ifndef BUFCACHEPERCENT
+#define BUFCACHEPERCENT 5
+#endif
+
+#ifdef BUFPAGES
+int bufpages = BUFPAGES;
+#else
+int bufpages = 0;
+#endif
+int bufcachepercent = BUFCACHEPERCENT;
+
/* Our exported CPU info; we can have only one. */
int cpu_arch;
int cpu_product;
@@ -119,6 +140,8 @@ extern char sh3_vector_tlbmiss[], sh3_vector_tlbmiss_end[];
extern char sh4_vector_tlbmiss[], sh4_vector_tlbmiss_end[];
#endif
+caddr_t allocsys(caddr_t);
+
/*
* These variables are needed by /sbin/savecore
*/
@@ -129,6 +152,8 @@ long dumplo; /* blocks */
void
sh_cpu_init(int arch, int product)
{
+ int i;
+
/* CPU type */
cpu_arch = arch;
cpu_product = product;
@@ -140,6 +165,7 @@ sh_cpu_init(int arch, int product)
/* Cache access ops. */
sh_cache_init();
+for(i=0xfffffff;i--;);
/* MMU access ops. */
sh_mmu_init();
@@ -223,7 +249,12 @@ sh_proc0_init()
void
sh_startup()
{
+ u_int loop;
vaddr_t minaddr, maxaddr;
+ caddr_t sysbase;
+ caddr_t size;
+ vsize_t bufsize;
+ int base, residual;
printf("%s", version);
if (*cpu_model != '\0')
@@ -247,7 +278,62 @@ sh_startup()
printf("real mem = %u (%uK)\n", ctob(physmem), ctob(physmem) / 1024);
- minaddr = 0;
+ /*
+ * Find out how much space we need, allocate it,
+ * and then give everything true virtual addresses.
+ */
+ size = allocsys(NULL);
+ sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page((vaddr_t)size));
+ if (sysbase == 0)
+ panic("sh_startup: no room for system tables; %d required",
+ (u_int)size);
+ if ((caddr_t)((allocsys(sysbase) - sysbase)) != size)
+ panic("cpu_startup: system table size inconsistency");
+
+ /*
+ * Now allocate buffers proper. They are different than the above
+ * in that they usually occupy more virtual memory than physical.
+ */
+ bufsize = MAXBSIZE * nbuf;
+ if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(bufsize),
+ NULL, UVM_UNKNOWN_OFFSET, 0,
+ UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
+ UVM_ADV_NORMAL, 0)) != 0)
+ panic("sh_startup: cannot allocate UVM space for buffers");
+ minaddr = (vaddr_t)buffers;
+ /* don't want to alloc more physical mem than needed */
+ if ((bufpages / nbuf) >= btoc(MAXBSIZE))
+ bufpages = btoc(MAXBSIZE) * nbuf;
+
+ base = bufpages / nbuf;
+ residual = bufpages % nbuf;
+ for (loop = 0; loop < nbuf; ++loop) {
+ vsize_t curbufsize;
+ vaddr_t curbuf;
+ struct vm_page *pg;
+
+ /*
+ * Each buffer has MAXBSIZE bytes of VM space allocated. Of
+ * that MAXBSIZE space, we allocate and map (base+1) pages
+ * for the first "residual" buffers, and then we allocate
+ * "base" pages for the rest.
+ */
+ curbuf = (vaddr_t) buffers + (loop * MAXBSIZE);
+ curbufsize = NBPG * ((loop < residual) ? (base+1) : base);
+
+ while (curbufsize) {
+ pg = uvm_pagealloc(NULL, 0, NULL, 0);
+ if (pg == NULL)
+ panic("sh_startup: not enough memory for buffer cache");
+
+ pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
+ VM_PROT_READ|VM_PROT_WRITE);
+ curbuf += PAGE_SIZE;
+ curbufsize -= PAGE_SIZE;
+ }
+ }
+ pmap_update(pmap_kernel());
+
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
@@ -261,8 +347,72 @@ sh_startup()
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, FALSE, NULL);
+ /*
+ * Set up buffers, so they can be used to read disk labels.
+ */
+ bufinit();
+
printf("avail mem = %u (%uK)\n", ptoa(uvmexp.free),
ptoa(uvmexp.free) / 1024);
+ printf("using %d buffers containing %u bytes (%uK) of memory\n",
+ nbuf, bufpages * PAGE_SIZE, bufpages * PAGE_SIZE / 1024);
+}
+
+/*
+ * Allocate space for system data structures. We are given
+ * a starting virtual address and we return a final virtual
+ * address; along the way we set each data structure pointer.
+ *
+ * We call allocsys() with 0 to find out how much space we want,
+ * allocate that much and fill it with zeroes, and then call
+ * allocsys() again with the correct base virtual address.
+ */
+caddr_t
+allocsys(caddr_t v)
+{
+#define valloc(name, type, num) v = (caddr_t)(((name) = (type *)v) + (num))
+
+#ifdef SYSVMSG
+ valloc(msgpool, char, msginfo.msgmax);
+ valloc(msgmaps, struct msgmap, msginfo.msgseg);
+ valloc(msghdrs, struct msg, msginfo.msgtql);
+ valloc(msqids, struct msqid_ds, msginfo.msgmni);
+#endif
+ /*
+ * Determine how many buffers to allocate. We use 10% of the
+ * first 2MB of memory, and 5% of the rest, with a minimum of 16
+ * buffers. We allocate 1/2 as many swap buffer headers as file
+ * i/o buffers.
+ */
+ if (bufpages == 0)
+ bufpages = (btoc(2 * 1024 * 1024) + physmem) *
+ bufcachepercent / 100;
+
+ if (nbuf == 0) {
+ nbuf = bufpages;
+ if (nbuf < 16)
+ nbuf = 16;
+ }
+
+ /* Restrict to at most 35% filled kvm */
+ /* XXX - This needs UBC... */
+ if (nbuf >
+ (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / MAXBSIZE * 35 / 100)
+ nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
+ MAXBSIZE * 35 / 100;
+
+ /* More buffer pages than fits into the buffers is senseless. */
+ if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE)
+ bufpages = nbuf * MAXBSIZE / PAGE_SIZE;
+
+ valloc(buf, struct buf, nbuf);
+ return v;
+}
+
+void
+dumpsys()
+{
+ /* TODO */
}
/*
@@ -455,6 +605,45 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
tf->tf_r15 = stack;
}
+void
+setrunqueue(struct proc *p)
+{
+ int whichq = p->p_priority / PPQ;
+ struct prochd *q;
+ struct proc *prev;
+
+#ifdef DIAGNOSTIC
+ if (p->p_back != NULL || p->p_wchan != NULL || p->p_stat != SRUN)
+ panic("setrunqueue");
+#endif
+ q = &qs[whichq];
+ prev = q->ph_rlink;
+ p->p_forw = (struct proc *)q;
+ q->ph_rlink = p;
+ prev->p_forw = p;
+ p->p_back = prev;
+ whichqs |= 1 << whichq;
+}
+
+void
+remrunqueue(struct proc *p)
+{
+ struct proc *prev, *next;
+ int whichq = p->p_priority / PPQ;
+
+#ifdef DIAGNOSTIC
+ if (((whichqs & (1 << whichq)) == 0))
+ panic("remrunqueue: bit %d not set", whichq);
+#endif
+ prev = p->p_back;
+ p->p_back = NULL;
+ next = p->p_forw;
+ prev->p_forw = next;
+ next->p_back = prev;
+ if (prev == next)
+ whichqs &= ~(1 << whichq);
+}
+
/*
* Jump to reset vector.
*/
@@ -469,3 +658,29 @@ cpu_reset()
#endif
/* NOTREACHED */
}
+
+int
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+ size_t newlen, struct proc *p)
+{
+
+ /* all sysctl names at this level are terminal */
+ if (namelen != 1)
+ return (ENOTDIR); /* overloaded */
+
+ switch (name[0]) {
+ case CPU_CONSDEV: {
+ dev_t consdev;
+ if (cn_tab != NULL)
+ consdev = cn_tab->cn_dev;
+ else
+ consdev = NODEV;
+ return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
+ sizeof consdev));
+ }
+
+ default:
+ return (EOPNOTSUPP);
+ }
+ /* NOTREACHED */
+}