示例#1
0
文件: main.c 项目: kevinlawler/kona
int main(int argc,S*argv)
{
  kinit();
  args(argc,argv);
  attend(); //loop on stdin/inet
  R 0;
}
示例#2
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();
}
示例#3
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();
}
示例#4
0
文件: exec.c 项目: chrislusf/push
/*
 * get command line flags, initialize keywords & traps.
 * get values from environment.
 * set $pid, $cflag, $*
 * fabricate bootstrap code and start it (*=(argv);. /usr/lib/rcmain $*)
 * start interpreting code
 */
int
main(int argc, char *argv[])
{
	code bootstrap[32];
	char num[12], *rcmain;
	int i;
	
	/* needed for rcmain later */
	putenv("PLAN9", unsharp("#9"));
	argc = getflags(argc, argv, "ftjSsrdiIlxepvVc:1m:1[command]", 1);
	if(argc==-1)
		usage("[file [arg ...]]");
	if(argv[0][0]=='-')
		flag['l'] = flagset;
	if(flag['I'])
		flag['i'] = 0;
	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
	rcmain = flag['m'] ? flag['m'][0] : Rcmain();
	err = openfd(2);
	kinit();
	Trapinit();
	Vinit();
	inttoascii(num, mypid = getpid());
	pathinit();
	setvar("pid", newword(num, (word *)0));
	setvar("cflag", flag['c']?newword(flag['c'][0], (word *)0)
				:(word *)0);
	setvar("rcname", newword(argv[0], (word *)0));
	i = 0;
	bootstrap[i++].i = 1;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xassign;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xdol;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s = rcmain;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s=".";
	bootstrap[i++].f = Xsimple;
	bootstrap[i++].f = Xexit;
	bootstrap[i].i = 0;
	start(bootstrap, 1, (var *)0);
	/* prime bootstrap argv */
	pushlist();
	argv0 = strdup(argv[0]);
	for(i = argc-1;i!=0;--i) pushword(argv[i]);
	for(;;){
		if(flag['r'])
			pfnc(err, runq);
		runq->pc++;
		(*runq->code[runq->pc-1].f)();
		if(ntrap)
			dotrap();
	}
}
示例#5
0
文件: kernel.c 项目: candraw/fOS
void init_kernel() 
{
    terminal_initialize();

    init_serial(COM1);
    terminal_enable_serial_echo(COM1);

    terminal_printf("fOS version %s\n\n\n", KERNEL_VERSION);

    kinit(end + 4096, end + 4096 + (100 * 4096));

    init_gdt();
    load_gdt();


    load_idt();
    load_isrs();

    irq_install();
    asm volatile ( "sti" );

    timer_install();
    sleep(1);

    keyboard_install();

    init_paging();
    switch_to_paging();
}
示例#6
0
文件: kapi.c 项目: JohnEarnest/kona
K ksk(S s, K x)
{
	K z;
	K y;
	if (!*s) { kinit(); R 0; }
	y = X(s);
	if (!x) R y;
	//z = dv_ex(0, KV(z)[2], x) : z;
	R y;
}
示例#7
0
文件: head64.c 项目: BillTheBest/k42
void  x86_64_start_kernel(char * real_mode_data)
{
	extern void kinit();

	clear_bss(); /* must be the first thing in C and must not depend on .bss to be zero */

	early_printk("booting amd64 k42...\n");
	copy_bootdata(real_mode_data);
	setup_boot_cpu_data();
	pda_init(0);

	kinit();
}
示例#8
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();
}
int main(int argc, char **argv)
{
  double t=0, t0;
  int c;
  time_t now=time(NULL);
  struct tm date=*localtime(&now);

  kinit();

  STARTDATE=caltoj( date.tm_year+1900, date.tm_mon+1, date.tm_mday );
  ENDDATE=caltoj( date.tm_year+1900+1, date.tm_mon+1, date.tm_mday );

  while (1) {
    int option_index = 0;
    static struct option long_options[] = {
      {"start", 1, 0, 's'},
      {"end", 1, 0, 'e'},
      {"spring", 0, 0, 'V'},
      {"vernal", 0, 0, 'V'},
      {"summer", 0, 0, 'S'},
      {"autumn", 0, 0, 'A'},
      {"fall", 0, 0, 'A'},
      {"winter", 0, 0, 'W'},
      {"newmoon", 0, 0, 'N'},
      {"fullmoon", 0, 0, 'F'},
      {"help", 0, 0, 'h'},
      {0, 0, 0, 0}
    };
    c = getopt_long (argc, argv, "s:e:VSAWNFh",
		     long_options, &option_index);
    if (c == -1)
      break;
    switch (c) {
    case 's': 
      if (strptime(optarg, "%Y-%m-%d", &date))
	STARTDATE=caltoj( date.tm_year+1900, date.tm_mon+1, date.tm_mday );
      else
	STARTDATE=atof(optarg); 
      break;
    case 'e':
      if (strptime(optarg, "%Y-%m-%d", &date))
	ENDDATE=caltoj( date.tm_year+1900, date.tm_mon+1, date.tm_mday );
      else
	ENDDATE=atof(optarg); 
      break;
    case 'V': event=SPRING; break;
    case 'S': event=SUMMER; break;
    case 'A': event=AUTUMN; break;
    case 'W': event=WINTER; break;
    case 'N': event=NEWMOON; break;
    case 'F': event=FULLMOON; break;
    case 'h': 
    default:
      printf("conjunct -  find dates of equinox or new/full moon\n"
	     "options:\n"
	     " -s, --start DATE  Julian or ISO 8601 starting date (default today)\n"
	     " -e, --end DATE  ending date (default 1 year from today)\n"
	     " -V, --vernal    find times of spring equinox\n"
	     " -S, --summer    find times of summer solstice\n"
	     " -A, --autumn    find times of autumn equinox\n"
	     " -W, --winter    find times of winter solstice\n"
	     " -F, --fullmoon  find times of full moon\n"
	     " -N, --newmoon   find times of new moon (default)\n");
      exit(0);		     
      break;
    }
  }
  if (STARTDATE >= ENDDATE)
    {
      printf("start date=%f >= end date=%f\n", STARTDATE, ENDDATE);
      exit(1);
    }
  
  objnum = 0;
  //  printf("184:STARTDATE=%6.1f\n", STARTDATE);
  t0 = STARTDATE - (((event==FULLMOON)||(event==NEWMOON))?40:400);
  while( 1 )
    {
      prtflg = 0;
      switch(event)
	{
	case SPRING:
	  t = search( t0, 0.0, 364.0 );
	  break;
	case AUTUMN:
	  t = search( t0, PI, 364.0 );
	  break;
	case WINTER:
	  t = search( t0, -PI/2, 364.0 );
	  break;
	case SUMMER:
	  t = search( t0, PI/2, 364.0 );
	  break;
	case NEWMOON:
	  t = search( t0, 0.0, 27.0 );
	  break;
	case FULLMOON:
	  t = search( t0, PI, 27.0 );
	  break;
	}
      TDT = t;
      if (t > ENDDATE)
	break;
      if (t >= STARTDATE)
	{
	  printf("%.4f ", t);
	  prtflg = 1;
	  jtocal(t);
	}
      t0 = t;
    }
exit(0);
}
示例#10
0
void main() {
    print_str("Start Initializing...", 'A');
    kinit();
    while(1) { }
}
示例#11
0
文件: main.c 项目: JamesLinus/inferno
void
main(int argc, char *argv[])
{
	Dir *db;
	Lsym *l;
	Node *n;
	char buf[128], *s;
	int pid, i;
	char *p;
	char afile[512];

	argv0 = argv[0];
	pid = 0;
	aout = "v.out";
	quiet = 1;
	/* turn off all debugging */
	protodebug = 0;

	mtype = 0;
	ARGBEGIN{
	case 'm':
		mtype = ARGF();
		break;
	case 'w':
		wtflag = 1;
		break;
	case 'l':
		s = ARGF();
		if(s == 0)
			usage();
		lm[nlm++] = s;
		break;
	case 'd':
		p = ARGF();
		if (p == 0)
			usage();
		while (*p) {
			setdbg_opt(*p, 0); /* don't print set message */
			p++;
		}
		break;
	case 'k':
		kernel++;
		break;
	case 'q':
		quiet = 0;
		break;
	case 'r':
		pid = 1;
		remote++;
		kernel++;
		break;
	case 'R':
		pid = 1;
		rdebug++;
		s = ARGF();
		if(s == 0)
			usage();
		remfd = opentty(s, 0);
		if(remfd < 0){
			fprint(2, "acid: can't open %s: %r\n", s);
			exits("open");
		}
		break;
	default:
		usage();
	}ARGEND

	if(argc > 0) {
		if(remote || rdebug)
			aout = argv[0];
		else
		if(isnumeric(argv[0])) {
			pid = atoi(argv[0]);
			sprint(prog, "/proc/%d/text", pid);
			aout = prog;
			if(argc > 1)
				aout = argv[1];
			else if(kernel)
				aout = mysystem();
		}
		else {
			if(kernel) {
				print("-k requires a pid");
				kernel = 0;
			}
			aout = argv[0];
		}
	} else if(rdebug)
		aout = "/386/bpc";
	else if(remote)
		aout = "/mips/bcarrera";

	fmtinstall('x', xfmt);
	fmtinstall('L', Lfmt);
	fmtinstall('f', gfltconv);
	fmtinstall('F', gfltconv);
	fmtinstall('g', gfltconv);
	fmtinstall('G', gfltconv);
	fmtinstall('e', gfltconv);
	fmtinstall('E', gfltconv);
	Binit(&bioout, 1, OWRITE);
	bout = &bioout;

	kinit();
	initialising = 1;
	pushfile(0);
	loadvars();
	installbuiltin();

	if(mtype && machbyname(mtype) == 0)
		print("unknown machine %s", mtype);

	if (attachfiles(aout, pid) < 0)
		varreg();		/* use default register set on error */

	acidlib = getenv("ACIDLIB");
	if(acidlib == nil){
		p = getenv("ROOT");
		if(p == nil)
			p = "/usr/inferno";
		snprint(afile, sizeof(afile)-1, "%s/lib/acid", p);
		acidlib = strdup(afile);
	}

	snprint(afile, sizeof(afile)-1, "%s/port", acidlib);
	loadmodule(afile);
	for(i = 0; i < nlm; i++) {
		if((db = dirstat(lm[i])) != nil) {
			free(db);
			loadmodule(lm[i]);
		} else {
			sprint(buf, "%s/%s", acidlib, lm[i]);
			loadmodule(buf);
		}
	}

	userinit();
	varsym();

	l = look("acidmap");
	if(l && l->proc) {
		n = an(ONAME, ZN, ZN);
		n->sym = l;
		n = an(OCALL, n, ZN);
		execute(n);
	}

	interactive = 1;
	initialising = 0;
	line = 1;

	setup_os_notify();

	for(;;) {
		if(setjmp(err)) {
			Binit(&bioout, 1, OWRITE);
			unwind();
		}
		stacked = 0;

		Bprint(bout, "acid: ");

		if(yyparse() != 1)
			die();
		restartio();

		unwind();
	}
	/* not reached */
}
示例#12
0
文件: main.c 项目: Fluray/NxM
void
main(int argc, char *argv[])
{
	Lsym *l;
	Node *n;
	char *s;
	int pid, i;

	argv0 = argv[0];
	pid = 0;
	aout = "8.out";
	quiet = 1;

	mtype = 0;
	ARGBEGIN{
	case 'm':
		mtype = EARGF(usage());
		break;
	case 'w':
		wtflag = 1;
		break;
	case 'l':
		s = EARGF(usage());
		lm[nlm++] = s;
		break;
	case 'k':
		kernel++;
		break;
	case 'q':
		quiet = 0;
		break;
	case 'r':
		pid = 1;
		remote++;
		kernel++;
		break;
	default:
		usage();
	}ARGEND

	if(argc > 0) {
		if(remote)
			aout = argv[0];
		else
		if(isnumeric(argv[0])) {
			pid = strtol(argv[0], 0, 0);
			snprint(prog, sizeof(prog), "/proc/%d/text", pid);
			aout = prog;
			if(argc > 1)
				aout = argv[1];
			else if(kernel)
				aout = system();
		}
		else {
			if(kernel) {
				fprint(2, "acid: -k requires a pid\n");
				usage();
			}
			aout = argv[0];
		}
	} else
	if(remote)
		aout = "/mips/9ch";

	fmtinstall('x', xfmt);
	fmtinstall('L', Lfmt);
	Binit(&bioout, 1, OWRITE);
	bout = &bioout;

	kinit();
	initialising = 1;
	pushfile(0);
	loadvars();
	installbuiltin();

	if(mtype && machbyname(mtype) == 0)
		print("unknown machine %s", mtype);

	if (attachfiles(aout, pid) < 0)
		varreg();		/* use default register set on error */

	loadmodule("/sys/lib/acid/port");
	loadmoduleobjtype();

	for(i = 0; i < nlm; i++) {
		if(access(lm[i], AREAD) >= 0)
			loadmodule(lm[i]);
		else {
			s = smprint("/sys/lib/acid/%s", lm[i]);
			loadmodule(s);
			free(s);
		}
	}

	userinit();
	varsym();

	l = look("acidmap");
	if(l && l->proc) {
		n = an(ONAME, ZN, ZN);
		n->sym = l;
		n = an(OCALL, n, ZN);
		execute(n);
	}

	interactive = 1;
	initialising = 0;
	line = 1;

	notify(catcher);

	for(;;) {
		if(setjmp(err)) {
			Binit(&bioout, 1, OWRITE);
			unwind();
		}
		stacked = 0;

		Bprint(bout, "acid: ");

		if(yyparse() != 1)
			die();
		restartio();

		unwind();
	}
	/* not reached */
}
示例#13
0
void kmain(multiboot_info_t* mbd, unsigned int magic ) {
    if ( magic != 0x2BADB002 ) {
        // TODO: Hacer un kputs.
        kprint ( "Warning: No se inicializo con GRUB, intentando de todas formas.\n" );
    }

    //Primero tenemos que corregir mbd para que sea una direccion virtual valida
    mbd = (multiboot_info_t*)( PA2KVA( (uint32_t) mbd) );

    //Ahora si, usando mbd que apunta bien a los datos del grub, inicializamos todo
    kinit( mbd );

    kprint("llego\n");
    key_init();

    //Aca asigna Esc a la funcion menu
    key_register(menu, 1);
    //Seteo Fs
    key_register(mostrar_slot,59);
    key_register(mostrar_slot,60);
    key_register(mostrar_slot,61);
    key_register(mostrar_slot,62);
    key_register(mostrar_slot,63);
    key_register(mostrar_slot,64);
    key_register(mostrar_slot,65);
    key_register(mostrar_slot,66);
    key_register(mostrar_slot,67);




    kprint("binding keys done\n");
    if(tty_init(&tty_kernel, menu_in)) {
        panic("fallo  el inicio de las tty");
    }
    //Lanzamos programa para cargar tareas y modificar quantums.
    set_isr_handler( 14, &pf ); // #PF

    // El idle task... siempre listo... :-)
    programs_t idle;
    idle.va_entry = idletask;
    crear_kthread( &idle, 10 );

    //Iniciamos Scheduler
    iniciar_scheduler();

    extern unsigned char ej1[];
    extern unsigned char ej2[];
    extern unsigned char ej3[];
    extern unsigned char ej4[];
    programas[0] = (programs_t *) ej1;
    programas[1]= (programs_t *) ej2;
    programas[2] = (programs_t *) ej3;
    programas[3]= (programs_t *) ej4;
    programas[4]= (programs_t *) ej1;

    set_irq_handler( 0, &timer );
    set_irq_handler( 1, &irq_keyboard );
    menu(1);
    sti();
    //Lanzamos programa menu
    while(1);
}
示例#14
0
文件: lex.c 项目: BGCX261/znos-git
int
main(int argc, char *argv[])
{
	int fd;
	char *p;

	ARGBEGIN{
	case 'C':
		dontcompile++;
		break;
	case 'c':
		mustcompile++;
		break;
	case 'l':
		listing++;
		break;
	default:
		usage();
	}ARGEND;

	fmtinstall('i', iconv);
	fmtinstall('a', aconv);
	kinit();
	pcentry = -1;
	dentry = -1;

	if(argc != 1)
		usage();
	file = argv[0];
	bin = Bopen(file, OREAD);
	if(bin == 0) {
		nerr++;
		print("open: %s: %r\n", file);
		exits("errors");
	}
	p = strrchr(file, '/');
	if(p == nil)
		p = file;
	else
		p++;
	ofile = mkfile(p, ".s", ".dis");
	fd = create(ofile, OWRITE, 0666);
	if(fd < 0) {
		nerr++;
		print("can't create: %s: %r\n", ofile);
		exits("errors");
	}
	Binit(&output, fd, OWRITE);
	bout = &output;
	line = 1;
	yyparse();
	Bterm(bin);
	Bterm(bout);
	close(fd);

	if(nerr != 0){
		remove(ofile);
		exits("errors");
	}

	exits(0);
    
    return 0;
}