Author: tkreuzer Date: Sun Oct 31 23:34:58 2010 New Revision: 49385
URL: http://svn.reactos.org/svn/reactos?rev=49385&view=rev Log: [NCITOOL] - Use the same stubs for GAS and ML (portable assembly) - Fix a warning (comparison signed/unsigned) - Don't duplicate the code when Zw stubs are requested, instead add both labels before the same code
Modified: branches/cmake-bringup/tools/nci/ncitool.c
Modified: branches/cmake-bringup/tools/nci/ncitool.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/tools/nci/ncitool.... ============================================================================== --- branches/cmake-bringup/tools/nci/ncitool.c [iso-8859-1] (original) +++ branches/cmake-bringup/tools/nci/ncitool.c [iso-8859-1] Sun Oct 31 23:34:58 2010 @@ -50,16 +50,15 @@ * This stubs calls into KUSER_SHARED_DATA where either a * sysenter or interrupt is performed, depending on CPU support. */ -#if defined(__GNUC__) -#define UserModeStub_x86 " movl $0x%x, %%eax\n" \ - " movl $KUSER_SHARED_SYSCALL, %%ecx\n" \ - " call *(%%ecx)\n" \ - " ret $0x%x\n\n" - -#define UserModeStub_amd64 " movl $0x%x, %%eax\n" \ - " movq %%rcx, %%r10\n" \ +#define UserModeStub_x86 " mov eax, %d\n" \ + " mov ecx, KUSER_SHARED_SYSCALL\n" \ + " call dword ptr [ecx]\n" \ + " ret %d\n\n" + +#define UserModeStub_amd64 " mov eax, %d\n" \ + " mov r10, rcx\n" \ " syscall\n" \ - " ret $0x%x\n\n" + " ret %d\n\n"
#define UserModeStub_ppc " stwu 1,-16(1)\n" \ " mflr 0\n\t" \ @@ -79,28 +78,6 @@ #define UserModeStub_arm " swi #0x%x\n" \ " bx lr\n\n"
-#elif defined(_MSC_VER) -#define UserModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " mov ecx, KUSER_SHARED_SYSCALL\n" \ - " call [ecx]\n" \ - " ret %xh\n" \ - " }\n" - -#define UserModeStub_amd64 " mov eax, %xh\n" \ - " mov r10, rcx\n" \ - " syscall\n" \ - " ret %xh\n\n" - -#define UserModeStub_ppc " \n" - -#define UserModeStub_mips " \n" - -#define UserModeStub_arm " \n" - -#else -#error Unknown compiler for inline assembler -#endif
/* * This stub calls KiSystemService directly with a fake INT2E stack. @@ -129,14 +106,12 @@ " bx ip\n\n"
#elif defined(_MSC_VER) -#define KernelModeStub_x86 " asm { \n" \ - " mov eax, %xh\n" \ - " lea edx, [esp+4]\n" \ - " pushf\n" \ - " push KGDT_R0_CODE\n" \ - " call _KiSystemService\n" \ - " ret %xh\n" \ - " }\n" +#define KernelModeStub_x86 " mov eax, %xh\n" \ + " lea edx, [esp+4]\n" \ + " pushf\n" \ + " push KGDT_R0_CODE\n" \ + " call _KiSystemService\n" \ + " ret %xh\n"
#define KernelModeStub_amd64 " mov eax, %xh\n" \ " call KiSystemService\n" \ @@ -164,9 +139,9 @@
struct ncitool_data_t ncitool_data[] = { { "i386", 4, KernelModeStub_x86, UserModeStub_x86, - ".global _%s@%d\n", "_%s@%d:\n" }, + "PUBLIC _%s@%d\n", "_%s@%d:\n" }, { "amd64", 4, KernelModeStub_amd64, UserModeStub_amd64, - ".global %s\n", "%s:\n" }, + "PUBLIC %s\n", "%s:\n" }, { "powerpc", 4, KernelModeStub_ppc, UserModeStub_ppc, "\t.globl %s\n", "%s:\n" }, { "mips", 4, KernelModeStub_mips, UserModeStub_mips, @@ -216,7 +191,10 @@ " * PROGRAMMER: Computer Generated File. See tools/nci/ncitool.c\n" " * REMARK: DO NOT EDIT OR COMMIT MODIFICATIONS TO THIS FILE\n" " */\n\n\n" - "#include <ndk/asm.h>\n\n", + "#include <reactos/asm.h>\n" + "#include <ndk/asm.h>\n\n" + + ".code\n", FileDescription, FileLocation); } @@ -416,6 +394,7 @@ char *SyscallArguments; int SyscallId; unsigned StackBytes; + unsigned int i;
/* We loop, incrementing the System Call Index, until the end of the file */ for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { @@ -431,26 +410,23 @@ if (NtSyscallName) {
/* Create Usermode Stubs for Nt/Zw syscalls in each Usermode file */ - int i; for (i= 0; i < UserFiles; i++) {
- /* Write the Nt Version */ - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes);
/* If a Zw Version is needed (was specified), write it too */ if (NeedsZw) {
NtSyscallName[0] = 'Z'; NtSyscallName[1] = 'w'; - WriteUserModeStub(UserModeFiles[i], - NtSyscallName, - StackBytes, - SyscallId | Index); + + /* Write the Stub Header and export the Function */ + WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); }
+ /* Write the Stub Code */ + fprintf(UserModeFiles[i], UserModeStub, SyscallId | Index, StackBytes); }
/* Create the Kernel coutnerparts (only Zw*, Nt* are the real functions!) */ @@ -468,6 +444,11 @@ SyscallId++; } } + +#if defined(_MSC_VER) + for (i= 0; i < UserFiles; i++) fprintf(UserModeFiles[i], "END\n"); + fprintf(KernelModeFile, "END\n"); +#endif }
/*++ @@ -650,7 +631,7 @@ /* Make sure we really extracted something */ if (NtSyscallName) {
- int i; + unsigned int i; for (i= 0; i < CountFiles; i++) {
if (!UseZw) {