Ejemplo n.º 1
0
void UART_Init(int id, UINT32 baud)
{
    if (id == 0) {
	uart[0] = 0; // open("/dev/tty", O_RDWR);
	tty_init(uart[0], baud);
    }
    else if (id == 1) {
	uart[1] = open("/dev/ttys000", O_RDWR);
	tty_init(uart[1], baud);
    }
    // UART_SetBaud(id, baud);
}
Ejemplo n.º 2
0
u_char
cisco_decrypt(void)
{
     u_char retval;
     time_t start, stop;

     tty_init();
     time(&start);

     /* check if the arg is a valid md5 cisco IOS password */
     if (cisco_is_ios_md5crypt(usr_opt.decryptopt.cipher))
          cipher_engine = cisco_ios_cipher;
     /* check if the arg is a valid md5 PIX password */
     else if (cisco_is_pix_md5crypt(usr_opt.decryptopt.cipher))
          cipher_engine = cisco_pix_cipher;
     else
          tty_error(ERR_USAGE,
                    "neither a Cisco IOS nor a PIX password -- `%s'",
                    usr_opt.decryptopt.cipher);

     retval = (usr_opt.action == decrypt_wl || usr_opt.action == resume_wl) ?
              wordlist() : bruteforce();
     time(&stop);

     if (usr_opt.verbose)
          tty_message("scan time: %g second(s)\n\n", difftime(stop, start));

     return retval;
}
Ejemplo n.º 3
0
Archivo: tty.c Proyecto: Hooman3/minix
/*===========================================================================*
 *		            sef_cb_init_fresh                                *
 *===========================================================================*/
static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
/* Initialize the tty driver. */
  int r;
  char val[CONS_ARG];

  /* Get kernel environment (protected_mode, pc_at and ega are needed). */ 
  if (OK != (r=sys_getmachine(&machine))) {
    panic("Couldn't obtain kernel environment: %d", r);
  }

  if (env_get_param("console", val, sizeof(val)) == OK) {
	set_console_line(val);
  }

  if ((r = env_get_param("kernelclr", val, sizeof(val))) == OK) {
	set_kernel_color(val);
  }

  /* Initialize the TTY driver. */
  tty_init();

  /* Final one-time keyboard initialization. */
  kb_init_once();

  /* Register for diagnostics notifications. */
  sys_diagctl_register();

  return(OK);
}
Ejemplo n.º 4
0
/*
 * Init
 */
static int
console_init(void)
{
	struct bootinfo *bootinfo;

	machine_bootinfo(&bootinfo);
	cols = bootinfo->video.text_x;
	rows = bootinfo->video.text_y;

	esc_index = 0;
	attrib = 0x0F;

	vram = phys_to_virt((void *)VID_RAM);
	reset_cursor();
#if defined(DEBUG) && defined(CONFIG_DIAG_SCREEN)
	debug_attach(console_puts);
#endif
	tty_init(&console_tty);	/* init data */
	console_tty.t_oproc = console_start;
	console_tty.t_winsize.ws_row = (u_short)rows;
	console_tty.t_winsize.ws_col = (u_short)cols;

	console_dev = tty_attach("console", &console_tty);
	tty_dev = tty_attach("tty", &console_tty);
	ASSERT(tty_dev);

	return 0;
}
Ejemplo n.º 5
0
/* ×Ö·ûÉ豸³õʼ»¯ */
long chr_dev_init(long mem_start, long mem_end)
{
	if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
	mem_start = tty_init(mem_start);
#ifdef CONFIG_PRINTER
	mem_start = lp_init(mem_start);
#endif
#if defined (CONFIG_BUSMOUSE) || defined (CONFIG_82C710_MOUSE) || \
    defined (CONFIG_PSMOUSE) || defined (CONFIG_MS_BUSMOUSE) || \
    defined (CONFIG_ATIXL_BUSMOUSE)
	mem_start = mouse_init(mem_start);
#endif
#ifdef CONFIG_SOUND
	mem_start = soundcard_init(mem_start);
#endif
#if CONFIG_TAPE_QIC02
	mem_start = tape_qic02_init(mem_start);
#endif
/*
 *      Rude way to allocate kernel memory buffer for tape device
 */
#ifdef CONFIG_FTAPE
        /* allocate NR_FTAPE_BUFFERS 32Kb buffers at aligned address */
        ftape_big_buffer= (char*) ((mem_start + 0x7fff) & ~0x7fff);
        printk( "ftape: allocated %d buffers alligned at: %p\n",
               NR_FTAPE_BUFFERS, ftape_big_buffer);
        mem_start = (long) ftape_big_buffer + NR_FTAPE_BUFFERS * 0x8000;
#endif 
	return mem_start;
}
Ejemplo n.º 6
0
/*
 * Initialize
 */
static int
serial_init(void)
{

	DPRINTF(("serial_init\n"));

	/* Initialize port */
	if (port_init() == -1)
		return -1;

#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
	debug_attach(diag_print);
#endif

	tty_init(&serial_tty);	/* init data */
	serial_tty.t_oproc = serial_start;
	serial_tty.t_winsize.ws_row = (u_short)TERM_ROWS;
	serial_tty.t_winsize.ws_col = (u_short)TERM_COLS;

	serial_dev = tty_attach("console", &serial_tty);
	tty_dev = tty_attach("tty", &serial_tty);
	ASSERT(tty_dev);

	return 0;
}
Ejemplo n.º 7
0
void command_line_parser(const char* command) {
    if(streq(command, "clear")) {
        tty_init(&task_admin->tasks[0]);
    } else if(streq(command, "free")) {
        printf("\nMem Free:%uM\n", free_mem() / 1024 / 1024);
    } else if(streq(command, "ls")) {
        printf("\n\tName\tType\tDate\t\tSize\n");
        struct DirectoryEntry* en = floppy_read(ROOT_DIRECTORY, 14);

        while(1) {
            if(en->name[0] == 0)
                break;

            char name[9], type[4];
            uint32_t mon = en->wtime >> 8;
            uint32_t day = en->wtime & 0xff;
            memcpy(name, en->name, 8);
            memcpy(type, en->name + 8, 3);
            name[8] = '\0';
            type[3] = '\0';
            printf("%s\t%s\t%u-%u-%u\t%u\n", name, type, en->wdate, mon, day, en->fsize);
            en++;
        }

        printf("\n");
    } else if(streqn(command, "./", 2) && strlen(command + 2) > 0) {
Ejemplo n.º 8
0
Archivo: kernel.c Proyecto: ajxs/jxos
void kernel_init(boot_info_t bootInfo) {
	tty_init();

	multiboot_init(bootInfo.multiboot_magic, bootInfo.multiboot_addr);
	if(a20_enable()) {
		serial_writestring(1, "A20 enable failed - triggering panic\n");
		kernel_panic();
	};
	gdt_install();
	idt_install();
	irq_install();
	_protected_mode_init();

	paging_init();
	_paging_enable();

	PIC_init();
	serial_init();
	keyboard_init();
	timer_init();

	serial_writestring(1, "End kernel_init\n");

	kernel_main();
};
Ejemplo n.º 9
0
Archivo: main.c Proyecto: UIKit0/flux
int main(int argc, char **argv) {
	struct vfs_obj *root;
	uint64_t kbd;
	
	root = calloc(sizeof(struct vfs_obj), 1);
	root->type = RP_TYPE_FILE;
	root->size = 0;
	root->acl = acl_set_default(root->acl, PERM_WRITE | PERM_READ);
	vfs_set_index(0, root);

	tty_init();

	kbd = io_find("/dev/kbd");
	event_register(kbd, tty_event);

	di_wrap_read (tty_read);
	di_wrap_write(tty_write);
	di_wrap_rcall(tty_rcall);
	vfs_wrap_init();

	msendb(RP_CONS(getppid(), 0), PORT_CHILD);
	_done();

	return 0;
}
Ejemplo n.º 10
0
int main(void)
{
    /* Interrupts are still disabled. Do necessary setups, then enable them. */
    time_init();
    tty_init();
    trap_init();
    sched_init();
    buffer_init();
    hd_init();
    sti();
    move_to_user_mode();
    if (!fork()) {		/* we count on this going ok */
	init();
    }

    /*
     * NOTE!!
     * For any other task 'pause()' would mean we have to get a signal to awaken,
     * but task 0 gets activated at every idle moment (when no other tasks can run).
     * For task0 'pause()' just means we go check if some other task can run, and
     * if not we return here.
     */
    // for(;;) pause();

    return 0;
}
Ejemplo n.º 11
0
Archivo: vga.c Proyecto: oridb/PhotonOS
void init_video()
{
	video_memory = (uint16_t*) 0xB8000;
	vga_change = 0;
	main_tty = tty_init(main_tty);
	clear_video();
}
Ejemplo n.º 12
0
static void setup(void)
{
    // rcc
    rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_168MHZ]);

    // systick
    systick_init();

    // LED ping
    LED_ping_init();

    // tty
    tty_init(&my_tty);

    // USB CDC/ACM
    cdcacm_init();

    // TTY stdio
    tty_stdio_init(&my_tty);

    // connect TTY to USB.
    cdcacm_register_receive_callback(usb_to_tty);
    tty_register_send_callback(&my_tty, tty_to_usb);

    // wait for user to connect.
    cdcacm_open();
}
Ejemplo n.º 13
0
int __init chr_dev_init(void)
{
	if (devfs_register_chrdev(MEM_MAJOR,"mem",&memory_fops))
		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
	memory_devfs_register();
	rand_initialize();
#ifdef CONFIG_I2C
	i2c_init_all();
#endif
#if defined (CONFIG_FB)
	fbmem_init();
#endif
#if defined (CONFIG_PROM_CONSOLE)
	prom_con_init();
#endif
#if defined (CONFIG_MDA_CONSOLE)
	mda_console_init();
#endif
	tty_init();
#ifdef CONFIG_M68K_PRINTER
	lp_m68k_init();
#endif
	misc_init();
#if CONFIG_QIC02_TAPE
	qic02_tape_init();
#endif
#ifdef CONFIG_FTAPE
	ftape_init();
#endif
#if defined(CONFIG_S390_TAPE) && defined(CONFIG_S390_TAPE_CHAR)
	tapechar_init();
#endif
	return 0;
}
Ejemplo n.º 14
0
Archivo: main.c Proyecto: qiuhw/linux
void main(void)		/* This really IS void, no error here. */
{			/* The startup routine assumes (well, ...) this */
/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
	time_init();
	tty_init();
	trap_init();
	sched_init();
	buffer_init();
	hd_init();
	sti();
	move_to_user_mode();
	if (!fork()) {		/* we count on this going ok */
		init();
	}
/*
 *   NOTE!!   For any other task 'pause()' would mean we have to get a
 * signal to awaken, but task0 is the sole exception (see 'schedule()')
 * as task 0 gets activated at every idle moment (when no other tasks
 * can run). For task0 'pause()' just means we go check if some other
 * task can run, and if not we return here.
 */
	for(;;) pause();
}
Ejemplo n.º 15
0
void main(void)		/* This really IS void, no error here. */
{			/* The startup routine assumes (well, ...) this */
/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
 	ROOT_DEV = ORIG_ROOT_DEV;
 	drive_info = DRIVE_INFO;
	memory_end = (1<<20) + (EXT_MEM_K<<10);
	memory_end &= 0xfffff000;
	if (memory_end > 16*1024*1024)
		memory_end = 16*1024*1024;
	if (memory_end > 12*1024*1024) 
		buffer_memory_end = 4*1024*1024;
	else if (memory_end > 6*1024*1024)
		buffer_memory_end = 2*1024*1024;
	else
		buffer_memory_end = 1*1024*1024;
	main_memory_start = buffer_memory_end;
#ifdef RAMDISK
	main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
#endif
	mem_init(main_memory_start,memory_end);
	trap_init();
	blk_dev_init();
	chr_dev_init();
	tty_init();
	time_init();
	sched_init();
	buffer_init(buffer_memory_end);
	hd_init();
	floppy_init();
	sti();
	move_to_user_mode();

	setup((void *) &drive_info);
	(void) open("/dev/tty0",O_RDWR,0);
	(void) dup(0);
	(void) dup(0);
	(void) open("/var/process.log",O_CREAT|O_TRUNC|O_WRONLY,0666);
#ifdef dis_func
	(void) open("/var/dis_func.log",O_CREAT|O_TRUNC|O_WRONLY,0666);
#endif

	if (!fork()) {		/* we count on this going ok */
		init();
	}
/*
 *   NOTE!!   For any other task 'pause()' would mean we have to get a
 * signal to awaken, but task0 is the sole exception (see 'schedule()')
 * as task 0 gets activated at every idle moment (when no other tasks
 * can run). For task0 'pause()' just means we go check if some other
 * task can run, and if not we return here.
 */
	for(;;) pause();
}
Ejemplo n.º 16
0
Archivo: yaft.c Proyecto: saitoha/yaft
int main()
{
	uint8_t buf[BUFSIZE];
	ssize_t size;
	fd_set fds;
	struct timeval tv;
	struct framebuffer fb;
	struct terminal term;

	/* init */
	setlocale(LC_ALL, "");
	if (atexit(tty_die) != 0)
		fatal("atexit failed");

	tty_init();
	fb_init(&fb, term.color_palette);
	check_env(&fb);
	term_init(&term, fb.res, fb.rotate);

	/* fork and exec shell */
	eforkpty(&term.fd, term.lines, term.cols);

	/* main loop */
	while (tty.loop_flag) {
		if (tty.redraw_flag) {
			redraw(&term);
			refresh(&fb, &term);
			tty.redraw_flag = false;
		}

		check_fds(&fds, &tv, STDIN_FILENO, term.fd);
		if (FD_ISSET(STDIN_FILENO, &fds)) {
			size = read(STDIN_FILENO, buf, BUFSIZE);
			if (size > 0)
				ewrite(term.fd, buf, size);
		}
		if (FD_ISSET(term.fd, &fds)) {
			size = read(term.fd, buf, BUFSIZE);
			if (size > 0) {
				if (DEBUG)
					ewrite(STDOUT_FILENO, buf, size);
				parse(&term, buf, size);
				if (tty.lazy_draw && size == BUFSIZE)
					continue;
				refresh(&fb, &term);
			}
		}
	}

	/* die */
	term_die(&term);
	fb_die(&fb);

	return EXIT_SUCCESS;
}
Ejemplo n.º 17
0
void vterm_init(struct vterm *vt, struct vterm_video *video,
		struct input_dev *indev) {
	assert(video && video->ops && video->ops->init);

	vt->video = video;
	vt->indev = indev;

	vt->video->ops->init(vt->video);

	tty_init(&vt->tty, &vterm_tty_ops);

}
Ejemplo n.º 18
0
int main(int argc, char *argv[])
{
	struct pollfd	pfd;
	int		fd;
	int		ret = 0;
	char		buf[16];
	ssize_t		val;

retry:
	fd = open(argv[1], O_RDWR);
	if (fd < 0) {
		perror(argv[1]);
		ret = fd;
		goto out1;
	}

	ret = tty_init(fd);
	if (ret < 0)
		goto out2;

	pfd.fd = fd;
	pfd.events = POLLIN | POLLHUP;
	pfd.revents = 0;

	while (1) {
		ret = poll(&pfd, 1, -1);
		if (ret < 0)
			goto out2;

		if (pfd.revents & POLLHUP) {
			close(fd);
			goto retry;
		}

		val = read(fd, buf, sizeof(buf));
		if (val < 0) {
			ret = val;
			goto out2;
		}

		printf("%s\n", buf);

		ret = write(fd, buf, val);
		if (ret < 0)
			goto out2;
	}

out2:
	close(fd);

out1:
	return ret;
}
Ejemplo n.º 19
0
// Starts the kernel's idle process. This process has kernel permissions.
int idle_main(int argc, char ** params) {
	
	int i = 0;
	char a[] = { ' ', 0x07 };
	
	for(; i < 2000; ++i)	{
		memcpy((char*)0xb8000 + i * 2, a, 2);
	}
	
	// The funny message, windows says starting windows... why shouldn't we? D:
	char start_msg[][2] =	{ 
		{ 'S', 0x07 },
		{ 't', 0x08 },
		{ 'a', 0x09 },
		{ 'r', 0x0a },
		{ 't', 0x0b },
		{ 'i', 0x0c },
		{ 'n', 0x0d },
		{ 'g', 0x0e },
		{ ' ', 0x0f },
		{ 'M', 0x02 },
		{ 'o', 0x03 },
		{ 'n', 0x04 },
		{ 'i', 0x05 },
		{ 'x', 0x06 },
		{ ' ', 0x0f },
		{ '\001', 0x5f },
	};
	
	i = 0;
	for(; i < 16; ++i)	{
		memcpy((char*)0xb8000 + i * 2, start_msg[i], 2);
		_setCursor(i);
	}
	
	Cli();
	make_atomic();

	mount();					// Mount or start the FS

	tty_init(0);				// Load up the TTY's
	tty_init(1);
	tty_init(2);
	tty_init(3);
	tty_init(4);
	tty_init(5);		
	
	setready(); 				// Set the kernel as ready and the FS as loaded
	users_init();				// Init the users
	
	fs_finish();

	release_atomic();	
	Sti();


	while(1) {
		_Halt(); // Now set to idle.
	}
}
Ejemplo n.º 20
0
static void john_run(void)
{
	if (options.flags & FLG_TEST_CHK)
		exit_status = benchmark_all() ? 1 : 0;
	else
	if (options.flags & FLG_MAKECHR_CHK)
		do_makechars(&database, options.charset);
	else
	if (options.flags & FLG_CRACKING_CHK) {
		if (!(options.flags & FLG_STDOUT)) {
			status_init(NULL, 1);
			log_init(LOG_NAME, options.loader.activepot, options.session);
			john_log_format();
			if (cfg_get_bool(SECTION_OPTIONS, NULL, "Idle", 1))
				log_event("- Configured to use otherwise idle "
					"processor cycles only");
		}
		tty_init(options.flags & FLG_STDIN_CHK);

		if (options.flags & FLG_SINGLE_CHK)
			do_single_crack(&database);
		else
                if ((options.flags & FLG_GIJOHN_CHK) && FLG_EXTERNAL_CHK)
                {
                        do
                        {
                                do_external_crack(&database);
                                if (!aborted_gijohn) ext_init("gijohn");
                        }
                        while (crk_db->password_count && !aborted_gijohn);
                }
                else
		if (options.flags & FLG_WORDLIST_CHK)
			do_wordlist_crack(&database, options.wordlist,
				(options.flags & FLG_RULES) != 0);
		else
		if (options.flags & FLG_INC_CHK)
			do_incremental_crack(&database, options.charset);
		else
		if (options.flags & FLG_MKV_CHK)
			do_markov_crack(&database, options.mkv_level, options.mkv_start, options.mkv_end, options.mkv_maxlen);
		else
                if ((options.flags & FLG_EXTERNAL_CHK) && FLG_GIJOHN_CHK)
			do_external_crack(&database);
		else
		if (options.flags & FLG_BATCH_CHK)
			do_batch_crack(&database);

		status_print();
		tty_done();
	}
}
Ejemplo n.º 21
0
/**
 * 主核初始化
 */
asmlinkage void __init start_master(void)
{
	debug_printstr_mmu("xby_debug, start cpu 0\n");

	local_irq_disable();

	//tick_init();
	
	/* 为当前CPU设置其活动掩码 */
	boot_cpu_init();
	/* 体系结构特定的初始化过程 */
	start_arch();

	//初始化boot内存分配器
	InitBootMemory(0xc0000000 + 8 * 1024 * 1024, 0xc0000000 + 24 * 1024 * 1024);
	
	init_IRQ();
	//体系结构和驱动的一些初始化过程
	//run_initcall();

	//为VFS分配一些大的内存块,用于哈希表。此过程必须在boot阶段分配。
	//vfs_caches_init_early();

#ifdef FS
	blk_dev_init();
	inode_init();
	file_table_init();
	name_cache_init();
	buffer_init_early();
#endif
	memory_init();
#ifdef FS
	buffer_init_tail();
	tty_init();
#endif
	sched_init();
	time_init();
	setup_timer();
	serial_init();
	//mmc_init();
	//omap_gpio_init();
	//初始化文件系统
	//vfs_caches_init(num_physpages);
	local_irq_enable();

	//创建系统任务,以及用户任务入口
	TaskEntry();
	cpu_idle();

	//不可能运行到这里来
	BUG();
}
Ejemplo n.º 22
0
Archivo: shell.c Proyecto: kjk/qemacs
EditBuffer *new_shell_buffer(const char *name, const char *path,
                             const char **argv, int is_shell)
{
    ShellState *s;
    EditBuffer *b, *b_color;

    b = eb_new("", BF_SAVELOG);
    if (!b)
        return NULL;
    set_buffer_name(b, name); /* ensure that the name is unique */
    eb_set_charset(b, &charset_vt100);

    s = malloc(sizeof(ShellState));
    if (!s) {
        eb_free(b);
        return NULL;
    }
    memset(s, 0, sizeof(ShellState));
    b->priv_data = s;
    b->close = shell_close;
    eb_add_callback(b, eb_offset_callback, &s->cur_offset);
    s->b = b;
    s->pty_fd = -1;
    s->pid = -1;
    s->is_shell = is_shell;
    s->qe_state = &qe_state;
    tty_init(s);

    /* add color buffer */
    if (is_shell) {
        b_color = eb_new("*color*", BF_SYSTEM);
        if (!b_color) {
            eb_free(b);
            free(s);
            return NULL;
        }
        /* no undo info in this color buffer */
        b_color->save_log = 0;
        eb_add_callback(b, shell_color_callback, s);
        s->b_color = b_color;
    }

    /* launch shell */
    if (run_process(path, argv, &s->pty_fd, &s->pid) < 0) {
        eb_free(b);
        return NULL;
    }

    set_read_handler(s->pty_fd, shell_read_cb, s);
    set_pid_handler(s->pid, shell_pid_cb, s);
    return b;
}
Ejemplo n.º 23
0
/*-----tty_platform-----*/
void tty_platform(void)
{
	struct	ttybuf	*pTtab = ttyTab;

	tty_init();

	while(1) {
		for(pTtab = ttyTab; pTtab < ttyTab + NR_TTY; pTtab++) {
			tty_do_read(pTtab);
			tty_do_write(pTtab);
		}
	}
}
Ejemplo n.º 24
0
/* suspend the shell */
void
j_suspend(void)
{
	struct sigaction sa, osa;

	/* Restore tty and pgrp. */
	if (ttypgrp_ok) {
		tcsetattr(tty_fd, TCSADRAIN, &tty_state);
		if (restore_ttypgrp >= 0) {
			if (tcsetpgrp(tty_fd, restore_ttypgrp) < 0) {
				warningf(false,
				    "j_suspend: tcsetpgrp() failed: %s",
				    strerror(errno));
			} else {
				if (setpgid(0, restore_ttypgrp) < 0) {
					warningf(false,
					    "j_suspend: setpgid() failed: %s",
					    strerror(errno));
				}
			}
		}
	}

	/* Suspend the shell. */
	memset(&sa, 0, sizeof(sa));
	sigemptyset(&sa.sa_mask);
	sa.sa_handler = SIG_DFL;
	sigaction(SIGTSTP, &sa, &osa);
	kill(0, SIGTSTP);

	/* Back from suspend, reset signals, pgrp and tty. */
	sigaction(SIGTSTP, &osa, NULL);
	if (ttypgrp_ok) {
		if (restore_ttypgrp >= 0) {
			if (setpgid(0, kshpid) < 0) {
				warningf(false,
				    "j_suspend: setpgid() failed: %s",
				    strerror(errno));
				ttypgrp_ok = 0;
			} else {
				if (tcsetpgrp(tty_fd, kshpid) < 0) {
					warningf(false,
					    "j_suspend: tcsetpgrp() failed: %s",
					    strerror(errno));
					ttypgrp_ok = 0;
				}
			}
		}
		tty_init(true);
	}
}
Ejemplo n.º 25
0
int main(int argc, char *argv[]){
	parce_args(argc, argv);
	tty_init();
	signal(SIGTERM, quit);		// kill (-15)
	signal(SIGINT,  quit);		// ctrl+C
	signal(SIGQUIT, SIG_IGN);	// ctrl+\   .
	signal(SIGTSTP, SIG_IGN);	// ctrl+Z
	setbuf(stdout, NULL);
	erase_ctrlr();
	if(G.erasecmd) return 0;
	if(G.relaycmd == -1 && G.gotopos == NULL){
		printf("No commands given!\n");
		return -1;
	}
	if(G.relaycmd != -1){
		int ans;
		if(G.relaycmd) // turn on
			ans = con_sig('R',0);
		else // turn off
			ans = con_sig('r',0);
		if(ans)
			wait_for_answer();
		else
			return -1;
	}
	if(G.gotopos){
		if(strcasecmp(G.gotopos, "refmir") == 0){
			if(!con_sig('1',0)) return -1;
			printf("Go to last end-switch\n");
			wait_for_answer();
			if(!con_sig('-',500)) return -1;
		}else if(strcasecmp(G.gotopos, "diagmir") == 0){
			if(!con_sig('0',0)) return -1;
			printf("Go to zero's end-switch\n");
			wait_for_answer();
			if(!con_sig('+',2500)) return -1;
		}else if(strcasecmp(G.gotopos, "shack") == 0){
			if(!con_sig('1',0)) return -1;
			printf("Go to last end-switch\n");
			wait_for_answer();
			if(!con_sig('-',30000)) return -1;
		}else{
			printf("Wrong goto command, should be one of refmir/diagmir/shack\n");
			return -1;
		}
		printf("Go to position\n");
		wait_for_answer();
	}
	return 0;
}
Ejemplo n.º 26
0
Archivo: main.c Proyecto: ahua/c
void main(void)
{
  memory_end = (1<<20) + (*(unsigned short *)0x90002);
  memory_end &= 0xfffff000;
  if( memory_end > 16 * 1024 * 1024) 
    memory_end = 16*1024*1024;
  buffer_memory_end = 4*1024*1024;
  main_memory_start = buffer_memory_end;

  mem_init(main_memory_start, memory_end);
  tty_init();

  for(;;);
}
Ejemplo n.º 27
0
static void replay_start(void)
{
    tty tev_vt;
    ttyrec_frame tev_tail;
    struct timeval doomsday;

    ttyrec_free(ttr);
    tev_vt=tty_init(defsx, defsy, 1);
    tev_vt->cp437=1;
    tty_printf(tev_vt, "\e[36m");
    tty_printf(tev_vt, _("Termplay v%s\n\n"),
        "\e[36;1m"PACKAGE_VERSION"\e[0;36m");
    tty_printf(tev_vt, "\e[0m");

    tr.tv_sec=tr.tv_usec=0;
    tev_done=0;
    tmax.tv_sec=tmax.tv_usec=0;
    progmax=0;
    progdiv=1000000;
    progval=-1;
    // TODO: re-enable threading
#ifdef THREADED
    pth=CreateThread(0, 0, (LPTHREAD_START_ROUTINE)playfile, (LPDWORD)0, 0, 0);
#else
//    printf("Buffering: started.\n");
    playfile(tev_vt);
//    printf("Buffering: done.\n");
    tev_done=1;
    tev_cur=ttyrec_seek(ttr, 0, 0);
    tdate=tev_cur->t;
    replay_seek();
    doomsday.tv_sec=1ULL<<(sizeof(doomsday.tv_sec)*8-1)-1;
    doomsday.tv_usec=0;
    tev_tail=ttyrec_seek(ttr, &doomsday, 0);
    tmax=tev_tail->t;
    tsub(tmax, tdate);
    if (tmax.tv_sec<100)
        progdiv=10000;
    else
        progdiv=1000000;
    selstart.tv_sec=0;
    selstart.tv_usec=0;
    selend=tmax;
    progmax=tmax.tv_sec*(1000000/progdiv)+tmax.tv_usec/progdiv;
    set_prog_max();
    set_prog();
#endif
}
Ejemplo n.º 28
0
int stdioInstallStderrHandler(PspDebugPrintHandler handler)
{
	if(g_initialised == 0)
	{
		int ret;
		ret = tty_init();
		if(ret < 0)
		{
			return ret;
		}
	}

	g_stderr_handler = handler;

	return 0;
}
Ejemplo n.º 29
0
/*
 * This is the kernel main routine. When the boot process is completed, this
 * function is called.
 */
void start_kernel(void) {
    int pid, i;
    char *names[N_CONSOLES] = { "PRG1", "PRG2", "PRG3", 
                                "PRG4", "PRG5", "PRG6" };

    // init traps
    init_traps();
    // initialize IRQs
    init_irq();

    // initialize the tty driver. The tty is composed by a keyboard driver
    // that read input keys a print the relative ASCII code on video.
    tty_init();
    // initialize the timer.
    time_init();
    // initialize the scheduler
    sched_init();

    printk("Kernel info: %u bytes, start at 0x%x0 end at 0x%x0.\n",
           &__KERNEL_END__-K_START, K_START, &__KERNEL_END__);
    sti();

    // calibrate delay
    calibrate_delay();
    // floppy driver initialization
    floppy_init();

    // switch in user mode
    move_to_user_mode();

    // for a process for each console and execute the program PRGi
    for (i=0; i<N_CONSOLES; ++i) {
        // spawn process i and run PRG1
        pid = fork();

        if (pid == 0) {
            exec(names[i]);
        } else if (pid < 0) {
            print("idle: cannot duplicate myself.\n");
        }
    }

	print("Idle: ok!\n");

    // idle loop
    while(1);
}
Ejemplo n.º 30
0
/* initialize job control */
void
j_init(int mflagset)
{
	if(!child_max)
		child_max = sysconf(_SC_CHILD_MAX);

	sigemptyset(&sm_default);
	sigprocmask(SIG_SETMASK, &sm_default, (sigset_t *) 0);

	sigemptyset(&sm_sigchld);
	sigaddset(&sm_sigchld, SIGCHLD);

	setsig(&sigtraps[SIGCHLD], j_sigchld,
	    SS_RESTORE_ORIG|SS_FORCE|SS_SHTRAP);

#ifdef JOBS
	if (!mflagset && Flag(FTALKING))
		Flag(FMONITOR) = 1;

	/* shl_j is used to do asynchronous notification (used in
	 * an interrupt handler, so need a distinct shf)
	 */
	shl_j = shf_fdopen(2, SHF_WR, (struct shf *) 0);

	if (Flag(FMONITOR) || Flag(FTALKING)) {
		int i;

		/* the TF_SHELL_USES test is a kludge that lets us know if
		 * if the signals have been changed by the shell.
		 */
		for (i = NELEM(tt_sigs); --i >= 0; ) {
			sigtraps[tt_sigs[i]].flags |= TF_SHELL_USES;
			/* j_change() sets this to SS_RESTORE_DFL if FMONITOR */
			setsig(&sigtraps[tt_sigs[i]], SIG_IGN,
			    SS_RESTORE_IGN|SS_FORCE);
		}
	}

	/* j_change() calls tty_init() */
	if (Flag(FMONITOR))
		j_change();
	else
#endif /* JOBS */
		if (Flag(FTALKING))
			tty_init(true);
}