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 ;; TODO: Make the interval programmable. Right now hogs MMIO entirely in vain.
m_genesis.kv 20
m_genesis.kv 21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 22 ;; Interval Clock Device ;;
m_genesis.kv 23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
m_genesis.kv 24
m_genesis.kv 25 ;-----------------------------------------------------------------------------
m_genesis.kv 26 ; Interval Clock MMIO:
m_genesis.kv 27 DECLARE_BUS_DEVICE CLOCK, 0x420, 0x42F
m_genesis.kv 28 ;-----------------------------------------------------------------------------
m_genesis.kv 29
m_genesis.kv 30 ;-----------------------------------------------------------------------------
m_genesis.kv 31 ; Interval Clock IRQ:
m_genesis.kv 32 ;-----------------------------------------------------------------------------
m_genesis.kv 33 %define CLOCK_IRQ 3 ; UART0 Receiver Slave IRQ
m_genesis.kv 34 ;-----------------------------------------------------------------------------
m_genesis.kv 35
m_genesis.kv 36 ;-----------------------------------------------------------------------------
m_genesis.kv 37 ; Interval Clock State
m_genesis.kv 38 ;-----------------------------------------------------------------------------
m_genesis.kv 39 section .bss
m_genesis.kv 40 CLOCK_Die resd 1 ; Shutdown Trigger
m_genesis.kv 41 ;-----------------------------------------------------------------------------
m_genesis.kv 42
m_genesis.kv 43 section .text
m_genesis.kv 44
m_genesis.kv 45 ;-----------------------------------------------------------------------------
m_genesis.kv 46 _PD_Read_Word_CLOCK: ; Word reads from CLOCK always 0
m_genesis.kv 47 xor eax, eax
m_genesis.kv 48 ret ; Fin.
m_genesis.kv 49 ;-----------------------------------------------------------------------------
m_genesis.kv 50 _PD_Write_Word_CLOCK: ; Word writes to CLOCK do nothing!
m_genesis.kv 51 ret
m_genesis.kv 52 ;-----------------------------------------------------------------------------
m_genesis.kv 53 _PD_Read_Byte_CLOCK:
m_genesis.kv 54 xor eax, eax ; Read Byte from CLOCK: always 0
m_genesis.kv 55 ret
m_genesis.kv 56 ;-----------------------------------------------------------------------------
m_genesis.kv 57 _PD_Write_Byte_CLOCK:
m_genesis.kv 58 ret ; Fin.
m_genesis.kv 59 ;-----------------------------------------------------------------------------
m_genesis.kv 60 _Device_Init_CLOCK:
m_genesis.kv 61 mov rdi, _Clock_Slave ; Clock Slave
m_genesis.kv 62 call _Create_Thread ; Start the Clock Slave Thread
m_genesis.kv 63 ret
m_genesis.kv 64 ;-----------------------------------------------------------------------------
m_genesis.kv 65 _Device_Shutdown_CLOCK: ; Shutdown
m_genesis.kv 66 mov dword [CLOCK_Die], 0x01 ; Ask (unblocked) slave to die
m_genesis.kv 67 ret
m_genesis.kv 68 ;-----------------------------------------------------------------------------
m_genesis.kv 69
m_genesis.kv 70 ;-----------------------------------------------------------------------------
m_genesis.kv 71 _Clock_Slave:
m_genesis.kv 72 mov rax, _clock_interval_ts ; Set the 'nanosleep' interval
m_genesis.kv 73 call _Nano_Sleep ; Sleep for the given interval (nS)
m_genesis.kv 74 SetSlaveIRQ CLOCK_IRQ ; Invoke timer slave interrupt
m_genesis.kv 75 cmp dword [CLOCK_Die], 0x01 ; time to die?
m_genesis.kv 76 jne _Clock_Slave ; if not, keep going.
m_genesis.kv 77 jmp _exit_thread ; terminate thread
m_genesis.kv 78 ;-----------------------------------------------------------------------------
m_genesis.kv 79
m_genesis.kv 80 section .rodata
m_genesis.kv 81
m_genesis.kv 82 ;-----------------------------------------------------------------------------
m_genesis.kv 83 ; TS for Clock Slave interval:
m_genesis.kv 84 _clock_interval_ts:
m_genesis.kv 85 dq 0 ; seconds
m_genesis.kv 86 dq TIMER_SLAVE_PERIOD ; nanoseconds
m_genesis.kv 87 ;-----------------------------------------------------------------------------