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();
}
}
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?