Skip to content

Commit

Permalink
Kernel: Lay groundwork for Intel HD Audio driver
Browse files Browse the repository at this point in the history
  • Loading branch information
fido2020 committed Mar 3, 2021
1 parent 04b15e4 commit 2ee0cc0
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
66 changes: 66 additions & 0 deletions Kernel/include/audio/hdaudio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

// Intel HD Audio Driver for Lemon OS

#include <device.h>

namespace Audio {
class IntelHDAudioController : public Device {
struct ControllerRegs {
uint16_t globalCap; // Global Capabilities
uint8_t minorVersion;
uint8_t majorVersion;
uint16_t outputPayloadCap; // Output Payload Capability
uint16_t inputPayloadCap; // Input Payload Capability
uint32_t globalControl; // Global Control
uint16_t wakeEnable; // Wake Enable
uint16_t wakeStatus; // Wake Status
uint16_t globalStatus; // Global Status
uint8_t reserved[6];
uint16_t outputStreamPayloadCap; // Output Stream Payload Capability
uint16_t inputStreamPayloadCap; // Input Stream Payload Capability
uint8_t reserved2[4];
uint32_t intControl; // Interrupt Control
uint32_t intStatus; // Interrupt Status
uint8_t reserved3[8];
uint32_t wallClock; // Wall Clock Counter
uint8_t reserved4[4];
uint32_t streamSync; // Stream Synchronizatoin
uint8_t reserved5[4];
uint64_t corbBase; // CORB Base Address
uint16_t corbWriteP; // CORB Write Pointer
uint16_t corbReadP; // CORB Read Pointer
uint8_t corbControl; // CORB Control
uint8_t corbStatus; // CORB Status
uint8_t corbSize; // CORB Size
uint8_t reserved6;
uint64_t rirbBase; // RIRB Base
uint16_t rirbWriteP;
uint16_t rIntCount; // Response Interrupt Count
uint8_t rirbControl;
uint8_t rirbStatus;
uint8_t rirbSize;
uint8_t reserved7;
uint32_t immediateCmdOutputInterface; // Immediate Command Output Interface
uint32_t immediateCmdInputInterface; // Immediate Command Output Interface
uint16_t immediateCmdStatus;
uint8_t reserved8[6];
uint64_t dmaPositionBuffer;
uint8_t reserved9[8];
uint32_t streamDesc0Control : 24; // Input Stream Descriptor 0 Control
uint8_t streamDesc0Status;
uint32_t streamDesc0LinkPosInCurrentBuffer; // ISD0 Link Position in Current Buffer
uint32_t streamDesc0CyclicBufferLength;
uint16_t streamDesc0LastValidIndex;
uint8_t reserved10[2];
uint16_t streamDesc0FIFOSize;
uint16_t streamDesc0Format;
uint8_t reserved11[4];
uint64_t streamDesc0BufferDescListPtr;
} __attribute__((packed));

ControllerRegs* cRegs;

void Initialize();
};
}
2 changes: 2 additions & 0 deletions Kernel/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ cpp_files = [
'src/video.cpp',
'src/videoconsole.cpp',

'src/audio/hdaudio.cpp',

'src/fs/ext2.cpp',
'src/fs/fat32.cpp',
'src/fs/filesystem.cpp',
Expand Down
9 changes: 5 additions & 4 deletions Kernel/src/arch/x86_64/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,10 +2520,11 @@ long SysEndpointQueue(RegisterContext* r){

Handle* endpHandle;
if(Scheduler::FindHandle(currentProcess, SC_ARG0(r), &endpHandle)){
Log::Warning("(%s): SysEndpointQueue: Invalid handle ID %d", currentProcess->name, SC_ARG0(r));
Log::Info("%x", r->rip);
UserPrintStackTrace(r->rbp, Scheduler::GetCurrentProcess()->addressSpace);

IF_DEBUG(debugLevelSyscalls >= DebugLevelNormal, {
Log::Warning("(%s): SysEndpointQueue: Invalid handle ID %d", currentProcess->name, SC_ARG0(r));
Log::Info("%x", r->rip);
UserPrintStackTrace(r->rbp, Scheduler::GetCurrentProcess()->addressSpace);
});
return -EINVAL;
}

Expand Down
13 changes: 13 additions & 0 deletions Kernel/src/audio/hdaudio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <audio/hdaudio.h>

#include <pair.h>

namespace Audio {
static const Pair<uint16_t, uint16_t> controllerPCIIDs[] = {

};

void IntelHDAudioController::Initialize(){

}
}

0 comments on commit 2ee0cc0

Please sign in to comment.