From 77ed20ce9d7e25654215980d0f89e63b8dd366f0 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 10 Nov 2009 13:14:31 +0800 Subject: [PATCH] General Cleanup, Implemented DMA Allocation - Cleaned up debugging and added notice of loading a module - Added doxygen comments to common.h - Fixed the dynamic modules not loading due to a buggy linker script - Added MM_AllocDMA to allow memory of a specific bit depth to be allocated - Various bugfixes and export adds --- Kernel/arch/x86/include/arch.h | 6 + Kernel/arch/x86/include/mm_virt.h | 12 +- Kernel/arch/x86/mm_phys.c | 44 +++++- Kernel/arch/x86/mm_virt.c | 147 ++++++++++++++----- Kernel/binary.c | 2 +- Kernel/drv/pci.c | 5 +- Kernel/drv/vterm.c | 4 + Kernel/include/common.h | 229 ++++++++++++++++++++++++++++-- Kernel/lib.c | 22 +-- Kernel/modules.c | 6 + Kernel/vfs/acls.c | 8 ++ Kernel/vfs/dir.c | 2 +- Modules/Makefile.tpl | 3 +- 13 files changed, 415 insertions(+), 75 deletions(-) diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 6a7ab45e..bc4e0af5 100644 --- a/Kernel/arch/x86/include/arch.h +++ b/Kernel/arch/x86/include/arch.h @@ -44,6 +44,12 @@ # define MAX_CPUS 1 #endif +#if USE_PAE +# define PHYS_BITS 48 +#else +# define PHYS_BITS 32 +#endif + // === MACROS === #define LOCK(lockptr) do {int v=1;\ while(v)__asm__ __volatile__("lock xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));}while(0) diff --git a/Kernel/arch/x86/include/mm_virt.h b/Kernel/arch/x86/include/mm_virt.h index d3260fe0..2dc3b30e 100644 --- a/Kernel/arch/x86/include/mm_virt.h +++ b/Kernel/arch/x86/include/mm_virt.h @@ -7,11 +7,11 @@ // === FUNCTIONS === extern void MM_SetCR3(Uint32 CR3); -extern tPAddr MM_Allocate(Uint VAddr); -extern void MM_Deallocate(Uint VAddr); -extern int MM_Map(Uint VAddr, tPAddr PAddr); -extern Uint MM_Clone(); -extern Uint MM_NewKStack(); -extern Uint MM_NewWorkerStack(); +extern tPAddr MM_Allocate(tVAddr VAddr); +extern void MM_Deallocate(tVAddr VAddr); +extern int MM_Map(tVAddr VAddr, tPAddr PAddr); +extern tVAddr MM_Clone(); +extern tVAddr MM_NewKStack(); +extern tVAddr MM_NewWorkerStack(); #endif diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index 82c45c37..1b79650b 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -102,7 +102,6 @@ tPAddr MM_AllocPhys() } for(b=0;gaSuperBitmap[a]&(1<0;c++); // Mark page used if(gaPageReferences) @@ -117,8 +116,47 @@ tPAddr MM_AllocPhys() // Release Spinlock RELEASE( &giPhysAlloc ); - //LOG("Allocated 0x%x\n", ret); - //LOG("ret = %x", ret); + + return ret; +} + +/** + * \fn tPAddr MM_AllocPhysRange(int Pages) + * \brief Allocate a range of physical pages + * \param Pages Number of pages to allocate + */ +tPAddr MM_AllocPhysRange(int Pages) +{ + int num = giPageCount / 32 / 32; + int a, b, c; + Uint32 ret; + + LOCK( &giPhysAlloc ); + + // Find free page + for(a=0;gaSuperBitmap[a]==-1&&a> 22 ] == 0 ) { Warning("MM_Deallocate - Directory not mapped"); @@ -315,10 +315,10 @@ void MM_Deallocate(Uint VAddr) } /** - * \fn tPAddr MM_GetPhysAddr(Uint Addr) + * \fn tPAddr MM_GetPhysAddr(tVAddr Addr) * \brief Checks if the passed address is accesable */ -tPAddr MM_GetPhysAddr(Uint Addr) +tPAddr MM_GetPhysAddr(tVAddr Addr) { if( !(gaPageDir[Addr >> 22] & 1) ) return 0; @@ -328,19 +328,19 @@ tPAddr MM_GetPhysAddr(Uint Addr) } /** - * \fn void MM_SetCR3(Uint CR3) + * \fn void MM_SetCR3(tPAddr CR3) * \brief Sets the current process space */ -void MM_SetCR3(Uint CR3) +void MM_SetCR3(tPAddr CR3) { __asm__ __volatile__ ("mov %0, %%cr3"::"r"(CR3)); } /** - * \fn int MM_Map(Uint VAddr, tPAddr PAddr) + * \fn int MM_Map(tVAddr VAddr, tPAddr PAddr) * \brief Map a physical page to a virtual one */ -int MM_Map(Uint VAddr, tPAddr PAddr) +int MM_Map(tVAddr VAddr, tPAddr PAddr) { //ENTER("xVAddr xPAddr", VAddr, PAddr); // Sanity check @@ -390,10 +390,10 @@ int MM_Map(Uint VAddr, tPAddr PAddr) } /** - * \fn Uint MM_ClearUser() + * \fn tVAddr MM_ClearUser() * \brief Clear user's address space */ -Uint MM_ClearUser() +tVAddr MM_ClearUser() { Uint i, j; @@ -424,15 +424,15 @@ Uint MM_ClearUser() } /** - * \fn Uint MM_Clone() + * \fn tPAddr MM_Clone() * \brief Clone the current address space */ -Uint MM_Clone() +tPAddr MM_Clone() { Uint i, j; - Uint ret; + tVAddr ret; Uint page = 0; - Uint kStackBase = Proc_GetCurThread()->KernelStack - KERNEL_STACK_SIZE; + tVAddr kStackBase = Proc_GetCurThread()->KernelStack - KERNEL_STACK_SIZE; void *tmp; LOCK( &gilTempFractal ); @@ -550,12 +550,12 @@ Uint MM_Clone() } /** - * \fn Uint MM_NewKStack() + * \fn tVAddr MM_NewKStack() * \brief Create a new kernel stack */ -Uint MM_NewKStack() +tVAddr MM_NewKStack() { - Uint base = KERNEL_STACKS; + tVAddr base = KERNEL_STACKS; Uint i; for(;base> 22] & 1) ) return ; @@ -703,10 +703,10 @@ void MM_SetFlags(Uint VAddr, Uint Flags, Uint Mask) } /** - * \fn tPAddr MM_DuplicatePage(Uint VAddr) + * \fn tPAddr MM_DuplicatePage(tVAddr VAddr) * \brief Duplicates a virtual page to a physical one */ -tPAddr MM_DuplicatePage(Uint VAddr) +tPAddr MM_DuplicatePage(tVAddr VAddr) { tPAddr ret; Uint temp; @@ -744,7 +744,7 @@ tPAddr MM_DuplicatePage(Uint VAddr) * \brief Create a temporary memory mapping * \todo Show Luigi Barone (C Lecturer) and see what he thinks */ -Uint MM_MapTemp(tPAddr PAddr) +tVAddr MM_MapTemp(tPAddr PAddr) { int i; @@ -775,10 +775,10 @@ Uint MM_MapTemp(tPAddr PAddr) } /** - * \fn void MM_FreeTemp(Uint PAddr) + * \fn void MM_FreeTemp(tVAddr PAddr) * \brief Free's a temp mapping */ -void MM_FreeTemp(Uint VAddr) +void MM_FreeTemp(tVAddr VAddr) { int i = VAddr >> 12; //ENTER("xVAddr", VAddr); @@ -790,10 +790,10 @@ void MM_FreeTemp(Uint VAddr) } /** - * \fn Uint MM_MapHWPage(tPAddr PAddr, Uint Number) + * \fn tVAddr MM_MapHWPage(tPAddr PAddr, Uint Number) * \brief Allocates a contigous number of pages */ -Uint MM_MapHWPage(tPAddr PAddr, Uint Number) +tVAddr MM_MapHWPage(tPAddr PAddr, Uint Number) { int i, j; @@ -828,10 +828,82 @@ Uint MM_MapHWPage(tPAddr PAddr, Uint Number) } /** - * \fn void MM_UnmapHWPage(Uint VAddr, Uint Number) + * \fn tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) + * \brief Allocates DMA physical memory + * \param Pages Number of pages required + * \param MaxBits Maximum number of bits the physical address can have + * \param PhysAddr Pointer to the location to place the physical address allocated + * \return Virtual address allocate + */ +tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) +{ + tPAddr maxCheck = (1 << MaxBits); + tPAddr phys; + tVAddr ret; + + ENTER("iPages iMaxBits pPhysAddr", Pages, MaxBits, PhysAddr); + + // Sanity Check + if(MaxBits < 12 || !PhysAddr) { + LEAVE('i', 0); + return 0; + } + + // Bound + if(MaxBits >= PHYS_BITS) maxCheck = -1; + + // Fast Allocate + if(Pages == 1 && MaxBits >= PHYS_BITS) + { + phys = MM_AllocPhys(); + *PhysAddr = phys; + ret = MM_MapHWPage(phys, 1); + if(ret == 0) { + MM_DerefPhys(phys); + LEAVE('i', 0); + return 0; + } + LEAVE('x', ret); + return ret; + } + + // Slow Allocate + phys = MM_AllocPhysRange(Pages); + // - Was it allocated? + if(phys == 0) { + LEAVE('i', 0); + return 0; + } + // - Check if the memory is OK + if(phys + (Pages-1)*0x1000 > maxCheck) + { + // Deallocate and return 0 + for(;Pages--;phys+=0x1000) + MM_DerefPhys(phys); + LEAVE('i', 0); + return 0; + } + + // Allocated successfully, now map + ret = MM_MapHWPage(phys, Pages); + if( ret == 0 ) { + // If it didn't map, free then return 0 + for(;Pages--;phys+=0x1000) + MM_DerefPhys(phys); + LEAVE('i', 0); + return 0; + } + + *PhysAddr = phys; + LEAVE('x', ret); + return ret; +} + +/** + * \fn void MM_UnmapHWPage(tVAddr VAddr, Uint Number) * \brief Unmap a hardware page */ -void MM_UnmapHWPage(Uint VAddr, Uint Number) +void MM_UnmapHWPage(tVAddr VAddr, Uint Number) { int i, j; // Sanity Check @@ -855,4 +927,5 @@ EXPORT(MM_GetPhysAddr); EXPORT(MM_Map); //EXPORT(MM_Unmap); EXPORT(MM_MapHWPage); +EXPORT(MM_AllocDMA); EXPORT(MM_UnmapHWPage); diff --git a/Kernel/binary.c b/Kernel/binary.c index dae3cfaa..2237d1b1 100644 --- a/Kernel/binary.c +++ b/Kernel/binary.c @@ -725,7 +725,7 @@ Uint Binary_Relocate(void *Base) } Warning("[BIN ] 0x%x is an unknown file type. (0x%x 0x%x 0x%x 0x%x)", - Base, ident&0xFF, ident>>8, ident>>16, ident>>24); + Base, ident&0xFF, (ident>>8)&0xFF, (ident>>16)&0xFF, (ident>>24)&0xFF); return 0; } diff --git a/Kernel/drv/pci.c b/Kernel/drv/pci.c index 43d6d544..b256d369 100644 --- a/Kernel/drv/pci.c +++ b/Kernel/drv/pci.c @@ -553,9 +553,10 @@ Uint8 PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) // === EXPORTS === -/* +//* EXPORT(PCI_CountDevices); EXPORT(PCI_GetDevice); +EXPORT(PCI_GetDeviceByClass); EXPORT(PCI_AssignPort); EXPORT(PCI_GetIRQ); -*/ +//*/ diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index 1dde000a..09f85ff6 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -494,6 +494,10 @@ void VT_KBCallBack(Uint32 Codepoint) case KEY_F10: VT_SetTerminal(9); return; case KEY_F11: VT_SetTerminal(10); return; case KEY_F12: VT_SetTerminal(11); return; + case KEY_PGUP: + break; + case KEY_PGDOWN: + break; } } diff --git a/Kernel/include/common.h b/Kernel/include/common.h index 398724da..154ad0d5 100644 --- a/Kernel/include/common.h +++ b/Kernel/include/common.h @@ -10,6 +10,23 @@ #include #include +// --- Helper Macros --- +/** + * \name Helper Macros + * \{ + */ +#define CONCAT(x,y) x ## y +#define EXPAND_CONCAT(x,y) CONCAT(x,y) +#define STR(x) #x +#define EXPAND_STR(x) STR(x) +/** + * \} + */ + +/** + * \name Per-Process Configuration Settings + * \{ + */ enum eConfigTypes { CFGT_NULL, CFGT_INT, @@ -23,28 +40,54 @@ enum eConfigs { }; #define CFGINT(id) (*Threads_GetCfgPtr(id)) #define CFGPTR(id) (*(void**)Threads_GetCfgPtr(id)) +/** + * \} + */ // === CONSTANTS === // --- Memory Flags -- +/** + * \name Memory Flags + * \{ + * \todo Move to mm_virt.h + */ #define MM_PFLAG_RO 0x01 // Writes disallowed #define MM_PFLAG_EXEC 0x02 // Allow execution #define MM_PFLAG_NOPAGE 0x04 // Prevent from being paged out #define MM_PFLAG_COW 0x08 // Copy-On-Write #define MM_PFLAG_KERNEL 0x10 // Kernel-Only (Ring0) +/** + * \} + */ // === Kernel Export Macros === +/** + * \name Kernel Function + * \{ + */ typedef struct sKernelSymbol { char *Name; unsigned int Value; } tKernelSymbol; #define EXPORT(_name) tKernelSymbol _kexp_##_name __attribute__((section ("KEXPORT"),unused))={#_name, (Uint)_name} +#define EXPORTV(_name) tKernelSymbol _kexp_##_name __attribute__((section ("KEXPORT"),unused))={#_name, (Uint)&_name} #define EXPORTAS(_sym,_name) tKernelSymbol _kexp_##_name __attribute__((section ("KEXPORT"),unused))={#_name, (Uint)_sym} +/** + * \} + */ // === FUNCTIONS === // --- Core --- extern void System_Init(char *ArgString); + +// --- IRQs --- extern int IRQ_AddHandler(int Num, void (*Callback)(int)); + // --- Debug --- +/** + * \name Debugging and Errors + * \{ + */ extern void Panic(char *Msg, ...); extern void Warning(char *Msg, ...); extern void Log(char *Fmt, ...); @@ -63,7 +106,15 @@ extern void Debug_HexDump(char *Header, void *Data, Uint Length); # define LOG(...) # define LEAVE(...) #endif +/** + * \} + */ + // --- IO --- +/** + * \name I/O Memory Access + * \{ + */ extern void outb(Uint16 Port, Uint8 Data); extern void outw(Uint16 Port, Uint16 Data); extern void outd(Uint16 Port, Uint32 Data); @@ -72,58 +123,204 @@ extern Uint8 inb(Uint16 Port); extern Uint16 inw(Uint16 Port); extern Uint32 ind(Uint16 Port); extern Uint64 inq(Uint16 Port); -// --- Memory --- -extern tPAddr MM_Allocate(Uint VAddr); -extern void MM_Deallocate(Uint VAddr); //!< Deallocate a page -extern int MM_Map(Uint VAddr, tPAddr PAddr); //!< Map a page -extern tPAddr MM_GetPhysAddr(Uint VAddr); //!< Get the physical address of a page -extern int MM_IsUser(Uint VAddr, int Length); //!< Checks if a memory address is valid user memory -extern void MM_SetFlags(Uint VAddr, Uint Flags, Uint Mask); -extern Uint MM_MapTemp(tPAddr PAddr); -extern void MM_FreeTemp(Uint PAddr); -extern Uint MM_MapHWPage(tPAddr PAddr, Uint Number); -extern void MM_UnmapHWPage(Uint VAddr, Uint Number); +/** + * \} + */ + +// --- Memory Management --- +/** + * \name Memory Management + * \{ + * \todo Move to mm_virt.h + */ +/** + * \brief Allocate a physical page at \a VAddr + * \param VAddr Virtual Address to allocate at + * \return Physical address allocated + */ +extern tPAddr MM_Allocate(tVAddr VAddr); +/** + * \brief Deallocate a page + * \param VAddr Virtual address to unmap + */ +extern void MM_Deallocate(tVAddr VAddr); +/** + * \brief Map a physical page at \a PAddr to \a VAddr + * \param VAddr Target virtual address + * \param PAddr Physical address to map + * \return Boolean Success + */ +extern int MM_Map(tVAddr VAddr, tPAddr PAddr); +/** + * \brief Get the physical address of \a VAddr + * \param VAddr Address of the page to get the physical address of + * \return Physical page mapped at \A VAddr + */ +extern tPAddr MM_GetPhysAddr(tVAddr VAddr); +/** + * \brief Checks is a memory range is user accessable + * \param VAddr Base address to check + * \param Length Number of bytes to check + * \return 1 if the memory is all user-accessable, 0 otherwise + */ +extern int MM_IsUser(tVAddr VAddr, int Length); +/** + * \brief Set the access flags on a page + * \param VAddr Virtual address of the page + * \param Flags New flags value + * \param Mask Flags to set + */ +extern void MM_SetFlags(tVAddr VAddr, Uint Flags, Uint Mask); +/** + * \brief Temporarily map a page into the address space + * \param PAddr Physical addres to map + * \return Virtual address of page in memory + * \note There is only a limited ammount of slots avaliable + */ +extern tVAddr MM_MapTemp(tPAddr PAddr); +/** + * \brief Free a temporarily mapped page + * \param VAddr Allocate virtual addres of page + */ +extern void MM_FreeTemp(tVAddr VAddr); +/** + * \brief Map a physcal address range into the virtual address space + * \param PAddr Physical address to map in + * \param Number Number of pages to map + */ +extern tVAddr MM_MapHWPage(tPAddr PAddr, Uint Number); +/** + * \brief Allocates DMA physical memory + * \param Pages Number of pages required + * \param MaxBits Maximum number of bits the physical address can have + * \param PhysAddr Pointer to the location to place the physical address allocated + * \return Virtual address allocate + */ +extern tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr); +/** + * \brief Unmaps an allocated hardware range + * \param VAddr Virtual address allocate by ::MM_MapHWPage or ::MM_AllocDMA + * \param Number Number of pages to free + */ +extern void MM_UnmapHWPage(tVAddr VAddr, Uint Number); +/** + * \brief Allocate a single physical page + * \return Physical address allocated + */ extern tPAddr MM_AllocPhys(); -extern void MM_RefPhys(tPAddr Addr); -extern void MM_DerefPhys(tPAddr Addr); +/** + * \brief Allocate a contiguous range of physical pages + * \param Pages Number of pages to allocate + * \return First physical address allocated + */ +extern tPAddr MM_AllocPhysRange(int Pages); +/** + * \brief Reference a physical page + * \param PAddr Page to mark as referenced + */ +extern void MM_RefPhys(tPAddr PAddr); +/** + * \brief Dereference a physical page + * \param PAddr Page to dereference + */ +extern void MM_DerefPhys(tPAddr PAddr); +/** + * \} + */ + +// --- Memory Manipulation --- +/** + * \name Memory Manipulation + * \{ + */ extern int memcmp(const void *m1, const void *m2, Uint count); extern void *memcpy(void *dest, const void *src, Uint count); extern void *memcpyd(void *dest, const void *src, Uint count); extern void *memset(void *dest, int val, Uint count); extern void *memsetd(void *dest, Uint val, Uint count); +/** + * \} + */ + +// --- Endianness --- +/** + * \name Endianness Swapping + * \{ + */ extern Uint16 LittleEndian16(Uint16 Val); extern Uint16 BigEndian16(Uint16 Val); extern Uint32 LittleEndian32(Uint32 Val); extern Uint32 BigEndian32(Uint32 Val); +/** + * \} + */ + // --- Strings --- +/** + * \name Strings + * \{ + */ extern Uint strlen(const char *Str); extern char *strcpy(char *__dest, const char *__src); extern int strcmp(const char *__str1, const char *__str2); extern int strncmp(const char *Str1, const char *Str2, size_t num); extern int strucmp(const char *Str1, const char *Str2); -extern char *strdup(const char *__str); +extern char *strdup(const char *Str); extern int strpos(const char *Str, char Ch); extern int strpos8(const char *str, Uint32 search); extern void itoa(char *buf, Uint num, int base, int minLength, char pad); extern int ReadUTF8(Uint8 *str, Uint32 *Val); extern int WriteUTF8(Uint8 *str, Uint32 Val); +/** + * \} + */ + extern Uint rand(); + // --- Heap --- +/** + * \name Heap + * \{ + */ extern void *malloc(size_t size); extern void *calloc(size_t num, size_t size); extern void *realloc(void *ptr, size_t size); extern void free(void *Ptr); extern int IsHeap(void *Ptr); +/** + * \} + */ + // --- Modules --- +/** + * \name Modules + * \{ + */ extern int Module_LoadMem(void *Buffer, Uint Length, char *ArgStr); extern int Module_LoadFile(char *Path, char *ArgStr); +/** + * \} + */ + // --- Timing --- +/** + * \name Time and Timing + * \{ + */ extern Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year); extern Sint64 now(); extern int Time_CreateTimer(int Delta, void *Callback, void *Argument); extern void Time_RemoveTimer(int ID); extern void Time_Delay(int Delay); +/** + * \} + */ + // --- Threads --- +/** + * \name Threads and Processes + * \{ + */ extern int Proc_SpawnWorker(); extern int Proc_Spawn(char *Path); extern void Threads_Exit(); @@ -133,6 +330,10 @@ extern int Threads_GetUID(); extern int Threads_GetGID(); extern int SpawnTask(tThreadFunction Function, void *Arg); extern Uint *Threads_GetCfgPtr(int Id); +/** + * \} + */ + // --- Simple Math --- extern int DivUp(int num, int dem); diff --git a/Kernel/lib.c b/Kernel/lib.c index 5bed4ca2..3d91c71c 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -56,7 +56,7 @@ void itoa(char *buf, Uint num, int base, int minLength, char pad) } /** - * \fn int tolower(int __c) + * \fn int tolower(int c) * \brief Converts a character to lower case */ int tolower(int c) @@ -78,7 +78,7 @@ int strucmp(const char *Str1, const char *Str2) } /** - * \fn int strpos(char *Str, char Ch) + * \fn int strpos(const char *Str, char Ch) * \brief Search a string for an ascii character */ int strpos(const char *Str, char Ch) @@ -92,6 +92,8 @@ int strpos(const char *Str, char Ch) } /** + * \fn int ByteSum(void *Ptr, int Size) + * \brief Adds the bytes in a memory region and returns the sum */ int ByteSum(void *Ptr, int Size) { @@ -101,7 +103,7 @@ int ByteSum(void *Ptr, int Size) } /** - * \fn Uint strlen(char *__str) + * \fn Uint strlen(const char *__str) * \brief Get the length of string */ Uint strlen(const char *__str) @@ -112,7 +114,7 @@ Uint strlen(const char *__str) } /** - * \fn char *strcpy(char *__str1, char *__str2) + * \fn char *strcpy(const char *__str1, const char *__str2) * \brief Copy a string to a new location */ char *strcpy(char *__str1, const char *__str2) @@ -124,7 +126,7 @@ char *strcpy(char *__str1, const char *__str2) } /** - * \fn int strcmp(char *str1, char *str2) + * \fn int strcmp(const char *str1, const char *str2) * \brief Compare two strings return the difference between * the first non-matching characters. */ @@ -136,7 +138,7 @@ int strcmp(const char *str1, const char *str2) } /** - * \fn int strncmp(char *Str1, char *Str2, size_t num) + * \fn int strncmp(const char *Str1, const char *Str2, size_t num) * \brief Compare strings \a Str1 and \a Str2 to a maximum of \a num characters */ int strncmp(const char *Str1, const char *Str2, size_t num) @@ -148,14 +150,14 @@ int strncmp(const char *Str1, const char *Str2, size_t num) } /** - * \fn char *strdup(char *str) + * \fn char *strdup(const char *Str) * \brief Duplicates a string */ -char *strdup(const char *str) +char *strdup(const char *Str) { char *ret; - ret = malloc(strlen(str)+1); - strcpy(ret, str); + ret = malloc(strlen(Str)+1); + strcpy(ret, Str); return ret; } diff --git a/Kernel/modules.c b/Kernel/modules.c index 71d76d4c..b1d858c7 100644 --- a/Kernel/modules.c +++ b/Kernel/modules.c @@ -175,6 +175,12 @@ int Module_LoadFile(char *Path, char *ArgString) return 0; } + Log("Initialising %p '%s' v%i.%i...", + info, + info->Name, + info->Version>>8, info->Version & 0xFF + ); + // Call Initialiser //if( info->Init( ArgString ) != 0 ) if( info->Init( NULL ) == 0 ) diff --git a/Kernel/vfs/acls.c b/Kernel/vfs/acls.c index e512b361..51cf65b4 100644 --- a/Kernel/vfs/acls.c +++ b/Kernel/vfs/acls.c @@ -135,3 +135,11 @@ tVFS_ACL *VFS_UnixToAcessACL(Uint Mode, Uint Owner, Uint Group) // Return buffer return ret; } + +// === EXPORTS === +// --- Variables --- +EXPORTV(gVFS_ACL_EveryoneRWX); +EXPORTV(gVFS_ACL_EveryoneRW); +EXPORTV(gVFS_ACL_EveryoneRX); +// --- Functions --- +EXPORT(VFS_UnixToAcessACL); diff --git a/Kernel/vfs/dir.c b/Kernel/vfs/dir.c index e87b5a31..52e9f807 100644 --- a/Kernel/vfs/dir.c +++ b/Kernel/vfs/dir.c @@ -2,7 +2,7 @@ * Acess2 VFS * - Directory Management Functions */ -#define DEBUG 1 +#define DEBUG 0 #include #include #include diff --git a/Modules/Makefile.tpl b/Modules/Makefile.tpl index 64cf4b55..7d20cd3d 100644 --- a/Modules/Makefile.tpl +++ b/Modules/Makefile.tpl @@ -23,7 +23,8 @@ clean: $(BIN): $(OBJ) @echo --- $(LD) -o $@ - @$(LD) -T ../link.ld -shared -o $@ $(OBJ) + @$(LD) -T ../link.ld -shared -nostdlib -o $@ $(OBJ) +# @$(LD) -shared -nostdlib -o $@ $(OBJ) @echo --- $(LD) -o $(KOBJ) @$(CC) -Wl,-r -nostdlib -o $(KOBJ) $(OBJ) -- 2.20.1