Skip to content
Snippets Groups Projects
Commit e957c67e authored by John Hodge's avatar John Hodge
Browse files

Kernel - Added pointer to IRQ callbacks

parent f8b9bcd7
Branches
Tags
No related merge requests found
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
#define TRACE_IRQS 0 #define TRACE_IRQS 0
// === TYPES === // === TYPES ===
typedef void (*tIRQ_Callback)(int); typedef void (*tIRQ_Callback)(int, void *);
// === PROTOTYPES === // === PROTOTYPES ===
void IRQ_Handler(tRegs *Regs); void IRQ_Handler(tRegs *Regs);
// === GLOBALS === // === GLOBALS ===
tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ]; tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ];
void *gaIRQ_DataPointers[16][MAX_CALLBACKS_PER_IRQ];
// === CODE === // === CODE ===
/** /**
...@@ -24,25 +25,23 @@ tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ]; ...@@ -24,25 +25,23 @@ tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ];
*/ */
void IRQ_Handler(tRegs *Regs) void IRQ_Handler(tRegs *Regs)
{ {
int i; int i, irq = Regs->int_num - 0xF0;
Regs->int_num -= 0xF0; // Adjust
//Log("IRQ_Handler: (Regs={int_num:%i})", Regs->int_num); //Log("IRQ_Handler: (Regs={int_num:%i})", Regs->int_num);
for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ ) for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
{ {
if( gIRQ_Handlers[Regs->int_num][i] ) { if( gIRQ_Handlers[irq][i] ) {
gIRQ_Handlers[Regs->int_num][i](Regs->int_num); gIRQ_Handlers[irq][i](irq, gaIRQ_DataPointers[irq][i]);
#if TRACE_IRQS #if TRACE_IRQS
if( Regs->int_num != 8 ) if( irq != 8 )
Log("IRQ %i: Call %p", Regs->int_num, gIRQ_Handlers[Regs->int_num][i]); Log("IRQ %i: Call %p", Regs->int_num, gIRQ_Handlers[Regs->int_num][i]);
#endif #endif
} }
} }
//Log(" IRQ_Handler: Resetting"); //Log(" IRQ_Handler: Resetting");
if(Regs->int_num >= 8) if(irq >= 8)
outb(0xA0, 0x20); // ACK IRQ (Secondary PIC) outb(0xA0, 0x20); // ACK IRQ (Secondary PIC)
outb(0x20, 0x20); // ACK IRQ outb(0x20, 0x20); // ACK IRQ
//Log("IRQ_Handler: RETURN"); //Log("IRQ_Handler: RETURN");
...@@ -51,7 +50,7 @@ void IRQ_Handler(tRegs *Regs) ...@@ -51,7 +50,7 @@ void IRQ_Handler(tRegs *Regs)
/** /**
* \fn int IRQ_AddHandler( int Num, void (*Callback)(int) ) * \fn int IRQ_AddHandler( int Num, void (*Callback)(int) )
*/ */
int IRQ_AddHandler( int Num, void (*Callback)(int) ) int IRQ_AddHandler( int Num, void (*Callback)(int, void*), void *Ptr )
{ {
int i; int i;
for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ ) for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
...@@ -59,6 +58,7 @@ int IRQ_AddHandler( int Num, void (*Callback)(int) ) ...@@ -59,6 +58,7 @@ int IRQ_AddHandler( int Num, void (*Callback)(int) )
if( gIRQ_Handlers[Num][i] == NULL ) { if( gIRQ_Handlers[Num][i] == NULL ) {
Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback); Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback);
gIRQ_Handlers[Num][i] = Callback; gIRQ_Handlers[Num][i] = Callback;
gaIRQ_DataPointers[Num][i] = Ptr;
return 1; return 1;
} }
} }
......
...@@ -30,7 +30,7 @@ volatile Uint64 giTime_TSCPerTick = 0; ...@@ -30,7 +30,7 @@ volatile Uint64 giTime_TSCPerTick = 0;
// === PROTOTYPES === // === PROTOTYPES ===
//Sint64 now(void); //Sint64 now(void);
int Time_Setup(void); int Time_Setup(void);
void Time_Interrupt(int); void Time_Interrupt(int IRQ, void *Ptr);
Uint64 Time_ReadTSC(void); Uint64 Time_ReadTSC(void);
// === CODE === // === CODE ===
...@@ -83,7 +83,7 @@ int Time_Setup(void) ...@@ -83,7 +83,7 @@ int Time_Setup(void)
outb(0x70, inb(0x70)|0x80); // Re-enable NMIs outb(0x70, inb(0x70)|0x80); // Re-enable NMIs
// Install IRQ Handler // Install IRQ Handler
IRQ_AddHandler(8, Time_Interrupt); IRQ_AddHandler(8, Time_Interrupt, NULL);
// Make sure the RTC actually fires // Make sure the RTC actually fires
outb(0x70, 0x0C); // Select register C outb(0x70, 0x0C); // Select register C
...@@ -96,7 +96,7 @@ int Time_Setup(void) ...@@ -96,7 +96,7 @@ int Time_Setup(void)
* \brief Called on the timekeeping IRQ * \brief Called on the timekeeping IRQ
* \param irq IRQ number (unused) * \param irq IRQ number (unused)
*/ */
void Time_Interrupt(int irq) void Time_Interrupt(int IRQ, void *Ptr)
{ {
//Log("RTC Tick"); //Log("RTC Tick");
Uint64 curTSC = Time_ReadTSC(); Uint64 curTSC = Time_ReadTSC();
......
...@@ -128,7 +128,7 @@ Desctab_Init: ...@@ -128,7 +128,7 @@ Desctab_Init:
ret ret
; int IRQ_AddHandler(int IRQ, void (*Handler)(int IRQ)) ; int IRQ_AddHandler(int IRQ, void (*Handler)(int IRQ), void *Ptr)
; Return Values: ; Return Values:
; 0 on Success ; 0 on Success
; -1 on an invalid IRQ Number ; -1 on an invalid IRQ Number
...@@ -137,6 +137,7 @@ Desctab_Init: ...@@ -137,6 +137,7 @@ Desctab_Init:
IRQ_AddHandler: IRQ_AddHandler:
; RDI - IRQ Number ; RDI - IRQ Number
; RSI - Callback ; RSI - Callback
; RDX - Ptr
; Check for RDI >= 16 ; Check for RDI >= 16
cmp rdi, 16 cmp rdi, 16
...@@ -153,8 +154,8 @@ IRQ_AddHandler: ...@@ -153,8 +154,8 @@ IRQ_AddHandler:
; Find a free callback slot ; Find a free callback slot
%rep NUM_IRQ_CALLBACKS %rep NUM_IRQ_CALLBACKS
mov rdx, [rax] mov rcx, [rax]
test rdx, rdx test rcx, rcx
jz .assign jz .assign
add rax, 8 add rax, 8
%endrep %endrep
...@@ -170,6 +171,7 @@ IRQ_AddHandler: ...@@ -170,6 +171,7 @@ IRQ_AddHandler:
push rdi push rdi
push rsi push rsi
push rax push rax
push rdx
sub rsp, 8 sub rsp, 8
mov rcx, rdi ; IRQ Number mov rcx, rdi ; IRQ Number
mov rdx, rsi ; Callback mov rdx, rsi ; Callback
...@@ -177,12 +179,15 @@ IRQ_AddHandler: ...@@ -177,12 +179,15 @@ IRQ_AddHandler:
mov rdi, csIRQ_Assigned mov rdi, csIRQ_Assigned
call Log call Log
add rsp, 8 add rsp, 8
pop rdx
pop rax pop rax
pop rsi pop rsi
pop rdi pop rdi
; Assign and return ; Assign and return
mov [rax], rsi mov [rax], rsi
add rax, gaIRQ_DataPtrs - gaIRQ_Handlers
mov [rax], rdx
xor rax, rax xor rax, rax
.ret: .ret:
...@@ -300,6 +305,7 @@ IrqCommon: ...@@ -300,6 +305,7 @@ IrqCommon:
jz .skip.%[i] jz .skip.%[i]
; Set RDI to IRQ number ; Set RDI to IRQ number
mov rdi, [rsp+(16+2+1)*8] ; Get IRQ number mov rdi, [rsp+(16+2+1)*8] ; Get IRQ number
mov rsi, [rbx-gaIRQ_Handlers+gaIRQ_DataPtrs]
call rax ; Call call rax ; Call
.skip.%[i]: .skip.%[i]:
add rbx, 8 ; Next! add rbx, 8 ; Next!
...@@ -433,3 +439,5 @@ gIDTPtr: ...@@ -433,3 +439,5 @@ gIDTPtr:
gaIRQ_Handlers: gaIRQ_Handlers:
times 16*NUM_IRQ_CALLBACKS dq 0 times 16*NUM_IRQ_CALLBACKS dq 0
gaIRQ_DataPtrs:
times 16*NUM_IRQ_CALLBACKS dq 0
...@@ -107,7 +107,7 @@ typedef struct sKernelSymbol { ...@@ -107,7 +107,7 @@ typedef struct sKernelSymbol {
// === FUNCTIONS === // === FUNCTIONS ===
// --- IRQs --- // --- IRQs ---
extern int IRQ_AddHandler(int Num, void (*Callback)(int)); extern int IRQ_AddHandler(int Num, void (*Callback)(int, void*), void *Ptr);
extern void IRQ_RemHandler(int Handle); extern void IRQ_RemHandler(int Handle);
// --- Logging --- // --- Logging ---
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
// === PROTOTYPES === // === PROTOTYPES ===
void KBC8042_Init(void); void KBC8042_Init(void);
void KBC8042_KeyboardHandler(int IRQ); void KBC8042_KeyboardHandler(int IRQ, void *Ptr);
void KBC8042_MouseHandler(int IRQ); void KBC8042_MouseHandler(int IRQ, void *Ptr);
void KBC8042_EnableMouse(void); void KBC8042_EnableMouse(void);
static inline void KBC8042_SendDataAlt(Uint8 data); static inline void KBC8042_SendDataAlt(Uint8 data);
static inline void KBC8042_SendData(Uint8 data); static inline void KBC8042_SendData(Uint8 data);
...@@ -20,8 +20,8 @@ static void KBC8042_SendMouseCommand(Uint8 cmd); ...@@ -20,8 +20,8 @@ static void KBC8042_SendMouseCommand(Uint8 cmd);
// === CODE === // === CODE ===
void KBC8042_Init(void) void KBC8042_Init(void)
{ {
IRQ_AddHandler(1, KBC8042_KeyboardHandler); IRQ_AddHandler(1, KBC8042_KeyboardHandler, NULL);
IRQ_AddHandler(12, KBC8042_MouseHandler); // Set IRQ IRQ_AddHandler(12, KBC8042_MouseHandler, NULL); // Set IRQ
{ {
Uint8 temp; Uint8 temp;
...@@ -34,7 +34,7 @@ void KBC8042_Init(void) ...@@ -34,7 +34,7 @@ void KBC8042_Init(void)
} }
} }
void KBC8042_KeyboardHandler(int IRQ) void KBC8042_KeyboardHandler(int IRQ, void *Ptr)
{ {
Uint8 scancode; Uint8 scancode;
...@@ -42,7 +42,7 @@ void KBC8042_KeyboardHandler(int IRQ) ...@@ -42,7 +42,7 @@ void KBC8042_KeyboardHandler(int IRQ)
KB_HandleScancode( scancode ); KB_HandleScancode( scancode );
} }
void KBC8042_MouseHandler(int IRQ) void KBC8042_MouseHandler(int IRQ, void *Ptr)
{ {
PS2Mouse_HandleInterrupt( inb(0x60) ); PS2Mouse_HandleInterrupt( inb(0x60) );
} }
......
...@@ -91,7 +91,7 @@ Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); ...@@ -91,7 +91,7 @@ Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
int Ne2k_int_ReadDMA(tCard *Card, int FirstPage, int NumPages, void *Buffer); int Ne2k_int_ReadDMA(tCard *Card, int FirstPage, int NumPages, void *Buffer);
Uint8 Ne2k_int_GetWritePage(tCard *Card, Uint16 Length); Uint8 Ne2k_int_GetWritePage(tCard *Card, Uint16 Length);
void Ne2k_IRQHandler(int IntNum); void Ne2k_IRQHandler(int IntNum, void *Ptr);
// === GLOBALS === // === GLOBALS ===
MODULE_DEFINE(0, VERSION, Ne2k, Ne2k_Install, NULL, NULL); MODULE_DEFINE(0, VERSION, Ne2k, Ne2k_Install, NULL, NULL);
...@@ -152,7 +152,7 @@ int Ne2k_Install(char **Options) ...@@ -152,7 +152,7 @@ int Ne2k_Install(char **Options)
gpNe2k_Cards[ k ].NextRXPage = RX_FIRST; gpNe2k_Cards[ k ].NextRXPage = RX_FIRST;
// Install IRQ Handler // Install IRQ Handler
IRQ_AddHandler(gpNe2k_Cards[ k ].IRQ, Ne2k_IRQHandler); IRQ_AddHandler(gpNe2k_Cards[ k ].IRQ, Ne2k_IRQHandler, &gpNe2k_Cards[k]);
// Reset Card // Reset Card
outb( base + 0x1F, inb(base + 0x1F) ); outb( base + 0x1F, inb(base + 0x1F) );
...@@ -506,41 +506,35 @@ Uint8 Ne2k_int_GetWritePage(tCard *Card, Uint16 Length) ...@@ -506,41 +506,35 @@ Uint8 Ne2k_int_GetWritePage(tCard *Card, Uint16 Length)
/** /**
* \fn void Ne2k_IRQHandler(int IntNum) * \fn void Ne2k_IRQHandler(int IntNum)
*/ */
void Ne2k_IRQHandler(int IntNum) void Ne2k_IRQHandler(int IntNum, void *Ptr)
{ {
int i;
Uint8 byte; Uint8 byte;
for( i = 0; i < giNe2k_CardCount; i++ ) tCard *card = Ptr;
{
if(gpNe2k_Cards[i].IRQ == IntNum) if(card->IRQ != IntNum) return;
{
byte = inb( gpNe2k_Cards[i].IOBase + ISR ); byte = inb( card->IOBase + ISR );
LOG("byte = 0x%02x", byte); LOG("byte = 0x%02x", byte);
// Reset All (save for RDMA), that's polled
outb( gpNe2k_Cards[i].IOBase + ISR, 0xFF&(~0x40) );
// 0: Packet recieved (no error) // Reset All (save for RDMA), that's polled
if( byte & 1 ) outb( card->IOBase + ISR, 0xFF&(~0x40) );
{
//if( gpNe2k_Cards[i].NumWaitingPackets > MAX_PACKET_QUEUE )
// gpNe2k_Cards[i].NumWaitingPackets = MAX_PACKET_QUEUE;
if( Semaphore_Signal( &gpNe2k_Cards[i].Semaphore, 1 ) != 1 ) {
// Oops?
}
}
// 1: Packet sent (no error)
// 2: Recieved with error
// 3: Transmission Halted (Excessive Collisions)
// 4: Recieve Buffer Exhausted
// 5:
// 6: Remote DMA Complete
// 7: Reset
return ; // 0: Packet recieved (no error)
if( byte & 1 )
{
//if( card->NumWaitingPackets > MAX_PACKET_QUEUE )
// card->NumWaitingPackets = MAX_PACKET_QUEUE;
if( Semaphore_Signal( &card->Semaphore, 1 ) != 1 ) {
// Oops?
} }
} }
Log_Warning("Ne2k", "Recieved Unknown IRQ %i", IntNum); // 1: Packet sent (no error)
// 2: Recieved with error
// 3: Transmission Halted (Excessive Collisions)
// 4: Recieve Buffer Exhausted
// 5:
// 6: Remote DMA Complete
// 7: Reset
} }
...@@ -97,7 +97,7 @@ tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename); ...@@ -97,7 +97,7 @@ tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename);
Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg); int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg);
void RTL8139_IRQHandler(int Num); void RTL8139_IRQHandler(int Num, void *Ptr);
// === GLOBALS === // === GLOBALS ===
MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL); MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL);
...@@ -149,7 +149,7 @@ int RTL8139_Install(char **Options) ...@@ -149,7 +149,7 @@ int RTL8139_Install(char **Options)
card->IRQ = PCI_GetIRQ( id ); card->IRQ = PCI_GetIRQ( id );
// Install IRQ Handler // Install IRQ Handler
IRQ_AddHandler(card->IRQ, RTL8139_IRQHandler); IRQ_AddHandler(card->IRQ, RTL8139_IRQHandler, card);
// Power on // Power on
outb( base + CONFIG1, 0x00 ); outb( base + CONFIG1, 0x00 );
...@@ -372,94 +372,90 @@ int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Data) ...@@ -372,94 +372,90 @@ int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Data)
return 0; return 0;
} }
void RTL8139_IRQHandler(int Num) void RTL8139_IRQHandler(int Num, void *Ptr)
{ {
int i, j; int j;
tCard *card; tCard *card = Ptr;
Uint16 status; Uint16 status;
LOG("Num = %i", Num); LOG("Num = %i", Num);
for( i = 0; i < giRTL8139_CardCount; i ++ ) if( Num != card->IRQ ) return;
{
card = &gaRTL8139_Cards[i];
if( Num != card->IRQ ) break;
status = inw(card->IOBase + ISR); status = inw(card->IOBase + ISR);
LOG("status = 0x%02x", status); LOG("status = 0x%02x", status);
// Transmit OK, a transmit descriptor is now free // Transmit OK, a transmit descriptor is now free
if( status & FLAG_ISR_TOK ) if( status & FLAG_ISR_TOK )
{
for( j = 0; j < 4; j ++ )
{ {
for( j = 0; j < 4; j ++ ) if( ind(card->IOBase + TSD0 + j*4) & 0x8000 ) { // TSD TOK
{ Mutex_Release( &card->TransmitInUse[j] );
if( ind(card->IOBase + TSD0 + j*4) & 0x8000 ) { // TSD TOK // TODO: Update semaphore once implemented
Mutex_Release( &card->TransmitInUse[j] );
// TODO: Update semaphore once implemented
}
} }
outw(card->IOBase + ISR, FLAG_ISR_TOK);
} }
outw(card->IOBase + ISR, FLAG_ISR_TOK);
}
// Recieve OK, inform read
if( status & FLAG_ISR_ROK )
{
int read_ofs, end_ofs;
int packet_count = 0;
int len;
// Recieve OK, inform read // Scan recieve buffer for packets
if( status & FLAG_ISR_ROK ) end_ofs = inw(card->IOBase + CBA);
read_ofs = card->SeenOfs;
LOG("read_ofs = %i, end_ofs = %i", read_ofs, end_ofs);
if( read_ofs > end_ofs )
{ {
int read_ofs, end_ofs; while( read_ofs < card->ReceiveBufferLength )
int packet_count = 0;
int len;
// Scan recieve buffer for packets
end_ofs = inw(card->IOBase + CBA);
read_ofs = card->SeenOfs;
LOG("read_ofs = %i, end_ofs = %i", read_ofs, end_ofs);
if( read_ofs > end_ofs )
{
while( read_ofs < card->ReceiveBufferLength )
{
packet_count ++;
len = *(Uint16*)&card->ReceiveBuffer[read_ofs+2];
LOG("%i 0x%x Pkt Hdr: 0x%04x, len: 0x%04x",
packet_count, read_ofs,
*(Uint16*)&card->ReceiveBuffer[read_ofs],
len
);
if(len > 2000) {
Log_Warning("RTL8139", "IRQ: Packet in buffer exceeds sanity (%i>2000)", len);
}
read_ofs += len + 4;
read_ofs = (read_ofs + 3) & ~3; // Align
}
read_ofs -= card->ReceiveBufferLength;
LOG("wrapped read_ofs");
}
while( read_ofs < end_ofs )
{ {
packet_count ++; packet_count ++;
len = *(Uint16*)&card->ReceiveBuffer[read_ofs+2];
LOG("%i 0x%x Pkt Hdr: 0x%04x, len: 0x%04x", LOG("%i 0x%x Pkt Hdr: 0x%04x, len: 0x%04x",
packet_count, read_ofs, packet_count, read_ofs,
*(Uint16*)&card->ReceiveBuffer[read_ofs], *(Uint16*)&card->ReceiveBuffer[read_ofs],
*(Uint16*)&card->ReceiveBuffer[read_ofs+2] len
); );
read_ofs += *(Uint16*)&card->ReceiveBuffer[read_ofs+2] + 4; if(len > 2000) {
Log_Warning("RTL8139", "IRQ: Packet in buffer exceeds sanity (%i>2000)", len);
}
read_ofs += len + 4;
read_ofs = (read_ofs + 3) & ~3; // Align read_ofs = (read_ofs + 3) & ~3; // Align
} }
if( read_ofs != end_ofs ) { read_ofs -= card->ReceiveBufferLength;
Log_Warning("RTL8139", "IRQ: read_ofs (%i) != end_ofs(%i)", read_ofs, end_ofs); LOG("wrapped read_ofs");
read_ofs = end_ofs; }
} while( read_ofs < end_ofs )
card->SeenOfs = read_ofs; {
packet_count ++;
LOG("packet_count = %i, read_ofs = 0x%x", packet_count, read_ofs); LOG("%i 0x%x Pkt Hdr: 0x%04x, len: 0x%04x",
packet_count, read_ofs,
if( packet_count ) *(Uint16*)&card->ReceiveBuffer[read_ofs],
{ *(Uint16*)&card->ReceiveBuffer[read_ofs+2]
if( Semaphore_Signal( &card->ReadSemaphore, packet_count ) != packet_count ) { );
// Oops? read_ofs += *(Uint16*)&card->ReceiveBuffer[read_ofs+2] + 4;
} read_ofs = (read_ofs + 3) & ~3; // Align
VFS_MarkAvaliable( &card->Node, 1 ); }
if( read_ofs != end_ofs ) {
Log_Warning("RTL8139", "IRQ: read_ofs (%i) != end_ofs(%i)", read_ofs, end_ofs);
read_ofs = end_ofs;
}
card->SeenOfs = read_ofs;
LOG("packet_count = %i, read_ofs = 0x%x", packet_count, read_ofs);
if( packet_count )
{
if( Semaphore_Signal( &card->ReadSemaphore, packet_count ) != packet_count ) {
// Oops?
} }
VFS_MarkAvaliable( &card->Node, 1 );
outw(card->IOBase + ISR, FLAG_ISR_ROK);
} }
}
outw(card->IOBase + ISR, FLAG_ISR_ROK);
}
} }
...@@ -79,8 +79,8 @@ Uint16 ATA_GetBasePort(int Disk); ...@@ -79,8 +79,8 @@ Uint16 ATA_GetBasePort(int Disk);
int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer); int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer); int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer);
// IRQs // IRQs
void ATA_IRQHandlerPri(int UNUSED(IRQ)); void ATA_IRQHandlerPri(int UNUSED(IRQ), void *UNUSED(Ptr));
void ATA_IRQHandlerSec(int UNUSED(IRQ)); void ATA_IRQHandlerSec(int UNUSED(IRQ), void *UNUSED(Ptr));
// Controller IO // Controller IO
Uint8 ATA_int_BusMasterReadByte(int Ofs); Uint8 ATA_int_BusMasterReadByte(int Ofs);
Uint32 ATA_int_BusMasterReadDWord(int Ofs); Uint32 ATA_int_BusMasterReadDWord(int Ofs);
...@@ -145,8 +145,8 @@ int ATA_SetupIO(void) ...@@ -145,8 +145,8 @@ int ATA_SetupIO(void)
} }
// Register IRQs and get Buffers // Register IRQs and get Buffers
IRQ_AddHandler( gATA_IRQPri, ATA_IRQHandlerPri ); IRQ_AddHandler( gATA_IRQPri, ATA_IRQHandlerPri, NULL );
IRQ_AddHandler( gATA_IRQSec, ATA_IRQHandlerSec ); IRQ_AddHandler( gATA_IRQSec, ATA_IRQHandlerSec, NULL );
gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[0] ); gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[0] );
gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[1] ); gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[1] );
...@@ -503,7 +503,7 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer) ...@@ -503,7 +503,7 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer)
/** /**
* \brief Primary ATA Channel IRQ handler * \brief Primary ATA Channel IRQ handler
*/ */
void ATA_IRQHandlerPri(int UNUSED(IRQ)) void ATA_IRQHandlerPri(int UNUSED(IRQ), void *UNUSED(Ptr))
{ {
Uint8 val; Uint8 val;
...@@ -521,7 +521,7 @@ void ATA_IRQHandlerPri(int UNUSED(IRQ)) ...@@ -521,7 +521,7 @@ void ATA_IRQHandlerPri(int UNUSED(IRQ))
/** /**
* \brief Second ATA Channel IRQ handler * \brief Second ATA Channel IRQ handler
*/ */
void ATA_IRQHandlerSec(int UNUSED(IRQ)) void ATA_IRQHandlerSec(int UNUSED(IRQ), void *UNUSED(Ptr))
{ {
Uint8 val; Uint8 val;
// IRQ bit set for Secondary Controller // IRQ bit set for Secondary Controller
......
...@@ -107,7 +107,7 @@ Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk); ...@@ -107,7 +107,7 @@ Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk);
int FDD_ReadSector(Uint32 disk, Uint64 lba, void *Buffer); int FDD_ReadSector(Uint32 disk, Uint64 lba, void *Buffer);
int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer); int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer);
// --- Helpers // --- Helpers
void FDD_IRQHandler(int Num); void FDD_IRQHandler(int Num, void *Ptr);
inline void FDD_WaitIRQ(); inline void FDD_WaitIRQ();
void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl); void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl);
int FDD_int_SendByte(int base, Uint8 Byte); int FDD_int_SendByte(int base, Uint8 Byte);
...@@ -172,7 +172,7 @@ int FDD_Install(char **Arguments) ...@@ -172,7 +172,7 @@ int FDD_Install(char **Arguments)
} }
// Install IRQ6 Handler // Install IRQ6 Handler
IRQ_AddHandler(6, FDD_IRQHandler); IRQ_AddHandler(6, FDD_IRQHandler, NULL);
// Ensure the FDD version is 0x90 // Ensure the FDD version is 0x90
{ {
...@@ -676,7 +676,7 @@ int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt) ...@@ -676,7 +676,7 @@ int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt)
* \fn void FDD_IRQHandler(int Num) * \fn void FDD_IRQHandler(int Num)
* \brief Handles IRQ6 * \brief Handles IRQ6
*/ */
void FDD_IRQHandler(int Num) void FDD_IRQHandler(int Num, void *Ptr)
{ {
gbFDD_IrqFired = 1; gbFDD_IrqFired = 1;
} }
......
...@@ -23,7 +23,7 @@ void UHCI_int_AppendTD(tUHCI_Controller *Cont, tUHCI_TD *TD); ...@@ -23,7 +23,7 @@ void UHCI_int_AppendTD(tUHCI_Controller *Cont, tUHCI_TD *TD);
int UHCI_DataOUT(void *Ptr, int Fcn, int Endpt, int DataTgl, void *Data, size_t Length); int UHCI_DataOUT(void *Ptr, int Fcn, int Endpt, int DataTgl, void *Data, size_t Length);
int UHCI_SendSetup(void *Ptr, int Fcn, int Endpt, int DataTgl, void *Data, size_t Length); int UHCI_SendSetup(void *Ptr, int Fcn, int Endpt, int DataTgl, void *Data, size_t Length);
int UHCI_Int_InitHost(tUHCI_Controller *Host); int UHCI_Int_InitHost(tUHCI_Controller *Host);
void UHCI_InterruptHandler(int IRQ); void UHCI_InterruptHandler(int IRQ, void *Ptr);
// === GLOBALS === // === GLOBALS ===
tUHCI_TD gaUHCI_TDPool[NUM_TDs]; tUHCI_TD gaUHCI_TDPool[NUM_TDs];
...@@ -64,7 +64,7 @@ int UHCI_Initialise(const char **Arguments) ...@@ -64,7 +64,7 @@ int UHCI_Initialise(const char **Arguments)
Log_Debug("UHCI", "Controller PCI #%i: IO Base = 0x%x, IRQ %i", Log_Debug("UHCI", "Controller PCI #%i: IO Base = 0x%x, IRQ %i",
id, cinfo->IOBase, cinfo->IRQNum); id, cinfo->IOBase, cinfo->IRQNum);
IRQ_AddHandler(cinfo->IRQNum, UHCI_InterruptHandler); IRQ_AddHandler(cinfo->IRQNum, UHCI_InterruptHandler, cinfo);
// Initialise Host // Initialise Host
ret = UHCI_Int_InitHost(&gUHCI_Controllers[i]); ret = UHCI_Int_InitHost(&gUHCI_Controllers[i]);
...@@ -204,8 +204,13 @@ int UHCI_Int_InitHost(tUHCI_Controller *Host) ...@@ -204,8 +204,13 @@ int UHCI_Int_InitHost(tUHCI_Controller *Host)
outw( Host->IOBase + FRNUM, 0 ); outw( Host->IOBase + FRNUM, 0 );
// Enable Interrupts // Enable Interrupts
//PCI_WriteWord( Host->PciId, 0xC0, 0x2000 ); // PCI_WriteWord( Host->PciId, 0xC0, 0x2000 );
LEAVE('i', 0); LEAVE('i', 0);
return 0; return 0;
} }
void UHCI_InterruptHandler(int IRQ, void *Ptr)
{
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment