;Implementation of SoftMMU - GeoRAM/BBGRam support ;================================================= #define georam_page $dffe ;select a page within the bank #define georam_bank $dfff ;select a 16k bank #define georam_window $de00 ;256-byte window into expansion memory #define georam_maxpage $3f ;there are 64 256-byte pages within each 16k bank #define tsp_geomirror tsp_exp ;our 2 bytes of TSP space .global init_georam .global xpage_georam .global xalloc_georam ;---- ;Name ;---- name_georam: .byte "GeoRAM/BBGRam",$00 ;--------- ;Page swap ;--------- xpage_georam: lda banklo ;3 ;convert 16-bit page offset into bank/page sta zptemp ;3 and #%00111111 ;2 sta georam_page ;4 ldy #tsp_geomirror ;2 sta (lk_tsp),y ;6 ;gotta mirror those registers, because they're write-only lda bankhi ;3 asl zptemp ;5 rol ;2 asl zptemp ;5 rol ;2 sta georam_bank ;4 iny ;2 sta (lk_tsp),y ;6 cli ;2 ;clean up & return pla ;4 tay ;2 pla ;4 rts ;6 ;== 67 cycles ;---------- ;Allocation ;---------- ;Being a banked system, we need to make sure that the currently ;accessed page is banked in when a task receives the current ;context again. However, we don't need to monitor context ;switches unless something's actually allocated, so we leave ;this flag alone until an actual allocation occurs. xalloc_georam: jsr sm_setmygetcontextbit rts ;------------ ;Reallocation ;------------ #define xrealloc_georam $0000 ;um, not implemented yet ;------------ ;Deallocation ;------------ #define xfree_georam $0000 ;unused ;---------------- ;Context switches ;---------------- ;GeoRAM registers are write-only, so we can't read them when ;we lose the context. Must rely on xpage to save the current ;bank/page config. #define losecontext_georam $0000 ;unused getcontext_georam: ldy #tsp_geomirror lda (lk_tsp),y sta georam_page iny lda (lk_tsp),y sta georam_bank rts