From: Alan Cox Date: Wed, 20 Feb 2019 00:29:12 +0000 (+0000) Subject: z80/rabbit: The big rearrange of U_DATA to _udata offsets X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=21457287ca5de90fbba180005950bee8515fd46a;p=FUZIX.git z80/rabbit: The big rearrange of U_DATA to _udata offsets The linker is good enough to work this out (except for the one z180.s case) so move to letting the linker do the work. This eliminates a configuration item for people to get wrong, and also will be needed to generate a relocatable Fuzix kernel. --- diff --git a/Kernel/cpu-z180/z180.s b/Kernel/cpu-z180/z180.s index f5707b25..9985b18c 100644 --- a/Kernel/cpu-z180/z180.s +++ b/Kernel/cpu-z180/z180.s @@ -15,6 +15,7 @@ .globl _irqvector .globl _need_resched .globl _int_disabled + .globl _udata ; imported symbols .globl _ramsize @@ -49,7 +50,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; Initialisation code @@ -262,10 +263,18 @@ _copy_and_map_process: ; CPU stalled until DMA completes ; Copy common memory code from kernel bank (from end of U_DATA to end of memory) - ld de, #(0x10000 - U_DATA__TOTALSIZE - U_DATA) ; copy to end of memory + ; ld de, #(0x10000 - U_DATA__TOTALSIZE - _udata) ; copy to end of memory + ; Only the linker isn't smart enough.... + or a + push hl + ld hl,#0 + ld de,#_udata + U_DATA__TOTALSIZE + sbc hl,de + ex de,hl + pop hl out0 (DMA_BCR0H), d ; set byte count out0 (DMA_BCR0L), e - ld de, #(U_DATA+U_DATA__TOTALSIZE) + ld de, #(_udata + U_DATA__TOTALSIZE) ld a, #((OS_BANK + FIRST_RAM_BANK) >> 4) ; source bank -- kernel is always 64K aligned out0 (DMA_SAR0B), a out0 (DMA_SAR0H), d ; source is kernel, always 64K aligned @@ -307,7 +316,7 @@ bankok2:out0 (DMA_DAR0B), a out0 (DMA_SAR0L), a out0 (DMA_SAR0H), l out0 (DMA_SAR0B), h - ld de, #(U_DATA + U_DATA__TOTALSIZE - 0x100) ; byte count + ld de, #(_udata + U_DATA__TOTALSIZE - 0x100) ; byte count out0 (DMA_BCR0H), d ; set byte count out0 (DMA_BCR0L), e ; call dump_dma_state @@ -372,7 +381,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hooray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -692,7 +701,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; no need to stash udata on this platform since common memory is dedicated ; to each process. @@ -734,13 +743,13 @@ _switchin: out0 (MMU_CBR), a ; sanity check: u_data->u_ptab matches what we wanted? - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING @@ -757,14 +766,14 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -798,7 +807,7 @@ map_process_always: ; map the process into the low 60K based on current common m ld a, #'=' call outchar .endif - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) out0 (MMU_BBR), a .if DEBUGBANK call outcharhex diff --git a/Kernel/dev/devfd_hw.s b/Kernel/dev/devfd_hw.s index d5bc41e2..166f11e8 100644 --- a/Kernel/dev/devfd_hw.s +++ b/Kernel/dev/devfd_hw.s @@ -31,7 +31,7 @@ CPU_Z180 .equ Z80_TYPE-2 .globl _fd_tick .include "../platform/kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;------------------------------------------------------------------------------ diff --git a/Kernel/dev/devrd_hw.s b/Kernel/dev/devrd_hw.s index d54f940f..3804a118 100644 --- a/Kernel/dev/devrd_hw.s +++ b/Kernel/dev/devrd_hw.s @@ -8,7 +8,7 @@ .globl _rd_read .globl _rd_write - .include "../kernel.def" + .include "../kernel-z80.def" .include "kernel.def" .area _CODE diff --git a/Kernel/dev/devrd_z180_hw.s b/Kernel/dev/devrd_z180_hw.s index fb9b8501..515e34ca 100644 --- a/Kernel/dev/devrd_z180_hw.s +++ b/Kernel/dev/devrd_z180_hw.s @@ -14,7 +14,7 @@ .globl _devmem_write .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../cpu-z180/z180.def" .area _CODE @@ -30,13 +30,13 @@ _devmem_read: _devmem_go: ld (_rd_dst_userspace), a ; 1 = userspace ; load the other parameters - ld hl, (U_DATA__U_BASE) + ld hl, (_udata + U_DATA__U_BASE) ld (_rd_dst_address), hl - ld hl, (U_DATA__U_COUNT) + ld hl, (_udata + U_DATA__U_COUNT) ld (_rd_cpy_count), hl - ld hl, (U_DATA__U_OFFSET) + ld hl, (_udata + U_DATA__U_OFFSET) ld (_rd_src_address), hl - ld hl, (U_DATA__U_OFFSET+2) + ld hl, (_udata + U_DATA__U_OFFSET+2) ld (_rd_src_address+2), hl ; FALL THROUGH INTO _rd_platform_copy @@ -63,7 +63,7 @@ _rd_platform_copy: ld hl, #(OS_BANK + FIRST_RAM_BANK) << 4 jr rd_done_translate rd_translate_userspace: - ld hl,(U_DATA__U_PAGE) ; load page number + ld hl,(_udata + U_DATA__U_PAGE) ; load page number add hl, hl ; shift left 4 bits add hl, hl add hl, hl diff --git a/Kernel/dev/ds1302_rbc.s b/Kernel/dev/ds1302_rbc.s index 87a95bcd..df0e41b3 100644 --- a/Kernel/dev/ds1302_rbc.s +++ b/Kernel/dev/ds1302_rbc.s @@ -15,7 +15,7 @@ .globl _ds1302_get_pin_data .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; DS1302 interface diff --git a/Kernel/dev/ds1302_rc2014.s b/Kernel/dev/ds1302_rc2014.s index ab215756..bd829085 100644 --- a/Kernel/dev/ds1302_rc2014.s +++ b/Kernel/dev/ds1302_rc2014.s @@ -13,7 +13,7 @@ .globl _ds1302_get_pin_data .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; DS1302 interface diff --git a/Kernel/dev/rbcfd9266_hw.s b/Kernel/dev/rbcfd9266_hw.s index 35591a51..3bde05c6 100644 --- a/Kernel/dev/rbcfd9266_hw.s +++ b/Kernel/dev/rbcfd9266_hw.s @@ -32,7 +32,7 @@ CPU_Z180 .equ Z80_TYPE-2 .globl _fd_tick .include "../platform/kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;------------------------------------------------------------------------------ diff --git a/Kernel/dev/z80softspi.s b/Kernel/dev/z80softspi.s index 1986424f..47b8c3da 100644 --- a/Kernel/dev/z80softspi.s +++ b/Kernel/dev/z80softspi.s @@ -13,7 +13,7 @@ .globl _sd_spi_rx_sector .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl _spi_port ; Port to use diff --git a/Kernel/dev/zx/tricks.s b/Kernel/dev/zx/tricks.s index 07d70969..47a1ed86 100644 --- a/Kernel/dev/zx/tricks.s +++ b/Kernel/dev/zx/tricks.s @@ -32,7 +32,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -54,7 +54,7 @@ _platform_switchout: ld a,(current_map) push af - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; ; We are now running on the sleeping process stack. The switchin @@ -63,14 +63,14 @@ _platform_switchout: ; ; Stash the uarea back into process memory - ld hl, (U_DATA__U_PAGE) + ld hl, (_udata + U_DATA__U_PAGE) ld a, l ld bc, #0x7ffd or #BANK_BITS out (c), a ; This includes the stacks, so be careful on restore - ld hl, #U_DATA + ld hl, #_udata ld de, #U_DATA_STASH ld bc, #U_DATA__TOTALSIZE ldir @@ -149,7 +149,7 @@ _switchin: ld (_inswap),a ld a, (hl) ; We should now have a page assigned not_swapped: - ld hl,(U_DATA__U_PTAB) + ld hl,(_udata + U_DATA__U_PTAB) or a sbc hl,de ; Turn this on once debugged @@ -170,7 +170,7 @@ not_swapped: ; exx ld hl, #U_DATA_STASH - ld de, #U_DATA + ld de, #_udata ld bc, #U_DATA__TOTALSIZE ldir exx @@ -226,27 +226,27 @@ flip1: nofliplow: ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE == HL jr nz, switchinfail ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix any moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ; We can now use the stack again @@ -261,7 +261,7 @@ nofliplow: call switch_bank ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -333,7 +333,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -349,7 +349,7 @@ _dofork: add hl, de ; load p_page ld c, (hl) - ld hl, (U_DATA__U_PAGE) + ld hl, (_udata + U_DATA__U_PAGE) ld a, l ; @@ -372,7 +372,7 @@ _dofork: ; Copy done - ld a, (U_DATA__U_PAGE) ; parent memory + ld a, (_udata + U_DATA__U_PAGE) ; parent memory or #BANK_BITS ; get the right ROMs ld bc, #0x7ffd out (c), a ; Switch context to parent in 0xC000+ @@ -380,7 +380,7 @@ _dofork: ; We are going to copy the uarea into the parents uarea stash ; we must not touch the parent uarea after this point, any ; changes only affect the child - ld hl, #U_DATA ; copy the udata from common into the + ld hl, #_udata ; copy the udata from common into the ld de, #U_DATA_STASH ; target process ld bc, #U_DATA__TOTALSIZE ldir diff --git a/Kernel/kernel-rabbit.def b/Kernel/kernel-rabbit.def index 2eb9ce82..4c82fb9d 100644 --- a/Kernel/kernel-rabbit.def +++ b/Kernel/kernel-rabbit.def @@ -111,28 +111,28 @@ GCPU_R2000 .equ 0x01 ; Keep these in sync with struct u_data!! -U_DATA__U_PTAB .equ (U_DATA+0) ; struct p_tab* -U_DATA__U_PAGE .equ (U_DATA+2) ; uint16_t -U_DATA__U_PAGE2 .equ (U_DATA+4) ; uint16_t -U_DATA__U_INSYS .equ (U_DATA+6) ; bool -U_DATA__U_CALLNO .equ (U_DATA+7) ; uint8_t -U_DATA__U_SYSCALL_SP .equ (U_DATA+8) ; void * -U_DATA__U_RETVAL .equ (U_DATA+10) ; int16_t -U_DATA__U_ERROR .equ (U_DATA+12) ; int16_t -U_DATA__U_SP .equ (U_DATA+14) ; void * -U_DATA__U_ININTERRUPT .equ (U_DATA+16) ; bool -U_DATA__U_CURSIG .equ (U_DATA+17) ; int8_t -U_DATA__U_ARGN .equ (U_DATA+18) ; uint16_t -U_DATA__U_ARGN1 .equ (U_DATA+20) ; uint16_t -U_DATA__U_ARGN2 .equ (U_DATA+22) ; uint16_t -U_DATA__U_ARGN3 .equ (U_DATA+24) ; uint16_t -U_DATA__U_ISP .equ (U_DATA+26) ; void * (initial stack pointer when _exec()ing) -U_DATA__U_TOP .equ (U_DATA+28) ; uint16_t -U_DATA__U_BREAK .equ (U_DATA+30) ; uint16_t -U_DATA__U_SIGVEC .equ (U_DATA+32) ; table of function pointers (void *) -U_DATA__U_BASE .equ (U_DATA+96) ; uint8_t * -U_DATA__U_COUNT .equ (U_DATA+98) ; uint16_t -U_DATA__U_OFFSET .equ (U_DATA+100) ; uint32_t +U_DATA__U_PTAB .equ 0 ; struct p_tab* +U_DATA__U_PAGE .equ 2 ; uint16_t +U_DATA__U_PAGE2 .equ 4 ; uint16_t +U_DATA__U_INSYS .equ 6 ; bool +U_DATA__U_CALLNO .equ 7 ; uint8_t +U_DATA__U_SYSCALL_SP .equ 8 ; void * +U_DATA__U_RETVAL .equ 10 ; int16_t +U_DATA__U_ERROR .equ 12 ; int16_t +U_DATA__U_SP .equ 14 ; void * +U_DATA__U_ININTERRUPT .equ 16 ; bool +U_DATA__U_CURSIG .equ 17 ; int8_t +U_DATA__U_ARGN .equ 18 ; uint16_t +U_DATA__U_ARGN1 .equ 20 ; uint16_t +U_DATA__U_ARGN2 .equ 22 ; uint16_t +U_DATA__U_ARGN3 .equ 24 ; uint16_t +U_DATA__U_ISP .equ 26 ; void * (initial stack pointer when _exec()ing) +U_DATA__U_TOP .equ 28 ; uint16_t +U_DATA__U_BREAK .equ 30 ; uint16_t +U_DATA__U_SIGVEC .equ 32 ; table of function pointers (void *) +U_DATA__U_BASE .equ 96 ; uint8_t * +U_DATA__U_COUNT .equ 98 ; uint16_t +U_DATA__U_OFFSET .equ 100 ; uint32_t ; Keep these in sync with struct p_tab!! P_TAB__P_STATUS_OFFSET .equ 0 diff --git a/Kernel/kernel-z80.def b/Kernel/kernel-z80.def new file mode 100644 index 00000000..a232b039 --- /dev/null +++ b/Kernel/kernel-z80.def @@ -0,0 +1,43 @@ + + .globl _udata + +; Keep these in sync with struct u_data!! +U_DATA__U_PTAB .equ 0 ; struct p_tab* +U_DATA__U_PAGE .equ 2 ; uint16_t +U_DATA__U_PAGE2 .equ 4 ; uint16_t +U_DATA__U_INSYS .equ 6 ; bool +U_DATA__U_CALLNO .equ 7 ; uint8_t +U_DATA__U_SYSCALL_SP .equ 8 ; void * +U_DATA__U_RETVAL .equ 10 ; int16_t +U_DATA__U_ERROR .equ 12 ; int16_t +U_DATA__U_SP .equ 14 ; void * +U_DATA__U_ININTERRUPT .equ 16 ; bool +U_DATA__U_CURSIG .equ 17 ; int8_t +U_DATA__U_ARGN .equ 18 ; uint16_t +U_DATA__U_ARGN1 .equ 20 ; uint16_t +U_DATA__U_ARGN2 .equ 22 ; uint16_t +U_DATA__U_ARGN3 .equ 24 ; uint16_t +U_DATA__U_ISP .equ 26 ; void * (initial stack pointer when _exec()ing) +U_DATA__U_TOP .equ 28 ; uint16_t +U_DATA__U_BREAK .equ 30 ; uint16_t +U_DATA__U_SIGVEC .equ 32 ; table of function pointers (void *) +U_DATA__U_BASE .equ 96 ; uint8_t * +U_DATA__U_COUNT .equ 98 ; uint16_t +U_DATA__U_OFFSET .equ 100 ; uint32_t + +; Keep these in sync with struct p_tab!! +P_TAB__P_STATUS_OFFSET .equ 0 +P_TAB__P_TTY_OFFSET .equ 1 +P_TAB__P_PID_OFFSET .equ 2 +P_TAB__P_PAGE_OFFSET .equ 14 +P_TAB__P_PAGE2_OFFSET .equ 16 + +P_RUNNING .equ 1 ; value from include/kernel.h +P_READY .equ 2 ; value from include/kernel.h + +OS_BANK .equ 0 ; value from include/kernel.h + +EAGAIN .equ 11 ; value from include/kernel.h + +; Keep in sync with struct blkbuf +BUFSIZE .equ 520 diff --git a/Kernel/lib/z80bank16.s b/Kernel/lib/z80bank16.s index fd0cde14..91f9ca6b 100644 --- a/Kernel/lib/z80bank16.s +++ b/Kernel/lib/z80bank16.s @@ -59,11 +59,11 @@ _platform_switchout: ld hl, #0 ; return code set here is ignored, but _switchin can ; return from either _switchout OR _dofork, so they must both write - ; U_DATA__U_SP with the following on the stack: + ; _udata + U_DATA__U_SP with the following on the stack: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -95,7 +95,7 @@ _switchin: ; ------- No stack ------- ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail @@ -111,7 +111,7 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ---- New task stack ---- @@ -120,7 +120,7 @@ _switchin: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -170,7 +170,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. diff --git a/Kernel/lib/z80fixedbank-banked.s b/Kernel/lib/z80fixedbank-banked.s index f859831f..44fa1b01 100644 --- a/Kernel/lib/z80fixedbank-banked.s +++ b/Kernel/lib/z80fixedbank-banked.s @@ -37,8 +37,8 @@ ; imported debug symbols .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -58,12 +58,12 @@ _platform_switchout: push iy call map_save_kmap ; save kernel bank mapping push af ; on stack in AF - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; Stash the uarea back into process memory call map_process_save - ld hl, #U_DATA + ld hl, #_udata ld de, #U_DATA_STASH ld bc, #U_DATA__TOTALSIZE ldir @@ -148,7 +148,7 @@ _switchin: .endif ld a, (hl) not_swapped: - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) or a sbc hl, de jr z, skip_copyback ; Tormod's optimisation: don't copy the @@ -162,7 +162,7 @@ not_swapped: exx ; thank goodness for exx 8) ld hl, #U_DATA_STASH - ld de, #U_DATA + ld de, #_udata ld bc, #U_DATA__TOTALSIZE ldir exx @@ -170,26 +170,26 @@ not_swapped: ; Restore the stack in case we are not swap based so we don't ; scribble the bank stack - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) call map_kernel_restore ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==HL jr nz, switchinfail skip_copyback: ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix the moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl @@ -205,7 +205,7 @@ skip_copyback: call map_restore_kmap ; enable interrupts, if we didn't pre-empt in an ISR - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; Not an ISR, leave interrupts off @@ -265,7 +265,7 @@ _dofork: ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -278,7 +278,7 @@ _dofork: ; load p_page ld c, (hl) ; load existing page ptr - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call bankfork ; do the bank to bank copy @@ -289,7 +289,7 @@ _dofork: ; We are going to copy the uarea into the parents uarea stash ; we must not touch the parent uarea after this point, any ; changes only affect the child - ld hl, #U_DATA ; copy the udata from common into the + ld hl, #_udata ; copy the udata from common into the ld de, #U_DATA_STASH ; target process ld bc, #U_DATA__TOTALSIZE ldir diff --git a/Kernel/lib/z80fixedbank-core.s b/Kernel/lib/z80fixedbank-core.s index 90483dbb..88a26bd5 100644 --- a/Kernel/lib/z80fixedbank-core.s +++ b/Kernel/lib/z80fixedbank-core.s @@ -36,8 +36,8 @@ ; imported debug symbols .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -55,11 +55,11 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; Stash the uarea back into process memory call map_process_always - ld hl, #U_DATA + ld hl, #_udata ld de, #U_DATA_STASH ld bc, #U_DATA__TOTALSIZE ldir @@ -134,7 +134,7 @@ _switchin: .endif ld a, (hl) not_swapped: - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) or a sbc hl, de jr z, skip_copyback ; Tormod's optimisation: don't copy the @@ -148,46 +148,46 @@ not_swapped: exx ; thank goodness for exx 8) ld hl, #U_DATA_STASH - ld de, #U_DATA + ld de, #_udata ld bc, #U_DATA__TOTALSIZE ldir exx ; In the non swap case we must set so before we use the stack ; otherwise we risk corrupting the restored stack frame - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) call map_kernel ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==HL jr nz, switchinfail skip_copyback: ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix the moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if we didn't pre-empt in an ISR - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; Not an ISR, leave interrupts off @@ -242,7 +242,7 @@ _dofork: ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -255,7 +255,7 @@ _dofork: ; load p_page ld c, (hl) ; load existing page ptr - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call bankfork ; do the bank to bank copy @@ -266,7 +266,7 @@ _dofork: ; We are going to copy the uarea into the parents uarea stash ; we must not touch the parent uarea after this point, any ; changes only affect the child - ld hl, #U_DATA ; copy the udata from common into the + ld hl, #_udata ; copy the udata from common into the ld de, #U_DATA_STASH ; target process ld bc, #U_DATA__TOTALSIZE ldir diff --git a/Kernel/lib/z80single.s b/Kernel/lib/z80single.s index 9afb89be..754adac9 100644 --- a/Kernel/lib/z80single.s +++ b/Kernel/lib/z80single.s @@ -51,7 +51,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -98,7 +98,7 @@ _switchin: ; practice that means it exited. We don't need to write ; it back out as it's dead. ; - ld ix,(U_DATA__U_PTAB) + ld ix,(_udata + U_DATA__U_PTAB) ld a,P_TAB__P_PAGE_OFFSET(ix) or a @@ -108,7 +108,7 @@ _switchin: ; push de ; save process ; We will always swap out the current process - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) push hl call _swapout pop hl @@ -122,34 +122,34 @@ not_resident: not_swapped: ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==HL jr nz, switchinfail ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix the moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ; put th einterrupt status flag back correctly ld (_int_disabled),a or a @@ -193,7 +193,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. diff --git a/Kernel/lowlevel-r2k.s b/Kernel/lowlevel-r2k.s index efc40303..d5852350 100644 --- a/Kernel/lowlevel-r2k.s +++ b/Kernel/lowlevel-r2k.s @@ -64,7 +64,7 @@ ; deliver_signals: ; Pending signal - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a,a ret z @@ -75,7 +75,7 @@ deliver_signals_2: ; Handler to use add hl, hl - ld de, #U_DATA__U_SIGVEC + ld de, #_udata + U_DATA__U_SIGVEC add hl, de ld e, (hl) inc hl @@ -83,7 +83,7 @@ deliver_signals_2: ; Indicate processed xor a,a - ld (U_DATA__U_CURSIG), a + ld (_udata + U_DATA__U_CURSIG), a ; Semantics for now: signal delivery clears handler ld (hl), a @@ -111,12 +111,12 @@ signal_return: ; element of this processing, as we don't want to ; set INSYS flags here. ; - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ld sp, #kstack_top call map_kernel call _chksigs call map_process_always - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) jr deliver_signals ; @@ -148,12 +148,12 @@ unix_syscall_entry: ;; call mmu_kernel ; must preserve HL ; save system call number ld a, (hl) - ld (U_DATA__U_CALLNO), a + ld (_udata + U_DATA__U_CALLNO), a ; advance to syscall arguments inc hl inc hl ; copy arguments to common memory - ld de, #U_DATA__U_ARGN + ld de, #_udata + U_DATA__U_ARGN ldi ldi ldi @@ -164,10 +164,10 @@ unix_syscall_entry: ldi ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; save process stack pointer - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ; switch to kernel stack ld sp, #kstack_top @@ -194,15 +194,15 @@ unix_syscall_entry: call map_process_always xor a,a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; Back to the user stack - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) - ld hl, (U_DATA__U_ERROR) - ld de, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_ERROR) + ld de, (_udata + U_DATA__U_RETVAL) - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a,a ; Fast path the normal case @@ -243,9 +243,9 @@ via_signal: ; Get off the kernel syscall stack before we start signal ; handling. Our signal handlers may themselves elect to make system ; calls. This means we must also save the error/return code - ld hl, (U_DATA__U_ERROR) + ld hl, (_udata + U_DATA__U_ERROR) push hl - ld hl, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_RETVAL) push hl ; Signal processing. This may longjmp back into userland @@ -268,12 +268,12 @@ _doexec: pop bc ; return address pop de ; start address - ld hl, (U_DATA__U_ISP) + ld hl, (_udata + U_DATA__U_ISP) ld sp, hl ; Initialize user stack, below main() parameters and the environment ; u_data.u_insys = false xor a,a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ex de, hl @@ -288,7 +288,7 @@ _doexec: ; null_handler: ; kernel jump to NULL is bad - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a,a jp nz, trap_illegal ld a, (_inint) @@ -296,7 +296,7 @@ null_handler: ; user is merely not good ld hl, #7 push hl - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ld l,P_TAB__P_PID_OFFSET(ix) ld h,P_TAB__P_PID_OFFSET+1(ix) push hl @@ -365,7 +365,7 @@ no_null_ptr: ld a, #1 ld (_inint), a ; So we know that this task should resume with IRQs off - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a call _platform_interrupt @@ -386,11 +386,11 @@ no_null_ptr: intout: xor a,a - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a intret: ipset1 - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a,a jr nz, interrupt_pop @@ -427,7 +427,7 @@ null_pointer_trap: ld hl, #11 ; SIGSEGV trap_signal: push hl - ld hl, (U_DATA__U_PTAB); + ld hl, (_udata + U_DATA__U_PTAB); push hl call _ssig pop hl @@ -450,7 +450,7 @@ preemption: call map_restore ld hl, (istack_switched_sp) - ld (U_DATA__U_SYSCALL_SP), hl + ld (_udata + U_DATA__U_SYSCALL_SP), hl ld sp, #kstack_top ; We don't pre-empt in a syscall ; so this is fine @@ -470,7 +470,7 @@ preemption: ; pre-empted when switchout re-enables interrupts. ; ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; ; Check for signals ; @@ -478,7 +478,7 @@ preemption: ; ; Process status is offset 0 ; - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) ld a,(hl) cp a,#P_RUNNING jr nz, not_running @@ -489,8 +489,8 @@ not_running: ; We are no longer in an interrupt or a syscall ; xor a,a - ld (U_DATA__U_ININTERRUPT), a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_INSYS), a ; ; We have been rescheduled, remap ourself and go back to user ; space via signal handling @@ -498,8 +498,8 @@ not_running: call map_process_always ; Get our user mapping back ; We were pre-empted but have now been rescheduled ; User stack - ld sp, (U_DATA__U_SYSCALL_SP) - ld a, (U_DATA__U_CURSIG) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) + ld a, (_udata + U_DATA__U_CURSIG) or a,a jr z, nosigs call deliver_signals_2 diff --git a/Kernel/lowlevel-z80-banked.s b/Kernel/lowlevel-z80-banked.s index d7b5a7f2..bec1ae67 100644 --- a/Kernel/lowlevel-z80-banked.s +++ b/Kernel/lowlevel-z80-banked.s @@ -59,9 +59,10 @@ .globl istack_switched_sp .globl istack_top .globl _ssig + .globl _udata .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; these make the code below more readable. sdas allows us only to ; test if an expression is zero or non-zero. @@ -81,7 +82,7 @@ CPU_Z180 .equ Z80_TYPE-2 ; deliver_signals: ; Pending signal - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a ret z @@ -92,7 +93,7 @@ deliver_signals_2: ; Handler to use add hl, hl - ld de, #U_DATA__U_SIGVEC + ld de, #_udata + U_DATA__U_SIGVEC add hl, de ld e, (hl) inc hl @@ -100,7 +101,7 @@ deliver_signals_2: ; Indicate processed xor a - ld (U_DATA__U_CURSIG), a + ld (_udata + U_DATA__U_CURSIG), a ; and we will handle the signal with interrupts on so clear the ; flag ld (_int_disabled),a @@ -129,7 +130,7 @@ signal_return: ; element of this processing, as we don't want to ; set INSYS flags here. ; - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ld sp, #kstack_top ld a,#1 ld (_int_disabled),a @@ -138,7 +139,7 @@ signal_return: call _chksigs pop af call map_process_always - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) jr deliver_signals @@ -167,20 +168,20 @@ unix_syscall_entry: add hl, sp ; save system call number ld a, (hl) - ld (U_DATA__U_CALLNO), a + ld (_udata + U_DATA__U_CALLNO), a ; advance to syscall arguments inc hl inc hl ; copy arguments to common memory ld bc, #8 ; four 16-bit values - ld de, #U_DATA__U_ARGN + ld de, #_udata + U_DATA__U_ARGN ldir ; copy ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; save process stack pointer - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ; switch to kernel stack ld sp, #kstack_top @@ -209,15 +210,15 @@ unix_syscall_entry: call map_process_always xor a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; Back to the user stack - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) - ld hl, (U_DATA__U_ERROR) - ld de, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_ERROR) + ld de, (_udata + U_DATA__U_RETVAL) - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a ; Fast path the normal case @@ -263,9 +264,9 @@ via_signal: ; Get off the kernel syscall stack before we start signal ; handling. Our signal handlers may themselves elect to make system ; calls. This means we must also save the error/return code - ld hl, (U_DATA__U_ERROR) + ld hl, (_udata + U_DATA__U_ERROR) push hl - ld hl, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_RETVAL) push hl ; Signal processing. This may longjmp back into userland @@ -288,12 +289,12 @@ _doexec: pop af ; bank number pop de ; start address - ld hl, (U_DATA__U_ISP) + ld hl, (_udata + U_DATA__U_ISP) ld sp, hl ; Initialize user stack, below main() parameters and the environment ; u_data.u_insys = false xor a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ex de, hl @@ -309,13 +310,13 @@ _doexec: ; null_handler: ; kernel jump to NULL is bad - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jp nz, trap_illegal ; user is merely not good ld hl, #7 push hl - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ld l,P_TAB__P_PID_OFFSET(ix) ld h,P_TAB__P_PID_OFFSET+1(ix) push hl @@ -410,7 +411,7 @@ interrupt_handler: ld a, #1 ld (_inint), a ; So we know that this task should resume with IRQs off - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a ; Load the interrupt flag properly. It got an implicit di from ; the IRQ being taken ld (_int_disabled),a @@ -436,7 +437,7 @@ interrupt_handler: intout: xor a - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a ld hl, #intret push hl @@ -446,7 +447,7 @@ intout: ; have DI set intret: di - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, interrupt_pop @@ -485,7 +486,7 @@ null_pointer_trap: ld hl, #11 ; SIGSEGV trap_signal: push hl - ld hl, (U_DATA__U_PTAB); + ld hl, (_udata + U_DATA__U_PTAB); push hl push af call _ssig @@ -509,7 +510,7 @@ preemption: call map_restore ld hl, (istack_switched_sp) - ld (U_DATA__U_SYSCALL_SP), hl + ld (_udata + U_DATA__U_SYSCALL_SP), hl ld sp, #kstack_top ; We don't pre-empt in a syscall ; so this is fine @@ -536,7 +537,7 @@ intret2:di ; pre-empted when switchout re-enables interrupts. ; ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; ; Check for signals ; @@ -547,7 +548,7 @@ intret2:di ; ; Process status is offset 0 ; - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) ld a, #P_RUNNING cp (hl) jr nz, not_running @@ -558,8 +559,8 @@ not_running: ; We are no longer in an interrupt or a syscall ; xor a - ld (U_DATA__U_ININTERRUPT), a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_INSYS), a ; ; We have been rescheduled, remap ourself and go back to user ; space via signal handling @@ -568,8 +569,8 @@ not_running: ; We were pre-empted but have now been rescheduled ; User stack - ld sp, (U_DATA__U_SYSCALL_SP) - ld a, (U_DATA__U_CURSIG) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) + ld a, (_udata + U_DATA__U_CURSIG) or a call nz, deliver_signals_2 ; diff --git a/Kernel/lowlevel-z80-thunked.s b/Kernel/lowlevel-z80-thunked.s index bd464885..e658020a 100644 --- a/Kernel/lowlevel-z80-thunked.s +++ b/Kernel/lowlevel-z80-thunked.s @@ -58,9 +58,10 @@ .globl istack_switched_sp .globl istack_top .globl _ssig + .globl _udata .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; these make the code below more readable. sdas allows us only to ; test if an expression is zero or non-zero. @@ -79,14 +80,14 @@ _doexec: di call map_user_low xor a - ld (U_DATA__U_INSYS),a + ld (_udata + U_DATA__U_INSYS),a pop bc pop de ; start address - ld hl,(U_DATA__U_ISP) + ld hl,(_udata + U_DATA__U_ISP) ld sp,hl ex de,hl ld de,#PROGLOAD - ld a,(U_DATA__U_PAGE+HIGHPAGE) ; pass high page to trampoline + ld a,(_udata + U_DATA__U_PAGE+HIGHPAGE) ; pass high page to trampoline jp _platform_doexec ; jump into the low memory stub ; @@ -111,11 +112,11 @@ _doexec: ; unix_syscall_entry: ; Start by saving the arguments. That frees up all our registers - ld (U_DATA__U_CALLNO),a - ld (U_DATA__U_ARGN),bc - ld (U_DATA__U_ARGN1),de - ld (U_DATA__U_ARGN2),ix - ld (U_DATA__U_ARGN3),hl + ld (_udata + U_DATA__U_CALLNO),a + ld (_udata + U_DATA__U_ARGN),bc + ld (_udata + U_DATA__U_ARGN1),de + ld (_udata + U_DATA__U_ARGN2),ix + ld (_udata + U_DATA__U_ARGN3),hl ; Stack the alternate registers exx push bc @@ -125,7 +126,7 @@ unix_syscall_entry: push af ; Tell the pre-emption code we are in kernel right now ld a,#1 - ld (U_DATA__U_INSYS),a + ld (_udata + U_DATA__U_INSYS),a ; Make the kernel appear call map_kernel_low ; Call into the kernel with interrupts on @@ -136,11 +137,11 @@ unix_syscall_entry: call map_user_low ; We are now not in kernel xor a - ld (U_DATA__U_INSYS),a + ld (_udata + U_DATA__U_INSYS),a ; Recover the return data - ld hl, (U_DATA__U_ERROR) - ld de, (U_DATA__U_RETVAL) - ld a, (U_DATA__U_CURSIG) + ld hl, (_udata + U_DATA__U_ERROR) + ld de, (_udata + U_DATA__U_RETVAL) + ld a, (_udata + U_DATA__U_CURSIG) or a ; Keep the hot path inline jr nz, signal_path @@ -158,17 +159,17 @@ syscall_return: exx ; Return page for caller (may not be the page we can in on if we ; swapped - ld a,(U_DATA__U_PAGE+HIGHPAGE) + ld a,(_udata + U_DATA__U_PAGE+HIGHPAGE) ret signal_path: ld h,a ; save signal number push hl ; Get the signal vector and zero it add a,a - ld hl,#U_DATA__U_SIGVEC + ld hl,#_udata + U_DATA__U_SIGVEC ld c,a xor a - ld (U_DATA__U_CURSIG),a + ld (_udata + U_DATA__U_CURSIG),a ld b,a add hl,bc ld c,(hl) @@ -204,7 +205,7 @@ interrupt_handler: call map_save_low ; save old and map kernel ld a,#1 ld (_inint),a - ld (U_DATA__U_ININTERRUPT),a + ld (_udata + U_DATA__U_ININTERRUPT),a ld (_int_disabled),a call _platform_interrupt xor a @@ -218,15 +219,15 @@ interrupt_handler: ; any interrupt controller intreti:di xor a - ld (U_DATA__U_ININTERRUPT),a + ld (_udata + U_DATA__U_ININTERRUPT),a ; Are we returning to kernel ? - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, interrupt_kernel intsig: call map_user_low - ld a,(U_DATA__U_CURSIG) + ld a,(_udata + U_DATA__U_CURSIG) or a jr nz, interrupt_sig ; Nothing special to do @@ -234,7 +235,7 @@ no_sig: xor a ld (_int_disabled),a ld e,a - ld a,(U_DATA__U_PAGE+HIGHPAGE) + ld a,(_udata + U_DATA__U_PAGE+HIGHPAGE) intret: ret @@ -254,8 +255,8 @@ interrupt_sig: ld (_int_disabled),a ld e,a ld c,a - ld (U_DATA__U_CURSIG),a - ld hl,#U_DATA__U_SIGVEC + ld (_udata + U_DATA__U_CURSIG),a + ld hl,#_udata + U_DATA__U_SIGVEC add hl,de add hl,de ld e,(hl) @@ -289,7 +290,7 @@ preemption: xor a ld (_need_resched),a ; we are doing it thank you ld hl,(istack_switched_sp) - ld (U_DATA__U_SYSCALL_SP), hl ; save the stack save + ld (_udata + U_DATA__U_SYSCALL_SP), hl ; save the stack save ld sp, #kstack_top ; free because we are not pre-empted ; during a system call push de ; return address onto our kstack @@ -301,9 +302,9 @@ intret2: di ; Fake being in a syscall ld a,#1 - ld (U_DATA__U_INSYS),a + ld (_udata + U_DATA__U_INSYS),a call _chksigs - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) ld a,#P_RUNNING cp (hl) jr nz, not_running @@ -316,13 +317,13 @@ not_running: call _platform_switchout ; Undo the fakery xor a - ld (U_DATA__U_ININTERRUPT),a - ld (U_DATA__U_INSYS),a + ld (_udata + U_DATA__U_ININTERRUPT),a + ld (_udata + U_DATA__U_INSYS),a ; The istack was lost but that is ok as we saved the return onto the ; kernel stack, so when we finally ret we end up in the right place ld sp,#kstack_top - 2 ; saved return address - ld hl,(U_DATA__U_SYSCALL_SP) + ld hl,(_udata + U_DATA__U_SYSCALL_SP) ld (istack_switched_sp),hl ; Now continue on the interrupt return path diff --git a/Kernel/lowlevel-z80.s b/Kernel/lowlevel-z80.s index 44c24849..a0052a67 100644 --- a/Kernel/lowlevel-z80.s +++ b/Kernel/lowlevel-z80.s @@ -59,9 +59,10 @@ .globl istack_switched_sp .globl istack_top .globl _ssig + .globl _udata .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; these make the code below more readable. sdas allows us only to ; test if an expression is zero or non-zero. @@ -80,7 +81,7 @@ CPU_Z180 .equ Z80_TYPE-2 ; deliver_signals: ; Pending signal - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a ret z @@ -91,7 +92,7 @@ deliver_signals_2: ; Handler to use add hl, hl - ld de, #U_DATA__U_SIGVEC + ld de, #_udata + U_DATA__U_SIGVEC add hl, de ld e, (hl) inc hl @@ -99,7 +100,7 @@ deliver_signals_2: ; Indicate processed xor a - ld (U_DATA__U_CURSIG), a + ld (_udata + U_DATA__U_CURSIG), a ; and we will handle the signal with interrupts on so clear the ; flag ld (_int_disabled),a @@ -134,7 +135,7 @@ signal_return: ; element of this processing, as we don't want to ; set INSYS flags here. ; - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ld sp, #kstack_top ; ; Ensure chksigs and friends see the right status @@ -144,7 +145,7 @@ signal_return: call map_kernel_di call _chksigs call map_process_always_di - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) jr deliver_signals @@ -179,20 +180,20 @@ unix_syscall_entry: .endif ; save system call number ld a, (hl) - ld (U_DATA__U_CALLNO), a + ld (_udata + U_DATA__U_CALLNO), a ; advance to syscall arguments inc hl inc hl ; copy arguments to common memory ld bc, #8 ; four 16-bit values - ld de, #U_DATA__U_ARGN + ld de, #_udata + U_DATA__U_ARGN ldir ; copy FIXME use LDI x 8 ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; save process stack pointer - ld (U_DATA__U_SYSCALL_SP), sp + ld (_udata + U_DATA__U_SYSCALL_SP), sp ; switch to kernel stack ld sp, #kstack_top @@ -219,15 +220,15 @@ unix_syscall_entry: call map_process_always_di xor a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; Back to the user stack - ld sp, (U_DATA__U_SYSCALL_SP) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) - ld hl, (U_DATA__U_ERROR) - ld de, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_ERROR) + ld de, (_udata + U_DATA__U_RETVAL) - ld a, (U_DATA__U_CURSIG) + ld a, (_udata + U_DATA__U_CURSIG) or a ; Fast path the normal case @@ -274,9 +275,9 @@ via_signal: ; Get off the kernel syscall stack before we start signal ; handling. Our signal handlers may themselves elect to make system ; calls. This means we must also save the error/return code - ld hl, (U_DATA__U_ERROR) + ld hl, (_udata + U_DATA__U_ERROR) push hl - ld hl, (U_DATA__U_RETVAL) + ld hl, (_udata + U_DATA__U_RETVAL) push hl ; Signal processing. This may longjmp back into userland @@ -299,12 +300,12 @@ _doexec: pop bc ; return address pop de ; start address - ld hl, (U_DATA__U_ISP) + ld hl, (_udata + U_DATA__U_ISP) ld sp, hl ; Initialize user stack, below main() parameters and the environment ; u_data.u_insys = false xor a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ex de, hl @@ -323,7 +324,7 @@ _doexec: ; null_handler: ; kernel jump to NULL is bad - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jp nz, trap_illegal ld a, (_inint) @@ -332,7 +333,7 @@ null_handler: ; user is merely not good ld hl, #7 push hl - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ld l,P_TAB__P_PID_OFFSET(ix) ld h,P_TAB__P_PID_OFFSET+1(ix) push hl @@ -434,7 +435,7 @@ mmu_irq_ret: ld a, #1 ld (_inint), a ; So we know that this task should resume with IRQs off - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a ; Load the interrupt flag properly. It got an implicit di from ; the IRQ being taken ld (_int_disabled),a @@ -458,7 +459,7 @@ mmu_irq_ret: intout: xor a - ld (U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_ININTERRUPT), a ld hl, #intret push hl @@ -468,7 +469,7 @@ intout: ; have DI set intret: di - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, interrupt_pop @@ -510,7 +511,7 @@ null_pointer_trap: ld hl, #11 ; SIGSEGV trap_signal: push hl - ld hl, (U_DATA__U_PTAB); + ld hl, (_udata + U_DATA__U_PTAB); push hl call _ssig pop hl @@ -533,7 +534,7 @@ preemption: call map_restore ld hl, (istack_switched_sp) - ld (U_DATA__U_SYSCALL_SP), hl + ld (_udata + U_DATA__U_SYSCALL_SP), hl ld sp, #kstack_top ; We don't pre-empt in a syscall ; so this is fine @@ -559,7 +560,7 @@ intret2:call map_kernel_di ; pre-empted when switchout re-enables interrupts. ; ld a, #1 - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_INSYS), a ; ; Check for signals ; @@ -567,7 +568,7 @@ intret2:call map_kernel_di ; ; Process status is offset 0 ; - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) ld a,#P_RUNNING cp (hl) jr nz, not_running @@ -578,8 +579,8 @@ not_running: ; We are no longer in an interrupt or a syscall ; xor a - ld (U_DATA__U_ININTERRUPT), a - ld (U_DATA__U_INSYS), a + ld (_udata + U_DATA__U_ININTERRUPT), a + ld (_udata + U_DATA__U_INSYS), a ; ; We have been rescheduled, remap ourself and go back to user ; space via signal handling @@ -589,8 +590,8 @@ not_running: ; We were pre-empted but have now been rescheduled ; User stack - ld sp, (U_DATA__U_SYSCALL_SP) - ld a, (U_DATA__U_CURSIG) + ld sp, (_udata + U_DATA__U_SYSCALL_SP) + ld a, (_udata + U_DATA__U_CURSIG) or a call nz, deliver_signals_2 ; diff --git a/Kernel/platform-amstradnc/fdc765.s b/Kernel/platform-amstradnc/fdc765.s index 60eeee6b..dc4da504 100644 --- a/Kernel/platform-amstradnc/fdc765.s +++ b/Kernel/platform-amstradnc/fdc765.s @@ -4,7 +4,7 @@ .module fdc765 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl map_process_always .globl map_kernel diff --git a/Kernel/platform-amstradnc/nc100.s b/Kernel/platform-amstradnc/nc100.s index 95bfd6b8..4f854fc0 100644 --- a/Kernel/platform-amstradnc/nc100.s +++ b/Kernel/platform-amstradnc/nc100.s @@ -62,7 +62,7 @@ .globl outstringhex .include "platform/kernel.def" - .include "../../kernel.def" ; Kernel + .include "../../kernel-z80.def" ; Kernel .include "nc100.def" ; ----------------------------------------------------------------------------- diff --git a/Kernel/platform-amstradnc/nc100/kernel.def b/Kernel/platform-amstradnc/nc100/kernel.def index 6bfefa3f..084d5ef2 100644 --- a/Kernel/platform-amstradnc/nc100/kernel.def +++ b/Kernel/platform-amstradnc/nc100/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x300 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @0xF000 Z80_TYPE .equ 0 diff --git a/Kernel/platform-amstradnc/nc200/kernel.def b/Kernel/platform-amstradnc/nc200/kernel.def index 6bfefa3f..084d5ef2 100644 --- a/Kernel/platform-amstradnc/nc200/kernel.def +++ b/Kernel/platform-amstradnc/nc200/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x300 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @0xF000 Z80_TYPE .equ 0 diff --git a/Kernel/platform-amstradnc/tricks.s b/Kernel/platform-amstradnc/tricks.s index 0d881124..6e22e9eb 100644 --- a/Kernel/platform-amstradnc/tricks.s +++ b/Kernel/platform-amstradnc/tricks.s @@ -1,7 +1,7 @@ .module tricks .include "platform/kernel.def" - .include "../../kernel.def" ; Kernel + .include "../../kernel-z80.def" ; Kernel TOP_PORT .equ 0x13 diff --git a/Kernel/platform-cromemco/cromemco.s b/Kernel/platform-cromemco/cromemco.s index 9b09dd93..c1fc1959 100644 --- a/Kernel/platform-cromemco/cromemco.s +++ b/Kernel/platform-cromemco/cromemco.s @@ -44,6 +44,7 @@ .globl _panic .globl _need_resched .globl _ssig + .globl _udata .globl _set_irq .globl _spurious @@ -57,7 +58,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0xF200 upwards) @@ -663,7 +664,7 @@ rst10: nop rst18: ; Activate the user bank (which also holds these bytes) - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ei ; and leap into user space @@ -719,7 +720,7 @@ my_nmi_handler: ; Should be at 0x66 ; This needs some properly optimized versions! ; ldir_to_user: - ld de,(U_DATA__U_PAGE) ; will load with 0 e with page + ld de,(_udata + U_DATA__U_PAGE) ; will load with 0 e with page inc d ; Kernel is in #1 ldir_far: push bc @@ -743,7 +744,7 @@ far_ldir_1: out (0x40),a ; Select kernel ret ldir_from_user: - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) ld e,#1 ld d,a jr ldir_far @@ -854,14 +855,14 @@ syscall_high: out (0x40),a ex af,af' ; Stack now invalid - ld (U_DATA__U_SYSCALL_SP),sp + ld (_udata + U_DATA__U_SYSCALL_SP),sp ld sp,#kstack_top call unix_syscall_entry ; FIXME check di rules ; stack now invalid. Grab the new sp before we unbank the ; memory holding it - ld sp,(U_DATA__U_SYSCALL_SP) - ld a, (U_DATA__U_PAGE) ; back to the user page + ld sp,(_udata + U_DATA__U_SYSCALL_SP) + ld a, (_udata + U_DATA__U_PAGE) ; back to the user page out (0x40),a xor a cp h diff --git a/Kernel/platform-cromemco/crt0.s b/Kernel/platform-cromemco/crt0.s index cbfe051a..459260a7 100644 --- a/Kernel/platform-cromemco/crt0.s +++ b/Kernel/platform-cromemco/crt0.s @@ -42,8 +42,8 @@ ; For the boot vector .globl init - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _BOOT diff --git a/Kernel/platform-cromemco/kernel.def b/Kernel/platform-cromemco/kernel.def index 7b32b414..ce99ec06 100644 --- a/Kernel/platform-cromemco/kernel.def +++ b/Kernel/platform-cromemco/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF200 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @0xF200 U_DATA_STASH .equ 0xF000 ; F000-F200 diff --git a/Kernel/platform-cromemco/tricks.s b/Kernel/platform-cromemco/tricks.s index 70bbe01f..7828f54c 100644 --- a/Kernel/platform-cromemco/tricks.s +++ b/Kernel/platform-cromemco/tricks.s @@ -1,6 +1,6 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; ; We can't quite use the standard helpers as we have rather weird @@ -48,10 +48,10 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; Stash the uarea back into process memory - ld hl, #U_DATA + ld hl, #_udata ld ix, #U_DATA_STASH ld bc, #U_DATA__TOTALSIZE ; Slow - must be a more elegant way to tackle this ! FIXME @@ -122,7 +122,7 @@ not_swapped: ; We need the swap stack anyway or we run out of registers ld sp, #_swapstack - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) or a sbc hl, de jr z, skip_copyback ; Tormod's optimisation: don't copy the @@ -141,14 +141,14 @@ not_swapped: ; or #0x80 ; out (0x40),a ; ld hl, #U_DATA_STASH -; ld de, #U_DATA +; ld de, #_udata ; ld bc, #U_DATA__TOTALSIZE ; ldir ; ld a,#1 ; back to kernel ; out (0x40),a - ld hl,# U_DATA_STASH - ld ix, #U_DATA + ld hl, # U_DATA_STASH + ld ix, #_udata ld bc, #U_DATA__TOTALSIZE ld d,a ld e,#0x01 @@ -158,38 +158,38 @@ not_swapped: ; In the non swap case we must set sp before we use the stack ; otherwise we risk corrupting the restored stack frame - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==HL jr nz, switchinfail skip_copyback: ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix the moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if we didn't pre-empt in an ISR - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; Not an ISR, leave interrupts off @@ -244,7 +244,7 @@ _dofork: ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -257,7 +257,7 @@ _dofork: ; load p_page ld c, (hl) ; load existing page ptr - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) push bc call bankfork ; do the bank to bank copy @@ -268,7 +268,7 @@ _dofork: ; We are going to copy the uarea into the parents uarea stash ; we must not touch the parent uarea after this point, any ; changes only affect the child - ld hl, #U_DATA ; copy the udata from common into the + ld hl, #_udata ; copy the udata from common into the ld ix, #U_DATA_STASH ; target process ld bc, #U_DATA__TOTALSIZE diff --git a/Kernel/platform-cromemco/usermem.s b/Kernel/platform-cromemco/usermem.s index 1682e925..12b821df 100644 --- a/Kernel/platform-cromemco/usermem.s +++ b/Kernel/platform-cromemco/usermem.s @@ -5,7 +5,7 @@ .module usermem .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; exported symbols .globl __uget @@ -77,7 +77,7 @@ __uzero: ld a,b or c ret z - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ; user bank ld (hl),#0 dec bc @@ -98,7 +98,7 @@ __ugetc: pop hl push hl push bc - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ld l,(hl) ld h,#0 @@ -109,7 +109,7 @@ __ugetw: pop hl push hl push bc - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ld a,(hl) inc hl @@ -124,7 +124,7 @@ __uputc: push hl push de push bc - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ld (hl),e jr uout @@ -136,7 +136,7 @@ __uputw: push hl push de push bc - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) out (0x40),a ld (hl),e inc hl diff --git a/Kernel/platform-genie-eg64/crt0.s b/Kernel/platform-genie-eg64/crt0.s index afc3f70b..4d88b1bf 100644 --- a/Kernel/platform-genie-eg64/crt0.s +++ b/Kernel/platform-genie-eg64/crt0.s @@ -37,7 +37,7 @@ .globl kstack_top .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; startup code .area _BOOT diff --git a/Kernel/platform-genie-eg64/kernel.def b/Kernel/platform-genie-eg64/kernel.def index dcb7d3d4..c0ed421f 100644 --- a/Kernel/platform-genie-eg64/kernel.def +++ b/Kernel/platform-genie-eg64/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0x0200 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 (we don't save istack) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@0x0200 PROGBASE .equ 0x8000 PROGLOAD .equ 0x8000 diff --git a/Kernel/platform-genie-eg64/tricks.s b/Kernel/platform-genie-eg64/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-genie-eg64/tricks.s +++ b/Kernel/platform-genie-eg64/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-genie-eg64/trs80-bank.s b/Kernel/platform-genie-eg64/trs80-bank.s index 4edbf40e..74c37016 100644 --- a/Kernel/platform-genie-eg64/trs80-bank.s +++ b/Kernel/platform-genie-eg64/trs80-bank.s @@ -28,7 +28,7 @@ .globl null_handler .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ; These live below 0x8000 so they are not switched out diff --git a/Kernel/platform-genie-eg64/trs80.s b/Kernel/platform-genie-eg64/trs80.s index a71bc15b..16635dca 100644 --- a/Kernel/platform-genie-eg64/trs80.s +++ b/Kernel/platform-genie-eg64/trs80.s @@ -43,7 +43,7 @@ .globl null_handler .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0x0000 upwards after the udata etc) diff --git a/Kernel/platform-linc80/linc80.s b/Kernel/platform-linc80/linc80.s index c75b60b1..cbb5a619 100644 --- a/Kernel/platform-linc80/linc80.s +++ b/Kernel/platform-linc80/linc80.s @@ -43,7 +43,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; diff --git a/Kernel/platform-linc80/tricks.s b/Kernel/platform-linc80/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-linc80/tricks.s +++ b/Kernel/platform-linc80/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-micropack/kernel.def b/Kernel/platform-micropack/kernel.def index 41f169e1..6d98e7ea 100644 --- a/Kernel/platform-micropack/kernel.def +++ b/Kernel/platform-micropack/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0x8200 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 @8200 Z80_TYPE .equ 0 diff --git a/Kernel/platform-micropack/tricks.s b/Kernel/platform-micropack/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-micropack/tricks.s +++ b/Kernel/platform-micropack/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-micropack/z80pack.s b/Kernel/platform-micropack/z80pack.s index 5eb67f83..c7e23127 100644 --- a/Kernel/platform-micropack/z80pack.s +++ b/Kernel/platform-micropack/z80pack.s @@ -56,7 +56,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (not meaningful on swap only) diff --git a/Kernel/platform-msx1/kernel.def b/Kernel/platform-msx1/kernel.def index a9ef12e1..b3b10ad3 100644 --- a/Kernel/platform-msx1/kernel.def +++ b/Kernel/platform-msx1/kernel.def @@ -1,9 +1,8 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 -U_DATA_STASH .equ 0x7D00 ; 0x7D00-0x7FFF +U_DATA_STASH .equ 0x7E00 ; 0x7E00-0x7FFF ; as far as I can tell either is allowed by the spec diff --git a/Kernel/platform-msx1/msx1.s b/Kernel/platform-msx1/msx1.s index c74f5f2a..bb32b431 100644 --- a/Kernel/platform-msx1/msx1.s +++ b/Kernel/platform-msx1/msx1.s @@ -49,7 +49,7 @@ .globl vdpinit .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0xF000 upwards) diff --git a/Kernel/platform-msx1/slots.s b/Kernel/platform-msx1/slots.s index ace0c5ae..a2ffe3f0 100644 --- a/Kernel/platform-msx1/slots.s +++ b/Kernel/platform-msx1/slots.s @@ -5,7 +5,7 @@ .module bank_msx1 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; imported symbols .globl _ramsize diff --git a/Kernel/platform-msx1/tricks.s b/Kernel/platform-msx1/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-msx1/tricks.s +++ b/Kernel/platform-msx1/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-msx1/vdp.s b/Kernel/platform-msx1/vdp.s index 89e9eca1..27364bae 100644 --- a/Kernel/platform-msx1/vdp.s +++ b/Kernel/platform-msx1/vdp.s @@ -1,7 +1,7 @@ .module vdp .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" diff --git a/Kernel/platform-msx2/kernel.def b/Kernel/platform-msx2/kernel.def index 988b2b28..56f5dcfe 100644 --- a/Kernel/platform-msx2/kernel.def +++ b/Kernel/platform-msx2/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes@F000 ; as far as I can tell either is allowed by the spec diff --git a/Kernel/platform-msx2/msx2.s b/Kernel/platform-msx2/msx2.s index 33c3d45d..d23318c6 100644 --- a/Kernel/platform-msx2/msx2.s +++ b/Kernel/platform-msx2/msx2.s @@ -59,7 +59,7 @@ .globl _vdpinit .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _BUFFERS diff --git a/Kernel/platform-msx2/tricks.s b/Kernel/platform-msx2/tricks.s index a9e5a211..e9cd9b8f 100644 --- a/Kernel/platform-msx2/tricks.s +++ b/Kernel/platform-msx2/tricks.s @@ -25,7 +25,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -51,7 +51,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -82,7 +82,7 @@ _switchin: ; ------- No stack ------- ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail @@ -98,7 +98,7 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ---- New task stack ---- @@ -110,7 +110,7 @@ _switchin: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -162,7 +162,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -205,7 +205,7 @@ _dofork: ; and map_restore ; fork_copy: - ld hl, (U_DATA__U_TOP) + ld hl, (_udata + U_DATA__U_TOP) ld de, #0x0fff add hl, de ; + 0x1000 (-1 for the rounding to follow) ld a, h @@ -220,7 +220,7 @@ fork_copy: ld de, #P_TAB__P_PAGE_OFFSET add hl, de ; hl now points into the child pages - ld de, #U_DATA__U_PAGE + ld de, #_udata + U_DATA__U_PAGE ; and de is the parent fork_next: ld a,(hl) diff --git a/Kernel/platform-mtx/kernel.def b/Kernel/platform-mtx/kernel.def index 2c111451..53ad01f0 100644 --- a/Kernel/platform-mtx/kernel.def +++ b/Kernel/platform-mtx/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 U_DATA_STASH .equ 0xBE00 ; BE00-BFFF diff --git a/Kernel/platform-mtx/mtx.s b/Kernel/platform-mtx/mtx.s index 4a4194bc..1b943dc4 100644 --- a/Kernel/platform-mtx/mtx.s +++ b/Kernel/platform-mtx/mtx.s @@ -53,7 +53,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0xC000 upwards) diff --git a/Kernel/platform-mtx/tricks.s b/Kernel/platform-mtx/tricks.s index ee50c077..891ef430 100644 --- a/Kernel/platform-mtx/tricks.s +++ b/Kernel/platform-mtx/tricks.s @@ -1,5 +1,5 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-mtx/vdp.s b/Kernel/platform-mtx/vdp.s index 59d7a140..cd2f79b2 100644 --- a/Kernel/platform-mtx/vdp.s +++ b/Kernel/platform-mtx/vdp.s @@ -1,7 +1,7 @@ .module vdp .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../dev/vdp1.s" diff --git a/Kernel/platform-n8vem-mark4/ds1302-mark4.s b/Kernel/platform-n8vem-mark4/ds1302-mark4.s index f9bec020..1b37bd84 100644 --- a/Kernel/platform-n8vem-mark4/ds1302-mark4.s +++ b/Kernel/platform-n8vem-mark4/ds1302-mark4.s @@ -13,7 +13,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; DS1302 interface diff --git a/Kernel/platform-n8vem-mark4/kernel.def b/Kernel/platform-n8vem-mark4/kernel.def index ad26ba32..8a0167e1 100644 --- a/Kernel/platform-n8vem-mark4/kernel.def +++ b/Kernel/platform-n8vem-mark4/kernel.def @@ -1,8 +1,7 @@ ; UZI mnemonics for memory addresses etc ; Move down to 0xF600 to fit the monitor in -U_DATA .equ 0xF800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F800 Z80_TYPE .equ 2 OS_BANK .equ 0x00 ; value from include/kernel.h diff --git a/Kernel/platform-n8vem-mark4/mark4.s b/Kernel/platform-n8vem-mark4/mark4.s index 98da09f1..f9bcdc52 100644 --- a/Kernel/platform-n8vem-mark4/mark4.s +++ b/Kernel/platform-n8vem-mark4/mark4.s @@ -20,7 +20,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; Buffers diff --git a/Kernel/platform-nascom/gm833.s b/Kernel/platform-nascom/gm833.s index 34dd8a45..ffea8624 100644 --- a/Kernel/platform-nascom/gm833.s +++ b/Kernel/platform-nascom/gm833.s @@ -4,7 +4,7 @@ .module gm833 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl _gm833_in .globl _gm833_out diff --git a/Kernel/platform-nascom/gm849a_sasi.s b/Kernel/platform-nascom/gm849a_sasi.s index 8d54abe0..d514bb9f 100644 --- a/Kernel/platform-nascom/gm849a_sasi.s +++ b/Kernel/platform-nascom/gm849a_sasi.s @@ -5,7 +5,7 @@ ; ACK handling. .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl _si_read .globl _si_write diff --git a/Kernel/platform-nascom/gm8x9.s b/Kernel/platform-nascom/gm8x9.s index dfb9176d..f4477a4a 100644 --- a/Kernel/platform-nascom/gm8x9.s +++ b/Kernel/platform-nascom/gm8x9.s @@ -1,7 +1,7 @@ .module gm8x9 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl _gm8x9_ioread .globl _gm8x9_iowrite diff --git a/Kernel/platform-nascom/henelec.s b/Kernel/platform-nascom/henelec.s index 8062fd27..2ae743a2 100644 --- a/Kernel/platform-nascom/henelec.s +++ b/Kernel/platform-nascom/henelec.s @@ -65,7 +65,7 @@ .globl _io_page .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _CODE diff --git a/Kernel/platform-nascom/kernel.def b/Kernel/platform-nascom/kernel.def index 0caf0514..cb2a514b 100644 --- a/Kernel/platform-nascom/kernel.def +++ b/Kernel/platform-nascom/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xFC00 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 (we don't save istack) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@FC00 U_DATA_STASH .equ 0xE600 ; E800-E9FF diff --git a/Kernel/platform-nascom/nascom-pagemode.s b/Kernel/platform-nascom/nascom-pagemode.s index e2349ab0..bbd0f451 100644 --- a/Kernel/platform-nascom/nascom-pagemode.s +++ b/Kernel/platform-nascom/nascom-pagemode.s @@ -26,7 +26,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ; We keep the probe routine in the common copy area as we need @@ -149,7 +149,7 @@ map_process_always: map_process_always_di: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE ld a, (hl) ld (pagereg),a out (0xFF),a diff --git a/Kernel/platform-nascom/nascom.s b/Kernel/platform-nascom/nascom.s index 61d61f17..7da201b7 100644 --- a/Kernel/platform-nascom/nascom.s +++ b/Kernel/platform-nascom/nascom.s @@ -39,7 +39,7 @@ .globl _bufpool .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _BUFFERS diff --git a/Kernel/platform-nascom/tricks.s b/Kernel/platform-nascom/tricks.s index ee50c077..891ef430 100644 --- a/Kernel/platform-nascom/tricks.s +++ b/Kernel/platform-nascom/tricks.s @@ -1,5 +1,5 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-p112/ds1302-p112.s b/Kernel/platform-p112/ds1302-p112.s index b87f47fa..4d0beb7b 100644 --- a/Kernel/platform-p112/ds1302-p112.s +++ b/Kernel/platform-p112/ds1302-p112.s @@ -13,7 +13,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; DS1202 interface diff --git a/Kernel/platform-p112/kernel.def b/Kernel/platform-p112/kernel.def index 7d15ed79..339e7799 100644 --- a/Kernel/platform-p112/kernel.def +++ b/Kernel/platform-p112/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @F800 OS_BANK .equ 0x00 ; value from include/kernel.h diff --git a/Kernel/platform-p112/p112.s b/Kernel/platform-p112/p112.s index d0240b5e..69702d61 100644 --- a/Kernel/platform-p112/p112.s +++ b/Kernel/platform-p112/p112.s @@ -23,7 +23,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; Buffers diff --git a/Kernel/platform-pcw8256/README b/Kernel/platform-pcw8256/README index ae548a87..64382121 100644 --- a/Kernel/platform-pcw8256/README +++ b/Kernel/platform-pcw8256/README @@ -15,6 +15,11 @@ ram table of 512 bytes or so = ~ 24K) in the low 128K WIP - lots to do to add swap support and memory map needs a re-arrange so we can get fork() going +FIXME: +- Move disk buffers into own bank and use external disk buffers to keep under + the 48K line + + Supported Hardware (all only in early test) ------------------ diff --git a/Kernel/platform-pcw8256/config.h b/Kernel/platform-pcw8256/config.h index 434ca6a8..d1642d40 100644 --- a/Kernel/platform-pcw8256/config.h +++ b/Kernel/platform-pcw8256/config.h @@ -35,8 +35,8 @@ #define CONFIG_INPUT_GRABMAX 2 /* We could in theory do full up/down but later */ #define MAX_BLKDEV 1 /* UIDE or FIDHD never both */ #define CONFIG_IDE /* Has an IDE controller - maybe anyway: UIDE */ -#define CONFIG_NET -#define CONFIG_NET_NATIVE +#undef CONFIG_NET +#undef CONFIG_NET_NATIVE #define TICKSPERSEC 300 /* FIXME: double check - Ticks per second */ #define PROGBASE 0x0000 /* memory base of program */ @@ -56,7 +56,7 @@ #define NUM_DEV_TTY 3 #define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */ #define SWAPDEV 5 /* Device for swapping. */ -#define NBUFS 6 /* Number of block buffers */ +#define NBUFS 5 /* Number of block buffers */ #define NMOUNTS 2 /* Number of mounts at a time */ #define CONFIG_LARGE_IO_DIRECT(x) 1 diff --git a/Kernel/platform-pcw8256/crt0.s b/Kernel/platform-pcw8256/crt0.s index f8fad120..1fab7470 100644 --- a/Kernel/platform-pcw8256/crt0.s +++ b/Kernel/platform-pcw8256/crt0.s @@ -13,10 +13,10 @@ .area _HEAP ; note that areas below here may be overwritten by the heap at runtime, so ; put initialisation stuff in here - .area _INITIALIZER .area _FONT .area _GSINIT .area _GSFINAL + .area _INITIALIZER .area _COMMONMEM .area _DISCARD @@ -30,7 +30,6 @@ .globl l__DISCARD .globl s__COMMONMEM .globl l__COMMONMEM - .globl s__INITIALIZER .globl kstack_top .globl start diff --git a/Kernel/platform-pcw8256/devtty.c b/Kernel/platform-pcw8256/devtty.c index caa0c53a..3cfa89ab 100644 --- a/Kernel/platform-pcw8256/devtty.c +++ b/Kernel/platform-pcw8256/devtty.c @@ -22,9 +22,9 @@ __sfr __at 0xE4 ctc0; __sfr __at 0xE5 ctc1; __sfr __at 0xE7 ctcmode; -static char tbuf1[TTYSIZ]; -static char tbuf2[TTYSIZ]; -static char tbuf3[TTYSIZ]; +static uint8_t tbuf1[TTYSIZ]; +static uint8_t tbuf2[TTYSIZ]; +static uint8_t tbuf3[TTYSIZ]; static uint8_t sleeping; @@ -35,6 +35,29 @@ struct s_queue ttyinq[NUM_DEV_TTY+1] = { /* ttyinq[0] is never used */ { tbuf3, tbuf3, tbuf3, TTYSIZ, 0, TTYSIZ/2 } }; +static tcflag_t console_mask[4] = { + _ISYS, + _OSYS, + _CSYS, + _LSYS +}; + + +static tcflag_t uart_mask[4] = { + _ISYS, + _OSYS, + _CSYS, /* For now - need to do DART code */ + _LSYS +}; + + +tcflag_t *termios_mask[NUM_DEV_TTY + 1] = { + NULL, + console_mask, + uart_mask, + uart_mask, +}; + /* console driver for errors etc */ void kputchar(char c) { diff --git a/Kernel/platform-pcw8256/fuzix.lnk b/Kernel/platform-pcw8256/fuzix.lnk index 87f3e6ba..8b1dbbb6 100644 --- a/Kernel/platform-pcw8256/fuzix.lnk +++ b/Kernel/platform-pcw8256/fuzix.lnk @@ -2,7 +2,7 @@ -i fuzix.ihx -b _CODE=0x0000 -b _COMMONMEM=0xF400 --b _DISCARD=0xE800 +-b _DISCARD=0xEB00 -l z80 platform-pcw8256/crt0.rel platform-pcw8256/commonmem.rel diff --git a/Kernel/platform-pcw8256/kernel.def b/Kernel/platform-pcw8256/kernel.def index c33b656d..b088bb7e 100644 --- a/Kernel/platform-pcw8256/kernel.def +++ b/Kernel/platform-pcw8256/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF400 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F400 Z80_TYPE .equ 0 ; FIXME: check diff --git a/Kernel/platform-pcw8256/main.c b/Kernel/platform-pcw8256/main.c index 9c8d13bb..49e09062 100644 --- a/Kernel/platform-pcw8256/main.c +++ b/Kernel/platform-pcw8256/main.c @@ -4,8 +4,6 @@ #include #include -uint16_t ramtop; - /* Kernel is 0-3 screen for now is 4 and bits of 5 Apps 6,7,8,9,10,11,12,13,14,15 etc diff --git a/Kernel/platform-pcw8256/pcw8256.s b/Kernel/platform-pcw8256/pcw8256.s index f13418f8..a3e433ea 100644 --- a/Kernel/platform-pcw8256/pcw8256.s +++ b/Kernel/platform-pcw8256/pcw8256.s @@ -15,7 +15,6 @@ .globl map_kernel_di .globl map_process_di .globl map_process_always_di - .globl _need_resched .globl _int_disabled .globl map_save_kernel .globl map_restore @@ -58,7 +57,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; VIDEO MEMORY BANK (0x4000-0xBFFF during video work) @@ -198,7 +197,7 @@ map_process_always: map_process_always_di: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_process_1 pop hl pop af @@ -213,7 +212,7 @@ map_process_di: or l jr z, map_kernel map_process_1: - ld a, (int_disabled) + ld a, (_int_disabled) push af di ; ensure we don't take an irq mid update push de @@ -517,9 +516,6 @@ map_save_area: .db 0 .db 0 -_need_resched: - .db 0 - _int_disabled: .db 1 diff --git a/Kernel/platform-pcw8256/tricks.s b/Kernel/platform-pcw8256/tricks.s index ec1ce16a..7b1d7d65 100644 --- a/Kernel/platform-pcw8256/tricks.s +++ b/Kernel/platform-pcw8256/tricks.s @@ -1,231 +1,13 @@ .module tricks - .globl _ptab_alloc - .globl _newproc - .globl _chksigs - .globl _getproc - .globl _platform_monitor - .globl trap_illegal - .globl _inint - .globl _platform_switchout - .globl _switchin - .globl _doexec - .globl _dofork - .globl _runticks - .globl unix_syscall_entry - .globl map_process - .globl map_kernel - .globl _swapper - .globl _int_disabled - - ; imported debug symbols - .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex - .include "kernel.def" - .include "../kernel.def" - - .area _COMMONMEM - -; Switchout switches out the current process, finds another that is READY, -; possibly the same process, and switches it in. When a process is -; restarted after calling switchout, it thinks it has just returned -; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_platform_switchout: - di - ; save machine state - - ld a, #'O' - call outchar - ld hl, (U_DATA__U_PTAB) - call outhl - - ld hl, #0 ; return code set here is ignored, but _switchin can - ; return from either _switchout OR _dofork, so they must both write - ; U_DATA__U_SP with the following on the stack: - push hl ; return code - push ix - push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin - - ; find another process to run (may select this one again) - call _getproc - - push hl - call _switchin - - ; we should never get here - call _platform_monitor - -badswitchmsg: .ascii "_switchin: FAIL" - .db 13, 10, 0 -_switchin: - di - pop bc ; return address - pop de ; new process pointer - push de ; restore stack - push bc ; restore stack - - push de - ld a, #'I' - call outchar - call outde - pop de - ld hl, #P_TAB__P_PAGE_OFFSET - add hl, de ; process ptr - - ld a, (hl) - or a - jr nz, not_swapped - - ld a, #'S' - call outchar - ; - ; Run the swapper - ; - push hl - push de - call _swapper - pop de - pop hl - -not_swapped: - push de - call outde - pop de - ld hl, #P_TAB__P_PAGE_OFFSET + 3 - add hl, de - ld a, (hl) ; common page - - push af - call outcharhex - pop af - ; ----------- Stack is switched across this instruction -;FIXME out (0xF3), a - - ; bear in mind that the stack will be switched now, so we can't use it - ; to carry values over this point - - ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab - or a ; clear carry flag - sbc hl, de ; subtract, result will be zero if DE==HL - jr nz, switchinfail - - ld hl, #P_TAB__P_STATUS_OFFSET - add hl, de - ; next_process->p_status = P_RUNNING - ld (hl), #P_RUNNING - - ; runticks = 0 - ld hl, #0 - ld (_runticks), hl + .include "../kernel-z80.def" - ; restore machine state -- note we may be returning from either - ; _switchout or _dofork - ld sp, (U_DATA__U_SP) +TOP_PORT .equ 0xF3 - ; ------------- Stack may be used again ------------ - pop iy - pop ix - pop hl ; return code + .include "../lib/z80bank16.s" - ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) - ld (_int_disabled),a - or a - ret nz ; in ISR, leave interrupts off - ei - ret ; return with interrupts on - -switchinfail: - ld hl, #badswitchmsg - call outstring - ; something went wrong and we didn't switch in what we asked for - jp _platform_monitor - -fork_proc_ptr: .dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry - -; -; Called from _fork. We are in a syscall, the uarea is live as the -; parent uarea. The kernel is the mapped object. -; -_dofork: - ; always disconnect the vehicle battery before performing maintenance - di ; should already be the case ... belt and braces. - - pop de ; return address - pop hl ; new process p_tab* - push hl - push de - - ld (fork_proc_ptr), hl - - ; prepare return value in parent process -- HL = p->p_pid; - ld de, #P_TAB__P_PID_OFFSET - add hl, de - ld a, (hl) - inc hl - ld h, (hl) - ld l, a - - ; Save the stack pointer and critical registers. - ; When this process (the parent) is switched back in, it will be as if - ; it returns with the value of the child's pid. - push hl ; HL still has p->p_pid from above, the return value in the parent - push ix - push iy - - ; save kernel stack pointer -- when it comes back in the parent we'll be in - ; _switchin which will immediately return (appearing to be _dofork() - ; returning) and with HL (ie return code) containing the child PID. - ; Hurray. - ld (U_DATA__U_SP), sp - - ; now we're in a safe state for _switchin to return in the parent - ; process. - - ; --------- copy process --------- - - ld hl, (fork_proc_ptr) - ld de, #P_TAB__P_PAGE_OFFSET - add hl, de - ; load p_page - ld c, (hl) - ld hl, (U_DATA__U_PTAB) - add hl, de - ld b, (hl) - - ; in this call we will switch stack to the child copy, which has - ; everything below this point from the parent. We will also change - ; our common instance - - call fork_copy ; do the bank to bank copy - - ; now the copy operation is complete we can get rid of the stuff - ; _switchin will be expecting from our copy of the stack. - pop bc - pop bc - pop bc - - ; Make a new process table entry, etc. - ld hl, (fork_proc_ptr) - push hl - call _newproc - pop bc - - ; runticks = 0; - ld hl, #0 - ld (_runticks), hl - ; in the child process, fork() returns zero. - ; - ; And we exit, with the kernel mapped, the child now being deemed - ; to be the live uarea. The parent is frozen in time and space as - ; if it had done a switchout(). - ret + .area _COMMONMEM fork_copy: ld hl, (U_DATA__U_TOP) @@ -266,3 +48,8 @@ fork_next: out (0xf3), a ; our last bank repeats up to common ; --- we are now on the stack copy, parent stack is locked away --- ret ; this stack is copied so safe to return on + +top_bank: + .db 0 ; dummy for core code + + diff --git a/Kernel/platform-pentagon/crt0.s b/Kernel/platform-pentagon/crt0.s index 2de325be..33caf7b0 100644 --- a/Kernel/platform-pentagon/crt0.s +++ b/Kernel/platform-pentagon/crt0.s @@ -49,8 +49,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _CODE1 ; startup code diff --git a/Kernel/platform-pentagon/kernel.def b/Kernel/platform-pentagon/kernel.def index 9e311b86..9cff8a01 100644 --- a/Kernel/platform-pentagon/kernel.def +++ b/Kernel/platform-pentagon/kernel.def @@ -1,8 +1,7 @@ ; UZI mnemonics for memory addresses etc ; We stick it straight after the tag -U_DATA .equ 0x100 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @0x0100 U_DATA_STASH .equ 0xFE00 ; FE00-FFFF diff --git a/Kernel/platform-pentagon/pentagon.s b/Kernel/platform-pentagon/pentagon.s index c7e618f6..fe8d3d90 100644 --- a/Kernel/platform-pentagon/pentagon.s +++ b/Kernel/platform-pentagon/pentagon.s @@ -28,6 +28,7 @@ .globl _need_resched .globl _int_disabled + .globl _udata ; exported debugging tools .globl _platform_monitor @@ -69,7 +70,7 @@ .globl __stub_3_2 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (below 0xC000) @@ -194,7 +195,7 @@ map_process_always_di: push af ld a, (current_map) ld (ksave_map), a - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call switch_bank pop af ret diff --git a/Kernel/platform-px4plus/kernel.def b/Kernel/platform-px4plus/kernel.def index 10a5d139..fce0ee53 100644 --- a/Kernel/platform-px4plus/kernel.def +++ b/Kernel/platform-px4plus/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0x0100 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 @0100 VIDBASE .equ 0xF8 ; Video for now diff --git a/Kernel/platform-px4plus/px4plus.s b/Kernel/platform-px4plus/px4plus.s index cbf8c1d0..3b97355f 100644 --- a/Kernel/platform-px4plus/px4plus.s +++ b/Kernel/platform-px4plus/px4plus.s @@ -59,7 +59,7 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (not unmapped when we flip to ROM) diff --git a/Kernel/platform-px4plus/tricks.s b/Kernel/platform-px4plus/tricks.s index 30ce5a1f..5276ea2c 100644 --- a/Kernel/platform-px4plus/tricks.s +++ b/Kernel/platform-px4plus/tricks.s @@ -29,7 +29,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -47,7 +47,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) push af @@ -121,34 +121,34 @@ not_swapped: ; ; check u_data->u_ptab matches what we wanted ; - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix the moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) or a ret nz ; in ISR, leave interrupts off ei @@ -199,7 +199,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -218,7 +218,7 @@ _dofork: ld a, c call outcharhex pop af - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call bankfork ; do the bank to bank copy diff --git a/Kernel/platform-rabbit2000/kernel.def b/Kernel/platform-rabbit2000/kernel.def index 718bf95a..8b003a0c 100644 --- a/Kernel/platform-rabbit2000/kernel.def +++ b/Kernel/platform-rabbit2000/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xE000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @E000 U_DATA_STASH .equ 0xBE00 ; BE00-BFFF diff --git a/Kernel/platform-rabbit2000/rabbit.s b/Kernel/platform-rabbit2000/rabbit.s index ff137dfb..b3e69392 100644 --- a/Kernel/platform-rabbit2000/rabbit.s +++ b/Kernel/platform-rabbit2000/rabbit.s @@ -90,6 +90,9 @@ _program_vectors: .globl _kdataseg + + .globl _udata + map_kernel: map_kernel_di: push af @@ -113,7 +116,7 @@ map_process_a: map_process_always: map_process_always_di: push af - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) ioi ld (DATASEG),a pop af @@ -415,8 +418,9 @@ _ser'X'_get: inc hl inc a cp a,(hl) ; in ptr - jr nz, ser'X'_empty + jr z, ser'X'_empty dec hl + and #63 ipset3 ld (hl),a ld hl,#_ser'X'_rxbuf ; work around dumb linker limit diff --git a/Kernel/platform-rc2014-sbc64/rc2014.s b/Kernel/platform-rc2014-sbc64/rc2014.s index a1afbad6..45c1598e 100644 --- a/Kernel/platform-rc2014-sbc64/rc2014.s +++ b/Kernel/platform-rc2014-sbc64/rc2014.s @@ -39,12 +39,13 @@ .globl _sio1_present .globl _tty_resume .globl _ide_resume + .globl _udata ; exported debugging tools .globl outchar .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;========================================================================= ; Constants @@ -354,7 +355,7 @@ map_process_a: map_process_always: map_process_always_di: push af - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) map_pop_a: ld (pagereg),a out (0x1f),a diff --git a/Kernel/platform-rc2014-sbc64/tricks.s b/Kernel/platform-rc2014-sbc64/tricks.s index b63a607b..f8727881 100644 --- a/Kernel/platform-rc2014-sbc64/tricks.s +++ b/Kernel/platform-rc2014-sbc64/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank-core.s" diff --git a/Kernel/platform-rc2014-tiny/kernel.def b/Kernel/platform-rc2014-tiny/kernel.def index c971ef3d..828be62e 100644 --- a/Kernel/platform-rc2014-tiny/kernel.def +++ b/Kernel/platform-rc2014-tiny/kernel.def @@ -1,7 +1,6 @@ ; FUZIX mnemonics for memory addresses etc -U_DATA .equ 0xC000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ 0xC000 Z80_TYPE .equ 0 ; CMOS Z80_MMU_HOOKS .equ 0 diff --git a/Kernel/platform-rc2014-tiny/rc2014.s b/Kernel/platform-rc2014-tiny/rc2014.s index 2c5d59f4..2fda9c5e 100644 --- a/Kernel/platform-rc2014-tiny/rc2014.s +++ b/Kernel/platform-rc2014-tiny/rc2014.s @@ -40,7 +40,7 @@ .globl outchar .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;========================================================================= ; Constants diff --git a/Kernel/platform-rc2014-tiny/tricks.s b/Kernel/platform-rc2014-tiny/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-rc2014-tiny/tricks.s +++ b/Kernel/platform-rc2014-tiny/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-rc2014/buffers.s b/Kernel/platform-rc2014/buffers.s index 73e2c0b5..377707b1 100644 --- a/Kernel/platform-rc2014/buffers.s +++ b/Kernel/platform-rc2014/buffers.s @@ -5,8 +5,8 @@ .module buffers .area _COMMONMEM - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .globl _do_blkzero .globl _do_blkcopyk diff --git a/Kernel/platform-rc2014/devrd_zeta2_hw.s b/Kernel/platform-rc2014/devrd_zeta2_hw.s index 05b2f861..048ab7e7 100644 --- a/Kernel/platform-rc2014/devrd_zeta2_hw.s +++ b/Kernel/platform-rc2014/devrd_zeta2_hw.s @@ -3,6 +3,7 @@ ; imported symbols .globl map_kernel, mpgsel_cache, _kernel_pages .globl _rd_platform_copy + .globl _udata ; exported symbols .globl _rd_page_copy @@ -14,8 +15,8 @@ .globl _devmem_read .globl _devmem_write - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _CODE _devmem_write: @@ -30,13 +31,13 @@ _devmem_read: _devmem_go: ld (_rd_dst_userspace), a ; 1 = userspace ; load the other parameters - ld hl, (U_DATA__U_BASE) + ld hl, (_udata + U_DATA__U_BASE) ld (_rd_dst_address), hl - ld hl, (U_DATA__U_OFFSET) + ld hl, (_udata + U_DATA__U_OFFSET) ld (_rd_src_address), hl - ld hl, (U_DATA__U_OFFSET+2) + ld hl, (_udata + U_DATA__U_OFFSET+2) ld (_rd_src_address+2), hl - ld hl, (U_DATA__U_COUNT) + ld hl, (_udata + U_DATA__U_COUNT) ld (_rd_cpy_count), hl ; for single byte transfers we can optimise away the outer loop dec l ; test for HL=1 @@ -95,7 +96,7 @@ _rd_page_copy: ld hl, #_kernel_pages ; get kernel page table jr rd_do_translate rd_translate_userspace: - ld hl, #U_DATA__U_PAGE ; get user process page table + ld hl, #_udata + U_DATA__U_PAGE ; get user process page table rd_do_translate: add hl, bc ; add index to base ptr (uint8_t *) ld a, (hl) ; load the page number from the page table diff --git a/Kernel/platform-rc2014/kernel.def b/Kernel/platform-rc2014/kernel.def index d0bc0db2..1d9a6c41 100644 --- a/Kernel/platform-rc2014/kernel.def +++ b/Kernel/platform-rc2014/kernel.def @@ -1,7 +1,6 @@ ; FUZIX mnemonics for memory addresses etc -U_DATA .equ 0xD000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ D000 Z80_TYPE .equ 0 ; just a old good Z80 USE_FANCY_MONITOR .equ 1 ; disabling this saves around approx 0.5KB diff --git a/Kernel/platform-rc2014/rc2014.s b/Kernel/platform-rc2014/rc2014.s index f6bf94ae..69373874 100644 --- a/Kernel/platform-rc2014/rc2014.s +++ b/Kernel/platform-rc2014/rc2014.s @@ -41,13 +41,14 @@ .globl _ctc_present .globl _sio_present .globl _sio1_present + .globl _udata ; exported debugging tools .globl outchar .globl inchar .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;========================================================================= ; Constants @@ -382,24 +383,24 @@ _program_vectors: map_process_always: map_process_always_di: push hl - ld hl,#U_DATA__U_PAGE + ld hl,#_udata + U_DATA__U_PAGE jr map_process_2_pophl_ret map_buffers_user: push hl - ld hl,(U_DATA__U_PAGE) + ld hl,(_udata + U_DATA__U_PAGE) ld h,#36 ld (_ubuffer_pages),hl - ld hl,(U_DATA__U_PAGE + 2) + ld hl,(_udata + U_DATA__U_PAGE + 2) ld (_ubuffer_pages + 2),hl ld hl,#_ubuffer_pages jr map_process_2_pophl_ret map_buffers_user_h: push hl - ld hl,(U_DATA__U_PAGE) + ld hl,(_udata + U_DATA__U_PAGE) ld (_ubuffer_pages),hl - ld hl,(U_DATA__U_PAGE + 2) + ld hl,(_udata + U_DATA__U_PAGE + 2) ld l,#36 ld (_ubuffer_pages + 2),hl ld hl,#_ubuffer_pages diff --git a/Kernel/platform-rc2014/tricks.s b/Kernel/platform-rc2014/tricks.s index b7f6d3dd..d73b6d8e 100644 --- a/Kernel/platform-rc2014/tricks.s +++ b/Kernel/platform-rc2014/tricks.s @@ -1,7 +1,7 @@ .module tricks .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" TOP_PORT .equ MPGSEL_3 @@ -12,7 +12,7 @@ TOP_PORT .equ MPGSEL_3 .globl mpgsel_cache fork_copy: - ld hl, (U_DATA__U_TOP) + ld hl, (_udata + U_DATA__U_TOP) ld de, #0x0fff add hl, de ; + 0x1000 (-1 for the rounding to follow) ld a, h @@ -27,7 +27,7 @@ fork_copy: ld de, #P_TAB__P_PAGE_OFFSET add hl, de ; hl now points into the child pages - ld de, #U_DATA__U_PAGE + ld de, #_udata + U_DATA__U_PAGE ; and de is the parent fork_next: ld a,(hl) diff --git a/Kernel/platform-rc2014/vfdterm.s b/Kernel/platform-rc2014/vfdterm.s index 1450a1b6..36730ce5 100644 --- a/Kernel/platform-rc2014/vfdterm.s +++ b/Kernel/platform-rc2014/vfdterm.s @@ -1,7 +1,7 @@ .module vfdterm .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl VFDTERM_PREINIT .globl VFDTERM_PUTC diff --git a/Kernel/platform-sam/atom.s b/Kernel/platform-sam/atom.s index a2dc0498..012b64ab 100644 --- a/Kernel/platform-sam/atom.s +++ b/Kernel/platform-sam/atom.s @@ -16,7 +16,7 @@ .module atom .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl _devide_read_data @@ -57,7 +57,7 @@ atomlite_read: atomlite_read_user: push ix ; HL is the user buffer, BC length - ld ix,#U_DATA__U_PAGE + ld ix,#_udata + U_DATA__U_PAGE call user_mapping jr z,ide_r2 call atomlite_reader @@ -84,7 +84,7 @@ atomlite_write: atomlite_write_user: push ix ; HL is the user buffer, BC length - ld ix,#U_DATA__U_PAGE + ld ix,#_udata + U_DATA__U_PAGE call user_mapping jr z,ide_w2 call atomlite_writer diff --git a/Kernel/platform-sam/kernel.def b/Kernel/platform-sam/kernel.def index d00b87bb..98a35731 100644 --- a/Kernel/platform-sam/kernel.def +++ b/Kernel/platform-sam/kernel.def @@ -1,7 +1,6 @@ ; Fuzix mnemonics for memory addresses etc -U_DATA .equ 0xF800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 512 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 512 bytes @ F800 U_DATA_STASH .equ 0xFD00 ; FD00-FEFF ; FF00-FFFF is the high stubs diff --git a/Kernel/platform-sam/sam.s b/Kernel/platform-sam/sam.s index 5e02691c..8c0513c1 100644 --- a/Kernel/platform-sam/sam.s +++ b/Kernel/platform-sam/sam.s @@ -26,6 +26,7 @@ .globl _mouse12 .globl _mouse_probe .globl _int_disabled + .globl _udata ; exported debugging tools .globl _platform_monitor @@ -49,7 +50,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" KERNEL_LOW .equ 0x20 ; 0/1 low 2/3 high (ROM off) KERNEL_HIGH .equ 2 @@ -179,7 +180,7 @@ map_restore_low: ld a, (low_save) jr map_page_low map_user_low: - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) map_page_low: or #0x20 ; force ROM off out (250),a @@ -566,7 +567,7 @@ syscall_high: or #KERNEL_HIGH out (251),a ; Stack now invalid - ld (U_DATA__U_SYSCALL_SP),sp + ld (_udata + U_DATA__U_SYSCALL_SP),sp ld sp,#kstack_top ld a,(syscall_stash) call unix_syscall_entry @@ -579,7 +580,7 @@ syscall_high: pop bc ; stack now invalid. Grab the new sp before we unbank the ; memory holding it - ld sp,(U_DATA__U_SYSCALL_SP) + ld sp,(_udata + U_DATA__U_SYSCALL_SP) out (251),a xor a cp h diff --git a/Kernel/platform-sam/tricks.s b/Kernel/platform-sam/tricks.s index c33f1cdb..ba413e9a 100644 --- a/Kernel/platform-sam/tricks.s +++ b/Kernel/platform-sam/tricks.s @@ -1,6 +1,6 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ;FIXME .include "../lib/z80fixedbank.s" @@ -43,13 +43,13 @@ _platform_switchout: push hl ; stack a retcode of 0 (see fork) push ix ; save registers push iy - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; The U_DATA stash lives in the top of the user process. Map that ; low with interrupts off so we can ldir between the two - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) call map_page_low - ld hl,#U_DATA + ld hl,#_udata ld de,#U_DATA_STASH-0x8000 ld bc,#U_DATA__TOTALSIZE ldir @@ -72,7 +72,7 @@ _switchin: ; FIXME: add swap support - ld hl,(U_DATA__U_PTAB) + ld hl,(_udata + U_DATA__U_PTAB) or a sbc hl,de jr z, skip_copyback @@ -83,28 +83,28 @@ _switchin: ; a moment exx ld hl,#U_DATA_STASH-0x8000 - ld de,#U_DATA + ld de,#_udata ld bc,#U_DATA__TOTALSIZE ldir exx - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; Ok our stack is now valid call map_kernel_low - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) or a sbc hl,de jr nz, switchin_failed ; invalid u_data skip_copyback: - ld sp, (U_DATA__U_SP) - ld ix, (U_DATA__U_PTAB) + ld sp, (_udata + U_DATA__U_SP) + ld ix, (_udata + U_DATA__U_PTAB) ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE),a + ld (_udata + U_DATA__U_PAGE),a ld a, P_TAB__P_PAGE_OFFSET+1(ix) - ld (U_DATA__U_PAGE + 1),a + ld (_udata + U_DATA__U_PAGE + 1),a ld hl,#0 ld (_runticks), hl ; Recover IX and IY, return value @@ -113,7 +113,7 @@ skip_copyback: pop hl ; if we pre-empted in an ISR IRQ's stay off, if not they get enabled - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled), a or a ret nz @@ -154,7 +154,7 @@ _dofork: push ix push iy - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; Parent state built and in u_data @@ -180,10 +180,10 @@ _dofork: ; modify it for the child ; Map parent high page - ld a,(U_DATA__U_PAGE+1) + ld a,(_udata + U_DATA__U_PAGE+1) call map_page_low ; Copy udata - ld hl, #U_DATA + ld hl, #_udata ld de, #U_DATA_STASH - 0x8000 ld bc, #U_DATA__TOTALSIZE ldir @@ -241,7 +241,7 @@ _dofork: copy_process: ld de,#P_TAB__P_PAGE_OFFSET add hl,de - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) call map_page_low call setup_platform_copier ld ix,#cp1ret @@ -252,7 +252,7 @@ cp1ret: inc hl cp (hl) ret z - ld a,(U_DATA__U_PAGE+1) + ld a,(_udata + U_DATA__U_PAGE+1) call map_page_low call setup_platform_copier ld ix,#cp2ret diff --git a/Kernel/platform-sbcv2/kernel.def b/Kernel/platform-sbcv2/kernel.def index 581d8215..a5f7863e 100644 --- a/Kernel/platform-sbcv2/kernel.def +++ b/Kernel/platform-sbcv2/kernel.def @@ -5,8 +5,7 @@ ; of common memory. We do actually have a symbol for udata so ; eventually this needs to go away ; -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 ; ; Space for the udata of a switched out process within the bank of ; memory that it uses. Normally placed at the very top diff --git a/Kernel/platform-sbcv2/sbcv2.s b/Kernel/platform-sbcv2/sbcv2.s index 2b9b4da4..f8be81b7 100644 --- a/Kernel/platform-sbcv2/sbcv2.s +++ b/Kernel/platform-sbcv2/sbcv2.s @@ -45,7 +45,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ; Buffers (we use asm to set this up as we need them in a special segment @@ -252,7 +252,7 @@ map_process_always_di: map_process_always: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_process_hl pop hl pop af @@ -325,7 +325,7 @@ _platform_prop_sd_read: dec a ld a, (_blk_op + BLKPARAM_SWAP_PAGE) jr nz, do_read_a - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) do_read_a: call map_process_a do_read: ld bc,#0xAB inir @@ -340,7 +340,7 @@ _platform_prop_sd_write: dec a ld a, (_blk_op + BLKPARAM_SWAP_PAGE) jr nz, do_write_a - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) do_write_a: call map_process_a do_write: ld bc,#0xAB otir diff --git a/Kernel/platform-sbcv2/tricks.s b/Kernel/platform-sbcv2/tricks.s index 2025fbed..0f475a79 100644 --- a/Kernel/platform-sbcv2/tricks.s +++ b/Kernel/platform-sbcv2/tricks.s @@ -3,8 +3,9 @@ ; only reason to do otherwise is for speed. A custom bank logic aware ; bank to bank copier will give vastly better fork() performance. ; - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" + ; ; All of the fixed bank support is available as a library routine, ; however it is a performance sensitive area. Start with diff --git a/Kernel/platform-sc108/kernel.def b/Kernel/platform-sc108/kernel.def index 3ccb1feb..15d52b0e 100644 --- a/Kernel/platform-sc108/kernel.def +++ b/Kernel/platform-sc108/kernel.def @@ -1,7 +1,6 @@ ; FUZIX mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 Z80_TYPE .equ 0 ; CMOS Z80_MMU_HOOKS .equ 0 diff --git a/Kernel/platform-sc108/sc108.s b/Kernel/platform-sc108/sc108.s index a5c6b560..71d280f5 100644 --- a/Kernel/platform-sc108/sc108.s +++ b/Kernel/platform-sc108/sc108.s @@ -39,7 +39,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; Base address of SIO/2 chip 0x80 @@ -624,13 +624,13 @@ syscall_high: out (0x38),a ex af,af' ; Stack now invalid - ld (U_DATA__U_SYSCALL_SP),sp + ld (_udata + U_DATA__U_SYSCALL_SP),sp ld sp,#kstack_top call unix_syscall_entry ; FIXME check di rules ; stack now invalid. Grab the new sp before we unbank the ; memory holding it - ld sp,(U_DATA__U_SYSCALL_SP) + ld sp,(_udata + U_DATA__U_SYSCALL_SP) ld a,#0x81 ; back to the user page out (0x38),a xor a diff --git a/Kernel/platform-sc108/tricks.s b/Kernel/platform-sc108/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-sc108/tricks.s +++ b/Kernel/platform-sc108/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-sc108/usermem.s b/Kernel/platform-sc108/usermem.s index ff9cc95f..7b5388e3 100644 --- a/Kernel/platform-sc108/usermem.s +++ b/Kernel/platform-sc108/usermem.s @@ -5,7 +5,7 @@ .module usermem .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; exported symbols .globl __uget diff --git a/Kernel/platform-sc114/sc114.s b/Kernel/platform-sc114/sc114.s index 925d5fa2..0cb457f1 100644 --- a/Kernel/platform-sc114/sc114.s +++ b/Kernel/platform-sc114/sc114.s @@ -40,7 +40,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; @@ -449,13 +449,13 @@ syscall_high: out (0x30),a ex af,af' ; Stack now invalid - ld (U_DATA__U_SYSCALL_SP),sp + ld (_udata + U_DATA__U_SYSCALL_SP),sp ld sp,#kstack_top call unix_syscall_entry ; FIXME check di rules ; stack now invalid. Grab the new sp before we unbank the ; memory holding it - ld sp,(U_DATA__U_SYSCALL_SP) + ld sp,(_udata + U_DATA__U_SYSCALL_SP) ld a,#0x81 ; back to the user page out (0x38),a rlca diff --git a/Kernel/platform-sc114/tricks.s b/Kernel/platform-sc114/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-sc114/tricks.s +++ b/Kernel/platform-sc114/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-sc114/usermem.s b/Kernel/platform-sc114/usermem.s index 81c92eeb..ca787370 100644 --- a/Kernel/platform-sc114/usermem.s +++ b/Kernel/platform-sc114/usermem.s @@ -5,7 +5,7 @@ .module usermem .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; exported symbols .globl __uget diff --git a/Kernel/platform-socz80/commonmem.s b/Kernel/platform-socz80/commonmem.s index 399f59b8..d2a2a732 100644 --- a/Kernel/platform-socz80/commonmem.s +++ b/Kernel/platform-socz80/commonmem.s @@ -2,8 +2,8 @@ .module commonmem - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM ; ------------------------------------------------------------------------------------------------ diff --git a/Kernel/platform-socz80/kernel.def b/Kernel/platform-socz80/kernel.def index e3c7b6d7..cad81f22 100644 --- a/Kernel/platform-socz80/kernel.def +++ b/Kernel/platform-socz80/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xf800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F800 Z80_TYPE .equ 0 ; Actually a T80 diff --git a/Kernel/platform-socz80/socz80.s b/Kernel/platform-socz80/socz80.s index cebe7d59..75881367 100644 --- a/Kernel/platform-socz80/socz80.s +++ b/Kernel/platform-socz80/socz80.s @@ -52,7 +52,7 @@ .include "socz80.def" .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0xF000 upwards) @@ -409,7 +409,7 @@ map_process_di: map_process_always: map_process_always_di: push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_loadhl pop hl ret diff --git a/Kernel/platform-socz80/tricks.s b/Kernel/platform-socz80/tricks.s index c1066116..fc2e1429 100644 --- a/Kernel/platform-socz80/tricks.s +++ b/Kernel/platform-socz80/tricks.s @@ -24,9 +24,8 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "socz80.def" - .include "../kernel.def" .include "kernel.def" - + .include "../kernel-z80.def" ; ; These do not need to be in common memory as we don't have to ; pull udata remapping tricks on a 16K banked system. In the case of @@ -52,7 +51,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -105,7 +104,7 @@ _switchin: ; ------------- Our stack just left the building --------------- ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==HL jr nz, switchinfail @@ -119,13 +118,13 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) pop iy pop ix pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -169,7 +168,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; ; We will return on the parent stack with everything copied. We can @@ -236,7 +235,7 @@ fork_copy: ld de, #P_TAB__P_PAGE_OFFSET add hl, de ; parent mapping to be copied - ld de, #U_DATA__U_PAGE + ld de, #_udata + U_DATA__U_PAGE ; ; Walk the 16K banks using a generic code pattern diff --git a/Kernel/platform-socz80/usermem.s b/Kernel/platform-socz80/usermem.s index 53ce7bef..142da0e8 100644 --- a/Kernel/platform-socz80/usermem.s +++ b/Kernel/platform-socz80/usermem.s @@ -1,7 +1,7 @@ .module usermem .include "socz80.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "kernel.def" ; imported symbols @@ -156,7 +156,7 @@ __uget: ugetputsetup: ; compute 32-bit dest address based on process MMU page and userspace address in DE - ld hl, (U_DATA__U_PAGE) ; load 4K page address + ld hl, (_udata + U_DATA__U_PAGE) ; load 4K page address ; we shift HL 4 bits to the left (would need to handle overflow for future hardware with >16MB RAM) add hl, hl diff --git a/Kernel/platform-tbblue/crt0.s b/Kernel/platform-tbblue/crt0.s index a58fa8f6..df529dfa 100644 --- a/Kernel/platform-tbblue/crt0.s +++ b/Kernel/platform-tbblue/crt0.s @@ -49,8 +49,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; ; startup code. Runs from 0x100. The kernel is mapped into pages diff --git a/Kernel/platform-tbblue/kernel.def b/Kernel/platform-tbblue/kernel.def index 849a7684..8875f9c8 100644 --- a/Kernel/platform-tbblue/kernel.def +++ b/Kernel/platform-tbblue/kernel.def @@ -1,5 +1,4 @@ -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 Z80_TYPE .equ 1 diff --git a/Kernel/platform-tbblue/tbblue.s b/Kernel/platform-tbblue/tbblue.s index 6ba3087b..f083a51b 100644 --- a/Kernel/platform-tbblue/tbblue.s +++ b/Kernel/platform-tbblue/tbblue.s @@ -47,7 +47,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (above 0xE000) @@ -193,7 +193,7 @@ map_process_always_di: push bc push de push hl - ld hl,(U_DATA__U_PAGE) + ld hl,(_udata + U_DATA__U_PAGE) map_write_hl: ; Switch this to nextreg at some point FIXME ld bc,#0x243b diff --git a/Kernel/platform-tbblue/tricks.s b/Kernel/platform-tbblue/tricks.s index 62cfb047..9f24c913 100644 --- a/Kernel/platform-tbblue/tricks.s +++ b/Kernel/platform-tbblue/tricks.s @@ -24,7 +24,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -46,7 +46,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -90,7 +90,7 @@ _switchin: ; ------- No stack ------- ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail @@ -106,7 +106,7 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ---- New task stack ---- @@ -115,7 +115,7 @@ _switchin: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -165,7 +165,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -218,7 +218,7 @@ fork_copy: ; DE is now the 8 page pointers for the child - ld hl, (U_DATA__U_PAGE) ; pointer to banks of parent + ld hl, (_udata + U_DATA__U_PAGE) ; pointer to banks of parent ; HL for the parent diff --git a/Kernel/platform-tc2068/crt0.s b/Kernel/platform-tc2068/crt0.s index ab70d163..cddddc59 100644 --- a/Kernel/platform-tc2068/crt0.s +++ b/Kernel/platform-tc2068/crt0.s @@ -58,8 +58,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; ; startup code diff --git a/Kernel/platform-tc2068/tc2068.s b/Kernel/platform-tc2068/tc2068.s index 1409895c..fe441d24 100644 --- a/Kernel/platform-tc2068/tc2068.s +++ b/Kernel/platform-tc2068/tc2068.s @@ -48,7 +48,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (below 0x4000) diff --git a/Kernel/platform-tc2068/tricks.s b/Kernel/platform-tc2068/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-tc2068/tricks.s +++ b/Kernel/platform-tc2068/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-trs80/kernel.def b/Kernel/platform-trs80/kernel.def index 9e704d69..fb6f7166 100644 --- a/Kernel/platform-trs80/kernel.def +++ b/Kernel/platform-trs80/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xE800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 (we don't save istack) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 @ E800 U_DATA_STASH .equ 0x7E00 ; 7E00-7FFF diff --git a/Kernel/platform-trs80/tricks.s b/Kernel/platform-trs80/tricks.s index ee50c077..891ef430 100644 --- a/Kernel/platform-trs80/tricks.s +++ b/Kernel/platform-trs80/tricks.s @@ -1,5 +1,5 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-trs80/trs80-bank.s b/Kernel/platform-trs80/trs80-bank.s index 5259b58b..76d59aec 100644 --- a/Kernel/platform-trs80/trs80-bank.s +++ b/Kernel/platform-trs80/trs80-bank.s @@ -29,7 +29,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; KERNEL MEMORY BANK (below 0xE800, only accessible when the kernel is mapped) @@ -190,7 +190,7 @@ map_process_always: map_process_always_di: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_process_hl pop hl pop af diff --git a/Kernel/platform-trs80/trs80.s b/Kernel/platform-trs80/trs80.s index 3c1448c1..78e7a5dc 100644 --- a/Kernel/platform-trs80/trs80.s +++ b/Kernel/platform-trs80/trs80.s @@ -44,7 +44,7 @@ .globl _bufpool .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _BUFFERS diff --git a/Kernel/platform-trs80m1/kernel.def b/Kernel/platform-trs80m1/kernel.def index 14070340..fc9197c5 100644 --- a/Kernel/platform-trs80m1/kernel.def +++ b/Kernel/platform-trs80m1/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0x4100 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 (we don't save istack) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 @4100 U_DATA_STASH .equ 0xFE00 ; FE00-FFFF diff --git a/Kernel/platform-trs80m1/stringy.s b/Kernel/platform-trs80m1/stringy.s index 7ab58b41..edc07d24 100644 --- a/Kernel/platform-trs80m1/stringy.s +++ b/Kernel/platform-trs80m1/stringy.s @@ -4,7 +4,7 @@ .globl _tape_err .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM diff --git a/Kernel/platform-trs80m1/tricks.s b/Kernel/platform-trs80m1/tricks.s index 4925f252..ed5dc327 100644 --- a/Kernel/platform-trs80m1/tricks.s +++ b/Kernel/platform-trs80m1/tricks.s @@ -1,6 +1,6 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank-banked.s" diff --git a/Kernel/platform-trs80m1/trs80-bank.s b/Kernel/platform-trs80m1/trs80-bank.s index 9b7db3d6..8bf69b5d 100644 --- a/Kernel/platform-trs80m1/trs80-bank.s +++ b/Kernel/platform-trs80m1/trs80-bank.s @@ -47,7 +47,7 @@ .globl __uzero .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; KERNEL MEMORY BANK (above 08000, only accessible when the kernel is mapped) @@ -241,7 +241,7 @@ map_process_always_di: push bc ld bc, (map_reg) ld (ksave_map), bc - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) ld b,a ld (map_reg),bc out (c),b @@ -486,7 +486,7 @@ __uput: ; Use helper as NMOS Z80 has bugs in this area call ___hard_di ; Our banks - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) ld c, a ld a, (map_bank2 + 1) ; kernel is source ld b, a @@ -513,7 +513,7 @@ __uget: jr z, uput_out exx call ___hard_di - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) ld b, a ld a, (map_bank2 + 1) ; kernel is destination ld c, a diff --git a/Kernel/platform-trs80m1/trs80.s b/Kernel/platform-trs80m1/trs80.s index 4d5ca7b0..7c63dfe3 100644 --- a/Kernel/platform-trs80m1/trs80.s +++ b/Kernel/platform-trs80m1/trs80.s @@ -50,7 +50,7 @@ .globl mapper_init .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0x4000 upwards after the udata etc) diff --git a/Kernel/platform-ubee/kernel.def b/Kernel/platform-ubee/kernel.def index 49a56f93..306b42cd 100644 --- a/Kernel/platform-ubee/kernel.def +++ b/Kernel/platform-ubee/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@F000 U_DATA_STASH .equ 0x7E00 ; 7E00-7FFF diff --git a/Kernel/platform-ubee/tricks.s b/Kernel/platform-ubee/tricks.s index ee50c077..891ef430 100644 --- a/Kernel/platform-ubee/tricks.s +++ b/Kernel/platform-ubee/tricks.s @@ -1,5 +1,5 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-ubee/ubee.s b/Kernel/platform-ubee/ubee.s index e19541d4..264d5829 100644 --- a/Kernel/platform-ubee/ubee.s +++ b/Kernel/platform-ubee/ubee.s @@ -47,7 +47,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ; Buffers (we use asm to set this up as we need them in a special segment @@ -394,7 +394,7 @@ map_process_always: map_process_always_di: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_process_hl pop hl pop af diff --git a/Kernel/platform-yaz180/kernel.def b/Kernel/platform-yaz180/kernel.def index c36d8ae6..4e0630c0 100644 --- a/Kernel/platform-yaz180/kernel.def +++ b/Kernel/platform-yaz180/kernel.def @@ -1,8 +1,7 @@ ; UZI mnemonics for memory addresses etc ; Move down to 0xF600 to fit the monitor in -U_DATA .equ 0xF800 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@F800 Z80_TYPE .equ 2 OS_BANK .equ 0x00 ; value from include/kernel.h diff --git a/Kernel/platform-yaz180/yaz180.s b/Kernel/platform-yaz180/yaz180.s index 98da09f1..f9bcdc52 100644 --- a/Kernel/platform-yaz180/yaz180.s +++ b/Kernel/platform-yaz180/yaz180.s @@ -20,7 +20,7 @@ .include "kernel.def" .include "../cpu-z180/z180.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; Buffers diff --git a/Kernel/platform-z280rc/devtty.c b/Kernel/platform-z280rc/devtty.c index b32bb6cf..d747f06f 100644 --- a/Kernel/platform-z280rc/devtty.c +++ b/Kernel/platform-z280rc/devtty.c @@ -22,7 +22,19 @@ __sfr __at 0x18 uart_tdr; /* * One buffer for each tty. For now just the console */ -static char tbuf1[TTYSIZ]; +static unsigned char tbuf1[TTYSIZ]; + +static tcflag_t console_mask[4] = { + _ISYS, + _OSYS, + _CSYS, + _LSYS +}; + +tcflag_t *termios_mask[NUM_DEV_TTY + 1] = { + NULL, + console_mask +}; /* * One entry per tty. The 0th entry is never used as tty minor 0 is diff --git a/Kernel/platform-z280rc/kernel.def b/Kernel/platform-z280rc/kernel.def index 5765fb52..1866f880 100644 --- a/Kernel/platform-z280rc/kernel.def +++ b/Kernel/platform-z280rc/kernel.def @@ -5,8 +5,7 @@ ; of common memory. We do actually have a symbol for udata so ; eventually this needs to go away ; -U_DATA .equ 0xE000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes) +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes@E000 ; ; Space for the udata of a switched out process within the bank of ; memory that it uses. Normally placed at the very top diff --git a/Kernel/platform-z280rc/tricks.s b/Kernel/platform-z280rc/tricks.s index 1eaafcaa..e9a384a2 100644 --- a/Kernel/platform-z280rc/tricks.s +++ b/Kernel/platform-z280rc/tricks.s @@ -7,7 +7,7 @@ ; approach. The morbidly curious can read the TRS80 model 1 bank to ; bank copier. ; - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-z280rc/z280rc.s b/Kernel/platform-z280rc/z280rc.s index d483aefa..499e69ed 100644 --- a/Kernel/platform-z280rc/z280rc.s +++ b/Kernel/platform-z280rc/z280rc.s @@ -4,7 +4,7 @@ ; Minimal for now to get us up and running ; - .module sbcv2 + .module z280rc ; exported symbols .globl init_early @@ -50,7 +50,7 @@ .globl l__COMMONMEM .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ; Buffers (we use asm to set this up as we need them in a special segment @@ -314,7 +314,7 @@ map_process_always: map_process_always_di: push af push hl - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE call map_process_hl pop hl pop af @@ -691,7 +691,7 @@ sig_or_die: ld a,(_inint) or a jr nz, diediedie - ld a,(U_DATA__U_INSYS) + ld a,(_udata + U_DATA__U_INSYS) or a jr nz, diediedie ; TODO - we need to go via the syscall signal path as we need this diff --git a/Kernel/platform-z80pack-lite/kernel.def b/Kernel/platform-z80pack-lite/kernel.def index e0b4d9d5..3e83feae 100644 --- a/Kernel/platform-z80pack-lite/kernel.def +++ b/Kernel/platform-z80pack-lite/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes@F000 Z80_TYPE .equ 0 PROGBASE .equ 0x0000 diff --git a/Kernel/platform-z80pack-lite/tricks.s b/Kernel/platform-z80pack-lite/tricks.s index aa6f9ee3..1368e446 100644 --- a/Kernel/platform-z80pack-lite/tricks.s +++ b/Kernel/platform-z80pack-lite/tricks.s @@ -26,7 +26,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -50,7 +50,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -110,7 +110,7 @@ _switchin: ld (hl), a not_swapped: ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail @@ -120,14 +120,14 @@ not_swapped: add hl, de ld (hl), #P_RUNNING - ld (U_DATA__U_PAGE), a ; save page offset + ld (_udata + U_DATA__U_PAGE), a ; save page offset ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ld hl, #0 add hl, sp @@ -137,7 +137,7 @@ not_swapped: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) or a ret z ; in ISR, leave interrupts off ei @@ -186,17 +186,17 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. ; --------- copy process --------- - ld hl, #U_DATA__U_PAGE + ld hl, #_udata + U_DATA__U_PAGE ld a, (hl) call map_process_a - ld hl, (U_DATA__U_PTAB) + ld hl, (_udata + U_DATA__U_PTAB) push hl call _swapout pop de diff --git a/Kernel/platform-z80pack-lite/z80pack.s b/Kernel/platform-z80pack-lite/z80pack.s index 59669880..c32e7298 100644 --- a/Kernel/platform-z80pack-lite/z80pack.s +++ b/Kernel/platform-z80pack-lite/z80pack.s @@ -51,10 +51,10 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- -; COMMON MEMORY BANK (0xF000 upwards) +; COMMON MEMORY BANK ; ----------------------------------------------------------------------------- .area _COMMONMEM diff --git a/Kernel/platform-z80pack/kernel.def b/Kernel/platform-z80pack/kernel.def index 7f47cd14..6cb4f541 100644 --- a/Kernel/platform-z80pack/kernel.def +++ b/Kernel/platform-z80pack/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xF400 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F400 U_DATA_STASH .equ 0xEE00 ; EE00-EFFF diff --git a/Kernel/platform-z80pack/tricks.s b/Kernel/platform-z80pack/tricks.s index ee50c077..891ef430 100644 --- a/Kernel/platform-z80pack/tricks.s +++ b/Kernel/platform-z80pack/tricks.s @@ -1,5 +1,5 @@ - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-z80pack/z80pack.s b/Kernel/platform-z80pack/z80pack.s index 5a2b90e4..72c96c54 100644 --- a/Kernel/platform-z80pack/z80pack.s +++ b/Kernel/platform-z80pack/z80pack.s @@ -61,7 +61,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (0xF000 upwards) @@ -208,7 +208,7 @@ map_process_a: map_process_always: map_process_always_di: push af - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) out (21), a pop af ret @@ -264,7 +264,7 @@ do_mmu_kernel: ; something bad has happened to our process (or the kernel) ; badstack: - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, badbadstack ld a, (_inint) @@ -296,7 +296,7 @@ badbadstack: call _panic badstackifu: - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, do_mmu_kernel ld a, (_inint) @@ -329,12 +329,12 @@ do_mmu_kernel_irq: ld (mmusave),a jp mmu_irq_ret - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a ld a, (_inint) or a badstackirq: - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, badbadstack_irq ld a, (_inint) @@ -356,7 +356,7 @@ badstack_doirq: call map_save_kernel ld hl,#9 push hl - ld hl,(U_DATA__U_PTAB) + ld hl,(_udata + U_DATA__U_PTAB) push hl call _ssig pop hl @@ -376,7 +376,7 @@ badstack_doirq: ; This will complete the IRQ and then hit preemption at which ; point it'll call switchout, chksigs and vanish forever badstackirqifu: - ld a, (U_DATA__U_INSYS) + ld a, (_udata + U_DATA__U_INSYS) or a jr nz, do_mmu_kernel_irq ld a, (_inint) diff --git a/Kernel/platform-zeta-v2/devrd_zeta2_hw.s b/Kernel/platform-zeta-v2/devrd_zeta2_hw.s index 05b2f861..ce166c91 100644 --- a/Kernel/platform-zeta-v2/devrd_zeta2_hw.s +++ b/Kernel/platform-zeta-v2/devrd_zeta2_hw.s @@ -14,8 +14,8 @@ .globl _devmem_read .globl _devmem_write - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" .area _CODE _devmem_write: @@ -30,13 +30,13 @@ _devmem_read: _devmem_go: ld (_rd_dst_userspace), a ; 1 = userspace ; load the other parameters - ld hl, (U_DATA__U_BASE) + ld hl, (_udata + U_DATA__U_BASE) ld (_rd_dst_address), hl - ld hl, (U_DATA__U_OFFSET) + ld hl, (_udata + U_DATA__U_OFFSET) ld (_rd_src_address), hl - ld hl, (U_DATA__U_OFFSET+2) + ld hl, (_udata + U_DATA__U_OFFSET+2) ld (_rd_src_address+2), hl - ld hl, (U_DATA__U_COUNT) + ld hl, (_udata + U_DATA__U_COUNT) ld (_rd_cpy_count), hl ; for single byte transfers we can optimise away the outer loop dec l ; test for HL=1 @@ -95,7 +95,7 @@ _rd_page_copy: ld hl, #_kernel_pages ; get kernel page table jr rd_do_translate rd_translate_userspace: - ld hl, #U_DATA__U_PAGE ; get user process page table + ld hl, #_udata + U_DATA__U_PAGE ; get user process page table rd_do_translate: add hl, bc ; add index to base ptr (uint8_t *) ld a, (hl) ; load the page number from the page table diff --git a/Kernel/platform-zeta-v2/ds1302-n8vem.s b/Kernel/platform-zeta-v2/ds1302-n8vem.s index 87a95bcd..df0e41b3 100644 --- a/Kernel/platform-zeta-v2/ds1302-n8vem.s +++ b/Kernel/platform-zeta-v2/ds1302-n8vem.s @@ -15,7 +15,7 @@ .globl _ds1302_get_pin_data .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; DS1302 interface diff --git a/Kernel/platform-zeta-v2/kernel.def b/Kernel/platform-zeta-v2/kernel.def index c63ed2b8..54146ffc 100644 --- a/Kernel/platform-zeta-v2/kernel.def +++ b/Kernel/platform-zeta-v2/kernel.def @@ -1,7 +1,6 @@ ; FUZIX mnemonics for memory addresses etc -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@F000 Z80_TYPE .equ 0 ; just an old good Z80 USE_FANCY_MONITOR .equ 1 ; disabling this saves around approx 0.5KB diff --git a/Kernel/platform-zeta-v2/tricks.s b/Kernel/platform-zeta-v2/tricks.s index b7f6d3dd..733e712e 100644 --- a/Kernel/platform-zeta-v2/tricks.s +++ b/Kernel/platform-zeta-v2/tricks.s @@ -1,7 +1,7 @@ .module tricks .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" TOP_PORT .equ MPGSEL_3 @@ -27,7 +27,7 @@ fork_copy: ld de, #P_TAB__P_PAGE_OFFSET add hl, de ; hl now points into the child pages - ld de, #U_DATA__U_PAGE + ld de, #_udata + U_DATA__U_PAGE ; and de is the parent fork_next: ld a,(hl) diff --git a/Kernel/platform-zeta-v2/zeta-v2.s b/Kernel/platform-zeta-v2/zeta-v2.s index f85dd38e..a0050b62 100644 --- a/Kernel/platform-zeta-v2/zeta-v2.s +++ b/Kernel/platform-zeta-v2/zeta-v2.s @@ -41,7 +41,7 @@ .globl outchar .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ;========================================================================= ; Constants @@ -242,7 +242,7 @@ _program_vectors: map_process_always: map_process_always_di: push hl - ld hl,#U_DATA__U_PAGE + ld hl,#_udata + U_DATA__U_PAGE jr map_process_2_pophl_ret ;========================================================================= diff --git a/Kernel/platform-zx+3/crt0.s b/Kernel/platform-zx+3/crt0.s index 0a05f8c3..913d6792 100644 --- a/Kernel/platform-zx+3/crt0.s +++ b/Kernel/platform-zx+3/crt0.s @@ -67,8 +67,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; ; startup code diff --git a/Kernel/platform-zx+3/fdc765.s b/Kernel/platform-zx+3/fdc765.s index f1108174..3da52536 100644 --- a/Kernel/platform-zx+3/fdc765.s +++ b/Kernel/platform-zx+3/fdc765.s @@ -31,7 +31,7 @@ .module fdc765 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .globl map_process_always .globl map_kernel diff --git a/Kernel/platform-zx+3/kernel.def b/Kernel/platform-zx+3/kernel.def index 3b0c8c89..d061dd72 100644 --- a/Kernel/platform-zx+3/kernel.def +++ b/Kernel/platform-zx+3/kernel.def @@ -1,8 +1,7 @@ ; UZI mnemonics for memory addresses etc ; We stick it straight after the tag -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256@F000 Z80_TYPE .equ 1 diff --git a/Kernel/platform-zx+3/plus3.s b/Kernel/platform-zx+3/plus3.s index f571c20e..17a05aac 100644 --- a/Kernel/platform-zx+3/plus3.s +++ b/Kernel/platform-zx+3/plus3.s @@ -49,7 +49,7 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (below 0x4000) diff --git a/Kernel/platform-zx+3/tricks.s b/Kernel/platform-zx+3/tricks.s index 0113d75b..a4678ac2 100644 --- a/Kernel/platform-zx+3/tricks.s +++ b/Kernel/platform-zx+3/tricks.s @@ -1,5 +1,5 @@ .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .include "../lib/z80single.s" diff --git a/Kernel/platform-zx128/kernel.def b/Kernel/platform-zx128/kernel.def index 9f291469..c57e918a 100644 --- a/Kernel/platform-zx128/kernel.def +++ b/Kernel/platform-zx128/kernel.def @@ -1,7 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0x4000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @4000 U_DATA_STASH .equ 0xFD00 ; FD00-FEFF diff --git a/Kernel/platform-zx128/tricks.s b/Kernel/platform-zx128/tricks.s index 612e7845..eae6d50a 100644 --- a/Kernel/platform-zx128/tricks.s +++ b/Kernel/platform-zx128/tricks.s @@ -26,7 +26,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -44,7 +44,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; ; We are now running on the sleeping process stack. The switchin @@ -53,14 +53,14 @@ _platform_switchout: ; ; Stash the uarea back into process memory - ld hl, (U_DATA__U_PAGE) + ld hl, (_udata + U_DATA__U_PAGE) ld a, l ld bc, #0x7ffd or #0x18 out (c), a ; This includes the stacks, so be careful on restore - ld hl, #U_DATA + ld hl, #_udata ld de, #U_DATA_STASH ld bc, #U_DATA__TOTALSIZE ldir @@ -147,7 +147,7 @@ not_swapped: ; exx ld hl, #U_DATA_STASH - ld de, #U_DATA + ld de, #_udata ld bc, #U_DATA__TOTALSIZE ldir exx @@ -205,27 +205,27 @@ flip1: nofliplow: ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab or a ; clear carry flag sbc hl, de ; subtract, result will be zero if DE == HL jr nz, switchinfail ; wants optimising up a bit - ld ix, (U_DATA__U_PTAB) + ld ix, (_udata + U_DATA__U_PTAB) ; next_process->p_status = P_RUNNING ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ; Fix any moved page pointers ; Just do one byte as that is all we use on this platform ld a, P_TAB__P_PAGE_OFFSET(ix) - ld (U_DATA__U_PAGE), a + ld (_udata + U_DATA__U_PAGE), a ; runticks = 0 ld hl, #0 ld (_runticks), hl ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ; We can now use the stack again @@ -236,7 +236,7 @@ nofliplow: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) or a ret nz ; in ISR, leave interrupts off ei @@ -304,7 +304,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -320,7 +320,7 @@ _dofork: add hl, de ; load p_page ld c, (hl) - ld hl, (U_DATA__U_PAGE) + ld hl, (_udata + U_DATA__U_PAGE) ld a, l ; @@ -343,7 +343,7 @@ _dofork: ; Copy done - ld a, (U_DATA__U_PAGE) ; parent memory + ld a, (_udata + U_DATA__U_PAGE) ; parent memory or #0x18 ; get the right ROMs ld bc, #0x7ffd out (c), a ; Switch context to parent in 0xC000+ @@ -351,7 +351,7 @@ _dofork: ; We are going to copy the uarea into the parents uarea stash ; we must not touch the parent uarea after this point, any ; changes only affect the child - ld hl, #U_DATA ; copy the udata from common into the + ld hl, #_udata ; copy the udata from common into the ld de, #U_DATA_STASH ; target process ld bc, #U_DATA__TOTALSIZE ldir diff --git a/Kernel/platform-zx128/zx128.s b/Kernel/platform-zx128/zx128.s index e3a3f996..af172328 100644 --- a/Kernel/platform-zx128/zx128.s +++ b/Kernel/platform-zx128/zx128.s @@ -227,7 +227,7 @@ map_process_always: push af ld a, (current_map) ld (ksave_map), a - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call switch_bank pop af ret diff --git a/Kernel/platform-zxdiv/crt0.s b/Kernel/platform-zxdiv/crt0.s index 5e8b28bf..73faaed7 100644 --- a/Kernel/platform-zxdiv/crt0.s +++ b/Kernel/platform-zxdiv/crt0.s @@ -54,8 +54,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; startup code ; diff --git a/Kernel/platform-zxdiv/kernel.def b/Kernel/platform-zxdiv/kernel.def index eb78b329..14a8a7ae 100644 --- a/Kernel/platform-zxdiv/kernel.def +++ b/Kernel/platform-zxdiv/kernel.def @@ -1,8 +1,7 @@ ; UZI mnemonics for memory addresses etc ; We stick it straight after the tag -U_DATA .equ 0x2204 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 @ 2204 U_DATA_STASH .equ 0xFE00 ; FE00-FFFF diff --git a/Kernel/platform-zxdiv/zx128.s b/Kernel/platform-zxdiv/zx128.s index 51bb8cbb..b6dc8fd5 100644 --- a/Kernel/platform-zxdiv/zx128.s +++ b/Kernel/platform-zxdiv/zx128.s @@ -69,7 +69,7 @@ .globl __stub_3_2 .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- ; COMMON MEMORY BANK (below 0xC000) @@ -181,7 +181,7 @@ map_process_always_di: push af ld a, (current_map) ld (ksave_map), a - ld a, (U_DATA__U_PAGE) + ld a, (_udata + U_DATA__U_PAGE) call switch_bank pop af ret diff --git a/Kernel/platform-zxevo/crt0.s b/Kernel/platform-zxevo/crt0.s index 6fddbb05..3dae7d34 100644 --- a/Kernel/platform-zxevo/crt0.s +++ b/Kernel/platform-zxevo/crt0.s @@ -49,8 +49,8 @@ .globl nmi_handler .globl interrupt_handler - .include "../kernel.def" .include "kernel.def" + .include "../kernel-z80.def" ; ; startup code. Runs from 0x100. The kernel is mapped into pages diff --git a/Kernel/platform-zxevo/kernel.def b/Kernel/platform-zxevo/kernel.def index 849a7684..8875f9c8 100644 --- a/Kernel/platform-zxevo/kernel.def +++ b/Kernel/platform-zxevo/kernel.def @@ -1,5 +1,4 @@ -U_DATA .equ 0xF000 ; (this is struct u_data from kernel.h) -U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes. +U_DATA__TOTALSIZE .equ 0x200 ; 256+256 bytes @ F000 Z80_TYPE .equ 1 diff --git a/Kernel/platform-zxevo/tricks.s b/Kernel/platform-zxevo/tricks.s index d4ee7e17..8547f813 100644 --- a/Kernel/platform-zxevo/tricks.s +++ b/Kernel/platform-zxevo/tricks.s @@ -23,7 +23,7 @@ .globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" .area _COMMONMEM @@ -50,7 +50,7 @@ _platform_switchout: push hl ; return code push ix push iy - ld (U_DATA__U_SP), sp ; this is where the SP is restored in _switchin + ld (_udata + U_DATA__U_SP), sp ; this is where the SP is restored in _switchin ; find another process to run (may select this one again) call _getproc @@ -86,7 +86,7 @@ _switchin: ; ------- No stack ------- ; check u_data->u_ptab matches what we wanted - ld hl, (U_DATA__U_PTAB) ; u_data->u_ptab + ld hl, (_udata + U_DATA__U_PTAB) ; u_data->u_ptab sbc hl, de ; subtract, result will be zero if DE==IX jr nz, switchinfail @@ -101,7 +101,7 @@ _switchin: ; restore machine state -- note we may be returning from either ; _switchout or _dofork - ld sp, (U_DATA__U_SP) + ld sp, (_udata + U_DATA__U_SP) ; ---- New task stack ---- @@ -110,7 +110,7 @@ _switchin: pop hl ; return code ; enable interrupts, if the ISR isn't already running - ld a, (U_DATA__U_ININTERRUPT) + ld a, (_udata + U_DATA__U_ININTERRUPT) ld (_int_disabled),a or a ret nz ; in ISR, leave interrupts off @@ -160,7 +160,7 @@ _dofork: ; _switchin which will immediately return (appearing to be _dofork() ; returning) and with HL (ie return code) containing the child PID. ; Hurray. - ld (U_DATA__U_SP), sp + ld (_udata + U_DATA__U_SP), sp ; now we're in a safe state for _switchin to return in the parent ; process. @@ -199,7 +199,7 @@ _dofork: ret fork_copy: - ld hl, (U_DATA__U_TOP) + ld hl, (_udata + U_DATA__U_TOP) ld de, #0x0fff add hl, de ; + 0x1000 (-1 for the rounding to follow) ld a, h @@ -214,7 +214,7 @@ fork_copy: ld de, #P_TAB__P_PAGE_OFFSET add hl, de ; hl now points into the child pages - ld de, #U_DATA__U_PAGE + ld de, #_udata + U_DATA__U_PAGE ; and de is the parent fork_next: diff --git a/Kernel/platform-zxevo/zxevo.s b/Kernel/platform-zxevo/zxevo.s index dc33ad99..316403b4 100644 --- a/Kernel/platform-zxevo/zxevo.s +++ b/Kernel/platform-zxevo/zxevo.s @@ -48,10 +48,10 @@ .globl outstringhex .include "kernel.def" - .include "../kernel.def" + .include "../kernel-z80.def" ; ----------------------------------------------------------------------------- -; COMMON MEMORY BANK (above 0xE000) +; COMMON MEMORY BANK ; ----------------------------------------------------------------------------- .area _COMMONMEM @@ -83,7 +83,7 @@ _vtborder: ; needs to be common ; ----------------------------------------------------------------------------- -; KERNEL CODE BANK (below 0xC000, only accessible when the kernel is mapped) +; KERNEL CODE BANK (only accessible when the kernel is mapped) ; ----------------------------------------------------------------------------- .area _CODE @@ -169,7 +169,7 @@ map_process_always_di: push af push bc push hl - ld hl,(U_DATA__U_PAGE) + ld hl,(_udata + U_DATA__U_PAGE) map_write_hl: ld (current_map),hl ; diff --git a/Kernel/usermem_std-z80-banked.s b/Kernel/usermem_std-z80-banked.s index 7eac765a..cce04ece 100644 --- a/Kernel/usermem_std-z80-banked.s +++ b/Kernel/usermem_std-z80-banked.s @@ -7,7 +7,7 @@ .module usermem .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; exported symbols .globl __uget diff --git a/Kernel/usermem_std-z80-thunked.s b/Kernel/usermem_std-z80-thunked.s index 2e743629..38470125 100644 --- a/Kernel/usermem_std-z80-thunked.s +++ b/Kernel/usermem_std-z80-thunked.s @@ -1,7 +1,7 @@ .module usermem32 .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; exported symbols .globl __uget @@ -116,7 +116,7 @@ uputget: ld e, 6(ix) ld d, 7(ix) ; And now load ix with our paging pointer - ld ix,#U_DATA__U_PAGE + ld ix,#_udata + U_DATA__U_PAGE ret __uget: @@ -168,7 +168,7 @@ __uzero: or c ret z push ix - ld ix,#U_DATA__U_PAGE + ld ix,#_udata + U_DATA__U_PAGE call user_mapping jr z, zeroit_1 call zeroit @@ -197,9 +197,9 @@ __ugetc: push hl push bc bit 7,h - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) jr z, ugetcl - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) res 7,h ugetcl: call map_page_low @@ -216,7 +216,7 @@ __ugetw: bit 7,h jr z, ugetwl ; High page - no wrap possible - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) call map_page_low res 7,h ld a,(hl) @@ -228,7 +228,7 @@ normal_wl: jp map_kernel_low ugetwl: ; Low page - we might be fetching 7FFF/8000 - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) call map_page_low ld a,(hl) inc hl @@ -236,7 +236,7 @@ ugetwl: jr z, normal_wl ; No split ; We fetched 7FFF/8000 ld l,a - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) call map_page_low ld a,(0) ; Split can only mean one address ld h,a @@ -250,9 +250,9 @@ __uputc: push de push bc bit 7,h - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) jr z, uputcl - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) res 7,h uputcl: call map_page_low @@ -268,7 +268,7 @@ __uputw: push bc bit 7,h jr z, uputwl - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) call map_page_low res 7,h ld (hl),e @@ -277,13 +277,13 @@ normal_pwl: ld (hl),d jp map_kernel_low uputwl: - ld a,(U_DATA__U_PAGE) + ld a,(_udata + U_DATA__U_PAGE) call map_page_low ld (hl),e inc hl bit 7,h jr z, normal_pwl - ld a,(U_DATA__U_PAGE + 1) + ld a,(_udata + U_DATA__U_PAGE + 1) call map_page_low ld a,d ld (0),a ; Split can only mean one address diff --git a/Kernel/usermem_std-z80.s b/Kernel/usermem_std-z80.s index 94d38505..4adffabb 100644 --- a/Kernel/usermem_std-z80.s +++ b/Kernel/usermem_std-z80.s @@ -7,7 +7,7 @@ .module usermem .include "platform/kernel.def" - .include "kernel.def" + .include "kernel-z80.def" ; exported symbols .globl __uget