USB OHCI: add support for big endian targets
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6368 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
470d86b736
commit
65e1d81b29
|
@ -1360,103 +1360,135 @@ static void ohci_port_set_status(OHCIState *ohci, int portnum, uint32_t val)
|
|||
static uint32_t ohci_mem_read(void *ptr, target_phys_addr_t addr)
|
||||
{
|
||||
OHCIState *ohci = ptr;
|
||||
uint32_t retval;
|
||||
|
||||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3) {
|
||||
fprintf(stderr, "usb-ohci: Mis-aligned read\n");
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) {
|
||||
} else if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) {
|
||||
/* HcRhPortStatus */
|
||||
return ohci->rhport[(addr - 0x54) >> 2].ctrl | OHCI_PORT_PPS;
|
||||
}
|
||||
|
||||
retval = ohci->rhport[(addr - 0x54) >> 2].ctrl | OHCI_PORT_PPS;
|
||||
} else {
|
||||
switch (addr >> 2) {
|
||||
case 0: /* HcRevision */
|
||||
return 0x10;
|
||||
retval = 0x10;
|
||||
break;
|
||||
|
||||
case 1: /* HcControl */
|
||||
return ohci->ctl;
|
||||
retval = ohci->ctl;
|
||||
break;
|
||||
|
||||
case 2: /* HcCommandStatus */
|
||||
return ohci->status;
|
||||
retval = ohci->status;
|
||||
break;
|
||||
|
||||
case 3: /* HcInterruptStatus */
|
||||
return ohci->intr_status;
|
||||
retval = ohci->intr_status;
|
||||
break;
|
||||
|
||||
case 4: /* HcInterruptEnable */
|
||||
case 5: /* HcInterruptDisable */
|
||||
return ohci->intr;
|
||||
retval = ohci->intr;
|
||||
break;
|
||||
|
||||
case 6: /* HcHCCA */
|
||||
return ohci->hcca;
|
||||
retval = ohci->hcca;
|
||||
break;
|
||||
|
||||
case 7: /* HcPeriodCurrentED */
|
||||
return ohci->per_cur;
|
||||
retval = ohci->per_cur;
|
||||
break;
|
||||
|
||||
case 8: /* HcControlHeadED */
|
||||
return ohci->ctrl_head;
|
||||
retval = ohci->ctrl_head;
|
||||
break;
|
||||
|
||||
case 9: /* HcControlCurrentED */
|
||||
return ohci->ctrl_cur;
|
||||
retval = ohci->ctrl_cur;
|
||||
break;
|
||||
|
||||
case 10: /* HcBulkHeadED */
|
||||
return ohci->bulk_head;
|
||||
retval = ohci->bulk_head;
|
||||
break;
|
||||
|
||||
case 11: /* HcBulkCurrentED */
|
||||
return ohci->bulk_cur;
|
||||
retval = ohci->bulk_cur;
|
||||
break;
|
||||
|
||||
case 12: /* HcDoneHead */
|
||||
return ohci->done;
|
||||
retval = ohci->done;
|
||||
break;
|
||||
|
||||
case 13: /* HcFmInterval */
|
||||
return (ohci->fit << 31) | (ohci->fsmps << 16) | (ohci->fi);
|
||||
case 13: /* HcFmInterretval */
|
||||
retval = (ohci->fit << 31) | (ohci->fsmps << 16) | (ohci->fi);
|
||||
break;
|
||||
|
||||
case 14: /* HcFmRemaining */
|
||||
return ohci_get_frame_remaining(ohci);
|
||||
retval = ohci_get_frame_remaining(ohci);
|
||||
break;
|
||||
|
||||
case 15: /* HcFmNumber */
|
||||
return ohci->frame_number;
|
||||
retval = ohci->frame_number;
|
||||
break;
|
||||
|
||||
case 16: /* HcPeriodicStart */
|
||||
return ohci->pstart;
|
||||
retval = ohci->pstart;
|
||||
break;
|
||||
|
||||
case 17: /* HcLSThreshold */
|
||||
return ohci->lst;
|
||||
retval = ohci->lst;
|
||||
break;
|
||||
|
||||
case 18: /* HcRhDescriptorA */
|
||||
return ohci->rhdesc_a;
|
||||
retval = ohci->rhdesc_a;
|
||||
break;
|
||||
|
||||
case 19: /* HcRhDescriptorB */
|
||||
return ohci->rhdesc_b;
|
||||
retval = ohci->rhdesc_b;
|
||||
break;
|
||||
|
||||
case 20: /* HcRhStatus */
|
||||
return ohci->rhstatus;
|
||||
retval = ohci->rhstatus;
|
||||
break;
|
||||
|
||||
/* PXA27x specific registers */
|
||||
case 24: /* HcStatus */
|
||||
return ohci->hstatus & ohci->hmask;
|
||||
retval = ohci->hstatus & ohci->hmask;
|
||||
break;
|
||||
|
||||
case 25: /* HcHReset */
|
||||
return ohci->hreset;
|
||||
retval = ohci->hreset;
|
||||
break;
|
||||
|
||||
case 26: /* HcHInterruptEnable */
|
||||
return ohci->hmask;
|
||||
retval = ohci->hmask;
|
||||
break;
|
||||
|
||||
case 27: /* HcHInterruptTest */
|
||||
return ohci->htest;
|
||||
retval = ohci->htest;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ohci_read: Bad offset %x\n", (int)addr);
|
||||
return 0xffffffff;
|
||||
retval = 0xffffffff;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
retval = bswap32(retval);
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void ohci_mem_write(void *ptr, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
OHCIState *ohci = ptr;
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
val = bswap32(val);
|
||||
#endif
|
||||
|
||||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3) {
|
||||
fprintf(stderr, "usb-ohci: Mis-aligned write\n");
|
||||
|
|
Loading…
Reference in a new issue