* mikeOS 16 bit and amd64 baremetal
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / baremetal0.5.2 / programs / ethtool.asm
blobe83151adf1d51e394de968dbcac031667367f7e0
1 ; -----------------------------------------------------------------
2 ; EthTool v0.1 - Ethernet debugging tool
3 ; Ian Seyler @ Return Infinity
4 ; -----------------------------------------------------------------
7 [BITS 64]
8 [ORG 0x0000000000200000]
10 %INCLUDE "bmdev.asm"
12 ethtool:
14 mov rsi, startstring
15 call b_print_string
17 ethtool_command:
18 call b_input_key_wait
19 or al, 00100000b ; Convert character to lowercase if it is not already
21 cmp al, 's'
22 je ethtool_send
23 cmp al, 'r'
24 je ethtool_receive
25 cmp al, 'q'
26 je ethtool_finish
27 jmp ethtool_command ; Didn't get any key we were expecting so try again.
29 ethtool_finish:
30 call b_print_newline
31 ret ; Back to OS
33 ethtool_send:
34 mov rsi, sendstring
35 call b_print_string
36 mov rdi, broadcastaddress
37 mov rsi, startstring
38 mov rbx, 0xABBA
39 mov rcx, 63
40 call b_ethernet_tx
41 mov rsi, sentstring
42 call b_print_string
43 jmp ethtool_command
45 ethtool_receive:
46 mov rsi, receivestring
47 call b_print_string
48 mov rdi, EthernetBuffer
49 call b_ethernet_rx
50 cmp rcx, 0
51 je ethtool_receive_nopacket
52 mov rsi, receiveddata
53 call b_print_string
54 mov rsi, EthernetBuffer
55 call b_debug_dump_mem
56 jmp ethtool_command
58 ethtool_receive_nopacket:
59 mov rsi, receivednothingstring
60 call b_print_string
61 jmp ethtool_command
63 ; -----------------------------------------------------------------
65 startstring: db 'EthTool: S to send a packet, R to recieve a packet, Q to quit.', 0
66 sendstring: db 13, 'Sending packet, ', 0
67 sentstring: db 'Sent', 0
68 receivestring: db 13, 'Receiving packet, ', 0
69 receivednothingstring: db 'Nothing there', 0
70 receiveddata: db 'Data received', 13, 0
71 broadcastaddress: db 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0
72 EthernetBuffer: db 0