diff --git a/reactos/dll/ntdll/ntdll.rbuild b/reactos/dll/ntdll/ntdll.rbuild
index 0661b0449d9..e5d0a75c8cb 100644
--- a/reactos/dll/ntdll/ntdll.rbuild
+++ b/reactos/dll/ntdll/ntdll.rbuild
@@ -47,5 +47,19 @@
ntdll.h
- napi.S
+
+
+ napi.S
+
+
+
+
+ napi.S
+
+
+
+
+ napi.S
+
+
diff --git a/reactos/dll/win32/gdi32/gdi32.rbuild b/reactos/dll/win32/gdi32/gdi32.rbuild
index 04af324c929..4f9702180c4 100644
--- a/reactos/dll/win32/gdi32/gdi32.rbuild
+++ b/reactos/dll/win32/gdi32/gdi32.rbuild
@@ -22,8 +22,22 @@
stubs.c
stubsa.c
stubsw.c
- win32k.S
wingl.c
+
+
+ win32k.S
+
+
+
+
+ win32k.S
+
+
+
+
+ win32k.S
+
+
bitmap.c
diff --git a/reactos/dll/win32/user32/user32.rbuild b/reactos/dll/win32/user32/user32.rbuild
index 2d8d6cf50fe..fd1461143e5 100644
--- a/reactos/dll/win32/user32/user32.rbuild
+++ b/reactos/dll/win32/user32/user32.rbuild
@@ -43,10 +43,24 @@
strpool.c
stubs.c
timer.c
- win32k.S
winhelp.c
winsta.c
wsprintf.c
+
+
+ win32k.S
+
+
+
+
+ win32k.S
+
+
+
+
+ win32k.S
+
+
accel.c
diff --git a/reactos/ntoskrnl/ntoskrnl.rbuild b/reactos/ntoskrnl/ntoskrnl.rbuild
index 1feaa572b4b..d94dd7a424c 100644
--- a/reactos/ntoskrnl/ntoskrnl.rbuild
+++ b/reactos/ntoskrnl/ntoskrnl.rbuild
@@ -103,6 +103,17 @@
interlck_asm.S
fastinterlck_asm.S
ioport.S
+ zw.S
+
+
+
+
+ zw.S
+
+
+
+
+ zw.S
atom.c
@@ -132,7 +143,6 @@
win32k.c
work.c
zone.c
- zw.S
dbcsname.c
diff --git a/reactos/tools/nci/nci.mak b/reactos/tools/nci/nci.mak
index f98e801a519..fdf14bcd6be 100644
--- a/reactos/tools/nci/nci.mak
+++ b/reactos/tools/nci/nci.mak
@@ -44,14 +44,14 @@ clean: nci_clean
# 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) \
@@ -63,7 +63,11 @@ NCI_SERVICE_FILES = \
$(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) \
diff --git a/reactos/tools/nci/ncitool.c b/reactos/tools/nci/ncitool.c
index 6083b90b410..908c3cd939c 100644
--- a/reactos/tools/nci/ncitool.c
+++ b/reactos/tools/nci/ncitool.c
@@ -53,6 +53,16 @@
" movl $KUSER_SHARED_SYSCALL, %%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" \
@@ -75,6 +85,9 @@
" pushl $KGDT_R0_CODE\n" \
" call _KiSystemService\n" \
" ret $0x%x\n\n"
+
+#define KernelModeStub_ppc " bl KiSystemService\n" \
+ " rfi\n"
#elif defined(_MSC_VER)
#define KernelModeStub_x86 " asm { \n" \
" mov eax, %xh\n" \
@@ -89,14 +102,28 @@
#endif
/***** Arch Dependent Stuff ******/
-//#ifdef _M_IX86
-#define ARGS_TO_BYTES(x) x*4
-#define UserModeStub UserModeStub_x86
-#define KernelModeStub KernelModeStub_x86
+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;
+};
-//#elseif
-//#error Unsupported Architecture
-//#endif
+struct ncitool_data_t ncitool_data[] = {
+ { "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, }
+};
+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 ****************************************************************/
@@ -162,10 +189,10 @@ WriteStubHeader(FILE* StubFile,
unsigned StackBytes)
{
/* Export the function */
- fprintf(StubFile, ".global _%s@%d\n", SyscallName, StackBytes);
+ fprintf(StubFile, GlobalHeader, SyscallName, StackBytes);
/* Define it */
- fprintf(StubFile, "_%s@%d:\n\n", SyscallName, StackBytes);
+ fprintf(StubFile, Declaration, SyscallName, StackBytes);
}
@@ -489,7 +516,7 @@ CreateSystemServiceTable(FILE *SyscallDb,
void usage(char * argv0)
{
- printf("Usage: %s sysfuncs.lst w32ksvc.db napi.h ssdt.h napi.S zw.S win32k.S win32k.S\n"
+ printf("Usage: %s [-arch ] sysfuncs.lst w32ksvc.db napi.h ssdt.h napi.S zw.S win32k.S win32k.S\n"
" sysfuncs.lst native system functions database\n"
" w32ksvc.db native graphic functions database\n"
" napi.h NTOSKRNL service table\n"
@@ -497,19 +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 %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";
+ /* 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);
}
@@ -519,33 +560,32 @@ int main(int argc, char* argv[])
/* Open the File */
if (FileNumber == 2) OpenType = "wb";
- Files[FileNumber] = fopen(argv[FileNumber + 1], OpenType);
+ Files[FileNumber] = fopen(argv[FileNumber + ArgOffset], OpenType);
/* 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 */
WriteFileHeader(Files[NtosUserStubs],
"System Call Stubs for Native API",
- argv[NtosUserStubs + 1]);
+ argv[NtosUserStubs + ArgOffset]);
WriteFileHeader(Files[NtosKernelStubs],
"System Call Stubs for Native API",
- argv[NtosKernelStubs + 1]);
+ argv[NtosKernelStubs + ArgOffset]);
fputs("#include \n\n", Files[NtosKernelStubs]);
WriteFileHeader(Files[Win32kGdiStubs],
"System Call Stubs for Native API",
- argv[Win32kGdiStubs + 1]);
+ argv[Win32kGdiStubs + ArgOffset]);
WriteFileHeader(Files[Win32kUserStubs],
"System Call Stubs for Native API",
- argv[Win32kUserStubs + 1]);
+ argv[Win32kUserStubs + ArgOffset]);
/* Create the System Stubs */
@@ -572,15 +612,15 @@ int main(int argc, char* argv[])
CreateSystemServiceTable(Files[NativeSystemDb],
Files[NtosServiceTable],
"Main",
- argv[NtosServiceTable + 1]);
+ argv[NtosServiceTable + ArgOffset]);
CreateSystemServiceTable(Files[NativeGuiDb],
Files[Win32kServiceTable],
"Win32k",
- argv[Win32kServiceTable + 1]);
+ argv[Win32kServiceTable + ArgOffset]);
/* Close all files */
- for (FileNumber = 0; FileNumber < Arguments; FileNumber++) {
+ for (FileNumber = 0; FileNumber < Arguments-ArgOffset; FileNumber++) {
/* Close the File */
fclose(Files[FileNumber]);