Search code examples
ckernelbochs

bochs gives "write to port 0xb004 with len 1 ignored" error


I am trying to use ACPI in my kernel development study. When the port_byte_out(0xB004, 0x0000 | 0x2000) code is executed, bochs gives 'write to port 0xb004 with len 1 ignored' error. The C function is as follows:

void port_byte_out(unsigned short port, unsigned char data) {
    __asm__("out %%al, %%dx" : : "a" (data), "d" (port));
}

What does that error means?


Solution

  • I think you meant to be using asm instruction outb instead of out. outb outputs a byte to a port where as out writes a 2 byte word.Consider changing the code to:

    __asm__("outb %%al, %%dx" : : "a" (data), "d" (port));
    

    Although you defined the function void port_byte_out(unsigned short port, unsigned char data) with a second parameter of unsigned char data your example port_byte_out(0xB004, 0x0000 | 0x2000) attempted to pass a 2 byte word (short int) as data. port_byte_out suggests you want that function to output a byte. 0x0000 | 0x2000 will get truncated since it is bigger than an unsigned char. Most compilers should have thrown a warning about that.

    Maybe you meant to have another function:

    void port_word_out(unsigned short port, unsigned short data) {
        __asm__("out %%ax, %%dx" : : "a" (data), "d" (port));
    }
    

    Then you could have called it as:

    port_word_out(0xB004, 0x0000 | 0x2000)