raw
m_genesis.kv            1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 2 ;; ;;
m_genesis.kv 3 ;; This file is part of 'M', a MIPS system emulator. ;;
m_genesis.kv 4 ;; ;;
m_genesis.kv 5 ;; (C) 2019 Stanislav Datskovskiy ( www.loper-os.org ) ;;
m_genesis.kv 6 ;; http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html ;;
m_genesis.kv 7 ;; ;;
m_genesis.kv 8 ;; You do not have, nor can you ever acquire the right to use, copy or ;;
m_genesis.kv 9 ;; distribute this software ; Should you use this software for any purpose, ;;
m_genesis.kv 10 ;; or copy and distribute it to anyone or in any manner, you are breaking ;;
m_genesis.kv 11 ;; the laws of whatever soi-disant jurisdiction, and you promise to ;;
m_genesis.kv 12 ;; continue doing so for the indefinite future. In any case, please ;;
m_genesis.kv 13 ;; always : read and understand any software ; verify any PGP signatures ;;
m_genesis.kv 14 ;; that you use - for any purpose. ;;
m_genesis.kv 15 ;; ;;
m_genesis.kv 16 ;; See also http://trilema.com/2015/a-new-software-licensing-paradigm . ;;
m_genesis.kv 17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 18
m_genesis.kv 19 ;; Universal MMIO Bus Dispatcher. Addition of new simulated devices will NOT
m_genesis.kv 20 ;; require any changes to this mechanism. Be sure to add any device component
m_genesis.kv 21 ;; to 'devices.asm'.
m_genesis.kv 22 ;; NOTE 1: The DECLARE_BUS_DEVICE macro is valid ONLY inside text included by
m_genesis.kv 23 ;; 'devices.asm' !
m_genesis.kv 24 ;; NOTE 2: Currently there is NO support for devices which demand a
m_genesis.kv 25 ;; non-contiguous MMIO segment !
m_genesis.kv 26 ;; NOTE 3: Make ABSOLUTELY certain that the MMIO Device ranges do not overlap!
m_genesis.kv 27
m_genesis.kv 28 section .text
m_genesis.kv 29
m_genesis.kv 30 ;-----------------------------------------------------------------------------
m_genesis.kv 31 ; MMIO_ADDR
m_genesis.kv 32 ;-----------------------------------------------------------------------------
m_genesis.kv 33 %define MMIO_ADDR(A) (MMIO_BASE + A) ; Address to be offset from MMIO_BASE
m_genesis.kv 34 ;-----------------------------------------------------------------------------
m_genesis.kv 35
m_genesis.kv 36 ;-----------------------------------------------------------------------------
m_genesis.kv 37 ; Proclaim Device and connect it to Bus; %1: Name, %2: Base Addr, %3: Top Addr
m_genesis.kv 38 ;-----------------------------------------------------------------------------
m_genesis.kv 39 %macro DECLARE_BUS_DEVICE 3
m_genesis.kv 40
m_genesis.kv 41 %define %1_BASE MMIO_ADDR(%2) ;; Declare DEVICE_BASE MMIO Address (first)
m_genesis.kv 42 %define %1_TOP MMIO_ADDR(%3) ;; Declare DEVICE_TOP MMIO Address (last)
m_genesis.kv 43
m_genesis.kv 44 ;; Put this device's MMIO range in _Phys_Device_Read_Word's set of cases
m_genesis.kv 45 SECTION .PD_Rd_Word
m_genesis.kv 46 JMP_If_In eax, %1_BASE, %1_TOP, _PD_Read_Word_%1
m_genesis.kv 47
m_genesis.kv 48 ;; Put this device's MMIO range in _Phys_Device_Write_Word's set of cases
m_genesis.kv 49 SECTION .PD_Wr_Word
m_genesis.kv 50 JMP_If_In eax, %1_BASE, %1_TOP, _PD_Write_Word_%1
m_genesis.kv 51
m_genesis.kv 52 ;; Put this device's MMIO range in _Phys_Device_Read_Byte's set of cases
m_genesis.kv 53 SECTION .PD_Rd_Byte
m_genesis.kv 54 JMP_If_In eax, %1_BASE, %1_TOP, _PD_Read_Byte_%1
m_genesis.kv 55
m_genesis.kv 56 ;; Put this device's MMIO range in _Phys_Device_Write_Byte's set of cases
m_genesis.kv 57 SECTION .PD_Wr_Byte
m_genesis.kv 58 JMP_If_In eax, %1_BASE, %1_TOP, _PD_Write_Byte_%1
m_genesis.kv 59
m_genesis.kv 60 ;; Put this device's initialization routine in the list of
m_genesis.kv 61 ;; called by _Phys_Devices_Initialize:
m_genesis.kv 62 SECTION .PD_Initialize
m_genesis.kv 63 call _Device_Init_%1
m_genesis.kv 64
m_genesis.kv 65 ;; Put this device's termination routine in the list of
m_genesis.kv 66 ;; called by _Phys_Devices_Shutdown:
m_genesis.kv 67 SECTION .PD_Shutdown
m_genesis.kv 68 call _Device_Shutdown_%1
m_genesis.kv 69
m_genesis.kv 70 section .text ;; Resume the .text section.
m_genesis.kv 71
m_genesis.kv 72 %endmacro
m_genesis.kv 73 ;-----------------------------------------------------------------------------
m_genesis.kv 74
m_genesis.kv 75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 76 ;; Prologues of Physical Device Bus Wires ;;
m_genesis.kv 77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 78
m_genesis.kv 79 ;-----------------------------------------------------------------------------
m_genesis.kv 80 ; Device Read Word -- we jump here from _Virt_Read_Word if pAddr in range
m_genesis.kv 81 ;-----------------------------------------------------------------------------
m_genesis.kv 82 section .PD_Rd_Word progbits exec alloc nowrite
m_genesis.kv 83 _Phys_Device_Read_Word:
m_genesis.kv 84 ;-----------------------------------------------------------------------------
m_genesis.kv 85
m_genesis.kv 86 ;-----------------------------------------------------------------------------
m_genesis.kv 87 ; Device Write Word -- we jump here from _Virt_Write_Word if pAddr in range
m_genesis.kv 88 ;-----------------------------------------------------------------------------
m_genesis.kv 89 section .PD_Wr_Word progbits exec alloc nowrite
m_genesis.kv 90 _Phys_Device_Write_Word:
m_genesis.kv 91 ;-----------------------------------------------------------------------------
m_genesis.kv 92
m_genesis.kv 93 ;-----------------------------------------------------------------------------
m_genesis.kv 94 ; Device Read Byte -- we jump here from _Virt_Read_Byte if pAddr in range
m_genesis.kv 95 ;-----------------------------------------------------------------------------
m_genesis.kv 96 section .PD_Rd_Byte progbits exec alloc nowrite
m_genesis.kv 97 _Phys_Device_Read_Byte:
m_genesis.kv 98 ;-----------------------------------------------------------------------------
m_genesis.kv 99
m_genesis.kv 100 ;-----------------------------------------------------------------------------
m_genesis.kv 101 ; Device Write Byte -- we jump here from _Virt_Write_Byte if pAddr in range
m_genesis.kv 102 ;-----------------------------------------------------------------------------
m_genesis.kv 103 section .PD_Wr_Byte progbits exec alloc nowrite
m_genesis.kv 104 _Phys_Device_Write_Byte:
m_genesis.kv 105 ;-----------------------------------------------------------------------------
m_genesis.kv 106
m_genesis.kv 107 ;-----------------------------------------------------------------------------
m_genesis.kv 108 ; Device Initialization
m_genesis.kv 109 ;-----------------------------------------------------------------------------
m_genesis.kv 110 section .PD_Initialize progbits exec alloc nowrite
m_genesis.kv 111 _Phys_Devices_Initialize:
m_genesis.kv 112 ;-----------------------------------------------------------------------------
m_genesis.kv 113
m_genesis.kv 114 ;-----------------------------------------------------------------------------
m_genesis.kv 115 ; Device Shutdown
m_genesis.kv 116 ;-----------------------------------------------------------------------------
m_genesis.kv 117 section .PD_Shutdown progbits exec alloc nowrite
m_genesis.kv 118 _Phys_Devices_Shutdown:
m_genesis.kv 119 ;-----------------------------------------------------------------------------
m_genesis.kv 120
m_genesis.kv 121 ;; ALL Device implementations MUST be included from:
m_genesis.kv 122 %include "devices/devices.asm"
m_genesis.kv 123
m_genesis.kv 124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 125 ;; Epilogues of Physical Device Bus Wires ;;
m_genesis.kv 126 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 127
m_genesis.kv 128 ;-----------------------------------------------------------------------------
m_genesis.kv 129 SECTION .PD_Rd_Word
m_genesis.kv 130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 131 ;; Unknown Device ?
m_genesis.kv 132 xor eax, eax ; Always return 0
m_genesis.kv 133 ACHTUNG "Read Word from Unknown Device?" ; TODO: print detail
m_genesis.kv 134 ret
m_genesis.kv 135 ;-----------------------------------------------------------------------------
m_genesis.kv 136
m_genesis.kv 137 ;-----------------------------------------------------------------------------
m_genesis.kv 138 SECTION .PD_Wr_Word
m_genesis.kv 139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 140 ;; Unknown Device ?
m_genesis.kv 141 ACHTUNG "Write Word to Unknown Device?" ; TODO: print detail
m_genesis.kv 142 ret
m_genesis.kv 143 ;-----------------------------------------------------------------------------
m_genesis.kv 144
m_genesis.kv 145 ;-----------------------------------------------------------------------------
m_genesis.kv 146 SECTION .PD_Rd_Byte
m_genesis.kv 147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 148 ;; Unknown Device ?
m_genesis.kv 149 xor eax, eax ; Always return 0
m_genesis.kv 150 ACHTUNG "Read Byte from Unknown Device?" ; TODO: print detail
m_genesis.kv 151 ret
m_genesis.kv 152 ;-----------------------------------------------------------------------------
m_genesis.kv 153
m_genesis.kv 154 ;-----------------------------------------------------------------------------
m_genesis.kv 155 SECTION .PD_Wr_Byte
m_genesis.kv 156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 157 ;; Unknown Device ?
m_genesis.kv 158 ACHTUNG "Write Byte to Unknown Device?" ; TODO: print detail
m_genesis.kv 159 ret
m_genesis.kv 160 ;-----------------------------------------------------------------------------
m_genesis.kv 161
m_genesis.kv 162 ;-----------------------------------------------------------------------------
m_genesis.kv 163 SECTION .PD_Initialize
m_genesis.kv 164 ret
m_genesis.kv 165 ;-----------------------------------------------------------------------------
m_genesis.kv 166
m_genesis.kv 167 ;-----------------------------------------------------------------------------
m_genesis.kv 168 SECTION .PD_Shutdown
m_genesis.kv 169 ret
m_genesis.kv 170 ;-----------------------------------------------------------------------------
m_genesis.kv 171
m_genesis.kv 172 ;; Back to code section:
m_genesis.kv 173 section .text