From: John Hodge Date: Fri, 3 Jun 2011 07:41:11 +0000 (+0800) Subject: Misc changes X-Git-Tag: rel0.10~87 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=37eb4d555b07704870b7dc87591d72b5b2539dec;p=tpg%2Facess2.git Misc changes - Moved IPStack to end of module list (ensures network drivers are inited earlier) - Debugging in IPStack (ARP) - Fixing little bugs exposed by verbose errors --- diff --git a/Kernel/arch/x86_64/start32.asm b/Kernel/arch/x86_64/start32.asm index 7154ad89..86c90a57 100644 --- a/Kernel/arch/x86_64/start32.asm +++ b/Kernel/arch/x86_64/start32.asm @@ -42,7 +42,7 @@ start: cmp eax, 0x80000001 ; Compare the A-register with 0x80000001. mov eax, 0x80000001 cpuid - jb .not64bitCapable + jb .not64bitCapable test edx, 1<<29 jz .not64bitCapable diff --git a/Makefile.cfg b/Makefile.cfg index 96c783e0..b0de6628 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -43,7 +43,6 @@ MODULES := MODULES += Filesystems/Ext2 MODULES += Filesystems/FAT MODULES += Filesystems/NTFS -MODULES += IPStack ifeq ($(ARCHDIR),x86) MODULES += Storage/ATA Storage/FDD @@ -55,4 +54,5 @@ MODULES += Input/PS2KbMouse MODULES += x86/ISADMA x86/VGAText endif +MODULES += IPStack # So the other modules are loaded before it DYNMODS := USB/Core diff --git a/Modules/IPStack/arp.c b/Modules/IPStack/arp.c index 1e5bb073..e5d8a2ba 100644 --- a/Modules/IPStack/arp.c +++ b/Modules/IPStack/arp.c @@ -134,8 +134,10 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address) // Wait for a reply for(;;) { - while(lastID == giARP_LastUpdateID && now() < timeout) + while(lastID == giARP_LastUpdateID && now() < timeout) { +// Log_Debug("ARP", "timeout = %lli", timeout); Threads_Yield(); + } if( now() >= timeout ) break; // Timeout diff --git a/Modules/IPStack/interface.c b/Modules/IPStack/interface.c index ab458b6b..14c3ed32 100644 --- a/Modules/IPStack/interface.c +++ b/Modules/IPStack/interface.c @@ -144,28 +144,6 @@ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) return &gIP_LoopInterface.Node; } - #if 0 - i = 0; num = 0; - while('0' <= Name[i] && Name[i] <= '9') - { - num *= 10; - num += Name[i] - '0'; - i ++; - } - if(Name[i] != '\0') { - LEAVE('n'); - return NULL; - } - - for( iface = gIP_Interfaces; iface; iface = iface->Next ) - { - if( (int)iface->Node.ImplInt == num ) - { - LEAVE('p', &iface->Node); - return &iface->Node; - } - } - #else for( iface = gIP_Interfaces; iface; iface = iface->Next ) { if( strcmp(iface->Name, Name) == 0 ) @@ -174,7 +152,6 @@ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) return &iface->Node; } } - #endif LEAVE('p', NULL); return NULL; diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index 3aa1a795..b67e8bd2 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -9,4 +9,8 @@ CPPFLAGS = -I$(ACESSUSERDIR)/include/ CFLAGS = -fno-stack-protector $(CPPFLAGS) LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc +# Extra-verbose errors! +#CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op +# -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings + DIR = Bin diff --git a/Usermode/include/acess/sys.h b/Usermode/include/acess/sys.h index fd219bca..c26cec1a 100644 --- a/Usermode/include/acess/sys.h +++ b/Usermode/include/acess/sys.h @@ -35,22 +35,22 @@ extern int _errno; extern void _SysDebug(const char *format, ...); // --- Proc --- extern void _exit(int status) __attribute__((noreturn)); -extern void sleep(); -extern void yield(); +extern void sleep(void); +extern void yield(void); extern int kill(int pid, int sig); extern void wait(int miliseconds); extern int waittid(int id, int *status); extern int clone(int flags, void *stack); extern int execve(char *path, char **argv, char **envp); -extern int gettid(); -extern int getpid(); +extern int gettid(void); +extern int getpid(void); extern int _SysSetFaultHandler(int (*Handler)(int)); extern void SysSetName(const char *Name); //extern int SysGetName(const char *Name); // --- Permissions --- -extern int getuid(); -extern int getgid(); +extern int getuid(void); +extern int getgid(void); extern void setuid(int id); extern void setgid(int id); diff --git a/Usermode/include/stdint.h b/Usermode/include/stdint.h index a7857ef3..adfb101e 100644 --- a/Usermode/include/stdint.h +++ b/Usermode/include/stdint.h @@ -14,7 +14,7 @@ typedef signed short int16_t; typedef signed long int32_t; typedef signed long long int64_t; -#if __LP64__ +#ifdef __LP64__ typedef uint64_t intptr_t; typedef uint64_t uintptr_t; #else diff --git a/Usermode/include/sys/types.h b/Usermode/include/sys/types.h index a1ed85b7..ec3d43e3 100644 --- a/Usermode/include/sys/types.h +++ b/Usermode/include/sys/types.h @@ -70,9 +70,18 @@ typedef struct s_sysFInfo t_sysFInfo; typedef struct s_sysACL t_sysACL; static inline void FD_ZERO(fd_set *fdsetp) {int i=FD_SETSIZE/16;while(i--)fdsetp->flags[i]=0; } -static inline void FD_CLR(int fd, fd_set *fdsetp) { fdsetp->flags[fd/16]&=~(1<<(fd%16)); } -static inline void FD_SET(int fd, fd_set *fdsetp) { fdsetp->flags[fd/16]|=1<<(fd%16); } -static inline int FD_ISSET(int fd, fd_set *fdsetp) { return fdsetp->flags[fd/16]&(1<<(fd%16)); } +static inline void FD_CLR(int fd, fd_set *fdsetp) { + if(fd < 0 || fd > FD_SETSIZE) return; + fdsetp->flags[fd/16] &= (uint16_t) ((~1 << (fd%16))) & 0xFFFF; +} +static inline void FD_SET(int fd, fd_set *fdsetp) { + if(fd < 0 || fd > FD_SETSIZE) return; + fdsetp->flags[fd/16] |= (uint16_t) (1 << (fd%16)); +} +static inline int FD_ISSET(int fd, fd_set *fdsetp) { + if(fd < 0 || fd > FD_SETSIZE) return 0; + return !!( fdsetp->flags[fd/16] & (1<<(fd%16)) ); +} typedef uint32_t pid_t; typedef uint32_t tid_t;