Synchronize with trunk.
[reactos.git] / ntoskrnl / CMakeLists.txt
index ae4148c..391868a 100644 (file)
@@ -1,4 +1,8 @@
 
+PROJECT(NTOS)
+
+spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB)
+
 include_directories(
     ${REACTOS_SOURCE_DIR}
     ${REACTOS_SOURCE_DIR}/lib/cmlib
@@ -14,15 +18,37 @@ add_definitions(
     -D_IN_KERNEL_
     -DNTDDI_VERSION=0x05020400)
 
-set_rc_compiler()
+if(NOT DEFINED NEWCC)
+    set(NEWCC FALSE)
+endif()
+
+if(NEWCC)
+    add_definitions(-DNEWCC)
+    list(APPEND SOURCE
+        cache/cachesub.c
+        cache/copysup.c
+        cache/fssup.c
+        cache/lazyrite.c
+        cache/logsup.c
+        cache/mdlsup.c
+        cache/pinsup.c)
+else()
+    list(APPEND SOURCE
+        cc/cacheman.c
+        cc/copy.c
+        cc/fs.c
+        cc/mdl.c
+        cc/pin.c
+        cc/view.c)
+endif()
 
 list(APPEND SOURCE
-    cc/cacheman.c
-    cc/copy.c
-    cc/fs.c
-    cc/mdl.c
-    cc/pin.c
-    cc/view.c
+    cache/section/io.c
+    cache/section/data.c
+    cache/section/fault.c
+    cache/section/reqtools.c
+    cache/section/sptab.c
+    cache/section/swapout.c
     config/cmalloc.c
     config/cmapi.c
     config/cmboot.c
@@ -59,12 +85,12 @@ list(APPEND SOURCE
     ex/event.c
     ex/evtpair.c
     ex/exintrin.c
-    ex/fastinterlck.c
     ex/fmutex.c
     ex/handle.c
     ex/harderr.c
     ex/hdlsterm.c
     ex/init.c
+    ex/interlocked.c
     ex/keyedevt.c
     ex/locale.c
     ex/lookas.c
@@ -92,6 +118,7 @@ list(APPEND SOURCE
     fsrtl/fsfilter.c
     fsrtl/fsrtlpc.c
     fsrtl/largemcb.c
+    fsrtl/mcb.c
     fsrtl/name.c
     fsrtl/notify.c
     fsrtl/oplock.c
@@ -102,6 +129,7 @@ list(APPEND SOURCE
     fstub/disksup.c
     fstub/fstubex.c
     fstub/halstub.c
+    fstub/translate.c
     inbv/inbv.c
     inbv/inbvport.c
     io/iomgr/adapter.c
@@ -188,19 +216,18 @@ list(APPEND SOURCE
     mm/ARM3/pool.c
     mm/ARM3/procsup.c
     mm/ARM3/section.c
+    mm/ARM3/special.c
     mm/ARM3/sysldr.c
     mm/ARM3/syspte.c
     mm/ARM3/vadnode.c
     mm/ARM3/virtual.c
     mm/ARM3/zeropage.c
-    mm/anonmem.c
     mm/balance.c
     mm/freelist.c
     mm/marea.c
     mm/mmfault.c
     mm/mminit.c
     mm/pagefile.c
-    mm/pageop.c
     mm/region.c
     mm/rmap.c
     mm/section.c
@@ -244,171 +271,188 @@ list(APPEND SOURCE
     se/token.c
     vf/driver.c
     wmi/wmi.c
-    ntoskrnl.rc
-    ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
-    ntoskrnl_${ARCH}.def)
-    
-set_source_files_properties(ntoskrnl_${ARCH}.def PROPERTIES EXTERNAL_OBJECT TRUE)
+    ntoskrnl.rc)
 
-if(ARCH MATCHES i386)
-list(APPEND SOURCE
-    config/i386/cmhardwr.c
-    ex/i386/interlck_asm.S
-    ex/i386/fastinterlck_asm.S
-    ex/i386/ioport.S
-    ke/freeldr.c
-    ke/i386/abios.c
-    ke/i386/cpu.c
-    ke/i386/context.c
-    ke/i386/ctxswitch.S
-    ke/i386/exp.c
-    ke/i386/irqobj.c
-    ke/i386/kiinit.c
-    ke/i386/ldt.c
-    ke/i386/mtrr.c
-    ke/i386/patpge.c
-    ke/i386/thrdini.c
-    ke/i386/trap.s
-    ke/i386/traphdlr.c
-    ke/i386/usercall_asm.S
-    ke/i386/usercall.c
-    ke/i386/v86vdm.c
-    mm/i386/page.c
-    mm/ARM3/i386/init.c
-    ps/i386/psctx.c
-    ps/i386/psldt.c
-    rtl/i386/stack.S
-    vdm/vdmmain.c
-    vdm/vdmexec.c)
-elseif(ARCH MATCHES amd64)
-list(APPEND SOURCE
-    config/i386/cmhardwr.c
-    ex/amd64/fastinterlck.c
-    ke/amd64/boot.S
-    ke/amd64/context.c
-    ke/amd64/cpu.c
-    ke/amd64/ctxswitch.S
-    ke/amd64/except.c
-    ke/amd64/interrupt.c
-    ke/amd64/irql.c
-    ke/amd64/kiinit.c
-    ke/amd64/spinlock.c
-    ke/amd64/stubs.c
-    ke/amd64/thrdini.c
-    ke/amd64/trap.S
-    mm/amd64/init.c
-    mm/amd64/page.c
-    ps/amd64/psctx.c)
-elseif(ARCH MATCHES arm)
-list(APPEND SOURCE
-    config/arm/cmhardwr.c
-    ke/arm/boot.s
-    ke/arm/cpu.c
-    ke/arm/ctxswtch.s
-    ke/arm/exp.c
-    ke/arm/kiinit.c
-    ke/arm/stubs_asm.s
-    ke/arm/thrdini.c
-    ke/arm/trap.s
-    ke/arm/trapc.c
-    ke/arm/usercall.c
-    mm/arm/page.c
-    mm/ARM3/arm/init.c
-    ps/arm/psctx.c
-    rtl/arm/rtlexcpt.c)
-elseif(ARCH MATCHES powerpc)
-list(APPEND SOURCE
-    config/powerpc/cmhardwr.c
-    ke/powerpc/main_asm.S
-    ke/powerpc/cpu.c
-    ke/powerpc/exp.c
-    ke/powerpc/kiinit.c
-    ke/powerpc/ppc_irq.c
-    ke/powerpc/stubs.c
-    ke/powerpc/systimer.c
-    ke/powerpc/thrdini.c
-    ke/powerpc/ctxswitch.c
-    ke/powerpc/ctxhelp.S
-    mm/powerpc/pfault.c
-    mm/powerpc/page.c)
-endif(ARCH MATCHES i386)
+list(APPEND ASM_SOURCE ex/zw.S)
+
+if(ARCH STREQUAL "i386")
+    list(APPEND ASM_SOURCE
+        ex/i386/fastinterlck_asm.S
+        ex/i386/ioport.S
+        ke/i386/ctxswitch.S
+        ke/i386/trap.s
+        ke/i386/usercall_asm.S
+        rtl/i386/stack.S)
+    list(APPEND SOURCE
+        config/i386/cmhardwr.c
+        ke/i386/abios.c
+        ke/i386/cpu.c
+        ke/i386/context.c
+        ke/i386/exp.c
+        ke/i386/irqobj.c
+        ke/i386/kiinit.c
+        ke/i386/ldt.c
+        ke/i386/mtrr.c
+        ke/i386/patpge.c
+        ke/i386/thrdini.c
+        ke/i386/traphdlr.c
+        ke/i386/usercall.c
+        ke/i386/v86vdm.c
+        mm/i386/page.c
+        mm/ARM3/i386/init.c
+        ps/i386/psctx.c
+        ps/i386/psldt.c
+        vdm/vdmmain.c
+        vdm/vdmexec.c)
+elseif(ARCH STREQUAL "amd64")
+    list(APPEND ASM_SOURCE
+        ke/amd64/boot.S
+        ke/amd64/ctxswitch.S
+        ke/amd64/trap.S)
+    list(APPEND SOURCE
+        config/i386/cmhardwr.c
+        ke/amd64/context.c
+        ke/amd64/cpu.c
+        ke/amd64/except.c
+        ke/amd64/interrupt.c
+        ke/amd64/irql.c
+        ke/amd64/kiinit.c
+        ke/amd64/krnlinit.c
+        ke/amd64/spinlock.c
+        ke/amd64/stubs.c
+        ke/amd64/thrdini.c
+        mm/amd64/init.c
+        mm/amd64/page.c
+        ps/amd64/psctx.c)
+elseif(ARCH STREQUAL "arm")
+    list(APPEND ASM_SOURCE
+        ke/arm/boot.s
+        ke/arm/ctxswtch.s
+        ke/arm/stubs_asm.s
+        ke/arm/trap.s)
+    list(APPEND SOURCE
+        config/arm/cmhardwr.c
+        ke/arm/cpu.c
+        ke/arm/exp.c
+        ke/arm/kiinit.c
+        ke/arm/thrdini.c
+        ke/arm/trapc.c
+        ke/arm/usercall.c
+        mm/arm/page.c
+        mm/ARM3/arm/init.c
+        ps/arm/psctx.c
+        rtl/arm/rtlexcpt.c)
+elseif(ARCH STREQUAL "powerpc")
+    list(APPEND ASM_SOURCE
+        ke/powerpc/main_asm.S
+        ke/powerpc/ctxhelp.S)
+    list(APPEND SOURCE
+        config/powerpc/cmhardwr.c
+        ke/powerpc/cpu.c
+        ke/powerpc/exp.c
+        ke/powerpc/kiinit.c
+        ke/powerpc/ppc_irq.c
+        ke/powerpc/stubs.c
+        ke/powerpc/systimer.c
+        ke/powerpc/thrdini.c
+        ke/powerpc/ctxswitch.c
+        mm/powerpc/pfault.c
+        mm/powerpc/page.c)
+endif()
 
 if(NOT _WINKD_)
+    if(ARCH STREQUAL "i386")
+        list(APPEND SOURCE
+            kd/i386/kdbg.c
+            kd/i386/kdmemsup.c
+            kd/wrappers/gdbstub.c)
+        if(KDBG)
+            list(APPEND ASM_SOURCE kdbg/i386/kdb_help.S)
+            list(APPEND SOURCE kdbg/i386/i386-dis.c)
+        endif()
+    elseif(ARCH STREQUAL "amd64")
+        list(APPEND SOURCE
+            kd/amd64/kd.c
+            kd/i386/kdbg.c  # Use the x86 file
+            kd/amd64/kdmemsup.c)
+        if(KDBG)
+            list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
+            list(APPEND SOURCE
+                kdbg/amd64/i386-dis.c
+                kdbg/amd64/kdb.c)
+        endif()
+    elseif(ARCH STREQUAL "arm")
+        list(APPEND SOURCE kd/arm/kdbg.c)
+    elseif(ARCH STREQUAL "powerpc")
+        list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
+    endif()
 
-if(ARCH MATCHES i386)
-list(APPEND SOURCE
-    kd/i386/kdmemsup.c
-    kd/wrappers/gdbstub.c)
+    if(KDBG)
+        list(APPEND SOURCE
+            kdbg/kdb.c
+            kdbg/kdb_cli.c
+            kdbg/kdb_expr.c
+            kdbg/kdb_keyboard.c
+            kdbg/kdb_serial.c)
+    endif()
 
-if(KDBG)
-list(APPEND SOURCE
-    kdbg/i386/i386-dis.c
-    kdbg/i386/kdb_help.S)
-endif(KDBG)
+    if(DBG OR KDBG)
+        #list(APPEND SOURCE kdbg/kdb_symbols.cmake.c)
+        list(APPEND SOURCE kdbg/kdb_symbols.c)
+    endif()
 
-elseif(ARCH MATCHES amd64)
-list(APPEND SOURCE
-    kd/amd64/kd.c
-    kd/amd64/kdmemsup.c)
+    list(APPEND SOURCE
+        kd/wrappers/bochs.c
+        kd/wrappers/kdbg.c
+        kd/kdinit.c
+        kd/kdio.c
+        kd/kdmain.c)
 
-if(KDBG)
-list(APPEND SOURCE
-    kdbg/amd64/i386-dis.c
-    kdbg/amd64/kdb_help.S
-    kdbg/amd64/kdb.c)
-endif(KDBG)
+else() # _WINKD_
 
-elseif(ARCH MATCHES powerpc)
-list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
+    list(APPEND SOURCE
+        kd64/kdapi.c
+        kd64/kdbreak.c
+        kd64/kddata.c
+        kd64/kdinit.c
+        kd64/kdlock.c
+        kd64/kdprint.c
+        kd64/kdtrap.c)
 
-endif(ARCH MATCHES i386)
+    if(ARCH STREQUAL "i386")
+        list(APPEND SOURCE kd64/i386/kdx86.c)
+    elseif(ARCH STREQUAL "amd64")
+        list(APPEND SOURCE kd64/amd64/kdx64.c)
+    elseif(ARCH STREQUAL "arm")
+        list(APPEND SOURCE kd64/arm/kdarm.c)
+    endif()
 
-if(KDBG)
-list(APPEND SOURCE
-    kdbg/kdb.c
-    kdbg/kdb_cli.c
-    kdbg/kdb_expr.c
-    kdbg/kdb_keyboard.c
-    kdbg/kdb_serial.c)
-endif(KDBG)
+endif()
 
-if(DBG OR KDBG)
-list(APPEND SOURCE kdbg/kdb_symbols.c)
-endif(DBG OR KDBG)
+add_asm_files(ntoskrnl_asm ${ASM_SOURCE})
 
-list(APPEND SOURCE
-    kd/wrappers/bochs.c
-    kd/wrappers/kdbg.c
-    kd/kdinit.c
-    kd/kdio.c
-    kd/kdmain.c)
+add_executable(ntoskrnl
+    ${ntoskrnl_asm}
+    ${SOURCE}
+    ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
 
-else() # _WINKD_
-
-list(APPEND SOURCE
-    kd64/kdapi.c
-    kd64/kdbreak.c
-    kd64/kddata.c
-    kd64/kdinit.c
-    kd64/kdlock.c
-    kd64/kdprint.c
-    kd64/kdtrap.c)
-
-if(ARCH MATCHES i386)
-list(APPEND SOURCE kd64/i386/kdx86.c)
-elseif(ARCH MATCHES amd64)
-list(APPEND SOURCE kd64/amd64/kdx64.c)
-elseif(ARCH MATCHES arm)
-list(APPEND SOURCE kd64/arm/kdarm.c)
-endif(ARCH MATCHES i386)
-
-endif(NOT _WINKD_)
-
-add_executable(ntoskrnl ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl_ntoskrnl.h.gch ${SOURCE})
-
-set_entrypoint(ntoskrnl KiSystemStartup@4)
+if(ARCH STREQUAL "i386")
+    set_entrypoint(ntoskrnl KiSystemStartup 4)
+else()
+    set_entrypoint(ntoskrnl KiSystemStartup)
+endif()
 set_subsystem(ntoskrnl native)
-set_image_base(ntoskrnl 0x80800000)
+
+if(MSVC)
+    set_image_base(ntoskrnl 0x00400000)
+else()
+    set_image_base(ntoskrnl 0x80800000)
+endif()
+
+# Linker bug
+if(NOT MSVC AND LTCG)
+    add_target_link_flags(ntoskrnl "-shared")
+endif()
 
 target_link_libraries(ntoskrnl
     cportlib
@@ -420,13 +464,52 @@ target_link_libraries(ntoskrnl
     libcntpr
     wdmguid
     ioevent)
-    
+
 add_importlibs(ntoskrnl hal kdcom bootvid)
+add_pch(ntoskrnl include/ntoskrnl.h)
+add_dependencies(ntoskrnl psdk bugcodes asm)
+add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
+
+if(BUILD_MP)
+    spec2def(ntkrnlmp.exe ntoskrnl.spec)
+
+    if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
+        set_source_files_properties(${ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "CONFIG_SMP")
+    endif()
+
+    add_asm_files(ntkrnlmp_asm ${ASM_SOURCE})
+
+    add_executable(ntkrnlmp
+        ${ntkrnlmp_asm}
+        ${SOURCE}
+        ${CMAKE_CURRENT_BINARY_DIR}/ntkrnlmp.def)
+
+    add_target_compile_definitions(ntkrnlmp CONFIG_SMP)
+
+    if(ARCH STREQUAL "i386")
+        set_entrypoint(ntkrnlmp KiSystemStartup 4)
+    else()
+        set_entrypoint(ntkrnlmp KiSystemStartup)
+    endif()
+    set_subsystem(ntkrnlmp native)
+
+    if(MSVC)
+        set_image_base(ntkrnlmp 0x00400000)
+    else()
+        set_image_base(ntkrnlmp 0x80800000)
+    endif()
+
+    # Linker bug
+    if(NOT MSVC AND LTCG)
+        add_target_link_flags(ntkrnlmp "-shared")
+    endif()
 
-add_pch(ntoskrnl ${CMAKE_CURRENT_SOURCE_DIR}/include/ntoskrnl.h ${SOURCE})
-set_source_files_properties(${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S PROPERTIES GENERATED TRUE)
-add_dependencies(ntoskrnl psdk bugcodes kernel_zw kernel_napi asm)
+    target_link_libraries(ntkrnlmp cportlib csq ${PSEH_LIB} cmlib rtl rossym libcntpr wdmguid ioevent)
+    add_importlibs(ntkrnlmp hal kdcom bootvid)
+    add_dependencies(ntkrnlmp psdk bugcodes asm)
+    add_cd_file(TARGET ntkrnlmp DESTINATION reactos/system32 NO_CAB FOR all)
+endif()
 
-add_minicd_target(ntoskrnl reactos ntoskrnl.exe)
-add_livecd_target(ntoskrnl reactos/system32)
-add_importlib_target(ntoskrnl.spec)
+add_asm_files(ntdllsys_asm ntdll.S)
+add_library(ntdllsys ${ntdllsys_asm})
+set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")