omap2.c
来自「xen虚拟机源代码安装包」· C语言 代码 · 共 2,270 行 · 第 1/5 页
C
2,270 行
case 0x38: /* MCSPI_TX */ s->ch[ch].tx = value; s->ch[ch].status &= ~(1 << 1); /* TXS */ omap_mcspi_transfer_run(s, ch); break; default: OMAP_BAD_REG(addr); return; }}static CPUReadMemoryFunc *omap_mcspi_readfn[] = { omap_badwidth_read32, omap_badwidth_read32, omap_mcspi_read,};static CPUWriteMemoryFunc *omap_mcspi_writefn[] = { omap_badwidth_write32, omap_badwidth_write32, omap_mcspi_write,};struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk){ int iomemtype; struct omap_mcspi_s *s = (struct omap_mcspi_s *) qemu_mallocz(sizeof(struct omap_mcspi_s)); struct omap_mcspi_ch_s *ch = s->ch; s->irq = irq; s->chnum = chnum; while (chnum --) { ch->txdrq = *drq ++; ch->rxdrq = *drq ++; ch ++; } omap_mcspi_reset(s); iomemtype = cpu_register_io_memory(0, omap_mcspi_readfn, omap_mcspi_writefn, s); s->base = omap_l4_attach(ta, 0, iomemtype); return s;}void omap_mcspi_attach(struct omap_mcspi_s *s, uint32_t (*txrx)(void *opaque, uint32_t, int), void *opaque, int chipselect){ if (chipselect < 0 || chipselect >= s->chnum) cpu_abort(cpu_single_env, "%s: Bad chipselect %i\n", __FUNCTION__, chipselect); s->ch[chipselect].txrx = txrx; s->ch[chipselect].opaque = opaque;}/* STI/XTI (emulation interface) console - reverse engineered only */struct omap_sti_s { target_phys_addr_t base; target_phys_addr_t channel_base; qemu_irq irq; CharDriverState *chr; uint32_t sysconfig; uint32_t systest; uint32_t irqst; uint32_t irqen; uint32_t clkcontrol; uint32_t serial_config;};#define STI_TRACE_CONSOLE_CHANNEL 239#define STI_TRACE_CONTROL_CHANNEL 253static inline void omap_sti_interrupt_update(struct omap_sti_s *s){ qemu_set_irq(s->irq, s->irqst & s->irqen);}static void omap_sti_reset(struct omap_sti_s *s){ s->sysconfig = 0; s->irqst = 0; s->irqen = 0; s->clkcontrol = 0; s->serial_config = 0; omap_sti_interrupt_update(s);}static uint32_t omap_sti_read(void *opaque, target_phys_addr_t addr){ struct omap_sti_s *s = (struct omap_sti_s *) opaque; int offset = addr - s->base; switch (offset) { case 0x00: /* STI_REVISION */ return 0x10; case 0x10: /* STI_SYSCONFIG */ return s->sysconfig; case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */ return 0x00; case 0x18: /* STI_IRQSTATUS */ return s->irqst; case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */ return s->irqen; case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */ case 0x28: /* STI_RX_DR / XTI_RXDATA */ /* TODO */ return 0; case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */ return s->clkcontrol; case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */ return s->serial_config; } OMAP_BAD_REG(addr); return 0;}static void omap_sti_write(void *opaque, target_phys_addr_t addr, uint32_t value){ struct omap_sti_s *s = (struct omap_sti_s *) opaque; int offset = addr - s->base; switch (offset) { case 0x00: /* STI_REVISION */ case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */ OMAP_RO_REG(addr); return; case 0x10: /* STI_SYSCONFIG */ if (value & (1 << 1)) /* SOFTRESET */ omap_sti_reset(s); s->sysconfig = value & 0xfe; break; case 0x18: /* STI_IRQSTATUS */ s->irqst &= ~value; omap_sti_interrupt_update(s); break; case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */ s->irqen = value & 0xffff; omap_sti_interrupt_update(s); break; case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */ s->clkcontrol = value & 0xff; break; case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */ s->serial_config = value & 0xff; break; case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */ case 0x28: /* STI_RX_DR / XTI_RXDATA */ /* TODO */ return; default: OMAP_BAD_REG(addr); return; }}static CPUReadMemoryFunc *omap_sti_readfn[] = { omap_badwidth_read32, omap_badwidth_read32, omap_sti_read,};static CPUWriteMemoryFunc *omap_sti_writefn[] = { omap_badwidth_write32, omap_badwidth_write32, omap_sti_write,};static uint32_t omap_sti_fifo_read(void *opaque, target_phys_addr_t addr){ OMAP_BAD_REG(addr); return 0;}static void omap_sti_fifo_write(void *opaque, target_phys_addr_t addr, uint32_t value){ struct omap_sti_s *s = (struct omap_sti_s *) opaque; int offset = addr - s->channel_base; int ch = offset >> 6; uint8_t byte = value; if (ch == STI_TRACE_CONTROL_CHANNEL) { /* Flush channel <i>value</i>. */ qemu_chr_write(s->chr, "\r", 1); } else if (ch == STI_TRACE_CONSOLE_CHANNEL || 1) { if (value == 0xc0 || value == 0xc3) { /* Open channel <i>ch</i>. */ } else if (value == 0x00) qemu_chr_write(s->chr, "\n", 1); else qemu_chr_write(s->chr, &byte, 1); }}static CPUReadMemoryFunc *omap_sti_fifo_readfn[] = { omap_sti_fifo_read, omap_badwidth_read8, omap_badwidth_read8,};static CPUWriteMemoryFunc *omap_sti_fifo_writefn[] = { omap_sti_fifo_write, omap_badwidth_write8, omap_badwidth_write8,};struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta, target_phys_addr_t channel_base, qemu_irq irq, omap_clk clk, CharDriverState *chr){ int iomemtype; struct omap_sti_s *s = (struct omap_sti_s *) qemu_mallocz(sizeof(struct omap_sti_s)); s->irq = irq; omap_sti_reset(s); s->chr = chr ?: qemu_chr_open("null"); iomemtype = cpu_register_io_memory(0, omap_sti_readfn, omap_sti_writefn, s); s->base = omap_l4_attach(ta, 0, iomemtype); iomemtype = cpu_register_io_memory(0, omap_sti_fifo_readfn, omap_sti_fifo_writefn, s); s->channel_base = channel_base; cpu_register_physical_memory(s->channel_base, 0x10000, iomemtype); return s;}/* L4 Interconnect */struct omap_target_agent_s { struct omap_l4_s *bus; int regions; struct omap_l4_region_s *start; target_phys_addr_t base; uint32_t component; uint32_t control; uint32_t status;};struct omap_l4_s { target_phys_addr_t base; int ta_num; struct omap_target_agent_s ta[0];};struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num){ struct omap_l4_s *bus = qemu_mallocz( sizeof(*bus) + ta_num * sizeof(*bus->ta)); bus->ta_num = ta_num; bus->base = base; return bus;}static uint32_t omap_l4ta_read(void *opaque, target_phys_addr_t addr){ struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque; target_phys_addr_t reg = addr - s->base; switch (reg) { case 0x00: /* COMPONENT */ return s->component; case 0x20: /* AGENT_CONTROL */ return s->control; case 0x28: /* AGENT_STATUS */ return s->status; } OMAP_BAD_REG(addr); return 0;}static void omap_l4ta_write(void *opaque, target_phys_addr_t addr, uint32_t value){ struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque; target_phys_addr_t reg = addr - s->base; switch (reg) { case 0x00: /* COMPONENT */ case 0x28: /* AGENT_STATUS */ OMAP_RO_REG(addr); break; case 0x20: /* AGENT_CONTROL */ s->control = value & 0x01000700; if (value & 1) /* OCP_RESET */ s->status &= ~1; /* REQ_TIMEOUT */ break; default: OMAP_BAD_REG(addr); }}static CPUReadMemoryFunc *omap_l4ta_readfn[] = { omap_badwidth_read16, omap_l4ta_read, omap_badwidth_read16,};static CPUWriteMemoryFunc *omap_l4ta_writefn[] = { omap_badwidth_write32, omap_badwidth_write32, omap_l4ta_write,};#define L4TA(n) (n)#define L4TAO(n) ((n) + 39)static struct omap_l4_region_s { target_phys_addr_t offset; size_t size; int access;} omap_l4_region[125] = { [ 1] = { 0x40800, 0x800, 32 }, /* Initiator agent */ [ 2] = { 0x41000, 0x1000, 32 }, /* Link agent */ [ 0] = { 0x40000, 0x800, 32 }, /* Address and protection */ [ 3] = { 0x00000, 0x1000, 32 | 16 | 8 }, /* System Control and Pinout */ [ 4] = { 0x01000, 0x1000, 32 | 16 | 8 }, /* L4TAO1 */ [ 5] = { 0x04000, 0x1000, 32 | 16 }, /* 32K Timer */ [ 6] = { 0x05000, 0x1000, 32 | 16 | 8 }, /* L4TAO2 */ [ 7] = { 0x08000, 0x800, 32 }, /* PRCM Region A */ [ 8] = { 0x08800, 0x800, 32 }, /* PRCM Region B */ [ 9] = { 0x09000, 0x1000, 32 | 16 | 8 }, /* L4TAO */ [ 10] = { 0x12000, 0x1000, 32 | 16 | 8 }, /* Test (BCM) */ [ 11] = { 0x13000, 0x1000, 32 | 16 | 8 }, /* L4TA1 */ [ 12] = { 0x14000, 0x1000, 32 }, /* Test/emulation (TAP) */ [ 13] = { 0x15000, 0x1000, 32 | 16 | 8 }, /* L4TA2 */ [ 14] = { 0x18000, 0x1000, 32 | 16 | 8 }, /* GPIO1 */ [ 16] = { 0x1a000, 0x1000, 32 | 16 | 8 }, /* GPIO2 */ [ 18] = { 0x1c000, 0x1000, 32 | 16 | 8 }, /* GPIO3 */ [ 19] = { 0x1e000, 0x1000, 32 | 16 | 8 }, /* GPIO4 */ [ 15] = { 0x19000, 0x1000, 32 | 16 | 8 }, /* Quad GPIO TOP */ [ 17] = { 0x1b000, 0x1000, 32 | 16 | 8 }, /* L4TA3 */ [ 20] = { 0x20000, 0x1000, 32 | 16 | 8 }, /* WD Timer 1 (Secure) */ [ 22] = { 0x22000, 0x1000, 32 | 16 | 8 }, /* WD Timer 2 (OMAP) */ [ 21] = { 0x21000, 0x1000, 32 | 16 | 8 }, /* Dual WD timer TOP */ [ 23] = { 0x23000, 0x1000, 32 | 16 | 8 }, /* L4TA4 */ [ 24] = { 0x28000, 0x1000, 32 | 16 | 8 }, /* GP Timer 1 */ [ 25] = { 0x29000, 0x1000, 32 | 16 | 8 }, /* L4TA7 */ [ 26] = { 0x48000, 0x2000, 32 | 16 | 8 }, /* Emulation (ARM11ETB) */ [ 27] = { 0x4a000, 0x1000, 32 | 16 | 8 }, /* L4TA9 */ [ 28] = { 0x50000, 0x400, 32 | 16 | 8 }, /* Display top */ [ 29] = { 0x50400, 0x400, 32 | 16 | 8 }, /* Display control */ [ 30] = { 0x50800, 0x400, 32 | 16 | 8 }, /* Display RFBI */ [ 31] = { 0x50c00, 0x400, 32 | 16 | 8 }, /* Display encoder */ [ 32] = { 0x51000, 0x1000, 32 | 16 | 8 }, /* L4TA10 */ [ 33] = { 0x52000, 0x400, 32 | 16 | 8 }, /* Camera top */ [ 34] = { 0x52400, 0x400, 32 | 16 | 8 }, /* Camera core */ [ 35] = { 0x52800, 0x400, 32 | 16 | 8 }, /* Camera DMA */ [ 36] = { 0x52c00, 0x400, 32 | 16 | 8 }, /* Camera MMU */ [ 37] = { 0x53000, 0x1000, 32 | 16 | 8 }, /* L4TA11 */ [ 38] = { 0x56000, 0x1000, 32 | 16 | 8 }, /* sDMA */ [ 39] = { 0x57000, 0x1000, 32 | 16 | 8 }, /* L4TA12 */ [ 40] = { 0x58000, 0x1000, 32 | 16 | 8 }, /* SSI top */ [ 41] = { 0x59000, 0x1000, 32 | 16 | 8 }, /* SSI GDD */ [ 42] = { 0x5a000, 0x1000, 32 | 16 | 8 }, /* SSI Port1 */ [ 43] = { 0x5b000, 0x1000, 32 | 16 | 8 }, /* SSI Port2 */ [ 44] = { 0x5c000, 0x1000, 32 | 16 | 8 }, /* L4TA13 */ [ 45] = { 0x5e000, 0x1000, 32 | 16 | 8 }, /* USB OTG */ [ 46] = { 0x5f000, 0x1000, 32 | 16 | 8 }, /* L4TAO4 */ [ 47] = { 0x60000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER1SDRC) */ [ 48] = { 0x61000, 0x1000, 32 | 16 | 8 }, /* L4TA14 */ [ 49] = { 0x62000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER2GPMC) */ [ 50] = { 0x63000, 0x1000, 32 | 16 | 8 }, /* L4TA15 */ [ 51] = { 0x64000, 0x1000, 32 | 16 | 8 }, /* Emulation (WIN_TRACER3OCM) */ [ 52] = { 0x65000, 0x1000, 32 | 16 | 8 }, /* L4TA16 */ [ 53] = { 0x66000, 0x300, 32 | 16 | 8 }, /* Emulation (WIN_TRACER4L4) */ [ 54] = { 0x67000, 0x1000, 32 | 16 | 8 }, /* L4TA17 */ [ 55] = { 0x68000, 0x1000, 32 | 16 | 8 }, /* Emulation (XTI) */ [ 56] = { 0x69000, 0x1000, 32 | 16 | 8 }, /* L4TA18 */ [ 57] = { 0x6a000, 0x1000, 16 | 8 }, /* UART1 */ [ 58] = { 0x6b000, 0x1000, 32 | 16 | 8 }, /* L4TA19 */ [ 59] = { 0x6c000, 0x1000, 16 | 8 }, /* UART2 */ [ 60] = { 0x6d000, 0x1000, 32 | 16 | 8 }, /* L4TA20 */ [ 61] = { 0x6e000, 0x1000, 16 | 8 }, /* UART3 */ [ 62] = { 0x6f000, 0x1000, 32 | 16 | 8 }, /* L4TA21 */ [ 63] = { 0x70000, 0x1000, 16 }, /* I2C1 */ [ 64] = { 0x71000, 0x1000, 32 | 16 | 8 }, /* L4TAO5 */ [ 65] = { 0x72000, 0x1000, 16 }, /* I2C2 */ [ 66] = { 0x73000, 0x1000, 32 | 16 | 8 }, /* L4TAO6 */ [ 67] = { 0x74000, 0x1000, 16 }, /* McBSP1 */ [ 68] = { 0x75000, 0x1000, 32 | 16 | 8 }, /* L4TAO7 */ [ 69] = { 0x76000, 0x1000, 16 }, /* McBSP2 */ [ 70] = { 0x77000, 0x1000, 32 | 16 | 8 }, /* L4TAO8 */ [ 71] = { 0x24000, 0x1000, 32 | 16 | 8 }, /* WD Timer 3 (DSP) */ [ 72] = { 0x25000, 0x1000, 32 | 16 | 8 }, /* L4TA5 */ [ 73] = { 0x26000, 0x1000, 32 | 16 | 8 }, /* WD Timer 4 (IVA) */ [ 74] = { 0x27000, 0x1000, 32 | 16 | 8 }, /* L4TA6 */ [ 75] = { 0x2a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 2 */ [ 76] = { 0x2b000, 0x1000, 32 | 16 | 8 }, /* L4TA8 */ [ 77] = { 0x78000, 0x1000, 32 | 16 | 8 }, /* GP Timer 3 */ [ 78] = { 0x79000, 0x1000, 32 | 16 | 8 }, /* L4TA22 */ [ 79] = { 0x7a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 4 */ [ 80] = { 0x7b000, 0x1000, 32 | 16 | 8 }, /* L4TA23 */ [ 81] = { 0x7c000, 0x1000, 32 | 16 | 8 }, /* GP Timer 5 */ [ 82] = { 0x7d000, 0x1000, 32 | 16 | 8 }, /* L4TA24 */ [ 83] = { 0x7e000, 0x1000, 32 | 16 | 8 }, /* GP Timer 6 */ [ 84] = { 0x7f000, 0x1000, 32 | 16 | 8 }, /* L4TA25 */ [ 85] = { 0x80000, 0x1000, 32 | 16 | 8 }, /* GP Timer 7 */ [ 86] = { 0x81000, 0x1000, 32 | 16 | 8 }, /* L4TA26 */ [ 87] = { 0x82000, 0x1000, 32 | 16 | 8 }, /* GP Timer 8 */ [ 88] = { 0x83000, 0x1000, 32 | 16 | 8 }, /* L4TA27 */ [ 89] = { 0x84000, 0x1000, 32 | 16 | 8 }, /* GP Timer 9 */ [ 90] = { 0x85000, 0x1000, 32 | 16 | 8 }, /* L4TA28 */ [ 91] = { 0x86000, 0x1000, 32 | 16 | 8 }, /* GP Timer 10 */ [ 92] = { 0x87000, 0x1000, 32 | 16 | 8 }, /* L4TA29 */ [ 93] = { 0x88000, 0x1000, 32 | 16 | 8 }, /* GP Timer 11 */ [ 94] = { 0x89000, 0x1000, 32 | 16 | 8 }, /* L4TA30 */ [ 95] = { 0x8a000, 0x1000, 32 | 16 | 8 }, /* GP Timer 12 */ [ 96] = { 0x8b000, 0x1000, 32 | 16 | 8 }, /* L4TA31 */ [ 97] = { 0x90000, 0x1000, 16 }, /* EAC */ [ 98] = { 0x91000, 0x1000, 32 | 16 | 8 }, /* L4TA32 */ [ 99] = { 0x92000, 0x1000, 16 }, /* FAC */ [100] = { 0x93000, 0x1000, 32 | 16 | 8 }, /* L4TA33 */ [101] = { 0x94000, 0x1000, 32 | 16 | 8 }, /* IPC (MAILBOX) */ [102] = { 0x95000, 0x1000, 32 | 16 | 8 }, /* L4TA34 */ [103] = { 0x98000, 0x1000, 32 | 16 | 8 }, /* SPI1 */ [104] = { 0x99000, 0x1000, 32 | 16 | 8 }, /* L4TA35 */ [105] = { 0x9a000, 0x1000, 32 | 16 | 8 }, /* SPI2 */ [106] = { 0x9b000, 0x1000, 32 | 16 | 8 }, /* L4TA36 */ [107] = { 0x9c000, 0x1000, 16 | 8 }, /* MMC SDIO */ [108] = { 0x9d000, 0x1000, 32 | 16 | 8 }, /* L4TAO9 */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?