-BUILD_NUM = 235
+BUILD_NUM = 237
typedef Uint32 tVAddr;
typedef struct {
- Uint gs, fs, es, ds;
- Uint edi, esi, ebp, kesp;
- Uint ebx, edx, ecx, eax;
- Uint int_num, err_code;
- Uint eip, cs;
- Uint eflags, esp, ss;
+ Uint32 gs, fs, es, ds;
+ Uint32 edi, esi, ebp, kesp;
+ Uint32 ebx, edx, ecx, eax;
+ Uint32 int_num, err_code;
+ Uint32 eip, cs;
+ Uint32 eflags, esp, ss;
} tRegs;
typedef struct {
%endif
call Proc_Scheduler
+[global scheduler_return]
+scheduler_return: ; Used by some hackery in Proc_DumpThreadCPUState
- add esp, 4 ; Remove Argument
+ add esp, 4 ; Remove CPU Number (thread is poped later)
%if USE_MP
test ebx, ebx
extern tThread gThreadZero;
extern void Isr8(void); // Double Fault
extern void Proc_ReturnToUser(tVAddr Handler, Uint Argument, tVAddr KernelStack);
+extern void scheduler_return; // Return address in SchedulerBase
+extern void IRQCommon; // Common IRQ handler code
// === PROTOTYPES ===
void ArchThreads_Init(void);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
void Proc_CallFaultHandler(tThread *Thread);
+void Proc_DumpThreadCPUState(tThread *Thread);
void Proc_Scheduler(int CPU);
// === GLOBALS ===
for(;;);
}
+void Proc_DumpThreadCPUState(tThread *Thread)
+{
+ Uint32 *stack = (void *)Thread->SavedState.EBP; // EBP = ESP after call and PUSH
+
+ if( Thread->CurCPU > -1 )
+ {
+ Log(" Currently running");
+ return ;
+ }
+
+ #if 1
+ tVAddr diffFromScheduler = Thread->SavedState.EIP - (tVAddr)Proc_Scheduler;
+ tVAddr diffFromClone = Thread->SavedState.EIP - (tVAddr)Proc_Clone;
+ tVAddr diffFromSpawn = Thread->SavedState.EIP - (tVAddr)Proc_SpawnWorker;
+
+ if( diffFromClone > 0 && diffFromClone < 512 ) // When I last checked, GetEIP was at .+0x183
+ {
+ // Just spawned full thread
+ Log(" Creating full thread");
+ return ;
+ }
+
+ if( diffFromSpawn > 0 && diffFromSpawn < 512 ) // When I last checked, GetEIP was at .+0x99
+ {
+ // Just spawned worker thread
+ Log(" Creating worker thread");
+ return ;
+ }
+
+ if( diffFromScheduler > 0 && diffFromScheduler < 256 ) // When I last checked, GetEIP was at .+0x60
+ #else
+ if( stack[1] == (Uint32)&IRQCommon + 25 )
+ {
+ tRegs *regs = (void *) stack[2];
+ Log(" oldebp = 0x%08x, ret = 0x%08x, regs = 0x%x",
+ stack[0], stack[1], stack[2]
+ );
+ // [EBP] = old EBP
+ // [EBP+0x04] = Return Addr
+ // [EBP+0x08] = Arg 1 (CPU Number)
+ // [EBP+0x0C] = Arg 2 (Thread)
+ // [EBP+0x10] = GS (start of tRegs)
+ Log(" IRQ%i from %02x:%08x", regs->int_num regs->cs, regs->eip);
+ }
+ if( stack[1] == (Uint32)&scheduler_return )
+ #endif
+ {
+ // Scheduled out
+ tRegs *regs = (void *) &stack[4];
+ Log(" oldebp = 0x%08x, ret = 0x%08x, cpu = %i, thread = 0x%x",
+ stack[0], stack[1], stack[2], stack[3]);
+ // [EBP] = old EBP
+ // [EBP+0x04] = Return Addr
+ // [EBP+0x08] = Arg 1 (CPU Number)
+ // [EBP+0x0C] = Arg 2 (Thread)
+ // [EBP+0x10] = GS (start of tRegs)
+ Log(" At %02x:%08x", regs->cs, regs->eip);
+ return ;
+ }
+
+ Log(" Just created");
+}
+
/**
* \fn void Proc_Scheduler(int CPU)
* \brief Swap current thread and clears dead threads
#endif
#if USE_MP // MP Debug
- Log("CPU = %i, Thread %p", CPU, thread);
+// Log("CPU = %i, Thread %p", CPU, thread);
#endif
// Update Kernel Stack pointer
// === IMPORTS ===
extern void ArchThreads_Init(void);
extern void Proc_CallFaultHandler(tThread *Thread);
+extern void Proc_DumpThreadCPUState(tThread *Thread);
extern int GetCPUNum(void);
// === PROTOTYPES ===
// Set state
Thread->Status = THREAD_STAT_ACTIVE;
- Thread->CurCPU = -1;
// Add to active list
#if SCHEDULER_TYPE == SCHED_RR_PRI
Thread->Next = gaActiveThreads[Thread->Priority];
giNumActiveThreads ++;
#if SCHEDULER_TYPE == SCHED_LOTTERY
- giFreeTickets += caiTICKET_COUNTS[ Thread->Priority ];
- # if DEBUG_TRACE_TICKETS
- Log("Threads_AddActive: CPU%i %p %i (%s) added, new giFreeTickets = %i",
- GetCPUNum(), Thread, Thread->TID, Thread->ThreadName, giFreeTickets);
- # endif
+ {
+ int delta;
+ // Only change the ticket count if the thread is un-scheduled
+ if(Thread->CurCPU != -1)
+ delta = 0;
+ else
+ delta = caiTICKET_COUNTS[ Thread->Priority ];
+
+ giFreeTickets += delta;
+ # if DEBUG_TRACE_TICKETS
+ Log("CPU%i %p (%i %s) added, new giFreeTickets = %i [+%i]",
+ GetCPUNum(), Thread, Thread->TID, Thread->ThreadName,
+ giFreeTickets, delta
+ );
+ # endif
+ }
#endif
SHORTREL( &glThreadListLock );
ret->Next = NULL;
ret->Remaining = 0;
- ret->CurCPU = -1;
giNumActiveThreads --;
// no need to decrement tickets, scheduler did it for us
#if SCHEDULER_TYPE == SCHED_LOTTERY && DEBUG_TRACE_TICKETS
- Log("Threads_RemActive: CPU%i %p %i (%s) removed, giFreeTickets = %i",
+ Log("CPU%i %p (%i %s) removed, giFreeTickets = %i [nc]",
GetCPUNum(), ret, ret->TID, ret->ThreadName, giFreeTickets);
#endif
Log(" ERROR State (%i) != THREAD_STAT_ACTIVE (%i)", thread->Status, THREAD_STAT_ACTIVE);
Log(" Priority %i, Quantum %i", thread->Priority, thread->Quantum);
Log(" KStack 0x%x", thread->KernelStack);
+ Proc_DumpThreadCPUState(thread);
}
#if SCHEDULER_TYPE == SCHED_RR_PRI
#if SCHEDULER_TYPE == SCHED_LOTTERY
giFreeTickets += caiTICKET_COUNTS[ Last->Priority ];
# if DEBUG_TRACE_TICKETS
- LogF(" CPU %i released %p (%i %s) into the pool (%i tickets in pool)\n",
- CPU, Last, Last->TID, Last->ThreadName, giFreeTickets);
+ LogF("Log: CPU%i released %p (%i %s) into the pool (%i [+%i] tickets in pool)\n",
+ CPU, Last, Last->TID, Last->ThreadName, giFreeTickets,
+ caiTICKET_COUNTS[ Last->Priority ]);
# endif
#endif
}
#if SCHEDULER_TYPE == SCHED_LOTTERY && DEBUG_TRACE_TICKETS
else
- LogF(" CPU %i released %p (%i %s)->Status = %i (Released)\n",
+ LogF("Log: CPU%i released %p (%i %s)->Status = %i (Released)\n",
CPU, Last, Last->TID, Last->ThreadName, Last->Status);
#endif
Last->CurCPU = -1;
Panic("Bookeeping Failed - giFreeTickets(%i) > true count (%i)",
giFreeTickets, number);
}
- # if DEBUG_TRACE_TICKETS
- LogF(" CPU%i giFreeTickets = %i, running %p (%i %s CPU=%i)\n",
- CPU, giFreeTickets, thread, thread->TID, thread->ThreadName, thread->CurCPU);
- # endif
giFreeTickets -= caiTICKET_COUNTS[ thread->Priority ];
+ # if DEBUG_TRACE_TICKETS
+ LogF("Log: CPU%i allocated %p (%i %s), (%i [-%i] tickets in pool), \n",
+ CPU, thread, thread->TID, thread->ThreadName,
+ giFreeTickets, caiTICKET_COUNTS[ thread->Priority ]);
+ # endif
}
// ---
UnHex(addrData, size, addr);
tInterface *iface = IPStack_AddInterface(dev, "");
+ if( !iface ) {
+ Log_Warning("IPStack", "Unable to add interface on '%s'", dev);
+ continue ;
+ }
iface->Type = iType;
memcpy(iface->Address, addrData, size);
iface->SubnetBits = iBits;
int NextRXPage; //!< Next expected RX page
int NextMemPage; //!< Next Card Memory page to use
-
- //Uint8 Buffer[RX_BUF_SIZE*256];
-
+
char Name[2]; // "0"
tVFS_Node Node; //!< VFS Node
Uint8 MacAddr[6]; //!< Cached MAC address
outb( base + ISR, 0xFF );
outb( base + RCR, 0x20 ); // Reciever to Monitor
outb( base + TCR, 0x02 ); // Transmitter OFF (TCR.LB = 1, Internal Loopback)
+
+ // Read MAC Address
outb( base + RBCR0, 6*4 ); // Remote Byte Count
outb( base + RBCR1, 0 );
outb( base + RSAR0, 0 ); // Clear Source Address
outb( base + RSAR1, 0 );
outb( base + CMD, 0x0A ); // Remote Read, Start
-
- // Read MAC Address
gpNe2k_Cards[ k ].MacAddr[0] = inb(base+0x10);// inb(base+0x10);
gpNe2k_Cards[ k ].MacAddr[1] = inb(base+0x10);// inb(base+0x10);
gpNe2k_Cards[ k ].MacAddr[2] = inb(base+0x10);// inb(base+0x10);
outb( base+RCR, 0x0F ); // Set WRAP and allow all packet matches
outb( base+TCR, 0x00 ); // Set Normal Transmitter mode
outb( base+TPSR, 0x40); // Set Transmit Start
- // Set MAC Address
- /*
- Ne2k_WriteReg(base, MAC0, gpNe2k_Cards[ k ].MacAddr[0]);
- Ne2k_WriteReg(base, MAC1, gpNe2k_Cards[ k ].MacAddr[1]);
- Ne2k_WriteReg(base, MAC2, gpNe2k_Cards[ k ].MacAddr[2]);
- Ne2k_WriteReg(base, MAC3, gpNe2k_Cards[ k ].MacAddr[3]);
- Ne2k_WriteReg(base, MAC4, gpNe2k_Cards[ k ].MacAddr[4]);
- Ne2k_WriteReg(base, MAC5, gpNe2k_Cards[ k ].MacAddr[5]);
- */
Log_Log("Ne2k", "Card %i 0x%04x IRQ%i %02x:%02x:%02x:%02x:%02x:%02x",
k, base, gpNe2k_Cards[ k ].IRQ,
+++ /dev/null
-/*
- * Acess2 RTL8139 Driver
- * - By John Hodge (thePowersGang)
- *
- * main.c - Driver Core
- */
-#define DEBUG 0
-#define VERSION ((0<<8)|50)
-#include <acess.h>
-#include <modules.h>
-#include <fs_devfs.h>
-#include <drv_pci.h>
-#include <tpl_drv_network.h>
-
-// === CONSTANTS ===
-enum eRTL8139_Regs
-{
- MAC0, MAC1, MAC2,
- MAC3, MAC4, MAC5,
- MAR0 = 0x08,
- MAR1, MAR2, MAR3,
- MAR4, MAR5, MAR6, MAR7,
-
- RBSTART = 0x30, //!< Recieve Buffer Start (DWord)
- // 0x31, 0x32, 0x33
-
- // ??, ??, ??, RST, RE, TE, ??, ??
- CMD = 0x37,
- IMR = 0x3C,
- ISR = 0x3E,
-
- RCR = 0x44,
-
- CONFIG1 = 0x52
-};
-
-// === TYPES ===
-typedef struct sCard
-{
- Uint16 IOBase;
- Uint8 IRQ;
-
- int NumWaitingPackets;
-
- void *ReceiveBuffer;
- tPAddr PhysReceiveBuffer;
-
- char Name[2];
- tVFS_Node Node;
- Uint8 MacAddr[6];
-} tCard;
-
-// === PROTOTYPES ===
- int RTL8139_Install(char **Options);
-char *RTL8139_ReadDir(tVFS_Node *Node, int Pos);
-tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename);
- int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg);
-Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-void RTL8139_IRQHandler(int Num);
-
-// === GLOBALS ===
-MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL);
-tDevFS_Driver gRTL8139_DriverInfo = {
- NULL, "RTL8139",
- {
- .NumACLs = 1,
- .ACLs = &gVFS_ACL_EveryoneRX,
- .Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = RTL8139_ReadDir,
- .FindDir = RTL8139_FindDir,
- .IOCtl = RTL8139_RootIOCtl
- }
-};
- int giRTL8139_CardCount;
-tCard *gpRTL8139_Cards;
-
-// === CODE ===
-/**
- * \brief Installs the RTL8139 Driver
- */
-int RTL8139_Install(char **Options)
-{
- int id = -1;
- int i = 0;
- Uint16 base;
-
- giRTL8139_CardCount = PCI_CountDevices( 0x10EC, 0x8139, 0 );
-
- gpRTL8139_Cards = calloc( giRTL8139_CardCount, sizeof(tCard) );
-
-
- while( (id = PCI_GetDevice(0x10EC, 0x8139, 0, id)) != -1 )
- {
- base = PCI_AssignPort( id, 0, 0x100 );
- gpRTL8139_Cards[i].IOBase = base;
- gpRTL8139_Cards[i].IRQ = PCI_GetIRQ( id );
-
- // Install IRQ Handler
- IRQ_AddHandler(gpRTL8139_Cards[ k ].IRQ, RTL8136_IRQHandler);
-
- // Power on
- outb( base + CONFIG1, 0x00 );
- // Reset (0x10 to CMD)
- outb( base + CMD, 0x10 );
-
- while( inb(base + CMD) & 0x10 ) ;
-
- // Allocate 3 pages below 4GiB for the recieve buffer (Allows 8k+16+1500)
- gpRTL8139_Cards[i].ReceiveBuffer = MM_AllocDMA( 3, 32, &gpRTL8139_Cards[i].PhysReceiveBuffer );
- // Set up recieve buffer
- outl(base + RBSTART, (Uint32)gpRTL8139_Cards[i].PhysReceiveBuffer);
- // Set IMR to Transmit OK and Receive OK
- outw(base + IMR, 0x5);
-
- // Set recieve buffer size and recieve mask
- outl(base + RCR, 0x0F);
-
- outb(base + CMD, 0x0C); // Recive Enable and Transmit Enable
-
- // Get the card's MAC address
- gpRTL8139_Cards[ i ].MacAddr[0] = inb(base+MAC0);
- gpRTL8139_Cards[ i ].MacAddr[1] = inb(base+MAC1);
- gpRTL8139_Cards[ i ].MacAddr[2] = inb(base+MAC2);
- gpRTL8139_Cards[ i ].MacAddr[3] = inb(base+MAC3);
- gpRTL8139_Cards[ i ].MacAddr[4] = inb(base+MAC4);
- gpRTL8139_Cards[ i ].MacAddr[5] = inb(base+MAC5);
-
- // Set VFS Node
- gpRTL8139_Cards[ i ].Name[0] = '0'+i;
- gpRTL8139_Cards[ i ].Name[1] = '\0';
- gpRTL8139_Cards[ i ].Node.ImplPtr = &gpRTL8139_Cards[ i ];
- gpRTL8139_Cards[ i ].Node.NumACLs = 0;
- gpRTL8139_Cards[ i ].Node.CTime = now();
- gpRTL8139_Cards[ i ].Node.Write = RTL8139_Write;
- gpRTL8139_Cards[ i ].Node.Read = RTL8139_Read;
- gpRTL8139_Cards[ i ].Node.IOCtl = RTL8139_IOCtl;
-
- Log_Log("RTL8139", "Card %i 0x%04x %02x:%02x:%02x:%02x:%02x:%02x",
- i, base,
- gpRTL8139_Cards[ i ].MacAddr[0], gpRTL8139_Cards[ i ].MacAddr[1],
- gpRTL8139_Cards[ i ].MacAddr[2], gpRTL8139_Cards[ i ].MacAddr[3],
- gpRTL8139_Cards[ i ].MacAddr[4], gpRTL8139_Cards[ i ].MacAddr[5]
- );
-
- i ++;
- }
- return MODULE_ERR_OK;
-}
-
-// --- Root Functions ---
-char *RTL8139_ReadDir(tVFS_Node *Node, int Pos)
-{
- if( Pos < 0 || Pos > giRTL8139_CardCount ) return NULL;
-
- return strdup( gpRTL8139_Cards[Pos].Name );
-}
-
-tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename)
-{
- //TODO: It might be an idea to supprt >10 cards
- if(Filename[0] == '\0' || Filename[0] != '\0') return NULL;
- if(Filename[0] < '0' || Filename[0] > '9') return NULL;
- return &gpRTL8139_Cards[ Filename[0]-'0' ].Node;
-}
-
-const char *csaRTL8139_RootIOCtls[] = {DRV_IOCTLNAMES, NULL};
-int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg)
-{
- switch(ID)
- {
- BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_RootIOCtls);
- }
- return 0;
-}
-
-// --- File Functions ---
-Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
-{
- return 0;
-}
-
-Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
-{
- return 0;
-}
-
-const char *csaRTL8139_NodeIOCtls[] = {DRV_IOCTLNAMES, NULL};
-int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg)
-{
- switch(ID)
- {
- BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_NodeIOCtls);
- }
- return 0;
-}
--- /dev/null
+/*
+ * Acess2 RTL8139 Driver
+ * - By John Hodge (thePowersGang)
+ */
+#define DEBUG 0
+#define VERSION ((0<<8)|50)
+#include <acess.h>
+#include <modules.h>
+#include <fs_devfs.h>
+#include <drv_pci.h>
+#include <tpl_drv_network.h>
+
+// === CONSTANTS ===
+enum eRTL8139_Regs
+{
+ MAC0, MAC1, MAC2,
+ MAC3, MAC4, MAC5,
+ MAR0 = 0x08,
+ MAR1, MAR2, MAR3,
+ MAR4, MAR5, MAR6, MAR7,
+
+ RBSTART = 0x30, //!< Recieve Buffer Start (DWord)
+ // 0x31, 0x32, 0x33
+
+ // ??, ??, ??, RST, RE, TE, ??, ??
+ CMD = 0x37,
+ IMR = 0x3C,
+ ISR = 0x3E,
+
+ RCR = 0x44,
+
+ CONFIG1 = 0x52
+};
+
+// === TYPES ===
+typedef struct sCard
+{
+ Uint16 IOBase;
+ Uint8 IRQ;
+
+ int NumWaitingPackets;
+
+ void *ReceiveBuffer;
+ tPAddr PhysReceiveBuffer;
+
+ char Name[2];
+ tVFS_Node Node;
+ Uint8 MacAddr[6];
+} tCard;
+
+// === PROTOTYPES ===
+ int RTL8139_Install(char **Options);
+char *RTL8139_ReadDir(tVFS_Node *Node, int Pos);
+tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename);
+ int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg);
+Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+void RTL8139_IRQHandler(int Num);
+
+// === GLOBALS ===
+MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL);
+tDevFS_Driver gRTL8139_DriverInfo = {
+ NULL, "RTL8139",
+ {
+ .NumACLs = 1,
+ .ACLs = &gVFS_ACL_EveryoneRX,
+ .Flags = VFS_FFLAG_DIRECTORY,
+ .ReadDir = RTL8139_ReadDir,
+ .FindDir = RTL8139_FindDir,
+ .IOCtl = RTL8139_RootIOCtl
+ }
+};
+ int giRTL8139_CardCount;
+tCard *gpRTL8139_Cards;
+
+// === CODE ===
+/**
+ * \brief Installs the RTL8139 Driver
+ */
+int RTL8139_Install(char **Options)
+{
+ int id = -1;
+ int i = 0;
+ Uint16 base;
+
+ giRTL8139_CardCount = PCI_CountDevices( 0x10EC, 0x8139, 0 );
+
+ gpRTL8139_Cards = calloc( giRTL8139_CardCount, sizeof(tCard) );
+
+
+ while( (id = PCI_GetDevice(0x10EC, 0x8139, 0, id)) != -1 )
+ {
+ base = PCI_AssignPort( id, 0, 0x100 );
+ gpRTL8139_Cards[i].IOBase = base;
+ gpRTL8139_Cards[i].IRQ = PCI_GetIRQ( id );
+
+ // Install IRQ Handler
+ IRQ_AddHandler(gpRTL8139_Cards[ k ].IRQ, RTL8136_IRQHandler);
+
+ // Power on
+ outb( base + CONFIG1, 0x00 );
+
+ // Reset (0x10 to CMD)
+ outb( base + CMD, 0x10 );
+ while( inb(base + CMD) & 0x10 ) ;
+
+ // Set up recieve buffer
+ // - Allocate 3 pages below 4GiB for the recieve buffer (Allows 8k+16+1500)
+ gpRTL8139_Cards[i].ReceiveBuffer = MM_AllocDMA( 3, 32, &gpRTL8139_Cards[i].PhysReceiveBuffer );
+ outl(base + RBSTART, (Uint32)gpRTL8139_Cards[i].PhysReceiveBuffer);
+ // Set IMR to Transmit OK and Receive OK
+ outw(base + IMR, 0x5);
+
+ // Set recieve buffer size and recieve mask
+ // - Bit 7 being unset tells the card to overflow the recieve buffer if needed
+ // (i.e. when the packet starts at the end of the bufffer, it overflows up
+ // to 1500 bytes)
+ outl(base + RCR, 0x0F);
+
+ // Recive Enable and Transmit Enable
+ outb(base + CMD, 0x0C);
+
+ // Get the card's MAC address
+ gpRTL8139_Cards[ i ].MacAddr[0] = inb(base+MAC0);
+ gpRTL8139_Cards[ i ].MacAddr[1] = inb(base+MAC1);
+ gpRTL8139_Cards[ i ].MacAddr[2] = inb(base+MAC2);
+ gpRTL8139_Cards[ i ].MacAddr[3] = inb(base+MAC3);
+ gpRTL8139_Cards[ i ].MacAddr[4] = inb(base+MAC4);
+ gpRTL8139_Cards[ i ].MacAddr[5] = inb(base+MAC5);
+
+ // Set VFS Node
+ gpRTL8139_Cards[ i ].Name[0] = '0'+i;
+ gpRTL8139_Cards[ i ].Name[1] = '\0';
+ gpRTL8139_Cards[ i ].Node.ImplPtr = &gpRTL8139_Cards[ i ];
+ gpRTL8139_Cards[ i ].Node.NumACLs = 0;
+ gpRTL8139_Cards[ i ].Node.CTime = now();
+ gpRTL8139_Cards[ i ].Node.Write = RTL8139_Write;
+ gpRTL8139_Cards[ i ].Node.Read = RTL8139_Read;
+ gpRTL8139_Cards[ i ].Node.IOCtl = RTL8139_IOCtl;
+
+ Log_Log("RTL8139", "Card %i 0x%04x %02x:%02x:%02x:%02x:%02x:%02x",
+ i, base,
+ gpRTL8139_Cards[ i ].MacAddr[0], gpRTL8139_Cards[ i ].MacAddr[1],
+ gpRTL8139_Cards[ i ].MacAddr[2], gpRTL8139_Cards[ i ].MacAddr[3],
+ gpRTL8139_Cards[ i ].MacAddr[4], gpRTL8139_Cards[ i ].MacAddr[5]
+ );
+
+ i ++;
+ }
+ return MODULE_ERR_OK;
+}
+
+// --- Root Functions ---
+char *RTL8139_ReadDir(tVFS_Node *Node, int Pos)
+{
+ if( Pos < 0 || Pos > giRTL8139_CardCount ) return NULL;
+
+ return strdup( gpRTL8139_Cards[Pos].Name );
+}
+
+tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename)
+{
+ //TODO: It might be an idea to supprt >10 cards
+ if(Filename[0] == '\0' || Filename[0] != '\0') return NULL;
+ if(Filename[0] < '0' || Filename[0] > '9') return NULL;
+ return &gpRTL8139_Cards[ Filename[0]-'0' ].Node;
+}
+
+const char *csaRTL8139_RootIOCtls[] = {DRV_IOCTLNAMES, NULL};
+int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg)
+{
+ switch(ID)
+ {
+ BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_RootIOCtls);
+ }
+ return 0;
+}
+
+// --- File Functions ---
+Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+{
+ return 0;
+}
+
+Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+{
+ return 0;
+}
+
+const char *csaRTL8139_NodeIOCtls[] = {DRV_IOCTLNAMES, NULL};
+int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg)
+{
+ switch(ID)
+ {
+ BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_NodeIOCtls);
+ }
+ return 0;
+}
*
* Disk Input/Output control
*/
-#define DEBUG 1
+#define DEBUG 0
#include <acess.h>
#include <modules.h> // Needed for error codes
#include <drv_pci.h>
$(_BIN): $(OBJ)
@mkdir -p $(dir $(_BIN))
- @echo --- $(LD) -o $@
+ @echo [LD] -o $@
ifneq ($(_DBGMAKEFILE),)
$(LD) -g $(LDFLAGS) -o $@ $(OBJ) -Map Map.txt
else
@$(DISASM) $(_BIN) > $(BIN).dsm
$(OBJ): $(_OBJPREFIX)%.o: %.c
- @echo --- GCC -o $@
+ @echo [CC] -o $@
ifneq ($(_OBJPREFIX),)
@mkdir -p $(_OBJPREFIX)
endif