void FIFO_Reference(tVFS_Node *Node);
void FIFO_Close(tVFS_Node *Node);
int FIFO_Relink(tVFS_Node *Node, const char *OldName, const char *NewName);
-Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t FIFO_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t FIFO_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
tPipe *FIFO_Int_NewPipe(int Size, const char *Name);
// === GLOBALS ===
}
/**
- * \fn Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read from a fifo pipe
*/
-Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t FIFO_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tPipe *pipe = Node->ImplPtr;
Uint len;
if(!pipe) return 0;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
while(remaining)
{
}
/**
- * \fn Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a fifo pipe
*/
-Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t FIFO_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tPipe *pipe = Node->ImplPtr;
Uint len;
if(!pipe) return 0;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
while(remaining)
{
char *PCI_int_ReadDirRoot(tVFS_Node *node, int pos);\r
tVFS_Node *PCI_int_FindDirRoot(tVFS_Node *node, const char *filename);\r
Uint32 PCI_int_GetBusAddr(Uint16 Bus, Uint16 Slot, Uint16 Fcn, Uint8 Offset);\r
-Uint64 PCI_int_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer);\r
+size_t PCI_int_ReadDevice(tVFS_Node *node, off_t Offset, size_t Length, void *buffer);\r
int PCI_int_EnumDevice(Uint16 bus, Uint16 dev, Uint16 fcn, tPCIDevice *info);\r
\r
// === GLOBALS ===\r
}\r
\r
/**\r
+ * \brief Read the PCI configuration space of a device\r
*/\r
-Uint64 PCI_int_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer)\r
+size_t PCI_int_ReadDevice(tVFS_Node *node, off_t pos, size_t length, void *buffer)\r
{ \r
if( pos + length > 256 ) return 0;\r
\r
char *SysFS_Comm_ReadDir(tVFS_Node *Node, int Id);
tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, const char *Filename);
-Uint64 SysFS_Comm_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+size_t SysFS_Comm_ReadFile(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
void SysFS_Comm_CloseFile(tVFS_Node *Node);
// === GLOBALS ===
}
/**
- * \fn Uint64 SysFS_Comm_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read from an exposed buffer
*/
-Uint64 SysFS_Comm_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t SysFS_Comm_ReadFile(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
if( Offset > Node->Size ) return -1;
if( Length > Node->Size ) Length = Node->Size;
char *VT_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *VT_FindDir(tVFS_Node *Node, const char *Name);
int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data);
-Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === CONSTANTS ===
/**
* \brief Read from a virtual terminal
*/
-Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
int pos = 0;
int avail;
}
/**
- * \fn Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
* \brief Write to a virtual terminal
*/
-Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tVTerm *term = &gVT_Terminals[ Node->Inode ];
int size;
typedef Sint64 tTime; //!< Same again
typedef struct sShortSpinlock tShortSpinlock; //!< Opaque (kinda) spinlock
typedef int bool; //!< Boolean type
+typedef Uint64 off_t; //!< VFS Offset
// --- Helper Macros ---
/**
* \{
*/
extern int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args);
-extern size_t snprintf(char *__s, size_t __n, const char *__format, ...);
+extern int snprintf(char *__s, size_t __n, const char *__format, ...);
extern int sprintf(char *__s, const char *__format, ...);
extern size_t strlen(const char *Str);
extern char *strcpy(char *__dest, const char *__src);
* \name Times
* \{
*/
- Sint64 ATime; //!< Last Accessed Time
- Sint64 MTime; //!< Last Modified Time
- Sint64 CTime; //!< Creation Time
+ tTime ATime; //!< Last Accessed Time
+ tTime MTime; //!< Last Modified Time
+ tTime CTime; //!< Creation Time
/**
* \}
*/
* \param Buffer Destination for read data
* \return Number of bytes read
*/
- Uint64 (*Read)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+ size_t (*Read)(struct sVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
/**
* \brief Write to the file
* \param Node Pointer to this node
* \param Buffer Source of written data
* \return Number of bytes read
*/
- Uint64 (*Write)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+ size_t (*Write)(struct sVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
/**
* \brief Map a region of a file into memory
* \return Boolean Failure
* \note If NULL, the VFS implements it using .Read
*/
- int (*MMap)(struct sVFS_Node *Node, Uint64 Offset, int Length, void *Dest);
+ int (*MMap)(struct sVFS_Node *Node, off_t Offset, int Length, void *Dest);
/**
* \}
int ParseInt(const char *string, int *Val);
void itoa(char *buf, Uint64 num, int base, int minLength, char pad);
int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args);
-size_t snprintf(char *__s, size_t __n, const char *__format, ...);
+ int snprintf(char *__s, size_t __n, const char *__format, ...);
int sprintf(char *__s, const char *__format, ...);
#endif
int tolower(int c);
EXPORT(atoi);
EXPORT(itoa);
EXPORT(vsnprintf);
+EXPORT(snprintf);
EXPORT(sprintf);
EXPORT(tolower);
EXPORT(strucmp);
/**
*/
-size_t snprintf(char *__s, size_t __n, const char *__format, ...)
+int snprintf(char *__s, size_t __n, const char *__format, ...)
{
va_list args;
int ret;
int Root_MkNod(tVFS_Node *Node, const char *Name, Uint Flags);
tVFS_Node *Root_FindDir(tVFS_Node *Node, const char *Name);
char *Root_ReadDir(tVFS_Node *Node, int Pos);
-Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t Root_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t Root_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
tRamFS_File *Root_int_AllocFile(void);
// === GLOBALS ===
}
/**
- * \fn Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read from a file in the root directory
*/
-Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t Root_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tRamFS_File *file = Node->ImplPtr;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
-
- if(Offset > Node->Size) {
- LEAVE('i', 0);
- return 0;
- }
- if(Length > Node->Size) Length = Node->Size;
+ if(Offset > Node->Size) return 0;
+
+ if(Length > Node->Size)
+ Length = Node->Size;
if(Offset+Length > Node->Size)
Length = Node->Size - Offset;
memcpy(Buffer, file->Data.Bytes+Offset, Length);
- LOG("Buffer = '%.*s'", (int)Length, Buffer);
-
- LEAVE('i', Length);
+
return Length;
}
/**
- * \fn Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file in the root directory
*/
-Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t Root_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tRamFS_File *file = Node->ImplPtr;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
if(Offset > Node->Size) {
LEAVE('i', -1);
// === PROTOTYPES ===
tVFS_Node *VFS_MemFile_Create(const char *Path);
void VFS_MemFile_Close(tVFS_Node *Node);
-Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t VFS_MemFile_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t VFS_MemFile_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
// === GLOBALS ===
tVFS_NodeType gVFS_MemFileType = {
}
/**
- * \fn Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read from a memory file
*/
-Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t VFS_MemFile_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
// Check for use of free'd file
if(Node->ImplPtr == NULL) return 0;
if(Offset > Node->Size) return 0;
// Truncate data read if needed
+ if(Length > Node->Size)
+ Length = Node->Size;
if(Offset + Length > Node->Size)
Length = Node->Size - Offset;
}
/**
- * \fn Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a memory file
*/
-Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t VFS_MemFile_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
// Check for use of free'd file
if(Node->ImplPtr == NULL) return 0;
if(Offset > Node->Size) return 0;
// Truncate data read if needed
+ if(Length > Node->Size)
+ Length = Node->Size;
if(Offset + Length > Node->Size)
Length = Node->Size - Offset;
int BGA_int_ModeInfo(tVideo_IOCtl_Mode *info);\r
int BGA_int_MapFB(void *Dest);\r
// Filesystem\r
-Uint64 BGA_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer);\r
-Uint64 BGA_Write(tVFS_Node *Node, Uint64 off, Uint64 len, const void *buffer);\r
+size_t BGA_Read(tVFS_Node *Node, off_t off, size_t len, void *buffer);\r
+size_t BGA_Write(tVFS_Node *Node, off_t off, size_t len, const void *buffer);\r
int BGA_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
\r
// === GLOBALS ===\r
}\r
\r
/**\r
- * \fn Uint64 BGA_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)\r
* \brief Read from the framebuffer\r
*/\r
-Uint64 BGA_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)\r
+size_t BGA_Read(tVFS_Node *node, off_t off, size_t len, void *buffer)\r
{\r
// Check Mode\r
if(giBGA_CurrentMode == -1) return -1;\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 BGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)\r
+size_t BGA_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)\r
{\r
if( giBGA_CurrentMode == -1 ) BGA_int_UpdateMode(0);\r
return DrvUtil_Video_WriteLFB(&gBGA_DrvUtil_BufInfo, Offset, Length, Buffer);\r
void PL110_Uninstall();\r
// Internal\r
// Filesystem\r
-Uint64 PL110_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);\r
-Uint64 PL110_Write(tVFS_Node *node, Uint64 off, Uint64 len, const void *buffer);\r
+size_t PL110_Read(tVFS_Node *node, off_t Offset, size_t len, void *buffer);\r
+size_t PL110_Write(tVFS_Node *node, off_t offset, size_t len, const void *buffer);\r
int PL110_IOCtl(tVFS_Node *node, int id, void *data);\r
// -- Internals\r
int PL110_int_SetResolution(int W, int H);\r
/**\r
* \brief Read from the framebuffer\r
*/\r
-Uint64 PL110_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)\r
+size_t PL110_Read(tVFS_Node *node, off_t off, size_t len, void *buffer)\r
{\r
return 0;\r
}\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 PL110_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)\r
+size_t PL110_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)\r
{\r
gPL110_DrvUtil_BufInfo.BufferFormat = giPL110_BufferMode;\r
return DrvUtil_Video_WriteLFB(&gPL110_DrvUtil_BufInfo, Offset, Length, Buffer);\r
void Tegra2Vid_Uninstall();\r
// Internal\r
// Filesystem\r
-Uint64 Tegra2Vid_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);\r
-Uint64 Tegra2Vid_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);\r
+size_t Tegra2Vid_Read(tVFS_Node *node, off_t off, size_t len, void *buffer);\r
+size_t Tegra2Vid_Write(tVFS_Node *node, off_t off, size_t len, const void *buffer);\r
int Tegra2Vid_IOCtl(tVFS_Node *node, int id, void *data);\r
// -- Internals\r
int Tegra2Vid_int_SetMode(int Mode);\r
\r
// === GLOBALS ===\r
MODULE_DEFINE(0, VERSION, Tegra2Vid, Tegra2Vid_Install, NULL, NULL);\r
-tDevFS_Driver gTegra2Vid_DriverStruct = {\r
- NULL, "Tegra2Vid",\r
- {\r
+tVFS_NodeType gTegra2Vid_NodeType = {\r
.Read = Tegra2Vid_Read,\r
.Write = Tegra2Vid_Write,\r
.IOCtl = Tegra2Vid_IOCtl\r
- }\r
+ };\r
+tDevFS_Driver gTegra2Vid_DriverStruct = {\r
+ NULL, "Tegra2Vid",\r
+ {.Type = &gTegra2Vid_NodeType}\r
};\r
// -- Options\r
tPAddr gTegra2Vid_PhysBase = TEGRA2VID_BASE;\r
*(gpTegra2Vid_IOMem[DC_WIN_A_SIZE_0]>>16)*4;\r
\r
Log_Debug("Tegra2Vid", "giTegra2Vid_FramebufferSize = 0x%x", giTegra2Vid_FramebufferSize);\r
- gpTegra2Vid_Framebuffer = MM_MapHWPages(\r
+ gpTegra2Vid_Framebuffer = (void*)MM_MapHWPages(\r
gpTegra2Vid_IOMem[DC_WINBUF_A_START_ADDR_0],\r
(giTegra2Vid_FramebufferSize+PAGE_SIZE-1)/PAGE_SIZE\r
);\r
/**\r
* \brief Read from the framebuffer\r
*/\r
-Uint64 Tegra2Vid_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)\r
+size_t Tegra2Vid_Read(tVFS_Node *node, off_t off, size_t len, void *buffer)\r
{\r
return 0;\r
}\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 Tegra2Vid_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+size_t Tegra2Vid_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)\r
{\r
gTegra2Vid_DrvUtil_BufInfo.BufferFormat = giTegra2Vid_BufferMode;\r
return DrvUtil_Video_WriteLFB(&gTegra2Vid_DrvUtil_BufInfo, Offset, Length, Buffer);\r
case VIDEO_IOCTL_FINDMODE:\r
{\r
tVideo_IOCtl_Mode *mode = Data;\r
- int closest, closestArea, reqArea = 0;\r
+ int closest=0, closestArea, reqArea = 0;\r
if(!Data || !CheckMem(Data, sizeof(tVideo_IOCtl_Mode)))\r
LEAVE_RET('i', -1);\r
if( mode->bpp != 32 )\r
\r
// === PROTOTYPES ===\r
int Vesa_Install(char **Arguments);\r
-Uint64 Vesa_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
-Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);\r
+size_t Vesa_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);\r
int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
int Vesa_Int_SetMode(int Mode);\r
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
// === GLOBALS ===\r
MODULE_DEFINE(0, VERSION, Vesa, Vesa_Install, NULL, "PCI", "VM8086", NULL);\r
tVFS_NodeType gVesa_NodeType = {\r
- .Read = Vesa_Read,\r
.Write = Vesa_Write,\r
.IOCtl = Vesa_IOCtl\r
};\r
}\r
}\r
\r
-/* Read from the framebuffer\r
- */\r
-Uint64 Vesa_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer)\r
-{\r
- #if DEBUG >= 2\r
- Log("Vesa_Read: () - NULL\n");\r
- #endif\r
- return 0;\r
-}\r
-\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)\r
+size_t Vesa_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)\r
{\r
if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) {\r
Log_Warning("VESA", "Vesa_Write - Non-LFB Modes not yet supported.");\r
extern int Ext2_MkNod(tVFS_Node *Node, const char *Name, Uint Flags);
extern int Ext2_Link(tVFS_Node *Parent, tVFS_Node *Node, const char *Name);
// --- Read ---
-extern Uint64 Ext2_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
+extern size_t Ext2_Read(tVFS_Node *node, off_t offset, size_t length, void *buffer);
// --- Write ---
-extern Uint64 Ext2_Write(tVFS_Node *node, Uint64 offset, Uint64 length, const void *buffer);
+extern size_t Ext2_Write(tVFS_Node *node, off_t offset, size_t length, const void *buffer);
#endif
#define VERBOSE 0
#include "ext2_common.h"
-// === PROTOTYPES ===
-Uint64 Ext2_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
-
// === CODE ===
/**
- * \fn Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read from a file
*/
-Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t Ext2_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tExt2_Disk *disk = Node->ImplPtr;
tExt2_Inode inode;
// === CODE ===
/**
- * \fn Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file
*/
-Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t Ext2_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tExt2_Disk *disk = Node->ImplPtr;
tExt2_Inode inode;
#endif\r
void FAT_int_ReadCluster(tFAT_VolInfo *Disk, Uint32 Cluster, int Length, void *Buffer);\r
// --- File IO\r
-Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
+size_t FAT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);\r
#if SUPPORT_WRITE\r
void FAT_int_WriteCluster(tFAT_VolInfo *Disk, Uint32 Cluster, void *Buffer);\r
-Uint64 FAT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
+size_t FAT_Write(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);\r
#endif\r
// --- Directory IO\r
char *FAT_ReadDir(tVFS_Node *Node, int ID);\r
* ====================\r
*/\r
/**\r
- * \fn Uint64 FAT_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer)\r
* \brief Reads data from a specified file\r
*/\r
-Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+size_t FAT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)\r
{\r
int preSkip, count;\r
Uint64 final_bytes;\r
char tmpBuf[disk->BytesPerCluster];\r
int bpc = disk->BytesPerCluster;\r
\r
- ENTER("pNode Xoffset Xlength pbuffer", Node, Offset, Length, Buffer);\r
+ ENTER("pNode Xoffset xlength pbuffer", Node, Offset, Length, Buffer);\r
\r
// Sanity Check offset\r
if(Offset > Node->Size) {\r
* \param Length Size of data to write\r
* \param Buffer Data source\r
*/\r
-Uint64 FAT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+size_t FAT_Write(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)\r
{\r
tFAT_VolInfo *disk = Node->ImplPtr;\r
char tmpBuf[disk->BytesPerCluster];\r
// === Functions ===
-extern Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Size, void *Buffer);
+extern size_t InitRD_ReadFile(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer);
extern char *InitRD_ReadDir(tVFS_Node *Node, int ID);
extern tVFS_Node *InitRD_FindDir(tVFS_Node *Node, const char *Name);
tVFS_Node *InitRD_InitDevice(const char *Device, const char **Arguments);
void InitRD_Unmount(tVFS_Node *Node);
tVFS_Node *InitRD_GetNodeFromINode(tVFS_Node *Root, Uint64 Inode);
-Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Size, void *Buffer);
+size_t InitRD_ReadFile(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer);
char *InitRD_ReadDir(tVFS_Node *Node, int ID);
tVFS_Node *InitRD_FindDir(tVFS_Node *Node, const char *Name);
void InitRD_DumpDir(tVFS_Node *Node, int Indent);
"initrd", 0, InitRD_InitDevice, InitRD_Unmount, InitRD_GetNodeFromINode
};
tVFS_NodeType gInitRD_DirType = {
- .ReadDir = InitRD_ReadFile,
+ .ReadDir = InitRD_ReadDir,
.FindDir = InitRD_FindDir
};
tVFS_NodeType gInitRD_FileType = {
/**
* \brief Read from a file
*/
-Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t InitRD_ReadFile(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
if(Offset > Node->Size)
return 0;
#include "ipstack.h"
#include "arp.h"
#include "link.h"
+#include "ipv4.h" // For IPv4_Netmask
#define ARPv6 0
#define ARP_CACHE_SIZE 64
// === FUNCTIONS ===
extern int IPv4_RegisterCallback(int ID, tIPCallback Callback);
extern Uint16 IPv4_Checksum(const void *Buf, size_t Length);
+extern Uint32 IPv4_Netmask(int FixedBits);
extern int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, int Length, const void *Data);
#endif
void TCP_Server_Close(tVFS_Node *Node);
// --- Client
tVFS_Node *TCP_Client_Init(tInterface *Interface);
-Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t TCP_Client_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t TCP_Client_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int TCP_Client_IOCtl(tVFS_Node *Node, int ID, void *Data);
void TCP_Client_Close(tVFS_Node *Node);
// --- Helpers
* \note If \a Length is smaller than the size of the packet, the rest
* of the packet's data will be discarded.
*/
-Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t TCP_Client_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tTCPConnection *conn = Node->ImplPtr;
size_t len;
/**
* \brief Send some bytes on a connection
*/
-Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t TCP_Client_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tTCPConnection *conn = Node->ImplPtr;
size_t rem = Length;
void UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, const void *Address, Uint16 Port, const void *Data, size_t Length);
// --- Client Channels
tVFS_Node *UDP_Channel_Init(tInterface *Interface);
-Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t UDP_Channel_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t UDP_Channel_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int UDP_Channel_IOCtl(tVFS_Node *Node, int ID, void *Data);
void UDP_Channel_Close(tVFS_Node *Node);
// --- Helpers
/**
* \brief Read from the channel file (wait for a packet)
*/
-Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t UDP_Channel_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tUDPChannel *chan = Node->ImplPtr;
tUDPPacket *pack;
/**
* \brief Write to the channel file (send a packet)
*/
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t UDP_Channel_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tUDPChannel *chan = Node->ImplPtr;
const tUDPEndpoint *ep;
int PS2Mouse_Install(char **Arguments);\r
void PS2Mouse_HandleInterrupt(Uint8 InputByte);\r
// - Filesystem -\r
-Uint64 PS2Mouse_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
-int PS2Mouse_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
+size_t PS2Mouse_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);\r
+ int PS2Mouse_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
\r
// == GLOBALS ==\r
void (*gpMouse_EnableFcn)(void);\r
\r
/* Read mouse state (coordinates)\r
*/\r
-Uint64 PS2Mouse_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+size_t PS2Mouse_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)\r
{\r
if(Offset > sizeof(gMouse_FileData)) return 0;\r
if(Length > sizeof(gMouse_FileData)) Length = sizeof(gMouse_FileData);\r
CPPFLAGS += $(_CPPFLAGS)
CPPFLAGS += $(LIBINCLUDES)
CFLAGS := -std=gnu99 -Wall -fno-stack-protector -g -O3
+CFLAGS += -Werror
ifneq ($(CATEGORY),)
FULLNAME := $(CATEGORY)_$(NAME)
char *Ne2k_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, const char *Name);
int Ne2k_IOCtl(tVFS_Node *Node, int ID, void *Data);
-Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
-Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+size_t Ne2k_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
+size_t Ne2k_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
int Ne2k_int_ReadDMA(tCard *Card, int FirstPage, int NumPages, void *Buffer);
Uint8 Ne2k_int_GetWritePage(tCard *Card, Uint16 Length);
}
/**
- * \fn Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
* \brief Send a packet from the network card
*/
-Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t Ne2k_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
tCard *Card = (tCard*)Node->ImplPtr;
const Uint16 *buf = Buffer;
int rem = Length;
int page;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
// TODO: Lock
}
/**
- * \fn Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Wait for and read a packet from the network card
*/
-Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t Ne2k_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
- tCard *Card = (tCard*)Node->ImplPtr;
+ tCard *Card = Node->ImplPtr;
Uint8 page;
Uint8 data[256];
struct {
Uint16 Length; // Little Endian
} *pktHdr;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
// Wait for packets
if( Semaphore_Wait( &Card->Semaphore, 1 ) != 1 )
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, const void *Buffer);
+size_t RTL8139_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t RTL8139_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg);
void RTL8139_IRQHandler(int Num, void *Ptr);
}
// --- File Functions ---
-Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t RTL8139_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tCard *card = Node->ImplPtr;
Uint16 read_ofs, pkt_length;
int new_read_ofs;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
retry:
if( Semaphore_Wait( &card->ReadSemaphore, 1 ) != 1 )
return Length;
}
-Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t RTL8139_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
int td;
Uint32 status;
// Filesystem Interface
char *ATA_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *ATA_FindDir(tVFS_Node *Node, const char *Name);
-Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t ATA_ReadFS(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t ATA_WriteFS(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data);
// Read/Write Interface/Quantiser
Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
}
/**
- * \fn Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+ * \brief Read handler for VFS interface
*/
-Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t ATA_ReadFS(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
int disk = Node->Inode >> 8;
int part = Node->Inode & 0xFF;
}
/**
- * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+ * \brief Write handler for VFS interface
*/
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t ATA_WriteFS(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
int disk = Node->Inode >> 8;
int part = Node->Inode & 0xFF;
char *FDD_ReadDir(tVFS_Node *Node, int pos);
tVFS_Node *FDD_FindDir(tVFS_Node *dirNode, const char *Name);
int FDD_IOCtl(tVFS_Node *Node, int ID, void *Data);
-Uint64 FDD_ReadFS(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);
+size_t FDD_ReadFS(tVFS_Node *node, off_t Offset, size_t Len, void *buffer);
// --- Helpers
int FDD_int_ReadWriteWithinTrack(int Disk, int Track, int bWrite, size_t Offset, size_t Length, void *Buffer);
* \param Buffer Destination buffer
* \return Number of bytes read
*/
-Uint64 FDD_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t FDD_ReadFS(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
int disk = Node->Inode;
int track;
int rem_len;
char *dest = Buffer;
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+ ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);
if( Offset > Node->Size ) LEAVE_RET('i', 0);
if( Length > Node->Size ) Length = Node->Size;
// === PROTOTYES ===
char *HID_Mouse_Root_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *HID_Mouse_Root_FindDir(tVFS_Node *Node, const char *Name);
-Uint64 HID_Mouse_Dev_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+size_t HID_Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
int HID_Mouse_Dev_IOCtl(tVFS_Node *Node, int ID, void *Data);
void HID_Mouse_Dev_Reference(tVFS_Node *Node);
void HID_Mouse_Dev_Close(tVFS_Node *Node);
return &mouse->Node;
}
-Uint64 HID_Mouse_Dev_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t HID_Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
tHID_Mouse *info = Node->ImplPtr;
// === PROTOTYPES ===
int VGA_Install(char **Arguments);
-Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
+size_t VGA_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data);
Uint8 VGA_int_GetColourNibble(Uint16 col);
Uint16 VGA_int_GetWord(const tVT_Char *Char);
/**
* \brief Writes a string of bytes to the VGA controller
*/
-Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
+size_t VGA_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
{
if( giVGA_BufferFormat == VIDEO_BUFFMT_TEXT )
{