Author: arty
Date: Sun Jun 25 01:27:06 2006
New Revision: 22591
URL:
http://svn.reactos.org/svn/reactos?rev=22591&view=rev
Log:
PowerPC WIP. Some of this is indeed hacky and will be changed.
Added:
branches/powerpc/reactos/tools/ppc.lost+found/
branches/powerpc/reactos/tools/ppc.lost+found/link-ntoskrnl (with props)
branches/powerpc/reactos/tools/ppc.lost+found/pmake (with props)
Modified:
branches/powerpc/reactos/tools/nci/nci.mak
branches/powerpc/reactos/tools/nci/ncitool.c
branches/powerpc/reactos/tools/pefixup.mak
branches/powerpc/reactos/tools/rsym.c
branches/powerpc/reactos/tools/rsym.h
branches/powerpc/reactos/tools/ssprintf.cpp
branches/powerpc/reactos/tools/wrc/newstruc.c
branches/powerpc/reactos/tools/wrc/wrc.mak
branches/powerpc/reactos/tools/wrc/wrctypes.h
Modified: branches/powerpc/reactos/tools/nci/nci.mak
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/nci/nci.m…
==============================================================================
--- branches/powerpc/reactos/tools/nci/nci.mak (original)
+++ branches/powerpc/reactos/tools/nci/nci.mak Sun Jun 25 01:27:06 2006
@@ -30,11 +30,11 @@
$(NCI_TARGET): $(NCI_OBJECTS) | $(NCI_OUT)
$(ECHO_LD)
- ${host_gcc} $(NCI_OBJECTS) $(NCI_HOST_LFLAGS) -o $@
+ ${host_gcc} -g $(NCI_OBJECTS) $(NCI_HOST_LFLAGS) -o $@
$(NCI_INT_)ncitool.o: $(NCI_BASE_)ncitool.c | $(NCI_INT)
$(ECHO_CC)
- ${host_gcc} $(NCI_HOST_CFLAGS) -c $< -o $@
+ ${host_gcc} -g $(NCI_HOST_CFLAGS) -c $< -o $@
.PHONY: nci_clean
nci_clean:
@@ -63,7 +63,7 @@
$(NCI_SERVICE_FILES): $(NCI_TARGET) $(KERNEL_SVC_DB) $(WIN32K_SVC_DB)
$(ECHO_NCI)
- $(Q)$(NCI_TARGET) \
+ $(Q)$(NCI_TARGET) -arch $(ARCH) \
$(KERNEL_SVC_DB) \
$(WIN32K_SVC_DB) \
$(KERNEL_SERVICE_TABLE) \
Modified: branches/powerpc/reactos/tools/nci/ncitool.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/nci/ncito…
==============================================================================
--- branches/powerpc/reactos/tools/nci/ncitool.c (original)
+++ branches/powerpc/reactos/tools/nci/ncitool.c Sun Jun 25 01:27:06 2006
@@ -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
-
-//#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,
+ ".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 @@
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 @@
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 <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,31 @@
" napi.S NTDLL stubs\n"
" zw.S NTOSKRNL Zw stubs\n"
" win32k.S GDI32 stubs\n"
- " win32k.S USER32 stubs\n",
+ " win32k.S USER32 stubs\n"
+ " -arch is optional, default is x86\n",
argv0
);
}
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")) {
+ 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;
+ }
/* Make sure all arguments all there */
- if (argc != Arguments + 1) {
+ if (argc != Arguments + ArgOffset) {
usage(argv[0]);
return(1);
}
@@ -519,11 +558,11 @@
/* 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);
}
@@ -532,20 +571,20 @@
/* 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 <ndk/asm.h>\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 +611,15 @@
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]);
Modified: branches/powerpc/reactos/tools/pefixup.mak
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/pefixup.m…
==============================================================================
--- branches/powerpc/reactos/tools/pefixup.mak (original)
+++ branches/powerpc/reactos/tools/pefixup.mak Sun Jun 25 01:27:06 2006
@@ -24,11 +24,11 @@
$(PEFIXUP_TARGET): $(PEFIXUP_OBJECTS) | $(PEFIXUP_OUT)
$(ECHO_LD)
- ${host_gcc} $(PEFIXUP_OBJECTS) $(PEFIXUP_HOST_LFLAGS) -o $@
+ ${host_gcc} -g $(PEFIXUP_OBJECTS) $(PEFIXUP_HOST_LFLAGS) -o $@
$(PEFIXUP_INT_)pefixup.o: $(PEFIXUP_BASE_)pefixup.c | $(PEFIXUP_INT)
$(ECHO_CC)
- ${host_gcc} $(PEFIXUP_HOST_CFLAGS) -c $< -o $@
+ ${host_gcc} -g $(PEFIXUP_HOST_CFLAGS) -c $< -o $@
.PHONY: pefixup_clean
pefixup_clean:
Added: branches/powerpc/reactos/tools/ppc.lost+found/link-ntoskrnl
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc.lost%…
==============================================================================
--- branches/powerpc/reactos/tools/ppc.lost+found/link-ntoskrnl (added)
+++ branches/powerpc/reactos/tools/ppc.lost+found/link-ntoskrnl Sun Jun 25 01:27:06 2006
@@ -1,0 +1,3 @@
+#!/bin/sh -xv
+
+reactos-powerpc-gcc --begin-group -v -Wl,--subsystem,native -Wl,--entry,NtProcessStartup
-Wl,--image-base,0x80000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000
-nostartfiles -shared ntoskrnl.temp.exp -o output-ppc/ntoskrnl/ntoskrnl.exe
obj-ppc/ntoskrnl/ke/powerpc/main_asm.o obj-ppc/ntoskrnl/ke/apc.o obj-ppc/ntoskrnl/ke/bug.o
obj-ppc/ntoskrnl/ke/clock.o obj-ppc/ntoskrnl/ke/device.o obj-ppc/ntoskrnl/ke/dpc.o
obj-ppc/ntoskrnl/ke/event.o obj-ppc/ntoskrnl/ke/exception.o obj-ppc/ntoskrnl/ke/gate.o
obj-ppc/ntoskrnl/ke/gmutex.o obj-ppc/ntoskrnl/ke/ipi.o obj-ppc/ntoskrnl/ke/kqueue.o
obj-ppc/ntoskrnl/ke/kthread.o obj-ppc/ntoskrnl/ke/main.o obj-ppc/ntoskrnl/ke/mutex.o
obj-ppc/ntoskrnl/ke/process.o obj-ppc/ntoskrnl/ke/profile.o obj-ppc/ntoskrnl/ke/queue.o
obj-ppc/ntoskrnl/ke/sem.o obj-ppc/ntoskrnl/ke/spinlock.o obj-ppc/ntoskrnl/ke/timer.o
obj-ppc/ntoskrnl/ke/usercall.o obj-ppc/ntoskrnl/ke/wait.o obj-ppc/ntoskrnl/cc/cacheman.o
obj-ppc/ntoskrnl/cc/copy.o obj-ppc/ntoskrnl/cc/fs.o obj-ppc/ntoskrnl/cc/mdl.o
obj-ppc/ntoskrnl/cc/pin.o obj-ppc/ntoskrnl/cc/view.o obj-ppc/ntoskrnl/cm/import.o
obj-ppc/ntoskrnl/cm/ntfunc.o obj-ppc/ntoskrnl/cm/regfile.o obj-ppc/ntoskrnl/cm/registry.o
obj-ppc/ntoskrnl/cm/regobj.o obj-ppc/ntoskrnl/dbgk/dbgkutil.o
obj-ppc/ntoskrnl/dbgk/debug.o obj-ppc/ntoskrnl/ex/atom.o obj-ppc/ntoskrnl/ex/callback.o
obj-ppc/ntoskrnl/ex/dbgctrl.o obj-ppc/ntoskrnl/ex/error.o obj-ppc/ntoskrnl/ex/event.o
obj-ppc/ntoskrnl/ex/evtpair.o obj-ppc/ntoskrnl/ex/fmutex.o obj-ppc/ntoskrnl/ex/handle.o
obj-ppc/ntoskrnl/ex/init.o obj-ppc/ntoskrnl/ex/lookas.o obj-ppc/ntoskrnl/ex/mutant.o
obj-ppc/ntoskrnl/ex/power.o obj-ppc/ntoskrnl/ex/pushlock.o obj-ppc/ntoskrnl/ex/profile.o
obj-ppc/ntoskrnl/ex/resource.o obj-ppc/ntoskrnl/ex/rundown.o obj-ppc/ntoskrnl/ex/sem.o
obj-ppc/ntoskrnl/ex/sysinfo.o obj-ppc/ntoskrnl/ex/time.o obj-ppc/ntoskrnl/ex/timer.o
obj-ppc/ntoskrnl/ex/uuid.o obj-ppc/ntoskrnl/ex/win32k.o obj-ppc/ntoskrnl/ex/work.o
obj-ppc/ntoskrnl/ex/zone.o obj-ppc/ntoskrnl/ex/zw.o obj-ppc/ntoskrnl/fs/context.o
obj-ppc/ntoskrnl/fs/fastio.o obj-ppc/ntoskrnl/fs/filelock.o obj-ppc/ntoskrnl/fs/mcb.o
obj-ppc/ntoskrnl/fs/name.o obj-ppc/ntoskrnl/fs/notify.o obj-ppc/ntoskrnl/fs/oplock.o
obj-ppc/ntoskrnl/fs/pool.o obj-ppc/ntoskrnl/fs/tunnel.o obj-ppc/ntoskrnl/fs/unc.o
obj-ppc/ntoskrnl/fs/util.o obj-ppc/ntoskrnl/inbv/inbv.o obj-ppc/ntoskrnl/io/adapter.o
obj-ppc/ntoskrnl/io/arcname.o obj-ppc/ntoskrnl/io/bootlog.o
obj-ppc/ntoskrnl/io/controller.o obj-ppc/ntoskrnl/io/device.o
obj-ppc/ntoskrnl/io/deviface.o obj-ppc/ntoskrnl/io/disk.o obj-ppc/ntoskrnl/io/driver.o
obj-ppc/ntoskrnl/io/efi.o obj-ppc/ntoskrnl/io/error.o obj-ppc/ntoskrnl/io/event.o
obj-ppc/ntoskrnl/io/fs.o obj-ppc/ntoskrnl/io/iocomp.o obj-ppc/ntoskrnl/io/iomgr.o
obj-ppc/ntoskrnl/io/iowork.o obj-ppc/ntoskrnl/io/irp.o obj-ppc/ntoskrnl/io/irq.o
obj-ppc/ntoskrnl/io/mdl.o obj-ppc/ntoskrnl/io/plugplay.o obj-ppc/ntoskrnl/io/pnpdma.o
obj-ppc/ntoskrnl/io/pnpmgr.o obj-ppc/ntoskrnl/io/pnpnotify.o
obj-ppc/ntoskrnl/io/pnpreport.o obj-ppc/ntoskrnl/io/pnproot.o obj-ppc/ntoskrnl/io/rawfs.o
obj-ppc/ntoskrnl/io/remlock.o obj-ppc/ntoskrnl/io/resource.o obj-ppc/ntoskrnl/io/share.o
obj-ppc/ntoskrnl/io/symlink.o obj-ppc/ntoskrnl/io/timer.o obj-ppc/ntoskrnl/io/vpb.o
obj-ppc/ntoskrnl/io/wmi.o obj-ppc/ntoskrnl/io/file.o obj-ppc/ntoskrnl/kd/wrappers/bochs.o
obj-ppc/ntoskrnl/kd/wrappers/gdbstub.o obj-ppc/ntoskrnl/kd/kdinit.o
obj-ppc/ntoskrnl/kd/kdio.o obj-ppc/ntoskrnl/kd/kdmain.o obj-ppc/ntoskrnl/ldr/loader.o
obj-ppc/ntoskrnl/ldr/rtl.o obj-ppc/ntoskrnl/lpc/close.o obj-ppc/ntoskrnl/lpc/complete.o
obj-ppc/ntoskrnl/lpc/connect.o obj-ppc/ntoskrnl/lpc/create.o obj-ppc/ntoskrnl/lpc/listen.o
obj-ppc/ntoskrnl/lpc/port.o obj-ppc/ntoskrnl/lpc/query.o obj-ppc/ntoskrnl/lpc/queue.o
obj-ppc/ntoskrnl/lpc/receive.o obj-ppc/ntoskrnl/lpc/reply.o obj-ppc/ntoskrnl/lpc/send.o
obj-ppc/ntoskrnl/mm/anonmem.o obj-ppc/ntoskrnl/mm/aspace.o obj-ppc/ntoskrnl/mm/balance.o
obj-ppc/ntoskrnl/mm/cont.o obj-ppc/ntoskrnl/mm/drvlck.o obj-ppc/ntoskrnl/mm/freelist.o
obj-ppc/ntoskrnl/mm/iospace.o obj-ppc/ntoskrnl/mm/kmap.o obj-ppc/ntoskrnl/mm/marea.o
obj-ppc/ntoskrnl/mm/mdl.o obj-ppc/ntoskrnl/mm/mm.o obj-ppc/ntoskrnl/mm/process.o
obj-ppc/ntoskrnl/mm/mminit.o obj-ppc/ntoskrnl/mm/mpw.o obj-ppc/ntoskrnl/mm/ncache.o
obj-ppc/ntoskrnl/mm/npool.o obj-ppc/ntoskrnl/mm/pagefile.o obj-ppc/ntoskrnl/mm/pageop.o
obj-ppc/ntoskrnl/mm/pager.o obj-ppc/ntoskrnl/mm/pagfault.o obj-ppc/ntoskrnl/mm/paging.o
obj-ppc/ntoskrnl/mm/pe.o obj-ppc/ntoskrnl/mm/physical.o obj-ppc/ntoskrnl/mm/pool.o
obj-ppc/ntoskrnl/mm/ppool.o obj-ppc/ntoskrnl/mm/region.o obj-ppc/ntoskrnl/mm/rmap.o
obj-ppc/ntoskrnl/mm/section.o obj-ppc/ntoskrnl/mm/verifier.o obj-ppc/ntoskrnl/mm/virtual.o
obj-ppc/ntoskrnl/mm/wset.o obj-ppc/ntoskrnl/mm/elf32.o obj-ppc/ntoskrnl/mm/elf64.o
obj-ppc/ntoskrnl/ob/obdir.o obj-ppc/ntoskrnl/ob/obinit.o obj-ppc/ntoskrnl/ob/obhandle.o
obj-ppc/ntoskrnl/ob/obname.o obj-ppc/ntoskrnl/ob/oblife.o obj-ppc/ntoskrnl/ob/obref.o
obj-ppc/ntoskrnl/ob/sdcache.o obj-ppc/ntoskrnl/ob/security.o obj-ppc/ntoskrnl/ob/symlink.o
obj-ppc/ntoskrnl/ob/wait.o obj-ppc/ntoskrnl/po/power.o obj-ppc/ntoskrnl/ps/debug.o
obj-ppc/ntoskrnl/ps/idle.o obj-ppc/ntoskrnl/ps/job.o obj-ppc/ntoskrnl/ps/kill.o
obj-ppc/ntoskrnl/ps/locale.o obj-ppc/ntoskrnl/ps/notify.o obj-ppc/ntoskrnl/ps/process.o
obj-ppc/ntoskrnl/ps/psmgr.o obj-ppc/ntoskrnl/ps/query.o obj-ppc/ntoskrnl/ps/quota.o
obj-ppc/ntoskrnl/ps/security.o obj-ppc/ntoskrnl/ps/suspend.o obj-ppc/ntoskrnl/ps/thread.o
obj-ppc/ntoskrnl/ps/win32.o obj-ppc/ntoskrnl/rtl/libsupp.o obj-ppc/ntoskrnl/rtl/misc.o
obj-ppc/ntoskrnl/rtl/nls.o obj-ppc/ntoskrnl/rtl/regio.o obj-ppc/ntoskrnl/rtl/strtok.o
obj-ppc/ntoskrnl/se/access.o obj-ppc/ntoskrnl/se/acl.o obj-ppc/ntoskrnl/se/audit.o
obj-ppc/ntoskrnl/se/lsa.o obj-ppc/ntoskrnl/se/luid.o obj-ppc/ntoskrnl/se/priv.o
obj-ppc/ntoskrnl/se/sd.o obj-ppc/ntoskrnl/se/semgr.o obj-ppc/ntoskrnl/se/sid.o
obj-ppc/ntoskrnl/se/token.o obj-ppc/ntoskrnl/ntoskrnl.coff
obj-ppc/ntoskrnl/kdbg/kdb_symbols.o obj-ppc/lib/drivers/csq/csq.a obj-ppc/hal/hal/libhal.a
obj-ppc/lib/kjs/kjs.a obj-ppc/lib/pseh/pseh.a obj-ppc/lib/rtl/rtl.a
obj-ppc/lib/rossym/rossym.a obj-ppc/lib/string/string.a obj-ppc/lib/wdmguid/wdmguid.a
-nostartfiles -nostdlib -lgcc -g --end-group
Propchange: branches/powerpc/reactos/tools/ppc.lost+found/link-ntoskrnl
------------------------------------------------------------------------------
svn:executable = *
Added: branches/powerpc/reactos/tools/ppc.lost+found/pmake
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc.lost%…
==============================================================================
--- branches/powerpc/reactos/tools/ppc.lost+found/pmake (added)
+++ branches/powerpc/reactos/tools/ppc.lost+found/pmake Sun Jun 25 01:27:06 2006
@@ -1,0 +1,12 @@
+#!/bin/sh
+
+export PATH=$PATH:/usr/local/pkg/reactos-powerpc/bin
+make \
+ HOST=mingw32-linux \
+ ROS_INTERMEDIATE=obj-ppc \
+ ROS_OUTPUT=output-ppc \
+ ROS_PREFIX=reactos-powerpc \
+ ROS_INSTALL=rosppc \
+ ROS_AUTOMAKE=makefile.ppc \
+ ROS_RBUILDFLAGS=-rReactOS-ppc.rbuild \
+ $*
Propchange: branches/powerpc/reactos/tools/ppc.lost+found/pmake
------------------------------------------------------------------------------
svn:executable = *
Modified: branches/powerpc/reactos/tools/rsym.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/rsym.c?re…
==============================================================================
--- branches/powerpc/reactos/tools/rsym.c (original)
+++ branches/powerpc/reactos/tools/rsym.c Sun Jun 25 01:27:06 2006
@@ -26,6 +26,35 @@
#include <assert.h>
#include "rsym.h"
+
+static inline WORD dtohs(WORD in)
+{
+ PBYTE in_ptr = (PBYTE)∈
+ return in_ptr[0] | (in_ptr[1] << 8);
+}
+
+static inline WORD htods(WORD in)
+{
+ WORD out;
+ PBYTE out_ptr = (PBYTE)&out;
+ out_ptr[0] = in; out_ptr[1] = in >> 8;
+ return out;
+}
+
+static inline DWORD dtohl(DWORD in)
+{
+ PBYTE in_ptr = (PBYTE)∈
+ return in_ptr[0] | (in_ptr[1] << 8) | (in_ptr[2] << 16) | (in_ptr[3]
<< 24);
+}
+
+static inline DWORD htodl(DWORD in)
+{
+ DWORD out;
+ PBYTE out_ptr = (PBYTE)&out;
+ out_ptr[0] = in ; out_ptr[1] = in >> 8;
+ out_ptr[2] = in >> 16; out_ptr[3] = in >> 24;
+ return out;
+}
static int
CompareSymEntry(const PROSSYM_ENTRY SymEntry1, const PROSSYM_ENTRY SymEntry2)
@@ -814,6 +843,9 @@
/* Check if MZ header exists */
PEDosHeader = (PIMAGE_DOS_HEADER) FileData;
+ PEDosHeader->e_magic = dtohs(PEDosHeader->e_magic);
+ PEDosHeader->e_lfanew = dtohl(PEDosHeader->e_lfanew);
+
if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC || PEDosHeader->e_lfanew == 0L)
{
perror("Input file is not a PE image.\n");
Modified: branches/powerpc/reactos/tools/rsym.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/rsym.h?re…
==============================================================================
--- branches/powerpc/reactos/tools/rsym.h (original)
+++ branches/powerpc/reactos/tools/rsym.h Sun Jun 25 01:27:06 2006
@@ -10,7 +10,7 @@
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
-typedef unsigned char BYTE;
+typedef unsigned char BYTE, *PBYTE;
typedef unsigned char UCHAR;
typedef unsigned short WORD;
typedef unsigned short USHORT;
Modified: branches/powerpc/reactos/tools/ssprintf.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ssprintf.…
==============================================================================
--- branches/powerpc/reactos/tools/ssprintf.cpp (original)
+++ branches/powerpc/reactos/tools/ssprintf.cpp Sun Jun 25 01:27:06 2006
@@ -690,6 +690,7 @@
return true;
}
+#ifdef __i386__
static bool
numberfl(std::string& f, long double __n, char exp_sign, int size, int precision,
int type)
{
@@ -1091,6 +1092,7 @@
}
return true;
}
+#endif
static int
do_string(std::string& f, const char* s, int len, int field_width, int precision, int
flags)
@@ -1507,7 +1509,9 @@
} else {
if ( precision == -1 )
precision = 6;
+#ifdef __i386__
result = numberfl(f,_ldouble,*fmt,field_width,precision,flags);
+#endif
if (result < 0)
{
assert(!"TODO FIXME handle error better");
@@ -1831,7 +1835,9 @@
} else {
if ( precision == -1 )
precision = 6;
+#ifdef __i386__
result = wnumberfl(f,_ldouble,*fmt,field_width,precision,flags);
+#endif
if (result < 0)
{
assert(!"TODO FIXME handle error better");
Modified: branches/powerpc/reactos/tools/wrc/newstruc.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/wrc/newst…
==============================================================================
--- branches/powerpc/reactos/tools/wrc/newstruc.c (original)
+++ branches/powerpc/reactos/tools/wrc/newstruc.c Sun Jun 25 01:27:06 2006
@@ -68,6 +68,29 @@
__NEW_STRUCT_FUNC(string)
__NEW_STRUCT_FUNC(toolbar_item)
__NEW_STRUCT_FUNC(ani_any)
+
+void hdump( void *v, int l ) {
+ int i;
+ char *c = (char *)v, *begin = c;
+
+ while( l > 0 ) {
+ if( (c - begin) )
+ printf("\n");
+ printf("%08x:", c);
+ for( i = 0; i < l && i < 16; i++ ) {
+ printf(" %02x", c[i] & 0xff);
+ }
+ for( ; i < 16; i++ ) {
+ printf(" ");
+ }
+ printf(" -- ");
+ for( i = 0; i < l && i < 16; i++ ) {
+ printf("%c", isprint(c[i]) ? c[i] : '.');
+ }
+ c += 16; l -= 16;
+ }
+ printf("\n");
+}
/* New instances for all types of structures */
/* Very inefficient (in size), but very functional :-]
@@ -984,7 +1007,10 @@
return w;
}
-#define MSGTAB_BAD_PTR(p, b, l, r) (((l) - ((char *)(p) - (char *)(b))) > (r))
+#define MSGTAB_BAD_PTR(p, b, l, r) \
+ (printf("MSGTAB_BAD_PTR(%x,%x,%d,r) => %x > r=%x\n", p,b,l, \
+ ((l) - ((char *)(p) - (char *)(b))), r), \
+ (((l) - ((char *)(p) - (char *)(b))) > (r)))
messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
{
messagetable_t *msg = (messagetable_t *)xmalloc(sizeof(messagetable_t));
@@ -1023,97 +1049,48 @@
if(!hi && !lo)
yyerror("Invalid messagetable block count 0");
- if(!hi && lo) /* Messagetable byteorder == native byteorder */
- {
#ifdef WORDS_BIGENDIAN
- if(byteorder != WRC_BO_LITTLE) goto out;
+ if(byteorder != WRC_BO_LITTLE) goto out;
#else
- if(byteorder != WRC_BO_BIG) goto out;
+ if(byteorder != WRC_BO_BIG) goto out;
#endif
- /* Resource byteorder != native byteorder */
-
- mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
- if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
- yyerror("Messagetable's blocks are outside of defined data");
- for(i = 0; i < nblk; i++)
- {
- msgtab_entry_t *mep, *next_mep;
- DWORD id;
-
- mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset);
-
- for(id = mbp[i].idlo; id <= mbp[i].idhi; id++)
- {
- if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
- yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined
data", (int)i, id);
- if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
- {
- WORD *wp = (WORD *)&mep[1];
- int l = mep->length/2 - 2; /* Length included header */
- int n;
-
- if(mep->length & 1)
- yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)",
id, (int)i, mep->length);
- for(n = 0; n < l; n++)
- wp[n] = BYTESWAP_WORD(wp[n]);
-
- }
- next_mep = (msgtab_entry_t *)(((char *)mep) + mep->length);
- mep->length = BYTESWAP_WORD(mep->length);
- mep->flags = BYTESWAP_WORD(mep->flags);
- mep = next_mep;
- }
-
- mbp[i].idlo = BYTESWAP_DWORD(mbp[i].idlo);
- mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi);
- mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset);
- }
- }
- if(hi && !lo) /* Messagetable byteorder != native byteorder */
- {
-#ifdef WORDS_BIGENDIAN
- if(byteorder == WRC_BO_LITTLE) goto out;
-#else
- if(byteorder == WRC_BO_BIG) goto out;
-#endif
- /* Resource byteorder == native byteorder */
-
- mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
- nblk = BYTESWAP_DWORD(nblk);
- if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
- yyerror("Messagetable's blocks are outside of defined data");
- for(i = 0; i < nblk; i++)
- {
- msgtab_entry_t *mep;
- DWORD id;
-
- mbp[i].idlo = BYTESWAP_DWORD(mbp[i].idlo);
- mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi);
- mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset);
- mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset);
-
- for(id = mbp[i].idlo; id <= mbp[i].idhi; id++)
- {
- mep->length = BYTESWAP_WORD(mep->length);
- mep->flags = BYTESWAP_WORD(mep->flags);
-
- if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
- yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined
data", (int)i, id);
- if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
- {
- WORD *wp = (WORD *)&mep[1];
- int l = mep->length/2 - 2; /* Length included header */
- int n;
-
- if(mep->length & 1)
- yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)",
id, (int)i, mep->length);
- for(n = 0; n < l; n++)
- wp[n] = BYTESWAP_WORD(wp[n]);
-
- }
- mep = (msgtab_entry_t *)(((char *)mep) + mep->length);
- }
- }
+ /* Resource byteorder != native byteorder */
+
+ mbp = BYTESWAP_DWORD((msgtab_block_t *)&(((DWORD *)rd->data)[1]));
+ if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
+ yyerror("[1] Messagetable's blocks are outside of defined data");
+ for(i = 0; i < nblk; i++)
+ {
+ msgtab_entry_t *mep, *next_mep;
+ DWORD id;
+
+ mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset);
+
+ for(id = mbp[i].idlo; id <= mbp[i].idhi; id++)
+ {
+ if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
+ yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of
defined data", (int)i, id);
+ if(BYTESWAP_DWORD(mep->flags) == 1) /* Docu says 'flags == 0x0001' for
unicode */
+ {
+ WORD *wp = (WORD *)&mep[1];
+ int l = BYTESWAP_DWORD(mep->length)/2 - 2; /* Length included header */
+ int n;
+
+ if(BYTESWAP_DWORD(mep->length) & 1)
+ yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)",
id, (int)i, BYTESWAP_DWORD(mep->length));
+ for(n = 0; n < l; n++)
+ wp[n] = BYTESWAP_WORD(wp[n]);
+
+ }
+ next_mep = (msgtab_entry_t *)(((char *)mep) + BYTESWAP_DWORD(mep->length));
+ mep->length = BYTESWAP_WORD(mep->length);
+ mep->flags = BYTESWAP_WORD(mep->flags);
+ mep = next_mep;
+ }
+
+ mbp[i].idlo = BYTESWAP_DWORD(mbp[i].idlo);
+ mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi);
+ mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset);
}
out:
Modified: branches/powerpc/reactos/tools/wrc/wrc.mak
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/wrc/wrc.m…
==============================================================================
--- branches/powerpc/reactos/tools/wrc/wrc.mak (original)
+++ branches/powerpc/reactos/tools/wrc/wrc.mak Sun Jun 25 01:27:06 2006
@@ -70,7 +70,7 @@
$(WRC_TARGET): $(WRC_OBJECTS) $(WRC_LIBS) | $(WRC_OUT)
$(ECHO_LD)
- ${host_gcc} $(WRC_OBJECTS) $(WRC_LIBS) $(WRC_HOST_LFLAGS) -o $@
+ ${host_gcc} -g $(WRC_OBJECTS) $(WRC_LIBS) $(WRC_HOST_LFLAGS) -o $@
$(WRC_INT_)dumpres.o: $(WRC_BASE_)dumpres.c | $(WRC_INT)
$(ECHO_CC)
@@ -82,7 +82,7 @@
$(WRC_INT_)newstruc.o: $(WRC_BASE_)newstruc.c | $(WRC_INT)
$(ECHO_CC)
- ${host_gcc} $(WRC_HOST_CFLAGS) -c $< -o $@
+ ${host_gcc} -g $(WRC_HOST_CFLAGS) -c $< -o $@
$(WRC_INT_)readres.o: $(WRC_BASE_)readres.c | $(WRC_INT)
$(ECHO_CC)
Modified: branches/powerpc/reactos/tools/wrc/wrctypes.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/wrc/wrcty…
==============================================================================
--- branches/powerpc/reactos/tools/wrc/wrctypes.h (original)
+++ branches/powerpc/reactos/tools/wrc/wrctypes.h Sun Jun 25 01:27:06 2006
@@ -80,8 +80,13 @@
#define WRC_HIBYTE(w) (((WORD)(w) >> 8) & 0xff)
#define WRC_LOWORD(d) ((DWORD)(d) & 0xffff)
#define WRC_HIWORD(d) (((DWORD)(d) >> 16) & 0xffff)
+#ifndef WORDS_BIGENDIAN
#define BYTESWAP_WORD(w) ((WORD)(((WORD)WRC_LOBYTE(w) << 8) +
(WORD)WRC_HIBYTE(w)))
#define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WRC_LOWORD(d)) << 16) +
((DWORD)BYTESWAP_WORD(WRC_HIWORD(d)))))
+#else
+#define BYTESWAP_WORD(w) ((WORD)(w))
+3define BYTESWAP_DWORD(d) ((DWORD)(d))
+#endif
/* Binary resource structure */
#define RES_BLOCKSIZE 512