Ejemplo n.º 1
0
static int
calc_looperms(void)
{
    int	i, count, c;
    int	totalloops = 0;

    serial_init();
    serial_set(TESTBAUD);		/* set 300 baud */
    serial_loopback(1);		/* enable loop back mode */

    for (i=0; i < NBYTES; i++)
    {
        count = 1;
        serial_putc(0xaa);	/* xmit character */

        /*
         * The timing loop is the same as the loops in serial_read.
         * Any changes to the loops in serial_read should be reflected
         * here.
         */
        do
        {
            c = serial_getc();
        } while (c < 0 && count++ > 0);

        totalloops += count;
    }

    serial_loopback(0);

    return(totalloops/TOTAL_MS);
}
Ejemplo n.º 2
0
void duart_initialize(void)
{
    if (duart_already_init == FALSE) {
	/* Calculate the time constant for timeouts on serial_read. */
	if ((looperms = calc_looperms()) <= 0)
	    looperms = DFLTLOOPERMS;
    }

    /* Initialize the serial port and set the baud rate.
     * The baud rate is set here for sanity only; the autobaud
     * mechanism will change it as required when the host connects.
     */

    serial_init();
    serial_set(baud_rate?baud_rate:9600L);  

    duart_already_init = TRUE;
}						
Ejemplo n.º 3
0
int setserial_main(int argc UNUSED_PARAM, char **argv)
{
	int opts;

	opt_complementary = "-1:b-aG:G-ab:a-bG";
	opts = getopt32(argv, "bGavzg");
	argv += optind;

	if (!argv[1]) /* one arg only? */
		opts |= OPT_GET;

	if (!(opts & OPT_GET)) {
		serial_set(argv, opts);
		argv[1] = NULL;
	}

	if (opts & (OPT_VERBOSE | OPT_GET)) {
		do {
			serial_get(*argv++, opts & OPT_MODE_MASK);
		} while (*argv);
	}

	return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
void uart_test ()
{
    volatile int loop;
    int	looplim;
    int int_id;
    unsigned long* reg_ptr;
    int i, baud;

    /*11/01/00 */
    char info[] = {"Move Console Cable back to Connector J9 and hit <CR> to exit test"};
    int index;

    looplim = 400000;

    /* perform tests on both UARTs */
    for (uart_unit = 0; uart_unit < 2; uart_unit++)
    {

        if (uart_unit == 0)
            int_id = UART1_INT_ID;
        else
            int_id = UART2_INT_ID;

        if (!bus_test ())
            printf ("\nERROR:  bus_test for UART Unit %d failed\n", uart_unit);
        else
        {
            printf ("\nbus_test for UART Unit %d passed\n", uart_unit);

            uart_int = 0;

            isr_connect (int_id, uart_isr, 0);

            if (enable_external_interrupt(int_id) != OK)
                printf("ERROR enabling UART UINT %d interrupt!\n", uart_unit);

            init_uart ();

            loop = 0;

            while (!uart_int && (loop < looplim))
                loop++;
            if (!uart_int)
                printf ("UART Unit %d INTERRUPT test failed %X\n", uart_unit, loop) ;
            else
                printf ("UART Unit %d INTERRUPT test passed\n", uart_unit);

            serial_putc(' ');
        }

        /* disable UART interrupt */
        if (disable_external_interrupt(int_id)!= OK)
            printf("ERROR disabling UART UNIT %d interrupt!\n", uart_unit);

        /* disconnect test handler */
        isr_disconnect (int_id);

    }

    /* 11/01/00 */
    /* #if 0 */	 /* writing to port 2 doesnt work yet... */
#if 1 /* writing to port 2 doesnt work yet... */

    /*
    	printf ("\nMove the Console Cable to the 2nd Serial Port,\n");
    	printf ("Connector J10,\n");
        printf ("and Hit <CR> when the cable is connected.\n\n");
    	printf ("After alphabet prints, move Console Cable back to 1st Serial Port,\n");
    	printf ("Connector J9,\n");
    	printf ("and hit <CR> to exit test\n");
    */

    /* 10/30/00 */
    uart_unit = DFLTPORT;	/* test J10, the PCI-700 GDB port */

    printf ("\nMove the Console Cable to the 2nd Serial Port, Connector J10,\n");
    printf ("and Hit <CR> when the cable is connected.\n");
    printf ("The alphabet should print on the screen.\n\n");

    /* 11/01/00 */
    /*
    	printf ("After alphabet prints, move Console Cable back to 1st Serial Port,\n");
    	printf ("Connector J9,\n");
    	printf ("and hit <CR> to exit test\n");
    */
    baud = 115200;
    serial_init();
    serial_set(baud?baud:115200L);

    /*	while (serial_getc() == -1); */
    while (serial_getc() != 0x0d);	/* wait for a carriage return character to start test */

    /*
    	while (1)
    	{
    		for ( i = 65; i <= 90; i++ )
    			serial_putc(i);
    	}
    */
    for ( i = 65; i <= 90; i++ )	/* transmit the alphabet */
        serial_putc(i);

    serial_putc(10);	/* transmit a New Line */
    serial_putc(13);	/* transmit a Carriage Return */
    serial_putc(10);	/* transmit a New Line */

    for (index=0; info[index] != '\0'; index++)		/* transmit some instructions to the user */
    {
        serial_putc(info[index]);
    }


    /* point at default port before returning */
    /*	uart_unit = DFLTPORT; */

    (void)hexIn();

#endif

    printf ("\n\nUART tests done.\n");

    printf ("Press return to continue.\n");
    (void) hexIn();
}
Ejemplo n.º 5
0
int racinix_dispatcher()
{
	unsigned rtc_hook_id = RTC_HOOK_BIT;
	if (rtc_subscribe_int(&rtc_hook_id, false, true, false) < 0)
	{
		return 1;
	}
	unsigned long seed = racinix_generate_seed();
	srand(seed);
	if (racinix_rtc_reprogram_alarm())
	{
		return 1;
	}
	unsigned mouse_hook_id = MOUSE_HOOK_BIT;
	if (mouse_subscribe_int(&mouse_hook_id) == -1)
	{
		return 1;
	}
	if (mouse_set_stream_mode(MOUSE_NUM_TRIES))
	{
		return 1;
	}
	if (mouse_enable_stream_mode(MOUSE_NUM_TRIES))
	{
		return 1;
	}
	mouse_discard_interrupts(MOUSE_NUM_TRIES, MOUSE_HOOK_BIT);

	if (keyboard_subscribe_int() == -1)
	{
		return 1;
	}

	unsigned char timer_hook_bit;
	if ((timer_hook_bit = timer_subscribe_int()) < 0)
	{
		return 1;
	}

	unsigned serial_hook_id = SERIAL_HOOK_BIT;
	if (serial_subscribe_int(&serial_hook_id, RACINIX_SERIAL_PORT_NUMBER, RACINIX_SERIAL_TRIGGER_LEVEL) == -1)
	{
		return 1;
	}

	if (serial_set(RACINIX_SERIAL_PORT_NUMBER, RACINIX_SERIAL_NUM_BITS, RACINIX_SERIAL_NUM_STOP_BITS, RACINIX_SERIAL_PARITY, RACINIX_SERIAL_BAUD_RATE))
	{
		return 1;
	}

	mouse_data_packet_t old_mouse_data_packet, new_mouse_data_packet;
	old_mouse_data_packet.left_button = old_mouse_data_packet.middle_button = old_mouse_data_packet.right_button = false;
	int r, ipc_status;
	unsigned fps_counter;
	message msg;
	key_t key;
	while(1) // Main loop
	{
		// Get a request message.
		if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
			// Driver receive fail
			continue;
		}
		if (is_ipc_notify(ipc_status)) { // received notification
			if (_ENDPOINT_P(msg.m_source) == HARDWARE) // hardware interrupt notification
			{
				// Keyboard
				if (msg.NOTIFY_ARG & BIT(KEYBOARD_HOOK_BIT)) {
					if ((key = racinix_keyboard_int_handler()) == -1)
					{
						return 1;
					}
					if (racinix_event_handler(RACINIX_EVENT_KEYSTROKE, kbd_keys[key].makecode, kbd_keys[key].pressed) == -1)
					{
						break;
					}
				}
				// Timer
				if (msg.NOTIFY_ARG & BIT(timer_hook_bit)) {
					if (racinix_serial_int_handler()) // Sometimes VMWare stops sending interrupts for no reason...
					{
						return 1;
					}
					if ((fps_counter = racinix_timer_int_handler()) != -1)
					{
						if (racinix_event_handler(RACINIX_EVENT_NEW_FRAME, fps_counter) == RACINIX_STATE_END)
						{
							break;
						}
					}
				}
				// Mouse
				if (msg.NOTIFY_ARG & BIT(MOUSE_HOOK_BIT)) {
					if (racinix_mouse_int_handler(&new_mouse_data_packet) == 0) // Packet ready
					{
						if (racinix_event_handler(RACINIX_EVENT_MOUSE_MOVEMENT, &new_mouse_data_packet) == RACINIX_STATE_END)
						{
							break;
						}
						if (new_mouse_data_packet.left_button != old_mouse_data_packet.left_button)
						{
							if (racinix_event_handler(RACINIX_EVENT_MOUSE_LEFT_BTN, new_mouse_data_packet.left_button) == RACINIX_STATE_END)
							{
								break;
							}
						}
						if (new_mouse_data_packet.right_button != old_mouse_data_packet.right_button)
						{
							if (racinix_event_handler(RACINIX_EVENT_MOUSE_RIGHT_BTN, new_mouse_data_packet.right_button) == RACINIX_STATE_END)
							{
								break;
							}
						}
						old_mouse_data_packet = new_mouse_data_packet;
					}
				}
				// Serial port
				if (msg.NOTIFY_ARG & BIT(SERIAL_HOOK_BIT))
				{
					if (racinix_serial_int_handler())
					{
						break;
					}
				}
				// RTC
				if (msg.NOTIFY_ARG & BIT(RTC_HOOK_BIT))
				{
					if (racinix_rtc_int_handler())
					{
						break;
					}
				}
			}
		}
	}
	timer_unsubscribe_int();
	keyboard_unsubscribe_int();
	mouse_disable_stream_mode(MOUSE_NUM_TRIES);
	mouse_unsubscribe_int(mouse_hook_id);
	rtc_unsubscribe_int(rtc_hook_id);
	return 0;
}