;Implementation of SoftMMU - core ;================================ #include "sm.h.txt" ;Routines .global sm_setmygetcontextbit .global sm_setmylosecontextbit ;Tables .global sm_memsrc .global sm_page .global sm_top .global sm_open ;Total number of installed memory sources sm_memsrc: .byte numexp-1 ;Tables of pointers for free lists sm_page: _table sm_top: _table sm_open: _table ;Jump tables sm_xalloclo: #define routine jumptable #define prefix < #define param_xalloc #include "sm_include.h.txt" sm_xallochi: #define routine jumptable #define prefix > #define param_xalloc #include "sm_include.h.txt" sm_xrealloclo: #define routine jumptable #define prefix < #define param_xrealloc #include "sm_include.h.txt" sm_xreallochi: #define routine jumptable #define prefix > #define param_xrealloc #include "sm_include.h.txt" sm_xfreelo: #define routine jumptable #define prefix < #define param_xfree #include "sm_include.h.txt" sm_xfreehi: #define routine jumptable #define prefix > #define param_xfree #include "sm_include.h.txt" sm_xpagelo: #define routine jumptable #define prefix < #define param_xpage #include "sm_include.h.txt" sm_xpagehi: #define routine jumptable #define prefix > #define param_xpage #include "sm_include.h.txt" sm_losecontextlo: #define routine jumptable #define prefix < #define param_losecontext #include "sm_include.h.txt" sm_losecontexthi: #define routine jumptable #define prefix > #define param_losecontext #include "sm_include.h.txt" sm_getcontextlo: #define routine jumptable #define prefix < #define param_getcontext #include "sm_include.h.txt" sm_getcontexthi: #define routine jumptable #define prefix > #define param_getcontext #include "sm_include.h.txt" ;Each memory source is free to use the following four ;routines if it needs to monitor context switches. ;Load .X with the memory source number before calling. bits: .byte %10000000 .byte %01000000 .byte %00100000 .byte %00010000 .byte %00001000 .byte %00000100 .byte %00000010 .byte %00000001 sm_setmygetcontextbit: lda bits,x ldy tsp_smget ora (lk_tsp),y sta (lk_tsp),y rts sm_setmylosecontextbit: lda bits,x ldy tsp_smlose ora (lk_tsp),y sta (lk_tsp),y rts sm_clearmygetcontextbit: lda bits,x eor #$ff ldy tsp_smget and (lk_tsp),y sta (lk_tsp),y rts sm_clearmylosecontextbit: lda bits,x eor #$ff ldy tsp_smlose and (lk_tsp),y sta (lk_tsp),y rts ;Include the source files for each expansion #define routine getsources #include "sm_include.h.txt"