Mercurial > repos > blastem
changeset 2580:939b818df589
Get 68K interrupts working in new CPU core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 08 Feb 2025 11:40:42 -0800 |
parents | bd8d1babbfb5 |
children | 9e10149c9e10 |
files | cpu_dsl.py m68k.cpu m68k_util.c |
diffstat | 3 files changed, 40 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/cpu_dsl.py Fri Feb 07 23:32:15 2025 -0800 +++ b/cpu_dsl.py Sat Feb 08 11:40:42 2025 -0800 @@ -1967,6 +1967,8 @@ pieces.append('\n\t{') if self.interrupt in self.subroutines: pieces.append('\n\t\tif (context->cycles >= context->sync_cycle) {') + pieces.append(f'\n\t\t\t{self.sync_cycle}(context, target_cycle);') + pieces.append('\n\t\t}') self.meta = {} self.temp = {} intpieces = [] @@ -1974,7 +1976,6 @@ for size in self.temp: pieces.append('\n\tuint{sz}_t gen_tmp{sz}__;'.format(sz=size)) pieces += intpieces - pieces.append('\n\t\t}') self.meta = {} self.temp = {} self.subroutines[self.body].inline(self, [], pieces, otype, None)
--- a/m68k.cpu Fri Feb 07 23:32:15 2025 -0800 +++ b/m68k.cpu Sat Feb 08 11:40:42 2025 -0800 @@ -173,42 +173,45 @@ int_pending = int_priority int_pending_num = int_num - else + end + + check_user_mode_swap_ssp_usp + + cycles 6 + #save status reg + a7 -= 6 + m68k_get_sr + scratch2 = a7 + ocall write_16 + + #update status register + status &= 0x78 + status |= int_pending + status |= 0x20 - check_user_mode_swap_ssp_usp - - cycles 6 - #save status reg - sub 6 a7 a7 - m68k_get_sr - mov a7 scratch2 - ocall write_16 - - #update status register - and 0x78 status status - or int_priority status status - or 0x20 status status - - #Interrupt ack cycle - mov int_pending int_ack - cycles 4 - if int_ack_handler - pcall int_ack_handler int_ack_fun context - end - if int_pending_num - else - int_pending_num = int_pending + 24 - end - - #save pc - add 2 a7 scratch2 - m68k_write32_lowfirst pc - - lsl int_pending_num 2 scratch1 - m68k_read32 - mov scratch1 pc - update_sync + #Interrupt ack cycle + int_ack = int_pending + cycles 4 + if int_ack_handler + pcall int_ack_handler int_ack_fun context + end + if int_pending_num + else + int_pending_num = int_pending + 24 end + + #save pc + scratch2 = a7 + 2 + scratch1 = pc - 2 + m68k_write32_lowfirst scratch1 + + scratch1 = int_pending_num << 2 + int_pending = 255 #INT_PENDING_NONE + int_pending_num = 0 + m68k_read32 + mov scratch1 pc + m68k_prefetch + update_sync end end
--- a/m68k_util.c Fri Feb 07 23:32:15 2025 -0800 +++ b/m68k_util.c Sat Feb 08 11:40:42 2025 -0800 @@ -52,6 +52,7 @@ context->opts = opts; context->reset_handler = reset_handler; context->int_cycle = 0xFFFFFFFFU; + context->int_pending = 255; context->sync_components = sync_comp_tmp; sync_comp_tmp = NULL; context->int_ack_handler = int_ack_tmp;