示例#1
0
文件: main.c 项目: KWMalik/Homework-3
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kvmalloc();      // kernel page table
  mpinit();        // collect info about this machine
  lapicinit(mpbcpu());
  seginit();       // set up segments
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  iinit();         // inode cache
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  startothers();    // start other processors (must come before kinit)
  kinit();         // initialize memory allocator
  userinit();      // first user process  (must come after kinit)
  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#2
0
文件: main.c 项目: humphreyja/Xv6
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // collect info about this machine
  lapicinit();
  seginit();       // set up segments
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
  userinit();      // first user process
  mpmain();
  
}
示例#3
0
void kmain (void)
{
    cpu = &cpus[0];

    uart_init (P2V(UART0));

    init_vmm ();
    kpt_freerange (align_up(&end, PT_SZ), P2V_WO(INIT_KERNMAP));
    paging_init (INIT_KERNMAP, PHYSTOP);

    kmem_init ();
    kmem_init2(P2V(INIT_KERNMAP), P2V(PHYSTOP));

    trap_init ();				// vector table and stacks for models
   
    gic_init(P2V(VIC_BASE));			// arm v2 gic init
    uart_enable_rx ();				// interrupt for uart
    consoleinit ();				// console
    pinit ();					// process (locks)

    binit ();					// buffer cache
    fileinit ();				// file table
    iinit ();					// inode cache
    ideinit ();					// ide (memory block device)

#ifdef INCLUDE_REMOVED
    timer_init (HZ);				// the timer (ticker)
#endif

    sti ();
    userinit();					// first user process
    scheduler();				// start running processes
}
示例#4
0
文件: main.c 项目: hosanli/os4
// Bootstrap processor starts running C code here.
int
main(int memsize)
{
  mpinit(); // collect info about this machine
  lapicinit(mpbcpu());
  ksegment();
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  cprintf("cpus %p cpu %p\n", cpus, cpu);
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  cprintf("mem: %d kb\n", memsize);
  kinit(memsize);         // physical memory allocator
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  iinit();         // inode cache
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  pageinit();	   // enable paging
  userinit();      // first user process
  bootothers();    // start other processors

  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#5
0
文件: main.c 项目: hubert-he/xv6
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kinit1(end, P2V(4*1024*1024)); // phys page allocator  // kmem. freelist added
  cprintf("%x \n", end);
  kvmalloc();      // kernel page table
#ifdef CONFIG_MULTI_PROCESS
  mpinit();        // collect info about this machine
#endif
  lapicinit();
  seginit();       // set up segments
  picinit();       // interrupt controller: Programmable Interrupt Controller
#ifdef CONFIG_MULTI_PROCESS
  ioapicinit();    // another interrupt controller
#endif
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  iinit();         // inode cache
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
#ifdef CONFIG_MULTI_PROCESS
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
#endif
  userinit();      // first user process
  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#6
0
文件: main.c 项目: MarcoCBA/Proyectos
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // detect other processors
  lapicinit();     // interrupt controller
  seginit();       // segment descriptors
  cprintf("\ncpu%d: starting xv6\n\n", cpunum());
  picinit();       // another interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // console hardware
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
  userinit();      // first user process
  mpmain();        // finish this processor's setup
  init_semaphores_on_boot();
}
示例#7
0
文件: kernel.c 项目: ismaellc/SOTR
/*int main(void){*/
void kmain(void){
//  vga_init();
//  puts((uint8_t*)"Hello kernel world!\n");
  /*do some work here, like initialize timer or paging*/
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // collect info about this machine
  lapicinit();
//  gdt_descriptor();
//  puts((uint8_t*)"GDT initialized...\n");
//  idt_descriptor();
//  puts((uint8_t*)"IDT initialized...\n");
//  cprintf("IDT initialized...\n");
  seginit();       // set up segments
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
  userinit();      // first user process
  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#8
0
文件: main.c 项目: ismaellc/SOTR
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
	unsigned char FB[]="MESSAGE WRITTEN THROUGH FRAMEBUFFER!!";
	fb_init();       // initialize framebuffer device (2015.11.02)
	cprintf("\nUsing Framebuffer still presents some problems :(\n\n");
	cprintf("\nSuggestion: review the way it is used in console.c\n\n");
	fb_write(FB, sizeof(FB)); // Framebuffer maybe could be used before this moment (2015.11.02)
	see_mylock(MYLOCK);
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // collect info about this machine
  lapicinit();
  seginit();       // set up segments
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
  pinit();         // process table
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
  userinit();      // first user process
  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#9
0
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
    monitor_clear ();

    // Print basic system information.
    cprintf ("Ensidia\n\n");
    cprintf ("Copyright (c) 2013-2014 Fotis Koutoulakis\n");
    cprintf ("Based on xv6 by Russ Cox et al, at MIT CSAIL\n");

    kinit1(end, P2V(4*1024*1024)); // phys page allocator
    kvmalloc();      // kernel page table
    mpinit();        // collect info about this machine
    lapicinit();
    seginit();       // set up segments
    cprintf("\ncpu%d: starting xng kernel\n\n", cpu->id);
    picinit();       // interrupt controller
    ioapicinit();    // another interrupt controller
    consoleinit();   // I/O devices & their interrupts
    uartinit();      // serial port
    pinit();         // process table
    tvinit();        // trap vectors
    binit();         // buffer cache
    fileinit();      // file table
    iinit();         // inode cache
    ideinit();       // disk
    if(!ismp)
        timerinit();   // uniprocessor timer
    startothers();   // start other processors
    kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
    userinit();      // first user process
    // Finish setting up this processor in mpmain.
    mpmain();
}
示例#10
0
文件: main.c 项目: dancrossnyc/harvey
static void
dochaninit(Chan *cp, int fd)
{
	cp->chan = fd;
	fileinit(cp);
	wlock(&cp->reflock);
	wunlock(&cp->reflock);
	lock(&cp->flock);
	unlock(&cp->flock);
}
示例#11
0
文件: fat.c 项目: vrthra/9front-tmp
static int
fatwalk(File *fp, Fat *fat, char *path)
{
	char name[Maxpath], *end;
	int i, j;
	Dir d;

	if(fat->ver == Fat32){
		fileinit(fp, fat, 0);
		fp->clust = fat->dirstart;
		fp->len = ~0U;
	}else{
		fileinit(fp, fat, fat->dirstart);
		fp->len = fat->dirents * Dirsz;
	}
	for(;;){
		if(readn(fp, &d, Dirsz) != Dirsz)
			break;
		if((i = dirname(&d, name)) <= 0)
			continue;
		while(*path == '/')
			path++;
		if((end = strchr(path, '/')) == 0)
			end = path + strlen(path);
		j = end - path;
		if(i == j && memcmp(name, path, j) == 0){
			fileinit(fp, fat, 0);
			fp->clust = dirclust(&d);
			fp->len = *((ulong*)d.len);
			if(*end == 0)
				return 0;
			else if(d.attr & 0x10){
				fp->len = fat->clustsize * Sectsz;
				path = end;
				continue;
			}
			break;
		}
	}
	return -1;
}
示例#12
0
文件: main.c 项目: BaoYu0721/xv6_gui
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // collect info about this machine
  lapicinit();
  seginit();       // set up segments
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  picinit();       // interrupt controller
  ioapicinit();    // another interrupt controller
  consoleinit();   // I/O devices & their interrupts
  uartinit();      // serial port
    initGraphMode();
    initDom();
    tryOnce();
    toggleOn();
  pinit();         // process table
    toggleOn();
  tvinit();        // trap vectors
    toggleOn();
  binit();         // buffer cache
    toggleOn();
  fileinit();      // file table
    toggleOn();
  iinit();         // inode cache
    toggleOn();
  ideinit();       // disk
    toggleOn();
  if(!ismp)
    timerinit();   // uniprocessor timer

    toggleOn();
  startothers();   // start other processors
    toggleOn();
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
    toggleOn();
	
  txt_initLock();
  mouseEnable();

  initProcessMsgMap();


  userinit();      // first user process
    toggleOn();
    endToggle();
  // Finish setting up this processor in mpmain.
  mpmain();
}
示例#13
0
文件: ex.c 项目: n-t-roff/ex-2.2
/*
 * Initialization, before editing a new file.
 * Main thing here is to get a new buffer (in fileinit),
 * rest is peripheral state resetting.
 */
void
init(void)
{
	register int i;

	fileinit();
	dot = zero = truedol = unddol = dol = fendcore;
	one = zero+1;
	undkind = UNDNONE;
	chng = 0;
	edited = 0;
	for (i = 0; i <= 'z'-'a'+1; i++)
		names[i] = 1;
	anymarks = 0;
}
示例#14
0
文件: 9p1.c 项目: dancrossnyc/harvey
void
f_session(Chan *cp, Oldfcall *in, Oldfcall *ou)
{
	if(CHAT(cp))
		print("c_session %d\n", cp->chan);

	memmove(cp->rchal, in->chal, sizeof(cp->rchal));
	if(wstatallow || cp == cons.srvchan){
		memset(ou->chal, 0, sizeof(ou->chal));
		memset(ou->authid, 0, sizeof(ou->authid));
	}else{
		mkchallenge(cp);
		memmove(ou->chal, cp->chal, sizeof(ou->chal));
		memmove(ou->authid, nvr.authid, sizeof(ou->authid));
	}
	sprint(ou->authdom, "%s.%s", service, nvr.authdom);
	fileinit(cp);
}
示例#15
0
文件: main.c 项目: douglasralmeida/uw
// Os procedimentos de inicialização começam a executar o 
// código .C a partir daqui.
// Aloca uma pilha real e troca para ela, primeiro fazendo
// algumas configurações necessárias par o alocador de memória funcionar.
int main(void) {
  kinit1(end, P2V(4*1024*1024)); // alocador de páginas de memória física
  kvmalloc();      // tabela de páginas do kernel
  mpinit();        // detecta outros processadores
  lapicinit();     // controlador de interrupções
  seginit();       // descritores de segmentos
  picinit();       // desabilita pic
  ioapicinit();    // outro controlador de interrupções
  consoleinit();   // console hardware
  uartinit();      // porta serial
  pinit();         // tabela de processos
  tvinit();        // vetores trap
  binit();         // buffer cache
  fileinit();      // tabela de arquivo
  ideinit();       // disco 
  startothers();   // inicia outros processadores
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // deve vir após startothers()
  userinit();      // primeiro processo no modo usuário
  mpmain();        // encerra esta configuração de processadores
}
示例#16
0
文件: ex.c 项目: n-t-roff/ex-3.6
/*
 * Initialization, before editing a new file.
 * Main thing here is to get a new buffer (in fileinit),
 * rest is peripheral state resetting.
 */
void
init(void)
{
	register int i;

	fileinit();
	dot = zero = truedol = unddol = dol = fendcore;
	one = zero+1;
	undkind = UNDNONE;
	chng = 0;
	edited = 0;
	for (i = 0; i <= 'z'-'a'+1; i++)
		names[i] = 1;
	anymarks = 0;
#ifdef CRYPT
        if(xflag) {
                xtflag = 1;
                makekey(key, tperm);
        }
#endif
}
示例#17
0
文件: main.c 项目: sihai/myos
/**
 * Bootstrap processor starts running C code here.
 */
int main(void)
{
	/**
	 * ld会生成如下几个变量用来标识程序的段
	 *
	 *  _etext(etext)	正文段结束后第一个地址
	 *	_edata(edata)	数据段结束后第一个地址
	 *	_end(end)		bss段结束后第一个地址
	 */
	extern char edata[], end[];

  	// clear BSS
  	memset(edata, 0, end - edata);

  	// collect info about this machine
  	mp_init();
  	lapic_init(mp_bcpu());

  	cprintf("\ncpu%d: starting myos\n\n", cpu());
	cprintf("Welcome to myos !\n");

	pinit();         // process table
	binit();         // buffer cache
	pic_init();      // interrupt controller
	ioapic_init();   // another interrupt controller

	kinit();         // physical memory allocator
	tvinit();        // trap vectors
	fileinit();      // file table
	iinit();         // inode cache
	console_init();  // I/O devices & their interrupts
	ide_init();      // disk
	if(!ismp)
			timer_init();  // uniprocessor timer
	userinit();      // first user process
	bootothers();    // start other processors

	// Finish setting up this processor in mpmain.
	mpmain();
}
示例#18
0
文件: dup3d.c 项目: nathanweeks/ast
int
fs3d_dup(int ofd, int nfd)
{
    register Mount_t*	mp;

    if (nfd >= 0 && ofd >= 0 && ofd < elementsof(state.file))
    {
        if (state.cache)
        {
            if (!(state.file[ofd].flags & FILE_OPEN))
                fileinit(ofd, NiL, NiL, 0);
            state.file[nfd] = state.file[ofd];
            state.file[nfd].flags &= ~FILE_CLOEXEC;
            state.file[nfd].reserved = 0;
            if (nfd > state.cache)
                state.cache = nfd;
            if (nfd > state.open)
                state.open = nfd;
            if (mp = state.file[nfd].mount)
                fscall(mp, MSG_dup, nfd, ofd);
            for (mp = state.global; mp; mp = mp->global)
                if (fssys(mp, MSG_dup))
                    fscall(mp, MSG_dup, nfd, ofd);
        }
#if defined(fchdir3d)
        if (state.file[nfd].dir)
        {
            free(state.file[nfd].dir);
            state.file[nfd].dir = 0;
        }
        if (state.file[ofd].dir && (state.file[nfd].dir = newof(0, Dir_t, 1, strlen(state.file[ofd].dir->path))))
        {
            strcpy(state.file[nfd].dir->path, state.file[ofd].dir->path);
            state.file[nfd].dir->dev = state.file[ofd].dir->dev;
            state.file[nfd].dir->ino = state.file[ofd].dir->ino;
        }
#endif
    }
    return 0;
}
示例#19
0
文件: main.c 项目: kglgsp/lab2-f17
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
  kinit1(end, P2V(4*1024*1024)); // phys page allocator
  kvmalloc();      // kernel page table
  mpinit();        // detect other processors
  lapicinit();     // interrupt controller
  seginit();       // segment descriptors
  picinit();       // disable pic
  ioapicinit();    // another interrupt controller
  consoleinit();   // console hardware
  uartinit();      // serial port
  pinit();         // process table
  shminit();       // shared memory
  tvinit();        // trap vectors
  binit();         // buffer cache
  fileinit();      // file table
  ideinit();       // disk 
  startothers();   // start other processors
  kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
  userinit();      // first user process
  mpmain();        // finish this processor's setup
}
示例#20
0
void
devcntrl(FILE *fp)	/* interpret device control functions */
{
	char str[4096];
	int n;

	sget(str, sizeof str, fp);
	switch (str[0]) {	/* crude for now */
	case 'i':	/* initialize */
		fileinit();
		t_init(0);
		break;
	case 'T':	/* device name */
		sget(devname, sizeof devname, fp);
		break;
	case 't':	/* trailer */
		t_trailer();
		break;
	case 'p':	/* pause -- can restart */
		t_reset('p');
		break;
	case 's':	/* stop */
		t_reset('s');
		break;
	case 'r':	/* resolution assumed when prepared */
		fscanf(fp, "%d", &res);
		break;
	case 'f':	/* font used */
		fscanf(fp, "%d", &n);
		sget(str, sizeof str, fp);
		loadfont(n, str);
		break;
	}
	while (getc(fp) != '\n')	/* skip rest of input line */
		;
}
示例#21
0
int
main(int argc, char **argv)
{
	int ch;
	int k, retcode;

	infile = stdin;
	diagfile = stderr;
#if 1 /* RAGGE */
	char file[] = "/tmp/initfile.XXXXXX";
	char buf[100];
	close(mkstemp(file));
	sprintf(buf, "sort > %s", file);
	initfile = popen(buf, "w");
#endif


#define DONE(c)	{ retcode = c; goto finis; }

	while ((ch = getopt(argc, argv, "qw:UuOdpC1I:Z:X:")) != -1)
		switch (ch) {
		case 'q':
			quietflag = YES;
			break;

		case 'w':
			if(optarg[0]=='6' && optarg[1]=='6') {
				ftn66flag = YES;
			} else
				nowarnflag = YES;
			break;

		case 'U':
			shiftcase = NO;
			break;

		case 'u':
			undeftype = YES;
			break;

		case 'O':
			optimflag = YES;
#ifdef notyet
			xdeljumps = 1;
			xtemps = 1;
#endif
			break;

		case 'd':
			debugflag = YES;
			break;

		case 'p':
			profileflag = YES;
			break;

		case 'C':
			checksubs = YES;
			break;

		case '1':
			onetripflag = YES;
			break;

		case 'I':
			if(*optarg == '2')
				tyint = TYSHORT;
			else if(*optarg == '4') {
				shortsubs = NO;
				tyint = TYLONG;
			} else if(*optarg == 's')
				shortsubs = YES;
			else
				fatal1("invalid flag -I%c\n", *optarg);
			tylogical = tyint;
			break;

		case 'Z':	/* pass2 debugging */
			while (*optarg)
				switch (*optarg++) {
				case 'b': /* basic block and SSA building */
					++b2debug;
					break;
				case 'c': /* code printout */
					++c2debug;
					break;
				case 'e': /* print tree upon pass2 enter */
					++e2debug;
					break;
				case 'f': /* instruction matching */
					++f2debug;
					break;
				case 'g':
					++g2debug;
					break;
				case 'n':
					++ndebug;
					break;
				case 'o':
					++o2debug;
					break;
				case 'r': /* register alloc/graph coloring */
					++r2debug;
					break;
				case 's': /* shape matching */
					++s2debug;
					break;
				case 't':
					++t2debug;
					break;
				case 'u': /* Sethi-Ullman debugging */
					++u2debug;
					break;
				case 'x':
					++x2debug;
					break;
				default:
					fprintf(stderr, "unknown Z flag '%c'\n",
					    optarg[-1]);
					exit(1);
				}
			break;

		case 'X':	/* pass1 debugging */
			while (*optarg)
				switch (*optarg++) {
				case 'm': /* memory allocation */
					++mflag;
					break;
				case 't': /* tree debugging */
					tflag++;
					break;
				default:
					usage();
				}
			break;

		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	mkdope();
	initkey();
	if (argc > 0) {
		if (inilex(copys(argv[0])))
			DONE(1);
		if (!quietflag)
			fprintf(diagfile, "%s:\n", argv[0]);
		if (argc != 1)
			if (freopen(argv[1], "w", stdout) == NULL) {
				fprintf(stderr, "open output file '%s':",
				    argv[1]);
				perror(NULL);
				exit(1);
			}
	} else {
		inilex(copys(""));
	}
	fileinit();
	procinit();
	if((k = yyparse())) {
		fprintf(diagfile, "Bad parse, return code %d\n", k);
		DONE(1);
	}
	if(nerr > 0)
		DONE(1);
	if(parstate != OUTSIDE) {
		warn("missing END statement");
		endproc();
	}
	doext();
	preven(ALIDOUBLE);
	prtail();
	puteof();
	DONE(0);


finis:
	pclose(initfile);
	retcode |= dodata(file);
	unlink(file);
	done(retcode);
	return(retcode);
}
示例#22
0
文件: main.c 项目: tim48134/xylos
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
	monitor_clear();
	xylos_logo();

	kinit1(end, P2V(4 * 1024 * 1024)); // phys page allocator, 16MB for kernel
	kvmalloc();      // kernel page table
	mpinit();        // collect info about this machine
	lapicinit();
	seginit();       // set up segments

	cprintf("Initializing interrupts...             ");
	init_generic_irq_table();
	picinit();       // interrupt controller
	ioapicinit();    // another interrupt controller
	cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");

	cprintf("Initializing console and serial...     ");
	consoleinit();   // I/O devices & their interrupts
	uartinit();      // serial port
	cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");

	cprintf("Setting up swap space disk...          ");
	swapinit();
	cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");

	cprintf("Initializing tasking...                ");
	pinit();         // process table
	tvinit();        // trap vectors
	binit();         // buffer cache
	cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");

	cprintf("Initializing pipe IPC...               ");
	init_pipe_ipc_system();
	if(pipe_ipc_sanitycheck() == 0) {
		cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");
	}

	cprintf("Initializing direct IPC...             ");
	init_direct_ipc_table();
	if(direct_ipc_sanitycheck() == 0) {
		cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");
	}

	cprintf("Mounting root filesystem...            ");
	fileinit();      // file table
	ideinit();       // disk
	cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");

	if(!ismp) {
		cprintf("Starting up uniprocessor CPU...        ");
		timerinit();   // uniprocessor timer
		cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");
	}

	if(ismp) {
		if(ncpu > 1) {
			cprintf("Starting up %d CPU cores...             ", ncpu);
		} else {
			cprintf("Starting up %d CPU core...              ", ncpu);
		}
	}

	startothers();   // start other processors
	kinit2(P2V(4 * 1024 * 1024), P2V(PHYSTOP)); // 16MB to PHYSTOP [234MB]

	if(ismp) {
		cprintf_color(COLOR_BLACK, COLOR_LIGHT_GREEN, false, "done\n");
	}

	// detects and starts km drivers
	auto_enable_nic();

	// first user process
	userinit();

	// Finish setting up this processor in mpmain.
	mpmain();


}
示例#23
0
文件: shell.c 项目: inspirer/history
void main()
{
  char s[200],cdir[200]="/",tmp[200];
  int a,b,ID=alloc_console();
  FILE *fp;
  meminit();
  fileinit();

  printf("ChaOS shell ID=%x\n",ID);

  do {
    printf(">");
    gets(s);

    if (!strcmp(s,"exit")) break;

    if (s[0]=='t'&&s[1]=='y'&&s[2]=='p'&&s[3]=='e'&&s[4]==' '){
        fp=fopen(s+5,"rb");
        while((a=fread(tmp,1,199,fp))) for (b=0;b<a;b++) putch(tmp[b]);
        fclose(fp);
        continue;
    }

    if (!strcmp(s,"dir")){
        showdir(cdir);continue;
    }

    if (!strcmp(s,"cls")){
       clrscr();
       continue;
    }

    if (s[0]=='c'&&s[1]=='d'&&s[2]==' '){
      if (s[3]=='.'&&s[4]=='.'&&s[5]==0){
         if (strlen(cdir)<=1) continue;
         b=strlen(cdir);b--;
         cdir[b]=0;
         for(b--;b>=0;b--) if (cdir[b]=='/'){ cdir[b+1]=0;break;}
         continue;
      }

      if (s[3]=='/')
         strcpy(tmp,s+3);
      else
         { strcpy(tmp,cdir);strcat(tmp,s+3);}
      if (tmp[strlen(tmp)-1]!='/') strcat(tmp,"/");
      if (strlen(tmp)>1){
        tmp[strlen(tmp)-1]=0;
        if (findfirst(tmp,&sr,_FF_NORMAL)==0){
           strcpy(cdir,tmp);strcat(cdir,"/");
        } else printf("not found: %s\n",tmp);
      } else strcpy(cdir,tmp);
      continue;
    }

    if (!strcmp(s,"mem")){
      printf("free = %i\n",get_free_mem()<<12);
      continue;
    }

    // Execute
    if (s[0]==0) continue;
    if (s[0]!='/'){ strcpy(tmp,cdir);strcat(tmp,s);strcpy(s,tmp); }
    if ((a=system(s))!=0)
       printf("not found: %s (%x)\n",s,a);

  } while(1);

  free_console(ID);
}