📄 bf537_io.c
字号:
core_int_read_long (bu32 addr){ int offset = addr - CORE_INT_IO_START_ADDR; bu32 ret; //printf("read %x\n",offset); switch (offset) { case 0x104: ret = (bf537_io.core_int.imask | 0x1f) & 0xffff; break; case 0x108: ret = bf537_io.core_int.ipend; break; case 0x10c: ret = bf537_io.core_int.ilat; //printf("read ilat %x",ret); break; case 0x110: ret = bf537_io.core_int.iprio; break; default: if (offset >= 0 && offset < 0x100) { ret = bf537_io.core_int.evt[offset >> 2]; return ret; } IO_ERR; } return ret;}static voidwd_write_word (bu32 addr, bu16 v){ int offset = addr - WD_IO_START_ADDR; switch (offset) { case 0x0: bf537_io.wd.ctl = v; break; case 0x4: bf537_io.wd.cnt = v; break; case 0x8: bf537_io.wd.stat = v; break; default: IO_ERR; }}static bu32deu_read_long (bu32 addr){ int offset = addr - DEU_IO_START_ADDR; switch (offset) { case 0x0: return bf537_io.deu.dspid; default: IO_ERR; }}static bu16dpmc_read_word (bu32 addr){ int offset = addr - DPMC_IO_START_ADDR; bu16 ret; switch (offset) { case 0x0: ret = bf537_io.dpmc.pll_ctl; break; case 0x4: ret = bf537_io.dpmc.pll_div; break; case 0x8: ret = bf537_io.dpmc.vr_ctl; break; case 0xc: ret = bf537_io.dpmc.pll_stat; /*PLL_LOCKED is set */ break; case 0x10: ret = bf537_io.dpmc.pll_lockcnt; break; default: IO_ERR; } return ret;}static voiddpmc_write_word (bu32 addr, bu16 v){ int offset = addr - DPMC_IO_START_ADDR; switch (offset) { case 0x0: bf537_io.dpmc.pll_ctl = v; break; case 0x4: bf537_io.dpmc.pll_div = v; break; case 0x8: bf537_io.dpmc.vr_ctl = v; break; case 0xc: bf537_io.dpmc.pll_stat = v; break; case 0x10: bf537_io.dpmc.pll_lockcnt = v; break; default: IO_ERR; } return;}static bu32tbuf_read_long (bu32 addr){ int offset = addr - TBUF_IO_START_ADDR; switch (offset) { case 0: return bf537_io.tbuf.ctrl; case 4: return bf537_io.tbuf.stat; case 0x100: if (bf537_io.tbuf.rsel == 1) { bf537_io.tbuf.rsel = 0; if (bf537_io.tbuf.rix >= 16) bf537_io.tbuf.rix = 0; return bf537_io.tbuf.sbuf[bf537_io.tbuf.rix]; } else { bf537_io.tbuf.rsel = 1; return bf537_io.tbuf.dbuf[bf537_io.tbuf.rix++]; } break; default: IO_ERR; break; } return 0;}static voidtbuf_write_long (bu32 addr, bu32 v){ int offset = addr - TBUF_IO_START_ADDR; switch (offset) { case 0: bf537_io.tbuf.ctrl = v; break; case 4: bf537_io.tbuf.stat = v; break; case 0x100: if (bf537_io.tbuf.wsel == 1) { bf537_io.tbuf.wsel = 0; if (bf537_io.tbuf.wix >= 16) bf537_io.tbuf.wix = 0; bf537_io.tbuf.sbuf[bf537_io.tbuf.wix] = v; } else { bf537_io.tbuf.wsel = 1; bf537_io.tbuf.dbuf[bf537_io.tbuf.wix++] = v; } break; default: IO_ERR; break; } return ;}static bu32sic_read_long (bu32 addr){ int offset = addr - SIC_IO_START_ADDR; bu32 ret; switch (offset) { case 0x0: ret = bf537_io.sic.swrst; break; case 0x4: ret = bf537_io.sic.syscr; break; case 0xc: ret = bf537_io.sic.sic_imask; //printf("KSDBG:read imask ret= %x\n",ret); break; case 0x20: ret = bf537_io.sic.sic_isr; //printf("read sic_isr 0x%x\n",ret); break; case 0x24: ret = bf537_io.sic.sic_iwr; break; default: if (offset >= 0x10 && offset <= 0x1c) { ret = bf537_io.sic.sic_iar[(offset - 0x10) >> 2]; return ret; } IO_ERR; } return ret;}static voidsic_write_long (bu32 addr, bu32 v){ int offset = addr - SIC_IO_START_ADDR; switch (offset) { case 0x24: bf537_io.sic.sic_iwr = v; break; case 0xc: //printf("KSDBG:write sic_imask v=%x\n",v); bf537_io.sic.sic_imask = v; break; default: if (offset >= 0x10 && offset <= 0x1c) { bf537_io.sic.sic_iar[(offset - 0x10) >> 2] = v; return; } IO_ERR; }}static voidl1mem_write_long (bu32 addr, bu32 v){ int offset = addr - L1MEM_IO_START_ADDR; int pos = offset >> 2; switch (pos) { default: bf537_io.l1mem.reg[pos] = v; break; }}static bu32l1mem_read_long (bu32 addr){ int offset = addr - L1MEM_IO_START_ADDR; int pos = offset >> 2; bu32 ret; switch (pos) { default: ret = bf537_io.l1mem.reg[pos]; } return ret;}static voidl1dmem_write_long (bu32 addr, bu32 v){ int offset = addr - L1DMEM_IO_START_ADDR; int pos = offset >> 2; switch (pos) { default: bf537_io.l1dmem.reg[pos]; break; }}static voidrtc_write_word (bu32 addr, bu16 v){ int offset = addr - RTC_IO_START_ADDR; switch (offset) { case 0x4: bf537_io.rtc.ictl = v; return; case 0x14: bf537_io.rtc.pren = v; /*set write complete bit to one */ bf537_io.rtc.istat |= 0x8000; return; case 0x8: bf537_io.rtc.istat = v; return; default: IO_ERR; }}static bu16rtc_read_word (bu32 addr){ int offset = addr - RTC_IO_START_ADDR; bu16 ret; switch (offset) { case 0x14: ret = bf537_io.rtc.pren; break; case 0x8: ret = bf537_io.rtc.istat; /*clear write complete bit */ bf537_io.rtc.istat &= ~0x8000; break; default: IO_ERR; } return ret;}static voidrtc_write_long (bu32 addr, bu32 v){ int offset = addr - RTC_IO_START_ADDR; switch (offset) { case 0x0: bf537_io.rtc.stat = v; return; case 0x10: bf537_io.rtc.alarm = v; return; default: IO_ERR; }}static bu32rtc_read_long (bu32 addr){ int offset = addr - RTC_IO_START_ADDR; bu32 ret; switch (offset) { case 0x0: ret = bf537_io.rtc.stat; break; default: IO_ERR; } return ret;}static bu32l1dmem_read_long (bu32 addr){ int offset = addr - L1DMEM_IO_START_ADDR; int pos = offset >> 2; bu32 ret; switch (pos) { default: ret = bf537_io.l1dmem.reg[pos]; break; } return ret;}static voidcore_timer_write_long (bu32 addr, bu32 v){ int offset = addr - CORE_TIMER_IO_START_ADDR; //printf("offset=%x",offset); switch (offset) { case 0x0: bf537_io.core_timer.tcntl = v; /*not sure core_int is open at this time */ if (bf537_io.core_timer.tcntl & 0x2) { bf537_io.core_int.imask |= 1 << CORE_TIMER_IRQ; } break; case 0x4: bf537_io.core_timer.tperio = v; break; case 0x8: bf537_io.core_timer.tscale = v; break; case 0xc: bf537_io.core_timer.tcount = v; break; default: IO_ERR; } return;}static bu32core_timer_read_long (bu32 addr){ int offset = addr - CORE_TIMER_IO_START_ADDR; bu32 ret; switch (offset) { case 0x0: ret = bf537_io.core_timer.tcntl; break; case 0x4: ret = bf537_io.core_timer.tperio; break; case 0x8: ret = bf537_io.core_timer.tscale; break; case 0xc: ret = bf537_io.core_timer.tcount; break; default: IO_ERR; } return ret;}static bu16pf_read_word (bu32 addr){ int offset = addr - PF_IO_START_ADDR; bu32 ret; switch (offset) { case 0x30: ret = bf537_io.pf.fio_dir; break; case 0x40: ret = bf537_io.pf.fio_inen; break; default: IO_ERR; } return ret;}static voidpf_write_word (bu32 addr, bu16 v){ int offset = addr - PF_IO_START_ADDR; switch (offset) { case 0x4: bf537_io.pf.fio_flag_c = v; return; case 0x8: bf537_io.pf.fio_flag_s = v; return; case 0x14: bf537_io.pf.fio_maska_c = v; return; case 0x24: bf537_io.pf.fio_maskb_c = v; return; case 0x30: bf537_io.pf.fio_dir = v; return; case 0x10: // Flag Mask Interrupt A Register (set directly) case 0x38: // Flag Source Sensitivity Register case 0x40: // Flag Input Enable Register return; default: IO_ERR; }}static bu16 port_read_word(bu32 addr){ uint32_t offset = addr - PORT_IO_START_ADDR; switch(offset){ case 0x0: return bf537_io.port.portf_fer; case 0xc: return bf537_io.port.port_mux; default: IO_ERR; }}static void port_write_word(bu32 addr, bu16 v){ uint32_t offset = addr - PORT_IO_START_ADDR; switch(offset){ case 0x0: bf537_io.port.portf_fer = v; return; case 0xc: bf537_io.port.port_mux = v; return; default: IO_ERR; }}static bu32 port_read_long(bu32 addr){ IO_ERR; return -1;}static bu32 eth_read_long(bu32 addr){ uint32_t offset = addr - ETH_IO_START_ADDR; switch(offset){ case 0x64: return bf537_io.eth.emac_systat; default: IO_ERR; }}static void eth_write_long(bu32 addr, bu32 v){ uint32_t offset = addr - ETH_IO_START_ADDR; switch(offset){ case 0x64: bf537_io.eth.emac_systat = v; return; default: IO_ERR; }}voidbf537_mach_init (void * curr_state, machine_config_t * this_mach){ saved_state_type *p_state; /*init bf537_io. value */ bf537_io.dpmc.pll_div = 0x0005; bf537_io.dpmc.pll_ctl = 0x1400; bf537_io.dpmc.pll_lockcnt = 0x0200; bf537_io.dpmc.pll_stat = 0x00a2; bf537_io.core_int.ipend = 0x11; /*at the beginning,global int is disabled and we are in Reset exception */ bf537_io.core_int.imask = 0x1f; bf537_io.core_int.ilat = 0x0; /**/ bf537_io.sic.sic_isr = 0x0; bf537_io.uart.lcr = 0x0; bf537_io.uart.dll = 0x0001; bf537_io.uart.ier = 0x0; bf537_io.uart.iir = 0x1; bf537_io.uart.lsr = 0x60; bf537_io.tbuf.ctrl = 0; bf537_io.tbuf.stat = 0; bf537_io.tbuf.rix = 0; bf537_io.tbuf.rsel = 0; bf537_io.tbuf.wix = 0; bf537_io.tbuf.wsel = 0; /*init mach */ if (!this_mach) { skyeye_exit (-1); } this_mach->mach_io_read_byte = bf537_io_read_byte; this_mach->mach_io_read_halfword = bf537_io_read_word; this_mach->mach_io_read_word = bf537_io_read_long; this_mach->mach_io_write_byte = bf537_io_write_byte; this_mach->mach_io_write_halfword = bf537_io_write_word; this_mach->mach_io_write_word = bf537_io_write_long; this_mach->mach_io_do_cycle = bf537_io_do_cycle; this_mach->mach_set_intr = bf537_set_int; p_state = (saved_state_type *)curr_state; p_state->disable_int = bf537_disable_int; p_state->enable_int = bf537_enable_int; p_state->clear_int = bf537_clear_int; p_state->sti = bf537_sti; p_state->cli = bf537_cli; p_state->set_int = bf537_set_int;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -