Beispiel #1
0
int main(void){
	struct virtual_machine * vm;
	unsigned int output;
        unsigned char c;
	struct termios * original = terminal_setup();

	vm = vm_create(data_start, data_end, data);

	while(!is_halted(vm)){
		if(vm_getc(vm, &output)){
			putchar((int)output);
			fflush(stdout);
		}

		if(read(STDIN_FILENO, &c, 1) > 0){
			vm_putc(vm, c);
		}
		step(vm);
	}

	vm_destroy(vm);
        tcsetattr(STDOUT_FILENO,TCSANOW, original);
        tcsetattr(STDOUT_FILENO,TCSAFLUSH, original);
        free(original);
	return 0;
}
Beispiel #2
0
const char* i860_cpu_device::reports(double realTime, double hostTime) {
    double dVT = hostTime - m_last_vt;
    
    if(is_halted()) {
        m_report[0] = 0;
    } else {
        if(dVT == 0) dVT = 0.0001;
        sprintf(m_report, "i860:{MIPS=%.1f icache_hit=%lld%% tlb_hit=%lld%% icach_inval/s=%.0f tlb_inval/s=%.0f intr/s=%0.f}",
                               (m_insn_decoded / (dVT*1000*1000)),
                               m_icache_hit+m_icache_miss == 0 ? 0 : (100 * m_icache_hit) / (m_icache_hit+m_icache_miss) ,
                               m_tlb_hit+m_tlb_miss       == 0 ? 0 : (100 * m_tlb_hit)    / (m_tlb_hit+m_tlb_miss),
                               (m_icache_inval)/dVT,
                               (m_tlb_inval)/dVT,
                               (m_intrs)/dVT
                               );
        
        m_insn_decoded  = 0;
        m_icache_hit    = 0;
        m_icache_miss   = 0;
        m_icache_inval  = 0;
        m_tlb_hit       = 0;
        m_tlb_miss      = 0;
        m_tlb_inval     = 0;
        m_intrs         = 0;

        m_last_rt = realTime;
        m_last_vt = hostTime;
    }
    
    return m_report;
}
Beispiel #3
0
int main(void){
	struct virtual_machine * vm;
	unsigned int output;
        unsigned char c;
	struct termios * original = terminal_setup();

	vm = vm_create(data_start, data_end, data);
	printf("Kernel image has been loaded. All input is now being handled by the emulator.\n");
	printf("Press 'q' to quit.\n");

	while(!is_halted(vm)){
		if(vm_getc(vm, &output)){
			putchar((int)output);
			fflush(stdout);
		}

		if(read(STDIN_FILENO, &c, 1) > 0){
			vm_putc(vm, c);
		}
		step(vm);
	}

	vm_destroy(vm);
        tcsetattr(STDOUT_FILENO,TCSANOW, original);
        tcsetattr(STDOUT_FILENO,TCSAFLUSH, original);
        free(original);
	return 0;
}
Beispiel #4
0
void i860_cpu_device::uninit() {
    if(is_halted()) return;
    
	halt(true);
    send_msg(MSG_I860_KILL);
    if(ConfigureParams.Dimension.bI860Thread) {
        if(m_thread) {
            host_thread_wait(m_thread);
            m_thread = NULL;
        }
        send_msg(MSG_NONE);
    }
}
Beispiel #5
0
void i860_cpu_device::run() {
    while(handle_msgs()) {
        
        /* Sleep a bit if halted */
        if(is_halted()) {
            host_sleep_ms(100);
            continue;
        }
        
        /* Run some i860 cycles before re-checking messages*/
        for(int i = 16; --i >= 0;)
            run_cycle();
    }
}
static int usb_host_handle_data(USBHostDevice *s, USBPacket *p)
{
    struct usbdevfs_urb *urb;
    AsyncURB *aurb;
    int ret;

    aurb = async_alloc();
    if (!aurb) {
        dprintf("husb: async malloc failed\n");
        return USB_RET_NAK;
    }
    aurb->hdev   = s;
    aurb->packet = p;

    urb = &aurb->urb;

    if (p->pid == USB_TOKEN_IN)
    	urb->endpoint = p->devep | 0x80;
    else
    	urb->endpoint = p->devep;

    if (is_halted(s, p->devep)) {
	ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint);
        if (ret < 0) {
            dprintf("husb: failed to clear halt. ep 0x%x errno %d\n", 
                   urb->endpoint, errno);
            return USB_RET_NAK;
        }
        clear_halt(s, p->devep);
    }

    urb->buffer        = p->data;
    urb->buffer_length = p->len;

    if (is_isoc(s, p->devep)) {
        /* Setup ISOC transfer */
        urb->type     = USBDEVFS_URB_TYPE_ISO;
        urb->flags    = USBDEVFS_URB_ISO_ASAP;
        urb->number_of_packets = 1;
        urb->iso_frame_desc[0].length = p->len;
    } else {
        /* Setup bulk transfer */
        urb->type     = USBDEVFS_URB_TYPE_BULK;
    }

    urb->usercontext = s;

    ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);

    dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);

    if (ret < 0) {
        dprintf("husb: submit failed. errno %d\n", errno);
        async_free(aurb);

        switch(errno) {
        case ETIMEDOUT:
            return USB_RET_NAK;
        case EPIPE:
        default:
            return USB_RET_STALL;
        }
    }

    usb_defer_packet(p, async_cancel, aurb);
    return USB_RET_ASYNC;
}