- Move NCI generated files to arch-specific directories
authorHervé Poussineau <hpoussin@reactos.org>
Mon, 26 Mar 2007 22:56:22 +0000 (22:56 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 26 Mar 2007 22:56:22 +0000 (22:56 +0000)
- Replace ncitool by the one from powerpc branch, which supports code generation for multiple architectures

svn path=/trunk/; revision=26181

1  2 
reactos/dll/ntdll/ntdll.rbuild
reactos/dll/win32/gdi32/gdi32.rbuild
reactos/dll/win32/user32/user32.rbuild
reactos/ntoskrnl/ntoskrnl.rbuild
reactos/tools/nci/nci.mak
reactos/tools/nci/ncitool.c

@@@ -1,51 -1,52 +1,65 @@@
 -<module name="ntdll" type="win32dll" baseaddress="${BASEADDRESS_NTDLL}" installbase="system32" installname="ntdll.dll">
 -      <bootstrap base="reactos/system32" />
 -      <importlibrary definition="def/ntdll.def" />
 -      <include base="ntdll">inc</include>
 -      <include base="ReactOS">include/reactos/subsys</include>
 -      <define name="__NTDLL__" />
 -      <define name="_DISABLE_TIDENTS" />
 -      <define name="__USE_W32API" />
 -      <define name="_WIN32_WINNT">0x0502</define>
 -      <define name="_NTOSKRNL_" />
 -      <define name="__NO_CTYPE_INLINES" />
 -      <library>rtl</library>
 -      <library>intrlck</library>
 -      <library>string</library>
 -      <library>pseh</library>
 -      <linkerflag>-lgcc</linkerflag>
 -      <linkerflag>-nostdlib</linkerflag>
 -      <linkerflag>-nostartfiles</linkerflag>
 -      <directory name="csr">
 -              <file>api.c</file>
 -              <file>capture.c</file>
 -              <file>connect.c</file>
 -      </directory>
 -      <directory name="dbg">
 -              <file>dbgui.c</file>
 -      </directory>
 -      <directory name="ldr">
 -              <file>startup.c</file>
 -              <file>utils.c</file>
 -      </directory>
 -      <directory name="main">
 -              <if property="ARCH" value="i386">
 -                      <directory name="i386">
 -                              <file>dispatch.S</file>
 -                      </directory>
 -              </if>
 -              <ifnot property="ARCH" value="i386">
 -                      <file>dispatch.c</file>
 -              </ifnot>
 -      </directory>
 -      <directory name="rtl">
 -              <file>libsupp.c</file>
 -              <file>version.c</file>
 -      </directory>
 -      <directory name="def">
 -              <file>ntdll.rc</file>
 -      </directory>
 -      <directory name="inc">
 -              <pch>ntdll.h</pch>
 -      </directory>
 -      <file>napi.S</file>
 +<module name="ntdll" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_NTDLL}" installbase="system32" installname="ntdll.dll">
 +    <bootstrap base="$(CDOUTPUT)/system32" />
 +    <importlibrary definition="def/ntdll.def" />
 +    <include base="ntdll">inc</include>
 +    <include base="ReactOS">include/reactos/subsys</include>
 +    <define name="__NTDLL__" />
 +    <define name="_DISABLE_TIDENTS" />
 +    <define name="__USE_W32API" />
 +    <define name="_WIN32_WINNT">0x0502</define>
 +    <define name="_NTOSKRNL_" />
 +    <define name="__NO_CTYPE_INLINES" />
 +    <library>rtl</library>
 +    <library>libcntpr</library>
 +    <library>pseh</library>
 +    <linkerflag>-lgcc</linkerflag>
 +    <linkerflag>-nostdlib</linkerflag>
 +    <linkerflag>-nostartfiles</linkerflag>
 +    <directory name="csr">
 +        <file>api.c</file>
 +        <file>capture.c</file>
 +        <file>connect.c</file>
 +    </directory>
 +    <directory name="dbg">
 +        <file>dbgui.c</file>
 +    </directory>
 +    <directory name="ldr">
 +        <file>startup.c</file>
 +        <file>utils.c</file>
 +    </directory>
 +    <directory name="main">
 +        <if property="ARCH" value="i386">
 +            <directory name="i386">
 +                <file>dispatch.S</file>
 +            </directory>
 +        </if>
 +        <ifnot property="ARCH" value="i386">
 +            <file>dispatch.c</file>
 +        </ifnot>
 +    </directory>
 +    <directory name="rtl">
 +        <file>libsupp.c</file>
 +        <file>version.c</file>
 +    </directory>
 +    <directory name="def">
 +        <file>ntdll.rc</file>
 +    </directory>
 +    <directory name="inc">
 +        <pch>ntdll.h</pch>
 +    </directory>
-     <file>napi.S</file>
++    <if property="ARCH" value="i386">
++        <directory name="i386">
++            <file>napi.S</file>
++        </directory>
++    </if>
++    <if property="ARCH" value="powerpc">
++        <directory name="powerpc">
++            <file>napi.S</file>
++        </directory>
++    </if>
++    <if property="ARCH" value="mips">
++        <directory name="mips">
++            <file>napi.S</file>
++        </directory>
++    </if>
  </module>
                <file>stubs.c</file>
                <file>stubsa.c</file>
                <file>stubsw.c</file>
--              <file>win32k.S</file>
                <file>wingl.c</file>
++              <if property="ARCH" value="i386">
++                      <directory name="i386">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
++              <if property="ARCH" value="powerpc">
++                      <directory name="powerpc">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
++              <if property="ARCH" value="mips">
++                      <directory name="mips">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
        </directory>
        <directory name="objects">
                <file>bitmap.c</file>
                <file>strpool.c</file>
                <file>stubs.c</file>
                <file>timer.c</file>
--              <file>win32k.S</file>
                <file>winhelp.c</file>
                <file>winsta.c</file>
                <file>wsprintf.c</file>
++              <if property="ARCH" value="i386">
++                      <directory name="i386">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
++              <if property="ARCH" value="powerpc">
++                      <directory name="powerpc">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
++              <if property="ARCH" value="mips">
++                      <directory name="mips">
++                              <file>win32k.S</file>
++                      </directory>
++              </if>
        </directory>
        <directory name="windows">
                <file>accel.c</file>
              <directory name="i386">
                  <file>interlck_asm.S</file>
                  <file>fastinterlck_asm.S</file>
 +                <file>ioport.S</file>
++                <file>zw.S</file>
++            </directory>
++        </if>
++        <if property="ARCH" value="powerpc">
++            <directory name="powerpc">
++                <file>zw.S</file>
++            </directory>
++        </if>
++        <if property="ARCH" value="mips">
++            <directory name="mips">
++                <file>zw.S</file>
              </directory>
          </if>
              <file>atom.c</file>
              <file>win32k.c</file>
              <file>work.c</file>
              <file>zone.c</file>
--        <file>zw.S</file>
      </directory>
 -    <directory name="fs">
 -            <file>context.c</file>
 +    <directory name="fsrtl">
 +            <file>dbcsname.c</file>
              <file>fastio.c</file>
 +            <file>faulttol.c</file>
              <file>filelock.c</file>
 -            <file>mcb.c</file>
 +            <file>filter.c</file>
 +            <file>filtrctx.c</file>
 +            <file>fsfilter.c</file>
 +            <file>fsrtlpc.c</file>
 +            <file>largemcb.c</file>
              <file>name.c</file>
              <file>notify.c</file>
              <file>oplock.c</file>
@@@ -44,14 -44,14 +44,14 @@@ clean: nci_clea
  # WIN32K.SYS
  WIN32K_SVC_DB = $(NCI_BASE_)w32ksvc.db
  WIN32K_SERVICE_TABLE = subsystems$(SEP)win32$(SEP)win32k$(SEP)include$(SEP)napi.h
--WIN32K_GDI_STUBS = dll$(SEP)win32$(SEP)gdi32$(SEP)misc$(SEP)win32k.S
--WIN32K_USER_STUBS = dll$(SEP)win32$(SEP)user32$(SEP)misc$(SEP)win32k.S
++WIN32K_GDI_STUBS = dll$(SEP)win32$(SEP)gdi32$(SEP)misc$(SEP)$(ARCH)$(SEP)win32k.S
++WIN32K_USER_STUBS = dll$(SEP)win32$(SEP)user32$(SEP)misc$(SEP)$(ARCH)$(SEP)win32k.S
  
  # NTOSKRNL.EXE
  KERNEL_SVC_DB = $(NCI_BASE_)sysfuncs.lst
  KERNEL_SERVICE_TABLE = ntoskrnl$(SEP)include$(SEP)internal$(SEP)napi.h
--NTDLL_STUBS = dll$(SEP)ntdll$(SEP)napi.S
--KERNEL_STUBS = ntoskrnl$(SEP)ex$(SEP)zw.S
++NTDLL_STUBS = dll$(SEP)ntdll$(SEP)$(ARCH)$(SEP)napi.S
++KERNEL_STUBS = ntoskrnl$(SEP)ex$(SEP)$(ARCH)$(SEP)zw.S
  
  NCI_SERVICE_FILES = \
        $(KERNEL_SERVICE_TABLE) \
  
  $(NCI_SERVICE_FILES): $(NCI_TARGET) $(KERNEL_SVC_DB) $(WIN32K_SVC_DB)
        $(ECHO_NCI)
-       $(Q)$(NCI_TARGET) \
++      ${mkdir} dll$(SEP)ntdll$(SEP)$(ARCH) 2>$(NUL)
++      ${mkdir} ntoskrnl$(SEP)ex$(SEP)$(ARCH) 2>$(NUL)
++      ${mkdir} dll$(SEP)win32$(SEP)gdi32$(SEP)misc$(SEP)$(ARCH) 2>$(NUL)
++      ${mkdir} dll$(SEP)win32$(SEP)user32$(SEP)misc$(SEP)$(ARCH) 2>$(NUL)
+       $(Q)$(NCI_TARGET) -arch $(ARCH) \
                $(KERNEL_SVC_DB) \
                $(WIN32K_SVC_DB) \
                $(KERNEL_SERVICE_TABLE) \
  #if defined(__GNUC__)
  #define UserModeStub_x86    "    movl $0x%x, %%eax\n" \
                              "    movl $KUSER_SHARED_SYSCALL, %%ecx\n" \
 -                            "    call *%%ecx\n" \
 +                            "    call *(%%ecx)\n" \
                              "    ret $0x%x\n\n"
+ #define UserModeStub_ppc    "    mflr 0\n" \
+                           "    addi 1,1,-16\n" \
+                           "    li   0,%x\n" \
+                           "    stw  0,1(0)\n" \
+                           "    sc\n" \
+                           "    lwz  0,1(0)\n" \
+                           "    mtlr 0\n" \
+                           "    addi 1,1,16\n" \
+                           "    blr\n"
  #elif defined(_MSC_VER)
  #define UserModeStub_x86    "    asm { \n" \
                              "        mov eax, %xh\n" \
  #endif
  
  /***** Arch Dependent Stuff ******/
- //#ifdef _M_IX86
- #define ARGS_TO_BYTES(x) x*4
- #define UserModeStub UserModeStub_x86
- #define KernelModeStub KernelModeStub_x86
- //#elseif
- //#error Unsupported Architecture
- //#endif
+ struct ncitool_data_t {
+       const char *arch;
+       int args_to_bytes;
+       const char *km_stub;
+       const char *um_stub;
+       const char *global_header;
+       const char *declaration;
+ };
+ struct ncitool_data_t ncitool_data[] = {
 -      { "x86", 4, KernelModeStub_x86, UserModeStub_x86,
++      { "i386", 4, KernelModeStub_x86, UserModeStub_x86,
+         ".global _%s@%d\n", "_%s@%d:\n" },
+       { "powerpc", 4, KernelModeStub_ppc, UserModeStub_ppc,
+         "\t.globl %s\n", "%s:\n" },
 -      { 0 }
++      { 0, }
+ };
+ int arch_sel = 0;
+ #define ARGS_TO_BYTES(x) 4*(ncitool_data[arch_sel].args_to_bytes)
+ #define UserModeStub ncitool_data[arch_sel].um_stub
+ #define KernelModeStub ncitool_data[arch_sel].km_stub
+ #define GlobalHeader ncitool_data[arch_sel].global_header
+ #define Declaration ncitool_data[arch_sel].declaration
  
  /* FUNCTIONS ****************************************************************/
  
@@@ -497,19 -524,31 +524,33 @@@ void usage(char * argv0
             "  napi.S        NTDLL stubs\n"
             "  zw.S          NTOSKRNL Zw stubs\n"
             "  win32k.S      GDI32 stubs\n"
-            "  win32k.S      USER32 stubs\n",
-            argv0
+            "  win32k.S      USER32 stubs\n"
 -         "  -arch is optional, default is x86\n",
 -           argv0
++           "  -arch is optional, default is %s\n",
++           argv0,
++           ncitool_data[0].arch
             );
  }
  
  int main(int argc, char* argv[])
  {
-     FILE * Files[Arguments];
-     int FileNumber;
+     FILE * Files[Arguments] = { };
+     int FileNumber, ArgOffset = 1;
      char * OpenType = "r";
  
 -      int i;
 -      for( i = 0; ncitool_data[arch_sel].arch && strcmp(argv[2],ncitool_data[i].arch); i++ );
 -      if (!ncitool_data[arch_sel].arch) {
 -          usage(argv[0]);
 -          return 1;
 -      }
 -      arch_sel = i;
 -      ArgOffset = 3;
+     /* Catch architecture argument */
+     if (argc > 3 && !strcmp(argv[1],"-arch")) {
++        for( arch_sel = 0; ncitool_data[arch_sel].arch; arch_sel++ )
++            if (strcmp(argv[2],ncitool_data[arch_sel].arch) == 0)
++                break;
++        if (!ncitool_data[arch_sel].arch) {
++            printf("Invalid arch '%s'\n", argv[2]);
++            usage(argv[0]);
++            return 1;
++        }
++        ArgOffset = 3;
+     }
      /* Make sure all arguments all there */
-     if (argc != Arguments + 1) {
+     if (argc != Arguments + ArgOffset) {
          usage(argv[0]);
          return(1);
      }
          
          /* Check for failure and error out if so */
          if (!Files[FileNumber]) {
-             perror(argv[FileNumber + 1]);
+             perror(argv[FileNumber + ArgOffset]);
              return (1);
          }
--    
      }
  
      /* Write the File Headers */