<commit_before>//! I/O port functionality.

/// Write 8 bits to port
pub unsafe fn outb(port: u16, val: u8) {
    asm!("outb %al, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 8 bits from port
pub unsafe fn inb(port: u16) -> u8 {
    let ret: u8;
    asm!("inb %dx, %al" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

/// Write 16 bits to port
pub unsafe fn outw(port: u16, val: u16) {
    asm!("outw %ax, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 16 bits from port
pub unsafe fn inw(port: u16) -> u16 {
    let ret: u16;
    asm!("inw %dx, %ax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

/// Write 32 bits to port
pub unsafe fn outl(port: u16, val: u32) {
    asm!("outl %eax, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 32 bits from port
pub unsafe fn inl(port: u16) -> u32 {
    let ret: u32;
    asm!("inl %dx, %eax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

// Write 8-bit array to port
pub unsafe fn outsb(port: u16, buf: &[u8]) {
    asm!("rep outsb (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

// Read 8-bit array from port
pub unsafe fn insb(port: u16, buf: &mut [u8]) {
    asm!("rep insb %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}

// Write 16-bit array to port
pub unsafe fn outsw(port: u16, buf: &[u16]) {
    asm!("rep outsw (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

// Read 16-bit array from port
pub unsafe fn insw(port: u16, buf: &mut [u16]) {
    asm!("rep insw %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}

// Write 32-bit array to port
pub unsafe fn outsl(port: u16, buf: &[u32]) {
    asm!("rep outsl (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

// Read 32-bit array from port
pub unsafe fn insl(port: u16, buf: &mut [u32]) {
    asm!("rep insl %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}<commit_msg>Make io assembly inlinable and fix doc comments<commit_after>//! I/O port functionality.

/// Write 8 bits to port
#[inline]
pub unsafe fn outb(port: u16, val: u8) {
    asm!("outb %al, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 8 bits from port
#[inline]
pub unsafe fn inb(port: u16) -> u8 {
    let ret: u8;
    asm!("inb %dx, %al" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

/// Write 16 bits to port
#[inline]
pub unsafe fn outw(port: u16, val: u16) {
    asm!("outw %ax, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 16 bits from port
#[inline]
pub unsafe fn inw(port: u16) -> u16 {
    let ret: u16;
    asm!("inw %dx, %ax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

/// Write 32 bits to port
#[inline]
pub unsafe fn outl(port: u16, val: u32) {
    asm!("outl %eax, %dx" :: "{dx}"(port), "{al}"(val));
}

/// Read 32 bits from port
#[inline]
pub unsafe fn inl(port: u16) -> u32 {
    let ret: u32;
    asm!("inl %dx, %eax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
    ret
}

/// Write 8-bit array to port
#[inline]
pub unsafe fn outsb(port: u16, buf: &[u8]) {
    asm!("rep outsb (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

/// Read 8-bit array from port
#[inline]
pub unsafe fn insb(port: u16, buf: &mut [u8]) {
    asm!("rep insb %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}

/// Write 16-bit array to port
#[inline]
pub unsafe fn outsw(port: u16, buf: &[u16]) {
    asm!("rep outsw (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

/// Read 16-bit array from port
#[inline]
pub unsafe fn insw(port: u16, buf: &mut [u16]) {
    asm!("rep insw %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}

/// Write 32-bit array to port
#[inline]
pub unsafe fn outsl(port: u16, buf: &[u32]) {
    asm!("rep outsl (%esi), %dx"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
         : "ecx", "edi");
}

/// Read 32-bit array from port
#[inline]
pub unsafe fn insl(port: u16, buf: &mut [u32]) {
    asm!("rep insl %dx, (%edi)"
         :: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
         : "ecx", "edi" : "volatile");
}
{'fraction_non_alphanumeric': 0.266199649737303, 'fraction_numerical': 0.03021015761821366, 'mean_word_length': 2.9730434782608697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2785296', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1874, 'n_words': 519}