OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 20, 2024 9:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Intel HDA DMA buffers not working
PostPosted: Fri Sep 11, 2020 2:51 pm 
Offline

Joined: Thu Sep 10, 2020 12:44 pm
Posts: 3
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:
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group