Ejemplo n.º 1
0
static void sio_error(int *status)
{
	printk("SIO0 error[%04x]\n", *status);
	do {
		sio_init();
	} while ((*status = __sio_in(PLD_ESIO0CR)) != 3);
}
Ejemplo n.º 2
0
static void sio_error(int *status)
{
	printk("SIO0 error[%04x]\n", *status);
	do {
		sio_init();
	} while ((*status = __sio_in(M32R_SIO0_CR_PORTL)) != 3);
}
Ejemplo n.º 3
0
static int
parse()
{
    char *arg = cmd;
    char *ep, *p, *q;
    char unit;
    size_t len;
    const char *cp;
#if 0
    int c, i, j;
#else
    int c, i;
#endif

    while ((c = *arg++)) {
	if (c == ' ' || c == '\t' || c == '\n')
	    continue;
	for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
	ep = p;
	if (*p)
	    *p++ = 0;
	if (c == '-') {
	    while ((c = *arg++)) {
		if (c == 'P') {
			cp = "yes";
#if 0
		    } else {
			opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL);
			cp = "no";
		    }
#endif
		    printf("Keyboard: %s\n", cp);
		    continue;
#if 0
		} else if (c == 'S') {
		    j = 0;
		    while ((unsigned int)(i = *arg++ - '0') <= 9)
			j = j * 10 + i;
		    if (j > 0 && i == -'0') {
			comspeed = j;
			break;
		    }
		    /* Fall through to error below ('S' not in optstr[]). */
#endif
		}
		for (i = 0; c != optstr[i]; i++)
		    if (i == NOPT - 1)
			return -1;
		opts ^= OPT_SET(flags[i]);
	    }
	    ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
		     OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
#if 0
	    if (ioctrl & IO_SERIAL) {
	        if (sio_init(115200 / comspeed) != 0)
		    ioctrl &= ~IO_SERIAL;
	    }
#endif
	} else {
Ejemplo n.º 4
0
static int __init m32r_sio_console_init(void)
{
	sio_reset();
	sio_init();
	m32r_sio_init_ports();
	register_console(&m32r_sio_console);
	return 0;
}
Ejemplo n.º 5
0
EXPORT ER knl_init_device( void )
{
IMPORT	void	sio_init( void );

	sio_init();	// UART setup

	return E_OK;
}
Ejemplo n.º 6
0
void at_batman_init()
{
        at_init();
        mouse_ps2_init();
        pci_init(PCI_CONFIG_TYPE_2, 0xd, 0x10);
        i430lx_init();
	sio_init(1);
        fdc37c665_init();
        intel_batman_init();
}
Ejemplo n.º 7
0
void at_plato_init()
{
        at_init();
	mouse_ps2_init();
        pci_init(PCI_CONFIG_TYPE_2, 0xd, 0x10);
        i430nx_init();
	sio_init(1);
	fdc37c665_init();
	/* It seems it uses the same interface as Batman. */
        intel_batman_init();
        // device_add(&intel_flash_bxt_ami_device);
}
Ejemplo n.º 8
0
int main()
{   
   SifInitRpc(0); 
/*
   init_scr();
   scr_printf("Hello, world!\n"); // hello world in the screen
*/
   printf("Hello, world!\n");
   nprintf("Hello, again, from Naplink RPC!\n");
   
   sio_init(115200, 0, 0, 0, 0);
   sio_printf("Hello from EE SIO!\n");

   /* Return to the bootloader or PS2 browser. */
   return 0;
}
Ejemplo n.º 9
0
/*
 *  ターゲットシステム依存 初期化ルーチン
 */
void
sys_initialize(void)
{
	/*
	 * モジュールストップモード解除
	 */
#if TNUM_SIOP < 2
	h8s_andh_reg( (VP) MSTPCR, ~( BIT5 ) );
#else /* TNUM_SIOP < 2 */
	h8s_andh_reg( (VP) MSTPCR, ~( BIT6 | BIT5 ) );
#endif /* TNUM_SIOP < 2 */

	/*
	 *  バナー表示用シリアルポートの初期化
	 */
	sio_init();
}
Ejemplo n.º 10
0
static int m32r_sio_startup(struct uart_port *port)
{
	struct uart_sio_port *up =
		container_of(port, struct uart_sio_port, port);
	int retval;

	sio_init();

	/*
	 * If the "interrupt" for this port doesn't correspond with any
	 * hardware interrupt, we use a timer-based system.  The original
	 * driver used to do this with IRQ0.
	 */
	if (!up->port.irq) {
		unsigned int timeout = up->port.timeout;

		timeout = timeout > 6 ? (timeout / 2 - 2) : 1;

		up->timer.data = (unsigned long)up;
		mod_timer(&up->timer, jiffies + timeout);
	} else {
		retval = serial_link_irq_chain(up);
		if (retval)
			return retval;
	}

	/*
	 * Finally, enable interrupts.  Note: Modem status interrupts
	 * are set via set_termios(), which will be occurring imminently
	 * anyway, so we don't enable them here.
	 * - M32R_SIO: 0x0c
	 * - M32R_PLDSIO: 0x04
	 */
	up->ier = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
	sio_out(up, SIOTRCR, up->ier);

	/*
	 * And clear the interrupt registers again for luck.
	 */
	sio_reset();

	return 0;
}
Ejemplo n.º 11
0
static void m32r_sio_shutdown(struct uart_port *port)
{
	struct uart_sio_port *up =
		container_of(port, struct uart_sio_port, port);

	/*
	 * Disable interrupts from this port
	 */
	up->ier = 0;
	sio_out(up, SIOTRCR, 0);

	/*
	 * Disable break condition and FIFOs
	 */

	sio_init();

	if (!up->port.irq)
		del_timer_sync(&up->timer);
	else
		serial_unlink_irq_chain(up);
}
Ejemplo n.º 12
0
/*
 *  ターゲットシステム依存 初期化ルーチン
 */
void
sys_initialize()
{

#ifndef GDB_STUB

	/*
	 * モジュールストップモード解除
	 */
#if TNUM_SIOP < 2
	h8s_andh( (VP) MSTPCR, ~( BIT5 ) );
#else /* TNUM_SIOP < 2 */
	h8s_andh( (VP) MSTPCR, ~( BIT6 | BIT5 ) );
#endif /* TNUM_SIOP < 2 */

	/*
	 *  バナー表示用シリアルポートの初期化
	 */
	sio_init();

#endif /* GDB_STUB */

}
Ejemplo n.º 13
0
int waitclients(void)
{
	int fd_max;
	fd_set fds;
	vlist_i *it;
	pipe_s *pit, *newpipe;
	tcpsock_s *newsock;
	thr_t thread;
	
	fd_max = 0;
	FD_ZERO(&fds);

	/* Set all sockets to listen */
	for (it = pipes.head; it; it = it->next)
	{
		pit = (pipe_s *)it->data;

		if (tcp_listen(&pit->sock))
			perror("waitclients() - tcp_listen()");
	}

	printf("Serproxy - (C)1999 Stefano Busti, (C)2005 David A. Mellis - Waiting for clients\n");
	
	while (1)
	{
		/* Iterate through the pipe list */
		for (it = pipes.head; it; it = it->next)
		{
			pit = (pipe_s *)it->data;

			/* Monitor socket fd of each */
			FD_SET(pit->sock.fd, &fds);

			/* Track max fd */
			if (pit->sock.fd > fd_max)
				fd_max = pit->sock.fd;
		}

		/* Wait for a read ( == accept() in this case) */
		if (select(fd_max + 1, &fds, NULL, NULL, NULL) == -1)
			perrend("waitclients() - select()");


		/* Find which sockets are involved */
		for (it = pipes.head; it; it = it->next)
		{
			pit = (pipe_s *)it->data;

			if (FD_ISSET(pit->sock.fd, &fds))
			{
				/* Create a new pipe struct for the new thread */
				newpipe = malloc(sizeof(pipe_s));
				if (!newpipe)
					perrend("waitclients() - malloc(pipe_s)");

				sio_init(&newpipe->sio);
				sio_assign(&newpipe->sio, &pit->sio);

				/* Try to open serial port */
				if (sio_open(&newpipe->sio))
				{
					tcp_refuse(&pit->sock);
					error("Failed to open comm port - connection refused");
					free(newpipe);
					continue;
				}
				
				/* Accept the connection */
				newsock = tcp_accept(&pit->sock);

				/* All ok? */
				if (newsock)
				{
					newpipe->sock = *newsock;
					free(newsock);

					newpipe->newlines = pit->newlines;
					newpipe->timeout = pit->timeout;
					newpipe->mutex = pit->mutex;
						
					/* Create the server thread */
					if (thr_create(&thread, 1, serve_pipe, newpipe))
					{
						error("Feck - thread creation failed");
						free(newpipe);
					}
					else
					{
						fprintf(stderr, "Server thread launched\n");
					}
				}
				else
				{
					perror("waitclients() - accept()");
					free(newpipe);
				}
			}
		}
	}
	return 0;
}
Ejemplo n.º 14
0
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
	static const uint16_t spd_addr[] = {
		// Node 0
		DIMM0, DIMM2, 0, 0,
		0, 0, 0, 0,
		// Node 1
		DIMM1, DIMM3, 0, 0,
		0, 0, 0, 0,
	};
	unsigned bsp_apicid = 0;
	int needs_reset = 0;
	struct sys_info *sysinfo = &sysinfo_car;

	sio_init();
	w83627ehg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
	console_init();
	enable_rom_decode();

	print_info("now booting... fallback\n");

	/* Is this a CPU only reset? Or is this a secondary CPU? */
	if (!cpu_init_detectedx && boot_cpu()) {
		/* Nothing special needs to be done to find bus 0. */
		/* Allow the HT devices to be found. */
		enumerate_ht_chain();
	}

	// FIXME why is this executed again? --->
	sio_init();
	w83627ehg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
	console_init();
	enable_rom_decode();
	// <--- FIXME why is this executed again?

	print_info("now booting... real_main\n");

	if (bist == 0)
		bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);

	/* Halt if there was a built in self test failure. */
	report_bist_failure(bist);

	setup_default_resource_map();
	setup_coherent_ht_domain();
	wait_all_core0_started();

	print_info("now booting... Core0 started\n");

#if CONFIG_LOGICAL_CPUS
	/* It is said that we should start core1 after all core0 launched. */
	start_other_cores();
	wait_all_other_cores_started(bsp_apicid);
#endif
	init_timer();
	ht_setup_chains_x(sysinfo); /* Init sblnk and sbbusn, nodes, sbdn. */

	needs_reset = optimize_link_coherent_ht();
	needs_reset |= optimize_link_incoherent_ht(sysinfo);
	needs_reset |= k8t890_early_setup_ht();

	if (needs_reset) {
		print_debug("ht reset -\n");
		soft_reset();
	}

	/* the HT settings needs to be OK, because link freq chnage may cause HT disconnect */
	enable_fid_change();
	init_fidvid_bsp(bsp_apicid);

	/* Stop the APs so we can start them later in init. */
	allow_all_aps_stop(bsp_apicid);

	/* It's the time to set ctrl now. */
	fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);

	enable_smbus();
	sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);
	post_cache_as_ram();
}
Ejemplo n.º 15
0
static void * sior_rpc_server(u32 funcno, void * data, int size) {
    int res = 0, c;
    size_t s;
    char * p;
    struct init_arguments_t * i;
    switch(funcno) {
    case SIOR_INIT:
	i = (struct init_arguments_t *) data;
	sio_init(i->baudrate, i->lcr_ueps, i->lcr_upen, i->lcr_usbl, i->lcr_umode);
	break;
    case SIOR_PUTC:
	c = *((int *) data);
	res = sio_putc(c);
	break;
    case SIOR_GETC:
	res = sio_getc();
	break;
    case SIOR_GETCBLOCK:
	res = sio_getc_block();
	break;
    case SIOR_WRITE:
	p = *((char **) data) + IOP_MEM;
	s = *(((size_t *) data) + 1);
	DI();
	ee_kmode_enter();
	res = sio_write(p, s);
	ee_kmode_exit();
	EI();
	break;
    case SIOR_READ:
	p = *((char **) data) + IOP_MEM;
	s = *(((size_t *) data) + 1);
	DI();
	ee_kmode_enter();
	res = sio_read(p, s);
	ee_kmode_exit();
	EI();
	break;
    case SIOR_PUTS:
	p = *((char **) data) + IOP_MEM;
	DI();
	ee_kmode_enter();
	res = sio_puts(p);
	ee_kmode_exit();
	EI();
	break;
    case SIOR_PUTSN:
	p = *((char **) data) + IOP_MEM;
	DI();
	ee_kmode_enter();
	res = sio_putsn(p);
	ee_kmode_exit();
	EI();
	break;
    case SIOR_GETS:
	p = *((char **) data) + IOP_MEM;
	DI();
	ee_kmode_enter();
	(char*)res = sio_gets(p);
	ee_kmode_exit();
	EI();
	break;
    case SIOR_FLUSH:
	sio_flush();
	break;
    }

    *((int *) data) = res;

    return data;
}
Ejemplo n.º 16
0
void
fob_open(char *fn, speed_t speed, int usec)
{
	int fd;
	//char *fn = "/dev/ttyS0";
	unsigned int retval1, retval2, retval, status;
	int num, i;
	char strbuf[1024], *str;

	if (-1 == (fd = open(fn, O_RDONLY))) {
		perror(fn);
		exit(1);
	}
	rtsclear(fd);

	close(fd);
	usleep(usec);
	fd = sio_init(fn, speed);
	rtsclear(0);

	// Bird Status
	sio_putc(0x4F); // Examine Value (FoBman p.73)
	sio_putc(0); // Bird Status (FoBman p.112)
	retval1 = sio_getc();
	retval2 = sio_getc();
	status = ((retval2 & 0xff) << 8) | (retval1 & 0xff);
#if 0
	printf("status: %04x\n", status);
	printf("master?:  %c\n", (status & 0x8000) ? 'O' : 'X');
	printf("init?:    %c\n", (status & 0x4000) ? 'O' : 'X');
	printf("error?:   %c\n", (status & 0x2000) ? 'O' : 'X');
	printf("running?: %c\n", (status & 0x1000) ? 'O' : 'X');
	printf("hostsync?: %c\n", (status & 0x800) ? 'O' : 'X');
	printf("expanded address mode?: %c\n", (status & 0x400) ? 'O' : 'X');
	printf("crtSync?: %c\n", (status & 0x200) ? 'O' : 'X');
	printf("noSync?: %c\n", (status & 0x100) ? 'O' : 'X');
	printf("factory test?: %c\n", (status & 0x80) ? 'O' : 'X');
	printf("XOFF?: %c\n", (status & 0x40) ? 'O' : 'X');
	printf("sleep?: %c\n", (status & 0x20) ? 'O' : 'X');
	printf("stream?: %c\n", (status & 0x1) ? 'O' : 'X');
#endif
	if (0 == (status & 0x8000)) {
		fprintf(stderr, "FoB Hardware Config Error: not master\n");
		exit(1);
	}

	// FBB Addressing mode
	sio_putc(0x4F); // Examine Value (FoBman p.73)
	sio_putc(19); // FBB Addressing mode (FoBman p.123)
	retval1 = sio_getc();
	str = "Unknown";
	switch (retval1) {
	case 0:
		str = "Normal";
		num = 14;
		break;
	case 1:
		str = "Expanded";
		num = 30;
		break;
	case 3:
		str = "SuperExpanded";
		num = 126;
		break;
	default:
		fprintf(stderr, "FATAL ERROR: unknown addressing mode\n");
		exit(1);
		break;
	}

	fob_addrmode = retval1;
	fob_maxaddrs = num;
	fob_num_sensors = 0;

	printf("FBB addressing mode: %s (%x)\n", str, retval1);


	// Flock System Status

	sio_putc(0x4F); // Examine Value (FoBman p.73)
	sio_putc(36); // Flock System Status mode (FoBman p.130)

	//printf("Flock System Status (max %d birds)\n", num);
	for (i = 0; i < num; ++i) {
		retval = sio_getc();
#if 0
		printf("%3d: %s, %s, %s, %s, %s, %s, %s, %s\n", i,
				(retval & 0x80) ? "ACCESSIBLE" : "not accessible",
				(retval & 0x40) ? "RUNNING" : "not running",
				(retval & 0x20) ? "a SENSOR exists" : "no sensors",
				(retval & 0x10) ? "ERT" : "not ert",
				(retval & 0x8) ? "ERT#3" : "no ert#3",
				(retval & 0x4) ? "ERT#2" : "no ert#2",
				(retval & 0x2) ? "ERT#1" : "no ert#1",
				(retval & 0x1) ? "ERT#0 or SRT" : "no ert#0 nor srt");
#endif
		if (retval & 0x80) {
			++fob_num_birds;
		}
		if (retval & 0x20) {
			fob_sensors[fob_num_sensors] = i + 1;
			++fob_num_sensors;
		}
	}

#if 0
	printf("fob_addrmode: %d\n", fob_addrmode);
	printf("fob_maxaddrs: %d\n", fob_maxaddrs);
	printf("fob_num_sensors: %d\n", fob_num_sensors);
	for (i = 0; i < fob_num_sensors; ++i) {
		printf("fob_sensors[%d]: %d\n", i, fob_sensors[i]);
	}
#endif
	printf("fob_num_birds: %d\n", fob_num_birds);
}
Ejemplo n.º 17
0
int
main(void)
{
    uint8_t autoboot;
    boot2_ino_t ino;

    kname = NULL;
    boot2_dmadat =
		(void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
    v86.ctl = V86_FLAGS;
    v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
    dsk.drive = *(uint8_t *)PTOV(MEM_BTX_USR_ARG);
    dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
    dsk.unit = dsk.drive & DRV_MASK;
    dsk.slice = *(uint8_t *)PTOV(MEM_BTX_USR_ARG + 1) + 1;
    bootinfo.bi_version = BOOTINFO_VERSION;
    bootinfo.bi_size = sizeof(bootinfo);

    autoboot = 1;

    /*
     * Probe the default disk and process the configuration file if
     * successful.
     */
    if (dskprobe() == 0) {
	if ((ino = fsapi->fslookup(PATH_CONFIG)))
	    fsapi->fsread(ino, cmd, sizeof(cmd));
    }

    /*
     * Parse config file if present.  parse() will re-probe if necessary.
     */
    if (cmd[0]) {
	printf("%s: %s", PATH_CONFIG, cmd);
	if (parse())
	    autoboot = 0;
	/* Do not process this command twice */
	*cmd = 0;
    }

    /*
     * Setup our (serial) console after processing the config file.  If
     * the initialization fails, don't try to use the serial port.  This
     * can happen if the serial port is unmaped (happens on new laptops a lot).
     */
    if ((opts & (RBF_MUTE|RBF_SERIAL|RBF_VIDEO)) == 0)
	opts |= RBF_SERIAL|RBF_VIDEO;
    if (opts & RBF_SERIAL) {
	if (sio_init())
	    opts = RBF_VIDEO;
    }


    /*
     * Try to exec stage 3 boot loader. If interrupted by a keypress,
     * or in case of failure, try to load a kernel directly instead.
     *
     * We have to try boot /boot/loader and /loader to support booting
     * from a /boot partition instead of a root partition.
     */
    if (autoboot && !kname) {
        kname = PATH_BOOT3;
	if (!keyhit(3*SECOND)) {
	    load();
	    kname = PATH_BOOT3_ALT;
	    load();
	    kname = PATH_KERNEL;
	}
    }

    /* Present the user with the boot2 prompt. */

    for (;;) {
	printf("\nDragonFly boot\n"
	       "%u:%s(%u,%c)%s: ",
	       dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
	       'a' + dsk.part, kname);
	if (!autoboot || keyhit(5*SECOND))
	    getstr();
	else
	    putchar('\n');
	autoboot = 0;
	if (parse())
	    putchar('\a');
	else
	    load();
    }
}
Ejemplo n.º 18
0
sio_status_t * sio_open( int devnum )
{
	char dev[20];

	/* would be nice with dynamic memory alloc */
	sio_status_t * siostate = &statusar[ devnum ];
/* 	siostruct_t * tmp; */


/* 	tmp = (siostruct_t*)(netif->state); */
/* 	tmp->sio = siostate; */

/* 	tmp = (siostruct_t*)(netif->state); */

/* 	((sio_status_t*)(tmp->sio))->fd = 0; */

#if ! PPP_SUPPORT
	fifoInit( &siostate->myfifo );
#endif /* ! PPP_SUPPORT */

	snprintf( dev, sizeof(dev), "/dev/ttyS%d", devnum );

	if ( (devnum == 1) || (devnum == 0) )
	{
		if ( ( siostate->fd = sio_init( dev, devnum, siostate ) ) == 0 )
		{
			LWIP_DEBUGF(SIO_DEBUG, ( "sio_open: ERROR opening serial device\n" ));
			abort( );
			return NULL;
		}
	}
#if PPP_SUPPORT
	else if (devnum == 2) {
	    pid_t childpid;
	    childpid = forkpty(&siostate->fd, NULL, NULL, NULL);
	    if(childpid < 0) {
		perror("forkpty");
		exit (1);
	    }
	    if(childpid == 0) {
		execl("/usr/sbin/pppd", "pppd",
			"ms-dns", "198.168.100.7",
			"local", "crtscts",
			"debug",
#ifdef LWIP_PPP_CHAP_TEST
			"auth",
			"require-chap",
			"remotename", "lwip",
#else
			"noauth",
#endif
			"192.168.1.1:192.168.1.2",
			NULL);
		perror("execl pppd");
		exit (1);
	    } else {
		LWIP_DEBUGF(SIO_DEBUG, ( "sio_open: spawned pppd pid %d\n", childpid));
	    }

	}
#endif
	else
	{
		LWIP_DEBUGF(SIO_DEBUG, ( "sio_open: device %s (%d) is not supported\n", dev, devnum ));
		return NULL;
	}
	LWIP_DEBUGF( 1,("sio_open: dev=%s open.\n", dev ));

	return siostate;
}
Ejemplo n.º 19
0
EXPORT ER knl_init_device( void )
{
    pll_init();
    sio_init();
	return E_OK;
}
Ejemplo n.º 20
0
static int
parse(char *cmdstr, int *dskupdated)
{
    char *arg = cmdstr;
    char *ep, *p, *q;
    const char *cp;
    unsigned int drv;
    int c, i, j;

    *dskupdated = 0;
    while ((c = *arg++)) {
	if (c == ' ' || c == '\t' || c == '\n')
	    continue;
	for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
	ep = p;
	if (*p)
	    *p++ = 0;
	if (c == '-') {
	    while ((c = *arg++)) {
		if (c == 'P') {
		    if (*(uint8_t *)PTOV(0x496) & 0x10) {
			cp = "yes";
		    } else {
			opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL);
			cp = "no";
		    }
		    printf("Keyboard: %s\n", cp);
		    continue;
		} else if (c == 'S') {
		    j = 0;
		    while ((unsigned int)(i = *arg++ - '0') <= 9)
			j = j * 10 + i;
		    if (j > 0 && i == -'0') {
			comspeed = j;
			break;
		    }
		    /* Fall through to error below ('S' not in optstr[]). */
		}
		for (i = 0; c != optstr[i]; i++)
		    if (i == NOPT - 1)
			return -1;
		opts ^= OPT_SET(flags[i]);
	    }
	    ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
		     OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
	    if (ioctrl & IO_SERIAL) {
	        if (sio_init(115200 / comspeed) != 0)
		    ioctrl &= ~IO_SERIAL;
	    }
	} else {
	    for (q = arg--; *q && *q != '('; q++);
	    if (*q) {
		drv = -1;
		if (arg[1] == ':') {
		    drv = *arg - '0';
		    if (drv > 9)
			return (-1);
		    arg += 2;
		}
		if (q - arg != 2)
		    return -1;
		for (i = 0; arg[0] != dev_nm[i][0] ||
			    arg[1] != dev_nm[i][1]; i++)
		    if (i == NDEV - 1)
			return -1;
		dsk.type = i;
		arg += 3;
		dsk.unit = *arg - '0';
		if (arg[1] != 'p' || dsk.unit > 9)
		    return -1;
		arg += 2;
		dsk.part = *arg - '0';
		if (dsk.part < 1 || dsk.part > 9)
		    return -1;
		arg++;
		if (arg[0] != ')')
		    return -1;
		arg++;
		if (drv == -1)
		    drv = dsk.unit;
		dsk.drive = (dsk.type <= TYPE_MAXHARD
			     ? DRV_HARD : 0) + drv;
		*dskupdated = 1;
	    }
	    if ((i = ep - arg)) {
		if ((size_t)i >= sizeof(kname))
		    return -1;
		memcpy(kname, arg, i + 1);
	    }
	}
	arg = p;
    }
    return 0;
}
Ejemplo n.º 21
0
/*
=======================================
    WinMain 程序入口
=======================================
*/
int WINAPI
WinMain (
  __CR_IN__ HINSTANCE   curt_app,
  __CR_IN__ HINSTANCE   prev_app,
  __CR_IN__ LPSTR       cmd_line,
  __CR_IN__ int         cmd_show
    )
{
    uint_t      argc;
    ansi_t**    argv;

    CR_NOUSE(prev_app);
    CR_NOUSE(cmd_show);

    /* 只允许一个例程 */
    if (misc_is_running(EXE_XNAME))
        return (QST_ERROR);

    /* 建立 CrHack 系统 */
    if (!set_app_type(CR_APP_GUI))
        return (QST_ERROR);
    mem_zero(&s_wrk_ctx, sizeof(s_wrk_ctx));

    int qt_argc;

    /* 获取命令行参数, 不包括进程文件名 */
    argv = misc_get_param(cmd_line, &argc);
    qt_argc = (int)argc;

    QApplication    qt_app(qt_argc, argv);

    qt_app.setApplicationName("QstComm");
    qt_app.setOrganizationName("QuestLAB");

    sint_t  x1, y1;
    uint_t  ww, hh;

    /* 生成一个可变大小的窗口 */
    mtlock_init(&s_wrk_ctx.lock);
    qst_load_cfg(&s_wrk_ctx.cfgs);
    misc_desk_init(WIN_ICONF, &x1, &y1, &ww, &hh,
                   QCOM_DEF_WIDTH, QCOM_DEF_HEIGHT);
    if (ww < QCOM_DEF_WIDTH)  ww = QCOM_DEF_WIDTH;
    if (hh < QCOM_DEF_HEIGHT) hh = QCOM_DEF_HEIGHT;

    RECT            w_rect;
    sint_t          fw, fh;
    QMainWindow     qt_win;

    /* Qt 里的宽高都不包括边框
       需要自己用 Win32 API 获取 */
    qt_win.setWindowFlags(qt_win.windowFlags()
        & (~Qt::WindowMaximizeButtonHint));
    qt_win.move(x1, y1);
    qt_win.resize(ww, hh);
    s_wrk_ctx.hwnd = (HWND)qt_win.winId();
    if (!GetWindowRect(s_wrk_ctx.hwnd, &w_rect))
        return (QST_ERROR);
    fw = w_rect.right - w_rect.left - ww;
    fh = w_rect.bottom - w_rect.top - hh;
    qt_win.setMinimumSize(QCOM_DEF_WIDTH  - fw,
                          QCOM_DEF_HEIGHT - fh);
    qt_win.resize(ww - fw, hh - fh);

    QWidget*        cent = new QWidget (&qt_win);
    CTextEdit*      edit = new CTextEdit (cent);
    QHBoxLayout*    hori = new QHBoxLayout (cent);

    /* 创建窗体里的控件 */
    hori->setSpacing(6);
    hori->setContentsMargins(8, 8, 8, 8);
    hori->addWidget(edit);
    qt_win.setCentralWidget(cent);

    CTextOper   oper(&qt_win, edit);

    s_wrk_ctx.oper = (void_t*)(&oper);
    SetClassLongPtr(s_wrk_ctx.hwnd, GCLP_HICON, (LONG_PTR)
                    LoadIconA(curt_app, (ansi_t*)101));

    /* 初始化 ANSI 上下文 */
    if (!qst_csi_init())
        return (QST_ERROR);
    qst_set_viewer(&s_wrk_ctx);

    /* 初始化网络 */
    if (!socket_init())
        return (QST_ERROR);
    s_wrk_ctx.netw = netw_cli_open(EXE_XNAME);
    if (s_wrk_ctx.netw == NULL)
        return (QST_ERROR);

    /* 读取需要超时, 不然线程无法退出 */
    socket_set_timeout(s_wrk_ctx.netw, -1, QST_TCP_TOUT);

    thrd_t  thrd;

    /* 生成工作线程 */
    s_wrk_ctx.quit = FALSE;
    s_wrk_ctx.comm.quit = FALSE;
    s_wrk_ctx.comm.text = TRUE;
    s_wrk_ctx.comm.rtype = "text";
    s_wrk_ctx.comm.stype = "text";
    s_wrk_ctx.comm.title = NULL;
    s_wrk_ctx.comm.render = qst_txt_show;
    s_wrk_ctx.page = get_sys_codepage();
    qst_update_title(&s_wrk_ctx);
    thrd = thread_new(0, qst_com_main, &s_wrk_ctx, FALSE);
    if (thrd == NULL)
        return (QST_ERROR);
    sio_init();

    /* 开始 Qt 流程 */
    qt_win.show();
    qt_app.exec();

    /* 关闭线程直接退出 */
    if (!s_wrk_ctx.quit)
        s_wrk_ctx.quit = TRUE;
    thread_wait(thrd);
    thread_del(thrd);
    netw_cli_close(s_wrk_ctx.netw);
    sio_free();
    qst_csi_free();
    return (QST_OKAY);
}
Ejemplo n.º 22
0
static int
parse()
{
    char *arg = cmd;
    char *ep, *p, *q;
    const char *cp;
    unsigned int drv;
    int c, i, j;
    size_t k;

    while ((c = *arg++)) {
	if (c == ' ' || c == '\t' || c == '\n')
	    continue;
	for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
	ep = p;
	if (*p)
	    *p++ = 0;
	if (c == '-') {
	    while ((c = *arg++)) {
		if (c == 'P') {
		    if (*(uint8_t *)PTOV(0x496) & 0x10) {
			cp = "yes";
		    } else {
			opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL);
			cp = "no";
		    }
		    printf("Keyboard: %s\n", cp);
		    continue;
#if SERIAL
		} else if (c == 'S') {
		    j = 0;
		    while ((unsigned int)(i = *arg++ - '0') <= 9)
			j = j * 10 + i;
		    if (j > 0 && i == -'0') {
			comspeed = j;
			break;
		    }
		    /* Fall through to error below ('S' not in optstr[]). */
#endif
		}
		for (i = 0; c != optstr[i]; i++)
		    if (i == NOPT - 1)
			return -1;
		opts ^= OPT_SET(flags[i]);
	    }
#if SERIAL
	    ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
		     OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
	    if (DO_SIO) {
	        if (sio_init(115200 / comspeed) != 0)
		    ioctrl &= ~IO_SERIAL;
	    }
#endif
	} else {
	    for (q = arg--; *q && *q != '('; q++);
	    if (*q) {
		drv = -1;
		if (arg[1] == ':') {
		    drv = *arg - '0';
		    if (drv > 9)
			return (-1);
		    arg += 2;
		}
		if (q - arg != 2)
		    return -1;
		for (i = 0; arg[0] != dev_nm[i][0] ||
			    arg[1] != dev_nm[i][1]; i++)
		    if (i == NDEV - 1)
			return -1;
		dsk.type = i;
		arg += 3;
		dsk.unit = *arg - '0';
		if (arg[1] != ',' || dsk.unit > 9)
		    return -1;
		arg += 2;
		dsk.slice = WHOLE_DISK_SLICE;
		if (arg[1] == ',') {
		    dsk.slice = *arg - '0' + 1;
		    if (dsk.slice > NDOSPART + 1)
			return -1;
		    arg += 2;
		}
		if (arg[1] != ')')
		    return -1;
		dsk.part = *arg - 'a';
		if (dsk.part > 7)
		    return (-1);
		arg += 2;
		if (drv == -1)
		    drv = dsk.unit;
		dsk.drive = (dsk.type <= TYPE_MAXHARD
			     ? DRV_HARD : 0) + drv;
		dsk_meta = 0;
	    }
	    k = ep - arg;
	    if (k > 0) {
		if (k >= sizeof(knamebuf))
		    return -1;
		memcpy(knamebuf, arg, k + 1);
		kname = knamebuf;
	    }
	}
	arg = p;
    }
    return 0;
}
Ejemplo n.º 23
0
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
	static const uint16_t spd_addr[] = {
		// Node 0
		DIMM0, DIMM1, DIMM2, 0,
		0, 0, 0, 0,
		// Node 1
		0, 0, 0, 0,
		0, 0, 0, 0,
	};
	unsigned bsp_apicid = 0;
	int needs_reset = 0;
	struct sys_info *sysinfo = &sysinfo_car;

	sio_init();
	w83697hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
	console_init();
	enable_rom_decode();

	print_info("now booting... fallback\n");

	/* Is this a CPU only reset? Or is this a secondary CPU? */
	if (!cpu_init_detectedx && boot_cpu()) {
		/* Nothing special needs to be done to find bus 0. */
		/* Allow the HT devices to be found. */
		enumerate_ht_chain();
	}

	// FIXME why is this executed again? --->
	sio_init();
	w83697hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
	console_init();
	enable_rom_decode();
	// <--- FIXME why is this executed again?

	print_info("now booting... real_main\n");

	if (bist == 0)
		bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);

	/* Halt if there was a built in self test failure. */
	report_bist_failure(bist);

	setup_default_resource_map();
	setup_coherent_ht_domain();
	wait_all_core0_started();

	print_info("now booting... Core0 started\n");

#if CONFIG_LOGICAL_CPUS
	/* It is said that we should start core1 after all core0 launched. */
	start_other_cores();
	wait_all_other_cores_started(bsp_apicid);
#endif
	init_timer();
	ht_setup_chains_x(sysinfo); /* Init sblnk and sbbusn, nodes, sbdn. */

	needs_reset = optimize_link_coherent_ht();
	needs_reset |= optimize_link_incoherent_ht(sysinfo);
	needs_reset |= k8t890_early_setup_ht();

	if (needs_reset) {
		print_debug("ht reset -\n");
		soft_reset();
	}

	/* the HT settings needs to be OK, because link freq change may cause HT disconnect */
	vt8237_sb_enable_fid_vid();
	enable_fid_change();
	init_fidvid_bsp(bsp_apicid);

	/* Stop the APs so we can start them later in init. */
	allow_all_aps_stop(bsp_apicid);

	/* It's the time to set ctrl now. */
	fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);

	enable_smbus();

	/* this seems to be some GPIO on the SMBus--in any case, setting these
	 * two bits reduces the pullup impedance of the bus lines and is required
	 * in order to be able to read SPD info */
	smbus_write_byte(0x48, 0x07, smbus_read_byte(0x48, 0x07) | 0x80);
	smbus_write_byte(0x4a, 0x07, smbus_read_byte(0x4a, 0x07) | 0x10);

	unsigned char mask;

	mask = 0;
//	mask |= 1 /* AGP voltage 1.7 V (not verified, just vendor BIOS value) */
//	mask |= 2 /* V-Link voltage 2.6 V (not verified either) */
	smbus_write_byte(0x4a, 0x00, (smbus_read_byte(0x4a, 0x00) & ~0x0f) | (0x0f ^ (mask << 2)));
	smbus_write_byte(0x4a, 0x01, (smbus_read_byte(0x4a, 0x01) & ~0x03) | (0x03 ^ mask));

	mask = 25; /* RAM voltage in decivolts, valid range from 25 to 28 */
	mask = 3 - (mask - 25);
	smbus_write_byte(0x4a, 0x02, 0x4f | (mask << 4));
	smbus_write_byte(0x4a, 0x03, 0x04 | mask);

	sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);
	post_cache_as_ram();
}
Ejemplo n.º 24
0
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
	static const u16 spd_addr[] = { DIMM0, DIMM2, 0, 0, DIMM1, DIMM3, 0, 0, };
	int needs_reset = 0;
	u32 bsp_apicid = 0;
	msr_t msr;
	struct cpuid_result cpuid1;
	struct sys_info *sysinfo = &sysinfo_car;

	if (!cpu_init_detectedx && boot_cpu()) {
		/* Nothing special needs to be done to find bus 0 */
		/* Allow the HT devices to be found */
		enumerate_ht_chain();
		/* sb7xx_51xx_lpc_port80(); */
		sb7xx_51xx_pci_port80();
	}

	if (bist == 0)
		bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);

	enable_rs780_dev8();
	sb7xx_51xx_lpc_init();

	sio_init();
	winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);

	console_init();

	/* Halt if there was a built in self test failure */
	report_bist_failure(bist);
	printk(BIOS_DEBUG, "bsp_apicid=0x%x\n", bsp_apicid);

	setup_939a785gmh_resource_map();

	setup_coherent_ht_domain();

#if CONFIG_LOGICAL_CPUS
	/* It is said that we should start core1 after all core0 launched */
	wait_all_core0_started();
	start_other_cores();
#endif
	wait_all_aps_started(bsp_apicid);

	ht_setup_chains_x(sysinfo);

	/* run _early_setup before soft-reset. */
	rs780_early_setup();
	sb7xx_51xx_early_setup();

	/* Check to see if processor is capable of changing FIDVID  */
	/* otherwise it will throw a GP# when reading FIDVID_STATUS */
	cpuid1 = cpuid(0x80000007);
	if ((cpuid1.edx & 0x6) == 0x6) {
		/* Read FIDVID_STATUS */
		msr=rdmsr(0xc0010042);
		printk(BIOS_DEBUG, "begin msr fid, vid: hi=0x%x, lo=0x%x\n", msr.hi, msr.lo);

		enable_fid_change();
		enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn);
		init_fidvid_bsp(bsp_apicid);

		/* show final fid and vid */
		msr=rdmsr(0xc0010042);
		printk(BIOS_DEBUG, "end msr fid, vid: hi=0x%x, lo=0x%x\n", msr.hi, msr.lo);
	} else {
		printk(BIOS_DEBUG, "Changing FIDVID not supported\n");
	}

	needs_reset = optimize_link_coherent_ht();
	needs_reset |= optimize_link_incoherent_ht(sysinfo);
	rs780_htinit();
	printk(BIOS_DEBUG, "needs_reset=0x%x\n", needs_reset);

	if (needs_reset) {
		printk(BIOS_INFO, "ht reset -\n");
		soft_reset();
	}

	allow_all_aps_stop(bsp_apicid);

	/* It's the time to set ctrl now; */
	printk(BIOS_DEBUG, "sysinfo->nodes: %2x  sysinfo->ctrl: %p  spd_addr: %p\n",
		     sysinfo->nodes, sysinfo->ctrl, spd_addr);
	fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);
	sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);

	rs780_before_pci_init();
	sb7xx_51xx_before_pci_init();

	post_cache_as_ram();
}
Ejemplo n.º 25
0
static int
parse()
{
    char *arg = cmd;
    char *p, *q;
    unsigned int drv;
    int c, i;

    while ((c = *arg++)) {
	if (c == ' ' || c == '\t' || c == '\n')
	    continue;
	for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
	if (*p)
	    *p++ = 0;
	if (c == '-') {
	    while ((c = *arg++)) {
		for (i = 0; c != optstr[i]; i++)
		    if (i == NOPT - 1)
			return -1;
		opts ^= 1 << flags[i];
	    }
	    if (opts & 1 << RBX_PROBEKBD) {
		i = *(uint8_t *)PTOV(0x496) & 0x10;
		printf("Keyboard: %s\n", i ? "yes" : "no");
		if (!i)
		    opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
		opts &= ~(1 << RBX_PROBEKBD);
	    }
	    ioctrl = opts & 1 << RBX_DUAL ? (IO_SERIAL|IO_KEYBOARD) :
		     opts & 1 << RBX_SERIAL ? IO_SERIAL : IO_KEYBOARD;
	    if (ioctrl & IO_SERIAL)
	        sio_init();
	} else {
	    for (q = arg--; *q && *q != '('; q++);
	    if (*q) {
		drv = -1;
		if (arg[1] == ':') {
		    drv = *arg - '0';
		    if (drv > 9)
			return (-1);
		    arg += 2;
		}
		if (q - arg != 2)
		    return -1;
		for (i = 0; arg[0] != dev_nm[i][0] ||
			    arg[1] != dev_nm[i][1]; i++)
		    if (i == NDEV - 1)
			return -1;
		dsk.type = i;
		arg += 3;
		dsk.unit = *arg - '0';
		if (arg[1] != ',' || dsk.unit > 9)
		    return -1;
		arg += 2;
		dsk.slice = WHOLE_DISK_SLICE;
		if (arg[1] == ',') {
		    dsk.slice = *arg - '0' + 1;
		    if (dsk.slice > NDOSPART)
			return -1;
		    arg += 2;
		}
		if (arg[1] != ')')
		    return -1;
		dsk.part = *arg - 'a';
		if (dsk.part > 7)
		    return (-1);
		arg += 2;
		if (drv == -1)
		    drv = dsk.unit;
		dsk.drive = (dsk.type <= TYPE_MAXHARD
			     ? DRV_HARD : 0) + drv;
		dsk_meta = 0;
	    }
	    if ((i = p - arg - !*(p - 1))) {
		if ((size_t)i >= sizeof(kname))
		    return -1;
		memcpy(kname, arg, i + 1);
	    }
	}
	arg = p;
    }
    return 0;
}
Ejemplo n.º 26
0
//--------------------------------------------------------------
int _start(int argc, const char **argv)
{
	iop_thread_t thread_param;
	register int thread_id;
	iop_library_t *libptr;
	int i, mcman_loaded;
	void **export_tab;

#ifdef SIO_DEBUG
	sio_init(38400, 0, 0, 0, 0);
#endif
#ifdef DEBUG
	DPRINTF("mcserv: _start...\n");
#endif

	// Get mcman lib ptr
	mcman_loaded = 0;
	libptr = GetLoadcoreInternalData()->let_next;
	while (libptr != 0) {
		for (i=0; i<8; i++) {
			if (libptr->name[i] != mcman_modname[i])
				break;
		}
		if (i == 8) {
			mcman_loaded = 1;
			break;
		}
		libptr = libptr->prev;
	}

	if (!mcman_loaded) {
#ifdef DEBUG
		DPRINTF("mcserv: mcman module is not loaded...\n");
#endif
		goto err_out;
	}

#ifdef DEBUG
	DPRINTF("mcserv: mcman version=%03x\n", libptr->version);
#endif
	if (libptr->version > 0x200)
		mcman_type = XMCMAN;

	// Get mcman export table
	export_tab = (void **)(((struct irx_export_table *)libptr)->fptrs);

	// Set functions pointers to match MCMAN exports
	McDetectCard = export_tab[5];
	McOpen = export_tab[6];
	McClose = export_tab[7];
	McRead = export_tab[8];
	McWrite = export_tab[9];
	McSeek = export_tab[10];
	McFormat = export_tab[11];
	McGetDir = export_tab[12];
	McDelete = export_tab[13];
	McFlush = export_tab[14];
	McChDir = export_tab[15];
	McSetFileInfo = export_tab[16];
	McEraseBlock = export_tab[17];
	McReadPage = export_tab[18];
	McWritePage = export_tab[19];
	McDataChecksum = export_tab[20];
	McReplaceBadBlock = export_tab[24]; // dummy in MCMAN !!!
	McReadPS1PDACard = export_tab[29];
	McWritePS1PDACard = export_tab[30];
	McUnformat = export_tab[36];
	McRetOnly = export_tab[37];
	McGetFreeClusters = export_tab[38];
	McGetMcType = export_tab[39];
	McSetPS1CardFlag = export_tab[40];

	// Set functions pointers to match XMCMAN exports if needed
	if (mcman_type == XMCMAN) {
	McDetectCard2 = export_tab[21];
	McGetFormat = export_tab[22];
	McGetEntSpace = export_tab[23];
	McGetModuleInfo = export_tab[42];
	McCheckBlock = export_tab[45];
	}

	// Register mcserv dummy export table
#ifdef DEBUG
	DPRINTF("mcserv: registering exports...\n");
#endif
	if (RegisterLibraryEntries(&_exp_mcserv) != 0)
		goto err_out;

	CpuEnableIntr();

#ifdef DEBUG
	DPRINTF("mcserv: starting RPC thread...\n");
#endif
 	thread_param.attr = TH_C;
 	thread_param.thread = (void *)thread_rpc_S_0400;
 	thread_param.priority = 0x68;
 	thread_param.stacksize = 0x1000;
 	thread_param.option = 0;

	thread_id = CreateThread(&thread_param);
	mcserv_tidS_0400 = thread_id;

	StartThread(thread_id, 0);

#ifdef DEBUG
	DPRINTF("mcserv: _start returns MODULE_RESIDENT_END...\n");
#endif

	return MODULE_RESIDENT_END;

err_out:

#ifdef DEBUG
	DPRINTF("mcserv: _start returns MODULE_NO_RESIDENT_END...\n");
#endif

	return MODULE_NO_RESIDENT_END;
}