Major build system changes
authorJohn Hodge <[email protected]>
Wed, 12 Oct 2011 03:12:29 +0000 (11:12 +0800)
committerJohn Hodge <[email protected]>
Wed, 12 Oct 2011 03:12:29 +0000 (11:12 +0800)
- Implemented ARMv7 userspace
- Shifted build system about to do so
 > `make all` processes user apps first
   This is so they are compiled for the initrd
 > Syscalls header changed to use #define instead of enum
   Allows ARMv7 assembly file to use it
- Moved most of my libgcc functions to ld-acess
 > ld-acess needed them, so remove code duplication

NOTE: Broke dependencies for nasm in user code
- I need to properly separate NASM and GAS objects, will
  do that in next commit.

23 files changed:
Kernel/GenSyscalls.php
Kernel/GenSyscalls.pl
Kernel/arch/armv7/start.S
Kernel/include/syscalls.h
Makefile
Makefile.cfg
Modules/Filesystems/InitRD/.gitignore
Modules/Filesystems/InitRD/GenerateInitRD.php
Modules/Filesystems/InitRD/Makefile
Modules/Filesystems/InitRD/files.lst
Modules/armv7/GIC/gic.c
Usermode/Applications/axwin2_src/WM/helpers.c
Usermode/Applications/axwin2_src/WM/input.c
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/acess.ld_src/acess_armv7.ld.h
Usermode/Libraries/crt0.o_src/crt0.armv7.S
Usermode/Libraries/ld-acess.so_src/Makefile
Usermode/Libraries/ld-acess.so_src/_stublib.c
Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h [new file with mode: 0644]
Usermode/Libraries/ld-acess.so_src/arch/armv7.ld [new file with mode: 0644]
Usermode/Libraries/ld-acess.so_src/lib.c
Usermode/Libraries/libc.so_src/arch/armv7.S [new file with mode: 0644]
Usermode/Libraries/libgcc.so_src/libgcc.c

index 1876046..d451d1d 100644 (file)
@@ -27,7 +27,6 @@ $lHeader  = "/*
 #ifndef _SYSCALLS_H
 #define _SYSCALLS_H
 
-enum eSyscalls {
 ";
 $i = 0;
 foreach($lSyscalls as $num=>$call)
@@ -37,9 +36,8 @@ foreach($lSyscalls as $num=>$call)
                $lAsmInc .= "\n";
        }
        
-       $lHeader .= "\t{$call[0]}";
-       if($i != $num)  $lHeader .= " = {$num}";
-       $lHeader .= ",\t// {$num} - {$call[1]}\n";
+       $lHeader .= "#define {$call[0]}\t{$num}";
+       $lHeader .= "\t// {$num} - {$call[1]}\n";
        
        $lAsmInc .= "%define {$call[0]}\t{$num}\t; {$call[1]}\n";
        
@@ -49,9 +47,10 @@ foreach($lSyscalls as $num=>$call)
        else
                $i ++;
 }
-$lHeader .= "\tNUM_SYSCALLS,\n";
-$lHeader .= "\tSYS_DEBUG = 0x100       // 0x100 - Print a debug string\n";
-$lHeader .= "};\n\n";
+$lHeader .= "#define NUM_SYSCALLS\t$i\n";
+$lHeader .= "#define SYS_DEBUG\t0x100  // 0x100 - Print a debug string\n";
+$lHeader .= "\n";
+$lHeader .= "#ifdef __GNUC__\n";
 $lHeader .= "static const char *cSYSCALL_NAMES[] = {\n\t";
 
 $j = 0;
@@ -67,7 +66,9 @@ for($i=0;$i<$lMax;$i++)
                $j = 0;
        }
 }
-$lHeader .= "\"\"\n};\n#endif\n";
+$lHeader .= "\"\"\n};\n"
+$lHeader .= "#endif\n";
+$lHeader .= "#endif\n";
 
 $fp = fopen("include/syscalls.h", "w");        fwrite($fp, $lHeader);  fclose($fp);
 $fp = fopen("include/syscalls.inc.asm", "w");  fwrite($fp, $lAsmInc);  fclose($fp);
index 15270a6..487ceca 100755 (executable)
@@ -33,27 +33,20 @@ print HEADER "/*
 #ifndef _SYSCALLS_H
 #define _SYSCALLS_H
 
-enum eSyscalls {
 ";
 
 $lastid = -1;
+$i = 0;
 foreach my $call (@calls)
 {
-       if( $lastid + 1 != $call->[0] ) {
-               print HEADER "\n";
-       }
-       print HEADER "\t", $call->[1];
-       if( $lastid + 1 != $call->[0] ) {
-               print HEADER " = ", $call->[0];
-       }
-       print HEADER ",\t// ", $call->[2], "\n";
-       $lastid = $call->[0];
+       print HEADER "#define ", $call->[1], "\t", $call->[0], "\t// ", $call->[2], "\n";
+       $i = $call->[0] + 1;
 }
 print HEADER "
-\tNUM_SYSCALLS,
-\tSYS_DEBUG = 0x100
-};
+#define NUM_SYSCALLS   ",$i,"
+#define SYS_DEBUG      0x100
 
+#ifndef __ASSEMBLER__
 static const char *cSYSCALL_NAMES[] = {
 ";
 
@@ -71,6 +64,7 @@ foreach $call (@calls)
 print HEADER  "
 \t\"\"
 };
+#endif
 
 #endif
 ";
index 0ba0c8c..078b998 100644 (file)
@@ -65,10 +65,10 @@ IRQHandler:
 
        PUSH_GPRS
 
-       ldr r0, =csIRQ_Tag
-       ldr r1, =csIRQ_Fmt
-       ldr r4, =Log_Debug
-       blx r4
+@      ldr r0, =csIRQ_Tag
+@      ldr r1, =csIRQ_Fmt
+@      ldr r4, =Log_Debug
+@      blx r4
        
        @ Call the registered handler
        ldr r0, gpIRQHandler
index bb80ffb..98bb979 100644 (file)
@@ -8,67 +8,64 @@
 #ifndef _SYSCALLS_H
 #define _SYSCALLS_H
 
-enum eSyscalls {
-       SYS_EXIT,       // Kill this thread
-       SYS_CLONE,      // Create a new thread
-       SYS_KILL,       // Send a signal
-       SYS_SETFAULTHANDLER,    // Set signal Handler
-       SYS_YIELD,      // Yield remainder of timestamp
-       SYS_SLEEP,      // Sleep until messaged or signaled
-       SYS_WAIT,       // Wait for a time or a message
-       SYS_WAITTID,    // Wait for a thread to do something
-       SYS_SETNAME,    // Set's the name of the current thread
-       SYS_GETNAME,    // Get's the name of a thread
-       SYS_GETTID,     // Get current thread ID
-       SYS_GETPID,     // Get current thread group ID
-       SYS_SETPRI,     // Set process priority
-       SYS_SENDMSG,    // Send an IPC message
-       SYS_GETMSG,     // Recieve an IPC message
-       SYS_GETTIME,    // Get the current timestamp
-       SYS_SPAWN,      // Spawn a new process
-       SYS_EXECVE,     // Replace the current process
-       SYS_LOADBIN,    // Load a binary into the current address space
-       SYS_UNLOADBIN,  // Unload a loaded binary
-       SYS_LOADMOD,    // Load a module into the kernel
+#define SYS_EXIT       0       // Kill this thread
+#define SYS_CLONE      1       // Create a new thread
+#define SYS_KILL       2       // Send a signal
+#define SYS_SETFAULTHANDLER    3       // Set signal Handler
+#define SYS_YIELD      4       // Yield remainder of timestamp
+#define SYS_SLEEP      5       // Sleep until messaged or signaled
+#define SYS_WAIT       6       // Wait for a time or a message
+#define SYS_WAITTID    7       // Wait for a thread to do something
+#define SYS_SETNAME    8       // Set's the name of the current thread
+#define SYS_GETNAME    9       // Get's the name of a thread
+#define SYS_GETTID     10      // Get current thread ID
+#define SYS_GETPID     11      // Get current thread group ID
+#define SYS_SETPRI     12      // Set process priority
+#define SYS_SENDMSG    13      // Send an IPC message
+#define SYS_GETMSG     14      // Recieve an IPC message
+#define SYS_GETTIME    15      // Get the current timestamp
+#define SYS_SPAWN      16      // Spawn a new process
+#define SYS_EXECVE     17      // Replace the current process
+#define SYS_LOADBIN    18      // Load a binary into the current address space
+#define SYS_UNLOADBIN  19      // Unload a loaded binary
+#define SYS_LOADMOD    20      // Load a module into the kernel
+#define SYS_GETPHYS    32      // Get the physical address of a page
+#define SYS_MAP        33      // Map a physical address
+#define SYS_ALLOCATE   34      // Allocate a page
+#define SYS_UNMAP      35      // Unmap a page
+#define SYS_PREALLOC   36      // Preallocate a page
+#define SYS_SETFLAGS   37      // Set a page's flags
+#define SYS_SHAREWITH  38      // Share a page with another thread
+#define SYS_GETUID     39      // Get current User ID
+#define SYS_GETGID     40      // Get current Group ID
+#define SYS_SETUID     41      // Set current user ID
+#define SYS_SETGID     42      // Set current Group ID
+#define SYS_OPEN       64      // Open a file
+#define SYS_REOPEN     65      // Close a file and reuse its handle
+#define SYS_CLOSE      66      // Close a file
+#define SYS_READ       67      // Read from an open file
+#define SYS_WRITE      68      // Write to an open file
+#define SYS_IOCTL      69      // Perform an IOCtl Call
+#define SYS_SEEK       70      // Seek to a new position in the file
+#define SYS_READDIR    71      // Read from an open directory
+#define SYS_OPENCHILD  72      // Open a child entry in a directory
+#define SYS_GETACL     73      // Get an ACL Value
+#define SYS_SETACL     74      // Set an ACL Value
+#define SYS_FINFO      75      // Get file information
+#define SYS_MKDIR      76      // Create a new directory
+#define SYS_LINK       77      // Create a new link to a file
+#define SYS_SYMLINK    78      // Create a symbolic link
+#define SYS_UNLINK     79      // Delete a file
+#define SYS_TELL       80      // Return the current file position
+#define SYS_CHDIR      81      // Change current directory
+#define SYS_GETCWD     82      // Get current directory
+#define SYS_MOUNT      83      // Mount a filesystem
+#define SYS_SELECT     84      // Wait for file handles
 
-       SYS_GETPHYS = 32,       // Get the physical address of a page
-       SYS_MAP,        // Map a physical address
-       SYS_ALLOCATE,   // Allocate a page
-       SYS_UNMAP,      // Unmap a page
-       SYS_PREALLOC,   // Preallocate a page
-       SYS_SETFLAGS,   // Set a page's flags
-       SYS_SHAREWITH,  // Share a page with another thread
-       SYS_GETUID,     // Get current User ID
-       SYS_GETGID,     // Get current Group ID
-       SYS_SETUID,     // Set current user ID
-       SYS_SETGID,     // Set current Group ID
-
-       SYS_OPEN = 64,  // Open a file
-       SYS_REOPEN,     // Close a file and reuse its handle
-       SYS_CLOSE,      // Close a file
-       SYS_READ,       // Read from an open file
-       SYS_WRITE,      // Write to an open file
-       SYS_IOCTL,      // Perform an IOCtl Call
-       SYS_SEEK,       // Seek to a new position in the file
-       SYS_READDIR,    // Read from an open directory
-       SYS_OPENCHILD,  // Open a child entry in a directory
-       SYS_GETACL,     // Get an ACL Value
-       SYS_SETACL,     // Set an ACL Value
-       SYS_FINFO,      // Get file information
-       SYS_MKDIR,      // Create a new directory
-       SYS_LINK,       // Create a new link to a file
-       SYS_SYMLINK,    // Create a symbolic link
-       SYS_UNLINK,     // Delete a file
-       SYS_TELL,       // Return the current file position
-       SYS_CHDIR,      // Change current directory
-       SYS_GETCWD,     // Get current directory
-       SYS_MOUNT,      // Mount a filesystem
-       SYS_SELECT,     // Wait for file handles
-
-       NUM_SYSCALLS,
-       SYS_DEBUG = 0x100
-};
+#define NUM_SYSCALLS   85
+#define SYS_DEBUG      0x100
 
+#ifndef __ASSEMBLER__
 static const char *cSYSCALL_NAMES[] = {
        "SYS_EXIT",
        "SYS_CLONE",
@@ -158,5 +155,6 @@ static const char *cSYSCALL_NAMES[] = {
 
        ""
 };
+#endif
 
 #endif
index 4fca6d5..3336e80 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
 
 -include Makefile.cfg
 
-.PHONY: all clean
+.PHONY: all clean SyscallList all-user
 
 SUBMAKE = $(MAKE) --no-print-directory
 
@@ -48,10 +48,14 @@ kmode:      $(AI_MODULES) $(AI_DYNMODS) allinstall-Kernel
 all-user: $(ALL_USRLIBS) $(ALL_USRAPPS)
 clean-user: $(CLEAN_USRLIBS) $(CLEAN_USRAPPS)
 
-all:   $(ALL_DYNMODS) $(ALL_MODULES) all-Kernel $(ALL_USRLIBS) $(ALL_USRAPPS)
-all-install:   $(AI_DYNMODS) $(AI_MODULES) allinstall-Kernel $(AI_USRLIBS) $(AI_USRAPPS)
+all:   SyscallList $(ALL_USRLIBS) $(ALL_USRAPPS) $(ALL_MODULES) all-Kernel $(ALL_DYNMODS)
+all-install:   SyscallList $(AI_USRLIBS) $(AI_USRAPPS) $(AI_MODULES) allinstall-Kernel $(AI_DYNMODS)
 clean: $(CLEAN_DYNMODS) $(CLEAN_MODULES) clean-Kernel $(CLEAN_USRLIBS) $(CLEAN_USRAPPS)
-install:       install-Filesystem $(INSTALL_DYNMODS) $(INSTALL_MODULES) install-Kernel $(INSTALL_USRLIBS) $(INSTALL_USRAPPS)
+install:       install-Filesystem SyscallList $(INSTALL_USRLIBS) $(INSTALL_USRAPPS) $(INSTALL_DYNMODS) $(INSTALL_MODULES) install-Kernel
+
+SyscallList: include/syscalls.h
+include/syscalls.h: Kernel/Makefile Kernel/syscalls.lst
+       @make -C Kernel/ include/syscalls.h
 
 # Compile Only
 $(ALL_DYNMODS): all-%:
index 6986150..b919d86 100644 (file)
@@ -72,6 +72,7 @@ endif
 ifeq ($(ARCHDIR),armv7)
 MODULES += Input/PS2KbMouse
 MODULES += armv7/GIC
+MODULES += Filesystems/InitRD
 endif
 
 MODULES += IPStack     # So the other modules are loaded before it
index ab6eb60..4632cc0 100644 (file)
@@ -10,6 +10,9 @@ $gOutput = <<<EOF
 
 EOF;
 
+$ACESSDIR = getenv("ACESSDIR");
+$ARCH = getenv("ARCH");
+
 $gInputFile = $argv[1];
 $gOutputFile = $argv[2];
 $gDepFile = ($argc > 3 ? $argv[3] : false);
@@ -24,6 +27,7 @@ $lStack = array( array("",array()) );
 foreach($lines as $line)
 {
        $line = trim($line);
+       // Directory
        if(preg_match('/^Dir\s+"([^"]+)"\s+{$/', $line, $matches))
        {
                $new = array($matches[1], array());
@@ -31,12 +35,14 @@ foreach($lines as $line)
                $lDepth ++;
                continue;
        }
+       // End of a block
        if($line == "}")
        {
                $lDepth --;
                $lStack[$lDepth][1][] = array_pop($lStack);
                continue;
        }
+       // File
        if(preg_match('/^File\s+"([^"]+)"\s+"([^"]+)"$/', $line, $matches))
        {
                $lStack[$lDepth][1][] = array($matches[1], $matches[2]);
@@ -63,6 +69,7 @@ function hd8($fp)
 function ProcessFolder($prefix, $items)
 {
        global  $gOutput;
+       global  $ACESSDIR, $ARCH;
        foreach($items as $i=>$item)
        {
                if(is_array($item[1]))
@@ -91,57 +98,40 @@ tVFS_Node {$prefix}_{$i} = {
 
 EOF;
                }
-               else {
-                       if(!file_exists($item[1])) {
-                               echo "ERROR: '{$item[1]}' does not exist\n", 
+               else
+               {
+                       $path = $item[1];
+                       
+                       // Parse path components
+                       $path = str_replace("__BIN__", "$ACESSDIR/Usermode/Output/$ARCH", $path);
+                       $path = str_replace("__FS__", "$ACESSDIR/Usermode/Filesystem", $path);
+                       echo $path,"\n";
+                       // ---
+
+                       if(!file_exists($path)) {
+                               echo "ERROR: '{$path}' does not exist\n", 
                                exit(1);
                        }
-                       $size = filesize($item[1]);
+                       $size = filesize($path);
                        
-                       $fp = fopen($item[1], "rb");
-                       if(0)
-                       {
-                               $gOutput .= "Uint32 {$prefix}_{$i}_data[] = {\n";
-                               for( $j = 0; $j + 16 < $size; $j += 16 )
-                               {
-                                       $gOutput .= "\t";
-                                       $gOutput .= hd($fp).",".hd($fp).",";
-                                       $gOutput .= hd($fp).",".hd($fp).",\n";
-                               }
+                       $fp = fopen($path, "rb");
+                       
+                       $gOutput .= "Uint8 {$prefix}_{$i}_data[] = {\n";
+                       for( $j = 0; $j + 16 < $size; $j += 16 ) {
                                $gOutput .= "\t";
-                               for( ; $j+3 < $size; $j += 4 )
-                               {
-                                       if( $j & 15 )   $gOutput .= ",";
-                                       $gOutput .= hd($fp);
-                               }
-                               if($j < $size) {
-                                       $tmp = "";
-                                       while($j ++ < $size)
-                                               $tmp .= fgetc($fp);
-                                       $tmp .= "\0\0\0";
-                                               $tmp = unpack("I", $tmp);
-                                       $gOutput .= "0x".dechex($tmp[1]);
-                               }
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",";
+                               $gOutput .= hd8($fp).",".hd8($fp).",\n";
                        }
-                       else
-                       {
-                               $gOutput .= "Uint8 {$prefix}_{$i}_data[] = {\n";
-                               for( $j = 0; $j + 16 < $size; $j += 16 ) {
-                                       $gOutput .= "\t";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",";
-                                       $gOutput .= hd8($fp).",".hd8($fp).",\n";
-                               }
-                               $gOutput .= "\t";
-                               for( ; $j < $size; $j ++ ) {
-                                       if( $j & 15 )   $gOutput .= ",";
-                                       $gOutput .= hd8($fp);
-                               }
+                       $gOutput .= "\t";
+                       for( ; $j < $size; $j ++ ) {
+                               if( $j & 15 )   $gOutput .= ",";
+                               $gOutput .= hd8($fp);
                        }
                        fclose($fp);
                        $gOutput .= "\n};\n";
index 7506f7e..205ad7b 100644 (file)
@@ -1,13 +1,15 @@
 # InitRD Filesystem Driver
 #
 
-OBJ = main.o files.o
+OBJ = main.o files.$(ARCH).o
 EXTRA = files.c
 NAME = InitRD
+EXTRA = files.$(ARCH).c files.$(ARCH).c.dep
 
 -include ../Makefile.tpl
 
-files.c: GenerateInitRD.php files.lst
-       php GenerateInitRD.php files.lst files.c files.c.d
 
--include files.c.d
+files.$(ARCH).c: GenerateInitRD.php files.lst
+       ARCH=$(ARCH) ACESSDIR=$(ACESSDIR) php GenerateInitRD.php files.lst $@ [email protected]
+
+-include files.$(ARCH).c.dep
index 6d7c842..e803326 100644 (file)
@@ -1,25 +1,24 @@
 Dir "SBin" {
-       File "init" "../../../Usermode/Output/i386/SBin/init"
-       File "login" "../../../Usermode/Output/i386/SBin/login"
+       File "init" "__BIN__/SBin/init"
+       File "login" "__BIN__/SBin/login"
 }
 Dir "Bin" {
-       File "CLIShell" "../../../Usermode/Output/i386/Bin/CLIShell"
-       File "ls" "../../../Usermode/Output/i386/Bin/ls"
-       File "cat" "../../../Usermode/Output/i386/Bin/cat"
-       File "mount" "../../../Usermode/Output/i386/Bin/mount"
-       File "pcidump" "../../../Usermode/Output/i386/Bin/pcidump"
-       File "ifconfig" "../../../Usermode/Output/i386/Bin/ifconfig"
-       File "telnet" "../../../Usermode/Output/i386/Bin/telnet"
-       File "irc" "../../../Usermode/Output/i386/Bin/irc"
+       File "CLIShell" "__BIN__/Bin/CLIShell"
+       File "ls" "__BIN__/Bin/ls"
+       File "cat" "__BIN__/Bin/cat"
+       File "mount" "__BIN__/Bin/mount"
+       File "ifconfig" "__BIN__/Bin/ifconfig"
+       File "telnet" "__BIN__/Bin/telnet"
+       File "irc" "__BIN__/Bin/irc"
 }
 Dir "Libs" {
-       File "ld-acess.so" "../../../Usermode/Output/i386/Libs/ld-acess.so"
-       File "libld-acess.so" "../../../Usermode/Output/i386/Libs/libld-acess.so"
-       File "libc.so" "../../../Usermode/Output/i386/Libs/libc.so"
-       File "libgcc.so" "../../../Usermode/Output/i386/Libs/libgcc.so"
-       File "libreadline.so" "../../../Usermode/Output/i386/Libs/libreadline.so"
-       File "libnet.so" "../../../Usermode/Output/i386/Libs/libnet.so"
+       File "ld-acess.so" "__BIN__/Libs/ld-acess.so"
+       File "libld-acess.so" "__BIN__/Libs/libld-acess.so"
+       File "libc.so" "__BIN__/Libs/libc.so"
+       File "libgcc.so" "__BIN__/Libs/libgcc.so"
+       File "libreadline.so" "__BIN__/Libs/libreadline.so"
+       File "libnet.so" "__BIN__/Libs/libnet.so"
 }
 Dir "Conf" {
-       File "BootConf.cfg" "../../../Usermode/Filesystem/Conf/BootConf.cfg"
+       File "BootConf.cfg" "__FS__/Conf/BootConf.cfg"
 }
index 4ace400..21c3a30 100644 (file)
@@ -57,7 +57,7 @@ int GIC_Install(char **Arguments)
 void GIC_IRQHandler(void)
 {
        Uint32  num = gpGIC_InterfaceBase[GICC_IAR];
-       Log_Debug("GIC", "IRQ 0x%x", num);
+//     Log_Debug("GIC", "IRQ 0x%x", num);
        gaIRQ_Handlers[num]( num, gaIRQ_HandlerData[num] );
        gpGIC_InterfaceBase[GICC_EOIR] = num;
 }
index d923817..194c024 100644 (file)
@@ -7,5 +7,6 @@
 // === CODE ===
 void memset32(void *ptr, uint32_t val, size_t count)
 {
-       __asm__ __volatile__ ("rep stosl" : : "D"(ptr),"a"(val),"c"(count));
+       uint32_t *dst = ptr;
+       while(count --) *dst++ = val;
 }
index a9728f7..aa7f3b3 100644 (file)
@@ -71,6 +71,6 @@ void Input_HandleSelect(fd_set *set)
                
                // Handle movement
 //             Video_SetCursorPos( mouseinfo.Axies[0], mouseinfo.Axies[1] );
-               _SysDebug("Cursor to %i,%i\n", mouseinfo.Axies[0], mouseinfo.Axies[1]);
+               _SysDebug("Cursor to %i,%i\n", mouseinfo.Axies[0].CursorPos, mouseinfo.Axies[1].CursorPos);
        }
 }
index 5ca97a9..adf1c7e 100644 (file)
@@ -43,11 +43,11 @@ $(_OBJPREFIX)%.o: %.c
        @$(CC) $(CFLAGS) -o $@ -c $<
        @$(CC) -M -MT $@ $(CPPFLAGS) $< -o [email protected]
 
-$(_OBJPREFIX)%.ao: %.asm
+$(_OBJPREFIX)%.ao: %.$(ASSUFFIX)
        @echo [AS] -o $@
        @mkdir -p $(dir $@)
        @$(AS) $(ASFLAGS) -o $@ $<
-       @$(AS) $(ASFLAGS) -o $@ $< -M > [email protected]
+       @$(AS) $(ASFLAGS) -o $@.dep $< -M
 
 #$(OUTPUTDIR)Libs/libld-acess.so:
 #      @make -C $(ACESSDIR)/Usermode/Libraries/ld-acess.so_src/
index c338f46..e652a5a 100644 (file)
@@ -4,6 +4,7 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
 OUTPUT_ARCH(arm)
 ENTRY(_start)
 SEARCH_DIR(__LIBDIR)
+INPUT(crt0.o)
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
index 77b9c2d..157ba15 100644 (file)
@@ -3,12 +3,12 @@
 @ C Runtime 0
 @ - crt0.arm7.asm
 
-.globl start
-start:
+.globl _start
+_start:
        bl main
        push {r0}
 
-       ldr r0, = _crt0_exit_handler
+       ldr r0, =_crt0_exit_handler
        ldr r0, [r0]
        tst r0, r0
        blxne r0
index a29dd4b..2a7a186 100644 (file)
@@ -23,7 +23,7 @@ $(_XBIN): $(_OBJPREFIX)_stublib.o
 
 
 # Override .ao to look in the object prefix for the source
-%.ao: %.asm
+%.ao: %.$(ASSUFFIX)
        @echo [AS] -o $@
        @mkdir -p $(dir $@)
        @$(AS) $(ASFLAGS) -o $@ $<
@@ -34,5 +34,5 @@ $(_XBIN): $(_OBJPREFIX)_stublib.o
 $(_OBJPREFIX)%: %.h
        @echo [CPP] -o $@
        @mkdir -p $(dir $@)
-       @$(CPP) $(CPPFLAGS) -P -D_ASM_ $< -o $@
+       @$(CPP) $(CPPFLAGS) -P -D__ASM__ $< -o $@
 
index 6107c69..347b32f 100644 (file)
@@ -1,4 +1,6 @@
 
+#include <stdint.h>
+
 int _errno;
 
 #define SYSCALL0(name,num)     void name(void){}
@@ -11,3 +13,12 @@ int _errno;
 
 #include "arch/syscalls.s.h"
 
+// libgcc functions
+uint64_t __udivdi3(uint64_t Num, uint64_t Den){return 0;}
+uint64_t __umoddi3(uint64_t Num, uint64_t Den){return 0;}
+
+int32_t __divsi3(int32_t Num, int32_t Den){return 0;}
+int32_t __modsi3(int32_t Num, int32_t Den){return 0;}
+uint32_t __udivsi3(uint32_t Num, uint32_t Den){return 0;}
+uint32_t __umodsi3(uint32_t Num, uint32_t Den){return 0;}
+
diff --git a/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h b/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h
new file mode 100644 (file)
index 0000000..75c56d8
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Acess2 ARMv7 - System Calls
+//
+
+#include "../../../../Kernel/include/syscalls.h"
+
+.globl _start
+.extern SoMain
+_start:
+       push {r1,r2,r3}
+       bl SoMain
+       
+       mov r4, r0
+
+       pop {r0,r1,r2}
+       blx r4
+       
+       b _exit
+
+@ Stupid GCC
+.globl __ucmpdi2
+__ucmpdi2:
+       cmp r0, r2
+       movmi r0, #0
+       movmi pc, lr
+       movhi r0, #2
+       movhi pc, lr
+       cmp r1, r2
+       movmi r0, #0
+       movmi pc, lr
+       movhi r0, #2
+       movhi pc, lr
+       mov r0, #1
+       mov pc, lr
+
+@ DEST
+@ SRC
+@_memcpy:
+@      push rbp
+@      mov rbp, rsp
+@      
+@      ; RDI - First Param
+@      ; RSI - Second Param
+@      mov rcx, rdx    ; RDX - Third
+@      rep movsb
+@      
+@      pop rbp
+@      ret
+@
+.globl _errno
+_errno:        .long   0       @ Placed in .text, to allow use of relative addressing
+
+.macro syscall0 _name, _num    
+.globl \_name
+\_name:
+       svc #\_num
+       str r2, _errno
+       mov pc, lr
+.endm
+
+#define SYSCALL0(_name,_num)   syscall0 _name, _num
+#define SYSCALL1(_name,_num)   SYSCALL0(_name, _num)
+#define SYSCALL2(_name,_num)   SYSCALL0(_name, _num)
+#define SYSCALL3(_name,_num)   SYSCALL0(_name, _num)
+#define SYSCALL4(_name,_num)   SYSCALL0(_name, _num)
+// TODO: 5/6 need special handling, because the args are on the stack
+#define SYSCALL5(_name,_num)   SYSCALL0(_name, _num)
+#define SYSCALL6(_name,_num)   SYSCALL0(_name, _num)
+
+// Override the clone syscall
+#define _exit  _exit_raw
+#include "syscalls.s.h"
+#undef _exit
+
+.globl _exit
+_exit:
+       svc #0
+       b .
+
diff --git a/Usermode/Libraries/ld-acess.so_src/arch/armv7.ld b/Usermode/Libraries/ld-acess.so_src/arch/armv7.ld
new file mode 100644 (file)
index 0000000..efa4f19
--- /dev/null
@@ -0,0 +1,66 @@
+ENTRY(_start)
+OUTPUT_FORMAT(elf32-littlearm)
+
+SECTIONS {
+       . = 0x00100000;
+       gLinkedBase = .;
+       . += SIZEOF_HEADERS;
+       .interp          : { *(.interp) }
+       .note.gnu.build-id : { *(.note.gnu.build-id) }
+       .hash              : { *(.hash) }
+       .gnu.hash          : { *(.gnu.hash) }
+       .dynsym          : { *(.dynsym) }
+       .dynstr          : { *(.dynstr) }
+       .gnu.version    : { *(.gnu.version) }
+       .gnu.version_d  : { *(.gnu.version_d) }
+       .gnu.version_r  : { *(.gnu.version_r) }
+       .rel.dyn                :
+       {
+               *(.rel.init)
+               *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+               *(.rel.fini)
+               *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+               *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
+               *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+               *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+               *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+               *(.rel.ctors)
+               *(.rel.dtors)
+               *(.rel.got)
+               *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+       }
+       .rela.dyn          :
+       {
+               *(.rela.init)
+               *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+               *(.rela.fini)
+               *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+               *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+               *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+               *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+               *(.rela.ctors)
+               *(.rela.dtors)
+               *(.rela.got)
+               *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+       }
+
+       .text : AT(ADDR(.text)) {
+               code = .;
+               *(.text)
+               *(.rodata*)
+       }
+
+       .data ALIGN (0x1000) : AT(ADDR(.data)) {
+               data = .;
+               *(.data)
+       }
+
+       .bss ALIGN (0x1000) : AT(ADDR(.bss)) {
+               _sbss = .;
+               *(COMMON)
+               *(.bss)
+               _ebss = .;
+               bss = .;
+       }
+       _end = .;
+}
index 150ae77..d7a581e 100644 (file)
@@ -72,10 +72,47 @@ int file_exists(const char *filename)
        return 1;
 }
 
-uint64_t __udivdi3(uint64_t Num, uint64_t Den)
+uint64_t __divmod64(uint64_t Num, uint64_t Den, uint64_t *Rem)
 {
        uint64_t        ret = 0, add = 1;
 
+       if( Den == 0 ) {
+               if(Rem) *Rem = 0;
+               return -1;
+       }
+
+       // Find what power of two times Den is > Num
+       while( Num >= Den )
+       {
+               Den <<= 1;
+               add <<= 1;
+       }
+
+       // Search backwards
+       while( add > 1 )
+       {
+               add >>= 1;
+               Den >>= 1;
+               // If the numerator is >= Den, subtract and add to return value
+               if( Num >= Den )
+               {
+                       ret += add;
+                       Num -= Den;
+               }
+       }
+       if(Rem) *Rem = Num;
+       return ret;
+}
+
+uint32_t __divmod32(uint32_t Num, uint32_t Den, uint32_t *Rem)
+{
+       uint32_t        ret = 0, add = 1;
+
+       if( Den == 0 ) {
+               if(Rem) *Rem = 0;
+               return -1;
+       }
+
        // Find what power of two times Den is > Num
        while( Num >= Den )
        {
@@ -88,14 +125,47 @@ uint64_t __udivdi3(uint64_t Num, uint64_t Den)
        {
                add >>= 1;
                Den >>= 1;
-               // If the numerator is > Den, subtract and add to return value
-               if( Num > Den )
+               // If the numerator is >= Den, subtract and add to return value
+               if( Num >= Den )
                {
                        ret += add;
                        Num -= Den;
                }
        }
-//     if(Rem) *Rem = Num;
+       if(Rem) *Rem = Num;
+       return ret;
+}
+
+uint64_t __udivdi3(uint64_t Num, uint64_t Den)
+{
+       return __divmod64(Num, Den, NULL);
+}
+
+uint64_t __umoddi3(uint64_t Num, uint64_t Den)
+{
+       uint64_t        ret;
+       __divmod64(Num, Den, &ret);
+       return ret;
+}
+
+int32_t __divsi3(int32_t Num, int32_t Den)
+{
+       int32_t sign = 1;
+       if(Num < 0) {
+               Num = -Num;
+               sign = -sign;
+       }
+       if(Den < 0) {
+               Den = -Den;
+               sign = -sign;
+       }
+       return sign * __divmod32(Num, Den, NULL);
+}
+
+uint32_t __umodsi3(uint32_t Num, uint32_t Den)
+{
+       uint32_t        ret;
+       __divmod32(Num, Den, &ret);
        return ret;
 }
 
diff --git a/Usermode/Libraries/libc.so_src/arch/armv7.S b/Usermode/Libraries/libc.so_src/arch/armv7.S
new file mode 100644 (file)
index 0000000..23fd42e
--- /dev/null
@@ -0,0 +1,24 @@
+@ 
+@ Acess2 C Library
+@ - By John Hodge (thePowersGang)
+@ 
+@ arch/armv7.S
+@ - ARMv7 specific code
+.globl setjmp
+setjmp:
+       @ RO: Buffer
+       stm r0, {r0-r14}
+       eor r0, r0
+       mov pc, lr
+
+.globl longjmp
+longjmp:
+       @ R0: Buffer
+       @ R1: Value
+       add r0, #8
+       ldm r0, {r2-r14}
+       mov r0, r1
+       tst r0, r0
+       addeq r0, #1
+       mov pc, lr      @ Will return to after setjmp
+
index 8c5c13a..df1832d 100644 (file)
@@ -18,111 +18,3 @@ void __stack_chk_fail()
        for(;;);
 }
 
-// --- 64-Bit Math ---
-/**
- * \fn uint64_t __udivdi3(uint64_t Num, uint64_t Den)
- * \brief Divide two 64-bit integers
- */
-uint64_t __udivdi3(uint64_t Num, uint64_t Den)
-{
-       #if 0
-       uint64_t        ret = 0;
-       if(Den == 0)    // Call Div by Zero Error
-               __asm__ __volatile__ ("int $0");
-       
-       if(Den == 1)    return Num;
-       if(Den == 2)    return Num >> 1;
-       if(Den == 4)    return Num >> 2;
-       if(Den == 8)    return Num >> 3;
-       if(Den == 16)   return Num >> 4;
-       if(Den == 32)   return Num >> 5;
-       if(Den == 64)   return Num >> 6;
-       if(Den == 128)  return Num >> 7;
-       if(Den == 256)  return Num >> 8;
-       
-       while(Num > Den) {
-               ret ++;
-               Num -= Den;
-       }
-       return ret;
-       #else
-       uint64_t        P[2];
-       uint64_t        q;
-        int    i;
-       
-       if(Den == 0)    __asm__ __volatile__ ("int $0x0");
-       // Common speedups
-       if(Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF)
-               return (uint32_t)Num / (uint32_t)Den;
-       if(Den == 1)    return Num;
-       if(Den == 2)    return Num >> 1;
-       if(Den == 16)   return Num >> 4;
-       if(Num < Den)   return 0;
-       if(Num < Den*2) return 1;
-       if(Num == Den*2)        return 2;
-       
-       // Restoring division, from wikipedia
-       // http://en.wikipedia.org/wiki/Division_(digital)
-       P[0] = Num;     P[1] = 0;
-       for( i = 64; i--; )
-       {
-               // P <<= 1;
-               P[1] = (P[1] << 1) | (P[0] >> 63);
-               P[0] = P[0] << 1;
-               
-               // P -= Den << 64
-               P[1] -= Den;
-               
-               // P >= 0
-               if( !(P[1] & (1ULL<<63)) ) {
-                       q |= (uint64_t)1 << (63-i);
-               }
-               else {
-                       //q |= 0 << (63-i);
-                       P[1] += Den;
-               }
-       }
-       
-       return q;
-       #endif
-}
-
-/**
- * \fn uint64_t __umoddi3(uint64_t Num, uint64_t Den)
- * \brief Get the modulus of two 64-bit integers
- */
-uint64_t __umoddi3(uint64_t Num, uint64_t Den)
-{
-       #if 0
-       if(Den == 0)    __asm__ __volatile__ ("int $0");        // Call Div by Zero Error
-       
-       if(Den == 1)    return 0;
-       if(Den == 2)    return Num & 0x01;
-       if(Den == 4)    return Num & 0x03;
-       if(Den == 8)    return Num & 0x07;
-       if(Den == 16)   return Num & 0x0F;
-       if(Den == 32)   return Num & 0x1F;
-       if(Den == 64)   return Num & 0x3F;
-       if(Den == 128)  return Num & 0x3F;
-       if(Den == 256)  return Num & 0x7F;
-       
-       while(Num >= Den)       Num -= Den;
-       
-       return Num;
-       #else
-       if(Den == 0)    __asm__ __volatile__ ("int $0");        // Call Div by Zero Error
-       
-       // Speedups
-       if(Num < Den)   return Num;
-       if(Num == Den)  return 0;
-       if(Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF)
-               return (uint32_t)Num % (uint32_t)Den;
-       
-       // Speedups for common operations
-       if(Den == 1)    return 0;
-       if(Den == 2)    return Num & 0x01;
-       if(Den == 8)    return Num & 0x07;
-       if(Den == 16)   return Num & 0x0F;
-       return Num - __udivdi3(Num, Den) * Den;
-       #endif
-}

UCC git Repository :: git.ucc.asn.au