2021-09-24 02:28:48 +00:00
|
|
|
(import-macros {:sss ! : compile} :ssc.macros)
|
|
|
|
(local {: cmd : response} (require :link.udpdebug))
|
|
|
|
|
2021-09-26 04:34:48 +00:00
|
|
|
; sudo route add -net 172.24.1.0/24 gw 192.168.2.25
|
|
|
|
|
2021-09-25 18:53:18 +00:00
|
|
|
; -VEDRIVE
|
|
|
|
; CAT,S1
|
|
|
|
; BLOAD UDPDEBUG.SYSTEM, TSYS, A$2000
|
|
|
|
; CALL-151
|
|
|
|
; 2000S
|
|
|
|
|
2021-09-24 02:28:48 +00:00
|
|
|
(local Ssc (require :ssc))
|
|
|
|
|
|
|
|
(local ssc (Ssc))
|
|
|
|
|
|
|
|
(compile ssc
|
2021-09-25 18:53:18 +00:00
|
|
|
(start-symbol boot-8)
|
|
|
|
(org 0x2000)
|
|
|
|
(fn boot-8 ()
|
|
|
|
(asm (clc) (xce) (rep 0x30) ; disable emulation mode, 16-bit index registers
|
|
|
|
(jsr debug-server-loop)
|
|
|
|
(sec) (xce))) ; re-enter emulation mode
|
|
|
|
|
2021-09-24 02:28:48 +00:00
|
|
|
(require ssc.stdlib)
|
2021-09-27 03:07:36 +00:00
|
|
|
(require ssc.iigs.toolbox)
|
2021-09-24 02:28:48 +00:00
|
|
|
|
2021-09-27 03:07:36 +00:00
|
|
|
(macro out [#(! (WriteLine (far-ref (pstr [$2]))))])
|
|
|
|
|
|
|
|
(buffer hexbuf (cstr " "))
|
|
|
|
(fn printnum (num)
|
|
|
|
(long! (ref hexbuf) (HexIt num))
|
|
|
|
(WriteCString (far-ref hexbuf)))
|
2021-09-29 00:19:13 +00:00
|
|
|
|
|
|
|
(require ssc.iigs.uthernet2)
|
|
|
|
|
2021-09-24 02:28:48 +00:00
|
|
|
(fn u2-init-debug-server ()
|
2021-09-27 03:07:36 +00:00
|
|
|
(out "Starting server")
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-reset)
|
2021-10-03 15:44:45 +00:00
|
|
|
(u2-udp-server-start 6502))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
2021-09-27 03:07:36 +00:00
|
|
|
(buffer u2-debug-buffer 1500)
|
2021-09-24 02:28:48 +00:00
|
|
|
|
2021-09-27 00:32:17 +00:00
|
|
|
(predef-fn u2-debug-server-poll () void far)
|
2021-09-24 02:28:48 +00:00
|
|
|
|
2021-10-03 15:44:45 +00:00
|
|
|
(global word u2-debug-server-paused false)
|
2021-09-24 02:28:48 +00:00
|
|
|
(fn u2-debug-server-cmd-write (msgid)
|
2021-10-03 15:44:45 +00:00
|
|
|
(set! u2-debug-server-paused true)
|
2021-09-24 02:28:48 +00:00
|
|
|
(let (addr (long-at (ref u2-debug-buffer))
|
|
|
|
size (word-at (+ (ref u2-debug-buffer) 4)))
|
|
|
|
(memcpy (+ (far-ref u2-debug-buffer) 6) addr size)
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-begin 2)
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-write msgid)
|
|
|
|
(u2-write [response.ack])
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-complete)))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
|
|
|
(fn u2-debug-server-cmd-read (msgid)
|
|
|
|
(let (addr (long-at (ref u2-debug-buffer))
|
|
|
|
size (word-at (+ (ref u2-debug-buffer) 4)))
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-begin (+ size 2))
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-write msgid)
|
|
|
|
(u2-write [response.data])
|
|
|
|
(u2-write-farbuf addr size)
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-complete)))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
2021-10-03 15:44:45 +00:00
|
|
|
(fn u2-debug-server-cmd-exec (msgid)
|
|
|
|
(let (val (asm (jsr u2-debug-buffer))
|
|
|
|
longval (asm-long))
|
|
|
|
(u2-tx-begin 8)
|
|
|
|
(u2-write msgid)
|
|
|
|
(u2-write [response.data])
|
|
|
|
(u2-write-word val)
|
|
|
|
(u2-write-word (loword longval))
|
|
|
|
(u2-write-word (hiword longval))
|
|
|
|
(u2-tx-complete)))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
|
|
|
(fn u2-debug-server-cmd-pause (msgid)
|
2021-10-03 15:44:45 +00:00
|
|
|
(set! u2-debug-server-paused (word-at (ref u2-debug-buffer)))
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-begin 3)
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-write msgid)
|
|
|
|
(u2-write [response.ack])
|
|
|
|
(u2-write u2-debug-server-paused)
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-complete)
|
2021-09-24 02:28:48 +00:00
|
|
|
(while u2-debug-server-paused
|
|
|
|
(u2-debug-server-poll)))
|
|
|
|
|
|
|
|
(fn u2-debug-server-cmd-ping (msgid)
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-begin 2)
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-write msgid)
|
|
|
|
(u2-write [response.ack])
|
2021-10-01 02:25:04 +00:00
|
|
|
(u2-tx-complete))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
|
|
|
(fn u2-debug-server-cmd (msgid cmd)
|
|
|
|
(if (= cmd [cmd.write]) (u2-debug-server-cmd-write msgid)
|
|
|
|
(= cmd [cmd.read]) (u2-debug-server-cmd-read msgid)
|
2021-10-03 15:44:45 +00:00
|
|
|
(= cmd [cmd.eval]) (u2-debug-server-cmd-exec msgid)
|
2021-09-24 02:28:48 +00:00
|
|
|
(= cmd [cmd.pause]) (u2-debug-server-cmd-pause msgid)
|
|
|
|
(= cmd [cmd.ping]) (u2-debug-server-cmd-ping msgid)))
|
|
|
|
|
2021-09-25 18:53:18 +00:00
|
|
|
(far-fn u2-debug-server-poll ()
|
2021-09-24 02:28:48 +00:00
|
|
|
(let (size (u2-rx-begin))
|
2021-09-29 00:19:13 +00:00
|
|
|
(when size
|
2021-09-24 02:28:48 +00:00
|
|
|
(let (msgid (u2-read)
|
|
|
|
cmd (u2-read))
|
2021-09-29 00:19:13 +00:00
|
|
|
(printnum msgid) (printnum cmd) (out "Got message!")
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-read-buf (ref u2-debug-buffer) (- size 2))
|
|
|
|
(u2-rx-complete)
|
2021-10-03 15:44:45 +00:00
|
|
|
(u2-set-tx-dest u2-udp-recv-ip u2-udp-recv-port)
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-debug-server-cmd msgid cmd)))))
|
|
|
|
|
2021-09-25 18:53:18 +00:00
|
|
|
(fn debug-server-loop ()
|
2021-09-27 03:07:36 +00:00
|
|
|
(TextStartUp)
|
|
|
|
(IMStartUp)
|
2021-09-24 02:28:48 +00:00
|
|
|
(u2-init-debug-server)
|
2021-10-03 15:44:45 +00:00
|
|
|
(forever (u2-debug-server-poll)))
|
2021-09-24 02:28:48 +00:00
|
|
|
)
|
|
|
|
|
2021-09-25 18:53:18 +00:00
|
|
|
(let [Prodos (require :asm.prodos)
|
|
|
|
prg (ssc:assemble)
|
|
|
|
disk (Prodos "ProDOS_Blank.dsk")]
|
|
|
|
(disk:update-volume-header {:name "UDP.DEBUG"})
|
|
|
|
(disk:add-file "UDPDEBUG.SYSTEM" Prodos.file-type.SYS 0x2000 (. (prg:org 0x2000) :block :bytes))
|
|
|
|
(disk:write "UdpDebug.dsk"))
|
2021-09-24 02:28:48 +00:00
|
|
|
|
|
|
|
ssc
|