📄 startup.c
字号:
#ifndef lintstatic char *sccsid = "@(#)startup.c 4.11 (ULTRIX) 2/28/91";#endif lint/************************************************************************ * * * Copyright (c) 1988 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//* ------------------------------------------------------------------ *//* | Copyright Unpublished, MIPS Computer Systems, Inc. All Rights | *//* | Reserved. This software contains proprietary and confidential | *//* | information of MIPS and its suppliers. Use, disclosure or | *//* | reproduction is prohibited without the prior express written | *//* | consent of MIPS. | *//* ------------------------------------------------------------------ *//* * Modification History: startup.c * * 23-Feb-91 jsd * new allocation scheme for gateway screen buffers * * 15-Nov-90 Randall Brown * Fixed a bug in msize_bitmap where the for loop was not being * broken out of when the first bad page was hit. Also changed * the bitmaplen for REX roms. The bitmaplen is now in bytes for * those roms. * * 13-Sep-90 Joe Szczypek * Added support for new 3max/3min TURBOchannel console callbacks. If * new console ROM present, use rex_getbitmap to get bitmap and bitmaplen, * and use rex_getsystype to get systype. Added a fourth argument as * input to startup. This passes in the base address of the new callback * vector dispatch table. Save all four arguments in globals. * * 17-Aug-90 Randall Brown * Removed cpu check for DS3100 after cninit(), cninit() now works * correctly on DS3100. * * 09-Aug-90 Randall Brown * Added support for 3min - DS_5000_100. * * 21-Jun-90 Paul Grist * fixed bug in msize_bitmap. It was using btoc() to do * calculation, this round up to the next page boundry, so when * the bitmap doesn't fall on a 4k boundry it was putting back * unavialable memory, the result was the bitmap was marked usable * and got stepped on. So on reboots the system thought it had no memory * * 01-May-90 -- Paul Grist * Added support for mipsmate - DS_5100. * * 15-Feb-90 -- Robin * Made a bug fix to allow the DS_5500 to size memory via the * bitmap (same as the 5800). * * 19-Dec-89 -- Fred Canter * Bug fix to last delta. Need 2 PTEs per buffer header not one. * * 18-Dec-89 -- burns * Fixed check of nbuf against sysptsize to exclude the MAXMEM * fudge factor which is incorrect for mips based systems. * * 12-Dec-89 -- burns * Moved out sysptsize to param.c since it is now calculated * based upon physmem from the config file. It needs to be * set in the targetbuild directory, not in a binary file. * * 11-Nov-89 -- Randall Brown * Moved when we call cninit() to after mapinit(), so that cninit() can * do BADDADDR if it needs to. Changed msize_bitmap to ignore the first * 2 long words if we are on a 3max. * * 10-Nov-89 -- jaw * remove references to maxcpu. * * 16-Oct-89 -- Alan Frechette * No longer dump out the buffer cache during a system crash * for partial selective crash dumps. Save the PFN of the last * kernel page to dump out for the crashdump code. Readjusted * the order of allocation so that the buffer cache is allocated * last. The buffer cache must be the last allocated data for * this to work. * * 13-Oct-89 -- gmm * smp support * * 10-July-89 -- burns * Added memory sizing via bitmap, and added afd's separate cpu * switch troutines for sizing memory via badaddr probes or bitmap. * * 30-Jun-89 -- afd * Call memsize routine (to size and clear memory) thru the cpu switch. * Added 2 new memory sizing rotines: msize_baddr and msize_bitmap. * * 15-Jun-89 -- afd * Call cpu_initialize() routine as soon as "cpup" is set up in startup(). * * 14-Jun-89 -- darrell * Removed the splhigh in startup, as spl() cannot be called yet, * * 14 Jun 89 -- chet * Make buffer header allocations based on maxcpu (uniprocessor * or multiprocessor). * * 01-Jun-89 -- Kong * Added a field in the "save_state" struct to store the value * of "cpu". This is to allow the ULTRIX installation program * "finder" to determine the type of machine it is running on * without doing a name list on the kernel. "save_state" is * initialised by "init_restartblk". * * 08-Jun-89 -- gmm * Allocate (KMALLOC) the idle stack for boot cpu during startup * * 02-May-89 -- jaw, jmartin * fix forkutl to work on mips. * * 20-May-89 -- Randall Brown * added call to cninit(), so that the cons_swp is setup correctly. * printf's can not be done before this call is executed. * * 17-Apr-89 -- afd * Created "save_state" struct at the bottom of the ULTRIX startup stack. * This struct contains a magic number and the address of "doadump". * This allows people to force a memory dump from console mode when * a system is hung. * * 07-Apr-89 -- afd * Updated system_type routine. * Don't need "system.h"; cpu & systype info is in cpuconf.h * Added "cpuswitch_entry" routine to initialize the pointer into * the cpusw table (cpup). * * 07-Apr-89 -- kong * Added global variable "qmapbase" which gets initialised to * the physical address of the Qbus map registers. Changed * routine "mapinit" so that on a kn210, the last 32K bytes * of physical memory is not used by the kernel, but is used * by the Qbus as map registers. Note that the Qbus map must * sit on a 32Kb boundary. * * 24-Mar-89 -- burns * Added ISIS specifics. * * 23-Mar-89 -- Kong * Added variable "sysptsize" and initialize it to SYSPTSIZE. * Some of the VAX i/o device drivers need it. * * 23-Feb-89 -- Kong * Added variable "Physmem" so that the "sizer" program knows * the actual size of physical memory. * * 12-Jan-89 -- Kong * .Added variable "cpu" whose value is defined in system.h. * Determine on what we are running and properly initialize "cpu". * .Based on the system type, initialize all the interrupt handler * entry points in c0vec_tbl (in trap.c). This way each different * system can use different handlers. * .Initialized the interrupt masks based on the type of system * we're on. This allows the different interrupt schemes of the * different systems to use the same splxxx routines. * * 10 Nov 88 -- chet * Add configurable buffer cache. * * 09-Nov-88 -- afd * Get the "systype" word from the boot PROM, and save it in * "cpu_systype". * This is done in startup because it must be done before the first * autoconfig printf so that the error log packet with config messages * will have the systype in the header. * * 09-Sep-88 -- afd * Cleanup startup msgs; no configuration printfs until after kmeminit(), * because the kernel printf routine does a km_alloc. * Set & clear appendflg so that startup msgs get logged together. * Set "printstate" to what level of printing is possible as the system * comes up. * Call chk_cpe() after configuration is done (records cache parity errs). * */#include "../machine/reg.h"#include "../machine/pte.h"#include "../machine/cpu.h"#include "../machine/hwconf.h"#include "../../machine/common/cpuconf.h"#include "../h/param.h"#include "../h/systm.h"#include "../h/user.h"#include "../h/gnode.h"#include "../h/dir.h"#include "../h/kernel.h"#include "../h/map.h"#include "../h/vm.h"#include "../h/proc.h"#include "../h/buf.h"#include "../h/reboot.h"#include "../h/conf.h"#include "../h/file.h"#include "../h/text.h"#include "../h/clist.h"#include "../h/callout.h"#include "../h/cmap.h"#include "../h/mbuf.h"#include "../h/quota.h"#include "../h/cpudata.h"#include "../fs/nfs/dnlc.h"#include "../h/flock.h"#include "../h/dump.h"#include "../machine/param.h"#include "../h/kmalloc.h"#if PROFILING#include "../h/prof.h"#endif PROFILING#include "../machine/entrypt.h"#include "./assym.h"extern Sysmaplimit;unsigned Syssize;extern int sysptsize; /* for device drivers to know */extern struct kmemusage *kmemusage;extern kmeminit();extern int appendflg; /* for logging startup messages */u_int printstate = PROMPRINT; /* what level of printf is available */int Physmem = 0; /* Size of physical memory */#ifdef CACHETRICKSunsigned short icachecnt[MAXCACHE/NBPG];unsigned short dcachecnt[MAXCACHE/NBPG];#endif CACHETRICKSunsigned icachemask, dcachemask;unsigned cpu_systype; /* systype word in boot PROM */int cpu; /* value defined in cpuconf.h */struct cpusw *cpup; /* pointer to cpusw entry */int splm[SPLMSIZE]; /* interrupt masks */struct cpusw *cpuswitch_entry();int qmapbase; /* Physical address of Qbus map regs*/extern int rex_base; /* Base of ROM Executive callback table used by 3max and 3min */extern int rex_magicid; /* Console type id */ char bootctlr[2];char consmagic[4];int ub_argc;char **ub_argv;int console_magic; /* Console id */struct mem_bitmap rex_map[1]; /* allocate a mem_bitmap structure *//* * Machine-dependent startup code. The boot stack is still in use. * The kernel sp in proc 0 U area is setup on return. */startup(argc, argv, envp, vector) int argc; char **argv; char **envp; char **vector;{ unsigned fpage; /* first free physical page */ int i; /* DEBUG */ extern char end[], edata[]; extern char utlbmiss[], eutlbmiss[]; extern char exception[], eexception[]; extern struct pte eSysmap[]; extern icache_size, dcache_size; /* * copy down exception vector code */ bcopy(utlbmiss, UT_VEC, eutlbmiss - utlbmiss); bcopy(exception, E_VEC, eexception - exception); bzero(edata, end - edata); /* zero bss */ /* initialize this cpu as boot processor */ /* * Get the "systype" word from the boot PROM, which contains * the processor type, the system implementation type, firmware * rev and hardware rev. * * Also set "cpu" (the ULTRIX system type) based on both * processor type and system implementation type. * * Initialize "cpup" to point to the cpusw table entry for the system * that we are currently running on. * * As soon as we have "cpup" set, call the cpu initialization routine * to fill in the splm, interupt vector table, ipl mask, etc. * This MUST be done before any spl routines can be called (thus before * any printfs can be done). */ console_magic = (int)envp; /* save console id */ ub_argc = argc; ub_argv = argv; if(console_magic == REX_MAGIC) { rex_base = (int)vector; rex_magicid = (int)envp; cpu_systype = rex_getsystype(); } else { rex_base = 0; rex_magicid=0; cpu_systype = xtob(prom_getenv("systype")); } cpu = system_type(cpu_systype); cpup = cpuswitch_entry(cpu); /* * Cannot call spl() before cpu_initialize is called -- therefore * printf's cannot be done before now. */ cpu_initialize(); /* init_boot_cpu() will call splextreme, so make sure spls are setup */ /* initialize this cpu as boot processor. 'cpu' should be setup before calling init_boot_cpu */ init_boot_cpu(); config_cache(); icachemask = (icache_size - 1) >> PGSHIFT; dcachemask = (dcache_size - 1) >> PGSHIFT; flush_cache(); /* * Acknowledge all interrupts */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -