Intel HDA DMA buffers not working

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Menotdan
Posts: 3
Joined: Thu Sep 10, 2020 12:44 pm

Intel HDA DMA buffers not working

Post by Menotdan »

I'm working on an Intel HDA driver for my OS, and I'm having an issue where the CORB read pointer won't update even after I update the write pointer. I have mapped the HDA register area, CORB, and RIRB as uncacheable. I have enabled the DMA engine for the CORB and for the RIRB.

Code: Select all

void write_corb(uint64_t controller_id, uint32_t data) {
    if (controller_id >= hda_controller_count) {
        warn("{-HDA-} A write to a CORB on a nonexistent controller was requested!");
        return;
    }

    hda_audio_controller_t controller = hda_controller_list[controller_id];
    volatile uint32_t *corb_address = GET_HIGHER_HALF(void *, ((uint64_t) controller.register_address->corb_lower_addr | ((uint64_t) controller.register_address->corb_higher_addr << 32)));
    corb_address[controller.register_address->corb_write_ptr & 255] = 0; // Testing, I read this helps
    controller.register_address->corb_write_ptr++;
    corb_address[controller.register_address->corb_write_ptr & 255] = data;
    controller.register_address->corb_write_ptr++;

    log("{-HDA-} Waiting for read pointer to equal write pointer...");
    while ((controller.register_address->corb_read_ptr & 0b11111111) != (controller.register_address->corb_write_ptr & 0b11111111)) {
        log("{-HDA-} Read ptr: %lu, Write ptr: %lu", (controller.register_address->corb_read_ptr & 0b11111111), (controller.register_address->corb_write_ptr & 0b11111111)); // testing
        sleep_ms(500); // testing
        asm("pause");

        if ((controller.register_address->corb_status & 0x1)) {
            log("{-HDA-} Memory error bit set in CORB");
        }

        if (!(controller.register_address->corb_control & (1<<1))) {
            log("{-HDA-} CORB not enabled!");
        }
    }

    log("{-HDA-} Waiting for 1 ms...");
    for (uint64_t i = 0; i < 2500; i++) { // Wait 1 ms for testing purposes
        io_wait();
    }
}
Above is my code for writing to the CORB.
The full code is here: https://github.com/Menotdan/DripOS/blob ... ntel_hda.c

I saw someone on these forums mention that they had to update the RIRB read buffer, not sure what they meant.

Any ideas on what could be wrong?
Post Reply