2 * Copyright (c) 2014 Andrew Turner
3 * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
6 * Portions of this software were developed by SRI International and the
7 * University of Cambridge Computer Laboratory under DARPA/AFRL contract
8 * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
10 * Portions of this software were developed by the University of Cambridge
11 * Computer Laboratory as part of the CTSRD Project, with support from the
12 * UK Higher Education Innovation Fund (HEIF).
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "opt_platform.h"
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
41 #include <sys/param.h>
42 #include <sys/systm.h>
48 #include <sys/imgact.h>
50 #include <sys/kernel.h>
51 #include <sys/limits.h>
52 #include <sys/linker.h>
53 #include <sys/msgbuf.h>
56 #include <sys/ptrace.h>
57 #include <sys/reboot.h>
58 #include <sys/rwlock.h>
59 #include <sys/sched.h>
60 #include <sys/signalvar.h>
61 #include <sys/syscallsubr.h>
62 #include <sys/sysent.h>
63 #include <sys/sysproto.h>
64 #include <sys/ucontext.h>
67 #include <vm/vm_kern.h>
68 #include <vm/vm_object.h>
69 #include <vm/vm_page.h>
71 #include <vm/vm_map.h>
72 #include <vm/vm_pager.h>
74 #include <machine/riscvreg.h>
75 #include <machine/cpu.h>
76 #include <machine/kdb.h>
77 #include <machine/machdep.h>
78 #include <machine/pcb.h>
79 #include <machine/reg.h>
80 #include <machine/trap.h>
81 #include <machine/vmparam.h>
82 #include <machine/intr.h>
83 #include <machine/sbi.h>
85 #include <machine/asm.h>
88 #include <machine/fpe.h>
92 #include <dev/fdt/fdt_common.h>
93 #include <dev/ofw/openfirm.h>
96 struct pcpu __pcpu[MAXCPU];
98 static struct trapframe proc0_tf;
100 vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2];
101 vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2];
108 #define DTB_SIZE_MAX (1024 * 1024)
110 #define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
111 vm_paddr_t physmap[PHYSMAP_SIZE];
114 struct kva_md_info kmi;
116 int64_t dcache_line_size; /* The minimum D cache line size */
117 int64_t icache_line_size; /* The minimum I cache line size */
118 int64_t idcache_line_size; /* The minimum cache line size */
121 extern int *initstack_end;
125 uintptr_t mcall_trap(uintptr_t mcause, uintptr_t* regs);
128 mcall_trap(uintptr_t mcause, uintptr_t* regs)
135 cpu_startup(void *dummy)
140 vm_ksubmap_init(&kmi);
142 vm_pager_bufferinit();
145 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
148 cpu_idle_wakeup(int cpu)
155 fill_regs(struct thread *td, struct reg *regs)
157 struct trapframe *frame;
159 frame = td->td_frame;
160 regs->sepc = frame->tf_sepc;
161 regs->sstatus = frame->tf_sstatus;
162 regs->ra = frame->tf_ra;
163 regs->sp = frame->tf_sp;
164 regs->gp = frame->tf_gp;
165 regs->tp = frame->tf_tp;
167 memcpy(regs->t, frame->tf_t, sizeof(regs->t));
168 memcpy(regs->s, frame->tf_s, sizeof(regs->s));
169 memcpy(regs->a, frame->tf_a, sizeof(regs->a));
175 set_regs(struct thread *td, struct reg *regs)
177 struct trapframe *frame;
179 frame = td->td_frame;
180 frame->tf_sepc = regs->sepc;
181 frame->tf_sstatus = regs->sstatus;
182 frame->tf_ra = regs->ra;
183 frame->tf_sp = regs->sp;
184 frame->tf_gp = regs->gp;
185 frame->tf_tp = regs->tp;
187 memcpy(frame->tf_t, regs->t, sizeof(frame->tf_t));
188 memcpy(frame->tf_s, regs->s, sizeof(frame->tf_s));
189 memcpy(frame->tf_a, regs->a, sizeof(frame->tf_a));
195 fill_fpregs(struct thread *td, struct fpreg *regs)
202 if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) {
204 * If we have just been running FPE instructions we will
205 * need to save the state to memcpy it below.
209 memcpy(regs->fp_x, pcb->pcb_x, sizeof(regs->fp_x));
210 regs->fp_fcsr = pcb->pcb_fcsr;
213 memset(regs->fp_x, 0, sizeof(regs->fp_x));
219 set_fpregs(struct thread *td, struct fpreg *regs)
226 memcpy(pcb->pcb_x, regs->fp_x, sizeof(regs->fp_x));
227 pcb->pcb_fcsr = regs->fp_fcsr;
234 fill_dbregs(struct thread *td, struct dbreg *regs)
237 panic("fill_dbregs");
241 set_dbregs(struct thread *td, struct dbreg *regs)
248 ptrace_set_pc(struct thread *td, u_long addr)
251 panic("ptrace_set_pc");
256 ptrace_single_step(struct thread *td)
264 ptrace_clear_single_step(struct thread *td)
272 exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
274 struct trapframe *tf;
280 memset(tf, 0, sizeof(struct trapframe));
283 * We need to set a0 for init as it doesn't call
284 * cpu_set_syscall_retval to copy the value. We also
285 * need to set td_retval for the cases where we do.
287 tf->tf_a[0] = td->td_retval[0] = stack;
288 tf->tf_sp = STACKALIGN(stack);
289 tf->tf_ra = imgp->entry_addr;
290 tf->tf_sepc = imgp->entry_addr;
292 pcb->pcb_fpflags &= ~PCB_FP_STARTED;
295 /* Sanity check these are the same size, they will be memcpy'd to and fro */
296 CTASSERT(sizeof(((struct trapframe *)0)->tf_a) ==
297 sizeof((struct gpregs *)0)->gp_a);
298 CTASSERT(sizeof(((struct trapframe *)0)->tf_s) ==
299 sizeof((struct gpregs *)0)->gp_s);
300 CTASSERT(sizeof(((struct trapframe *)0)->tf_t) ==
301 sizeof((struct gpregs *)0)->gp_t);
302 CTASSERT(sizeof(((struct trapframe *)0)->tf_a) ==
303 sizeof((struct reg *)0)->a);
304 CTASSERT(sizeof(((struct trapframe *)0)->tf_s) ==
305 sizeof((struct reg *)0)->s);
306 CTASSERT(sizeof(((struct trapframe *)0)->tf_t) ==
307 sizeof((struct reg *)0)->t);
309 /* Support for FDT configurations only. */
313 get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
315 struct trapframe *tf = td->td_frame;
317 memcpy(mcp->mc_gpregs.gp_t, tf->tf_t, sizeof(mcp->mc_gpregs.gp_t));
318 memcpy(mcp->mc_gpregs.gp_s, tf->tf_s, sizeof(mcp->mc_gpregs.gp_s));
319 memcpy(mcp->mc_gpregs.gp_a, tf->tf_a, sizeof(mcp->mc_gpregs.gp_a));
321 if (clear_ret & GET_MC_CLEAR_RET) {
322 mcp->mc_gpregs.gp_a[0] = 0;
323 mcp->mc_gpregs.gp_t[0] = 0; /* clear syscall error */
326 mcp->mc_gpregs.gp_ra = tf->tf_ra;
327 mcp->mc_gpregs.gp_sp = tf->tf_sp;
328 mcp->mc_gpregs.gp_gp = tf->tf_gp;
329 mcp->mc_gpregs.gp_tp = tf->tf_tp;
330 mcp->mc_gpregs.gp_sepc = tf->tf_sepc;
331 mcp->mc_gpregs.gp_sstatus = tf->tf_sstatus;
337 set_mcontext(struct thread *td, mcontext_t *mcp)
339 struct trapframe *tf;
343 memcpy(tf->tf_t, mcp->mc_gpregs.gp_t, sizeof(tf->tf_t));
344 memcpy(tf->tf_s, mcp->mc_gpregs.gp_s, sizeof(tf->tf_s));
345 memcpy(tf->tf_a, mcp->mc_gpregs.gp_a, sizeof(tf->tf_a));
347 tf->tf_ra = mcp->mc_gpregs.gp_ra;
348 tf->tf_sp = mcp->mc_gpregs.gp_sp;
349 tf->tf_gp = mcp->mc_gpregs.gp_gp;
350 tf->tf_tp = mcp->mc_gpregs.gp_tp;
351 tf->tf_sepc = mcp->mc_gpregs.gp_sepc;
352 tf->tf_sstatus = mcp->mc_gpregs.gp_sstatus;
358 get_fpcontext(struct thread *td, mcontext_t *mcp)
365 curpcb = curthread->td_pcb;
367 KASSERT(td->td_pcb == curpcb, ("Invalid fpe pcb"));
369 if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) {
371 * If we have just been running FPE instructions we will
372 * need to save the state to memcpy it below.
376 KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
377 ("Non-userspace FPE flags set in get_fpcontext"));
378 memcpy(mcp->mc_fpregs.fp_x, curpcb->pcb_x,
379 sizeof(mcp->mc_fpregs));
380 mcp->mc_fpregs.fp_fcsr = curpcb->pcb_fcsr;
381 mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags;
382 mcp->mc_flags |= _MC_FP_VALID;
390 set_fpcontext(struct thread *td, mcontext_t *mcp)
397 if ((mcp->mc_flags & _MC_FP_VALID) != 0) {
398 curpcb = curthread->td_pcb;
399 /* FPE usage is enabled, override registers. */
400 memcpy(curpcb->pcb_x, mcp->mc_fpregs.fp_x,
401 sizeof(mcp->mc_fpregs));
402 curpcb->pcb_fcsr = mcp->mc_fpregs.fp_fcsr;
403 curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK;
417 if (!sched_runnable())
434 * Flush the D-cache for non-DMA I/O so that the I-cache can
435 * be made coherent later.
438 cpu_flush_dcache(void *ptr, size_t len)
444 /* Get current clock frequency for the given CPU ID. */
446 cpu_est_clockrate(int cpu_id, uint64_t *rate)
449 panic("cpu_est_clockrate");
453 cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
463 if (td->td_md.md_spinlock_count == 0) {
464 td->td_md.md_spinlock_count = 1;
465 td->td_md.md_saved_sstatus_ie = intr_disable();
467 td->td_md.md_spinlock_count++;
475 register_t sstatus_ie;
479 sstatus_ie = td->td_md.md_saved_sstatus_ie;
480 td->td_md.md_spinlock_count--;
481 if (td->td_md.md_spinlock_count == 0)
482 intr_restore(sstatus_ie);
485 #ifndef _SYS_SYSPROTO_H_
486 struct sigreturn_args {
492 sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
500 if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
504 * Make sure the processor mode has not been tampered with and
505 * interrupts have not been disabled.
506 * Supervisor interrupts in user mode are always enabled.
508 sstatus = uc.uc_mcontext.mc_gpregs.gp_sstatus;
509 if ((sstatus & SSTATUS_SPP) != 0)
512 error = set_mcontext(td, &uc.uc_mcontext);
516 set_fpcontext(td, &uc.uc_mcontext);
518 /* Restore signal mask. */
519 kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
521 return (EJUSTRETURN);
525 * Construct a PCB from a trapframe. This is called from kdb_trap() where
526 * we want to start a backtrace from the function that caused us to enter
527 * the debugger. We have the context in the trapframe, but base the trace
528 * on the PCB. The PCB doesn't have to be perfect, as long as it contains
529 * enough for a backtrace.
532 makectx(struct trapframe *tf, struct pcb *pcb)
535 memcpy(pcb->pcb_t, tf->tf_t, sizeof(tf->tf_t));
536 memcpy(pcb->pcb_s, tf->tf_s, sizeof(tf->tf_s));
537 memcpy(pcb->pcb_a, tf->tf_a, sizeof(tf->tf_a));
539 pcb->pcb_ra = tf->tf_ra;
540 pcb->pcb_sp = tf->tf_sp;
541 pcb->pcb_gp = tf->tf_gp;
542 pcb->pcb_tp = tf->tf_tp;
543 pcb->pcb_sepc = tf->tf_sepc;
547 sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
549 struct sigframe *fp, frame;
550 struct sysentvec *sysent;
551 struct trapframe *tf;
561 PROC_LOCK_ASSERT(p, MA_OWNED);
563 sig = ksi->ksi_signo;
564 code = ksi->ksi_code;
566 mtx_assert(&psp->ps_mtx, MA_OWNED);
569 onstack = sigonstack(tf->tf_sp);
571 CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm,
574 /* Allocate and validate space for the signal handler context. */
575 if ((td->td_pflags & TDP_ALTSTACK) != 0 && !onstack &&
576 SIGISMEMBER(psp->ps_sigonstack, sig)) {
577 fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
578 td->td_sigstk.ss_size);
580 fp = (struct sigframe *)td->td_frame->tf_sp;
583 /* Make room, keeping the stack aligned */
585 fp = (struct sigframe *)STACKALIGN(fp);
587 /* Fill in the frame to copy out */
588 get_mcontext(td, &frame.sf_uc.uc_mcontext, 0);
589 get_fpcontext(td, &frame.sf_uc.uc_mcontext);
590 frame.sf_si = ksi->ksi_info;
591 frame.sf_uc.uc_sigmask = *mask;
592 frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) ?
593 ((onstack) ? SS_ONSTACK : 0) : SS_DISABLE;
594 frame.sf_uc.uc_stack = td->td_sigstk;
595 mtx_unlock(&psp->ps_mtx);
596 PROC_UNLOCK(td->td_proc);
598 /* Copy the sigframe out to the user's stack. */
599 if (copyout(&frame, fp, sizeof(*fp)) != 0) {
600 /* Process has trashed its stack. Kill it. */
601 CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp);
607 tf->tf_a[1] = (register_t)&fp->sf_si;
608 tf->tf_a[2] = (register_t)&fp->sf_uc;
610 tf->tf_sepc = (register_t)catcher;
611 tf->tf_sp = (register_t)fp;
613 sysent = p->p_sysent;
614 if (sysent->sv_sigcode_base != 0)
615 tf->tf_ra = (register_t)sysent->sv_sigcode_base;
617 tf->tf_ra = (register_t)(sysent->sv_psstrings -
618 *(sysent->sv_szsigcode));
620 CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_sepc,
624 mtx_lock(&psp->ps_mtx);
628 init_proc0(vm_offset_t kstack)
633 proc_linkup0(&proc0, &thread0);
634 thread0.td_kstack = kstack;
635 thread0.td_pcb = (struct pcb *)(thread0.td_kstack) - 1;
636 thread0.td_pcb->pcb_fpflags = 0;
637 thread0.td_frame = &proc0_tf;
638 pcpup->pc_curpcb = thread0.td_pcb;
642 add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
645 u_int i, insert_idx, _physmap_idx;
647 _physmap_idx = *physmap_idxp;
653 * Find insertion point while checking for overlap. Start off by
654 * assuming the new entry will be added to the end.
656 insert_idx = _physmap_idx;
657 for (i = 0; i <= _physmap_idx; i += 2) {
658 if (base < physmap[i + 1]) {
659 if (base + length <= physmap[i]) {
663 if (boothowto & RB_VERBOSE)
665 "Overlapping memory regions, ignoring second region\n");
670 /* See if we can prepend to the next entry. */
671 if (insert_idx <= _physmap_idx &&
672 base + length == physmap[insert_idx]) {
673 physmap[insert_idx] = base;
677 /* See if we can append to the previous entry. */
678 if (insert_idx > 0 && base == physmap[insert_idx - 1]) {
679 physmap[insert_idx - 1] += length;
684 *physmap_idxp = _physmap_idx;
685 if (_physmap_idx == PHYSMAP_SIZE) {
687 "Too many segments in the physical address map, giving up\n");
692 * Move the last 'N' entries down to make room for the new
695 for (i = _physmap_idx; i > insert_idx; i -= 2) {
696 physmap[i] = physmap[i - 2];
697 physmap[i + 1] = physmap[i - 1];
700 /* Insert the new entry. */
701 physmap[insert_idx] = base;
702 physmap[insert_idx + 1] = base + length;
704 printf("physmap[%d] = 0x%016lx\n", insert_idx, base);
705 printf("physmap[%d] = 0x%016lx\n", insert_idx + 1, base + length);
711 try_load_dtb(caddr_t kmdp, vm_offset_t dtbp)
714 #if defined(FDT_DTB_STATIC)
715 dtbp = (vm_offset_t)&fdt_static_dtb;
718 if (dtbp == (vm_offset_t)NULL) {
719 printf("ERROR loading DTB\n");
723 if (OF_install(OFW_FDT, 0) == FALSE)
724 panic("Cannot install FDT");
726 if (OF_init((void *)dtbp) != 0)
727 panic("OF_init failed with the found device tree");
739 * Fake up a boot descriptor table.
740 * RISCVTODO: This needs to be done via loader (when it's available).
743 fake_preload_metadata(struct riscv_bootparams *rvbp __unused)
746 vm_offset_t zstart = 0, zend = 0;
748 vm_offset_t lastaddr;
750 static uint32_t fake_preload[35];
752 fake_preload[i++] = MODINFO_NAME;
753 fake_preload[i++] = strlen("kernel") + 1;
754 strcpy((char*)&fake_preload[i++], "kernel");
756 fake_preload[i++] = MODINFO_TYPE;
757 fake_preload[i++] = strlen("elf64 kernel") + 1;
758 strcpy((char*)&fake_preload[i++], "elf64 kernel");
760 fake_preload[i++] = MODINFO_ADDR;
761 fake_preload[i++] = sizeof(vm_offset_t);
762 fake_preload[i++] = (uint64_t)(KERNBASE + KERNENTRY);
764 fake_preload[i++] = MODINFO_SIZE;
765 fake_preload[i++] = sizeof(uint64_t);
766 printf("end is 0x%016lx\n", (uint64_t)&end);
767 fake_preload[i++] = (uint64_t)&end - (uint64_t)(KERNBASE + KERNENTRY);
772 if (*(uint32_t *)KERNVIRTADDR == MAGIC_TRAMP_NUMBER) {
773 fake_preload[i++] = MODINFO_METADATA|MODINFOMD_SSYM;
774 fake_preload[i++] = sizeof(vm_offset_t);
775 fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 4);
776 fake_preload[i++] = MODINFO_METADATA|MODINFOMD_ESYM;
777 fake_preload[i++] = sizeof(vm_offset_t);
778 fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 8);
779 lastaddr = *(uint32_t *)(KERNVIRTADDR + 8);
781 zstart = *(uint32_t *)(KERNVIRTADDR + 4);
782 db_fetch_ksymtab(zstart, zend);
786 lastaddr = (vm_offset_t)&end;
787 fake_preload[i++] = 0;
789 preload_metadata = (void *)fake_preload;
795 initriscv(struct riscv_bootparams *rvbp)
797 struct mem_region mem_regions[FDT_MEM_REGIONS];
798 vm_offset_t rstart, rend;
801 vm_offset_t lastaddr;
806 /* Set the module data location */
807 lastaddr = fake_preload_metadata(rvbp);
809 /* Find the kernel address */
810 kmdp = preload_search_by_type("elf kernel");
812 kmdp = preload_search_by_type("elf64 kernel");
814 boothowto = RB_VERBOSE | RB_SINGLE;
815 boothowto = RB_VERBOSE;
820 try_load_dtb(kmdp, rvbp->dtbp_virt);
823 /* Load the physical memory ranges */
827 /* Grab physical memory regions information from device tree. */
828 if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, NULL) != 0)
829 panic("Cannot get physical memory regions");
832 e = s + DTB_SIZE_MAX;
834 for (i = 0; i < mem_regions_sz; i++) {
835 rstart = mem_regions[i].mr_start;
836 rend = (mem_regions[i].mr_start + mem_regions[i].mr_size);
838 if ((rstart < s) && (rend > e)) {
839 /* Exclude DTB region. */
840 add_physmap_entry(rstart, (s - rstart), physmap, &physmap_idx);
841 add_physmap_entry(e, (rend - e), physmap, &physmap_idx);
843 add_physmap_entry(mem_regions[i].mr_start,
844 mem_regions[i].mr_size, physmap, &physmap_idx);
849 /* Set the pcpu data, this is needed by pmap_bootstrap */
851 pcpu_init(pcpup, 0, sizeof(struct pcpu));
853 /* Set the pcpu pointer */
854 __asm __volatile("mv gp, %0" :: "r"(pcpup));
856 PCPU_SET(curthread, &thread0);
858 /* Do basic tuning, hz etc */
863 /* Bootstrap enough of pmap to enter the kernel proper */
864 kernlen = (lastaddr - KERNBASE);
865 pmap_bootstrap(rvbp->kern_l1pt, mem_regions[0].mr_start, kernlen);
869 init_proc0(rvbp->kern_stack);
871 /* set page table base register for thread0 */
872 thread0.td_pcb->pcb_l1addr = \
873 (rvbp->kern_l1pt - KERNBASE + rvbp->kern_phys);
875 msgbufinit(msgbufp, msgbufsize);
877 init_param2(physmem);
880 riscv_init_interrupts();
887 bzero(void *buf, size_t len)