From: John Hodge Date: Sat, 10 Apr 2010 01:31:59 +0000 (+0800) Subject: Fixed a bug in the heap manager where if an exact match of the block is found, garbag... X-Git-Tag: rel0.06~251 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=60149f3ea48a795f9fbb15149e87d3a41aa136bf;p=tpg%2Facess2.git Fixed a bug in the heap manager where if an exact match of the block is found, garbage is returned --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index 2453f866..a1e5f087 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1802 +BUILD_NUM = 1811 diff --git a/Kernel/arch/x86/vm8086.c b/Kernel/arch/x86/vm8086.c index 6853cbfe..8ef7453e 100644 --- a/Kernel/arch/x86/vm8086.c +++ b/Kernel/arch/x86/vm8086.c @@ -74,7 +74,7 @@ int VM8086_Install(char **Arguments) //MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO ); // Set Read Only } MM_Map( 0, 0 ); // IVT / BDA - for(i=0x70;i<0x80;i++) { + for(i=0x10;i<0x9F;i++) { MM_Map( i * 0x1000, i * 0x1000 ); MM_DerefPhys( i * 0x1000 ); } MM_Map( 0x9F000, 0x9F000 ); // Stack / EBDA diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index 69d85b3a..cf4efc72 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -42,13 +42,10 @@ typedef struct { int Flags; //!< Flags (see VT_FLAG_*) short Width; //!< Virtual Width short Height; //!< Virtual Height - short RealWidth; //!< Real Width - short RealHeight; //!< Real Height int ViewPos; //!< View Buffer Offset (Text Only) int WritePos; //!< Write Buffer Offset (Text Only) Uint32 CurColour; //!< Current Text Colour - char Name[2]; //!< Name of the terminal int InputRead; //!< Input buffer read position int InputWrite; //!< Input buffer write position @@ -57,6 +54,7 @@ typedef struct { tVT_Char *Text; Uint32 *Buffer; }; + char Name[2]; //!< Name of the terminal tVFS_Node Node; } tVTerm; @@ -102,6 +100,10 @@ tDevFS_Driver gVT_DrvInfo = { // --- Terminals --- tVTerm gVT_Terminals[NUM_VTS]; int giVT_CurrentTerminal = 0; +// --- Video State --- +short giVT_RealWidth; //!< Real Width +short giVT_RealHeight; //!< Real Height + int gbVT_TextMode = 1; // --- Driver Handles --- char *gsVT_OutputDevice = NULL; char *gsVT_InputDevice = NULL; @@ -350,7 +352,7 @@ Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) VT_int_PutString(term, Buffer, Length); break; case TERM_MODE_FB: - if( term->RealWidth > term->Width || term->RealHeight > term->Height ) + if( giVT_RealWidth > term->Width || giVT_RealHeight > term->Height ) { #if 0 int x, y, h; @@ -444,36 +446,39 @@ int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data) return -1; } -/** - * \fn void VT_SetTerminal(int ID) - * \brief Set the current terminal - */ -void VT_SetTerminal(int ID) +void VT_SetResolution(int IsTextMode, int Width, int Height) { tVideo_IOCtl_Mode mode = {0}; - int modeNum; + int tmp; // Create the video mode - mode.width = gVT_Terminals[ ID ].Width; - mode.height = gVT_Terminals[ ID ].Height; - // - Text Mode - if(gVT_Terminals[ ID ].Mode == TERM_MODE_TEXT) { - mode.bpp = 12; - mode.flags = VIDEO_FLAG_TEXT; - } - // - Framebuffer or 3D - else { - mode.bpp = 32; - mode.flags = 0; - } + mode.width = Width; + mode.height = Height; + mode.bpp = 32; + mode.flags = 0; // Set video mode VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_FINDMODE, &mode ); - modeNum = mode.id; - gVT_Terminals[ ID ].RealWidth = mode.width; - gVT_Terminals[ ID ].RealHeight = mode.height; - VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &modeNum ); + tmp = mode.id; + giVT_RealWidth = mode.width; + giVT_RealHeight = mode.height; + VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &tmp ); + + + if(IsTextMode) + tmp = VIDEO_BUFFMT_TEXT; + else + tmp = VIDEO_BUFFMT_FRAMEBUFFER; + VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp ); +} + +/** + * \fn void VT_SetTerminal(int ID) + * \brief Set the current terminal + */ +void VT_SetTerminal(int ID) +{ // Update current terminal ID Log_Log("VTerm", "Changed terminal from %i to %i", giVT_CurrentTerminal, ID); giVT_CurrentTerminal = ID; @@ -915,21 +920,41 @@ void VT_int_UpdateScreen( tVTerm *Term, int UpdateAll ) if( Term->Mode == TERM_MODE_TEXT ) { - if(UpdateAll) { - VFS_WriteAt( - giVT_OutputDevHandle, - 0, - Term->Width*Term->Height*sizeof(tVT_Char), - &Term->Text[Term->ViewPos] - ); - } else { - int pos = Term->WritePos - Term->WritePos % Term->Width; - VFS_WriteAt( - giVT_OutputDevHandle, - (pos - Term->ViewPos)*sizeof(tVT_Char), - Term->Width*sizeof(tVT_Char), - &Term->Text[pos] - ); + if(gbVT_TextMode) + { + if(UpdateAll) { + VFS_WriteAt( + giVT_OutputDevHandle, + 0, + Term->Width*Term->Height*sizeof(tVT_Char), + &Term->Text[Term->ViewPos] + ); + } else { + int pos = Term->WritePos - Term->WritePos % Term->Width; + VFS_WriteAt( + giVT_OutputDevHandle, + (pos - Term->ViewPos)*sizeof(tVT_Char), + Term->Width*sizeof(tVT_Char), + &Term->Text[pos] + ); + } + } + else + { + //TODO: Do VT Rendered Text + #if 0 + if( UpdateAll ) { + VT_RenderText(0, Term->Width*Term->Height, &Term->Text[Term->ViewPos]); + } + else { + int pos = Term->WritePos - Term->WritePos % Term->Width; + VT_RenderText( + pos - Term->ViewPos, + Term->Width, + &Term->Text[pos] + ); + } + #endif } } else diff --git a/Kernel/heap.c b/Kernel/heap.c index 3a0edb37..9d282b98 100644 --- a/Kernel/heap.c +++ b/Kernel/heap.c @@ -151,7 +151,7 @@ void *malloc(size_t Bytes) // Alignment Check if( head->Size & (BLOCK_SIZE-1) ) { #if WARNINGS - Warning("Size of heap address %p is invalid not aligned (0x%x)", head, head->Size); + Log_Warning("Heap", "Size of heap address %p is invalid not aligned (0x%x)", head, head->Size); Heap_Dump(); #endif RELEASE(&glHeap); @@ -163,7 +163,7 @@ void *malloc(size_t Bytes) // Error check if(head->Magic != MAGIC_FREE) { #if WARNINGS - Warning("Magic of heap address %p is invalid (0x%x)", head, head->Magic); + Log_Warning("Heap", "Magic of heap address %p is invalid (0x%x)", head, head->Magic); Heap_Dump(); #endif RELEASE(&glHeap); // Release spinlock @@ -178,9 +178,9 @@ void *malloc(size_t Bytes) head->Magic = MAGIC_USED; RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", head->Data, head->Size, __builtin_return_address(0)); #endif - return best->Data; + return head->Data; } // Break out of loop @@ -210,7 +210,7 @@ void *malloc(size_t Bytes) if(best->Size == Bytes) { RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0)); #endif return best->Data; } @@ -231,7 +231,7 @@ void *malloc(size_t Bytes) RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0)); #endif return best->Data; } @@ -246,8 +246,8 @@ void free(void *Ptr) tHeapFoot *foot; #if DEBUG_TRACE - LOG("Ptr = %p", Ptr); - LOG("Returns to %p", __builtin_return_address(0)); + Log_Log("Heap", "free: Ptr = %p", Ptr); + Log_Log("Heap", "free: Returns to %p", __builtin_return_address(0)); #endif // Alignment Check @@ -414,31 +414,31 @@ void Heap_Dump() while( (Uint)head < (Uint)gHeapEnd ) { foot = (void*)( (Uint)head + head->Size - sizeof(tHeapFoot) ); - Log("%p (0x%x): 0x%08lx 0x%lx", head, MM_GetPhysAddr((Uint)head), head->Size, head->Magic); - Log("%p 0x%lx", foot->Head, foot->Magic); - Log(""); + Log_Log("Heap", "%p (0x%x): 0x%08lx 0x%lx", head, MM_GetPhysAddr((Uint)head), head->Size, head->Magic); + Log_Log("Heap", "%p 0x%lx", foot->Head, foot->Magic); + Log_Log("Heap", ""); // Sanity Check Header if(head->Size == 0) { - Log("HALTED - Size is zero"); + Log_Warning("Heap", "HALTED - Size is zero"); break; } if(head->Size & (BLOCK_SIZE-1)) { - Log("HALTED - Size is malaligned"); + Log_Warning("Heap", "HALTED - Size is malaligned"); break; } if(head->Magic != MAGIC_FREE && head->Magic != MAGIC_USED) { - Log("HALTED - Head Magic is Bad"); + Log_Warning("Heap", "HALTED - Head Magic is Bad"); break; } // Check footer if(foot->Magic != MAGIC_FOOT) { - Log("HALTED - Foot Magic is Bad"); + Log_Warning("Heap", "HALTED - Foot Magic is Bad"); break; } if(head != foot->Head) { - Log("HALTED - Footer backlink is invalid"); + Log_Warning("Heap", "HALTED - Footer backlink is invalid"); break; } diff --git a/Kernel/include/fs_devfs.h b/Kernel/include/fs_devfs.h index 54f4280d..f75a7ffe 100644 --- a/Kernel/include/fs_devfs.h +++ b/Kernel/include/fs_devfs.h @@ -21,10 +21,15 @@ typedef struct sDevFS_Driver // === FUNCTIONS === /** * \fn int DevFS_AddDevice(tDevFS_Driver *Dev) - * \brief Registers a device in the Device filesystem - * \param Dev Pointer to a persistant structure that represents the driver + * \brief Registers a device in the Device Filesystem + * \param Device Pointer to a persistant structure that represents the driver * \return Boolean success */ -extern int DevFS_AddDevice(tDevFS_Driver *Dev); +extern int DevFS_AddDevice(tDevFS_Driver *Device); + +/** + * \brief Unregisters a device with the Device Filesystem + */ +extern void DevFS_DelDevice(tDevFS_Driver *Device); #endif diff --git a/Kernel/include/tpl_drv_video.h b/Kernel/include/tpl_drv_video.h index bf3d286d..ebbe98fa 100644 --- a/Kernel/include/tpl_drv_video.h +++ b/Kernel/include/tpl_drv_video.h @@ -12,12 +12,20 @@ * but they may choose not to allow direct user access to the framebuffer. * * \section Screen Contents - * Reads and writes to the driver's file while in component colour modes + * Writes to the driver's file while in component colour modes * must correspond to a change of the contents of the screen. The framebuffer * must start at offset 0 in the file. * In pallete colour modes the LFB is preceded by a 1024 byte pallete (allowing * room for 256 entries of 32-bits each) -*/ + * Reading from the screen must either return zero, or read from the + * framebuffer. + * + * \section Mode Support + * All video drivers must support at least one text mode (Mode #0) + * For each graphics mode the driver exposes, there must be a corresponding + * text mode with the same resolution, this mode will be used when the + * user switches to a text Virtual Terminal while in graphics mode. + */ #ifndef _TPL_VIDEO_H #define _TPL_VIDEO_H @@ -59,6 +67,17 @@ enum eTplVideo_IOCtl { */ VIDEO_IOCTL_MODEINFO, + /** + * ioctl(..., int *NewFormat) + * \brief Switches between Text, Framebuffer and 3D modes + * \param NewFormat Pointer to the new format code (see eTplVideo_BufFormats) + * \return Original format + * + * Enabes and disables the video text mode, changing the behavior of + * writes to the device file. + */ + VIDEO_IOCTL_SETBUFFORMAT, + /** * ioctl(..., tVideo_IOCtl_Pos *pos) * \brief Sets the cursor position @@ -101,18 +120,15 @@ typedef struct sVideo_IOCtl_Mode Uint8 flags; //!< Mode Flags } tVideo_IOCtl_Mode; -//! \name Video Mode flags -//! \{ -/** - * \brief Text Mode Flag - * \note A text mode should have the ::sVideo_IOCtl_Mode.bpp set to 12 - */ -#define VIDEO_FLAG_TEXT 0x1 /** - * \brief Slow (non-accellerated mode) + * \brief Buffer Format Codes */ -#define VIDEO_FLAG_SLOW 0x2 -//! \} +enum eTplVideo_BufFormats +{ + VIDEO_BUFFMT_TEXT, + VIDEO_BUFFMT_FRAMEBUFFER, + VIDEO_BUFFMT_3DSTREAM +}; /** * \brief Describes a position in the video framebuffer diff --git a/Kernel/vfs/fs/devfs.c b/Kernel/vfs/fs/devfs.c index d396a1f8..b7379ad5 100644 --- a/Kernel/vfs/fs/devfs.c +++ b/Kernel/vfs/fs/devfs.c @@ -8,7 +8,8 @@ #include // === PROTOTYPES === - int DevFS_AddDevice(tDevFS_Driver *Dev); + int DevFS_AddDevice(tDevFS_Driver *Device); +void DevFS_DelDevice(tDevFS_Driver *Device); tVFS_Node *DevFS_InitDevice(char *Device, char **Options); char *DevFS_ReadDir(tVFS_Node *Node, int Pos); tVFS_Node *DevFS_FindDir(tVFS_Node *Node, char *Name); @@ -27,17 +28,73 @@ tVFS_Node gDevFS_RootNode = { }; tDevFS_Driver *gDevFS_Drivers = NULL; int giDevFS_NextID = 1; +tSpinlock glDevFS_ListLock; // === CODE === /** - * \fn int DevFS_AddDevice(tDevFS_Driver *Dev) + * \fn int DevFS_AddDevice(tDevFS_Driver *Device) */ -int DevFS_AddDevice(tDevFS_Driver *Dev) +int DevFS_AddDevice(tDevFS_Driver *Device) { - Dev->Next = gDevFS_Drivers; - gDevFS_Drivers = Dev; - gDevFS_RootNode.Size ++; - return giDevFS_NextID++; + int ret = 0; + tDevFS_Driver *dev; + + LOCK( &glDevFS_ListLock ); + + // Check if the device is already registered or the name is taken + for( dev = gDevFS_Drivers; dev; dev = dev->Next ) + { + if(dev == Device) break; + if(strcmp(dev->Name, Device->Name) == 0) break; + } + + if(dev) { + if(dev == Device) + Log_Warning("DevFS", "Device %p '%s' attempted to register itself twice", + dev, dev->Name); + else + Log_Warning("DevFS", "Device %p attempted to register '%s' which was owned by %p", + Device, dev->Name, dev); + ret = 0; // Error + } + else { + Device->Next = gDevFS_Drivers; + gDevFS_Drivers = Device; + gDevFS_RootNode.Size ++; + ret = giDevFS_NextID ++; + } + RELEASE( &glDevFS_ListLock ); + + return ret; +} + +/** + * \brief Delete a device from the DevFS folder + */ +void DevFS_DelDevice(tDevFS_Driver *Device) +{ + tDevFS_Driver *prev = NULL, *dev; + + LOCK( &glDevFS_ListLock ); + // Search list for device + for(dev = gDevFS_Drivers; + dev && dev != Device; + prev = dev, dev = dev->Next + ); + + // Check if it was found + if(dev) + { + if(prev) + prev->Next = Device->Next; + else + gDevFS_Drivers = Device->Next; + } + else + Log_Warning("DevFS", "Attempted to unregister device %p '%s' which was not registered", + Device, Device->Name); + + RELEASE( &glDevFS_ListLock ); } /** @@ -64,7 +121,10 @@ char *DevFS_ReadDir(tVFS_Node *Node, int Pos) dev = dev->Next ); - return strdup(dev->Name); + if(dev) + return strdup(dev->Name); + else + return NULL; } /** @@ -96,3 +156,4 @@ tVFS_Node *DevFS_FindDir(tVFS_Node *Node, char *Name) // --- EXPORTS --- EXPORT(DevFS_AddDevice); +EXPORT(DevFS_DelDevice); diff --git a/Modules/Display/BochsGA/bochsvbe.c b/Modules/Display/BochsGA/bochsvbe.c index 1ed46ccb..8f73ccbd 100644 --- a/Modules/Display/BochsGA/bochsvbe.c +++ b/Modules/Display/BochsGA/bochsvbe.c @@ -15,18 +15,14 @@ #define INT // === TYPES === -typedef struct { +typedef struct sBGA_Mode { Uint16 width; Uint16 height; Uint16 bpp; - Uint16 flags; Uint32 fbSize; -} t_bga_mode; +} tBGA_Mode; // === CONSTANTS === -enum eMode_Flags { - MODEFLAG_TEXT = 1 -}; #define BGA_LFB_MAXSIZE (1024*768*4) #define VBE_DISPI_BANK_ADDRESS 0xA0000 #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000 @@ -79,17 +75,15 @@ tDevFS_Driver gBGA_DriverStruct = { } }; int giBGA_CurrentMode = -1; + int giBGA_BufferFormat = 0; tVideo_IOCtl_Pos gBGA_CursorPos = {-1,-1}; - int giBGA_DriverId = -1; Uint *gBGA_Framebuffer; -t_bga_mode gBGA_Modes[] = { +tBGA_Mode gpBGA_CurrentMode; +const tBGA_Mode gBGA_Modes[] = { {}, - { 80,25, 12, MODEFLAG_TEXT, 80*25*8}, // 640 x 480 - {100,37, 12, MODEFLAG_TEXT, 100*37*8}, // 800 x 600 - {640,480,8, 0, 640*480}, {640,480,32, 0, 640*480*4}, - {800,600,8, 0, 800*600}, {800,600,32, 0, 800*600*4}, + {1024,768,32, 0, 1024*768*4} }; #define BGA_MODE_COUNT (sizeof(gBGA_Modes)/sizeof(gBGA_Modes[0])) @@ -99,20 +93,20 @@ t_bga_mode gBGA_Modes[] = { */ int BGA_Install(char **Arguments) { - int bga_version = 0; + int version = 0; // Check BGA Version - bga_version = BGA_int_ReadRegister(VBE_DISPI_INDEX_ID); + version = BGA_int_ReadRegister(VBE_DISPI_INDEX_ID); + // NOTE: This driver was written for 0xB0C4, but they seem to be backwards compatable - if(bga_version < 0xB0C4 || bga_version > 0xB0C5) { - Warning("[BGA ] Bochs Adapter Version is not 0xB0C4 or 0xB0C5, instead 0x%x", bga_version); + if(version < 0xB0C4 || version > 0xB0C5) { + Log_Warning("BGA", "Bochs Adapter Version is not 0xB0C4 or 0xB0C5, instead 0x%x", version); return MODULE_ERR_NOTNEEDED; } // Install Device - giBGA_DriverId = DevFS_AddDevice( &gBGA_DriverStruct ); - if(giBGA_DriverId == -1) { - Warning("[BGA ] Unable to register with DevFS, maybe already loaded?"); + if(DevFS_AddDevice( &gBGA_DriverStruct ) == -1) { + Log_Warning("BGA", "Unable to register with DevFS, maybe already loaded?"); return MODULE_ERR_MISC; } @@ -127,7 +121,7 @@ int BGA_Install(char **Arguments) */ void BGA_Uninstall() { - //DevFS_DelDevice( giBGA_DriverId ); + DevFS_DelDevice( &gBGA_DriverStruct ); MM_UnmapHWPage( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 ); } @@ -141,7 +135,7 @@ Uint64 BGA_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer) if(giBGA_CurrentMode == -1) return -1; // Check Offset and Length against Framebuffer Size - if(off+len > gBGA_Modes[giBGA_CurrentMode].fbSize) + if(off+len > gpBGA_CurrentMode->fbSize) return -1; // Copy from Framebuffer @@ -163,24 +157,27 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer) return -1; } - // Check Input against Frambuffer Size - if(off + len > gBGA_Modes[giBGA_CurrentMode].fbSize) { - LEAVE('i', -1); - return -1; - } - // Text Mode - if( gBGA_Modes[giBGA_CurrentMode].flags & MODEFLAG_TEXT ) + switch( giBGA_BufferFormat ) { + case VIDEO_BUFFMT_TEXT: + { tVT_Char *chars = Buffer; - int pitch = gBGA_Modes[giBGA_CurrentMode].width * giVT_CharWidth; + int pitch = gpBGA_CurrentMode->width * giVT_CharWidth; int x, y; Uint32 *dest; off /= sizeof(tVT_Char); dest = (void*)gBGA_Framebuffer; - x = (off % gBGA_Modes[giBGA_CurrentMode].width) * giVT_CharWidth; - y = (off / gBGA_Modes[giBGA_CurrentMode].width) * giVT_CharHeight; + x = (off % gpBGA_CurrentMode->width) * giVT_CharWidth; + y = (off / gpBGA_CurrentMode->width) * giVT_CharHeight; + + // Sanity Check + if(y > gpBGA_CurrentMode->height) { + LEAVE('i', 0); + return 0; + } + dest += y * pitch; dest += x * giVT_CharWidth; len /= sizeof(tVT_Char); @@ -203,20 +200,31 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer) dest += pitch*(giVT_CharHeight-1); } } - } - else - { + } + break; + + case VIDEO_BUFFMT_FRAMEBUFFER: + { Uint8 *destBuf = (Uint8*) ((Uint)gBGA_Framebuffer + (Uint)off); - Log("buffer = %p", Buffer); - Log("Updating Framebuffer (%p to %p)", - destBuf, destBuf + (Uint)len); + if( off + len > gpBGA_CurrentMode->fbSize ) { + LEAVE('i', 0); + return 0; + } + + LOG("buffer = %p", Buffer); + LOG("Updating Framebuffer (%p to %p)", destBuf, destBuf + (Uint)len); // Copy to Frambuffer memcpy(destBuf, Buffer, len); - Log("BGA Framebuffer updated"); + LOG("BGA Framebuffer updated"); + } + break; + default: + LEAVE('i', -1); + return -1; } LEAVE('i', len); @@ -224,13 +232,13 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer) } /** - * \fn INT int BGA_Ioctl(tVFS_Node *node, int ID, void *Data) + * \fn int BGA_Ioctl(tVFS_Node *Node, int ID, void *Data) * \brief Handle messages to the device */ -INT int BGA_Ioctl(tVFS_Node *node, int ID, void *Data) +int BGA_Ioctl(tVFS_Node *Node, int ID, void *Data) { int ret = -2; - ENTER("pNode iId pData", node, ID, Data); + ENTER("pNode iId pData", Node, ID, Data); switch(ID) { @@ -263,9 +271,10 @@ INT int BGA_Ioctl(tVFS_Node *node, int ID, void *Data) ret = BGA_int_ModeInfo((tVideo_IOCtl_Mode*)Data); break; - // Request Access to LFB - case VIDEO_IOCTL_REQLFB: - ret = BGA_int_MapFB( *(void**)Data ); + case VIDEO_IOCTL_SETBUFFORMAT: + ret = giBGA_BufferFormat; + if(Data) + giBGA_BufferFormat = *(int*)Data; break; case VIDEO_IOCTL_SETCURSOR: @@ -273,6 +282,11 @@ INT int BGA_Ioctl(tVFS_Node *node, int ID, void *Data) gBGA_CursorPos.y = ((tVideo_IOCtl_Pos*)Data)->y; break; + // Request Access to LFB + case VIDEO_IOCTL_REQLFB: + ret = BGA_int_MapFB( *(void**)Data ); + break; + default: LEAVE('i', -2); return -2; @@ -293,14 +307,14 @@ void BGA_int_WriteRegister(Uint16 reg, Uint16 value) outw(VBE_DISPI_IOPORT_DATA, value); } -INT Uint16 BGA_int_ReadRegister(Uint16 reg) +Uint16 BGA_int_ReadRegister(Uint16 reg) { outw(VBE_DISPI_IOPORT_INDEX, reg); return inw(VBE_DISPI_IOPORT_DATA); } #if 0 -INT void BGA_int_SetBank(Uint16 bank) +void BGA_int_SetBank(Uint16 bank) { BGA_int_WriteRegister(VBE_DISPI_INDEX_BANK, bank); } @@ -310,15 +324,14 @@ INT void BGA_int_SetBank(Uint16 bank) * \fn void BGA_int_SetMode(Uint16 width, Uint16 height, Uint16 bpp) * \brief Sets the video mode from the dimensions and bpp given */ -void BGA_int_SetMode(Uint16 width, Uint16 height) +void BGA_int_SetMode(Uint16 Width, Uint16 Height) { - ENTER("iwidth iheight ibpp", width, height, bpp); + ENTER("iWidth iheight ibpp", Width, Height, bpp); BGA_int_WriteRegister(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED); - BGA_int_WriteRegister(VBE_DISPI_INDEX_XRES, width); - BGA_int_WriteRegister(VBE_DISPI_INDEX_YRES, height); + BGA_int_WriteRegister(VBE_DISPI_INDEX_XRES, Width); + BGA_int_WriteRegister(VBE_DISPI_INDEX_YRES, Height); BGA_int_WriteRegister(VBE_DISPI_INDEX_BPP, 32); BGA_int_WriteRegister(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_NOCLEARMEM | VBE_DISPI_LFB_ENABLED); - //BGA_int_WriteRegister(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_NOCLEARMEM); LEAVE('-'); } @@ -342,6 +355,7 @@ int BGA_int_UpdateMode(int id) gBGA_Modes[id].height); giBGA_CurrentMode = id; + gpBGA_CurrentMode = &gBGA_Modes[id]; return id; } @@ -446,10 +460,10 @@ int BGA_int_MapFB(void *Dest) // Sanity Check if((Uint)Dest > 0xC0000000) return 0; - if(gBGA_Modes[giBGA_CurrentMode].bpp < 15) return 0; // Only non-pallete modes are supported + if(gpBGA_CurrentMode->bpp < 15) return 0; // Only non-pallete modes are supported // Count required pages - pages = (gBGA_Modes[giBGA_CurrentMode].fbSize + 0xFFF) >> 12; + pages = (gpBGA_CurrentMode->fbSize + 0xFFF) >> 12; // Check if there is space for( i = 0; i < pages; i++ ) diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index 69292933..e87ca058 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -38,6 +38,7 @@ tDevFS_Driver gVesa_DriverStruct = { tSpinlock glVesa_Lock; tVM8086 *gpVesa_BiosState; int giVesaCurrentMode = -1; + int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT; int giVesaDriverId = -1; char *gVesaFramebuffer = (void*)0xC00A0000; tVesa_Mode *gVesa_Modes; @@ -82,7 +83,7 @@ int Vesa_Install(char **Arguments) gVesa_Modes[0].height = 25; gVesa_Modes[0].bpp = 12; gVesa_Modes[0].code = 0x3; - gVesa_Modes[0].flags = VIDEO_FLAG_TEXT; + gVesa_Modes[0].flags = 1; gVesa_Modes[0].fbSize = 80*25*2; gVesa_Modes[0].framebuffer = 0xB8000; @@ -153,6 +154,14 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { Uint8 *fb = (Uint8 *)(KERNEL_BASE|0xB8000); Uint32 *buf = Buffer; + int rem; + + if( giVesaCurrentFormat != VIDEO_BUFFMT_TEXT ) { + Log_Warning("VESA", "Vesa_Write - Mode 0 is not framebuffer"); + LEAVE('i', -1); + return -1; + } + if( Offset + Length > 25*80*8 ) { Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow"); LEAVE('i', 0); @@ -160,7 +169,7 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) } fb += 2*Offset; - for(; Length > 0; Length -= 8, fb += 2) + for(rem = Length / sizeof(tVT_Char); rem --; fb += 2) { if( *buf < 0x80 ) *fb = *buf & 0x7F; @@ -179,6 +188,10 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) fb[1] |= (*buf & 0x007000) > 0x003000 ? 0x10 : 0; buf ++; } + Length /= sizeof(tVT_Char); + Length *= sizeof(tVT_Char); + LEAVE('X', Length); + return Length; } if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) { @@ -186,14 +199,80 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) LEAVE('i', 0); return 0; } - if(gVesa_Modes[giVesaCurrentMode].fbSize < Offset+Length) + + // Text Mode + switch( giVesaCurrentFormat ) { - Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow"); - LEAVE('i', 0); - return 0; - } + case VIDEO_BUFFMT_TEXT: + { + tVT_Char *chars = Buffer; + int pitch = gVesa_Modes[giVesaCurrentMode].width * giVT_CharWidth; + int x, y; + Uint32 *dest; + int rem; + + Offset /= sizeof(tVT_Char); + dest = (void*)gVesaFramebuffer; + x = (Offset % gVesa_Modes[giVesaCurrentMode].width) * giVT_CharWidth; + y = (Offset / gVesa_Modes[giVesaCurrentMode].width) * giVT_CharHeight; + + // Sanity Check + if(y > gVesa_Modes[giVesaCurrentMode].height) { + LEAVE('i', 0); + return 0; + } + + dest += y * pitch; + dest += x * giVT_CharWidth; + for( rem = Length / sizeof(tVT_Char); rem--; ) + { + VT_Font_Render( + chars->Ch, + dest, pitch, + VT_Colour12to24(chars->BGCol), + VT_Colour12to24(chars->FGCol) + ); + + dest += giVT_CharWidth; + + chars ++; + x += giVT_CharWidth; + if( x >= pitch ) { + x = 0; + y += giVT_CharHeight; + dest += pitch*(giVT_CharHeight-1); + } + } + Length /= sizeof(tVT_Char); + Length *= sizeof(tVT_Char); + } + break; - memcpy(gVesaFramebuffer + Offset, Buffer, Length); + case VIDEO_BUFFMT_FRAMEBUFFER: + { + Uint8 *destBuf = (Uint8*) ((Uint)gVesaFramebuffer + (Uint)Offset); + + if(gVesa_Modes[giVesaCurrentMode].fbSize < Offset+Length) + { + Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow"); + LEAVE('i', 0); + return 0; + } + + LOG("buffer = %p", Buffer); + LOG("Updating Framebuffer (%p to %p)", destBuf, destBuf + (Uint)Length); + + + // Copy to Frambuffer + memcpy(destBuf, Buffer, Length); + + LOG("BGA Framebuffer updated"); + } + break; + default: + LEAVE('i', -1); + return -1; + } LEAVE('X', Length); return Length; @@ -205,6 +284,7 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) */ int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data) { + int ret; switch(ID) { case DRV_IOCTL_TYPE: return DRV_TYPE_VIDEO; @@ -220,6 +300,11 @@ int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data) case VIDEO_IOCTL_MODEINFO: return Vesa_Int_ModeInfo((tVideo_IOCtl_Mode*)Data); + case VIDEO_IOCTL_SETBUFFORMAT: + ret = giVesaCurrentFormat; + if(Data) giVesaCurrentFormat = *(int*)Data; + return ret; + case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer return 0; } @@ -274,11 +359,6 @@ int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data) ENTER("idata->width idata->height idata->bpp", data->width, data->height, data->bpp); - if(data->flags & VIDEO_FLAG_TEXT) { - LEAVE('i', 0); - return 0; - } - for(i=0;iDestination = Address; hdr->HeaderChecksum = IPv4_Checksum(hdr, sizeof(tIPv4Header)); - Log("[IPv4 ] Sending packet to %i.%i.%i.%i", + Log_Log("IPv4", "Sending packet to %i.%i.%i.%i", Address.B[0], Address.B[1], Address.B[2], Address.B[3]); Link_SendPacket(Iface->Adapter, IPV4_ETHERNET_ID, to, bufSize, buf); return 1; @@ -103,23 +103,23 @@ void IPv4_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff int dataLength; if(Length < sizeof(tIPv4Header)) return; - //Log("[IPv4 ] Version = %i", hdr->Version); - Log("[IPv4 ] HeaderLength = %i", hdr->HeaderLength); - Log("[IPv4 ] DiffServices = %i", hdr->DiffServices); - Log("[IPv4 ] TotalLength = %i", ntohs(hdr->TotalLength) ); - //Log("[IPv4 ] Identifcation = %i", ntohs(hdr->Identifcation) ); - //Log("[IPv4 ] TTL = %i", hdr->TTL ); - Log("[IPv4 ] Protocol = %i", hdr->Protocol ); - //Log("[IPv4 ] HeaderChecksum = 0x%x", ntohs(hdr->HeaderChecksum) ); - Log("[IPv4 ] Source = %i.%i.%i.%i", + //Log_Log("IPv4", "Version = %i", hdr->Version); + Log_Log("IPv4", "HeaderLength = %i", hdr->HeaderLength); + Log_Log("IPv4", "DiffServices = %i", hdr->DiffServices); + Log_Log("IPv4", "TotalLength = %i", ntohs(hdr->TotalLength) ); + //Log_Log("IPv4", "Identifcation = %i", ntohs(hdr->Identifcation) ); + //Log_Log("IPv4", "TTL = %i", hdr->TTL ); + Log_Log("IPv4", "Protocol = %i", hdr->Protocol ); + //Log_Log("IPv4", "HeaderChecksum = 0x%x", ntohs(hdr->HeaderChecksum) ); + Log_Log("IPv4", "Source = %i.%i.%i.%i", hdr->Source.B[0], hdr->Source.B[1], hdr->Source.B[2], hdr->Source.B[3] ); - Log("[IPv4 ] Destination = %i.%i.%i.%i", + Log_Log("IPv4", "Destination = %i.%i.%i.%i", hdr->Destination.B[0], hdr->Destination.B[1], hdr->Destination.B[2], hdr->Destination.B[3] ); // Check that the version IS IPv4 if(hdr->Version != 4) { - Log("[IPv4 ] hdr->Version(%i) != 4", hdr->Version); + Log_Log("IPv4", "hdr->Version(%i) != 4", hdr->Version); return; } @@ -128,14 +128,14 @@ void IPv4_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff // Check Packet length if( ntohs(hdr->TotalLength) > Length) { - Log("[IPv4 ] hdr->TotalLength(%i) > Length(%i)", ntohs(hdr->TotalLength), Length); + Log_Log("IPv4", "hdr->TotalLength(%i) > Length(%i)", ntohs(hdr->TotalLength), Length); return; } // Get Interface (allowing broadcasts) iface = IPv4_GetInterface(Adapter, hdr->Destination, 1); if(!iface) { - Log("[IPv4 ] Ignoring Packet (Not for us)"); + Log_Log("IPv4", "Ignoring Packet (Not for us)"); return; // Not for us? Well, let's ignore it } @@ -149,7 +149,7 @@ void IPv4_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff if( gaIPv4_Callbacks[hdr->Protocol] ) gaIPv4_Callbacks[hdr->Protocol] (iface, &hdr->Source, dataLength, data); else - Log("[IPv4 ] Unknown Protocol %i", hdr->Protocol); + Log_Log("IPv4", "Unknown Protocol %i", hdr->Protocol); } /** diff --git a/Modules/IPStack/link.c b/Modules/IPStack/link.c index 0191efb8..6cdb2bc4 100644 --- a/Modules/IPStack/link.c +++ b/Modules/IPStack/link.c @@ -41,7 +41,7 @@ void Link_RegisterType(Uint16 Type, tPacketCallback Callback) for( i = giRegisteredTypes; i -- ; ) { if(gaRegisteredTypes[i].Type == Type) { - Warning("[NET ] Attempt to register 0x%x twice", Type); + Log_Warning("NET", "Attempt to register 0x%x twice", Type); return ; } // Ooh! Free slot! @@ -52,7 +52,7 @@ void Link_RegisterType(Uint16 Type, tPacketCallback Callback) { tmp = realloc(gaRegisteredTypes, (giRegisteredTypes+1)*sizeof(*gaRegisteredTypes)); if(!tmp) { - Warning("[NET ] Out of heap space!"); + Log_Warning("NET", "Out of heap space!"); return ; } i = giRegisteredTypes; @@ -74,7 +74,7 @@ void Link_SendPacket(tAdapter *Adapter, Uint16 Type, tMacAddr To, int Length, vo Uint8 buf[bufSize]; // dynamic stack arrays ftw! tEthernetHeader *hdr = (void*)buf; - Log("[NET ] Sending %i bytes to %02x:%02x:%02x:%02x:%02x:%02x (Type 0x%x)", + Log_Log("NET", "Sending %i bytes to %02x:%02x:%02x:%02x:%02x:%02x (Type 0x%x)", Length, To.B[0], To.B[1], To.B[2], To.B[3], To.B[4], To.B[5], Type); hdr->Dest = To; @@ -98,12 +98,12 @@ void Link_WatchDevice(tAdapter *Adapter) int tid = Proc_SpawnWorker(); // Create a new worker thread if(tid < 0) { - Warning("[NET ] Unable to create watcher thread for '%s'", Adapter->Device); + Log_Warning("NET", "Unable to create watcher thread for '%s'", Adapter->Device); return ; } if(tid > 0) { - Log("[NET ] Watching '%s' using tid %i", Adapter->Device, tid); + Log_Log("NET", "Watching '%s' using tid %i", Adapter->Device, tid); return ; } @@ -123,20 +123,20 @@ void Link_WatchDevice(tAdapter *Adapter) if(ret == -1) break; if(ret <= sizeof(tEthernetHeader)) { - Log("[NET ] Recieved an undersized packet"); + Log_Log("NET", "Recieved an undersized packet"); continue; } - Log("[NET ] Packet from %02x:%02x:%02x:%02x:%02x:%02x", + Log_Log("NET", "Packet from %02x:%02x:%02x:%02x:%02x:%02x", hdr->Src.B[0], hdr->Src.B[1], hdr->Src.B[2], hdr->Src.B[3], hdr->Src.B[4], hdr->Src.B[5] ); - Log("[NET ] to %02x:%02x:%02x:%02x:%02x:%02x", + Log_Log("NET", "to %02x:%02x:%02x:%02x:%02x:%02x", hdr->Dest.B[0], hdr->Dest.B[1], hdr->Dest.B[2], hdr->Dest.B[3], hdr->Dest.B[4], hdr->Dest.B[5] ); checksum = *(Uint32*)&hdr->Data[ret-sizeof(tEthernetHeader)-4]; - Log("[NET ] Checksum 0x%08x", checksum); + Log_Log("NET", "Checksum 0x%08x", checksum); // Check if there is a registered callback for this packet type for( i = giRegisteredTypes; i--; ) @@ -145,7 +145,7 @@ void Link_WatchDevice(tAdapter *Adapter) } // No? Ignore it if( i == -1 ) { - Log("[NET ] Unregistered type 0x%x", ntohs(hdr->Type)); + Log_Log("NET", "Unregistered type 0x%x", ntohs(hdr->Type)); continue; } @@ -158,7 +158,7 @@ void Link_WatchDevice(tAdapter *Adapter) ); } - Log("[NET ] Watcher terminated (file closed)"); + Log_Log("NET", "Watcher terminated (file closed)"); } // From http://www.cl.cam.ac.uk/research/srg/bluebook/21/crc/node6.html diff --git a/Modules/IPStack/main.c b/Modules/IPStack/main.c index 6fe92f45..6b75b770 100644 --- a/Modules/IPStack/main.c +++ b/Modules/IPStack/main.c @@ -231,7 +231,6 @@ char *IPStack_Iface_ReadDir(tVFS_Node *Node, int Pos) { tSocketFile *file = gIP_FileTemplates; while(Pos-- && file) { - Log("IPStack_Iface_ReadDir: %s", file->Name); file = file->Next; } @@ -251,7 +250,6 @@ tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, char *Name) for(;file;file = file->Next) { if( strcmp(file->Name, Name) == 0 ) break; - Log("IPStack_Iface_FindDir: strcmp('%s', '%s')", file->Name, Name); } if(!file) return NULL; @@ -513,9 +511,12 @@ int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data) int IPStack_AddInterface(char *Device) { tInterface *iface; + tAdapter *card; ENTER("sDevice", Device); + card = IPStack_GetAdapter(Device); + iface = malloc(sizeof(tInterface)); if(!iface) { LEAVE('i', -2); @@ -527,7 +528,6 @@ int IPStack_AddInterface(char *Device) // Create Node iface->Node.ImplPtr = iface; - iface->Node.ImplInt = giIP_NextIfaceId++; iface->Node.Flags = VFS_FFLAG_DIRECTORY; iface->Node.Size = -1; iface->Node.NumACLs = 1; @@ -547,6 +547,10 @@ int IPStack_AddInterface(char *Device) return -1; // Return ERR_YOUFAIL } + // Delay setting ImplInt until after the adapter is opened + // Keeps things simple + iface->Node.ImplInt = giIP_NextIfaceId++; + // Append to list LOCK( &glIP_Interfaces ); if( gIP_Interfaces ) { diff --git a/Modules/IPStack/tcp.c b/Modules/IPStack/tcp.c index 36837a5f..3db8230a 100644 --- a/Modules/IPStack/tcp.c +++ b/Modules/IPStack/tcp.c @@ -121,24 +121,24 @@ void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffe tTCPListener *srv; tTCPConnection *conn; - Log("[TCP ] SourcePort = %i, DestPort = %i", + Log_Log("TCP", "SourcePort = %i, DestPort = %i", ntohs(hdr->SourcePort), ntohs(hdr->DestPort)); - Log("[TCP ] SequenceNumber = 0x%x", ntohl(hdr->SequenceNumber)); - Log("[TCP ] AcknowlegementNumber = 0x%x", ntohl(hdr->AcknowlegementNumber)); - Log("[TCP ] DataOffset = %i", hdr->DataOffset >> 4); - Log("[TCP ] Flags = {"); - Log("[TCP ] CWR = %B, ECE = %B", + Log_Log("TCP", "SequenceNumber = 0x%x", ntohl(hdr->SequenceNumber)); + Log_Log("TCP", "AcknowlegementNumber = 0x%x", ntohl(hdr->AcknowlegementNumber)); + Log_Log("TCP", "DataOffset = %i", hdr->DataOffset >> 4); + Log_Log("TCP", "Flags = {"); + Log_Log("TCP", " CWR = %B, ECE = %B", !!(hdr->Flags & TCP_FLAG_CWR), !!(hdr->Flags & TCP_FLAG_ECE)); - Log("[TCP ] URG = %B, ACK = %B", + Log_Log("TCP", " URG = %B, ACK = %B", !!(hdr->Flags & TCP_FLAG_URG), !!(hdr->Flags & TCP_FLAG_ACK)); - Log("[TCP ] PSH = %B, RST = %B", + Log_Log("TCP", " PSH = %B, RST = %B", !!(hdr->Flags & TCP_FLAG_PSH), !!(hdr->Flags & TCP_FLAG_RST)); - Log("[TCP ] SYN = %B, FIN = %B", + Log_Log("TCP", " SYN = %B, FIN = %B", !!(hdr->Flags & TCP_FLAG_SYN), !!(hdr->Flags & TCP_FLAG_FIN)); - Log("[TCP ] }"); - Log("[TCP ] WindowSize = %i", htons(hdr->WindowSize)); - Log("[TCP ] Checksum = 0x%x", htons(hdr->Checksum)); - Log("[TCP ] UrgentPointer = 0x%x", htons(hdr->UrgentPointer)); + Log_Log("TCP", "}"); + Log_Log("TCP", "WindowSize = %i", htons(hdr->WindowSize)); + Log_Log("TCP", "Checksum = 0x%x", htons(hdr->Checksum)); + Log_Log("TCP", "UrgentPointer = 0x%x", htons(hdr->UrgentPointer)); if( Length > (hdr->DataOffset >> 4)*4 ) { @@ -160,17 +160,17 @@ void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffe // Check the destination port if(srv->Port != htons(hdr->DestPort)) continue; - Log("[TCP ] Matches server %p", srv); + Log_Log("TCP", "Matches server %p", srv); // Is this in an established connection? for( conn = srv->Connections; conn; conn = conn->Next ) { - Log("[TCP ] conn->Interface(%p) == Interface(%p)", + Log_Log("TCP", "conn->Interface(%p) == Interface(%p)", conn->Interface, Interface); // Check that it is coming in on the same interface if(conn->Interface != Interface) continue; // Check Source Port - Log("[TCP ] conn->RemotePort(%i) == hdr->SourcePort(%i)", + Log_Log("TCP", "conn->RemotePort(%i) == hdr->SourcePort(%i)", conn->RemotePort, ntohs(hdr->SourcePort)); if(conn->RemotePort != ntohs(hdr->SourcePort)) continue; @@ -180,17 +180,17 @@ void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffe if(conn->Interface->Type == 4 && !IP4_EQU(conn->RemoteIP.v4, *(tIPv4*)Address)) continue; - Log("[TCP ] Matches connection %p", conn); + Log_Log("TCP", "Matches connection %p", conn); // We have a response! TCP_INT_HandleConnectionPacket(conn, hdr, Length); return; } - Log("[TCP ] Opening Connection"); + Log_Log("TCP", "Opening Connection"); // Open a new connection (well, check that it's a SYN) if(hdr->Flags != TCP_FLAG_SYN) { - Log("[TCP ] Packet is not a SYN"); + Log_Log("TCP", "Packet is not a SYN"); return ; } @@ -270,7 +270,7 @@ void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffe } } - Log("[TCP ] No Match"); + Log_Log("TCP", "No Match"); } /** @@ -291,11 +291,11 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head // Get length of data dataLen = Length - (Header->DataOffset>>4)*4; - Log("[TCP ] HandleConnectionPacket - dataLen = %i", dataLen); + Log_Log("TCP", "HandleConnectionPacket - dataLen = %i", dataLen); if(Header->Flags & TCP_FLAG_ACK) { // TODO: Process an ACKed Packet - Log("[TCP ] Conn %p, Packet 0x%x ACKed", Connection, Header->AcknowlegementNumber); + Log_Log("TCP", "Conn %p, Packet 0x%x ACKed", Connection, Header->AcknowlegementNumber); } if(dataLen == 0) return ; @@ -317,7 +317,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head { tTCPStoredPacket *tmp, *prev = NULL; - Log("[TCP ] Out of sequence packet (0x%08x != 0x%08x)", + Log_Log("TCP", "Out of sequence packet (0x%08x != 0x%08x)", pkt->Sequence, Connection->NextSequenceRcv); // No? Well, let's cache it and look at it later @@ -480,7 +480,9 @@ int TCP_DeallocatePort(Uint16 Port) // --- Server tVFS_Node *TCP_Server_Init(tInterface *Interface) { - tTCPListener *srv = malloc( sizeof(tTCPListener) ); + tTCPListener *srv; + + srv = malloc( sizeof(tTCPListener) ); Log_Debug("TCP", "srv = %p", srv); @@ -524,7 +526,7 @@ char *TCP_Server_ReadDir(tVFS_Node *Node, int Pos) tTCPConnection *conn; char *ret; - Log("[TCP ] Thread %i waiting for a connection", Threads_GetTID()); + Log_Log("TCP", "Thread %i waiting for a connection", Threads_GetTID()); for(;;) { LOCK( &srv->lConnections ); @@ -612,7 +614,7 @@ int TCP_Server_IOCtl(tVFS_Node *Node, int ID, void *Data) else // Else, mark this as used TCP_AllocatePort(srv->Port); - Log("[TCP ] Server %p listening on port %i", srv, srv->Port); + Log_Log("TCP", "Server %p listening on port %i", srv, srv->Port); return srv->Port; }