Changeset 1914
- Timestamp:
- 05/06/07 01:51:17 (6 years ago)
- Location:
- trunk/src/host/qemu-neo1973
- Files:
-
- 1 added
- 5 edited
-
Makefile.target (modified) (1 diff)
-
hw/s3c.h (modified) (3 diffs)
-
hw/s3c2410.c (modified) (3 diffs)
-
hw/s3c24xx_udc.c (added)
-
usb-linux-gadget.c (modified) (12 diffs)
-
vl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/host/qemu-neo1973/Makefile.target
r1825 r1914 383 383 VL_OBJS+= ads7846.o sd.o ide.o serial.o nand.o $(AUDIODRV) wm8750.o wm8753.o 384 384 VL_OBJS+= s3c2410.o s3c24xx_gpio.o s3c24xx_lcd.o s3c24xx_mmci.o s3c24xx_rtc.o 385 VL_OBJS+= neo1973.o pcf5060x.o jbt6k74.o modem.o386 CPPFLAGS += -DHAS_AUDIO -DHIGH_LATENCY385 VL_OBJS+= s3c24xx_udc.o neo1973.o pcf5060x.o jbt6k74.o modem.o 386 CPPFLAGS += -DHAS_AUDIO 387 387 endif 388 388 ifeq ($(TARGET_BASE_ARCH), sh4) -
trunk/src/host/qemu-neo1973/hw/s3c.h
r1647 r1914 34 34 # define S3C_PIC_SPI0 22 35 35 # define S3C_PIC_UART1 23 36 # define S3C_PIC_USBD 25 36 37 # define S3C_PIC_USBH 26 37 38 # define S3C_PIC_IIC 27 … … 152 153 void s3c_rtc_reset(struct s3c_rtc_state_s *s); 153 154 155 /* s3c24xx_udc.c */ 156 struct s3c_udc_state_s; 157 struct s3c_udc_state_s *s3c_udc_init(target_phys_addr_t base, void *pic, 158 void *dma); 159 void s3c_udc_reset(struct s3c_udc_state_s *s); 160 154 161 /* s3c2410.c */ 155 162 struct s3c_spi_state_s; … … 175 182 struct s3c_rtc_state_s *rtc; 176 183 struct s3c_spi_state_s *spi; 184 struct s3c_udc_state_s *udc; 177 185 178 186 /* Memory controller */ -
trunk/src/host/qemu-neo1973/hw/s3c2410.c
r1673 r1914 801 801 elapsed = muldiv64(qemu_get_clock(vm_clock) - s->timer[tm].reload, 802 802 s->timer[tm].divider, ticks_per_sec); 803 if ( elapsed > s->timer[tm].count) /* unlikely() */803 if (unlikely(elapsed > s->timer[tm].count)) 804 804 return s->timer[tm].count; 805 805 … … 2158 2158 s3c_rtc_reset(s->rtc); 2159 2159 s3c_spi_reset(s->spi); 2160 s3c_udc_reset(s->udc); 2160 2161 s3c_clkpwr_reset(s); 2161 2162 s3c_nand_reset(s); … … 2213 2214 s->timers = s3c_timers_init(0x51000000, s->pic, s->dma); 2214 2215 2215 /* USBDevice at 0x52000000 */ 2216 s->udc = s3c_udc_init(0x52000000, s->pic, s->dma); 2217 2216 2218 /* Watchdog at 0x53000000 */ 2217 2219 -
trunk/src/host/qemu-neo1973/usb-linux-gadget.c
r1898 r1914 33 33 struct gadget_state_s { 34 34 USBPort port; 35 uint8_t config_num; 35 36 int connected; 36 37 int speed; … … 45 46 int num; 46 47 struct gadget_state_s *state; 48 49 int busy; 50 uint8_t buffer[4096]; 51 USBPacket packet; 47 52 } ep[16]; 48 53 … … 123 128 } 124 129 130 static void gadget_ep_run(struct ep_s *ep) 131 { 132 USBDevice *dev = ep->state->port.dev; 133 int ret; 134 135 ret = dev->handle_packet(dev, &ep->packet); 136 137 if (ret >= 0) { 138 ep->packet.len = ret; 139 ep->packet.complete_cb(&ep->packet, ep->packet.complete_opaque); 140 } else if (ret == USB_RET_STALL) { 141 gadget_stall(ep->state, &ep->packet); 142 } else if (ret == USB_RET_ASYNC) { 143 ep->busy = 1; 144 } else { 145 fprintf(stderr, "%s: packet unhandled: %i\n", __FUNCTION__, ret); 146 if (ret != USB_RET_NAK) 147 gadget_detach(ep->state); 148 } 149 } 150 125 151 static void gadget_respond(USBPacket *packet, void *opaque) 126 152 { … … 142 168 { 143 169 struct ep_s *ep = (struct ep_s *) opaque; 144 if (packet->len > 0) 145 write(ep->fd, packet->data, packet->len); 170 ep->busy = 0; 171 while (write(ep->fd, packet->data, packet->len) < packet->len && 172 errno == EINTR); 146 173 } 147 174 … … 161 188 struct gadget_state_s *hci = ep->state; 162 189 190 if (ep->busy) 191 return; 192 163 193 #if 0 164 194 if (!gadget_ep_poll(opaque)) … … 167 197 168 198 /* write() is supposed to not block here */ 169 if (write(ep->fd, hci->buffer, 0))199 if (write(ep->fd, ep->buffer, 0)) 170 200 return; 171 201 172 if (hci->async_count) { 173 fprintf(stderr, "%s: overrun\n", __FUNCTION__); 174 gadget_detach(hci); 175 return; 176 } 177 178 hci->async_count = 1; 179 180 hci->packet->pid = USB_TOKEN_IN; 181 hci->packet->devaddr = hci->addr; 182 hci->packet->devep = ep->num; 183 hci->packet->data = hci->buffer; 184 hci->packet->len = sizeof(hci->buffer); 185 hci->packet->complete_cb = gadget_token_in; 186 hci->packet->complete_opaque = ep; 187 188 gadget_run(0, hci); 202 ep->packet.pid = USB_TOKEN_IN; 203 ep->packet.devaddr = hci->addr; 204 ep->packet.devep = ep->num; 205 ep->packet.data = ep->buffer; 206 ep->packet.len = sizeof(ep->buffer); 207 ep->packet.complete_cb = gadget_token_in; 208 ep->packet.complete_opaque = ep; 209 210 gadget_ep_run(ep); 189 211 } 190 212 191 213 static void gadget_nop(USBPacket *prev_packet, void *opaque) 192 214 { 215 ((struct ep_s *) opaque)->busy = 0; 193 216 } 194 217 … … 199 222 int ret; 200 223 201 ret = read(ep->fd, hci->buffer, sizeof(hci->buffer)); 224 if (ep->busy) 225 return; 226 227 ret = read(ep->fd, ep->buffer, sizeof(ep->buffer)); 202 228 if (ret <= 0) 203 229 return; 204 230 205 if (hci->async_count) { 206 fprintf(stderr, "%s: overrun\n", __FUNCTION__); 207 gadget_detach(hci); 208 return; 209 } 210 211 hci->async_count = 1; 212 213 hci->packet->pid = USB_TOKEN_OUT; 214 hci->packet->devaddr = hci->addr; 215 hci->packet->devep = ep->num; 216 hci->packet->data = hci->buffer; 217 hci->packet->len = ret; 218 hci->packet->complete_cb = gadget_nop; 219 hci->packet->complete_opaque = ep; 220 221 gadget_run(0, hci); 231 ep->packet.pid = USB_TOKEN_OUT; 232 ep->packet.devaddr = hci->addr; 233 ep->packet.devep = ep->num; 234 ep->packet.data = ep->buffer; 235 ep->packet.len = ret; 236 ep->packet.complete_cb = gadget_nop; 237 ep->packet.complete_opaque = ep; 238 239 gadget_ep_run(ep); 222 240 } 223 241 … … 268 286 goto fail; 269 287 } 288 289 ep->busy = 0; 270 290 271 291 if (desc->bEndpointAddress & USB_DIR_IN) … … 472 492 req->bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE; 473 493 req->bRequest = USB_REQ_GET_DESCRIPTOR; 474 req->wValue = (USB_DT_CONFIG << 8) | 0;494 req->wValue = (USB_DT_CONFIG << 8) | hci->config_num; 475 495 req->wIndex = 0x0000; 476 496 req->wLength = sizeof(hci->buffer); … … 496 516 int ret, len; 497 517 498 if (!s-> connected)518 if (!s->addr) 499 519 return; 500 520 … … 526 546 s->async_count = 2; 527 547 528 memcpy(s->buffer, &event.u.setup, 8);548 memcpy(s->buffer, &event.u.setup, sizeof(event.u.setup)); 529 549 s->packet[1].pid = USB_TOKEN_SETUP; 530 550 s->packet[1].devaddr = s->addr; 531 551 s->packet[1].devep = 0; 532 552 s->packet[1].data = s->buffer; 533 s->packet[1].len = 8;553 s->packet[1].len = sizeof(event.u.setup); 534 554 s->packet[1].complete_cb = gadget_run; 535 555 s->packet[1].complete_opaque = s; … … 718 738 719 739 hci->addr = 0; 740 hci->config_num = 0; 720 741 721 742 qemu_register_usb_port(&hci->port, hci, USB_INDEX_HOST, gadget_attach); -
trunk/src/host/qemu-neo1973/vl.h
r1898 r1914 1460 1460 #include "hw/i2c.h" 1461 1461 1462 #define unlikely(cond) __builtin_expect( cond, 0)1462 #define unlikely(cond) __builtin_expect(!!(cond), 0) 1463 1463 1464 1464 #ifdef TARGET_ARM
Note: See TracChangeset
for help on using the changeset viewer.
