z80/rabbit: The big rearrange of U_DATA to _udata offsets
authorAlan Cox <alan@linux.intel.com>
Wed, 20 Feb 2019 00:29:12 +0000 (00:29 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 20 Feb 2019 00:29:12 +0000 (00:29 +0000)
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.

166 files changed:
Kernel/cpu-z180/z180.s
Kernel/dev/devfd_hw.s
Kernel/dev/devrd_hw.s
Kernel/dev/devrd_z180_hw.s
Kernel/dev/ds1302_rbc.s
Kernel/dev/ds1302_rc2014.s
Kernel/dev/rbcfd9266_hw.s
Kernel/dev/z80softspi.s
Kernel/dev/zx/tricks.s
Kernel/kernel-rabbit.def
Kernel/kernel-z80.def [new file with mode: 0644]
Kernel/lib/z80bank16.s
Kernel/lib/z80fixedbank-banked.s
Kernel/lib/z80fixedbank-core.s
Kernel/lib/z80single.s
Kernel/lowlevel-r2k.s
Kernel/lowlevel-z80-banked.s
Kernel/lowlevel-z80-thunked.s
Kernel/lowlevel-z80.s
Kernel/platform-amstradnc/fdc765.s
Kernel/platform-amstradnc/nc100.s
Kernel/platform-amstradnc/nc100/kernel.def
Kernel/platform-amstradnc/nc200/kernel.def
Kernel/platform-amstradnc/tricks.s
Kernel/platform-cromemco/cromemco.s
Kernel/platform-cromemco/crt0.s
Kernel/platform-cromemco/kernel.def
Kernel/platform-cromemco/tricks.s
Kernel/platform-cromemco/usermem.s
Kernel/platform-genie-eg64/crt0.s
Kernel/platform-genie-eg64/kernel.def
Kernel/platform-genie-eg64/tricks.s
Kernel/platform-genie-eg64/trs80-bank.s
Kernel/platform-genie-eg64/trs80.s
Kernel/platform-linc80/linc80.s
Kernel/platform-linc80/tricks.s
Kernel/platform-micropack/kernel.def
Kernel/platform-micropack/tricks.s
Kernel/platform-micropack/z80pack.s
Kernel/platform-msx1/kernel.def
Kernel/platform-msx1/msx1.s
Kernel/platform-msx1/slots.s
Kernel/platform-msx1/tricks.s
Kernel/platform-msx1/vdp.s
Kernel/platform-msx2/kernel.def
Kernel/platform-msx2/msx2.s
Kernel/platform-msx2/tricks.s
Kernel/platform-mtx/kernel.def
Kernel/platform-mtx/mtx.s
Kernel/platform-mtx/tricks.s
Kernel/platform-mtx/vdp.s
Kernel/platform-n8vem-mark4/ds1302-mark4.s
Kernel/platform-n8vem-mark4/kernel.def
Kernel/platform-n8vem-mark4/mark4.s
Kernel/platform-nascom/gm833.s
Kernel/platform-nascom/gm849a_sasi.s
Kernel/platform-nascom/gm8x9.s
Kernel/platform-nascom/henelec.s
Kernel/platform-nascom/kernel.def
Kernel/platform-nascom/nascom-pagemode.s
Kernel/platform-nascom/nascom.s
Kernel/platform-nascom/tricks.s
Kernel/platform-p112/ds1302-p112.s
Kernel/platform-p112/kernel.def
Kernel/platform-p112/p112.s
Kernel/platform-pcw8256/README
Kernel/platform-pcw8256/config.h
Kernel/platform-pcw8256/crt0.s
Kernel/platform-pcw8256/devtty.c
Kernel/platform-pcw8256/fuzix.lnk
Kernel/platform-pcw8256/kernel.def
Kernel/platform-pcw8256/main.c
Kernel/platform-pcw8256/pcw8256.s
Kernel/platform-pcw8256/tricks.s
Kernel/platform-pentagon/crt0.s
Kernel/platform-pentagon/kernel.def
Kernel/platform-pentagon/pentagon.s
Kernel/platform-px4plus/kernel.def
Kernel/platform-px4plus/px4plus.s
Kernel/platform-px4plus/tricks.s
Kernel/platform-rabbit2000/kernel.def
Kernel/platform-rabbit2000/rabbit.s
Kernel/platform-rc2014-sbc64/rc2014.s
Kernel/platform-rc2014-sbc64/tricks.s
Kernel/platform-rc2014-tiny/kernel.def
Kernel/platform-rc2014-tiny/rc2014.s
Kernel/platform-rc2014-tiny/tricks.s
Kernel/platform-rc2014/buffers.s
Kernel/platform-rc2014/devrd_zeta2_hw.s
Kernel/platform-rc2014/kernel.def
Kernel/platform-rc2014/rc2014.s
Kernel/platform-rc2014/tricks.s
Kernel/platform-rc2014/vfdterm.s
Kernel/platform-sam/atom.s
Kernel/platform-sam/kernel.def
Kernel/platform-sam/sam.s
Kernel/platform-sam/tricks.s
Kernel/platform-sbcv2/kernel.def
Kernel/platform-sbcv2/sbcv2.s
Kernel/platform-sbcv2/tricks.s
Kernel/platform-sc108/kernel.def
Kernel/platform-sc108/sc108.s
Kernel/platform-sc108/tricks.s
Kernel/platform-sc108/usermem.s
Kernel/platform-sc114/sc114.s
Kernel/platform-sc114/tricks.s
Kernel/platform-sc114/usermem.s
Kernel/platform-socz80/commonmem.s
Kernel/platform-socz80/kernel.def
Kernel/platform-socz80/socz80.s
Kernel/platform-socz80/tricks.s
Kernel/platform-socz80/usermem.s
Kernel/platform-tbblue/crt0.s
Kernel/platform-tbblue/kernel.def
Kernel/platform-tbblue/tbblue.s
Kernel/platform-tbblue/tricks.s
Kernel/platform-tc2068/crt0.s
Kernel/platform-tc2068/tc2068.s
Kernel/platform-tc2068/tricks.s
Kernel/platform-trs80/kernel.def
Kernel/platform-trs80/tricks.s
Kernel/platform-trs80/trs80-bank.s
Kernel/platform-trs80/trs80.s
Kernel/platform-trs80m1/kernel.def
Kernel/platform-trs80m1/stringy.s
Kernel/platform-trs80m1/tricks.s
Kernel/platform-trs80m1/trs80-bank.s
Kernel/platform-trs80m1/trs80.s
Kernel/platform-ubee/kernel.def
Kernel/platform-ubee/tricks.s
Kernel/platform-ubee/ubee.s
Kernel/platform-yaz180/kernel.def
Kernel/platform-yaz180/yaz180.s
Kernel/platform-z280rc/devtty.c
Kernel/platform-z280rc/kernel.def
Kernel/platform-z280rc/tricks.s
Kernel/platform-z280rc/z280rc.s
Kernel/platform-z80pack-lite/kernel.def
Kernel/platform-z80pack-lite/tricks.s
Kernel/platform-z80pack-lite/z80pack.s
Kernel/platform-z80pack/kernel.def
Kernel/platform-z80pack/tricks.s
Kernel/platform-z80pack/z80pack.s
Kernel/platform-zeta-v2/devrd_zeta2_hw.s
Kernel/platform-zeta-v2/ds1302-n8vem.s
Kernel/platform-zeta-v2/kernel.def
Kernel/platform-zeta-v2/tricks.s
Kernel/platform-zeta-v2/zeta-v2.s
Kernel/platform-zx+3/crt0.s
Kernel/platform-zx+3/fdc765.s
Kernel/platform-zx+3/kernel.def
Kernel/platform-zx+3/plus3.s
Kernel/platform-zx+3/tricks.s
Kernel/platform-zx128/kernel.def
Kernel/platform-zx128/tricks.s
Kernel/platform-zx128/zx128.s
Kernel/platform-zxdiv/crt0.s
Kernel/platform-zxdiv/kernel.def
Kernel/platform-zxdiv/zx128.s
Kernel/platform-zxevo/crt0.s
Kernel/platform-zxevo/kernel.def
Kernel/platform-zxevo/tricks.s
Kernel/platform-zxevo/zxevo.s
Kernel/usermem_std-z80-banked.s
Kernel/usermem_std-z80-thunked.s
Kernel/usermem_std-z80.s

index f5707b2..9985b18 100644 (file)
@@ -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
index d5bc41e..166f11e 100644 (file)
@@ -31,7 +31,7 @@ CPU_Z180      .equ    Z80_TYPE-2
         .globl _fd_tick
 
         .include "../platform/kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 
 ;------------------------------------------------------------------------------
index d54f940..3804a11 100644 (file)
@@ -8,7 +8,7 @@
         .globl _rd_read
         .globl _rd_write
 
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
         .include "kernel.def"
 
         .area _CODE
index fb9b850..515e34c 100644 (file)
@@ -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
index 87a95bc..df0e41b 100644 (file)
@@ -15,7 +15,7 @@
         .globl _ds1302_get_pin_data
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; DS1302 interface
index ab21575..bd82908 100644 (file)
@@ -13,7 +13,7 @@
         .globl _ds1302_get_pin_data
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; DS1302 interface
index 35591a5..3bde05c 100644 (file)
@@ -32,7 +32,7 @@ CPU_Z180      .equ    Z80_TYPE-2
         .globl _fd_tick
 
         .include "../platform/kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 
 ;------------------------------------------------------------------------------
index 1986424..47b8c3d 100644 (file)
@@ -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
index 07d7096..47a1ed8 100644 (file)
@@ -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
index 2eb9ce8..4c82fb9 100644 (file)
@@ -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 (file)
index 0000000..a232b03
--- /dev/null
@@ -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
index fd0cde1..91f9ca6 100644 (file)
@@ -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.
index f859831..44fa1b0 100644 (file)
@@ -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
index 90483db..88a26bd 100644 (file)
@@ -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
index 9afb89b..754adac 100644 (file)
@@ -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.
index efc4030..d585235 100644 (file)
@@ -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
index d7b5a7f..bec1ae6 100644 (file)
        .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
        ;
index bd46488..e658020 100644 (file)
        .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
index 44c2484..a0052a6 100644 (file)
        .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
        ;
index 60eeee6..dc4da50 100644 (file)
@@ -4,7 +4,7 @@
                .module fdc765
 
                .include "kernel.def"
-               .include "../kernel.def"
+               .include "../kernel-z80.def"
 
        .globl  map_process_always
        .globl  map_kernel
index 95bfd6b..4f854fc 100644 (file)
@@ -62,7 +62,7 @@
             .globl outstringhex
 
             .include "platform/kernel.def"
-            .include "../../kernel.def" ; Kernel
+            .include "../../kernel-z80.def" ; Kernel
            .include "nc100.def"
 
 ; -----------------------------------------------------------------------------
index 6bfefa3..084d5ef 100644 (file)
@@ -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
 
index 6bfefa3..084d5ef 100644 (file)
@@ -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
 
index 0d88112..6e22e9e 100644 (file)
@@ -1,7 +1,7 @@
         .module tricks
 
         .include "platform/kernel.def"
-        .include "../../kernel.def" ; Kernel
+        .include "../../kernel-z80.def" ; Kernel
 
 TOP_PORT       .equ    0x13
 
index 9b09dd9..c1fc195 100644 (file)
@@ -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
index cbfe051..459260a 100644 (file)
@@ -42,8 +42,8 @@
        ; For the boot vector
        .globl init
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .area _BOOT
 
index 7b32b41..ce99ec0 100644 (file)
@@ -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
 
index 70bbe01..7828f54 100644 (file)
@@ -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
 
index 1682e92..12b821d 100644 (file)
@@ -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
index afc3f70..4d88b1b 100644 (file)
@@ -37,7 +37,7 @@
                .globl kstack_top
 
                 .include "kernel.def"
-                .include "../kernel.def"
+                .include "../kernel-z80.def"
 
                ; startup code
                .area _BOOT
index dcb7d3d..c0ed421 100644 (file)
@@ -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
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 4edbf40..74c3701 100644 (file)
@@ -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
index a71bc15..16635dc 100644 (file)
@@ -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)
index c75b60b..cbb5a61 100644 (file)
@@ -43,7 +43,7 @@
        .globl l__COMMONMEM
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 
 ;
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 41f169e..6d98e7e 100644 (file)
@@ -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
 
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 5eb67f8..c7e2312 100644 (file)
@@ -56,7 +56,7 @@
             .globl outstringhex
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (not meaningful on swap only)
index a9ef12e..b3b10ad 100644 (file)
@@ -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
 
index c74f5f2..bb32b43 100644 (file)
@@ -49,7 +49,7 @@
            .globl vdpinit
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (0xF000 upwards)
index ace0c5a..a2ffe3f 100644 (file)
@@ -5,7 +5,7 @@
        .module bank_msx1
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
         ; imported symbols
         .globl _ramsize
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 89e9eca..27364ba 100644 (file)
@@ -1,7 +1,7 @@
             .module vdp
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 
 
index 988b2b2..56f5dcf 100644 (file)
@@ -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
 
index 33c3d45..d23318c 100644 (file)
@@ -59,7 +59,7 @@
            .globl _vdpinit
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
            .area _BUFFERS
 
index a9e5a21..e9cd9b8 100644 (file)
@@ -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)
index 2c11145..53ad01f 100644 (file)
@@ -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
 
index 4a4194b..1b943dc 100644 (file)
@@ -53,7 +53,7 @@
             .globl outstringhex
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (0xC000 upwards)
index ee50c07..891ef43 100644 (file)
@@ -1,5 +1,5 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank.s"
index 59d7a14..cd2f79b 100644 (file)
@@ -1,7 +1,7 @@
             .module vdp
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
            .include "../dev/vdp1.s"
 
index f9bec02..1b37bd8 100644 (file)
@@ -13,7 +13,7 @@
 
         .include "kernel.def"
         .include "../cpu-z180/z180.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; DS1302 interface
index ad26ba3..8a0167e 100644 (file)
@@ -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
index 98da09f..f9bcdc5 100644 (file)
@@ -20,7 +20,7 @@
 
         .include "kernel.def"
         .include "../cpu-z180/z180.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; Buffers
index 34dd8a4..ffea862 100644 (file)
@@ -4,7 +4,7 @@
        .module gm833
 
        .include "kernel.def"
-       .include "../kernel.def"
+       .include "../kernel-z80.def"
 
        .globl _gm833_in
        .globl _gm833_out
index 8d54abe..d514bb9 100644 (file)
@@ -5,7 +5,7 @@
 ;      ACK handling.
 
        .include "kernel.def"
-       .include "../kernel.def"
+       .include "../kernel-z80.def"
 
        .globl _si_read
        .globl _si_write
index dfb9176..f4477a4 100644 (file)
@@ -1,7 +1,7 @@
        .module gm8x9
 
        .include "kernel.def"
-       .include "../kernel.def"
+       .include "../kernel-z80.def"
 
        .globl _gm8x9_ioread
        .globl _gm8x9_iowrite
index 8062fd2..2ae743a 100644 (file)
@@ -65,7 +65,7 @@
        .globl _io_page
 
        .include "kernel.def"
-       .include "../kernel.def"
+       .include "../kernel-z80.def"
 
        .area _CODE
 
index 0caf051..cb2a514 100644 (file)
@@ -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
 
index e2349ab..bbd0f45 100644 (file)
@@ -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
index 61d61f1..7da201b 100644 (file)
@@ -39,7 +39,7 @@
            .globl _bufpool
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
            .area _BUFFERS
 
index ee50c07..891ef43 100644 (file)
@@ -1,5 +1,5 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank.s"
index b87f47f..4d0beb7 100644 (file)
@@ -13,7 +13,7 @@
 
         .include "kernel.def"
         .include "../cpu-z180/z180.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; DS1202 interface
index 7d15ed7..339e779 100644 (file)
@@ -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
 
index d0240b5..69702d6 100644 (file)
@@ -23,7 +23,7 @@
 
         .include "kernel.def"
         .include "../cpu-z180/z180.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; Buffers
index ae548a8..6438212 100644 (file)
@@ -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)
 ------------------
 
index 434ca6a..d1642d4 100644 (file)
@@ -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
index f8fad12..1fab747 100644 (file)
                .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
 
index caa0c53..3cfa89a 100644 (file)
@@ -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)
 {
index 87f3e6b..8b1dbbb 100644 (file)
@@ -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
index c33b656..b088bb7 100644 (file)
@@ -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
 
index 9c8d13b..49e0906 100644 (file)
@@ -4,8 +4,6 @@
 #include <printf.h>
 #include <devtty.h>
 
-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
    
index f13418f..a3e433e 100644 (file)
@@ -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
 
index ec1ce16..7b1d7d6 100644 (file)
         .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
+
+
index 2de325b..33caf7b 100644 (file)
@@ -49,8 +49,8 @@
         .globl nmi_handler
         .globl interrupt_handler
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .area _CODE1
         ; startup code
index 9e311b8..9cff8a0 100644 (file)
@@ -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
 
index c7e618f..fe8d3d9 100644 (file)
@@ -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
index 10a5d13..fce0ee5 100644 (file)
@@ -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
 
index cbf8c1d..3b97355 100644 (file)
@@ -59,7 +59,7 @@
 
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (not unmapped when we flip to ROM)
index 30ce5a1..5276ea2 100644 (file)
@@ -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
 
index 718bf95..8b003a0 100644 (file)
@@ -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
 
index ff137df..b3e6939 100644 (file)
@@ -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
index a1afbad..45c1598 100644 (file)
        .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
index b63a607..f872788 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank-core.s"
 
index c971ef3..828be62 100644 (file)
@@ -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
index 2c5d59f..2fda9c5 100644 (file)
@@ -40,7 +40,7 @@
        .globl outchar
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ;=========================================================================
 ; Constants
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 73e2c0b..377707b 100644 (file)
@@ -5,8 +5,8 @@
        .module buffers
        .area _COMMONMEM
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .globl _do_blkzero
        .globl _do_blkcopyk
index 05b2f86..048ab7e 100644 (file)
@@ -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
index d0bc0db..1d9a6c4 100644 (file)
@@ -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
 
index f6bf94a..6937387 100644 (file)
        .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
index b7f6d3d..d73b6d8 100644 (file)
@@ -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)
index 1450a1b..36730ce 100644 (file)
@@ -1,7 +1,7 @@
         .module vfdterm
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
         .globl  VFDTERM_PREINIT
         .globl  VFDTERM_PUTC
index a2dc049..012b64a 100644 (file)
@@ -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
index d00b87b..98a3573 100644 (file)
@@ -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
index 5e02691..8c0513c 100644 (file)
@@ -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
index c33f1cd..ba413e9 100644 (file)
@@ -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
index 581d821..a5f7863 100644 (file)
@@ -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
index 2b9b4da..f8be81b 100644 (file)
@@ -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
index 2025fbe..0f475a7 100644 (file)
@@ -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
index 3ccb1fe..15d52b0 100644 (file)
@@ -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
index a5c6b56..71d280f 100644 (file)
@@ -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
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index ff9cc95..7b5388e 100644 (file)
@@ -5,7 +5,7 @@
         .module usermem
 
        .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
         ; exported symbols
         .globl __uget
index 925d5fa..0cb457f 100644 (file)
@@ -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
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 81c92ee..ca78737 100644 (file)
@@ -5,7 +5,7 @@
         .module usermem
 
        .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
         ; exported symbols
         .globl __uget
index 399f59b..d2a2a73 100644 (file)
@@ -2,8 +2,8 @@
 
         .module commonmem
 
-        .include "../kernel.def"
         .include "kernel.def"
+        .include "../kernel-z80.def"
 
         .area _COMMONMEM
         ; ------------------------------------------------------------------------------------------------
index e3c7b6d..cad81f2 100644 (file)
@@ -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
 
index cebe7d5..7588136 100644 (file)
@@ -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
index c106611..fc2e142 100644 (file)
@@ -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
index 53ce7be..142da0e 100644 (file)
@@ -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
index a58fa8f..df529df 100644 (file)
@@ -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
index 849a768..8875f9c 100644 (file)
@@ -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
 
index 6ba3087..f083a51 100644 (file)
@@ -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
index 62cfb04..9f24c91 100644 (file)
@@ -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
 
index ab70d16..cddddc5 100644 (file)
@@ -58,8 +58,8 @@
         .globl nmi_handler
         .globl interrupt_handler
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        ;
         ; startup code
index 1409895..fe441d2 100644 (file)
@@ -48,7 +48,7 @@
         .globl outstringhex
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (below 0x4000)
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 9e704d6..fb6f716 100644 (file)
@@ -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
 
index ee50c07..891ef43 100644 (file)
@@ -1,5 +1,5 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank.s"
index 5259b58..76d59ae 100644 (file)
@@ -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
index 3c1448c..78e7a5d 100644 (file)
@@ -44,7 +44,7 @@
            .globl _bufpool
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
            .area _BUFFERS
 
index 1407034..fc9197c 100644 (file)
@@ -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
 
index 7ab58b4..edc07d2 100644 (file)
@@ -4,7 +4,7 @@
        .globl  _tape_err
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .area _COMMONMEM
 
index 4925f25..ed5dc32 100644 (file)
@@ -1,6 +1,6 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank-banked.s"
 
index 9b7db3d..8bf69b5 100644 (file)
@@ -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
index 4d5ca7b..7c63dfe 100644 (file)
@@ -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)
index 49a56f9..306b42c 100644 (file)
@@ -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
 
index ee50c07..891ef43 100644 (file)
@@ -1,5 +1,5 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank.s"
index e19541d..264d582 100644 (file)
@@ -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
index c36d8ae..4e0630c 100644 (file)
@@ -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
index 98da09f..f9bcdc5 100644 (file)
@@ -20,7 +20,7 @@
 
         .include "kernel.def"
         .include "../cpu-z180/z180.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; Buffers
index b32bb6c..d747f06 100644 (file)
@@ -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
index 5765fb5..1866f88 100644 (file)
@@ -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
index 1eaafca..e9a384a 100644 (file)
@@ -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"
index d483aef..499e69e 100644 (file)
@@ -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
index e0b4d9d..3e83fea 100644 (file)
@@ -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
index aa6f9ee..1368e44 100644 (file)
@@ -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
index 5966988..c32e729 100644 (file)
            
 
             .include "kernel.def"
-            .include "../kernel.def"
+            .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
-; COMMON MEMORY BANK (0xF000 upwards)
+; COMMON MEMORY BANK
 ; -----------------------------------------------------------------------------
             .area _COMMONMEM
 
index 7f47cd1..6cb4f54 100644 (file)
@@ -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
 
index ee50c07..891ef43 100644 (file)
@@ -1,5 +1,5 @@
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        .include "../lib/z80fixedbank.s"
index 5a2b90e..72c96c5 100644 (file)
@@ -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)
index 05b2f86..ce166c9 100644 (file)
@@ -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
index 87a95bc..df0e41b 100644 (file)
@@ -15,7 +15,7 @@
         .globl _ds1302_get_pin_data
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; DS1302 interface
index c63ed2b..54146ff 100644 (file)
@@ -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
 
index b7f6d3d..733e712 100644 (file)
@@ -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)
index f85dd38..a0050b6 100644 (file)
@@ -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
 
 ;=========================================================================
index 0a05f8c..913d679 100644 (file)
@@ -67,8 +67,8 @@
         .globl nmi_handler
         .globl interrupt_handler
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
        ;
         ; startup code
index f110817..3da5253 100644 (file)
@@ -31,7 +31,7 @@
                .module fdc765
 
                .include "kernel.def"
-               .include "../kernel.def"
+               .include "../kernel-z80.def"
 
        .globl  map_process_always
        .globl  map_kernel
index 3b0c8c8..d061dd7 100644 (file)
@@ -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
 
index f571c20..17a05aa 100644 (file)
@@ -49,7 +49,7 @@
         .globl outstringhex
 
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
 ; -----------------------------------------------------------------------------
 ; COMMON MEMORY BANK (below 0x4000)
index 0113d75..a4678ac 100644 (file)
@@ -1,5 +1,5 @@
         .include "kernel.def"
-        .include "../kernel.def"
+        .include "../kernel-z80.def"
 
        .include "../lib/z80single.s"
 
index 9f29146..c57e918 100644 (file)
@@ -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
 
index 612e784..eae6d50 100644 (file)
@@ -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
index e3a3f99..af17232 100644 (file)
@@ -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
index 5e8b28b..73faaed 100644 (file)
@@ -54,8 +54,8 @@
         .globl nmi_handler
         .globl interrupt_handler
 
-       .include "../kernel.def"
        .include "kernel.def"
+       .include "../kernel-z80.def"
 
         ; startup code
        ;
index eb78b32..14a8a7a 100644 (file)
@@ -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
 
index 51bb8cb..b6dc8fd 100644 (file)
@@ -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
index 6fddbb0..3dae7d3 100644 (file)
@@ -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
index 849a768..8875f9c 100644 (file)
@@ -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
 
index d4ee7e1..8547f81 100644 (file)
@@ -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:
index dc33ad9..316403b 100644 (file)
         .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
        ;
index 7eac765..cce04ec 100644 (file)
@@ -7,7 +7,7 @@
         .module usermem
 
        .include "platform/kernel.def"
-        .include "kernel.def"
+        .include "kernel-z80.def"
 
         ; exported symbols
         .globl __uget
index 2e74362..3847012 100644 (file)
@@ -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
index 94d3850..4adffab 100644 (file)
@@ -7,7 +7,7 @@
         .module usermem
 
        .include "platform/kernel.def"
-        .include "kernel.def"
+        .include "kernel-z80.def"
 
         ; exported symbols
         .globl __uget