From 351dd3b194833c923bad0292e9019320fb2a41fa Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 1 Apr 2010 10:18:01 +0800 Subject: [PATCH] Misc Changes - Moved USB core to a new folder, - Slight changes to Ext2 driver - Slight changes in BochsGA driver - Added a cache field to the tVFS_Node that can be assumed to be a heap address or NULL > Allows easier cleanup of per-fs buffers when a node is freed - Added the start of a VM8086 driver for BIOS calls --- Kernel/Makefile.BuildNum | 2 +- Kernel/arch/x86/include/vm8086.h | 29 +++++++++++++++++++++++++++++ Kernel/include/vfs.h | 6 ++++++ Modules/Display/BochsGA/bochsvbe.c | 2 +- Modules/Filesystems/Ext2/dir.c | 6 +++--- Modules/Filesystems/Ext2/ext2.c | 22 +++++++++++++--------- Modules/Filesystems/Ext2/write.c | 4 ++-- Modules/USB/{ => Core}/Makefile | 0 Modules/USB/{ => Core}/main.c | 0 Modules/USB/{ => Core}/uhci.c | 0 Modules/USB/{ => Core}/uhci.h | 0 Modules/USB/{ => Core}/usb.c | 12 ++++++++---- Modules/USB/{ => Core}/usb.h | 3 +++ 13 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 Kernel/arch/x86/include/vm8086.h rename Modules/USB/{ => Core}/Makefile (100%) rename Modules/USB/{ => Core}/main.c (100%) rename Modules/USB/{ => Core}/uhci.c (100%) rename Modules/USB/{ => Core}/uhci.h (100%) rename Modules/USB/{ => Core}/usb.c (68%) rename Modules/USB/{ => Core}/usb.h (96%) diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index f26427d5..dc7f7ff2 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1633 +BUILD_NUM = 1636 diff --git a/Kernel/arch/x86/include/vm8086.h b/Kernel/arch/x86/include/vm8086.h new file mode 100644 index 00000000..cb2834c2 --- /dev/null +++ b/Kernel/arch/x86/include/vm8086.h @@ -0,0 +1,29 @@ +/* + * Acess2 VM8086 BIOS Interface + * - By John Hodge (thePowersGang) + * + * vm8086.h + * - Core Header + */ +#ifndef _VM80806_H_ +#define _VM80806_H_ + +// === TYPES === +typedef struct sVM8086 +{ + Uint16 AX, CX, DX, BX; + Uint16 BP, SP, SI, DI; + + Uint16 CS, SS, DS, ES; + + Uint16 IP; +} tVM8086; + +// === FUNCTIONS === +extern tVM8086 *VM8086_Init(void); +extern void VM8086_Free(tVM8086 *State); +extern void *VM8086_Allocate(tVM8086 *State, int Size, Uint16 *Segment, Uint16 *Ofs); +extern void *VM8086_GetPointer(tVM8086 *State, Uint16 Segment, Uint16 Ofs); +extern void VM8086_Int(tVM8086 *State, Uint8 Interrupt); + +#endif diff --git a/Kernel/include/vfs.h b/Kernel/include/vfs.h index a7821048..e3a61d43 100644 --- a/Kernel/include/vfs.h +++ b/Kernel/include/vfs.h @@ -97,6 +97,12 @@ typedef struct sVFS_Node Uint64 Size; //!< File Size Uint32 Flags; //!< File Flags + + /** + * Pointer to cached data (FS Specific) + * \note Inode_* will free when the node is uncached this if needed + */ + void *Data; /** * \} */ diff --git a/Modules/Display/BochsGA/bochsvbe.c b/Modules/Display/BochsGA/bochsvbe.c index 7065709f..d1d78a5c 100644 --- a/Modules/Display/BochsGA/bochsvbe.c +++ b/Modules/Display/BochsGA/bochsvbe.c @@ -15,7 +15,7 @@ #define INT -// === TYPEDEFS === +// === TYPES === typedef struct { Uint16 width; Uint16 height; diff --git a/Modules/Filesystems/Ext2/dir.c b/Modules/Filesystems/Ext2/dir.c index 0ab3ed39..86092b0f 100644 --- a/Modules/Filesystems/Ext2/dir.c +++ b/Modules/Filesystems/Ext2/dir.c @@ -57,7 +57,7 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) if(ofs >= disk->BlockSize) { block ++; if( ofs > disk->BlockSize ) { - Warning("[EXT2] Directory Entry %i of inode %i extends over a block boundary, ignoring", + Log_Warning("EXT2", "Directory Entry %i of inode %i extends over a block boundary, ignoring", entNum-1, Node->Inode); } ofs = 0; @@ -135,7 +135,7 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, char *Filename) if(ofs >= disk->BlockSize) { block ++; if( ofs > disk->BlockSize ) { - Warning("[EXT2 ] Directory Entry %i of inode %i extends over a block boundary, ignoring", + Log_Warning("EXT2", "Directory Entry %i of inode %i extends over a block boundary, ignoring", entNum-1, Node->Inode); } ofs = 0; @@ -220,7 +220,7 @@ tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID, char *Name) //if(Name[0] == '.') retNode.Flags |= VFS_FFLAG_HIDDEN; // Set Timestamps - retNode.ATime = now(); + retNode.ATime = inode.i_atime * 1000; retNode.MTime = inode.i_mtime * 1000; retNode.CTime = inode.i_ctime * 1000; diff --git a/Modules/Filesystems/Ext2/ext2.c b/Modules/Filesystems/Ext2/ext2.c index c2c2df9c..ac3d7e5c 100644 --- a/Modules/Filesystems/Ext2/ext2.c +++ b/Modules/Filesystems/Ext2/ext2.c @@ -33,7 +33,6 @@ tVFS_Driver gExt2_FSInfo = { }; // === CODE === - /** * \fn int Ext2_Install(char **Arguments) * \brief Install the Ext2 Filesystem Driver @@ -64,7 +63,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Open Disk fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device if(fd == -1) { - Warning("[EXT2 ] Unable to open '%s'", Device); + Log_Warning("EXT2", "Unable to open '%s'", Device); LEAVE('n'); return NULL; } @@ -74,7 +73,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Sanity Check Magic value if(sb.s_magic != 0xEF53) { - Warning("[EXT2 ] Volume '%s' is not an EXT2 volume", Device); + Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume", Device); VFS_Close(fd); LEAVE('n'); return NULL; @@ -87,7 +86,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Allocate Disk Information disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount); if(!disk) { - Warning("[EXT2 ] Unable to allocate disk structure"); + Log_Warning("EXT2", "Unable to allocate disk structure"); VFS_Close(fd); LEAVE('n'); return NULL; @@ -187,7 +186,7 @@ int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode) { int group, subId; - //ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode); + ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode); if(InodeId == 0) return 0; @@ -196,7 +195,7 @@ int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode) group = InodeId / Disk->SuperBlock.s_inodes_per_group; subId = InodeId % Disk->SuperBlock.s_inodes_per_group; - //LOG("group=%i, subId = %i", group, subId); + LOG("group=%i, subId = %i", group, subId); // Read Inode VFS_ReadAt(Disk->FD, @@ -204,7 +203,7 @@ int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode) sizeof(tExt2_Inode), Inode); - //LEAVE('i', 1); + LEAVE('i', 1); return 1; } @@ -216,7 +215,10 @@ int Ext2_int_WriteInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode) int group, subId; ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode); - if(InodeId == 0) return 0; + if(InodeId == 0) { + LEAVE('i', 0); + return 0; + } InodeId --; // Inodes are numbered starting at 1 @@ -229,7 +231,8 @@ int Ext2_int_WriteInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode) VFS_WriteAt(Disk->FD, Disk->Groups[group].bg_inode_table * Disk->BlockSize + sizeof(tExt2_Inode)*subId, sizeof(tExt2_Inode), - Inode); + Inode + ); LEAVE('i', 1); return 1; @@ -293,6 +296,7 @@ Uint64 Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum) Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent) { // Uint block = (Parent - 1) / Disk->SuperBlock.s_inodes_per_group; + Log_Warning("EXT2", "Ext2_int_AllocateInode is unimplemented"); return 0; } diff --git a/Modules/Filesystems/Ext2/write.c b/Modules/Filesystems/Ext2/write.c index ba8b61ce..e52ebf75 100644 --- a/Modules/Filesystems/Ext2/write.c +++ b/Modules/Filesystems/Ext2/write.c @@ -90,7 +90,7 @@ Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) base = Ext2_int_GetBlockAddr(disk, inode.i_block, allocSize/disk->BlockSize-1); addBlocks: - Warning("[EXT2 ] File extending is untested"); + Log_Notice("EXT2", "File extending is untested"); // Allocate blocks and copy data to them retLen = Length - (allocSize-Offset); @@ -201,7 +201,7 @@ Uint32 Ext2_int_AllocateBlock(tExt2_Disk *Disk, Uint32 PrevBlock) else { checkAll: - Warning("[EXT2 ] TODO - Implement using blocks outside the current block group"); + Log_Warning("EXT2", "TODO - Implement using blocks outside the current block group"); return 0; } diff --git a/Modules/USB/Makefile b/Modules/USB/Core/Makefile similarity index 100% rename from Modules/USB/Makefile rename to Modules/USB/Core/Makefile diff --git a/Modules/USB/main.c b/Modules/USB/Core/main.c similarity index 100% rename from Modules/USB/main.c rename to Modules/USB/Core/main.c diff --git a/Modules/USB/uhci.c b/Modules/USB/Core/uhci.c similarity index 100% rename from Modules/USB/uhci.c rename to Modules/USB/Core/uhci.c diff --git a/Modules/USB/uhci.h b/Modules/USB/Core/uhci.h similarity index 100% rename from Modules/USB/uhci.h rename to Modules/USB/Core/uhci.h diff --git a/Modules/USB/usb.c b/Modules/USB/Core/usb.c similarity index 68% rename from Modules/USB/usb.c rename to Modules/USB/Core/usb.c index 934136a1..60bf3f23 100644 --- a/Modules/USB/usb.c +++ b/Modules/USB/Core/usb.c @@ -13,7 +13,7 @@ void USB_MakeToken(void *Buf, int PID, int Addr, int EndP) { Uint8 *tok = Buf; - int crc = 0; //USB_TokenCRC(); + int crc = 0; tok[0] = PID & 0xFF; tok[1] = (Addr & 0x7F) | ((EndP&1)<<7); @@ -21,13 +21,17 @@ void USB_MakeToken(void *Buf, int PID, int Addr, int EndP) } #if 0 -void USB_SendPacket(int Controller, int PID, int Dev, int Endpoint, void *Data, int Length) +void USB_SendData(int Controller, int Dev, int Endpoint, void *Data, int Length) { - uint8_t buf[Length/*+??*/]; + Uint8 buf[Length+3+2/*?*/]; + + USB_MakeToken(buf, PID_DATA0, Dev, Endpoint); + switch(Controller & 0xF00) { - case 1: + case 1: // UHCI UHCI_SendPacket(Controller & 0xFF); + break; } } #endif diff --git a/Modules/USB/usb.h b/Modules/USB/Core/usb.h similarity index 96% rename from Modules/USB/usb.h rename to Modules/USB/Core/usb.h index a867c112..397e4d70 100644 --- a/Modules/USB/usb.h +++ b/Modules/USB/Core/usb.h @@ -88,6 +88,9 @@ struct sUSBHost struct sUSBDevice { tUSBHost *Host; + int MaxControl; + int MaxBulk; + int MaxISync; }; #endif -- 2.20.1