More to the point, when I disable the in and out lines in the code below, it works (I have to disable both lines for it to work). I used the Serial_Ports wiki sample code as inspiration.
Code: Select all
DbgConsolePutChar:
push rbp ; save the caller's frame
mov.q rbp,rsp ; create our own frame
push rdx ; save rdx
.loop: mov.q rdx,(DBG_PORT+5) ; we want the LSR
in al,dx ; read the port
test.b al,0x20 ; mask out the transmit buffer flag
jz .loop ; loop until it is empty
mov.q rdx,(DBG_PORT+0) ; we want the serial port
mov.q rax,[rbp+16] ; get the character to write
cmp.q rax,13 ; is the char a <CR>?
jne .put ; if not, put it on the serial port
mov.q rax,10 ; make it a LF
.put: out dx,al ; write the char to the serial port
pop rdx ; restore rdx
pop rbp ; restore caller's frame
ret
Code: Select all
DbgConsoleInit:
push rbp ; save the caller's frame
mov.q rbp,rsp ; create our own frame
push rdx ; save rdx
xor.q rax,rax ; clear the entire rax register
mov.q rdx,(DBG_PORT+1) ; we want the IER port
out dx,al ; disable interrupts
mov.b al,0x80 ; need to setup the baud rate divisor
mov.q rdx,(DBG_PORT+3) ; we want the LCR port
out dx,al ; enable the DLAB registers
mov.b al,0x03 ; the divisor is 3 for 38.4K baud
mov.q rdx,(DBG_PORT+0) ; we want the base port
out dx,al ; send the lo byte to the UART
mov.b al,0x00 ; set the upper byte
mov.q rdx,(DBG_PORT+1) ; we want the base port + 1
out dx,al ; send the hi byte to the UART
mov.b al,0x03 ; disable DLAB, set bits to 8-N-1
mov.q rdx,(DBG_PORT+3) ; we want the LCR port
out dx,al ; set the line setup
mov.b al,0xc7 ; we don't need a FIFO
mov.q rdx,(DBG_PORT+2) ; we want the FCR port
out dx,al ; set the FIFO parms
mov.b al,0x0b ; we don't want interrupts
mov.q rdx,(DBG_PORT+4) ; we want the MCR port
out dx,al ; No interrupts
pop rdx ; restore rdx
pop rbp ; restore caller's frame
ret