Beispiel #1
0
void octopus_keyboard_device::device_reset()
{
	buffered_rs232_device::device_reset();

	set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
	set_rcv_rate(1200);
	set_tra_rate(9600);
	receive_register_reset();
	transmit_register_reset();

	m_enabled = 0;
	m_delay = 500;  // 3*100+200
	m_repeat = 110;  // 4^2*5+30

	stop_processing();
	reset_key_state();
	typematic_stop();
	clear_fifo();

	output_dcd(0);
	output_dsr(0);
	output_cts(0);
	output_rxd(1);

	start_processing(attotime::from_hz(9600));
}
Beispiel #2
0
// MDSM entry point
int main(int argc, char *argv[])
{
    // Create main QCoreApplication instance
    QCoreApplication app(argc, argv);
    SURVEY* survey = file_process_arguments(argc, argv);

    // Initialise Dedispersion code and survey struct
    initialise(survey);

    unsigned char *input_buffer;

    // Process current chunk
    unsigned int counter = 0, data_read = 0;
    while (TRUE) 
    {
        // Get current buffer pointer
        input_buffer = get_buffer_pointer();

		// Read data from file
//		data_read = readBinaryData(input_buffer, survey -> fp, survey -> nbits, 
//                                   survey -> nsamp, survey -> nchans, survey -> nbeams);

        // Check if there is more processing to be done
		unsigned int x;
        next_chunk(survey -> nsamp, x, survey -> tsamp * survey -> nsamp * counter, survey -> tsamp);
		if (!start_processing(survey -> nsamp))  break;
       
        counter++;
    }

    // Tear down MDSM
    tearDown();
}
Beispiel #3
0
void apricot_keyboard_hle_device::device_reset()
{
	clear_fifo();

	receive_register_reset();
	transmit_register_reset();

	set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
	set_rcv_rate(7800);
	set_tra_rate(7800);

	reset_key_state();
	start_processing(attotime::from_hz(7800));
}
Beispiel #4
0
void m20_keyboard_device::device_reset()
{
	buffered_rs232_device::device_reset();

	reset_key_state();
	clear_fifo();

	set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2);
	set_rate(1'200);
	receive_register_reset();
	transmit_register_reset();

	output_dcd(0);
	output_dsr(0);
	output_cts(0);
	output_rxd(1);

	start_processing(attotime::from_hz(1'200));
}
Beispiel #5
0
static int s3c_pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	s3c_pp_instance_context_t *current_instance;
	s3c_pp_params_t *parg;

	unsigned int temp = 0;
    mutex_lock(h_mutex);

	current_instance	= (s3c_pp_instance_context_t *) file->private_data;
	parg	            = (s3c_pp_params_t *) arg;

	switch ( cmd )
    {
		case S3C_PP_SET_PARAMS:
            {
                s3c_pp_out_path_t temp_out_path; 
                unsigned int temp_src_width, temp_src_height, temp_dst_width, temp_dst_height;
                s3c_color_space_t temp_src_color_space, temp_dst_color_space;

                get_user(temp_out_path, &parg->out_path);

                if ( (-1 != s3c_pp_instance_info.fifo_mode_instance_no )
                     || ((s3c_pp_instance_info.dma_mode_instance_count) && (FIFO_FREERUN == temp_out_path)) )
                {
                    printk ( KERN_ERR "\n%s: S3C_PP_SET_PARAMS can't be executed.\n", __FUNCTION__ );
                    mutex_unlock(h_mutex);
    			    return -EINVAL; 
                }

    			get_user(temp_src_width,       &parg->src_width);
    			get_user(temp_src_height,      &parg->src_height);
    			get_user(temp_dst_width,       &parg->dst_width);
    			get_user(temp_dst_height,      &parg->dst_height);

                // S3C6410 support that the source image is up to 4096 x 4096
                //     and the destination image is up to 2048 x 2048.
    			if (    (temp_src_width > 4096) || (temp_src_height > 4096) 
                     || (temp_dst_width > 2048) || (temp_dst_height > 2048) )
    			{
    				printk(KERN_ERR "\n%s: Size is too big to be supported.\n", __FUNCTION__);
    				mutex_unlock(h_mutex);
    				return -EINVAL;
    			}
                
                get_user(temp_src_color_space, &parg->src_color_space);
                get_user(temp_dst_color_space, &parg->dst_color_space);

                if (    ( (temp_src_color_space == YC420) && (temp_src_width % 8) )
                     || ( (temp_src_color_space == RGB16) && (temp_src_width % 2) ) 
                     || ( (temp_out_path == DMA_ONESHOT) && (    ((temp_dst_color_space == YC420) && (temp_dst_width % 8))
                                                              || ((temp_dst_color_space == RGB16) && (temp_dst_width % 2)))) )
                {
    				printk(KERN_ERR "\n%s: YUV420 image width must be a multiple of 8.\n", __FUNCTION__);
                    printk(KERN_ERR "%s: RGB16 must be a multiple of 2.\n", __FUNCTION__);
    				mutex_unlock(h_mutex);
    				return -EINVAL;
                } 
                
                
    			get_user(current_instance->src_full_width,  &parg->src_full_width);
    			get_user(current_instance->src_full_height, &parg->src_full_height);
    			get_user(current_instance->src_start_x,     &parg->src_start_x);
    			get_user(current_instance->src_start_y,     &parg->src_start_y);
    			current_instance->src_width                 = temp_src_width;
    			current_instance->src_height                = temp_src_height;
                current_instance->src_color_space           = temp_src_color_space;

    			get_user(current_instance->dst_full_width,  &parg->dst_full_width);
                get_user(current_instance->dst_full_height, &parg->dst_full_height);
                get_user(current_instance->dst_start_x,     &parg->dst_start_x);
    			get_user(current_instance->dst_start_y,     &parg->dst_start_y);
    			current_instance->dst_width                 = temp_dst_width;
    			current_instance->dst_height                = temp_dst_height;
                current_instance->dst_color_space           = temp_dst_color_space;

                current_instance->out_path                  = temp_out_path;

                if ( DMA_ONESHOT == current_instance->out_path )
                {
                    s3c_pp_instance_info.instance_state[current_instance->instance_no] = PP_INSTANCE_INUSE_DMA_ONESHOT;
                    s3c_pp_instance_info.dma_mode_instance_count++;               
                }
                else
                {
                    get_user(current_instance->scan_mode, &parg->scan_mode);

                    current_instance->dst_color_space = RGB30;

                    s3c_pp_instance_info.instance_state[current_instance->instance_no] = PP_INSTANCE_INUSE_FIFO_FREERUN;
                    s3c_pp_instance_info.fifo_mode_instance_no = current_instance->instance_no;
                    s3c_pp_instance_info.wincon0_value_before_fifo_mode = __raw_readl ( S3C_WINCON0 );
                
                    //.[ REDUCE_VCLK_SYOP_TIME
                    if ( current_instance->src_height > current_instance->dst_height )
                    {
                        int i;

                        for ( i=2; (current_instance->src_height >= (i * current_instance->dst_height)) && (i<8); i++ )
                        {
                        }

                        current_instance->src_full_width  *= i;
                        current_instance->src_full_height /= i;
                        current_instance->src_height      /= i;
                    }
                    //.] REDUCE_VCLK_SYOP_TIME
                }

                current_instance->value_changed |= PP_VALUE_CHANGED_PARAMS;
            }
			break;

		case S3C_PP_START:
            dprintk ( "%s: S3C_PP_START last_instance=%d, curr_instance=%d\n", __FUNCTION__, 
                        s3c_pp_instance_info.last_running_instance_no, current_instance->instance_no );

            if ( PP_INSTANCE_READY == s3c_pp_instance_info.instance_state[current_instance->instance_no] )
            {
                printk ( KERN_ERR "%s: S3C_PP_START must be executed after running S3C_PP_SET_PARAMS.\n", __FUNCTION__ );
                mutex_unlock(h_mutex);
			    return -EINVAL;
            }

            if ( current_instance->instance_no != s3c_pp_instance_info.last_running_instance_no )
            {
                __raw_writel(0x0<<31, s3c_pp_base + S3C_VPP_POSTENVID);
            
                temp = S3C_MODE2_ADDR_CHANGE_DISABLE | S3C_MODE2_CHANGE_AT_FRAME_END | S3C_MODE2_SOFTWARE_TRIGGER;
                __raw_writel(temp, s3c_pp_base + S3C_VPP_MODE_2);
                   
                set_clock_src(HCLK);
            
                // setting the src/dst color space
                set_data_format(current_instance);
            
                // setting the src/dst size 
                set_scaler(current_instance);
            
                // setting the src/dst buffer address
                set_src_addr(current_instance);
                set_dest_addr(current_instance);

                current_instance->value_changed = PP_VALUE_CHANGED_NONE;

                s3c_pp_instance_info.last_running_instance_no = current_instance->instance_no;
                s3c_pp_instance_info.running_instance_no = current_instance->instance_no;

                if ( PP_INSTANCE_INUSE_DMA_ONESHOT == s3c_pp_instance_info.instance_state[current_instance->instance_no] )
                { // DMA OneShot Mode
                    dprintk ( "%s: DMA_ONESHOT mode\n", __FUNCTION__ );

                    post_int_enable(1);
                    pp_dma_mode_set_and_start();


                    if ( !(file->f_flags & O_NONBLOCK) )
                    {
                        if (interruptible_sleep_on_timeout(&waitq, 500) == 0) 
                        {
                            printk(KERN_ERR "\n%s: Waiting for interrupt is timeout\n", __FUNCTION__);
                        }
                    }
                }
                else
                { // FIFO freerun Mode
                    dprintk ( "%s: FIFO_freerun mode\n", __FUNCTION__ );
                    s3c_pp_instance_info.fifo_mode_instance_no = current_instance->instance_no;

                    post_int_enable(1);
                    pp_fifo_mode_set_and_start(current_instance); 
                }
            }
            else
            {
                if ( current_instance->value_changed != PP_VALUE_CHANGED_NONE )
                {
                    __raw_writel(0x0<<31, s3c_pp_base + S3C_VPP_POSTENVID);

                    if ( current_instance->value_changed & PP_VALUE_CHANGED_PARAMS )
                    {
                        set_data_format(current_instance);
                        set_scaler(current_instance);
                    }

                    if ( current_instance->value_changed & PP_VALUE_CHANGED_SRC_BUF_ADDR_PHY )
                    {
                        set_src_addr(current_instance);
                    }

                    if ( current_instance->value_changed & PP_VALUE_CHANGED_DST_BUF_ADDR_PHY )
                    {
                        set_dest_addr(current_instance);
                    }

                    current_instance->value_changed = PP_VALUE_CHANGED_NONE;
                }

                s3c_pp_instance_info.running_instance_no = current_instance->instance_no;

                post_int_enable(1);
                start_processing();

                if ( !(file->f_flags & O_NONBLOCK) )
                {
                    if (interruptible_sleep_on_timeout(&waitq, 500) == 0) 
                    {
                        printk(KERN_ERR "\n%s: Waiting for interrupt is timeout\n", __FUNCTION__);
                    }
                }
            }
			break;

		case S3C_PP_GET_SRC_BUF_SIZE:

            if ( PP_INSTANCE_READY == s3c_pp_instance_info.instance_state[current_instance->instance_no] )
            {
                dprintk ( "%s: S3C_PP_GET_SRC_BUF_SIZE must be executed after running S3C_PP_SET_PARAMS.\n", __FUNCTION__ );
                mutex_unlock(h_mutex);
			    return -EINVAL;
            }

            temp = cal_data_size ( current_instance->src_color_space, current_instance->src_full_width, current_instance->src_full_height );

			mutex_unlock(h_mutex);
			return temp;


		case S3C_PP_SET_SRC_BUF_ADDR_PHY:

            get_user(current_instance->src_buf_addr_phy, &parg->src_buf_addr_phy);
            current_instance->value_changed |= PP_VALUE_CHANGED_SRC_BUF_ADDR_PHY;
			break;

        case S3C_PP_SET_SRC_BUF_NEXT_ADDR_PHY:

            if ( current_instance->instance_no != s3c_pp_instance_info.fifo_mode_instance_no )
            { // if FIFO Mode is not Active
                dprintk (KERN_DEBUG "%s: S3C_PP_SET_SRC_BUF_NEXT_ADDR_PHY can't be executed.\n", __FUNCTION__ );
                mutex_unlock(h_mutex);
                return -EINVAL;
            }            

            get_user(current_instance->src_next_buf_addr_phy, &parg->src_next_buf_addr_phy);

            temp = __raw_readl(s3c_pp_base + S3C_VPP_MODE_2);
            temp |= (0x1<<4);
            __raw_writel(temp, s3c_pp_base + S3C_VPP_MODE_2);
    
            set_src_next_buf_addr(current_instance);

            temp = __raw_readl(s3c_pp_base + S3C_VPP_MODE_2);
            temp &= ~(0x1<<4);
            __raw_writel(temp, s3c_pp_base + S3C_VPP_MODE_2);
            break;

		case S3C_PP_GET_DST_BUF_SIZE:
            
            if ( PP_INSTANCE_READY == s3c_pp_instance_info.instance_state[current_instance->instance_no] )
            {
                dprintk ( "%s: S3C_PP_GET_DST_BUF_SIZE must be executed after running S3C_PP_SET_PARAMS.\n", __FUNCTION__ );
                mutex_unlock(h_mutex);
			    return -EINVAL;
            }

            temp = cal_data_size ( current_instance->dst_color_space, current_instance->dst_full_width, current_instance->dst_full_height );

			mutex_unlock(h_mutex);
			return temp;

		case S3C_PP_SET_DST_BUF_ADDR_PHY:

            get_user(current_instance->dst_buf_addr_phy, &parg->dst_buf_addr_phy);
            current_instance->value_changed |= PP_VALUE_CHANGED_DST_BUF_ADDR_PHY;
			break;


        case S3C_PP_ALLOC_KMEM:
            {
                s3c_pp_mem_alloc_t param;
                
                if (copy_from_user(&param, (s3c_pp_mem_alloc_t *)arg, sizeof(s3c_pp_mem_alloc_t)))
                {
                    mutex_unlock(h_mutex);
                    return -EFAULT;
                }
                
                flag = ALLOC_KMEM;
                
                param.vir_addr = do_mmap(file, 0, param.size, PROT_READ|PROT_WRITE, MAP_SHARED, 0);
                dprintk (KERN_DEBUG "param.vir_addr = %08x\n", param.vir_addr);
                            
                flag = 0;

                if(param.vir_addr == -EINVAL) {
                    printk(KERN_ERR "%s: PP_MEM_ALLOC FAILED\n", __FUNCTION__);
                    mutex_unlock(h_mutex);
                    return -EFAULT;
                }
                param.phy_addr = physical_address;
                
                dprintk (KERN_DEBUG "KERNEL MALLOC : param.phy_addr = 0x%X \t size = %d \t param.vir_addr = 0x%X\n", param.phy_addr, param.size, param.vir_addr);
                
                if (copy_to_user((s3c_pp_mem_alloc_t *)arg, &param, sizeof(s3c_pp_mem_alloc_t)))
                {
                    mutex_unlock(h_mutex);
                    return -EFAULT;
                }
            }
            break;

        case S3C_PP_FREE_KMEM:
            {
                s3c_pp_mem_alloc_t param;
                struct mm_struct *mm = current->mm;
                void *virt_addr;

                if ( copy_from_user(&param, (s3c_pp_mem_alloc_t *)arg, sizeof(s3c_pp_mem_alloc_t)) )
                {
                    mutex_unlock(h_mutex);
                    return -EFAULT;
                }
            
                dprintk (KERN_DEBUG "KERNEL FREE : param.phy_addr = 0x%X \t size = %d \t param.vir_addr = 0x%X\n", param.phy_addr, param.size, param.vir_addr);
            
                if ( do_munmap(mm, param.vir_addr, param.size ) < 0 ) 
                {
                    dprintk("do_munmap() failed !!\n");
                    mutex_unlock(h_mutex);
                    return -EINVAL;
                }
                virt_addr = phys_to_virt(param.phy_addr);
                dprintk ( "KERNEL : virt_addr = 0x%X\n", (unsigned int) virt_addr );
            
                kfree(virt_addr);
                param.size = 0;

                dprintk(KERN_DEBUG "do_munmap() succeed !!\n");
            }
            break;

        case S3C_PP_GET_RESERVED_MEM_SIZE:
            mutex_unlock(h_mutex);
            return PP_RESERVED_MEM_SIZE;

        case S3C_PP_GET_RESERVED_MEM_ADDR_PHY:
            mutex_unlock(h_mutex);
            return PP_RESERVED_MEM_ADDR_PHY;

		default:
			mutex_unlock(h_mutex);
			return -EINVAL;
	}

	mutex_unlock(h_mutex);
	
	return 0;
}
Beispiel #6
0
void x68k_keyboard_device::received_byte(uint8_t data)
{
	/* Keyboard control commands:
	   00xxxxxx - TV Control
	              Not of much use as yet

	   01000xxy - y = Mouse control signal

	   01001xxy - y = Keyboard enable

	   010100xy - y = Sharp X1 display compatibility mode

	   010101xx - xx = LED brightness (00 = bright, 11 = dark)

	   010110xy - y = Display control enable

	   010111xy - y = Display control via the Opt. 2 key enable

	   0110xxxx - xxxx = Key delay (default 500ms)
	                     100 * (delay time) + 200ms

	   0111xxxx - xxxx = Key repeat rate  (default 110ms)
	                     (repeat rate)^2*5 + 30ms

	   1xxxxxxx - xxxxxxx = keyboard LED status
	              b6 = fullwidth
	              b5 = hiragana
	              b4 = insert
	              b3 = caps
	              b2 = code input
	              b1 = romaji
	              b0 = kana
	*/

	if (data & 0x80)  // LED status
	{
		machine().output().set_value("key_led_kana", data & 0x01);
		machine().output().set_value("key_led_romaji", data & 0x02);
		machine().output().set_value("key_led_code", data & 0x04);
		machine().output().set_value("key_led_caps", data & 0x08);
		machine().output().set_value("key_led_insert", data & 0x10);
		machine().output().set_value("key_led_hiragana", data & 0x20);
		machine().output().set_value("key_led_fullsize", data & 0x40);
		logerror("KB: LED status set to %02x\n", data & 0x7f);
	}

	if ((data & 0xc0) == 0)  // TV control
	{
		// nothing for now
	}

	if ((data & 0xf8) == 0x48)  // Keyboard enable
	{
		m_enabled = data & 0x01;
		if (m_enabled) start_processing(attotime::from_hz(2'400));
		else stop_processing();
		logerror("KB: Keyboard enable bit = %i\n", m_enabled);
	}

	if ((data & 0xf0) == 0x60)  // Key delay time
	{
		m_delay = ((data & 0x0f) * 100) + 200;
		logerror("KB: Keypress delay time is now %ims\n", m_delay);
	}

	if ((data & 0xf0) == 0x70)  // Key repeat rate
	{
		m_repeat = (((data & 0x0f)^2) * 5) + 30;
		logerror("KB: Keypress repeat rate is now %ims\n", m_repeat);
	}
}
int main(int argc, char *argv[])
{
    int sd = 0, opt, print_pkt = 0, fix_cks = 0, status;

    static char *opstring = "czhpa:e:d:t:i:f:o:";

    if (argc == 1) {
        usage(argv[0]);
        exit(-1);
    }

    while ((opt = getopt(argc, argv, opstring)) != -1) {
        switch (opt) {
            case ('i'):
                status = set_source(ETHERNET_NIC, optarg);
                printf("Source: live NIC %s\n", optarg);
                if (status != 1) {
                    printf("Error setting input\n");
                    exit(-2);
                }
                sd = create_set();
                break;
            case ('f'):
                status = set_source(TCPDUMP_TRACE, optarg);
                printf("Source: pcap file %s\n", optarg);
                if (status != 1) {
                    printf("Error setting input\n");
                    exit(-2);
                }

                sd = create_set();
                break;
            case ('e'):
                if (strcmp(optarg, "ZERO") == 0) {
                    add_function(sd, "ANONYMIZE", ETHERNET, SRC_IP, ZERO);
                    add_function(sd, "ANONYMIZE", ETHERNET, DST_IP, ZERO);
                    printf("Zero ethernet addresses\n");
                }
                break;
            case ('a'):
                if (strcmp(optarg, "MAP") == 0) {
                    add_function(sd, "ANONYMIZE", IP, SRC_IP, MAP);
                    add_function(sd, "ANONYMIZE", IP, DST_IP, MAP);
                    printf("Map ip addresses\n");
                } else if (strcmp(optarg, "PREFIX") == 0) {
                      add_function(sd, "ANONYMIZE", IP, SRC_IP, PREFIX_PRESERVING);
                      add_function(sd, "ANONYMIZE", IP, DST_IP, PREFIX_PRESERVING);
                    printf("Prefix-preserving ip addresses\n");
                } else {
                    add_function(sd, "ANONYMIZE", IP, SRC_IP, ZERO);
                    add_function(sd, "ANONYMIZE", IP, DST_IP, ZERO);
                    printf("Zero ip addresses\n");
                }
                break;
            case ('p'):
                print_pkt = 1;
                break;
            case ('d'):
                if (strcmp(optarg, "STRIP") == 0) {
                    add_function(sd, "ANONYMIZE", TCP, PAYLOAD, STRIP, 0);
                    add_function(sd, "ANONYMIZE", UDP, PAYLOAD, STRIP, 0);
                    printf("Removing TCP payload\n");
                } else if (strcmp(optarg, "HASH") == 0) {
                    add_function(sd, "ANONYMIZE", TCP, PAYLOAD, HASHED, MD5,
                            STRIP_REST);
                    add_function(sd, "ANONYMIZE", UDP, PAYLOAD, HASHED, MD5,
                            STRIP_REST);
                    printf("HASH TCP/UDP payload\n");
                } else {
                    add_function(sd, "ANONYMIZE", TCP, PAYLOAD, ZERO);
                    add_function(sd, "ANONYMIZE", UDP, PAYLOAD, ZERO);
                    printf("ZERO TCP payload\n");
                }
                break;
            case ('h'):
                usage(argv[0]);
                exit(0);
                break;
            case ('t'):
                if (strcmp(optarg, "MAP") == 0) {
                    add_function(sd, "ANONYMIZE", TCP, SRC_PORT, MAP);
                    add_function(sd, "ANONYMIZE", TCP, DST_PORT, MAP);
                    printf("Map TCP ports\n");
                } else {
                    add_function(sd, "ANONYMIZE", TCP, SRC_PORT, ZERO);
                    add_function(sd, "ANONYMIZE", TCP, DST_PORT, ZERO);
                    printf("ZERO TCP ports\n");
                }
                break;
            case ('z'):
                add_function(sd, "ANONYMIZE", IP, OPTIONS, ZERO);
                add_function(sd, "ANONYMIZE", TCP, TCP_OPTIONS, RANDOM);
                printf("Zero TCP and IP options\n");
                break;
            case ('c'):
                fix_cks = 1;
                printf("Fix checksums\n");
                break;
            default:
                usage(argv[0]);
                exit(0);
                break;
        }
    }

    status = set_output(sd, TCPDUMP_TRACE, argv[argc - 1]);
    printf("Output: File %s\n\n", argv[argc - 1]);
    if (status != 1) {
        printf("Error setting output\n");
        exit(-2);
    }

    if (fix_cks)
        add_function(sd, "ANONYMIZE", IP, CHECKSUM, CHECKSUM_ADJUST);
    if (print_pkt)
        add_function(sd, "PRINT_PACKET");

    printf("\nStart anonymize...\n");
    start_processing();
    printf("End anonymize\n");
    return EXIT_SUCCESS;
}