Kernel: Change NMOS_Z80/CMOS_Z80 to Z80_TYPE. Change _irqvector so that
authorWill Sowerbutts <will@sowerbutts.com>
Tue, 13 Jan 2015 20:27:43 +0000 (20:27 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Tue, 13 Jan 2015 20:49:07 +0000 (20:49 +0000)
it does not change in case of re-entrant interrupts.

17 files changed:
Kernel/cpu-z180/z180.s
Kernel/lowlevel-z80.s
Kernel/platform-micropack/kernel.def
Kernel/platform-msx1/kernel.def
Kernel/platform-msx2/kernel.def
Kernel/platform-mtx/kernel.def
Kernel/platform-n8vem-mark4/kernel.def
Kernel/platform-nc100/kernel.def
Kernel/platform-p112/kernel.def
Kernel/platform-pcw8256/kernel.def
Kernel/platform-socz80/kernel.def
Kernel/platform-trs80/kernel.def
Kernel/platform-ubee/kernel.def
Kernel/platform-z80pack-lite/kernel.def
Kernel/platform-z80pack/kernel.def
Kernel/platform-z80pack32/kernel.def
Kernel/platform-zx128/kernel.def

index 61f401e..dc242ba 100644 (file)
@@ -10,6 +10,7 @@
         .globl _program_vectors
         .globl _copy_and_map_process
         .globl interrupt_table ; not used elsewhere but useful to check correct alignment
+        .globl hw_irqvector
         .globl _irqvector
         .globl _kernel_flag
 
@@ -571,7 +572,8 @@ interrupt_table:
         .dw z180_irq_unused         ;     15
         .dw z180_irq_unused         ;     16
 
-_irqvector: .db 0
+hw_irqvector:  .db 0
+_irqvector:    .db 0
 
 z80_irq:
         push af
@@ -593,7 +595,7 @@ z180_irq3:
         ld a, #3
         ; fall through -- timer is likely to be the most common, we'll save it the jr
 z180_irqgo:
-        ld (_irqvector), a
+        ld (hw_irqvector), a
         ; quick and dirty way to debug which interrupt is jamming us up ...
         ;    add #0x30
         ;    .globl outchar
index c43c4f6..14a5b39 100644 (file)
@@ -3,12 +3,17 @@
 ; collect this here to minimise the amount of platform specific gloop
 ; involved in a port
 ;
+; Some features are controlled by Z80_TYPE which should be declared in
+; platform/kernel.def as one of the following values:
+;     0   CMOS Z80
+;     1   NMOS Z80
+;     2   Z180
+;
 ;      Based upon code (C) 2013 William R Sowerbutts
 ;
 
        .module lowlevel
 
-
        ; debugging aids
        .globl outcharhex
        .globl outbc, outde, outhl
        .globl _platform_interrupt
        .globl platform_interrupt_all
 
-        .module syscall
-
         ; exported symbols
         .globl unix_syscall_entry
        .globl _chksigs
        .globl null_handler
        .globl unix_syscall_entry
-       .globl dispatch_process_signal
         .globl _doexec
         .globl trap_illegal
        .globl nmi_handler
@@ -48,7 +50,6 @@
         .globl _unix_syscall
         .globl outstring
         .globl kstack_top
-        .globl dispatch_process_signal
        .globl istack_switched_sp
        .globl istack_top
        .globl _ssig
         .include "platform/kernel.def"
         .include "kernel.def"
 
+; these make the code below more readable. sdas allows us only to 
+; test if an expression is zero or non-zero.
+CPU_CMOS_Z80       .equ    Z80_TYPE-0
+CPU_NMOS_Z80       .equ    Z80_TYPE-1
+CPU_Z180           .equ    Z80_TYPE-2
+
         .area _COMMONMEM
 
 ; entry point for UZI system calls
@@ -282,6 +289,20 @@ interrupt_handler:
             inc a
             ld (U_DATA__U_ININTERRUPT), a
 
+.ifeq CPU_Z180
+            ; On Z180 we have more than one IRQ, so we need to track of which one
+            ; we arrived through. The IRQ handler sets irqvector_hw when each
+            ; interrupt arrives. If we are not already handling an interrupt then
+            ; we copy this into _irqvector which is the value the kernel code
+            ; examines (and will not change even if reentrant interrupts arrive). 
+            ; Generally the only place that irqvector_hw should be used is in 
+            ; the platform_interrupt_all routine.
+            .globl hw_irqvector
+            .globl _irqvector
+            ld a, (hw_irqvector)
+            ld (_irqvector), a
+.endif
+
             ; switch stacks
             ld (istack_switched_sp), sp
            ; the istack is not banked (very important!)
@@ -370,7 +391,12 @@ interrupt_return:
             pop af
             ex af, af'
             ei
+.ifeq CPU_Z180
+            ; WRS - we could examine hw_irqvector and return with ret/reti as appropriate?
+            ret
+.else
             reti
+.endif
 
 ;  Enter with HL being the signal to send ourself
 trap_signal:
@@ -505,8 +531,8 @@ numeral:add a, #0x30 ; start at '0' (0x30='0')
 ;      Pull in the CPU specific workarounds
 ;
 
-       .if NMOS_Z80
+.ifeq CPU_NMOS_Z80
        .include "lowlevel-z80-nmos.s"
-       .else
+.else
        .include "lowlevel-z80-cmos.s"
-       .endif
+.endif
index 362b990..3cb9253 100644 (file)
@@ -3,4 +3,4 @@
 U_DATA                      .equ 0x7D00       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
index a9f3e9c..ccff40f 100644 (file)
@@ -7,7 +7,7 @@ U_DATA_STASH                .equ 0x7D00       ; 0x7D00-0x7FFF
 
 ; as far as I can tell either is allowed by the spec
 
-NMOS_Z80                   .equ 1
+Z80_TYPE                   .equ 1
 
 ; Where is the character font preloaded for us on this box
 
index e0f4da1..dd2b6e5 100644 (file)
@@ -5,4 +5,4 @@ U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
 ; as far as I can tell either is allowed by the spec
 
-NMOS_Z80                   .equ 1
+Z80_TYPE                   .equ 1
index 4d1aa3a..6ab4982 100644 (file)
@@ -7,7 +7,7 @@ U_DATA_STASH                .equ 0xBD00       ; BD00-BFFF
 
 PROG_BASE                  .equ 0x0000
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
 
 VRAM_CH                            .equ 3            ; font data 0x1800-1BFF ?
 
index 9ccfb4d..cabb2a9 100644 (file)
@@ -2,7 +2,7 @@
 
 U_DATA                      .equ 0xF000       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
-NMOS_Z80                    .equ 0
+Z80_TYPE                    .equ 2
 
 OS_BANK                     .equ 0x00         ; value from include/kernel.h
 
index 8e6bb14..6e50804 100644 (file)
@@ -3,4 +3,4 @@
 U_DATA                      .equ 0xF000       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
index 0996308..024c6b0 100644 (file)
@@ -2,7 +2,6 @@
 
 U_DATA                      .equ 0xF000       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
-NMOS_Z80                    .equ 0
 
 OS_BANK                     .equ 0x00         ; value from include/kernel.h
 
@@ -10,6 +9,7 @@ OS_BANK                     .equ 0x00         ; value from include/kernel.h
 FIRST_RAM_BANK              .equ 0x00         ; all memory is RAM on P112
 RAM_KB                      .equ 1024
 Z180_IO_BASE                .equ 0x00
+Z80_TYPE                   .equ 2
 
 ; Believe most P112 kits shipped with 16MHz oscillators, I have tried faster 
 ; (18.432MHz) but this made the machine unstable.
index be4a3f0..67fe1f1 100644 (file)
@@ -3,4 +3,4 @@
 U_DATA                      .equ 0xF000       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
-NMOS_Z80                   .equ 0            ; FIXME: check
+Z80_TYPE                   .equ 0            ; FIXME: check
index 40bc6de..b4d7274 100644 (file)
@@ -4,4 +4,4 @@ U_DATA                      .equ 0xf900       ; (this is struct u_data from kern
 U_DATA__PAGEOFFSET          .equ 0x0900       ; U_DATA % 0x1000
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
-NMOS_Z80                   .equ 0            ; Actually a T80
+Z80_TYPE                   .equ 0            ; Actually a T80
index 026e8dc..3291d85 100644 (file)
@@ -7,4 +7,4 @@ U_DATA_STASH                .equ 0x7D00       ; BD00-BFFF
 
 PROG_BASE                  .equ 0x0000
 
-NMOS_Z80                   .equ 1
+Z80_TYPE                   .equ 1
index c6bc875..04e570c 100644 (file)
@@ -7,4 +7,4 @@ U_DATA_STASH                .equ 0x7D00       ; BD00-BFFF
 
 PROG_BASE                  .equ 0x0000
 
-NMOS_Z80                   .equ 1
+Z80_TYPE                   .equ 1
index 8e6bb14..6e50804 100644 (file)
@@ -3,4 +3,4 @@
 U_DATA                      .equ 0xF000       ; (this is struct u_data from kernel.h)
 U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
index 7510c06..e6a5a3c 100644 (file)
@@ -7,4 +7,4 @@ U_DATA_STASH                .equ 0xED00       ; ED00-EFFF
 
 PROG_BASE                  .equ 0
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
index 1cbf67a..9859fe9 100644 (file)
@@ -7,4 +7,4 @@ U_STASH_HIGH                .equ 0xBD00       ; BD00-BFFF
 U_STASH_LOW                .equ 0x7D00       ; 7D00-BFFF
 
 
-NMOS_Z80                   .equ 0
+Z80_TYPE                   .equ 0
index 8a965ee..de19e2a 100644 (file)
@@ -5,7 +5,7 @@ U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
 
 U_DATA_STASH               .equ 0xFD00       ; BD00-BFFF
 
-NMOS_Z80                   .equ 1
+Z80_TYPE                   .equ 1
 
 PROG_BASE                  .equ 0xC000