From: John Hodge Date: Mon, 14 Feb 2011 09:35:00 +0000 (+0800) Subject: Added some very pedantic warning flags X-Git-Tag: rel0.07~1 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9d85201216cb35e1b1e051b1d7cdc38eaa5befa4;p=tpg%2Facess2.git Added some very pedantic warning flags --- diff --git a/Kernel/Makefile b/Kernel/Makefile index cf4b0771..39e41ddc 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -17,6 +17,7 @@ MAKEDEP = $(CC) -M CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include -D_MODULE_NAME_=\"Kernel\" CPPFLAGS += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM) CFLAGS += -Wall -Werror -fno-stack-protector -fno-builtin -Wstrict-prototypes -g +CFLAGS += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized ASFLAGS += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\" LDFLAGS += -T arch/$(ARCHDIR)/link.ld -g diff --git a/Kernel/adt.c b/Kernel/adt.c index 7a238341..849b6c27 100644 --- a/Kernel/adt.c +++ b/Kernel/adt.c @@ -22,7 +22,7 @@ size_t RingBuffer_Read(void *Dest, tRingBuffer *Buffer, size_t Length) { int endData = Buffer->Space - Buffer->Start; memcpy(Dest, &Buffer->Data[Buffer->Start], endData); - memcpy(Dest + endData, &Buffer->Data, Length - endData); + memcpy((Uint8*)Dest + endData, &Buffer->Data, Length - endData); } else { @@ -44,7 +44,7 @@ size_t RingBuffer_Write(tRingBuffer *Buffer, void *Source, size_t Length) if(endSpace < Length) { memcpy( &Buffer->Data[bufEnd], Source, endSpace ); - memcpy( Buffer->Data, Source + endSpace, Length - endSpace ); + memcpy( Buffer->Data, (Uint8*)Source + endSpace, Length - endSpace ); Buffer->Length = Length - endSpace; } else diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 109f6506..f9813ed5 100644 --- a/Kernel/arch/x86/include/arch.h +++ b/Kernel/arch/x86/include/arch.h @@ -56,7 +56,7 @@ struct sShortSpinlock { // === MACROS === /** - * \brief Halt the CPU + * \brief Halt the CPU (shorter version of yield) */ #define HALT() __asm__ __volatile__ ("hlt") /** diff --git a/Kernel/arch/x86/include/mm_phys.h b/Kernel/arch/x86/include/mm_phys.h index 1e05c01a..96d3e64a 100644 --- a/Kernel/arch/x86/include/mm_phys.h +++ b/Kernel/arch/x86/include/mm_phys.h @@ -6,10 +6,10 @@ #define _MM_PHYS_H // === FUNCTIONS === -extern tPAddr MM_AllocPhys(void); -extern tPAddr MM_AllocPhysRange(int Pages, int MaxBits); -extern void MM_RefPhys(tPAddr PAddr); -extern void MM_DerefPhys(tPAddr PAddr); -extern int MM_GetRefCount(tPAddr Addr); +//extern tPAddr MM_AllocPhys(void); +//extern tPAddr MM_AllocPhysRange(int Pages, int MaxBits); +//extern void MM_RefPhys(tPAddr PAddr); +//extern void MM_DerefPhys(tPAddr PAddr); +//extern int MM_GetRefCount(tPAddr Addr); #endif diff --git a/Kernel/arch/x86/include/mm_virt.h b/Kernel/arch/x86/include/mm_virt.h index 84b088c6..e19a310c 100644 --- a/Kernel/arch/x86/include/mm_virt.h +++ b/Kernel/arch/x86/include/mm_virt.h @@ -27,9 +27,6 @@ // === FUNCTIONS === extern void MM_FinishVirtualInit(void); extern void MM_SetCR3(Uint CR3); -extern tPAddr MM_Allocate(tVAddr VAddr) __attribute__ ((warn_unused_result)); -extern void MM_Deallocate(tVAddr VAddr); -extern int MM_Map(tVAddr VAddr, tPAddr PAddr); extern tPAddr MM_Clone(void); extern tVAddr MM_NewKStack(void); extern tVAddr MM_NewWorkerStack(void); diff --git a/Kernel/arch/x86/irq.c b/Kernel/arch/x86/irq.c index e08f1ba0..381b1579 100644 --- a/Kernel/arch/x86/irq.c +++ b/Kernel/arch/x86/irq.c @@ -11,6 +11,9 @@ // === TYPES === typedef void (*tIRQ_Callback)(int); +// === PROTOTYPES === +void IRQ_Handler(tRegs *Regs); + // === GLOBALS === tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ]; diff --git a/Kernel/arch/x86/kpanic.c b/Kernel/arch/x86/kpanic.c index dc1a719b..0950be82 100644 --- a/Kernel/arch/x86/kpanic.c +++ b/Kernel/arch/x86/kpanic.c @@ -52,6 +52,11 @@ const struct { }; #define NUM_REGVALUES (sizeof(caRegValues)/sizeof(caRegValues[0])) +// === PROTOTYPES === +void KernelPanic_SetMode(void); +void KernelPanic_PutChar(char Ch); + +// === CODE === /** * \brief Sets the screen mode for a kernel panic */ diff --git a/Kernel/arch/x86/lib.c b/Kernel/arch/x86/lib.c index 3d951d46..5fa9d12e 100644 --- a/Kernel/arch/x86/lib.c +++ b/Kernel/arch/x86/lib.c @@ -11,8 +11,13 @@ extern struct sShortSpinlock glDebug_Lock; #endif +// === IMPRORTS === extern int GetCPUNum(void); +// === PROTOTYPES == +Uint64 __udivdi3(Uint64 Num, Uint64 Den); +Uint64 __umoddi3(Uint64 Num, Uint64 Den); + // === CODE === /** * \brief Determine if a short spinlock is locked @@ -216,14 +221,16 @@ void *memsetd(void *Dest, Uint32 Val, size_t Num) */ int memcmp(const void *m1, const void *m2, size_t Num) { + const Uint8 *d1 = m1; + const Uint8 *d2 = m2; if( Num == 0 ) return 0; // No bytes are always identical while(Num--) { - if(*(Uint8*)m1 != *(Uint8*)m2) - return *(Uint8*)m1 - *(Uint8*)m2; - m1 ++; - m2 ++; + if(*d1 != *d2) + return *d1 - *d2; + d1 ++; + d2 ++; } return 0; } diff --git a/Kernel/arch/x86/main.c b/Kernel/arch/x86/main.c index f9e70e5c..a55979f2 100644 --- a/Kernel/arch/x86/main.c +++ b/Kernel/arch/x86/main.c @@ -23,11 +23,11 @@ extern void MM_InstallVirtual(void); extern void Threads_Init(void); extern int Time_Setup(void); extern Uint Proc_Clone(Uint *Err, Uint Flags); -extern void Threads_Sleep(void); // --- Core --- extern void System_Init(char *Commandline); // === PROTOTYPES === + int kmain(Uint MbMagic, void *MbInfoPtr); void Arch_LoadBootModules(void); // === GLOBALS === diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index 4dbb2c32..a1feb464 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -16,10 +16,12 @@ extern void gKernelEnd; // === PROTOTYPES === -tPAddr MM_AllocPhys(void); -tPAddr MM_AllocPhysRange(int Pages, int MaxBits); -void MM_RefPhys(tPAddr PAddr); -void MM_DerefPhys(tPAddr PAddr); +void MM_Install(tMBoot_Info *MBoot); +//tPAddr MM_AllocPhys(void); +//tPAddr MM_AllocPhysRange(int Pages, int MaxBits); +//void MM_RefPhys(tPAddr PAddr); +//void MM_DerefPhys(tPAddr PAddr); +// int MM_GetRefCount(tPAddr PAddr); // === GLOBALS === tMutex glPhysAlloc; @@ -481,14 +483,14 @@ void MM_DerefPhys(tPAddr PAddr) /** * \fn int MM_GetRefCount(tPAddr Addr) */ -int MM_GetRefCount(tPAddr Addr) +int MM_GetRefCount(tPAddr PAddr) { // Get page number - Addr >>= 12; + PAddr >>= 12; // We don't care about non-ram pages - if(Addr >= giPageCount) return -1; + if(PAddr >= giPageCount) return -1; // Check if it is freed - return gaPageReferences[ Addr ]; + return gaPageReferences[ PAddr ]; } diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index a07f876d..68fd5c0d 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -78,6 +78,7 @@ void MM_PreinitVirtual(void); void MM_InstallVirtual(void); void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs); void MM_DumpTables(tVAddr Start, tVAddr End); +tVAddr MM_ClearUser(void); tPAddr MM_DuplicatePage(tVAddr VAddr); // === GLOBALS === diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index bdb5c5d3..4ab40398 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -56,11 +56,14 @@ void ArchThreads_Init(void); void MP_StartAP(int CPU); void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode); #endif -void Proc_Start(void); -tThread *Proc_GetCurThread(void); +//void Proc_Start(void); +//tThread *Proc_GetCurThread(void); void Proc_ChangeStack(void); - int Proc_Clone(Uint *Err, Uint Flags); +// int Proc_Clone(Uint *Err, Uint Flags); +Uint Proc_MakeUserStack(void); +void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize); 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_Scheduler(int CPU); @@ -470,7 +473,7 @@ void Proc_Start(void) if(Proc_Clone(0, 0) == 0) { gpIdleThread = Proc_GetCurThread(); - gpIdleThread->ThreadName = "Idle Thread"; + gpIdleThread->ThreadName = strdup("Idle Thread"); Threads_SetPriority( gpIdleThread, -1 ); // Never called randomly gpIdleThread->Quantum = 1; // 1 slice quantum for(;;) HALT(); // Just yeilds diff --git a/Kernel/arch/x86/time.c b/Kernel/arch/x86/time.c index ce77ee32..22ea6181 100644 --- a/Kernel/arch/x86/time.c +++ b/Kernel/arch/x86/time.c @@ -28,7 +28,7 @@ volatile Uint64 giTime_TSCAtLastTick = 0; volatile Uint64 giTime_TSCPerTick = 0; // === PROTOTYPES === -Sint64 now(void); +//Sint64 now(void); int Time_Setup(void); void Time_Interrupt(int); Uint64 Time_ReadTSC(void); diff --git a/Kernel/arch/x86/vm8086.c b/Kernel/arch/x86/vm8086.c index a1c75e23..71813510 100644 --- a/Kernel/arch/x86/vm8086.c +++ b/Kernel/arch/x86/vm8086.c @@ -40,7 +40,7 @@ struct sVM8086_InternalData // === PROTOTYPES === int VM8086_Install(char **Arguments); void VM8086_GPF(tRegs *Regs); -tVM8086 *VM8086_Init(void); +//tVM8086 *VM8086_Init(void); // === GLOBALS === MODULE_DEFINE(0, 0x100, VM8086, VM8086_Install, NULL, NULL); @@ -83,7 +83,12 @@ int VM8086_Install(char **Arguments) MM_Map( i * 0x1000, i * 0x1000 ); MM_DerefPhys( i * 0x1000 ); } MM_Map( 0x9F000, 0x9F000 ); // Stack / EBDA - MM_Allocate( 0x100000 ); // System Stack / Stub + // System Stack / Stub + if( MM_Allocate( 0x100000 ) == 0 ) { + Log_Error("VM8086", "Unable to allocate memory for stack/stub"); + gVM8086_WorkerPID = 0; + Threads_Exit(0, 1); + } *(Uint8*)(0x100000) = VM8086_OP_IRET; *(Uint8*)(0x100001) = 0x07; // POP ES @@ -133,6 +138,11 @@ int VM8086_Install(char **Arguments) while( gpVM8086_State != NULL ) Threads_Yield(); // Yield to allow the child to initialise + // Worker killed itself + if( gVM8086_WorkerPID != pid ) { + return MODULE_ERR_MISC; + } + return MODULE_ERR_OK; } diff --git a/Kernel/bin/elf.c b/Kernel/bin/elf.c index c524cf81..2f43eee8 100644 --- a/Kernel/bin/elf.c +++ b/Kernel/bin/elf.c @@ -12,9 +12,9 @@ // === PROTOTYPES === tBinary *Elf_Load(int fp); int Elf_Relocate(void *Base); - int Elf_GetSymbol(void *Base, char *Name, Uint *ret); + int Elf_GetSymbol(void *Base, const char *Name, Uint *ret); int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base); -Uint Elf_Int_HashString(char *str); +Uint Elf_Int_HashString(const char *str); // === GLOBALS === tBinaryType gELF_Info = { @@ -285,7 +285,7 @@ int Elf_Relocate(void *Base) ENTER("pBase", Base); // Parse Program Header to get Dynamic Table - phtab = Base + hdr->phoff; + phtab = (void *)( (tVAddr)Base + hdr->phoff ); iSegmentCount = hdr->phentcount; for(i = 0; i < iSegmentCount; i ++ ) { @@ -528,10 +528,10 @@ int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symta } /** - * \fn int Elf_GetSymbol(void *Base, char *name, Uint *ret) + * \fn int Elf_GetSymbol(void *Base, const char *name, Uint *ret) * \brief Get a symbol from the loaded binary */ -int Elf_GetSymbol(void *Base, char *Name, Uint *ret) +int Elf_GetSymbol(void *Base, const char *Name, Uint *ret) { Elf32_Ehdr *hdr = (void*)Base; Elf32_Sym *symtab; @@ -581,7 +581,7 @@ int Elf_GetSymbol(void *Base, char *Name, Uint *ret) * \param str String to hash * \return Hash value */ -Uint Elf_Int_HashString(char *str) +Uint Elf_Int_HashString(const char *str) { Uint h = 0, g; while(*str) diff --git a/Kernel/bin/pe.c b/Kernel/bin/pe.c index 0b74529d..a697e9cb 100644 --- a/Kernel/bin/pe.c +++ b/Kernel/bin/pe.c @@ -13,11 +13,11 @@ tBinary *PE_Load(int fp); tBinary *MZ_Open(int fp); int PE_Relocate(void *Base); - int PE_GetSymbol(void *Base, char *Name, Uint *Ret); + int PE_GetSymbol(void *Base, const char *Name, Uint *Ret); // === GLOBALS === MODULE_DEFINE(0, 0x0032, BinPE, PE_Install, NULL, NULL); -char *gsPE_DefaultInterpreter = "/Acess/Libs/ld-acess.so"; +const char *gsPE_DefaultInterpreter = "/Acess/Libs/ld-acess.so"; tBinaryType gPE_Loader = { NULL, ('M'|('Z'<<8)), 0xFFFF, // 'MZ' @@ -231,7 +231,7 @@ int PE_Relocate(void *Base) return 0; } -int PE_GetSymbol(void *Base, char *Name, Uint *Ret) +int PE_GetSymbol(void *Base, const char *Name, Uint *Ret) { return 0; } diff --git a/Kernel/binary.c b/Kernel/binary.c index fa49e850..5a919e17 100644 --- a/Kernel/binary.c +++ b/Kernel/binary.c @@ -25,7 +25,6 @@ typedef struct sKernelBin { // === IMPORTS === extern int Proc_Clone(Uint *Err, Uint Flags); extern char *Threads_GetName(int ID); -extern void Threads_Exit(int, int); extern Uint MM_ClearUser(void); extern void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize); extern tKernelSymbol gKernelSymbols[]; @@ -33,16 +32,20 @@ extern void gKernelSymbolsEnd; extern tBinaryType gELF_Info; // === PROTOTYPES === - int Proc_Execve(char *File, char **ArgV, char **EnvP); -Uint Binary_Load(char *file, Uint *entryPoint); -tBinary *Binary_GetInfo(char *truePath); + int Proc_Execve(const char *File, const char **ArgV, const char **EnvP); +Uint Binary_Load(const char *file, Uint *entryPoint); +tBinary *Binary_GetInfo(const char *truePath); Uint Binary_MapIn(tBinary *binary); Uint Binary_IsMapped(tBinary *binary); -tBinary *Binary_DoLoad(char *truePath); +tBinary *Binary_DoLoad(const char *truePath); void Binary_Dereference(tBinary *Info); +#if 0 Uint Binary_Relocate(void *Base); -Uint Binary_GetSymbolEx(char *Name, Uint *Value); -Uint Binary_FindSymbol(void *Base, char *Name, Uint *Val); +#endif +Uint Binary_GetSymbolEx(const char *Name, Uint *Value); +#if 0 +Uint Binary_FindSymbol(void *Base, const char *Name, Uint *Val); +#endif // === GLOBALS === tShortSpinlock glBinListLock; @@ -78,7 +81,7 @@ int Proc_Spawn(char *Path) if(Proc_Clone(NULL, CLONE_VM) == 0) { // CHILD - char *args[2] = {stackPath, NULL}; + const char *args[2] = {stackPath, NULL}; LOG("stackPath = '%s'\n", stackPath); Proc_Execve(stackPath, args, &args[1]); for(;;); @@ -94,7 +97,7 @@ int Proc_Spawn(char *Path) * \param EnvP User's environment * \note Called Proc_ for historical reasons */ -int Proc_Execve(char *File, char **ArgV, char **EnvP) +int Proc_Execve(const char *File, const char **ArgV, const char **EnvP) { int argc, envc, i; int argenvBytes; @@ -177,7 +180,7 @@ int Proc_Execve(char *File, char **ArgV, char **EnvP) * \param file Path to binary to load * \param entryPoint Pointer for exectuable entry point */ -Uint Binary_Load(char *file, Uint *entryPoint) +Uint Binary_Load(const char *file, Uint *entryPoint) { char *sTruePath; tBinary *pBinary; @@ -256,7 +259,7 @@ Uint Binary_Load(char *file, Uint *entryPoint) * \brief Finds a matching binary entry * \param TruePath File Identifier (True path name) */ -tBinary *Binary_GetInfo(char *TruePath) +tBinary *Binary_GetInfo(const char *TruePath) { tBinary *pBinary; pBinary = glLoadedBinaries; @@ -389,7 +392,7 @@ Uint Binary_IsMapped(tBinary *binary) * \brief Loads a binary file into memory * \param truePath Absolute filename of binary */ -tBinary *Binary_DoLoad(char *truePath) +tBinary *Binary_DoLoad(const char *truePath) { tBinary *pBinary; int fp, i; @@ -432,8 +435,7 @@ tBinary *Binary_DoLoad(char *truePath) // Initialise Structure pBinary->ReferenceCount = 0; - pBinary->TruePath = malloc( strlen(truePath) + 1 ); - strcpy(pBinary->TruePath, truePath); + pBinary->TruePath = strdup(truePath); // Debug Information LOG("Interpreter: '%s'", pBinary->Interpreter); @@ -615,12 +617,12 @@ char *Binary_RegInterp(char *Path) // Kernel Binary Handling // ============ /** - * \fn void *Binary_LoadKernel(char *File) + * \fn void *Binary_LoadKernel(const char *File) * \brief Load a binary into kernel space * \note This function shares much with #Binary_Load, but does it's own mapping * \param File File to load into the kernel */ -void *Binary_LoadKernel(char *File) +void *Binary_LoadKernel(const char *File) { char *sTruePath; tBinary *pBinary; @@ -629,7 +631,7 @@ void *Binary_LoadKernel(char *File) Uint addr; int i; - ENTER("sfile", File); + ENTER("sFile", File); // Sanity Check Argument if(File == NULL) { @@ -792,7 +794,7 @@ Uint Binary_Relocate(void *Base) * Gets the value of a symbol from either the currently loaded * libraries or the kernel's exports. */ -int Binary_GetSymbol(char *Name, Uint *Val) +int Binary_GetSymbol(const char *Name, Uint *Val) { if( Binary_GetSymbolEx(Name, Val) ) return 1; return 0; @@ -805,7 +807,7 @@ int Binary_GetSymbol(char *Name, Uint *Val) * Gets the value of a symbol from either the currently loaded * libraries or the kernel's exports. */ -Uint Binary_GetSymbolEx(char *Name, Uint *Value) +Uint Binary_GetSymbolEx(const char *Name, Uint *Value) { int i; tKernelBin *pKBin; @@ -841,7 +843,7 @@ Uint Binary_GetSymbolEx(char *Name, Uint *Value) * \param Name Name of symbol to find * \param Val Pointer to place final value */ -Uint Binary_FindSymbol(void *Base, char *Name, Uint *Val) +Uint Binary_FindSymbol(void *Base, const char *Name, Uint *Val) { Uint32 ident = *(Uint32*) Base; tBinaryType *bt = gRegBinTypes; diff --git a/Kernel/debug.c b/Kernel/debug.c index c05efa0b..f59704ad 100644 --- a/Kernel/debug.c +++ b/Kernel/debug.c @@ -25,7 +25,10 @@ extern void KernelPanic_PutChar(char Ch); int getDebugChar(void); static void Debug_Putchar(char ch); static void Debug_Puts(int DbgOnly, const char *Str); +void Debug_DbgOnlyFmt(const char *format, va_list args); +void Debug_FmtS(const char *format, ...); void Debug_Fmt(const char *format, va_list args); +void Debug_SetKTerminal(const char *File); // === GLOBALS === int gDebug_Level = 0; @@ -308,6 +311,7 @@ void Debug_Enter(const char *FuncName, const char *ArgTypes, ...) va_start(args, ArgTypes); + LogF("%012lli ", now()); while(i--) Debug_Putchar(' '); Debug_Puts(1, FuncName); @@ -365,6 +369,7 @@ void Debug_Log(const char *FuncName, const char *Fmt, ...) va_start(args, Fmt); + LogF("%012lli ", now()); while(i--) Debug_Putchar(' '); Debug_Puts(1, FuncName); @@ -399,6 +404,7 @@ void Debug_Leave(const char *FuncName, char RetType, ...) gDebug_Level = 0; i = 0; } + LogF("%012lli ", now()); // Indenting while(i--) Debug_Putchar(' '); diff --git a/Kernel/drv/dma.c b/Kernel/drv/dma.c index 798a3e40..dd8e88f7 100644 --- a/Kernel/drv/dma.c +++ b/Kernel/drv/dma.c @@ -23,6 +23,7 @@ typedef struct int DMA_Install(char **Arguments); void DMA_SetChannel(int Channel, int length, int read); int DMA_ReadData(int channel, int count, void *buffer); + int DMA_WriteData(int channel, int count, const void *buffer); // === CONSTANTS === const Uint8 cMASKPORT [8] = { 0x0A, 0x0A, 0x0A, 0x0A, 0xD4, 0xD4, 0xD4, 0xD4 }; @@ -110,7 +111,7 @@ int DMA_ReadData(int channel, int count, void *buffer) * \fn void DMA_WriteData(int channel, int count, void *buffer) * \brief Write data to a DMA buffer */ -int DMA_WriteData(int channel, int count, void *buffer) +int DMA_WriteData(int channel, int count, const void *buffer) { if(channel < 0 || channel > 7) return -1; diff --git a/Kernel/drv/fifo.c b/Kernel/drv/fifo.c index 00570531..53e6bab3 100644 --- a/Kernel/drv/fifo.c +++ b/Kernel/drv/fifo.c @@ -33,7 +33,7 @@ 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, void *Buffer); -tPipe *FIFO_Int_NewPipe(int Size, char *Name); +tPipe *FIFO_Int_NewPipe(int Size, const char *Name); // === GLOBALS === MODULE_DEFINE(0, 0x0032, FIFO, FIFO_Install, NULL, NULL); @@ -220,7 +220,8 @@ Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) while(remaining) { // Wait for buffer to fill - if(pipe->Flags & PF_BLOCKING) { + if(pipe->Flags & PF_BLOCKING) + { len = Semaphore_Wait( &pipe->Semaphore, remaining ); } else @@ -239,7 +240,7 @@ Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { int ofs = pipe->BufSize - pipe->ReadPos; memcpy(Buffer, &pipe->Buffer[pipe->ReadPos], ofs); - memcpy(Buffer + ofs, &pipe->Buffer, len-ofs); + memcpy((Uint8*)Buffer + ofs, &pipe->Buffer, len-ofs); } else { @@ -253,7 +254,7 @@ Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) // Decrement Remaining Bytes remaining -= len; // Increment Buffer address - Buffer += len; + Buffer = (Uint8*)Buffer + len; } return Length; @@ -294,7 +295,7 @@ Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { int ofs = pipe->BufSize - pipe->WritePos; memcpy(&pipe->Buffer[pipe->WritePos], Buffer, ofs); - memcpy(&pipe->Buffer, Buffer + ofs, len-ofs); + memcpy(&pipe->Buffer, (Uint8*)Buffer + ofs, len-ofs); } else { @@ -308,7 +309,7 @@ Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) // Decrement Remaining Bytes remaining -= len; // Increment Buffer address - Buffer += len; + Buffer = (Uint8*)Buffer + len; } return Length; @@ -316,10 +317,10 @@ Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) // --- HELPERS --- /** - * \fn tPipe *FIFO_Int_NewPipe(int Size, char *Name) + * \fn tPipe *FIFO_Int_NewPipe(int Size, const char *Name) * \brief Create a new pipe */ -tPipe *FIFO_Int_NewPipe(int Size, char *Name) +tPipe *FIFO_Int_NewPipe(int Size, const char *Name) { tPipe *ret; int namelen = strlen(Name) + 1; diff --git a/Kernel/drv/iocache.c b/Kernel/drv/iocache.c index 271fc840..2b4755cf 100644 --- a/Kernel/drv/iocache.c +++ b/Kernel/drv/iocache.c @@ -305,14 +305,14 @@ void IOCache_Destroy( tIOCache *Cache ) // Remove from list SHORTLOCK( &glIOCache_Caches ); { - tIOCache *ent; - tIOCache *prev = (tIOCache*)&gIOCache_Caches; - for(ent = gIOCache_Caches; - ent; - prev = ent, ent = ent->Next ) + tIOCache *cache; + tIOCache *prev_cache = (tIOCache*)&gIOCache_Caches; + for(cache = gIOCache_Caches; + cache; + prev_cache = cache, cache = cache->Next ) { - if(ent == Cache) { - prev->Next = ent->Next; + if(cache == Cache) { + prev_cache->Next = cache->Next; break; } } diff --git a/Kernel/drv/pci.c b/Kernel/drv/pci.c index 1f9e7285..73e3a40c 100644 --- a/Kernel/drv/pci.c +++ b/Kernel/drv/pci.c @@ -39,17 +39,20 @@ typedef struct sPCIDevice char *PCI_ReadDirRoot(tVFS_Node *node, int pos); tVFS_Node *PCI_FindDirRoot(tVFS_Node *node, const char *filename); Uint64 PCI_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer); - + +#if 0 int PCI_CountDevices(Uint16 vendor, Uint16 device, Uint16 fcn); int PCI_GetDevice(Uint16 vendor, Uint16 device, Uint16 fcn, int idx); int PCI_GetDeviceByClass(Uint16 class, Uint16 mask, int prev); Uint8 PCI_GetIRQ(int id); Uint32 PCI_GetBAR0(int id); Uint32 PCI_GetBAR1(int id); +Uint32 PCI_GetBAR2(int id); Uint32 PCI_GetBAR3(int id); Uint32 PCI_GetBAR4(int id); Uint32 PCI_GetBAR5(int id); Uint16 PCI_AssignPort(int id, int bar, int count); +#endif int PCI_EnumDevice(Uint16 bus, Uint16 dev, Uint16 fcn, tPCIDevice *info); Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset); diff --git a/Kernel/drv/proc.c b/Kernel/drv/proc.c index cf19a66a..c0ce6edc 100644 --- a/Kernel/drv/proc.c +++ b/Kernel/drv/proc.c @@ -26,9 +26,11 @@ typedef struct sSysFS_Ent int SysFS_Install(char **Arguments); int SysFS_IOCtl(tVFS_Node *Node, int Id, void *Data); - int SysFS_RegisterFile(char *Path, char *Data, int Length); - int SysFS_UpdateFile(int ID, char *Data, int Length); +#if 0 + int SysFS_RegisterFile(const char *Path, const char *Data, int Length); + int SysFS_UpdateFile(int ID, const char *Data, int Length); int SysFS_RemoveFile(int ID); +#endif char *SysFS_Comm_ReadDir(tVFS_Node *Node, int Id); tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, const char *Filename); @@ -44,7 +46,7 @@ tSysFS_Ent gSysFS_Version_Kernel = { &gSysFS_Version, // Parent { .Inode = 1, // File #1 - .ImplPtr = KERNEL_VERSION_STRING, + .ImplPtr = (void*)KERNEL_VERSION_STRING, .ImplInt = (Uint)&gSysFS_Version_Kernel, // Self-Link .Size = sizeof(KERNEL_VERSION_STRING)-1, .NumACLs = 1, @@ -114,7 +116,7 @@ int SysFS_Install(char **Options) * \param Length Length of the data buffer * \return The file's identifier */ -int SysFS_RegisterFile(char *Path, char *Data, int Length) +int SysFS_RegisterFile(const char *Path, const char *Data, int Length) { int start = 0; int tmp; @@ -199,7 +201,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) child->Parent = ent; child->Node.Inode = giSysFS_NextFileID++; - child->Node.ImplPtr = Data; + child->Node.ImplPtr = (void*)Data; child->Node.ImplInt = (Uint)child; // Uplink child->Node.Size = Length; child->Node.NumACLs = 1; @@ -235,7 +237,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) * \param Length Length of the data buffer * \return Boolean Success */ -int SysFS_UpdateFile(int ID, char *Data, int Length) +int SysFS_UpdateFile(int ID, const char *Data, int Length) { tSysFS_Ent *ent; @@ -245,7 +247,7 @@ int SysFS_UpdateFile(int ID, char *Data, int Length) if(ent->Node.Inode < ID) return 0; if(ent->Node.Inode == ID) { - ent->Node.ImplPtr = Data; + ent->Node.ImplPtr = (void*)Data; ent->Node.Size = Length; return 1; } diff --git a/Kernel/drv/vga.c b/Kernel/drv/vga.c index ac00c78b..54360697 100644 --- a/Kernel/drv/vga.c +++ b/Kernel/drv/vga.c @@ -15,6 +15,7 @@ int VGA_Install(char **Arguments); Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data); +Uint8 VGA_int_GetColourNibble(Uint16 col); Uint16 VGA_int_GetWord(tVT_Char *Char); void VGA_int_SetCursor(Sint16 x, Sint16 y); diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index 52c3a944..db56f0e7 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -30,7 +30,7 @@ #define VT_FLAG_HASFB 0x10 //!< Set if the VTerm has requested the Framebuffer enum eVT_InModes { - VT_INMODE_TEXT8, // UTF-8 Text Mode (VT100 Emulation) + VT_INMODE_TEXT8, // UTF-8 Text Mode (VT100/xterm Emulation) VT_INMODE_TEXT32, // UTF-32 Text Mode (Acess Native) NUM_VT_INMODES }; @@ -65,7 +65,7 @@ typedef struct { } tVTerm; // === IMPORTS === -extern void Debug_SetKTerminal(char *File); +extern void Debug_SetKTerminal(const char *File); // === PROTOTYPES === int VT_Install(char **Arguments); @@ -82,6 +82,7 @@ void VT_SetMode(int Mode); void VT_SetTerminal(int ID); void VT_KBCallBack(Uint32 Codepoint); void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count); +void VT_int_ClearLine(tVTerm *Term, int Num); int VT_int_ParseEscape(tVTerm *Term, char *Buffer); void VT_int_PutChar(tVTerm *Term, Uint32 Ch); void VT_int_ScrollFramebuffer( tVTerm *Term ); @@ -157,10 +158,10 @@ int VT_Install(char **Arguments) Log_Debug("VTerm", "Argument '%s'", arg); if( strcmp(opt, "Video") == 0 ) { - gsVT_OutputDevice = val; + gsVT_OutputDevice = strdup(val); } else if( strcmp(opt, "Input") == 0 ) { - gsVT_InputDevice = val; + gsVT_InputDevice = strdup(val); } else if( strcmp(opt, "Width") == 0 ) { giVT_RealWidth = atoi( val ); @@ -178,8 +179,8 @@ int VT_Install(char **Arguments) if(gsVT_InputDevice) Modules_InitialiseBuiltin( gsVT_InputDevice ); // Apply Defaults - if(!gsVT_OutputDevice) gsVT_OutputDevice = DEFAULT_OUTPUT; - if(!gsVT_InputDevice) gsVT_InputDevice = DEFAULT_INPUT; + if(!gsVT_OutputDevice) gsVT_OutputDevice = strdup(DEFAULT_OUTPUT); + if(!gsVT_InputDevice) gsVT_InputDevice = strdup(DEFAULT_INPUT); // Create paths { @@ -392,6 +393,8 @@ int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data) len = strlen(Data); + // TODO: Check if the string used is a heap string + free(gsVT_OutputDevice); gsVT_OutputDevice = malloc(len+1); @@ -1031,7 +1034,7 @@ void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count) void VT_int_PutChar(tVTerm *Term, Uint32 Ch) { int i; - + switch(Ch) { case '\0': return; // Ignore NULL byte @@ -1083,7 +1086,7 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) // - Check if we need to scroll the entire scrollback buffer if(Term->WritePos >= Term->TextWidth*Term->TextHeight*(giVT_Scrollback+1)) { - int base, i; + int base; // Move back by one Term->WritePos -= Term->TextWidth; diff --git a/Kernel/drvutil.c b/Kernel/drvutil.c index 85d4434d..7e5b9b18 100644 --- a/Kernel/drvutil.c +++ b/Kernel/drvutil.c @@ -118,7 +118,7 @@ Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, return leading; } - Buffer += leading; + Buffer = (Uint8*)Buffer + leading; block ++; num = ( Length - leading ) / BlockSize; tailings = Length - num * BlockSize - leading; @@ -144,7 +144,7 @@ Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, { LOG("Reading %i bytes from last block", tailings); block += num; - Buffer += num * BlockSize; + Buffer = (Uint8*)Buffer + num * BlockSize; ret = ReadBlocks(block, 1, tmp, Argument); if(ret != 1) { LEAVE('X', leading + num * BlockSize); @@ -197,7 +197,7 @@ Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer, return leading; } - Buffer += leading; + Buffer = (Uint8*)Buffer + leading; block ++; num = ( Length - leading ) / BlockSize; tailings = Length - num * BlockSize - leading; @@ -223,7 +223,7 @@ Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer, { LOG("Writing %i bytes to last block", tailings); block += num; - Buffer += num * BlockSize; + Buffer = (Uint8*)Buffer + num * BlockSize; // Read ret = ReadBlocks(block, 1, tmp, Argument); if(ret != 1) { diff --git a/Kernel/heap.c b/Kernel/heap.c index 8a7adec4..a569578c 100644 --- a/Kernel/heap.c +++ b/Kernel/heap.c @@ -28,10 +28,10 @@ void Heap_Install(void); void *Heap_Extend(int Bytes); void *Heap_Merge(tHeapHead *Head); -void *Heap_Allocate(const char *File, int Line, size_t Bytes); -void *Heap_AllocateZero(const char *File, int Line, size_t Bytes); -void *Heap_Reallocate(const char *File, int Line, void *Ptr, size_t Bytes); -void Heap_Deallocate(void *Ptr); +//void *Heap_Allocate(const char *File, int Line, size_t Bytes); +//void *Heap_AllocateZero(const char *File, int Line, size_t Bytes); +//void *Heap_Reallocate(const char *File, int Line, void *Ptr, size_t Bytes); +//void Heap_Deallocate(void *Ptr); void Heap_Dump(void); void Heap_Stats(void); @@ -79,7 +79,7 @@ void *Heap_Extend(int Bytes) } // Increas heap end - gHeapEnd += i << 12; + gHeapEnd = (Uint8*)gHeapEnd + (i << 12); // Create Block head->Size = (Bytes+0xFFF)&~0xFFF; diff --git a/Kernel/include/acess.h b/Kernel/include/acess.h index d2e1e802..4286f5ee 100644 --- a/Kernel/include/acess.h +++ b/Kernel/include/acess.h @@ -95,7 +95,7 @@ typedef void (*tThreadFunction)(void*); * \{ */ typedef struct sKernelSymbol { - char *Name; + const char *Name; tVAddr Value; } tKernelSymbol; #define EXPORT(_name) tKernelSymbol _kexp_##_name __attribute__((section ("KEXPORT"),unused))={#_name, (tVAddr)_name} @@ -110,13 +110,13 @@ typedef struct sKernelSymbol { extern int IRQ_AddHandler(int Num, void (*Callback)(int)); // --- Logging --- -extern void Log_KernelPanic(char *Ident, char *Message, ...); -extern void Log_Panic(char *Ident, char *Message, ...); -extern void Log_Error(char *Ident, char *Message, ...); -extern void Log_Warning(char *Ident, char *Message, ...); -extern void Log_Notice(char *Ident, char *Message, ...); -extern void Log_Log(char *Ident, char *Message, ...); -extern void Log_Debug(char *Ident, char *Message, ...); +extern void Log_KernelPanic(const char *Ident, const char *Message, ...); +extern void Log_Panic(const char *Ident, const char *Message, ...); +extern void Log_Error(const char *Ident, const char *Message, ...); +extern void Log_Warning(const char *Ident, const char *Message, ...); +extern void Log_Notice(const char *Ident, const char *Message, ...); +extern void Log_Log(const char *Ident, const char *Message, ...); +extern void Log_Debug(const char *Ident, const char *Message, ...); // --- Debug --- /** @@ -185,7 +185,7 @@ extern Uint64 inq(Uint16 Port); * \param VAddr Virtual Address to allocate at * \return Physical address allocated */ -extern tPAddr MM_Allocate(tVAddr VAddr); +extern tPAddr MM_Allocate(tVAddr VAddr) __attribute__ ((warn_unused_result)); /** * \brief Deallocate a page * \param VAddr Virtual address to unmap @@ -277,6 +277,12 @@ extern void MM_RefPhys(tPAddr PAddr); * \param PAddr Page to dereference */ extern void MM_DerefPhys(tPAddr PAddr); +/** + * \brief Get the number of times a page has been referenced + * \param PAddr Address to check + * \return Reference count for the page + */ +extern int MM_GetRefCount(tPAddr PAddr); /** * \} */ @@ -298,8 +304,8 @@ extern void *memsetd(void *dest, Uint32 val, size_t count); * \name Memory Validation * \{ */ -extern int CheckString(char *String); -extern int CheckMem(void *Mem, int Num); +extern int CheckString(const char *String); +extern int CheckMem(const void *Mem, int Num); /** * \} */ @@ -339,12 +345,12 @@ extern int strpos(const char *Str, char Ch); extern int strpos8(const char *str, Uint32 search); extern void itoa(char *buf, Uint64 num, int base, int minLength, char pad); extern int atoi(const char *string); -extern int ReadUTF8(Uint8 *str, Uint32 *Val); +extern int ReadUTF8(const Uint8 *str, Uint32 *Val); extern int WriteUTF8(Uint8 *str, Uint32 Val); -extern int ModUtil_SetIdent(char *Dest, char *Value); -extern int ModUtil_LookupString(char **Array, char *Needle); +extern int ModUtil_SetIdent(char *Dest, const char *Value); +extern int ModUtil_LookupString(const char **Array, const char *Needle); -extern Uint8 ByteSum(void *Ptr, int Size); +extern Uint8 ByteSum(const void *Ptr, int Size); extern int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString); /** * \} @@ -361,8 +367,8 @@ extern int CallWithArgArray(void *Function, int NArgs, Uint *Args); * \name Modules * \{ */ -extern int Module_LoadMem(void *Buffer, Uint Length, char *ArgStr); -extern int Module_LoadFile(char *Path, char *ArgStr); +extern int Module_LoadMem(void *Buffer, Uint Length, const char *ArgStr); +extern int Module_LoadFile(const char *Path, const char *ArgStr); /** * \} */ diff --git a/Kernel/include/binary.h b/Kernel/include/binary.h index 77ccdd74..91a2e224 100644 --- a/Kernel/include/binary.h +++ b/Kernel/include/binary.h @@ -65,12 +65,12 @@ typedef struct sBinary * \note Used to uniquely identify the loaded binary to reduce in-memory * duplication. */ - char *TruePath; + const char *TruePath; /** * \brief Interpreter used to load the file * \note This can be either requested by the individual file, or a per-driver option */ - char *Interpreter; + const char *Interpreter; /** * \brief Entrypoint of the binary (at requested base); */ @@ -118,7 +118,7 @@ typedef struct sBinaryType */ Uint32 Ident; Uint32 Mask; //!< Mask value for tBinaryType.Ident - char *Name; //!< Name of this executable type (for debug purpouses) + const char *Name; //!< Name of this executable type (for debug purpouses) /** * \brief Read a binary from a file * \param FD VFS File handle to file to load @@ -151,7 +151,7 @@ typedef struct sBinaryType * tBinaryType.Relocate at this time, so the driver should * accomodate this. */ - int (*GetSymbol)(void *Base, char *Name, Uint *Dest); + int (*GetSymbol)(void *Base, const char *Name, Uint *Dest); } tBinaryType; /** diff --git a/Kernel/include/binary_ext.h b/Kernel/include/binary_ext.h index 67c6073d..b2fc89d8 100644 --- a/Kernel/include/binary_ext.h +++ b/Kernel/include/binary_ext.h @@ -7,11 +7,11 @@ #define _BINARY_EXT_H // === FUNCTIONS === -extern void *Binary_LoadFile(char *Path); -extern void *Binary_LoadKernel(char *Path); +extern void *Binary_LoadFile(const char *Path); +extern void *Binary_LoadKernel(const char *Path); extern Uint Binary_Relocate(void *Mem); extern void Binary_Unload(void *Base); -extern int Binary_GetSymbol(char *Name, Uint *Dest); -extern Uint Binary_FindSymbol(void *Base, char *Name, Uint *Val); +extern int Binary_GetSymbol(const char *Name, Uint *Dest); +extern Uint Binary_FindSymbol(void *Base, const char *Name, Uint *Val); #endif diff --git a/Kernel/include/drv_pci.h b/Kernel/include/drv_pci.h index d3eb8a27..128f1052 100644 --- a/Kernel/include/drv_pci.h +++ b/Kernel/include/drv_pci.h @@ -45,6 +45,7 @@ extern int PCI_GetDeviceByClass(Uint16 class, Uint16 mask, int prev); extern Uint8 PCI_GetIRQ(int id); extern Uint32 PCI_GetBAR0(int id); extern Uint32 PCI_GetBAR1(int id); +extern Uint32 PCI_GetBAR2(int id); extern Uint32 PCI_GetBAR3(int id); extern Uint32 PCI_GetBAR4(int id); extern Uint32 PCI_GetBAR5(int id); diff --git a/Kernel/include/fs_devfs.h b/Kernel/include/fs_devfs.h index 5589f4f9..c099fc6c 100644 --- a/Kernel/include/fs_devfs.h +++ b/Kernel/include/fs_devfs.h @@ -14,7 +14,7 @@ typedef struct sDevFS_Driver { struct sDevFS_Driver *Next; //!< Set to NULL by drivers (used internally) - char *Name; //!< Name of the driver file/folder (must be unique) + const char *Name; //!< Name of the driver file/folder (must be unique) tVFS_Node RootNode; //!< Root node of driver } tDevFS_Driver; diff --git a/Kernel/include/fs_sysfs.h b/Kernel/include/fs_sysfs.h index 698646f4..c6c75f82 100644 --- a/Kernel/include/fs_sysfs.h +++ b/Kernel/include/fs_sysfs.h @@ -21,7 +21,7 @@ * \note \a Data must be maintained until ::SysFS_UpdateFile is called * with a different buffer, or ::SysFS_RemoveFile is called. */ -extern int SysFS_RegisterFile(char *Path, char *Data, int Length); +extern int SysFS_RegisterFile(const char *Path, const char *Data, int Length); /** * \brief Updates the size/pointer associated with a SysFD file @@ -30,7 +30,7 @@ extern int SysFS_RegisterFile(char *Path, char *Data, int Length); * \param Length New length of the file * \return Boolean Success */ -extern int SysFS_UpdateFile(int ID, char *Data, int Length); +extern int SysFS_UpdateFile(int ID, const char *Data, int Length); /** * \brief Removes a file from the SysFS tree diff --git a/Kernel/include/modules.h b/Kernel/include/modules.h index db3f91ad..0c576750 100644 --- a/Kernel/include/modules.h +++ b/Kernel/include/modules.h @@ -53,7 +53,7 @@ * Contains the identifiers of the required modules. */ #define MODULE_DEFINE(_flags,_ver,_ident,_entry,_deinit,_deps...) \ - char *EXPAND_CONCAT(_DriverDeps_,_ident)[]={_deps};\ + const char *EXPAND_CONCAT(_DriverDeps_,_ident)[]={_deps};\ tModule __attribute__ ((section ("KMODULES"),unused))\ EXPAND_CONCAT(_DriverInfo_,_ident)=\ {MODULE_MAGIC,MODULE_ARCH_ID,_flags,_ver,NULL,EXPAND_STR(_ident),\ @@ -71,10 +71,10 @@ typedef struct sModule Uint8 Flags; //!< Module Flags Uint16 Version; //!< Module Version in Major.Minor 8.8 form struct sModule *Next; //!< Next module in list (not to be touched by the driver) - char *Name; //!< Module Name/Identifier + const char *Name; //!< Module Name/Identifier int (*Init)(char **Arguments); //!< Module initialiser / entrypoint void (*Deinit)(void); //!< Cleanup Function - char **Dependencies; //!< NULL terminated list of dependencies + const char **Dependencies; //!< NULL terminated list of dependencies } PACKED tModule; /** diff --git a/Kernel/include/threads.h b/Kernel/include/threads.h index 0f164f8c..f53bbad2 100644 --- a/Kernel/include/threads.h +++ b/Kernel/include/threads.h @@ -116,9 +116,19 @@ extern void Threads_SetPriority(tThread *Thread, int Pri); extern int Threads_Wake(tThread *Thread); extern void Threads_Kill(tThread *Thread, int Status); extern void Threads_AddActive(tThread *Thread); +extern tThread *Threads_RemActive(void); extern tThread *Threads_GetNextToRun(int CPU, tThread *Last); +extern void Threads_SetFaultHandler(Uint Handler); + +extern int Threads_SetUID(Uint *Errno, tUID ID); +extern int Threads_SetGID(Uint *Errno, tUID ID); +extern int Threads_WaitTID(int TID, int *Status); + extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags); extern tThread *Threads_CloneThreadZero(void); +extern int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data); +extern int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer); + #endif diff --git a/Kernel/include/tpl_drv_common.h b/Kernel/include/tpl_drv_common.h index 632f3dcb..ebc9130d 100644 --- a/Kernel/include/tpl_drv_common.h +++ b/Kernel/include/tpl_drv_common.h @@ -111,7 +111,7 @@ enum eTplDrv_IOCtl { }\ case DRV_IOCTL_VERSION: LEAVE('x', (_version)); return (_version);\ case DRV_IOCTL_LOOKUP:{\ - int tmp = ModUtil_LookupString( (char**)(_ioctls), (char*)Data );\ + int tmp = ModUtil_LookupString( _ioctls, (const char*)Data );\ LEAVE('i', tmp);\ return tmp;\ } diff --git a/Kernel/include/vfs.h b/Kernel/include/vfs.h index c0e9705c..8618a048 100644 --- a/Kernel/include/vfs.h +++ b/Kernel/include/vfs.h @@ -265,7 +265,7 @@ typedef struct sVFS_Node typedef struct sVFS_Driver { //! \brief Unique Identifier for this filesystem type - char *Name; + const char *Name; //! \brief Flags applying to this driver Uint Flags; diff --git a/Kernel/lib.c b/Kernel/lib.c index 4c6ab188..3e57d00d 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -14,11 +14,14 @@ const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 3 #define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years // === PROTOTYPES === +#if 0 int atoi(const char *string); 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); int sprintf(char *__s, const char *__format, ...); +#endif int tolower(int c); +#if 0 int strucmp(const char *Str1, const char *Str2); char *strchr(const char *__s, int __c); int strpos(const char *Str, char Ch); @@ -33,7 +36,6 @@ char **str_split(const char *__str, char __ch); int strpos8(const char *str, Uint32 Search); int ReadUTF8(Uint8 *str, Uint32 *Val); int WriteUTF8(Uint8 *str, Uint32 Val); - int DivUp(int num, int dem); Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year); int rand(void); @@ -45,6 +47,7 @@ Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year); int ModUtil_SetIdent(char *Dest, char *Value); int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString); +#endif // === EXPORTS === EXPORT(atoi); @@ -198,7 +201,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) char c, pad = ' '; int minSize = 0, len; char tmpBuf[34]; // For Integers - char *p = NULL; + const char *p = NULL; int isLongLong = 0; Uint64 val; size_t pos = 0; @@ -222,8 +225,8 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) if(c == 'p') { Uint ptr = va_arg(args, Uint); PUTCH('*'); PUTCH('0'); PUTCH('x'); + itoa(tmpBuf, ptr, 16, BITS/4, '0'); p = tmpBuf; - itoa(p, ptr, 16, BITS/4, '0'); goto printString; } @@ -285,30 +288,30 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) PUTCH('-'); val = -(Sint32)val; } - itoa(p, val, 10, minSize, pad); + itoa(tmpBuf, val, 10, minSize, pad); goto printString; case 'u': GETVAL(); - itoa(p, val, 10, minSize, pad); + itoa(tmpBuf, val, 10, minSize, pad); goto printString; case 'X': if(BITS == 64) isLongLong = 1; // TODO: Handle non-x86 64-bit archs GETVAL(); - itoa(p, val, 16, minSize, pad); + itoa(tmpBuf, val, 16, minSize, pad); goto printString; case 'x': GETVAL(); - itoa(p, val, 16, minSize, pad); + itoa(tmpBuf, val, 16, minSize, pad); goto printString; case 'o': GETVAL(); - itoa(p, val, 8, minSize, pad); + itoa(tmpBuf, val, 8, minSize, pad); goto printString; case 'b': GETVAL(); - itoa(p, val, 2, minSize, pad); + itoa(tmpBuf, val, 2, minSize, pad); goto printString; case 'B': //Boolean @@ -418,10 +421,11 @@ int strpos(const char *Str, char Ch) * \fn Uint8 ByteSum(void *Ptr, int Size) * \brief Adds the bytes in a memory region and returns the sum */ -Uint8 ByteSum(void *Ptr, int Size) +Uint8 ByteSum(const void *Ptr, int Size) { Uint8 sum = 0; - while(Size--) sum += *(Uint8*)Ptr++; + const Uint8 *data = Ptr; + while(Size--) sum += *(data++); return sum; } @@ -593,7 +597,7 @@ int strpos8(const char *str, Uint32 Search) * \fn int ReadUTF8(Uint8 *str, Uint32 *Val) * \brief Read a UTF-8 character from a string */ -int ReadUTF8(Uint8 *str, Uint32 *Val) +int ReadUTF8(const Uint8 *str, Uint32 *Val) { *Val = 0xFFFD; // Assume invalid character @@ -756,7 +760,7 @@ int rand(void) /** * \brief Checks if a string resides fully in valid memory */ -int CheckString(char *String) +int CheckString(const char *String) { if( !MM_GetPhysAddr( (tVAddr)String ) ) return 0; @@ -792,7 +796,7 @@ int CheckString(char *String) /** * \brief Check if a sized memory region is valid memory */ -int CheckMem(void *Mem, int NumBytes) +int CheckMem(const void *Mem, int NumBytes) { tVAddr addr = (tVAddr)Mem; @@ -826,7 +830,7 @@ int CheckMem(void *Mem, int NumBytes) * \brief Search a string array for \a Needle * \note Helper function for eTplDrv_IOCtl::DRV_IOCTL_LOOKUP */ -int ModUtil_LookupString(char **Array, char *Needle) +int ModUtil_LookupString(const char **Array, const char *Needle) { int i; if( !CheckString(Needle) ) return -1; @@ -837,7 +841,7 @@ int ModUtil_LookupString(char **Array, char *Needle) return -1; } -int ModUtil_SetIdent(char *Dest, char *Value) +int ModUtil_SetIdent(char *Dest, const char *Value) { if( !CheckMem(Dest, 32) ) return -1; strncpy(Dest, Value, 32); diff --git a/Kernel/logging.c b/Kernel/logging.c index cb3c61cb..17888a71 100644 --- a/Kernel/logging.c +++ b/Kernel/logging.c @@ -47,15 +47,15 @@ typedef struct sLogList } tLogList; // === PROTOTYPES === -void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args); +void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args); static void Log_Int_PrintMessage(tLogEntry *Entry); -void Log_KernelPanic(char *Ident, char *Message, ...); -void Log_Panic(char *Ident, char *Message, ...); -void Log_Error(char *Ident, char *Message, ...); -void Log_Warning(char *Ident, char *Message, ...); -void Log_Notice(char *Ident, char *Message, ...); -void Log_Log(char *Ident, char *Message, ...); -void Log_Debug(char *Ident, char *Message, ...); +//void Log_KernelPanic(const char *Ident, const char *Message, ...); +//void Log_Panic(const char *Ident, const char *Message, ...); +//void Log_Error(const char *Ident, const char *Message, ...); +//void Log_Warning(const char *Ident, const char *Message, ...); +//void Log_Notice(const char *Ident, const char *Message, ...); +//void Log_Log(const char *Ident, const char *Message, ...); +//void Log_Debug(const char *Ident, const char *Message, ...); // === EXPORTS === EXPORT(Log_Panic); @@ -80,7 +80,7 @@ tLogList gLog_Levels[NUM_LOG_LEVELS]; /** * \brief Adds an event to the log */ -void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args) +void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args) { int len; tLogEntry *ent; @@ -166,7 +166,7 @@ void Log_Int_PrintMessage(tLogEntry *Entry) /** * \brief KERNEL PANIC!!!! */ -void Log_KernelPanic(char *Ident, char *Message, ...) +void Log_KernelPanic(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); @@ -177,7 +177,7 @@ void Log_KernelPanic(char *Ident, char *Message, ...) /** * \brief Panic Message - Driver Unrecoverable error */ -void Log_Panic(char *Ident, char *Message, ...) +void Log_Panic(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); @@ -188,7 +188,7 @@ void Log_Panic(char *Ident, char *Message, ...) /** * \brief Error Message - Recoverable Error */ -void Log_Error(char *Ident, char *Message, ...) +void Log_Error(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); @@ -199,7 +199,7 @@ void Log_Error(char *Ident, char *Message, ...) /** * \brief Warning Message - Something the user should know */ -void Log_Warning(char *Ident, char *Message, ...) +void Log_Warning(const char *Ident, const char *Message, ...) { va_list args; @@ -211,7 +211,7 @@ void Log_Warning(char *Ident, char *Message, ...) /** * \brief Notice Message - Something the user might like to know */ -void Log_Notice(char *Ident, char *Message, ...) +void Log_Notice(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); @@ -222,7 +222,7 @@ void Log_Notice(char *Ident, char *Message, ...) /** * \brief Log Message - Possibly useful information */ -void Log_Log(char *Ident, char *Message, ...) +void Log_Log(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); @@ -233,7 +233,7 @@ void Log_Log(char *Ident, char *Message, ...) /** * \brief Debug Message - Only a developer would want this info */ -void Log_Debug(char *Ident, char *Message, ...) +void Log_Debug(const char *Ident, const char *Message, ...) { va_list args; va_start(args, Message); diff --git a/Kernel/modules.c b/Kernel/modules.c index 58521baa..b2923f7c 100644 --- a/Kernel/modules.c +++ b/Kernel/modules.c @@ -10,12 +10,13 @@ #define USE_UDI 0 // === PROTOTYPES === - int Module_int_Initialise(tModule *Module, char *ArgString); + int Module_int_Initialise(tModule *Module, const char *ArgString); +void Modules_int_GetBuiltinArray(void); void Modules_LoadBuiltins(void); void Modules_SetBuiltinParams(char *Name, char *ArgString); - int Module_RegisterLoader(tModuleLoader *Loader); - int Module_LoadMem(void *Buffer, Uint Length, char *ArgString); - int Module_LoadFile(char *Path, char *ArgString); +// int Module_RegisterLoader(tModuleLoader *Loader); +// int Module_LoadMem(void *Buffer, Uint Length, char *ArgString); +// int Module_LoadFile(char *Path, char *ArgString); int Module_int_ResolveDeps(tModule *Info); int Module_IsLoaded(const char *Name); @@ -26,7 +27,7 @@ EXPORT(Module_RegisterLoader); #if USE_UDI extern int UDI_LoadDriver(void *Base); #endif -extern void StartupPrint(char *Str); +extern void StartupPrint(const char *Str); extern void gKernelModules; extern void gKernelModulesEnd; @@ -50,11 +51,11 @@ char **gasBuiltinModuleArgs; * \retval 0 Returned on success * \retval >0 Error code form the module's initialisation function */ -int Module_int_Initialise(tModule *Module, char *ArgString) +int Module_int_Initialise(tModule *Module, const char *ArgString) { int i, j; int ret; - char **deps; + const char **deps; char **args; tModule *mod; @@ -321,7 +322,7 @@ int Module_RegisterLoader(tModuleLoader *Loader) * \fn int Module_LoadMem(void *Buffer, Uint Length, char *ArgString) * \brief Load a module from a memory location */ -int Module_LoadMem(void *Buffer, Uint Length, char *ArgString) +int Module_LoadMem(void *Buffer, Uint Length, const char *ArgString) { char path[VFS_MEMPATH_SIZE]; @@ -331,10 +332,10 @@ int Module_LoadMem(void *Buffer, Uint Length, char *ArgString) } /** - * \fn int Module_LoadFile(char *Path, char *ArgString) + * \fn int Module_LoadFile(const char *Path, const char *ArgString) * \brief Load a module from a file */ -int Module_LoadFile(char *Path, char *ArgString) +int Module_LoadFile(const char *Path, const char *ArgString) { void *base; tModule *info; @@ -395,7 +396,7 @@ int Module_LoadFile(char *Path, char *ArgString) */ int Module_int_ResolveDeps(tModule *Info) { - char **names = Info->Dependencies; + const char **names = Info->Dependencies; // Walk dependencies array for( ; *names; names++ ) diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index 95ad2e5f..f930cdd4 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -19,17 +19,11 @@ if(!(v)||!Syscall_ValidString((Uint)(v))){ret=-1;err=-EINVAL;break;} // === IMPORTS === -extern int Proc_Clone(Uint *Err, Uint Flags); -extern int Threads_WaitTID(int TID, int *status); -extern Uint Proc_SendMessage(Uint *Err, Uint Dest, Uint Length, void *Data); -extern int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer); extern int Proc_Execve(char *File, char **ArgV, char **EnvP); extern Uint Binary_Load(char *file, Uint *entryPoint); -extern int Threads_SetUID(Uint *errno, tUID ID); -extern int Threads_SetGID(Uint *errno, tGID ID); -extern int Threads_SetFaultHandler(Uint Handler); // === PROTOTYPES === +void SyscallHandler(tSyscallRegs *Regs); int Syscall_ValidString(Uint Addr); int Syscall_Valid(int Size, Uint Addr); diff --git a/Kernel/system.c b/Kernel/system.c index da1dc92f..8b457b49 100644 --- a/Kernel/system.c +++ b/Kernel/system.c @@ -23,7 +23,7 @@ typedef struct } tConfigFile; typedef struct { - char *Name; // Name + const char *Name; // Name int MinArgs; // Minimum number of arguments int MaxArgs; // Maximum number of arguments Uint IntArgs; // Bitmap of arguments that should be treated as integers @@ -35,7 +35,7 @@ typedef struct extern void Arch_LoadBootModules(void); extern int Modules_LoadBuiltins(void); extern void Modules_SetBuiltinParams(char *Name, char *ArgString); -extern void Debug_SetKTerminal(char *File); +extern void Debug_SetKTerminal(const char *File); // === PROTOTYPES === void System_Init(char *Commandline); @@ -64,7 +64,7 @@ const tConfigCommand caConfigCommands[] = { #define NUM_CONFIG_COMMANDS (sizeof(caConfigCommands)/sizeof(caConfigCommands[0])) // === GLOBALS === -char *gsConfigScript = "/Acess/Conf/BootConf.cfg"; +const char *gsConfigScript = "/Acess/Conf/BootConf.cfg"; char *argv[32]; int argc; diff --git a/Kernel/threads.c b/Kernel/threads.c index 2043bc42..dc79908d 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -32,22 +32,24 @@ const enum eConfigTypes cCONFIG_TYPES[] = { // === IMPORTS === extern void ArchThreads_Init(void); -extern void Proc_Start(void); -extern tThread *Proc_GetCurThread(void); -extern int Proc_Clone(Uint *Err, Uint Flags); extern void Proc_CallFaultHandler(tThread *Thread); extern int GetCPUNum(void); // === PROTOTYPES === void Threads_Init(void); +#if 0 int Threads_SetName(const char *NewName); +#endif char *Threads_GetName(int ID); +#if 0 void Threads_SetPriority(tThread *Thread, int Pri); tThread *Threads_CloneTCB(Uint *Err, Uint Flags); int Threads_WaitTID(int TID, int *status); tThread *Threads_GetThread(Uint TID); +#endif void Threads_AddToDelete(tThread *Thread); tThread *Threads_int_DelFromQueue(tThread **List, tThread *Thread); +#if 0 void Threads_Exit(int TID, int Status); void Threads_Kill(tThread *Thread, int Status); void Threads_Yield(void); @@ -55,25 +57,32 @@ void Threads_Sleep(void); int Threads_Wake(tThread *Thread); void Threads_AddActive(tThread *Thread); tThread *Threads_RemActive(void); +#endif +void Threads_Fault(int Num); +void Threads_SegFault(tVAddr Addr); +#if 0 int Threads_GetPID(void); int Threads_GetTID(void); tUID Threads_GetUID(void); - int Threads_SetUID(Uint *Errno, tUID ID); tGID Threads_GetGID(void); + int Threads_SetUID(Uint *Errno, tUID ID); int Threads_SetGID(Uint *Errno, tUID ID); +#endif void Threads_Dump(void); void Threads_DumpActive(void); +#if 0 int Mutex_Acquire(tMutex *Mutex); void Mutex_Release(tMutex *Mutex); int Mutex_IsLocked(tMutex *Mutex); +#endif // === GLOBALS === // -- Core Thread -- // Only used for the core kernel tThread gThreadZero = { Status: THREAD_STAT_ACTIVE, // Status - ThreadName: "ThreadZero", // Name + ThreadName: (char*)"ThreadZero", // Name Quantum: DEFAULT_QUANTUM, // Default Quantum Remaining: DEFAULT_QUANTUM, // Current Quantum Priority: DEFAULT_PRIORITY // Number of tickets @@ -887,6 +896,17 @@ void Threads_Fault(int Num) Proc_CallFaultHandler(thread); } +/** + * \fn void Threads_SegFault(tVAddr Addr) + * \brief Called when a Segment Fault occurs + */ +void Threads_SegFault(tVAddr Addr) +{ + Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr); + Threads_Fault( 1 ); + //Threads_Exit( 0, -1 ); +} + // --- Process Structure Access Functions --- tPID Threads_GetPID(void) { @@ -1220,17 +1240,6 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last) return thread; } -/** - * \fn void Threads_SegFault(tVAddr Addr) - * \brief Called when a Segment Fault occurs - */ -void Threads_SegFault(tVAddr Addr) -{ - Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr); - Threads_Fault( 1 ); - //Threads_Exit( 0, -1 ); -} - /** * \brief Acquire a heavy mutex * \param Mutex Mutex to acquire diff --git a/Kernel/time.c b/Kernel/time.c index e64d0b77..54ef08fc 100644 --- a/Kernel/time.c +++ b/Kernel/time.c @@ -17,7 +17,6 @@ typedef struct sTimer { } tTimer; // === PROTOTYPES === -Sint64 now(void); void Timer_CallTimers(void); // === GLOBALS === diff --git a/Kernel/vfs/dir.c b/Kernel/vfs/dir.c index 0fa213d1..43cc0b53 100644 --- a/Kernel/vfs/dir.c +++ b/Kernel/vfs/dir.c @@ -11,7 +11,9 @@ extern tVFS_Mount *gRootMount; // === PROTOTYPES === +#if 0 int VFS_MkDir(const char *Path); +#endif int VFS_MkNod(const char *Path, Uint Flags); // === CODE === diff --git a/Kernel/vfs/fs/devfs.c b/Kernel/vfs/fs/devfs.c index be5a655a..162f1113 100644 --- a/Kernel/vfs/fs/devfs.c +++ b/Kernel/vfs/fs/devfs.c @@ -8,8 +8,10 @@ #include // === PROTOTYPES === +#if 0 int DevFS_AddDevice(tDevFS_Driver *Device); void DevFS_DelDevice(tDevFS_Driver *Device); +#endif tVFS_Node *DevFS_InitDevice(const char *Device, const char **Options); char *DevFS_ReadDir(tVFS_Node *Node, int Pos); tVFS_Node *DevFS_FindDir(tVFS_Node *Node, const char *Name); diff --git a/Kernel/vfs/handle.c b/Kernel/vfs/handle.c index 21a98e05..ecf3f5c0 100644 --- a/Kernel/vfs/handle.c +++ b/Kernel/vfs/handle.c @@ -13,7 +13,9 @@ #define MAX_KERNEL_FILES 128 // === PROTOTYPES === +#if 0 tVFS_Handle *VFS_GetHandle(int FD); +#endif int VFS_AllocHandle(int FD, tVFS_Node *Node, int Mode); // === GLOBALS === diff --git a/Kernel/vfs/main.c b/Kernel/vfs/main.c index dc43fbf0..c0c37e1d 100644 --- a/Kernel/vfs/main.c +++ b/Kernel/vfs/main.c @@ -13,11 +13,13 @@ extern tVFS_Driver gRootFS_Info; extern tVFS_Driver gDevFS_Info; // === PROTOTYPES === +#if 0 int VFS_Init(void); char *VFS_GetTruePath(const char *Path); void VFS_GetMemPath(char *Dest, void *Base, Uint Length); tVFS_Driver *VFS_GetFSByName(const char *Name); int VFS_AddDriver(tVFS_Driver *Info); +#endif void VFS_UpdateDriverFile(void); // === EXPORTS === diff --git a/Kernel/vfs/memfile.c b/Kernel/vfs/memfile.c index 941fcfe2..c197626f 100644 --- a/Kernel/vfs/memfile.c +++ b/Kernel/vfs/memfile.c @@ -110,7 +110,7 @@ Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf Length = Node->Size - Offset; // Copy Data - memcpy(Buffer, Node->ImplPtr+Offset, Length); + memcpy(Buffer, (Uint8*)Node->ImplPtr + Offset, Length); return Length; } @@ -132,7 +132,7 @@ Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Bu Length = Node->Size - Offset; // Copy Data - memcpy(Node->ImplPtr+Offset, Buffer, Length); + memcpy((Uint8*)Node->ImplPtr + Offset, Buffer, Length); return Length; } diff --git a/Kernel/vfs/mount.c b/Kernel/vfs/mount.c index d0d7290c..13c1fb39 100644 --- a/Kernel/vfs/mount.c +++ b/Kernel/vfs/mount.c @@ -11,7 +11,9 @@ extern int giVFS_MountFileID; extern char *gsVFS_MountFile; // === PROTOTYPES === +#if 0 int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options); +#endif void VFS_UpdateMountFile(void); // === GLOBALS === diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c index 51d7885e..01d73d66 100644 --- a/Kernel/vfs/open.c +++ b/Kernel/vfs/open.c @@ -15,8 +15,6 @@ // === IMPORTS === extern tVFS_Node gVFS_MemRoot; extern tVFS_Mount *gVFS_RootMount; - -extern tVFS_Handle *VFS_GetHandle(int FD); extern int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode); // === CODE === @@ -32,9 +30,9 @@ char *VFS_GetAbsPath(const char *Path) char *tmpStr; int iPos = 0; int iPos2 = 0; - char *chroot = CFGPTR(CFG_VFS_CHROOT); + const char *chroot = CFGPTR(CFG_VFS_CHROOT); int chrootLen; - char *cwd = CFGPTR(CFG_VFS_CWD); + const char *cwd = CFGPTR(CFG_VFS_CWD); int cwdLen; ENTER("sPath", Path); diff --git a/Modules/IPStack/interface.c b/Modules/IPStack/interface.c index fc79e9ef..fc7db903 100644 --- a/Modules/IPStack/interface.c +++ b/Modules/IPStack/interface.c @@ -192,28 +192,12 @@ int IPStack_Root_IOCtl(tVFS_Node *Node, int ID, void *Data) switch(ID) { // --- Standard IOCtls (0-3) --- - case DRV_IOCTL_TYPE: - LEAVE('i', DRV_TYPE_MISC); - return DRV_TYPE_MISC; - - case DRV_IOCTL_IDENT: - tmp = ModUtil_SetIdent(Data, "IPStack"); - LEAVE('i', 1); - return 1; - - case DRV_IOCTL_VERSION: - LEAVE('x', VERSION); - return VERSION; - - case DRV_IOCTL_LOOKUP: - tmp = ModUtil_LookupString( (char**)casIOCtls_Root, (char*)Data ); - LEAVE('i', tmp); - return tmp; + BASE_IOCTLS(DRV_TYPE_MISC, "IPStack", VERSION, casIOCtls_Root) - /* - * add_interface - * - Adds a new IP interface and binds it to a device - */ + /* + * add_interface + * - Adds a new IP interface and binds it to a device + */ case 4: if( Threads_GetUID() != 0 ) LEAVE_RET('i', -1); if( !CheckString( Data ) ) LEAVE_RET('i', -1); @@ -384,23 +368,7 @@ int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data) switch(ID) { // --- Standard IOCtls (0-3) --- - case DRV_IOCTL_TYPE: - LEAVE('i', DRV_TYPE_MISC); - return DRV_TYPE_MISC; - - case DRV_IOCTL_IDENT: - tmp = ModUtil_SetIdent(Data, STR(IDENT)); - LEAVE('i', 1); - return 1; - - case DRV_IOCTL_VERSION: - LEAVE('x', VERSION); - return VERSION; - - case DRV_IOCTL_LOOKUP: - tmp = ModUtil_LookupString( (char**)casIOCtls_Iface, (char*)Data ); - LEAVE('i', tmp); - return tmp; + BASE_IOCTLS(DRV_TYPE_MISC, "IPStack", VERSION, casIOCtls_Iface) /* * getset_type diff --git a/Modules/IPStack/routing.c b/Modules/IPStack/routing.c index 26817b65..6b8aa1a1 100644 --- a/Modules/IPStack/routing.c +++ b/Modules/IPStack/routing.c @@ -104,23 +104,7 @@ int IPStack_RouteDir_IOCtl(tVFS_Node *Node, int ID, void *Data) switch(ID) { // --- Standard IOCtls (0-3) --- - case DRV_IOCTL_TYPE: - LEAVE('i', DRV_TYPE_MISC); - return DRV_TYPE_MISC; - - case DRV_IOCTL_IDENT: - tmp = ModUtil_SetIdent(Data, STR(IDENT)); - LEAVE('i', 1); - return 1; - - case DRV_IOCTL_VERSION: - LEAVE('x', VERSION); - return VERSION; - - case DRV_IOCTL_LOOKUP: - tmp = ModUtil_LookupString( (char**)casIOCtls_RouteDir, (char*)Data ); - LEAVE('i', tmp); - return tmp; + BASE_IOCTLS(DRV_TYPE_MISC, STR(IDENT), VERSION, casIOCtls_RouteDir) case 4: // Add Route if( !CheckString(Data) ) LEAVE_RET('i', -1); @@ -371,7 +355,6 @@ static const char *casIOCtls_Route[] = { */ int IPStack_Route_IOCtl(tVFS_Node *Node, int ID, void *Data) { - int tmp; int *iData = Data; tRoute *rt = Node->ImplPtr; int addrSize = IPStack_GetAddressSize(rt->AddressType); @@ -379,23 +362,7 @@ int IPStack_Route_IOCtl(tVFS_Node *Node, int ID, void *Data) switch(ID) { // --- Standard IOCtls (0-3) --- - case DRV_IOCTL_TYPE: - LEAVE('i', DRV_TYPE_MISC); - return DRV_TYPE_MISC; - - case DRV_IOCTL_IDENT: - tmp = ModUtil_SetIdent(Data, STR(IDENT)); - LEAVE('i', 1); - return 1; - - case DRV_IOCTL_VERSION: - LEAVE('x', VERSION); - return VERSION; - - case DRV_IOCTL_LOOKUP: - tmp = ModUtil_LookupString( (char**)casIOCtls_Route, (char*)Data ); - LEAVE('i', tmp); - return tmp; + BASE_IOCTLS(DRV_TYPE_MISC, STR(IDENT), VERSION, casIOCtls_Route) // Get address type case 4: diff --git a/Modules/Storage/ATA/io.c b/Modules/Storage/ATA/io.c index 0f442acd..44f774a2 100644 --- a/Modules/Storage/ATA/io.c +++ b/Modules/Storage/ATA/io.c @@ -332,7 +332,10 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer) // Wait for transfer to complete timeoutTime = now() + ATA_TIMEOUT; while( gaATA_IRQs[cont] == 0 && now() < timeoutTime) - Threads_Yield(); + { + HALT(); +// Threads_Yield(); + } // Complete Transfer ATA_int_BusMasterWriteByte( cont << 3, 8 ); // Read and stop @@ -429,7 +432,10 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer) // Wait for transfer to complete timeoutTime = now() + ATA_TIMEOUT; while( gaATA_IRQs[cont] == 0 && now() < timeoutTime) - Threads_Yield(); + { +// Threads_Yield(); + HALT(); + } // Complete Transfer ATA_int_BusMasterWriteByte( cont << 3, 0 ); // Write and stop diff --git a/Modules/Storage/FDD/fdd.c b/Modules/Storage/FDD/fdd.c index bd117e1d..cbd7844f 100644 --- a/Modules/Storage/FDD/fdd.c +++ b/Modules/Storage/FDD/fdd.c @@ -676,22 +676,19 @@ void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl) */ void FDD_int_SendByte(int base, char byte) { - volatile int state; - int timeout = 128; - for( ; timeout--; ) + int timeout = 128; + + while( (inb(base + PORT_MAINSTATUS) & 0xC0) != 0x80 && timeout-- ) + inb(0x80); //Delay + + if( timeout >= 0 ) { - state = inb(base + PORT_MAINSTATUS); - if ((state & 0xC0) == 0x80) - { - outb(base + PORT_DATA, byte); - return; - } - inb(0x80); //Delay + outb(base + PORT_DATA, byte); + } + else + { + Log_Warning("FDD", "FDD_int_SendByte: Timeout sending byte 0x%x to base 0x%x\n", byte, base); } - - #if WARN - Warning("FDD_int_SendByte - Timeout sending byte 0x%x to base 0x%x\n", byte, base); - #endif } /** @@ -700,16 +697,20 @@ void FDD_int_SendByte(int base, char byte) */ int FDD_int_GetByte(int base) { - volatile int state; - int timeout; - for( timeout = 128; timeout--; ) + int timeout = 128; + + while( (inb(base + PORT_MAINSTATUS) & 0xd0) != 0xd0 && timeout-- ) + inb(0x80); //Delay + + if( timeout >= 0 ) { - state = inb((base + PORT_MAINSTATUS)); - if ((state & 0xd0) == 0xd0) - return inb(base + PORT_DATA); - inb(0x80); + return inb(base + PORT_DATA); + } + else + { + Log_Warning("FDD", "FDD_int_GetByte: Timeout reading byte from base 0x%x\n", base); + return -1; } - return -1; } /**