forked from lemonjesus/qemu-ipod-nano
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include "hw/arm/ipod_touch_sdio.h" | ||
|
||
static void ipod_touch_sdio_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) | ||
{ | ||
fprintf(stderr, "%s: writing 0x%08x to 0x%08x\n", __func__, value, addr); | ||
|
||
IPodTouchSDIOState *s = (struct IPodTouchSDIOState *) opaque; | ||
|
||
switch(addr) { | ||
case SDIO_CMD: | ||
s->cmd = value; | ||
break; | ||
case SDIO_ARGU: | ||
s->arg = value; | ||
break; | ||
case SDIO_CSR: | ||
s->csr = value; | ||
break; | ||
case SDIO_IRQMASK: | ||
s->irq_mask = value; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
static uint64_t ipod_touch_sdio_read(void *opaque, hwaddr addr, unsigned size) | ||
{ | ||
fprintf(stderr, "%s: offset = 0x%08x\n", __func__, addr); | ||
|
||
IPodTouchSDIOState *s = (struct IPodTouchSDIOState *) opaque; | ||
|
||
switch (addr) { | ||
case SDIO_CMD: | ||
return s->cmd; | ||
case SDIO_ARGU: | ||
return s->arg; | ||
case SDIO_DSTA: | ||
return (1 << 0) | (1 << 4) ; // 0x1 indicates that the SDIO is ready for a CMD, (1 << 4) that the command is complete | ||
case SDIO_CSR: | ||
return s->csr; | ||
case SDIO_IRQMASK: | ||
return s->irq_mask; | ||
default: | ||
break; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static const MemoryRegionOps ipod_touch_sdio_ops = { | ||
.read = ipod_touch_sdio_read, | ||
.write = ipod_touch_sdio_write, | ||
.endianness = DEVICE_NATIVE_ENDIAN, | ||
}; | ||
|
||
static void ipod_touch_sdio_init(Object *obj) | ||
{ | ||
DeviceState *dev = DEVICE(obj); | ||
IPodTouchSDIOState *s = IPOD_TOUCH_SDIO(obj); | ||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
|
||
memory_region_init_io(&s->iomem, obj, &ipod_touch_sdio_ops, s, TYPE_IPOD_TOUCH_SDIO, 4096); | ||
sysbus_init_mmio(sbd, &s->iomem); | ||
} | ||
|
||
static void ipod_touch_sdio_class_init(ObjectClass *klass, void *data) | ||
{ | ||
DeviceClass *dc = DEVICE_CLASS(klass); | ||
} | ||
|
||
static const TypeInfo ipod_touch_sdio_type_info = { | ||
.name = TYPE_IPOD_TOUCH_SDIO, | ||
.parent = TYPE_SYS_BUS_DEVICE, | ||
.instance_size = sizeof(IPodTouchSDIOState), | ||
.instance_init = ipod_touch_sdio_init, | ||
.class_init = ipod_touch_sdio_class_init, | ||
}; | ||
|
||
static void ipod_touch_sdio_register_types(void) | ||
{ | ||
type_register_static(&ipod_touch_sdio_type_info); | ||
} | ||
|
||
type_init(ipod_touch_sdio_register_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef IPOD_TOUCH_SDIO_H | ||
#define IPOD_TOUCH_SDIO_H | ||
|
||
#include "qemu/osdep.h" | ||
#include "qemu/module.h" | ||
#include "qemu/timer.h" | ||
#include "hw/sysbus.h" | ||
|
||
#define TYPE_IPOD_TOUCH_SDIO "ipodtouch.sdio" | ||
OBJECT_DECLARE_SIMPLE_TYPE(IPodTouchSDIOState, IPOD_TOUCH_SDIO) | ||
|
||
#define SDIO_CMD 0x8 | ||
#define SDIO_ARGU 0xC | ||
#define SDIO_DSTA 0x18 | ||
#define SDIO_CSR 0x34 | ||
#define SDIO_IRQMASK 0x3C | ||
|
||
typedef struct IPodTouchSDIOState | ||
{ | ||
SysBusDevice parent_obj; | ||
MemoryRegion iomem; | ||
|
||
uint32_t cmd; | ||
uint32_t arg; | ||
uint32_t csr; | ||
uint32_t irq_mask; | ||
} IPodTouchSDIOState; | ||
|
||
#endif |