.intel_syntax noprefix

.global x86_64_outb
x86_64_outb:
    mov dx, di
    mov al, sil
    out dx, al
    ret

.global x86_64_inb
x86_64_inb:
    mov dx, di
    xor eax, eax
    in al, dx
    ret

.global x86_64_inw
x86_64_inw:
    mov dx, di
    xor eax, eax
    in ax, dx
    ret

.global x86_64_outw
x86_64_outw:
    mov dx, di
    mov ax, si
    out dx, ax
    ret

.global x86_64_outl
x86_64_outl:
    mov dx, di
    mov eax, esi
    out dx, eax
    ret

.global x86_64_inl
x86_64_inl:
    mov dx, di
    xor eax, eax
    in eax, dx
    ret

.global x86_64_insw
x86_64_insw:
    test rdx, rdx
    jz .inswdone
    mov rcx, rdx
    mov dx, di
    mov rdi, rsi
    cld
    rep insw
.inswdone:
    ret

.global x86_64_outsw
x86_64_outsw:
    test rdx, rdx
    jz .outswdone
    mov rcx, rdx
    mov dx, di
    mov rsi, rsi
    cld
    rep outsw
.outswdone:
    ret

.global x86_64_Panic
x86_64_Panic:
    cli
    hlt
1:  jmp 1b

.global x86_64_EnableInterrupts
x86_64_EnableInterrupts:
    sti
    ret

.global x86_64_DisableInterrupts
x86_64_DisableInterrupts:
    cli
    ret

.global x86_64_iowait
x86_64_iowait:
    out 0x80, al   // classic I/O wait
    ret

.global x86_64_crashme
x86_64_crashme:
    xor rdx, rdx
    mov rax, 1
    mov rbx, 0
    div rbx
    ret