aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-musb.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-10 01:44:56 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-10 01:44:56 +0100
commitbc24a225af2464dc30f88d6f930779cbf0e22b67 (patch)
tree6df682b479f89863159f836e1dc292623ab577e1 /hw/usb-musb.c
parentd4ec5228821b8bdd8019cb5dafa2ea3659ddb1f9 (diff)
Follow coding conventions
Remove explicit struct qualifiers and rename structure types. Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/usb-musb.c')
-rw-r--r--hw/usb-musb.c138
1 files changed, 70 insertions, 68 deletions
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index adc76a22c1..451bc8dbde 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -251,7 +251,36 @@
static void musb_attach(USBPort *port, USBDevice *dev);
-struct musb_s {
+typedef struct {
+ uint16_t faddr[2];
+ uint8_t haddr[2];
+ uint8_t hport[2];
+ uint16_t csr[2];
+ uint16_t maxp[2];
+ uint16_t rxcount;
+ uint8_t type[2];
+ uint8_t interval[2];
+ uint8_t config;
+ uint8_t fifosize;
+ int timeout[2]; /* Always in microframes */
+
+ uint32_t *buf[2];
+ int fifolen[2];
+ int fifostart[2];
+ int fifoaddr[2];
+ USBPacket packey[2];
+ int status[2];
+ int ext_size[2];
+
+ /* For callbacks' use */
+ int epnum;
+ int interrupt[2];
+ MUSBState *musb;
+ USBCallback *delayed_cb[2];
+ QEMUTimer *intv_timer[2];
+} MUSBEndPoint;
+
+struct MUSBState {
qemu_irq *irqs;
USBPort port;
@@ -272,39 +301,12 @@ struct musb_s {
uint32_t buf[0x2000];
- struct musb_ep_s {
- uint16_t faddr[2];
- uint8_t haddr[2];
- uint8_t hport[2];
- uint16_t csr[2];
- uint16_t maxp[2];
- uint16_t rxcount;
- uint8_t type[2];
- uint8_t interval[2];
- uint8_t config;
- uint8_t fifosize;
- int timeout[2]; /* Always in microframes */
-
- uint32_t *buf[2];
- int fifolen[2];
- int fifostart[2];
- int fifoaddr[2];
- USBPacket packey[2];
- int status[2];
- int ext_size[2];
-
- /* For callbacks' use */
- int epnum;
- int interrupt[2];
- struct musb_s *musb;
- USBCallback *delayed_cb[2];
- QEMUTimer *intv_timer[2];
/* Duplicating the world since 2008!... probably we should have 32
* logical, single endpoints instead. */
- } ep[16];
+ MUSBEndPoint ep[16];
} *musb_init(qemu_irq *irqs)
{
- struct musb_s *s = qemu_mallocz(sizeof(*s));
+ MUSBState *s = qemu_mallocz(sizeof(*s));
int i;
s->irqs = irqs;
@@ -334,7 +336,7 @@ struct musb_s {
return s;
}
-static void musb_vbus_set(struct musb_s *s, int level)
+static void musb_vbus_set(MUSBState *s, int level)
{
if (level)
s->devctl |= 3 << MGC_S_DEVCTL_VBUS;
@@ -344,7 +346,7 @@ static void musb_vbus_set(struct musb_s *s, int level)
qemu_set_irq(s->irqs[musb_set_vbus], level);
}
-static void musb_intr_set(struct musb_s *s, int line, int level)
+static void musb_intr_set(MUSBState *s, int line, int level)
{
if (!level) {
s->intr &= ~(1 << line);
@@ -355,7 +357,7 @@ static void musb_intr_set(struct musb_s *s, int line, int level)
}
}
-static void musb_tx_intr_set(struct musb_s *s, int line, int level)
+static void musb_tx_intr_set(MUSBState *s, int line, int level)
{
if (!level) {
s->tx_intr &= ~(1 << line);
@@ -367,7 +369,7 @@ static void musb_tx_intr_set(struct musb_s *s, int line, int level)
}
}
-static void musb_rx_intr_set(struct musb_s *s, int line, int level)
+static void musb_rx_intr_set(MUSBState *s, int line, int level)
{
if (line) {
if (!level) {
@@ -382,12 +384,12 @@ static void musb_rx_intr_set(struct musb_s *s, int line, int level)
musb_tx_intr_set(s, line, level);
}
-uint32_t musb_core_intr_get(struct musb_s *s)
+uint32_t musb_core_intr_get(MUSBState *s)
{
return (s->rx_intr << 15) | s->tx_intr;
}
-void musb_core_intr_clear(struct musb_s *s, uint32_t mask)
+void musb_core_intr_clear(MUSBState *s, uint32_t mask)
{
if (s->rx_intr) {
s->rx_intr &= mask >> 15;
@@ -402,7 +404,7 @@ void musb_core_intr_clear(struct musb_s *s, uint32_t mask)
}
}
-void musb_set_size(struct musb_s *s, int epnum, int size, int is_tx)
+void musb_set_size(MUSBState *s, int epnum, int size, int is_tx)
{
s->ep[epnum].ext_size[!is_tx] = size;
s->ep[epnum].fifostart[0] = 0;
@@ -411,7 +413,7 @@ void musb_set_size(struct musb_s *s, int epnum, int size, int is_tx)
s->ep[epnum].fifolen[1] = 0;
}
-static void musb_session_update(struct musb_s *s, int prev_dev, int prev_sess)
+static void musb_session_update(MUSBState *s, int prev_dev, int prev_sess)
{
int detect_prev = prev_dev && prev_sess;
int detect = !!s->port.dev && s->session;
@@ -448,7 +450,7 @@ static void musb_session_update(struct musb_s *s, int prev_dev, int prev_sess)
/* Attach or detach a device on our only port. */
static void musb_attach(USBPort *port, USBDevice *dev)
{
- struct musb_s *s = (struct musb_s *) port->opaque;
+ MUSBState *s = (MUSBState *) port->opaque;
USBDevice *curr;
port = &s->port;
@@ -478,14 +480,14 @@ static void musb_attach(USBPort *port, USBDevice *dev)
static inline void musb_cb_tick0(void *opaque)
{
- struct musb_ep_s *ep = (struct musb_ep_s *) opaque;
+ MUSBEndPoint *ep = (MUSBEndPoint *) opaque;
ep->delayed_cb[0](&ep->packey[0], opaque);
}
static inline void musb_cb_tick1(void *opaque)
{
- struct musb_ep_s *ep = (struct musb_ep_s *) opaque;
+ MUSBEndPoint *ep = (MUSBEndPoint *) opaque;
ep->delayed_cb[1](&ep->packey[1], opaque);
}
@@ -494,7 +496,7 @@ static inline void musb_cb_tick1(void *opaque)
static inline void musb_schedule_cb(USBPacket *packey, void *opaque, int dir)
{
- struct musb_ep_s *ep = (struct musb_ep_s *) opaque;
+ MUSBEndPoint *ep = (MUSBEndPoint *) opaque;
int timeout = 0;
if (ep->status[dir] == USB_RET_NAK)
@@ -559,7 +561,7 @@ static int musb_timeout(int ttype, int speed, int val)
hw_error("bad interval\n");
}
-static inline void musb_packet(struct musb_s *s, struct musb_ep_s *ep,
+static inline void musb_packet(MUSBState *s, MUSBEndPoint *ep,
int epnum, int pid, int len, USBCallback cb, int dir)
{
int ret;
@@ -606,9 +608,9 @@ static void musb_tx_packet_complete(USBPacket *packey, void *opaque)
{
/* Unfortunately we can't use packey->devep because that's the remote
* endpoint number and may be different than our local. */
- struct musb_ep_s *ep = (struct musb_ep_s *) opaque;
+ MUSBEndPoint *ep = (MUSBEndPoint *) opaque;
int epnum = ep->epnum;
- struct musb_s *s = ep->musb;
+ MUSBState *s = ep->musb;
ep->fifostart[0] = 0;
ep->fifolen[0] = 0;
@@ -686,9 +688,9 @@ static void musb_rx_packet_complete(USBPacket *packey, void *opaque)
{
/* Unfortunately we can't use packey->devep because that's the remote
* endpoint number and may be different than our local. */
- struct musb_ep_s *ep = (struct musb_ep_s *) opaque;
+ MUSBEndPoint *ep = (MUSBEndPoint *) opaque;
int epnum = ep->epnum;
- struct musb_s *s = ep->musb;
+ MUSBState *s = ep->musb;
ep->fifostart[1] = 0;
ep->fifolen[1] = 0;
@@ -766,9 +768,9 @@ static void musb_rx_packet_complete(USBPacket *packey, void *opaque)
musb_rx_intr_set(s, epnum, 1);
}
-static void musb_tx_rdy(struct musb_s *s, int epnum)
+static void musb_tx_rdy(MUSBState *s, int epnum)
{
- struct musb_ep_s *ep = s->ep + epnum;
+ MUSBEndPoint *ep = s->ep + epnum;
int pid;
int total, valid = 0;
@@ -806,9 +808,9 @@ static void musb_tx_rdy(struct musb_s *s, int epnum)
total, musb_tx_packet_complete, 0);
}
-static void musb_rx_req(struct musb_s *s, int epnum)
+static void musb_rx_req(MUSBState *s, int epnum)
{
- struct musb_ep_s *ep = s->ep + epnum;
+ MUSBEndPoint *ep = s->ep + epnum;
int total;
/* If we already have a packet, which didn't fit into the
@@ -869,7 +871,7 @@ static void musb_rx_req(struct musb_s *s, int epnum)
total, musb_rx_packet_complete, 1);
}
-static void musb_ep_frame_cancel(struct musb_ep_s *ep, int dir)
+static void musb_ep_frame_cancel(MUSBEndPoint *ep, int dir)
{
if (ep->intv_timer[dir])
qemu_del_timer(ep->intv_timer[dir]);
@@ -878,7 +880,7 @@ static void musb_ep_frame_cancel(struct musb_ep_s *ep, int dir)
/* Bus control */
static uint8_t musb_busctl_readb(void *opaque, int ep, int addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
/* For USB2.0 HS hubs only */
@@ -899,7 +901,7 @@ static uint8_t musb_busctl_readb(void *opaque, int ep, int addr)
static void musb_busctl_writeb(void *opaque, int ep, int addr, uint8_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXHUBADDR:
@@ -922,7 +924,7 @@ static void musb_busctl_writeb(void *opaque, int ep, int addr, uint8_t value)
static uint16_t musb_busctl_readh(void *opaque, int ep, int addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXFUNCADDR:
@@ -938,7 +940,7 @@ static uint16_t musb_busctl_readh(void *opaque, int ep, int addr)
static void musb_busctl_writeh(void *opaque, int ep, int addr, uint16_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXFUNCADDR:
@@ -957,7 +959,7 @@ static void musb_busctl_writeh(void *opaque, int ep, int addr, uint16_t value)
/* Endpoint control */
static uint8_t musb_ep_readb(void *opaque, int ep, int addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXTYPE:
@@ -981,7 +983,7 @@ static uint8_t musb_ep_readb(void *opaque, int ep, int addr)
static void musb_ep_writeb(void *opaque, int ep, int addr, uint8_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXTYPE:
@@ -1013,7 +1015,7 @@ static void musb_ep_writeb(void *opaque, int ep, int addr, uint8_t value)
static uint16_t musb_ep_readh(void *opaque, int ep, int addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
uint16_t ret;
switch (addr) {
@@ -1043,7 +1045,7 @@ static uint16_t musb_ep_readh(void *opaque, int ep, int addr)
static void musb_ep_writeh(void *opaque, int ep, int addr, uint16_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
switch (addr) {
case MUSB_HDRC_TXMAXP:
@@ -1141,7 +1143,7 @@ static void musb_ep_writeh(void *opaque, int ep, int addr, uint16_t value)
/* Generic control */
static uint32_t musb_readb(void *opaque, target_phys_addr_t addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
int ep, i;
uint8_t ret;
@@ -1199,7 +1201,7 @@ static uint32_t musb_readb(void *opaque, target_phys_addr_t addr)
static void musb_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
int ep;
switch (addr) {
@@ -1280,7 +1282,7 @@ static void musb_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)
static uint32_t musb_readh(void *opaque, target_phys_addr_t addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
int ep, i;
uint16_t ret;
@@ -1330,7 +1332,7 @@ static uint32_t musb_readh(void *opaque, target_phys_addr_t addr)
static void musb_writeh(void *opaque, target_phys_addr_t addr, uint32_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
+ MUSBState *s = (MUSBState *) opaque;
int ep;
switch (addr) {
@@ -1380,8 +1382,8 @@ static void musb_writeh(void *opaque, target_phys_addr_t addr, uint32_t value)
static uint32_t musb_readw(void *opaque, target_phys_addr_t addr)
{
- struct musb_s *s = (struct musb_s *) opaque;
- struct musb_ep_s *ep;
+ MUSBState *s = (MUSBState *) opaque;
+ MUSBEndPoint *ep;
int epnum;
switch (addr) {
@@ -1409,8 +1411,8 @@ static uint32_t musb_readw(void *opaque, target_phys_addr_t addr)
static void musb_writew(void *opaque, target_phys_addr_t addr, uint32_t value)
{
- struct musb_s *s = (struct musb_s *) opaque;
- struct musb_ep_s *ep;
+ MUSBState *s = (MUSBState *) opaque;
+ MUSBEndPoint *ep;
int epnum;
switch (addr) {