; 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
.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
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!)
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:
; 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
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
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.