ld e, #32 ; 32 sectors (16K)
push bc
rst 8 ; Can error but if so wtf do we do ?
- ld hl,#0x8100 ; Don't copy first 256 bytes over
- ld de,#0x4100
- ld bc,#0x3F00 ; We've loaded 0100-4000
+ ld hl,#0x8000 ; Don't copy first 256 bytes over
+ ld de,#0x4000
+ ld bc,#0x4000 ; We've loaded 0000-4000
ld a,#32
out (MPGSEL_1),a ; Low bank at 0x4000 please
ldir
; Final 16K
;
ld hl,#0x8000 ; Now load 8000 up
- ld e, #32 ; takes us up to F000. If that's not enough
- ; before unpack we have a problem as we
- ; will need to move the loader
+ ld e, #32
+ push bc
rst 8
ld hl,#0x8000 ; Move it into place
ld a,#35
out (MPGSEL_1),a
ldir
+ pop bc
+
+ ;
+ ; Bank 2 first 16K
+ ;
+ ld hl,#0x8000 ; Load 4000 up
+ ld e, #32
+ push bc
+ rst 8
+ ld hl,#0x8000 ; Move it into place
+ ld de,#0x4000
+ ld bc,#0x4000
+ ld a,#36
+ out (MPGSEL_1),a
+ ldir
+ pop bc
+
+ ;
+ ; Bank 2 second 16K
+ ;
+ ld hl,#0x8000 ; Now load 8000 up
+ ld e, #32
+ rst 8
+ ld hl,#0x8000 ; Move it into place
+ ld de,#0x4000
+ ld bc,#0x4000
+ ld a,#37
+ out (MPGSEL_1),a
+ ldir
;
; Map the kernel low 16K block and jump into it
#define TICKSPERSEC 10 /* Ticks per second */
#define PROGBASE 0x0000 /* also data base */
#define PROGLOAD 0x0100 /* also data base */
-#define PROGTOP 0xD000 /* Top of program, base of U_DATA copy */
-/* FIXME: check this... for discard looks wrong */
-#define KERNTOP 0xC000 /* Top of kernel (first 3 banks), base of shared bank */
+#define PROGTOP 0xF000 /* Top of program, base of U_DATA copy */
//#define SWAPDEV (swap_dev) /* A variable for dynamic, or a device major/minor */
extern unsigned int swap_dev;
#define SWAP_SIZE 0x69 /* 60.5K in blocks (prog + udata) */
#define SWAPBASE 0x0000 /* start at the base of user mem */
-#define SWAPTOP 0xD200 /* Swap out udata and program */
+#define SWAPTOP 0xF200 /* Swap out udata and program */
#define MAX_SWAPS 16 /* We will size if from the partition */
/* Swap will be set up when a suitably labelled partition is seen */
#define CONFIG_DYNAMIC_SWAP
.globl map_process
.globl map_process_save
.globl map_buffers
- .globl map_buffers_user
- .globl map_buffers_user_h
.globl map_kernel_di
.globl map_process_di
.globl map_process_always
MAP_BANK1 .equ 0x2221 ; 20 is low, 23 is high
BANK1 .equ 0x21
-MAP_BANK2 .equ 0x2625 ; for now 24 is buffers - FIXME
-BANK2 .equ 0x25
+MAP_BANK2 .equ 0x2524 ; for now 24 is buffers - FIXME
+BANK2 .equ 0x24
;=========================================================================
; Initialization code
.area _DISCARD
init_hardware:
; program vectors for the kernel
- ld hl, #0
- push hl
- call _program_vectors
- pop hl
+ call do_program_vectors
; Stop floppy drive motors
ld a, #0x0C
; At this point the common block has already been copied
call map_process
+ call do_program_vectors
+
+ jp map_kernel_restore
+
+
+do_program_vectors:
; write zeroes across all vectors
ld hl,#0
ld de,#1
ld (0x0066),a ; Set vector for NMI
ld hl,#nmi_handler
ld (0x0067),hl
-
- jr map_kernel
+ ret
;=========================================================================
; Memory management
map_process_save:
map_process_always_di:
push hl
- ld hl,#_kernel_pages + 1
- ; Save the current versions of MPGSEL 1 and 2 for map_kernel_restore
- ; so we return to the right kernel bank
- in a,(MPGSEL_1)
- ld (hl),a
- inc hl
- in a,(MPGSEL_2)
- ld (hl),a
+ ; We don't need to save the kernel page numbers because we
+ ; patched them on bank switches
ld hl,#_udata + U_DATA__U_PAGE
jr map_process_2_pophl_ret
-;
-; FIXME: needs to save the old kernel mid mapping
-;
-map_buffers_user:
- push hl
- ld hl,(_udata + U_DATA__U_PAGE)
- ld h,#36
- ld (_ubuffer_pages),hl
- 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,(_udata + U_DATA__U_PAGE)
- ld (_ubuffer_pages),hl
- ld hl,(_udata + U_DATA__U_PAGE + 2)
- ld l,#36
- ld (_ubuffer_pages + 2),hl
- ld hl,#_ubuffer_pages
- jr map_process_2_pophl_ret
-
;=========================================================================
; map_process - map process or kernel pages
; Inputs: page table address in HL, map kernel if HL == 0
; Outputs: none; all registers preserved
;=========================================================================
map_kernel:
+map_buffers:
map_kernel_restore:
map_kernel_di:
push hl
ld hl,#_kernel_pages
jr map_process_2_pophl_ret
-;=========================================================================
-; map_buffers - map kernel with disk buffers at 0x4000-0x7FFF
-; Inputs: none
-; Outputs: none; all registers preserved
-;=========================================================================
-map_buffers:
- push hl
- ld hl,#_kernelbuf_pages
- jr map_process_2_pophl_ret
-
;=========================================================================
; map_process_2 - map process or kernel pages
; Inputs: page table address in HL
;=========================================================================
; map_save_kernel - save the current page mapping to map_savearea and
-; switch to kernel maps
+; switch to kernel maps. We might switch to any kernel map but that is
+; ok as we will make a thunking call from common to the C irq handler
; Inputs: none
; Outputs: none
;=========================================================================
ld d,(hl)
inc hl
push hl
+ ld a,(_kernel_pages + 1) ; save old page
ld (_kernel_pages + 1),bc
- in a, (MPGSEL_1) ; existing page
+ ld (mpgsel_cache + 1),bc ; and mark as current
ld b,a
ld a,c ; set new page
out (MPGSEL_1),a
ld bc,#MAP_BANK2
banksetbc:
ld (_kernel_pages + 1), bc
+ ld (mpgsel_cache + 1), bc
ld a,c
out (MPGSEL_1),a
ld a,b
out (MPGSEL_2),a
ret
retbank1:
+ call callhl
ld bc,#MAP_BANK1
jr banksetbc
__bank_0_2:
inc hl
push hl
call banksetbc
+ ex de,hl
call callhl
ld bc,#MAP_BANK1
jr banksetbc
inc hl
push hl
call banksetbc
+ ex de,hl
call callhl
ld bc,#MAP_BANK2
jr banksetbc
stub_call:
pop hl ; return address
ex (sp),hl ; bank space now target
- in a,(MPGSEL_1) ; current bank
+ ld a,(_kernel_pages+1) ; current bank
ld (_kernel_pages+1),bc ; target
+ ld (mpgsel_cache + 1), bc
ld b,a
ld a,c
out (MPGSEL_1),a
inc a
out (MPGSEL_2),a
+ ex de,hl
ld a,b
cp #BANK1
jr z, stub_ret_1
ld bc,#MAP_BANK2
stub_ret:
ld (_kernel_pages+1),bc
+ ld (mpgsel_cache + 1), bc
ld a,c
out (MPGSEL_1),a
inc a
push bc
ld a,e
call map_for_swap
- ld hl,#0xD300
- ld de,#0x4300
- ld bc,#0x2D00
+ ld hl,#0xF200
+ ld de,#0x7200
+ ld bc,#0x0E00
ldir
jp map_kernel
_kernel_pages:
.db 32,33,34,35
-; kernel page mapping with buffer window
-_kernelbuf_pages:
- .db 32,36,34,35
-
-_ubuffer_pages:
- .db 0,0,0,0
; memory page mapping save area for map_save/map_restore
map_savearea:
.db 0,0,0,0